Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: fusl/src/string/strchrnul.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <string.h> 1 #include <string.h>
2 #include <stdint.h> 2 #include <stdint.h>
3 #include <limits.h> 3 #include <limits.h>
4 #include "libc.h" 4 #include "libc.h"
5 5
6 #define ALIGN (sizeof(size_t)) 6 #define ALIGN (sizeof(size_t))
7 #define ONES ((size_t)-1/UCHAR_MAX) 7 #define ONES ((size_t)-1 / UCHAR_MAX)
8 #define HIGHS (ONES * (UCHAR_MAX/2+1)) 8 #define HIGHS (ONES * (UCHAR_MAX / 2 + 1))
9 #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) 9 #define HASZERO(x) ((x)-ONES & ~(x)&HIGHS)
10 10
11 char *__strchrnul(const char *s, int c) 11 char* __strchrnul(const char* s, int c) {
12 { 12 size_t *w, k;
13 » size_t *w, k;
14 13
15 » c = (unsigned char)c; 14 c = (unsigned char)c;
16 » if (!c) return (char *)s + strlen(s); 15 if (!c)
16 return (char*)s + strlen(s);
17 17
18 » for (; (uintptr_t)s % ALIGN; s++) 18 for (; (uintptr_t)s % ALIGN; s++)
19 » » if (!*s || *(unsigned char *)s == c) return (char *)s; 19 if (!*s || *(unsigned char*)s == c)
20 » k = ONES * c; 20 return (char*)s;
21 » for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++); 21 k = ONES * c;
22 » for (s = (void *)w; *s && *(unsigned char *)s != c; s++); 22 for (w = (void*)s; !HASZERO(*w) && !HASZERO(*w ^ k); w++)
23 » return (char *)s; 23 ;
24 for (s = (void*)w; *s && *(unsigned char*)s != c; s++)
25 ;
26 return (char*)s;
24 } 27 }
25 28
26 weak_alias(__strchrnul, strchrnul); 29 weak_alias(__strchrnul, strchrnul);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698