summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CHANGELOG.txt13
-rw-r--r--GNUmakefile71
-rw-r--r--LICENSE3
-rw-r--r--Makefile67
-rw-r--r--README.html47
-rw-r--r--rgo/include/rgo.h66
-rw-r--r--test.c162
-rw-r--r--test.cc160
-rw-r--r--zap/include-priv/zap/priv.h (renamed from rgo/include-priv/rgo-priv.h)11
-rw-r--r--zap/include/zap/base.h68
-rw-r--r--zap/src/fastimpl.c (renamed from rgo/src/fastimpl.c)8
-rw-r--r--zap/src/fndbyte.c (renamed from rgo/src/fndbyte.c)12
-rw-r--r--zap/src/fndchr.c (renamed from rgo/src/fndchr.c)12
-rw-r--r--zap/src/memcmp.c (renamed from rgo/src/memcmp.c)6
-rw-r--r--zap/src/memcpy.c (renamed from rgo/src/memcpy.c)10
-rw-r--r--zap/src/memdup.c (renamed from rgo/src/memdup.c)12
-rw-r--r--zap/src/memeq.c (renamed from rgo/src/memeq.c)10
-rw-r--r--zap/src/memfill.c (renamed from rgo/src/memfill.c)10
-rw-r--r--zap/src/strcmp.c (renamed from rgo/src/strcmp.c)6
-rw-r--r--zap/src/strcpy.c (renamed from rgo/src/strcpy.c)10
-rw-r--r--zap/src/strdup.c (renamed from rgo/src/strdup.c)8
-rw-r--r--zap/src/streq.c (renamed from rgo/src/streq.c)10
-rw-r--r--zap/src/strfill.c (renamed from rgo/src/strfill.c)4
-rw-r--r--zap/src/strlen.c (renamed from rgo/src/strlen.c)10
25 files changed, 392 insertions, 405 deletions
diff --git a/.gitignore b/.gitignore
index ca10573..128428e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.a
*.o
+/build
/test
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index e5da972..e3e2f73 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,16 @@
+| B
+
+- memdup: Use sus_unlikely instead of __builtin_expect;
+- Rename project to zap (from rgo);
+- Remove global license file (useless with MPL);
+- Migrate test to C++ (for reasons which will be revealed later);
+- Restructure headers;
+- Add include guards to the private header;
+- Add attribute useret to functions;
+- Require GNU Make;
+- Compile position independent code;
+- Update readme;
+
| A
- Installation script: Create installation directories if they don't already exist;
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..5376911
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,71 @@
+# TOOLS
+
+# TOOL FLAGS
+
+ASFLAGS = \
+ -fPIC
+
+CFLAGS = \
+ -Izap/include \
+ -Izap/include-priv \
+ -O3 \
+ -fPIC \
+ -g \
+ -march=native \
+ -std=c99 \
+ -Wall \
+ -Wextra \
+ -Wpedantic
+
+# Uncomment to enable freestanding mode:
+#CFLAGS += \
+ -Dzap_priv_nostdlib \
+ -ffreestanding
+
+# Uncomment to disable assembly algorithms:
+#CFLAGS += -Dzap_priv_noasm
+
+# HEADERS
+
+HDRS = \
+ zap/include-priv/zap/priv.h \
+ zap/include/zap.h \
+
+# BINARIES
+
+OBJS = \
+ zap/src/fastimpl.o \
+ zap/src/fndbyte.o \
+ zap/src/fndchr.o \
+ zap/src/memcmp.o \
+ zap/src/memcpy.o \
+ zap/src/memdup.o \
+ zap/src/memeq.o \
+ zap/src/memfill.o \
+ zap/src/strcmp.o \
+ zap/src/strdup.o \
+ zap/src/streq.o \
+ zap/src/strfill.o \
+ zap/src/strcpy.o \
+ zap/src/strlen.o
+
+LIB = libzap.a
+
+# TARGETS
+
+.PHONY: clean install purge
+
+$(LIB): $(OBJS)
+ ar r $@ $^
+
+install: $(LIB)
+ mkdir -pm755 $(HDRDIR)
+ mkdir -pm755 $(LIBDIR)
+ install -Dm644 zap/include/zap.h $(HDRDIR)
+ install -Dm755 $(LIB) $(LIBDIR)/$(LIB)
+
+clean:
+ rm -fr $(OBJS)
+
+purge: clean
+ rm -fr $(LIB)
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 59f4152..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,3 +0,0 @@
-Copyright 2022 Gabriel Jensen.
-This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
-If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. \ No newline at end of file
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 264dbaa..0000000
--- a/Makefile
+++ /dev/null
@@ -1,67 +0,0 @@
-# TOOLS
-
-# TOOL FLAGS
-
-CFLAGS = \
- -Irgo/include \
- -Irgo/include-priv \
- -O3 \
- -g \
- -march=native \
- -std=c99 \
- -Wall \
- -Wextra \
- -Wpedantic
-
-# Uncomment to enable freestanding mode:
-#CFLAGS += \
- -Drgo_priv_nostdlib \
- -ffreestanding
-
-# Uncomment to disable assembly algorithms:
-#CFLAGS += -Drgo_priv_noasm
-
-# HEADERS
-
-HDRS = \
- rgo/include-priv/rgo-priv.h \
- rgo/include/rgo.h \
-
-# BINARIES
-
-OBJS = \
- rgo/src/fastimpl.o \
- rgo/src/fndbyte.o \
- rgo/src/fndchr.o \
- rgo/src/memcmp.o \
- rgo/src/memcpy.o \
- rgo/src/memdup.o \
- rgo/src/memeq.o \
- rgo/src/memfill.o \
- rgo/src/strcmp.o \
- rgo/src/strdup.o \
- rgo/src/streq.o \
- rgo/src/strfill.o \
- rgo/src/strcpy.o \
- rgo/src/strlen.o
-
-LIB = librgo.a
-
-# TARGETS
-
-.PHONY: clean install purge
-
-$(LIB): $(OBJS)
- ar r $@ $^
-
-install: $(LIB)
- mkdir -pm755 $(HDRDIR)
- mkdir -pm755 $(LIBDIR)
- install -Dm644 rgo/include/rgo.h $(HDRDIR)
- install -Dm755 $(LIB) $(LIBDIR)/$(LIB)
-
-clean:
- rm -fr $(OBJS)
-
-purge: clean
- rm -fr $(LIB)
diff --git a/README.html b/README.html
index e4b75e6..f460a0a 100644
--- a/README.html
+++ b/README.html
@@ -1,46 +1,13 @@
<!DOCTYPE html>
<html>
- <h1>rgo</h1>
- <p>rgo (<b>R</b>untime-al<b>GO</b>rithmic, pronounced as <i>are-go</i>) is a C/C++ library for runtime algorithmics on memory sequences.</p>
- <p>rgo, by default, implements it's algorithms in C. On some platforms (see section <i>Supported Platforms</i>), we implement them in assembly instead. This is to ensure that architecture features (such as SIMD) are used to make the algorithms as efficient as possible.</p>
+ <h1>zap</h1>
+ <p>A library for algorithmics.</p>
<p><i>Note: This library is still in it's early stages and is NOT anywhere near being fully optimised.</i></p>
<br />
- <h2>Supported Platforms</h2>
- <p>rgo is written in C except on some platforms where we have implemented the algorithms in assembly instead.</p>
- <p>Our implementations are only compatbile with System V-based operating systems. Support for Windows in a future release is being reflected.</p>
- <p>Currently, we have only implemented algorithms in assembly for the following architectures:</p>
- <ul>
- <li>
- <p>AMD64, including AVX;</p>
- </li>
- <li>
- <p>IA-32, including SSE and AVX;</p>
- </li>
- <li>
- <p><i>(Planned) Aarch64, including Neon and SVE;</i></p>
- </li>
- <li>
- <p><i>(Planned) Motorola 68000;</i></p>
- </li>
- <li>
- <p><i>(Planned) Power ISA, including AltiVec;</i></p>
- </li>
- <li>
- <p><i>(Planned) RISC-V;</i></p>
- </li>
- <li>
- <p><i>(Planned) Sparc;</i></p>
- </li>
- </ul>
- <p>They have been implemented using the GNU C extension for inline assembly, meaning a supporting compiler is required (such as Clang, GCC, and ICC).</p>
- <br />
- <h2>Building</h2>
- <p>The provided makefile has been tested to work with GNU make and BSD make and should work with other make implementations.</p>
- <p>The target <i>rgo</i> builds the static library file (located at <i>rgo/librgo.a</i>). The target <i>clean</i> removes all object files, whilst <i>purge</i> removes all object files and the static library file.</p>
+ <h2>Building and installation</h2>
+ <p>zap uses GNU Make for building.</p>
+ <p>The default target builds the static library file (located at <i>zap/libzap.a</i>). The target <i>clean</i> removes object files, whilst <i>purge</i> removes object files and the static library file.</p>
+ <p>Currently, zap doesn't support being compiled as a shared library out of the box, but the makefile could be modified to allow this.</p>
+ <p>The <i>install</i> target installs the headers to <i>$(HDRDIR)</i> and the library file to <i>$(LIBDIR)</i>.</p>
<p>Instructions for building the test program may be found on the first line of <i>test.c</i>.</p>
- <br />
- <h2>Copyright and License</h2>
- <p>Copyright 2022 Gabriel Jensen.</p>
- <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.</p>
- <p>If a copy of the MPL was not distributed with this file, You can obtain one at <i>https://mozilla.org/MPL/2.0/</i>.</p>
</html> \ No newline at end of file
diff --git a/rgo/include/rgo.h b/rgo/include/rgo.h
deleted file mode 100644
index d05b4dd..0000000
--- a/rgo/include/rgo.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright 2022 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-*/
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sus.h>
-
-#if !defined(rgo_ver)
-#define rgo_ver rgo_typlit_u64(0xA)
-
-#define rgo_typlit_s10(_lit) ((int_least16_t)( _lit))
-#define rgo_typlit_s20(_lit) ((int_least32_t)( _lit))
-#define rgo_typlit_s40(_lit) ((int_least64_t)( _lit))
-#define rgo_typlit_s8( _lit) ((int_least8_t)( _lit))
-#define rgo_typlit_u10(_lit) ((uint_least16_t)(_lit))
-#define rgo_typlit_u20(_lit) ((uint_least32_t)(_lit))
-#define rgo_typlit_u40(_lit) ((uint_least64_t)(_lit))
-#define rgo_typlit_u8( _lit) ((uint_least8_t)( _lit))
-#define rgo_typlit_usz(_lit) ((size_t)( _lit))
-
-#if defined(sus_lang_asm)
-
-.extern rgo_fndbyte
-.extern rgo_fndchr
-.extern rgo_memcmp
-.extern rgo_memcpy
-.extern rgo_memeq
-.extern rgo_memfill
-.extern rgo_strcmp
-.extern rgo_strcpy
-.extern rgo_streq
-.extern rgo_strfill
-.extern rgo_strlen
-
-#else
-
-#if defined(sus_lang_cxx)
-extern "C" {
-#endif
-
-extern bool const rgo_fastimpl;
-
-sus_attr_alloc sus_attr_allocsz(0x2) sus_attr_hot sus_attr_nothrw void * rgo_memdup( void const * ptr, size_t num);
-sus_attr_hot sus_attr_nothrw size_t rgo_fndbyte( void const * ptr, size_t num, uint_least8_t byte);
-sus_attr_hot sus_attr_nothrw size_t rgo_fndchr( char const * str, char chr);
-sus_attr_hot sus_attr_nothrw int_least8_t rgo_memcmp( void const * lstr,size_t num, void const * rstr);
-sus_attr_hot sus_attr_nothrw void rgo_memcpy( void const * in, size_t num, void * out);
-sus_attr_hot sus_attr_nothrw bool rgo_memeq( void const * lptr,size_t num, void const * rptr);
-sus_attr_hot sus_attr_nothrw void rgo_memfill( void * ptr, size_t num, uint_least8_t val);
-sus_attr_hot sus_attr_nothrw int_least8_t rgo_strcmp( char const * lstr,char const * rstr);
-sus_attr_hot sus_attr_nothrw size_t rgo_strcpy( char const * in, char * out);
-sus_attr_alloc sus_attr_hot sus_attr_nothrw char * rgo_strdup( char const * str);
-sus_attr_hot sus_attr_nothrw bool rgo_streq( char const * lstr,char const * rstr);
-sus_attr_hot sus_attr_nothrw void rgo_strfill( char * lstr,char chr);
-sus_attr_hot sus_attr_nothrw size_t rgo_strlen( char const * str);
-
-#endif
-#if defined(sus_lang_cxx)
-}
-#endif
-
-#endif
diff --git a/test.c b/test.c
deleted file mode 100644
index 4e7e146..0000000
--- a/test.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* cc -Irgo/include -L. -otest test.c -lrgo */
-
-#include <assert.h>
-#include <inttypes.h>
-#include <rgo.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-
-int main(void) {
- fprintf(stderr,"rgo test\n");
- fprintf(stderr,"arch: %s\n",sus_archstr);
- fprintf(stderr,"fast: %s\n",rgo_fastimpl ? "yes" : "no");
- fprintf(stderr,"\n");
- {
-#undef arrsz
-#define arrsz rgo_typlit_usz(0x8)
- uint64_t arr0[arrsz] = {0x0};
- rgo_memfill(arr0,arrsz * sizeof (uint64_t),rgo_typlit_u8(0x0));
- fprintf(stderr,"arr0[0]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x0)]);
- fprintf(stderr,"arr0[1]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x1)]);
- fprintf(stderr,"arr0[2]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x2)]);
- fprintf(stderr,"arr0[3]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x3)]);
- fprintf(stderr,"arr0[4]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x4)]);
- fprintf(stderr,"arr0[5]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x5)]);
- fprintf(stderr,"arr0[6]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x6)]);
- assert(arr0[rgo_typlit_usz(0x0)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x1)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x2)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x3)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x4)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x5)] == rgo_typlit_u40(0x0));
- assert(arr0[rgo_typlit_usz(0x6)] == rgo_typlit_u40(0x0));
- rgo_memfill(arr0,arrsz * sizeof (uint64_t),INT8_C(0x7F));
- fprintf(stderr,"arr0[0]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x0)]);
- fprintf(stderr,"arr0[1]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x1)]);
- fprintf(stderr,"arr0[2]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x2)]);
- fprintf(stderr,"arr0[3]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x3)]);
- fprintf(stderr,"arr0[4]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x4)]);
- fprintf(stderr,"arr0[5]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x5)]);
- fprintf(stderr,"arr0[6]: %" PRIX64 "\n",arr0[rgo_typlit_usz(0x6)]);
- assert(arr0[rgo_typlit_usz(0x0)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x1)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x2)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x3)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x4)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x5)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- assert(arr0[rgo_typlit_usz(0x6)] == rgo_typlit_u40(0x7F7F7F7F7F7F7F7F));
- uint64_t arr1[arrsz] = {0x0};
- rgo_memcpy(arr0,arrsz * sizeof (uint64_t),arr1);
- fprintf(stderr,"arr1[0]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x0)]);
- fprintf(stderr,"arr1[1]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x1)]);
- fprintf(stderr,"arr1[2]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x2)]);
- fprintf(stderr,"arr1[3]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x3)]);
- fprintf(stderr,"arr1[4]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x4)]);
- fprintf(stderr,"arr1[5]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x5)]);
- fprintf(stderr,"arr1[6]: %" PRIX64 "\n",arr1[rgo_typlit_usz(0x6)]);
- assert(arr1[rgo_typlit_usz(0x0)] == arr0[rgo_typlit_usz(0x0)]);
- assert(arr1[rgo_typlit_usz(0x1)] == arr0[rgo_typlit_usz(0x1)]);
- assert(arr1[rgo_typlit_usz(0x2)] == arr0[rgo_typlit_usz(0x2)]);
- assert(arr1[rgo_typlit_usz(0x3)] == arr0[rgo_typlit_usz(0x3)]);
- assert(arr1[rgo_typlit_usz(0x4)] == arr0[rgo_typlit_usz(0x4)]);
- assert(arr1[rgo_typlit_usz(0x5)] == arr0[rgo_typlit_usz(0x5)]);
- assert(arr1[rgo_typlit_usz(0x6)] == arr0[rgo_typlit_usz(0x6)]);
- bool const eq = rgo_memeq(arr1,arrsz,arr0);
- fprintf(stderr,"eq: %u\n",eq);
- assert(eq);
-#undef arrsz
- }
- fprintf(stderr,"\n");
- {
- char const * str0 = "Hello there! General Kenobi?";
- fprintf(stderr,"str0: \"%s\"\n",str0);
- size_t const strsz = rgo_strlen(str0);
- fprintf(stderr,"strsz: %zX\n",strsz);
- assert(strsz == rgo_typlit_usz(0x1C));
- }
- fprintf(stderr,"\n");
- {
- char const * restrict str = "Oh my science!";
- fprintf(stderr,"str: \"%s\"\n",str);
- size_t len = rgo_strlen(str);
- fprintf(stderr,"len: %zX\n",len);
- size_t pos0 = rgo_fndchr(str,' ');
- size_t pos1 = rgo_fndbyte(str,len,(uint_least8_t)' ');
- fprintf(stderr,"pos0: %zX\n",pos0);
- fprintf(stderr,"pos1: %zX\n",pos1);
- assert(pos0 == rgo_typlit_usz(0x2));
- assert(pos1 == pos0);
- str += pos0 + rgo_typlit_usz(0x1);
- len = rgo_strlen(str);
- pos0 = rgo_fndchr(str,' ');
- pos1 = rgo_fndbyte(str,len,(uint_least8_t)' ');
- fprintf(stderr,"pos0: %zX\n",pos0);
- fprintf(stderr,"pos1: %zX\n",pos1);
- assert(pos0 == rgo_typlit_usz(0x2));
- assert(pos1 == pos0);
- str += pos0 + rgo_typlit_usz(0x1);
- len = rgo_strlen(str);
- pos0 = rgo_fndchr(str,' ');
- pos1 = rgo_fndbyte(str,len,(uint_least8_t)' ');
- fprintf(stderr,"pos0: %zX\n",pos0);
- fprintf(stderr,"pos1: %zX\n",pos1);
- assert(pos0 == (size_t)-0x1);
- assert(pos1 == pos0);
- }
- fprintf(stderr,"\n");
- {
- char const str0[] = "What's up, my guy?";
- fprintf(stderr,"str0: \"%s\"\n",str0);
- char const str1[] = "What's up, my guy?";
- fprintf(stderr,"str1: \"%s\"\n",str1);
- char const str2[] = "I don't know you!";
- fprintf(stderr,"str2: \"%s\"\n",str2);
- bool const cmp0 = rgo_streq(str0,str1);
- bool const cmp1 = rgo_streq(str0,str2);
- bool const cmp2 = rgo_streq(str1,str2);
- fprintf(stderr,"cmp0: %u\n",cmp0);
- fprintf(stderr,"cmp1: %u\n",cmp1);
- fprintf(stderr,"cmp2: %u\n",cmp2);
- assert(cmp0);
- assert(!cmp1);
- assert(!cmp2);
- }
- fprintf(stderr,"\n");
- {
- char const str0[] = "What in the world are you doing?";
- fprintf(stderr,"str0: \"%s\"\n",str0);
- char str1[sizeof (str0)];
- assert(rgo_strcpy(str0,str1) == rgo_typlit_usz(0x20));
- fprintf(stderr,"str1: \"%s\"\n",str1);
- assert(rgo_streq(str0,str1));
- }
- fprintf(stderr,"\n");
- {
- char const str0[] = "Oej Moej Goejd";
- char const str1[] = "Er jeg egentlig okay med AWP?";
- fprintf(stderr,"str0: \"%s\"\n",str0);
- fprintf(stderr,"str1: \"%s\"\n",str1);
- int_least8_t const cmp0 = rgo_strcmp(str0,str1);
- int_least8_t const cmp1 = rgo_strcmp(str0,str0);
- int_least8_t const cmp2 = rgo_strcmp(str1,str0);
- size_t const leastsz = sizeof (str0) < sizeof (str1) ? sizeof (str0) : sizeof (str1);
- int_least8_t const cmp3 = rgo_memcmp(str0,leastsz,str1);
- int_least8_t const cmp4 = rgo_memcmp(str0,leastsz,str0);
- int_least8_t const cmp5 = rgo_memcmp(str1,leastsz,str0);
- fprintf(stderr,"cmp0: %i\n",cmp0);
- fprintf(stderr,"cmp1: %i\n",cmp1);
- fprintf(stderr,"cmp2: %i\n",cmp2);
- fprintf(stderr,"cmp3: %i\n",cmp3);
- fprintf(stderr,"cmp4: %i\n",cmp4);
- fprintf(stderr,"cmp5: %i\n",cmp5);
- assert(cmp0 > rgo_typlit_s8(0x0));
- assert(cmp1 == rgo_typlit_s8(0x0));
- assert(cmp2 < rgo_typlit_s8(0x0));
- assert(cmp3 > rgo_typlit_s8(0x0));
- assert(cmp4 == rgo_typlit_s8(0x0));
- assert(cmp5 < rgo_typlit_s8(0x0));
- }
- fprintf(stderr,"\n");
- printf("All tests have passed!\n");
-}
diff --git a/test.cc b/test.cc
new file mode 100644
index 0000000..7d4799e
--- /dev/null
+++ b/test.cc
@@ -0,0 +1,160 @@
+/* c++ -Izap/include -L. -otest test.cc -lzap */
+
+#include <cassert>
+#include <cinttypes>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <zap/base.h>
+
+int main(void) {
+ ::std::fprintf(stderr,"zap test\n");
+ ::std::fprintf(stderr,"arch: %s\n",sus_archstr);
+ ::std::fprintf(stderr,"fast: %s\n",::zap_fastimpl ? "yes" : "no");
+ ::std::fprintf(stderr,"\n");
+ {
+ constexpr auto arrsz {zap_typlit_usz(0x8)};
+ ::std::uint_least64_t arr0[arrsz] {zap_typlit_u40(0x0)};
+ ::zap_memfill(arr0,arrsz * sizeof (::std::uint_least64_t),zap_typlit_u8(0x0));
+ ::std::fprintf(stderr,"arr0[0]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x0)]);
+ ::std::fprintf(stderr,"arr0[1]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x1)]);
+ ::std::fprintf(stderr,"arr0[2]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x2)]);
+ ::std::fprintf(stderr,"arr0[3]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x3)]);
+ ::std::fprintf(stderr,"arr0[4]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x4)]);
+ ::std::fprintf(stderr,"arr0[5]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x5)]);
+ ::std::fprintf(stderr,"arr0[6]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x6)]);
+ assert(arr0[zap_typlit_usz(0x0)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x1)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x2)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x3)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x4)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x5)] == zap_typlit_u40(0x0));
+ assert(arr0[zap_typlit_usz(0x6)] == zap_typlit_u40(0x0));
+ ::zap_memfill(arr0,arrsz * sizeof (::std::uint_least64_t),zap_typlit_u8(0x7F));
+ ::std::fprintf(stderr,"arr0[0]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x0)]);
+ ::std::fprintf(stderr,"arr0[1]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x1)]);
+ ::std::fprintf(stderr,"arr0[2]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x2)]);
+ ::std::fprintf(stderr,"arr0[3]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x3)]);
+ ::std::fprintf(stderr,"arr0[4]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x4)]);
+ ::std::fprintf(stderr,"arr0[5]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x5)]);
+ ::std::fprintf(stderr,"arr0[6]: %" PRIX64 "\n",arr0[zap_typlit_usz(0x6)]);
+ assert(arr0[zap_typlit_usz(0x0)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x1)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x2)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x3)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x4)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x5)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ assert(arr0[zap_typlit_usz(0x6)] == zap_typlit_u40(0x7F7F7F7F7F7F7F7F));
+ ::std::uint_least64_t arr1[arrsz] {zap_typlit_u40(0x0)};
+ ::zap_memcpy(arr0,arrsz * sizeof (::std::uint_least64_t),arr1);
+ ::std::fprintf(stderr,"arr1[0]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x0)]);
+ ::std::fprintf(stderr,"arr1[1]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x1)]);
+ ::std::fprintf(stderr,"arr1[2]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x2)]);
+ ::std::fprintf(stderr,"arr1[3]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x3)]);
+ ::std::fprintf(stderr,"arr1[4]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x4)]);
+ ::std::fprintf(stderr,"arr1[5]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x5)]);
+ ::std::fprintf(stderr,"arr1[6]: %" PRIX64 "\n",arr1[zap_typlit_usz(0x6)]);
+ assert(arr1[zap_typlit_usz(0x0)] == arr0[zap_typlit_usz(0x0)]);
+ assert(arr1[zap_typlit_usz(0x1)] == arr0[zap_typlit_usz(0x1)]);
+ assert(arr1[zap_typlit_usz(0x2)] == arr0[zap_typlit_usz(0x2)]);
+ assert(arr1[zap_typlit_usz(0x3)] == arr0[zap_typlit_usz(0x3)]);
+ assert(arr1[zap_typlit_usz(0x4)] == arr0[zap_typlit_usz(0x4)]);
+ assert(arr1[zap_typlit_usz(0x5)] == arr0[zap_typlit_usz(0x5)]);
+ assert(arr1[zap_typlit_usz(0x6)] == arr0[zap_typlit_usz(0x6)]);
+ auto const eq {::zap_memeq(arr1,arrsz,arr0)};
+ ::std::fprintf(stderr,"eq: %u\n",eq);
+ assert(eq);
+ }
+ ::std::fprintf(stderr,"\n");
+ {
+ auto const str {"Hello there! General Kenobi?"};
+ ::std::fprintf(stderr,"str: \"%s\"\n",str);
+ auto const strsz {::zap_strlen(str)};
+ ::std::fprintf(stderr,"strsz: %zX\n",strsz);
+ assert(strsz == zap_typlit_usz(0x1C));
+ }
+ ::std::fprintf(stderr,"\n");
+ {
+ auto str {"Oh my science!"};
+ ::std::fprintf(stderr,"str: \"%s\"\n",str);
+ auto len {::zap_strlen(str)};
+ ::std::fprintf(stderr,"len: %zX\n",len);
+ ::std::size_t pos0 = ::zap_fndchr(str,' ');
+ ::std::size_t pos1 = ::zap_fndbyte(str,len,(::std::uint_least8_t)' ');
+ ::std::fprintf(stderr,"pos0: %zX\n",pos0);
+ ::std::fprintf(stderr,"pos1: %zX\n",pos1);
+ assert(pos0 == zap_typlit_usz(0x2));
+ assert(pos1 == pos0);
+ str += pos0 + zap_typlit_usz(0x1);
+ len = ::zap_strlen(str);
+ pos0 = ::zap_fndchr(str,' ');
+ pos1 = ::zap_fndbyte(str,len,(::std::uint_least8_t)' ');
+ ::std::fprintf(stderr,"pos0: %zX\n",pos0);
+ ::std::fprintf(stderr,"pos1: %zX\n",pos1);
+ assert(pos0 == zap_typlit_usz(0x2));
+ assert(pos1 == pos0);
+ str += pos0 + zap_typlit_usz(0x1);
+ len = ::zap_strlen(str);
+ pos0 = ::zap_fndchr(str,' ');
+ pos1 = ::zap_fndbyte(str,len,(::std::uint_least8_t)' ');
+ ::std::fprintf(stderr,"pos0: %zX\n",pos0);
+ ::std::fprintf(stderr,"pos1: %zX\n",pos1);
+ assert(pos0 == (::std::size_t)-0x1);
+ assert(pos1 == pos0);
+ }
+ ::std::fprintf(stderr,"\n");
+ {
+ char const str0[] = "What's up, my guy?";
+ ::std::fprintf(stderr,"str0: \"%s\"\n",str0);
+ char const str1[] = "What's up, my guy?";
+ ::std::fprintf(stderr,"str1: \"%s\"\n",str1);
+ char const str2[] = "I don't know you!";
+ ::std::fprintf(stderr,"str2: \"%s\"\n",str2);
+ bool const cmp0 = ::zap_streq(str0,str1);
+ bool const cmp1 = ::zap_streq(str0,str2);
+ bool const cmp2 = ::zap_streq(str1,str2);
+ ::std::fprintf(stderr,"cmp0: %u\n",cmp0);
+ ::std::fprintf(stderr,"cmp1: %u\n",cmp1);
+ ::std::fprintf(stderr,"cmp2: %u\n",cmp2);
+ assert(cmp0);
+ assert(!cmp1);
+ assert(!cmp2);
+ }
+ ::std::fprintf(stderr,"\n");
+ {
+ char const str0[] = "What in the world are you doing?";
+ ::std::fprintf(stderr,"str0: \"%s\"\n",str0);
+ char str1[sizeof (str0)];
+ assert(::zap_strcpy(str0,str1) == zap_typlit_usz(0x20));
+ ::std::fprintf(stderr,"str1: \"%s\"\n",str1);
+ assert(::zap_streq(str0,str1));
+ }
+ ::std::fprintf(stderr,"\n");
+ {
+ char const str0[] {"Oej Moej Goejd"};
+ char const str1[] {"Er jeg egentlig okay med AWP?"};
+ ::std::fprintf(stderr,"str0: \"%s\"\n",str0);
+ ::std::fprintf(stderr,"str1: \"%s\"\n",str1);
+ auto const cmp0 {::zap_strcmp(str0,str1)};
+ auto const cmp1 {::zap_strcmp(str0,str0)};
+ auto const cmp2 {::zap_strcmp(str1,str0)};
+ auto const leastsz {sizeof (str0) < sizeof (str1) ? sizeof (str0) : sizeof (str1)};
+ auto const cmp3 {::zap_memcmp(str0,leastsz,str1)};
+ auto const cmp4 {::zap_memcmp(str0,leastsz,str0)};
+ auto const cmp5 {::zap_memcmp(str1,leastsz,str0)};
+ ::std::fprintf(stderr,"cmp0: %i\n",cmp0);
+ ::std::fprintf(stderr,"cmp1: %i\n",cmp1);
+ ::std::fprintf(stderr,"cmp2: %i\n",cmp2);
+ ::std::fprintf(stderr,"cmp3: %i\n",cmp3);
+ ::std::fprintf(stderr,"cmp4: %i\n",cmp4);
+ ::std::fprintf(stderr,"cmp5: %i\n",cmp5);
+ assert(cmp0 > zap_typlit_s8(0x0));
+ assert(cmp1 == zap_typlit_s8(0x0));
+ assert(cmp2 < zap_typlit_s8(0x0));
+ assert(cmp3 > zap_typlit_s8(0x0));
+ assert(cmp4 == zap_typlit_s8(0x0));
+ assert(cmp5 < zap_typlit_s8(0x0));
+ }
+ ::std::fprintf(stderr,"\n");
+ ::std::fprintf(stderr,"All tests have passed!\n");
+}
diff --git a/rgo/include-priv/rgo-priv.h b/zap/include-priv/zap/priv.h
index 2669e92..b051589 100644
--- a/rgo/include-priv/rgo-priv.h
+++ b/zap/include-priv/zap/priv.h
@@ -4,13 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#pragma once
+#if !defined(zap_hdr_priv)
+#define zap_hdr_priv
-#include <rgo.h>
+#include <zap/base.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(__GNUC__) && defined(sus_os_unix) && !defined(rgo_priv_noasm) && (defined(sus_arch_amd64) || defined(sus_arch_ia32))
-#define rgo_priv_fastimpl
+#if (defined(sus_cmpl_gnu) || defined(sus_cmpl_llvm)) && defined(sus_os_unix) && !defined(zap_priv_noasm) && (defined(sus_arch_amd64) || defined(sus_arch_ia32))
+#define zap_priv_fastimpl
+#endif
+
#endif
diff --git a/zap/include/zap/base.h b/zap/include/zap/base.h
new file mode 100644
index 0000000..48e0fb1
--- /dev/null
+++ b/zap/include/zap/base.h
@@ -0,0 +1,68 @@
+/*
+ Copyright 2022 Gabriel Jensen.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+*/
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <susinfo.h>
+
+#if !defined(zap_hdr_base)
+#define zap_hdr_base
+
+#define zap_typlit_s10(_lit) ((int_least16_t)( _lit))
+#define zap_typlit_s20(_lit) ((int_least32_t)( _lit))
+#define zap_typlit_s40(_lit) ((int_least64_t)( _lit))
+#define zap_typlit_s8( _lit) ((int_least8_t)( _lit))
+#define zap_typlit_u10(_lit) ((uint_least16_t)(_lit))
+#define zap_typlit_u20(_lit) ((uint_least32_t)(_lit))
+#define zap_typlit_u40(_lit) ((uint_least64_t)(_lit))
+#define zap_typlit_u8( _lit) ((uint_least8_t)( _lit))
+#define zap_typlit_usz(_lit) ((size_t)( _lit))
+
+#define zap_ver zap_typlit_u64(0xB)
+
+#if defined(sus_lang_asm)
+
+.extern zap_fndbyte
+.extern zap_fndchr
+.extern zap_memcmp
+.extern zap_memcpy
+.extern zap_memeq
+.extern zap_memfill
+.extern zap_strcmp
+.extern zap_strcpy
+.extern zap_streq
+.extern zap_strfill
+.extern zap_strlen
+
+#else
+
+#if defined(sus_lang_cxx)
+extern "C" {
+#endif
+
+extern bool const zap_fastimpl;
+
+sus_attr_alloc sus_attr_allocsz(0x2) sus_attr_hot sus_attr_nothrw sus_attr_useret void * zap_memdup( void const * ptr, size_t num);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndbyte( void const * ptr, size_t num, uint_least8_t byte);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndchr( char const * str, char chr);
+sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_memcmp( void const * lstr,size_t num, void const * rstr);
+sus_attr_hot sus_attr_nothrw void zap_memcpy( void const * in, size_t num, void * out);
+sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_memeq( void const * lptr,size_t num, void const * rptr);
+sus_attr_hot sus_attr_nothrw void zap_memfill( void * ptr, size_t num, uint_least8_t val);
+sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_strcmp( char const * lstr,char const * rstr);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strcpy( char const * in, char * out);
+sus_attr_alloc sus_attr_hot sus_attr_nothrw sus_attr_useret char * zap_strdup( char const * str);
+sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_streq( char const * lstr,char const * rstr);
+sus_attr_hot sus_attr_nothrw void zap_strfill( char * lstr,char chr);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strlen( char const * str);
+
+#endif
+#if defined(sus_lang_cxx)
+}
+#endif
+
+#endif
diff --git a/rgo/src/fastimpl.c b/zap/src/fastimpl.c
index 3d3e67f..71ded00 100644
--- a/rgo/src/fastimpl.c
+++ b/zap/src/fastimpl.c
@@ -4,13 +4,13 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdbool.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
-bool const rgo_fastimpl = true;
+#if defined(zap_priv_fastimpl)
+bool const zap_fastimpl = true;
#else
-bool const rgo_fastimpl = false;
+bool const zap_fastimpl = false;
#endif
diff --git a/rgo/src/fndbyte.c b/zap/src/fndbyte.c
index 79b4aaf..85fc14d 100644
--- a/rgo/src/fndbyte.c
+++ b/zap/src/fndbyte.c
@@ -4,16 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_fndbyte\n"
+ ".global zap_fndbyte\n"
- "rgo_fndbyte:\n"
+ "zap_fndbyte:\n"
/*
void const * ptr
size_t num
@@ -68,10 +68,10 @@ __asm__ (
#endif
);
#else
-size_t rgo_fndbyte(void const * const _ptr,size_t const _num,uint_least8_t const _byte) {
+size_t zap_fndbyte(void const * const _ptr,size_t const _num,uint_least8_t const _byte) {
uint_least8_t const * ptr = (uint_least8_t const *)_ptr;
uint_least8_t const * const afterbuf = ptr + _num;
for (;ptr != afterbuf;++ptr) {sus_unlikely (*ptr == _byte) {return ptr - (uint_least8_t const *)_ptr;}}
- return rgo_typlit_usz(-0x1);
+ return zap_typlit_usz(-0x1);
}
#endif
diff --git a/rgo/src/fndchr.c b/zap/src/fndchr.c
index 74aac4d..cd5458f 100644
--- a/rgo/src/fndchr.c
+++ b/zap/src/fndchr.c
@@ -4,16 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_fndchr\n"
+ ".global zap_fndchr\n"
- "rgo_fndchr:\n"
+ "zap_fndchr:\n"
/*
char const * str
char chr
@@ -59,12 +59,12 @@ __asm__ (
#endif
);
#else
-size_t rgo_fndchr(char const * const _str,char const _chr) {
+size_t zap_fndchr(char const * const _str,char const _chr) {
char const * pos = _str;
for (;;++pos) {
char const chr = *pos;
sus_unlikely (chr == _chr) {return (size_t)(pos - _str);}
- sus_unlikely (chr == '\x0') {return rgo_typlit_usz(-0x1);}
+ sus_unlikely (chr == '\x0') {return zap_typlit_usz(-0x1);}
}
sus_unreach();
}
diff --git a/rgo/src/memcmp.c b/zap/src/memcmp.c
index bb134f4..810bab0 100644
--- a/rgo/src/memcmp.c
+++ b/zap/src/memcmp.c
@@ -4,11 +4,11 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
-int_least8_t rgo_memcmp(void const * const _lstr,size_t const _num,void const * const _rstr) {
+int_least8_t zap_memcmp(void const * const _lstr,size_t const _num,void const * const _rstr) {
unsigned char const * lpos = (unsigned char const *)_lstr;
unsigned char const * rpos = (unsigned char const *)_rstr;
unsigned char const * const afterlbuf = lpos + _num;
@@ -17,5 +17,5 @@ int_least8_t rgo_memcmp(void const * const _lstr,size_t const _num,void const *
unsigned char const rbyte = *rpos;
sus_likely (lbyte != rbyte) {return lbyte < rbyte ? (int_least8_t)INT8_MIN : (int_least8_t)INT8_MAX;}
}
- return rgo_typlit_s8(0x0);
+ return zap_typlit_s8(0x0);
}
diff --git a/rgo/src/memcpy.c b/zap/src/memcpy.c
index 33ca41c..1b40832 100644
--- a/rgo/src/memcpy.c
+++ b/zap/src/memcpy.c
@@ -4,16 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_memcpy\n"
+ ".global zap_memcpy\n"
- "rgo_memcpy:\n"
+ "zap_memcpy:\n"
/*
void const * in
size_t num
@@ -132,7 +132,7 @@ __asm__ (
#endif
);
#else
-void rgo_memcpy(void const * const _in,size_t const _num,void * const _out) {
+void zap_memcpy(void const * const _in,size_t const _num,void * const _out) {
uint_least8_t const * in = (uint_least8_t const *)_in;
uint_least8_t * out = (uint_least8_t *)_out;
uint_least8_t const * const afterbuf = in + _num;
diff --git a/rgo/src/memdup.c b/zap/src/memdup.c
index 9cdf3cb..3670eb3 100644
--- a/rgo/src/memdup.c
+++ b/zap/src/memdup.c
@@ -4,17 +4,19 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdlib.h>
-void * rgo_memdup(sus_attr_unused void const * const _ptr,sus_attr_unused size_t const _num) {
-#if !defined(rgo_priv_nostdlib)
+void * zap_memdup(sus_attr_unused void const * const _ptr,sus_attr_unused size_t const _num) {
+#if !defined(zap_priv_nostdlib)
void * const dup = malloc(_num);
- if (__builtin_expect (dup == NULL,0x0l)) {return NULL;}
- rgo_memcpy(_ptr,_num,dup);
+ sus_unlikely (dup == NULL) {return NULL;}
+ zap_memcpy(_ptr,_num,dup);
return dup;
#else
return NULL;
#endif
}
+
+
diff --git a/rgo/src/memeq.c b/zap/src/memeq.c
index d2d51a2..f9717ad 100644
--- a/rgo/src/memeq.c
+++ b/zap/src/memeq.c
@@ -4,17 +4,17 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_memeq\n"
+ ".global zap_memeq\n"
- "rgo_memeq:\n"
+ "zap_memeq:\n"
/*
void const * lptr
size_t num
@@ -100,7 +100,7 @@ __asm__ (
#endif
);
#else
-bool rgo_memeq(void const * const _lptr,size_t const _num,void const * const _rptr) {
+bool zap_memeq(void const * const _lptr,size_t const _num,void const * const _rptr) {
uint_least8_t const * lpos = (uint_least8_t const *)_lptr;
uint_least8_t const * rpos = (uint_least8_t const *)_rptr;
uint_least8_t const * const afterbuf = lpos + _num;
diff --git a/rgo/src/memfill.c b/zap/src/memfill.c
index d4c27e0..70982c4 100644
--- a/rgo/src/memfill.c
+++ b/zap/src/memfill.c
@@ -4,16 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_memfill\n"
+ ".global zap_memfill\n"
- "rgo_memfill:\n"
+ "zap_memfill:\n"
/*
void const * ptr
size_t num
@@ -50,7 +50,7 @@ __asm__ (
#endif
);
#else
-void rgo_memfill(void * const _ptr,size_t const _num,uint_least8_t const _byte) {
+void zap_memfill(void * const _ptr,size_t const _num,uint_least8_t const _byte) {
uint_least8_t * pos = (uint_least8_t *)_ptr;
uint_least8_t * const afterbuf = pos + _num;
for (;pos != afterbuf;++pos) {*pos = _byte;}
diff --git a/rgo/src/strcmp.c b/zap/src/strcmp.c
index aea821b..9e11601 100644
--- a/rgo/src/strcmp.c
+++ b/zap/src/strcmp.c
@@ -4,18 +4,18 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdint.h>
-int_least8_t rgo_strcmp(char const * const _lstr,char const * const _rstr) {
+int_least8_t zap_strcmp(char const * const _lstr,char const * const _rstr) {
unsigned char const * lpos = (unsigned char const *)_lstr;
unsigned char const * rpos = (unsigned char const *)_rstr;
for (;;++lpos,++rpos) {
unsigned char const lchr = *lpos;
unsigned char const rchr = *rpos;
sus_likely (lchr != rchr) {return lchr < rchr ? (int_least8_t)INT8_MIN : (int_least8_t)INT8_MAX;}
- sus_unlikely (lchr == (unsigned char)0x0) {return rgo_typlit_s8(0x0);}
+ sus_unlikely (lchr == (unsigned char)0x0) {return zap_typlit_s8(0x0);}
}
sus_unreach();
}
diff --git a/rgo/src/strcpy.c b/zap/src/strcpy.c
index 1d27be3..3dc3e0f 100644
--- a/rgo/src/strcpy.c
+++ b/zap/src/strcpy.c
@@ -4,15 +4,15 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_strcpy\n"
+ ".global zap_strcpy\n"
- "rgo_strcpy:\n"
+ "zap_strcpy:\n"
/*
char const * in
char const * out
@@ -56,7 +56,7 @@ __asm__ (
#endif
);
#else
-size_t rgo_strcpy(char const * const _in,char * const _out) {
+size_t zap_strcpy(char const * const _in,char * const _out) {
char const * inpos = _in;
char * outpos = _out;
for (;;++inpos,++outpos) {
diff --git a/rgo/src/strdup.c b/zap/src/strdup.c
index 786de55..785a93b 100644
--- a/rgo/src/strdup.c
+++ b/zap/src/strdup.c
@@ -4,13 +4,13 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdlib.h>
-char * rgo_strdup(sus_attr_unused char const * const _str) {
-#if !defined(rgo_priv_nostdlib)
- return rgo_memdup(_str,rgo_strlen(_str) + rgo_typlit_usz(0x1));
+char * zap_strdup(sus_attr_unused char const * const _str) {
+#if !defined(zap_priv_nostdlib)
+ return zap_memdup(_str,zap_strlen(_str) + zap_typlit_usz(0x1));
#else
return NULL;
#endif
diff --git a/rgo/src/streq.c b/zap/src/streq.c
index feecf15..6425ef7 100644
--- a/rgo/src/streq.c
+++ b/zap/src/streq.c
@@ -4,16 +4,16 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdbool.h>
#include <stdint.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_streq\n"
+ ".global zap_streq\n"
- "rgo_streq:\n"
+ "zap_streq:\n"
/*
char const * lstr
char const * rstr
@@ -67,7 +67,7 @@ __asm__ (
#endif
);
#else
-bool rgo_streq(char const * const _lstr,char const * const _rstr) {
+bool zap_streq(char const * const _lstr,char const * const _rstr) {
char const * lpos = _lstr;
char const * rpos = _rstr;
for (;;++lpos,++rpos) {
diff --git a/rgo/src/strfill.c b/zap/src/strfill.c
index 6fe3f48..a113094 100644
--- a/rgo/src/strfill.c
+++ b/zap/src/strfill.c
@@ -4,8 +4,8 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stdint.h>
-void rgo_strfill(char * const _str,char const _chr) {rgo_memfill(_str,rgo_strlen(_str),(uint_least8_t)_chr);}
+void zap_strfill(char * const _str,char const _chr) {zap_memfill(_str,zap_strlen(_str),(uint_least8_t)_chr);}
diff --git a/rgo/src/strlen.c b/zap/src/strlen.c
index b937fb9..c1e8959 100644
--- a/rgo/src/strlen.c
+++ b/zap/src/strlen.c
@@ -4,15 +4,15 @@
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
-#include <rgo-priv.h>
+#include <zap/priv.h>
#include <stddef.h>
-#if defined(rgo_priv_fastimpl)
+#if defined(zap_priv_fastimpl)
__asm__ (
- ".global rgo_strlen\n"
+ ".global zap_strlen\n"
- "rgo_strlen:\n"
+ "zap_strlen:\n"
/*
char const * str
*/
@@ -45,7 +45,7 @@ __asm__ (
#endif
);
#else
-size_t rgo_strlen(char const * const _str) {
+size_t zap_strlen(char const * const _str) {
char const * pos = _str;
for (;;++pos) {
char const chr = *pos;