summaryrefslogtreecommitdiff
path: root/lib/string/memchr.c
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-10-16 02:39:56 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-10-16 02:39:56 +0800
commit8cace3f05003c6cb4d38c36890055f03151c2ad4 (patch)
treeaa739deaac0266f17c4e91b333957501cb1ea2e9 /lib/string/memchr.c
parent3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee (diff)
downloadlume-8cace3f05003c6cb4d38c36890055f03151c2ad4.tar.gz
lume-8cace3f05003c6cb4d38c36890055f03151c2ad4.tar.xz
Remove old code
Signed-off-by: Richard Qin <richard.qin.x@gmail.com>
Diffstat (limited to 'lib/string/memchr.c')
-rw-r--r--lib/string/memchr.c30
1 files changed, 0 insertions, 30 deletions
diff --git a/lib/string/memchr.c b/lib/string/memchr.c
deleted file mode 100644
index d0f670f..0000000
--- a/lib/string/memchr.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */
-
-#include <string.h>
-#include <stdint.h>
-#include <limits.h>
-
-#define SS (sizeof(size_t))
-#define ALIGN (sizeof(size_t)-1)
-#define ONES ((size_t)-1/UCHAR_MAX)
-#define HIGHS (ONES * (UCHAR_MAX/2+1))
-#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
-
-void *memchr(const void *src, int c, size_t n)
-{
- const unsigned char *s = src;
- c = (unsigned char)c;
-#ifdef __GNUC__
- for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
- if (n && *s != c) {
- typedef size_t __attribute__((__may_alias__)) word;
- const word *w;
- size_t k = ONES * c;
- for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
- s = (const void *)w;
- }
-#endif
- for (; n && *s != c; s++, n--);
- return n ? (void *)s : 0;
-}