X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstring%2Fstrchrnul.c;h=39e2635b3064df1e2b15cb45d60c654238ad8f79;hb=d91a6cf6e369a79587c5665fce9635e5634ca201;hp=ceae4d45f22000fd3ee4e5f5ce86d67a1bcf7466;hpb=68dbd05039f8b256f586ed9a589645fa3a1b7f5f;p=musl diff --git a/src/string/strchrnul.c b/src/string/strchrnul.c index ceae4d45..39e2635b 100644 --- a/src/string/strchrnul.c +++ b/src/string/strchrnul.c @@ -1,8 +1,6 @@ #include -#include #include #include -#include "libc.h" #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) @@ -11,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; }