x86: Make the vdso2c compiler use the host architecture headers
[linux/fpc-iii.git] / arch / arm / boot / compressed / string.c
blob68946744873677292a32652828cd7accedd3e858
1 /*
2 * arch/arm/boot/compressed/string.c
4 * Small subset of simple string routines
5 */
7 #include <linux/string.h>
9 void *memcpy(void *__dest, __const void *__src, size_t __n)
11 int i = 0;
12 unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
14 for (i = __n >> 3; i > 0; i--) {
15 *d++ = *s++;
16 *d++ = *s++;
17 *d++ = *s++;
18 *d++ = *s++;
19 *d++ = *s++;
20 *d++ = *s++;
21 *d++ = *s++;
22 *d++ = *s++;
25 if (__n & 1 << 2) {
26 *d++ = *s++;
27 *d++ = *s++;
28 *d++ = *s++;
29 *d++ = *s++;
32 if (__n & 1 << 1) {
33 *d++ = *s++;
34 *d++ = *s++;
37 if (__n & 1)
38 *d++ = *s++;
40 return __dest;
43 void *memmove(void *__dest, __const void *__src, size_t count)
45 unsigned char *d = __dest;
46 const unsigned char *s = __src;
48 if (__dest == __src)
49 return __dest;
51 if (__dest < __src)
52 return memcpy(__dest, __src, count);
54 while (count--)
55 d[count] = s[count];
56 return __dest;
59 size_t strlen(const char *s)
61 const char *sc = s;
63 while (*sc != '\0')
64 sc++;
65 return sc - s;
68 size_t strnlen(const char *s, size_t count)
70 const char *sc;
72 for (sc = s; count-- && *sc != '\0'; ++sc)
73 /* nothing */;
74 return sc - s;
77 int memcmp(const void *cs, const void *ct, size_t count)
79 const unsigned char *su1 = cs, *su2 = ct, *end = su1 + count;
80 int res = 0;
82 while (su1 < end) {
83 res = *su1++ - *su2++;
84 if (res)
85 break;
87 return res;
90 int strcmp(const char *cs, const char *ct)
92 unsigned char c1, c2;
93 int res = 0;
95 do {
96 c1 = *cs++;
97 c2 = *ct++;
98 res = c1 - c2;
99 if (res)
100 break;
101 } while (c1);
102 return res;
105 void *memchr(const void *s, int c, size_t count)
107 const unsigned char *p = s;
109 while (count--)
110 if ((unsigned char)c == *p++)
111 return (void *)(p - 1);
112 return NULL;
115 char *strchr(const char *s, int c)
117 while (*s != (char)c)
118 if (*s++ == '\0')
119 return NULL;
120 return (char *)s;
123 #undef memset
125 void *memset(void *s, int c, size_t count)
127 char *xs = s;
128 while (count--)
129 *xs++ = c;
130 return s;
133 void __memzero(void *s, size_t count)
135 memset(s, 0, count);