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;
43 for (char_ptr = (
const unsigned char *) s;
44 (
size_t) char_ptr %
sizeof (longword) != 0;
47 return (
void *) char_ptr;
49 longword_ptr = (
const longword *) char_ptr;
57 repeated_one = 0x01010101;
58 repeated_c = c | (c << 8);
59 repeated_c |= repeated_c << 16;
60 if (0xffffffffU < (longword) -1)
62 repeated_one |= repeated_one << 31 << 1;
63 repeated_c |= repeated_c << 31 << 1;
64 if (8 <
sizeof (longword))
68 for (i = 64; i <
sizeof (longword) * 8; i *= 2)
70 repeated_one |= repeated_one << i;
71 repeated_c |= repeated_c << i;
115 longword longword1 = *longword_ptr ^ repeated_c;
117 if ((((longword1 - repeated_one) & ~longword1)
118 & (repeated_one << 7)) != 0)
123 char_ptr = (
const unsigned char *) longword_ptr;
132 char_ptr = (
unsigned char *) longword_ptr;
133 while (*char_ptr != c)
135 return (
void *) char_ptr;
void * rawmemchr(const void *s, int c_in)
Searching in a string.