X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstring%2Fstrchrnul.c;h=39e2635b3064df1e2b15cb45d60c654238ad8f79;hb=d4f987e4ac44e4e5ca2bcf68365b4c2b77bdf2d0;hp=05700ad64eea55cb8f6dffad0fe6dd97feb3d31c;hpb=571744447c23f91feb6439948f3a619aca850dfb;p=musl diff --git a/src/string/strchrnul.c b/src/string/strchrnul.c index 05700ad6..39e2635b 100644 --- a/src/string/strchrnul.c +++ b/src/string/strchrnul.c @@ -1,7 +1,6 @@ #include #include #include -#include "libc.h" #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) @@ -10,16 +9,19 @@ char *__strchrnul(const char *s, int c) { - size_t *w, k; - c = (unsigned char)c; if (!c) return (char *)s + strlen(s); +#ifdef __GNUC__ + typedef size_t __attribute__((__may_alias__)) word; + const word *w; for (; (uintptr_t)s % ALIGN; s++) if (!*s || *(unsigned char *)s == c) return (char *)s; - k = ONES * c; + size_t k = ONES * c; for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++); - for (s = (void *)w; *s && *(unsigned char *)s != c; s++); + s = (void *)w; +#endif + for (; *s && *(unsigned char *)s != c; s++); return (char *)s; }