diff options
Diffstat (limited to 'zap/src')
-rw-r--r-- | zap/src/fndbyte.c | 4 | ||||
-rw-r--r-- | zap/src/fndchr.c | 4 | ||||
-rw-r--r-- | zap/src/foreach.c | 16 | ||||
-rw-r--r-- | zap/src/memcpy.c | 12 | ||||
-rw-r--r-- | zap/src/memeq.c | 2 | ||||
-rw-r--r-- | zap/src/memfill.c | 4 | ||||
-rw-r--r-- | zap/src/strcpy.c | 2 | ||||
-rw-r--r-- | zap/src/streq.c | 2 | ||||
-rw-r--r-- | zap/src/strlen.c | 2 |
9 files changed, 32 insertions, 16 deletions
diff --git a/zap/src/fndbyte.c b/zap/src/fndbyte.c index 917aeff..3283eec 100644 --- a/zap/src/fndbyte.c +++ b/zap/src/fndbyte.c @@ -11,7 +11,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_fndbyte\n" + ".globl zap_fndbyte\n" "zap_fndbyte:\n" /* @@ -72,6 +72,6 @@ size_t zap_fndbyte(void const * const _ptr,size_t const _num,uint_least8_t const 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 -0x1u; + return SIZE_MAX; } #endif diff --git a/zap/src/fndchr.c b/zap/src/fndchr.c index 6af1b73..5cf78f8 100644 --- a/zap/src/fndchr.c +++ b/zap/src/fndchr.c @@ -11,7 +11,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_fndchr\n" + ".globl zap_fndchr\n" "zap_fndchr:\n" /* @@ -64,7 +64,7 @@ size_t zap_fndchr(char const * const _str,char const _chr) { for (;;++pos) { char const chr = *pos; sus_unlikely (chr == _chr) {return (size_t)(pos - _str);} - sus_unlikely (chr == '\x0') {return -0x1u;} + sus_unlikely (chr == '\x0') {return SIZE_MAX;} } sus_unreach(); } diff --git a/zap/src/foreach.c b/zap/src/foreach.c new file mode 100644 index 0000000..54911e9 --- /dev/null +++ b/zap/src/foreach.c @@ -0,0 +1,16 @@ +/* + 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 <stddef.h> + +void zap_foreach(void * const _ptr,size_t const _sz,size_t const _num,void (* const _fn)(void *)) { + unsigned char * ptr = _ptr; + size_t const numbyte = _sz * _num; + void * const afterbuf = ptr + numbyte; + for (;ptr != afterbuf;ptr += _sz) {_fn(ptr);} +} diff --git a/zap/src/memcpy.c b/zap/src/memcpy.c index 1b40832..8fa98ae 100644 --- a/zap/src/memcpy.c +++ b/zap/src/memcpy.c @@ -11,14 +11,14 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_memcpy\n" + ".globl zap_memcpy\n" "zap_memcpy:\n" - /* - void const * in - size_t num - void * out - */ + /* + void const * in + size_t num + void * out + */ #if defined(sus_arch_amd64) /* rdi: Address of the current input element. */ /* rsi: Number of remaining elements. */ diff --git a/zap/src/memeq.c b/zap/src/memeq.c index f9717ad..75ecc12 100644 --- a/zap/src/memeq.c +++ b/zap/src/memeq.c @@ -12,7 +12,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_memeq\n" + ".globl zap_memeq\n" "zap_memeq:\n" /* diff --git a/zap/src/memfill.c b/zap/src/memfill.c index 70982c4..c9a9797 100644 --- a/zap/src/memfill.c +++ b/zap/src/memfill.c @@ -11,7 +11,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_memfill\n" + ".globl zap_memfill\n" "zap_memfill:\n" /* @@ -24,7 +24,7 @@ __asm__ ( /* rsi: Address of the element after the last element. */ "addq %rdi,%rsi\n" ".loop:\n" - "cmpq %rsi,%rdi\n" + "cmpq %rdi,%rsi\n" "je .done\n" /* Exit loop if we have reached the final element. */ "movb %dl,(%rdi)\n" "incq %rdi\n" diff --git a/zap/src/strcpy.c b/zap/src/strcpy.c index 3dc3e0f..943cb2c 100644 --- a/zap/src/strcpy.c +++ b/zap/src/strcpy.c @@ -10,7 +10,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_strcpy\n" + ".globl zap_strcpy\n" "zap_strcpy:\n" /* diff --git a/zap/src/streq.c b/zap/src/streq.c index 6425ef7..9221cec 100644 --- a/zap/src/streq.c +++ b/zap/src/streq.c @@ -11,7 +11,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_streq\n" + ".globl zap_streq\n" "zap_streq:\n" /* diff --git a/zap/src/strlen.c b/zap/src/strlen.c index c1e8959..eab12e6 100644 --- a/zap/src/strlen.c +++ b/zap/src/strlen.c @@ -10,7 +10,7 @@ #if defined(zap_priv_fastimpl) __asm__ ( - ".global zap_strlen\n" + ".globl zap_strlen\n" "zap_strlen:\n" /* |