5 #define ALIGN (sizeof(size_t))
6 #define ONES ((size_t)-1/UCHAR_MAX)
7 #define HIGHS (ONES * (UCHAR_MAX/2+1))
8 #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
10 char *__strchrnul(const char *s
, int c
)
13 if (!c
) return (char *)s
+ strlen(s
);
16 typedef size_t __attribute__((__may_alias__
)) word
;
18 for (; (uintptr_t)s
% ALIGN
; s
++)
19 if (!*s
|| *(unsigned char *)s
== c
) return (char *)s
;
21 for (w
= (void *)s
; !HASZERO(*w
) && !HASZERO(*w
^k
); w
++);
24 for (; *s
&& *(unsigned char *)s
!= c
; s
++);
28 weak_alias(__strchrnul
, strchrnul
);