diff options
Diffstat (limited to 'zap')
-rw-r--r-- | zap/GNUmakefile | 70 | ||||
-rw-r--r-- | zap/include-private/zap/priv.h | 8 | ||||
-rw-r--r-- | zap/include/zap/bs.h | 8 | ||||
-rw-r--r-- | zap/include/zap/mem.h | 2 | ||||
-rw-r--r-- | zap/source/amd64/mem/fndbyte.S (renamed from zap/src/mem/fndbyte.S) | 21 | ||||
-rw-r--r-- | zap/source/amd64/mem/fndchr.S (renamed from zap/src/mem/fndchr.S) | 20 | ||||
-rw-r--r-- | zap/source/amd64/mem/foreach.S (renamed from zap/src/mem/foreach.S) | 22 | ||||
-rw-r--r-- | zap/source/amd64/mem/memcat.c (renamed from zap/src/mem/memcat.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/memcp.S (renamed from zap/src/mem/memcp.S) | 21 | ||||
-rw-r--r-- | zap/source/amd64/mem/memeq.S (renamed from zap/src/mem/memeq.S) | 21 | ||||
-rw-r--r-- | zap/source/amd64/mem/memfill.S (renamed from zap/src/mem/memfill.S) | 21 | ||||
-rw-r--r-- | zap/source/amd64/mem/memgen.c (renamed from zap/src/mem/memgen.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/strcat.c (renamed from zap/src/mem/strcat.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/strcp.S (renamed from zap/src/mem/strcp.S) | 20 | ||||
-rw-r--r-- | zap/source/amd64/mem/streq.S (renamed from zap/src/mem/streq.S) | 20 | ||||
-rw-r--r-- | zap/source/amd64/mem/strfill.S (renamed from zap/src/mem/strfill.S) | 20 | ||||
-rw-r--r-- | zap/source/amd64/mem/strlen.S (renamed from zap/src/mem/strlen.S) | 19 | ||||
-rw-r--r-- | zap/source/amd64/mem/utf8dec.c (renamed from zap/src/mem/utf8dec.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/utf8declen.c (renamed from zap/src/mem/utf8declen.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/utf8enc.S (renamed from zap/src/mem/utf8enc.S) | 23 | ||||
-rw-r--r-- | zap/source/amd64/mem/utf8enclen.S (renamed from zap/src/mem/utf8enclen.S) | 19 | ||||
-rw-r--r-- | zap/source/amd64/mem/win1252dec.c (renamed from zap/src/mem/win1252dec.c) | 0 | ||||
-rw-r--r-- | zap/source/amd64/mem/win1252enc.c (renamed from zap/src/mem/win1252enc.c) | 0 | ||||
-rw-r--r-- | zap/src/mem/memcmp.c | 21 | ||||
-rw-r--r-- | zap/src/mem/strcmp.c | 23 |
25 files changed, 80 insertions, 299 deletions
diff --git a/zap/GNUmakefile b/zap/GNUmakefile index 58a85ce..442cb32 100644 --- a/zap/GNUmakefile +++ b/zap/GNUmakefile @@ -2,6 +2,10 @@ # 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/. +ifneq "$(arch)" "amd64" +$(error invalid architecture) +endif + # TOOLS #CC = clang @@ -9,49 +13,47 @@ # TOOL FLAGS -ASFLAGS += \ +ASFLAGS := \ -g \ -march=native -CFLAGS += \ +CFLAGS := \ -Ofast \ + -Wall \ + -Wextra \ + -Wpedantic \ -fPIC \ -ffreestanding \ -g \ -march=native \ - -std=c90 \ - -Wall \ - -Wextra \ - -Wpedantic + -std=c90 -CPPFLAGS += \ +CPPFLAGS := \ -Iinclude \ - -Iinclude-private + -Iinclude-private \ # ARTEFACTS -OBJS = \ - src/mem/fndbyte.o \ - src/mem/fndchr.o \ - src/mem/foreach.o \ - src/mem/memcat.o \ - src/mem/memcmp.o \ - src/mem/memcp.o \ - src/mem/memeq.o \ - src/mem/memfill.o \ - src/mem/memgen.o \ - src/mem/strcat.o \ - src/mem/strcmp.o \ - src/mem/streq.o \ - src/mem/strfill.o \ - src/mem/strcp.o \ - src/mem/strlen.o \ - src/mem/utf8dec.o \ - src/mem/utf8declen.o \ - src/mem/utf8enc.o \ - src/mem/utf8enclen.o \ - src/mem/win1252dec.o \ - src/mem/win1252enc.o +OBJS = \ + source/$(arch)/mem/fndbyte.o \ + source/$(arch)/mem/fndchr.o \ + source/$(arch)/mem/foreach.o \ + source/$(arch)/mem/memcat.o \ + source/$(arch)/mem/memcp.o \ + source/$(arch)/mem/memeq.o \ + source/$(arch)/mem/memfill.o \ + source/$(arch)/mem/memgen.o \ + source/$(arch)/mem/strcat.o \ + source/$(arch)/mem/streq.o \ + source/$(arch)/mem/strfill.o \ + source/$(arch)/mem/strcp.o \ + source/$(arch)/mem/strlen.o \ + source/$(arch)/mem/utf8dec.o \ + source/$(arch)/mem/utf8declen.o \ + source/$(arch)/mem/utf8enc.o \ + source/$(arch)/mem/utf8enclen.o \ + source/$(arch)/mem/win1252dec.o \ + source/$(arch)/mem/win1252enc.o LIB = libzap.a @@ -59,11 +61,17 @@ LIB = libzap.a # TARGETS -.PHONY: clean purge +.PHONY: clean install purge $(LIB): $(OBJS) $(AR) r $@ $^ +install: $(LIB) + mkdir -pm755 "$(HDRDIR)/zap" + mkdir -pm755 "$(LIBDIR)" + install -m644 "zap/include/zap/"*".h" "$(HDRDIR)/zap" + install -m755 "$(LIB)" "$(LIBDIR)" + clean: $(RM) $(OBJS) diff --git a/zap/include-private/zap/priv.h b/zap/include-private/zap/priv.h index c47d802..0aeafaa 100644 --- a/zap/include-private/zap/priv.h +++ b/zap/include-private/zap/priv.h @@ -7,14 +7,6 @@ #if !defined(zap_priv_hdr_priv) #define zap_priv_hdr_priv -#if !defined(__amd64__) -#error zapq only supports AMD64! -#endif - -#if !defined(__ASSEMBLER__) #include <zap/bs.h> -#include <sus/extra.h> -#endif - #endif diff --git a/zap/include/zap/bs.h b/zap/include/zap/bs.h index c2a7053..4d8d004 100644 --- a/zap/include/zap/bs.h +++ b/zap/include/zap/bs.h @@ -26,15 +26,11 @@ typedef signed char zap_cmp; #define zap_nopos (~((zap_sz)+0u)) -#if defined(__cplusplus) -#define zap_nullptr ((unsigned long)0x0u) -#else -#define zap_nullptr ((void *)0x0u) -#endif +#define zap_nullptr ((zap_sz)0x0u) typedef unsigned long zap_sz; -#define zap_ver ((unsigned long)+0x10u) +#define zap_ver ((unsigned long)+0x11u) #if defined(__cplusplus) } diff --git a/zap/include/zap/mem.h b/zap/include/zap/mem.h index 46ab872..f4877fa 100644 --- a/zap/include/zap/mem.h +++ b/zap/include/zap/mem.h @@ -17,13 +17,11 @@ __attribute__ ((hot,nothrow,warn_unused_result)) zap_sz zap_fndbyte( void co __attribute__ ((hot,nothrow,warn_unused_result)) zap_sz zap_fndchr( char const * str, char chr); __attribute__ ((hot)) void zap_foreach( void * ptr, zap_sz sz, zap_sz num, void (* fn)(void *)); __attribute__ ((hot,nothrow)) void zap_memcat( void const * lptr, zap_sz llen,void const * rptr, zap_sz rlen, void * buf); -__attribute__ ((hot,nothrow,warn_unused_result)) zap_cmp zap_memcmp( void const * lstr, zap_sz num, void const * rstr); __attribute__ ((hot,nothrow)) void zap_memcp( void const * in, zap_sz num, void * out); __attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_memeq( void const * lptr, zap_sz num, void const * rptr); __attribute__ ((hot,nothrow)) void zap_memfill( void * ptr, zap_sz num, unsigned char val); __attribute__ ((hot)) void zap_memgen( void * ptr, zap_sz sz, zap_sz num, void (* fn)(zap_sz,void *)); __attribute__ ((hot,nothrow)) void zap_strcat( char const * lstr, char const * rstr,char * buf); -__attribute__ ((hot,nothrow,warn_unused_result)) zap_cmp zap_strcmp( char const * lstr, char const * rstr); __attribute__ ((hot,nothrow)) zap_sz zap_strcp( char const * in, char * out); __attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_streq( char const * lstr, char const * rstr); __attribute__ ((hot,nothrow)) zap_sz zap_strfill( char * lstr, char chr); diff --git a/zap/src/mem/fndbyte.S b/zap/source/amd64/mem/fndbyte.S index 4413b42..9298b73 100644 --- a/zap/src/mem/fndbyte.S +++ b/zap/source/amd64/mem/fndbyte.S @@ -1,23 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_fndbyte zap_fndbyte: - - /* - void const * ptr - zap_sz num - unsigned char byte - */ - -#if defined(__amd64__) - # rax: Address of the current element. # rdi: Address of the first element. # rsi: Address of the element after the last element. @@ -55,5 +42,3 @@ zap_fndbyte: movq $0xFFFFFFFFFFFFFFFF,%rax ret - -#endif diff --git a/zap/src/mem/fndchr.S b/zap/source/amd64/mem/fndchr.S index 2982e7e..1078a10 100644 --- a/zap/src/mem/fndchr.S +++ b/zap/source/amd64/mem/fndchr.S @@ -1,22 +1,10 @@ -/* - Copyright 2022 Gabriel Jensen. - This Source Code Form is subject to the terms of the Mozilla Pudhic 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 <zap/priv.h> +# 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/. .globl zap_fndchr zap_fndchr: - - /* - char const * str - char chr - */ - -#if defined(__amd64__) - # rdi: Address of the first character. # rsi: Character to be found. # rax: Address of the current character. @@ -53,5 +41,3 @@ zap_fndchr: movq $0xFFFFFFFFFFFFFFFF,%rax ret - -#endif diff --git a/zap/src/mem/foreach.S b/zap/source/amd64/mem/foreach.S index fe96538..f19bcfa 100644 --- a/zap/src/mem/foreach.S +++ b/zap/source/amd64/mem/foreach.S @@ -1,24 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_foreach zap_foreach: - - /* - void * ptr - zap_sz sz - zap_sz num - void (* fn)(void *) - */ - -#if defined(__amd64__) - # rbx: Address of the current element. # r12: Address of the element after the last input element. # r13: Size of each input element. @@ -67,5 +53,3 @@ zap_foreach: popq %rbx ret - -#endif diff --git a/zap/src/mem/memcat.c b/zap/source/amd64/mem/memcat.c index f3e9a9b..f3e9a9b 100644 --- a/zap/src/mem/memcat.c +++ b/zap/source/amd64/mem/memcat.c diff --git a/zap/src/mem/memcp.S b/zap/source/amd64/mem/memcp.S index ead0718..5691446 100644 --- a/zap/src/mem/memcp.S +++ b/zap/source/amd64/mem/memcp.S @@ -1,22 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_memcp zap_memcp: - - /* - void const * in - zap_sz num - void * out - */ -#if defined(__amd64__) - # rdi: Address of the current input element. # rsi: Number of remaining elements. # rdx: Address of the current output element. @@ -103,5 +91,4 @@ zap_memcp: .done: ret - -#endif +
\ No newline at end of file diff --git a/zap/src/mem/memeq.S b/zap/source/amd64/mem/memeq.S index cf554c2..ba43dfc 100644 --- a/zap/src/mem/memeq.S +++ b/zap/source/amd64/mem/memeq.S @@ -1,23 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_memeq zap_memeq: - - /* - void const * lptr - zap_sz num - void const * rptr - */ - -#if defined(__amd64__) - /* rdi: Left pointer. */ /* rsi: Number of remaining elements. */ /* rdx: Right pointer. */ @@ -78,5 +65,3 @@ zap_memeq: .neq: movb $0x0,%al ret - -#endif diff --git a/zap/src/mem/memfill.S b/zap/source/amd64/mem/memfill.S index 63a1aad..e563b55 100644 --- a/zap/src/mem/memfill.S +++ b/zap/source/amd64/mem/memfill.S @@ -1,23 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_memfill zap_memfill: - - /* - void const * ptr - zap_sz num - unsigned char val - */ - -#if defined(__amd64__) - # rdi: Address of the current element. # rsi: Address of the element after the last element. # rdx: Byte value. @@ -41,5 +28,3 @@ zap_memfill: # Finish: .done: ret - -#endif diff --git a/zap/src/mem/memgen.c b/zap/source/amd64/mem/memgen.c index a39e326..a39e326 100644 --- a/zap/src/mem/memgen.c +++ b/zap/source/amd64/mem/memgen.c diff --git a/zap/src/mem/strcat.c b/zap/source/amd64/mem/strcat.c index f7f66c8..f7f66c8 100644 --- a/zap/src/mem/strcat.c +++ b/zap/source/amd64/mem/strcat.c diff --git a/zap/src/mem/strcp.S b/zap/source/amd64/mem/strcp.S index 04c3198..eb5c276 100644 --- a/zap/src/mem/strcp.S +++ b/zap/source/amd64/mem/strcp.S @@ -1,22 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_strcp zap_strcp: - - /* - char const * in - char const * out - */ - -#if defined(__amd64__) - # rax: Address of the current input character. # rdi: Address of the first input character. # rsi: Address of the current output character. @@ -49,5 +37,3 @@ zap_strcp: decq %rax # We do not count the null-terminator in the string length. ret - -#endif diff --git a/zap/src/mem/streq.S b/zap/source/amd64/mem/streq.S index d331e93..4270e7d 100644 --- a/zap/src/mem/streq.S +++ b/zap/source/amd64/mem/streq.S @@ -1,22 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_streq zap_streq: - - /* - char const * lstr - char const * rstr - */ - -#if defined(__amd64__) - # rdi: Address of the current left character. # rsi: Address of the current right character. # rax: Current left character. @@ -53,5 +41,3 @@ zap_streq: movb $0x0,%al ret - -#endif diff --git a/zap/src/mem/strfill.S b/zap/source/amd64/mem/strfill.S index 277865e..590b99f 100644 --- a/zap/src/mem/strfill.S +++ b/zap/source/amd64/mem/strfill.S @@ -1,22 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_strfill zap_strfill: - - /* - char * str - char chr - */ - -#if defined(__amd64__) - # rdi: Address of the first character of the string. # rsi: Fill character. # rax: Address of the current character. @@ -44,5 +32,3 @@ zap_strfill: subq %rdi,%rax ret - -#endif diff --git a/zap/src/mem/strlen.S b/zap/source/amd64/mem/strlen.S index 4cb435f..bd83008 100644 --- a/zap/src/mem/strlen.S +++ b/zap/source/amd64/mem/strlen.S @@ -1,21 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_strlen zap_strlen: - - /* - char const * str - */ - -#if defined(__amd64__) - # rax: Address of the current character. # rdx: Current character. @@ -42,5 +31,3 @@ zap_strlen: subq %rdi,%rax ret - -#endif diff --git a/zap/src/mem/utf8dec.c b/zap/source/amd64/mem/utf8dec.c index 62f3f61..62f3f61 100644 --- a/zap/src/mem/utf8dec.c +++ b/zap/source/amd64/mem/utf8dec.c diff --git a/zap/src/mem/utf8declen.c b/zap/source/amd64/mem/utf8declen.c index 85062b9..85062b9 100644 --- a/zap/src/mem/utf8declen.c +++ b/zap/source/amd64/mem/utf8declen.c diff --git a/zap/src/mem/utf8enc.S b/zap/source/amd64/mem/utf8enc.S index 24e09d8..357bdaa 100644 --- a/zap/src/mem/utf8enc.S +++ b/zap/source/amd64/mem/utf8enc.S @@ -1,22 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_utf8enc zap_utf8enc: - - /* - zap_chr20 const * in - zap_chr8 * out - */ - -#if defined(__amd64__) - # rdi: Current input codepoint. # rsi: Current output octet. # rax: Current codepoint. @@ -101,7 +89,7 @@ zap_utf8enc: jmp .cnt - # Four octets:/ + # Four octets: .oct4: # Octet #0: @@ -148,5 +136,4 @@ zap_utf8enc: .done: ret - -#endif +
\ No newline at end of file diff --git a/zap/src/mem/utf8enclen.S b/zap/source/amd64/mem/utf8enclen.S index 1c80e6a..2e3b09f 100644 --- a/zap/src/mem/utf8enclen.S +++ b/zap/source/amd64/mem/utf8enclen.S @@ -1,21 +1,10 @@ -/* - 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 <zap/priv.h> +# 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/. .globl zap_utf8enclen zap_utf8enclen: - - /* - zap_chr20 const * utf20 - */ - -#if defined(__amd64__) - # rdi: Address of the current character. # rax: Length of the string. # rsi: Current character. @@ -76,5 +65,3 @@ zap_utf8enclen: .done: ret - -#endif diff --git a/zap/src/mem/win1252dec.c b/zap/source/amd64/mem/win1252dec.c index 2a5e897..2a5e897 100644 --- a/zap/src/mem/win1252dec.c +++ b/zap/source/amd64/mem/win1252dec.c diff --git a/zap/src/mem/win1252enc.c b/zap/source/amd64/mem/win1252enc.c index cd313cd..cd313cd 100644 --- a/zap/src/mem/win1252enc.c +++ b/zap/source/amd64/mem/win1252enc.c diff --git a/zap/src/mem/memcmp.c b/zap/src/mem/memcmp.c deleted file mode 100644 index 13fa269..0000000 --- a/zap/src/mem/memcmp.c +++ /dev/null @@ -1,21 +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 <zap/priv.h> - -#include <zap/mem.h> - -zap_cmp zap_memcmp(void const * const _lstr,zap_sz const _num,void const * const _rstr) { - unsigned char const * lpos = _lstr; - unsigned char const * rpos = _rstr; - unsigned char const * const afterlbuf = lpos + _num; - for (;lpos != afterlbuf;++lpos,++rpos) { - unsigned char const lbyte = *lpos; - unsigned char const rbyte = *rpos; - if (lbyte != rbyte) {return lbyte < rbyte ? zap_lt : zap_gt;} - } - return zap_eq; -} diff --git a/zap/src/mem/strcmp.c b/zap/src/mem/strcmp.c deleted file mode 100644 index d620560..0000000 --- a/zap/src/mem/strcmp.c +++ /dev/null @@ -1,23 +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 <zap/priv.h> - -#include <zap/mem.h> - -#include <stdint.h> - -zap_cmp 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 ? zap_lt : zap_gt;} - if (lchr == (unsigned char)0x0) {return zap_eq;} - } - sus_unreach(); -} |