31 typedef unsigned long int longword;
33 const unsigned char *char_ptr;
34 const longword *longword_ptr;
35 longword repeated_one;
39 c = (
unsigned char)
c_in;
45 for (char_ptr = (
const unsigned char *) s;
46 (
size_t) char_ptr %
sizeof (longword) != 0;
48 if (!*char_ptr || *char_ptr == c)
49 return (
char *) char_ptr;
51 longword_ptr = (
const longword *) char_ptr;
59 repeated_one = 0x01010101;
60 repeated_c = c | (c << 8);
61 repeated_c |= repeated_c << 16;
62 if (0xffffffffU < (longword) -1)
64 repeated_one |= repeated_one << 31 << 1;
65 repeated_c |= repeated_c << 31 << 1;
66 if (8 <
sizeof (longword))
70 for (i = 64; i <
sizeof (longword) * 8; i *= 2)
72 repeated_one |= repeated_one << i;
73 repeated_c |= repeated_c << i;
119 longword longword1 = *longword_ptr ^ repeated_c;
120 longword longword2 = *longword_ptr;
122 if (((((longword1 - repeated_one) & ~longword1)
123 | ((longword2 - repeated_one) & ~longword2))
124 & (repeated_one << 7)) != 0)
129 char_ptr = (
const unsigned char *) longword_ptr;
138 char_ptr = (
unsigned char *) longword_ptr;
139 while (*char_ptr && (*char_ptr != c))
141 return (
char *) char_ptr;
void * rawmemchr(const void *s, int c_in)
Searching in a string.
char * strchrnul(const char *s, int c_in)
Searching in a string.