1#define SYSCLIB_DISABLE_BUILTINS
6#define SS (sizeof(size_t))
7#define ALIGN (sizeof(size_t)-1)
8#define ONES ((size_t)-1/UCHAR_MAX)
9#define HIGHS (ONES * (UCHAR_MAX/2+1))
10#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS)
12void *memchr(
const void *src,
int c,
size_t n)
14 const unsigned char *s = src;
17 for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
22 for (w = (
const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
26 for (; n && *s != c; s++, n--);
27 return n ? (
void *)s : 0;