22 #include <linux/types.h>
23 #include <linux/string.h>
24 #include <linux/ctype.h>
25 #include <linux/kernel.h>
26 #include <linux/export.h>
28 #include <linux/errno.h>
30 #ifndef __HAVE_ARCH_STRNICMP
57 return (
int)c1 - (
int)c2;
62 #ifndef __HAVE_ARCH_STRCASECMP
70 }
while (c1 == c2 && c1 != 0);
76 #ifndef __HAVE_ARCH_STRNCASECMP
84 }
while ((--n > 0) && c1 == c2 && c1 != 0);
90 #ifndef __HAVE_ARCH_STRCPY
101 while ((*dest++ = *src++) !=
'\0')
108 #ifndef __HAVE_ARCH_STRNCPY
127 if ((*tmp = *src) != 0)
137 #ifndef __HAVE_ARCH_STRLCPY
154 size_t len = (ret >=
size) ? size - 1 : ret;
163 #ifndef __HAVE_ARCH_STRCAT
176 while ((*dest++ = *src++) !=
'\0')
183 #ifndef __HAVE_ARCH_STRNCAT
200 while ((*dest++ = *src++) != 0) {
212 #ifndef __HAVE_ARCH_STRLCAT
221 size_t dsize =
strlen(dest);
223 size_t res = dsize + len;
239 #ifndef __HAVE_ARCH_STRCMP
248 unsigned char c1, c2;
254 return c1 < c2 ? -1 : 1;
263 #ifndef __HAVE_ARCH_STRNCMP
272 unsigned char c1, c2;
278 return c1 < c2 ? -1 : 1;
288 #ifndef __HAVE_ARCH_STRCHR
296 for (; *s != (
char)c; ++
s)
304 #ifndef __HAVE_ARCH_STRRCHR
322 #ifndef __HAVE_ARCH_STRNCHR
331 for (; count-- && *s !=
'\0'; ++
s)
371 while (end >= s &&
isspace(*end))
379 #ifndef __HAVE_ARCH_STRLEN
388 for (sc = s; *sc !=
'\0'; ++
sc)
395 #ifndef __HAVE_ARCH_STRNLEN
405 for (sc = s; count-- && *sc !=
'\0'; ++
sc)
412 #ifndef __HAVE_ARCH_STRSPN
418 size_t strspn(
const char *
s,
const char *accept)
424 for (p = s; *p !=
'\0'; ++
p) {
425 for (a = accept; *a !=
'\0'; ++
a) {
439 #ifndef __HAVE_ARCH_STRCSPN
451 for (p = s; *p !=
'\0'; ++
p) {
452 for (r = reject; *r !=
'\0'; ++
r) {
463 #ifndef __HAVE_ARCH_STRPBRK
471 const char *sc1, *sc2;
473 for (sc1 = cs; *sc1 !=
'\0'; ++sc1) {
474 for (sc2 = ct; *sc2 !=
'\0'; ++sc2) {
484 #ifndef __HAVE_ARCH_STRSEP
525 while (*s1 && *s1 == *s2) {
532 if (!*s1 && *s2 ==
'\n' && !s2[1])
534 if (*s1 ==
'\n' && !s1[1] && !*s2)
569 #ifndef __HAVE_ARCH_MEMSET
589 #ifndef __HAVE_ARCH_MEMCPY
611 #ifndef __HAVE_ARCH_MEMMOVE
643 #ifndef __HAVE_ARCH_MEMCMP
653 const unsigned char *su1, *su2;
656 for (su1 = cs, su2 = ct; 0 <
count; ++su1, ++su2, count--)
657 if ((res = *su1 - *su2) != 0)
664 #ifndef __HAVE_ARCH_MEMSCAN
676 unsigned char *
p =
addr;
689 #ifndef __HAVE_ARCH_STRSTR
714 #ifndef __HAVE_ARCH_STRNSTR
739 #ifndef __HAVE_ARCH_MEMCHR
751 const unsigned char *
p =
s;
753 if ((
unsigned char)c == *p++) {
754 return (
void *)(p - 1);
766 return (
void *)
start;
786 unsigned int words,
prefix;
789 return check_bytes8(start, value, bytes);
792 #if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
793 value64 *= 0x0101010101010101;
794 #elif defined(ARCH_HAS_FAST_MULTIPLIER)
795 value64 *= 0x01010101;
796 value64 |= value64 << 32;
798 value64 |= value64 << 8;
799 value64 |= value64 << 16;
800 value64 |= value64 << 32;
803 prefix = (
unsigned long)start % 8;
808 r = check_bytes8(start, value, prefix);
818 if (*(
u64 *)start != value64)
819 return check_bytes8(start, value, 8);
824 return check_bytes8(start, value, bytes % 8);