-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Pitre
authored and
Nicolas Pitre
committed
Sep 14, 2011
1 parent
d6a3d96
commit e07b2e3
Showing
4 changed files
with
133 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 5ffb04f6690d71fab241b3562ebf52b893ac4ff1 | ||
refs/heads/master: df4879fa2603fbf0804a80f9f146ef9023dd621f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* arch/arm/boot/compressed/string.c | ||
* | ||
* Small subset of simple string routines | ||
*/ | ||
|
||
#include <linux/string.h> | ||
|
||
void *memcpy(void *__dest, __const void *__src, size_t __n) | ||
{ | ||
int i = 0; | ||
unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src; | ||
|
||
for (i = __n >> 3; i > 0; i--) { | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
} | ||
|
||
if (__n & 1 << 2) { | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
} | ||
|
||
if (__n & 1 << 1) { | ||
*d++ = *s++; | ||
*d++ = *s++; | ||
} | ||
|
||
if (__n & 1) | ||
*d++ = *s++; | ||
|
||
return __dest; | ||
} | ||
|
||
void *memmove(void *__dest, __const void *__src, size_t count) | ||
{ | ||
unsigned char *d = __dest; | ||
const unsigned char *s = __src; | ||
|
||
if (__dest == __src) | ||
return __dest; | ||
|
||
if (__dest < __src) | ||
return memcpy(__dest, __src, count); | ||
|
||
while (count--) | ||
d[count] = s[count]; | ||
return __dest; | ||
} | ||
|
||
size_t strlen(const char *s) | ||
{ | ||
const char *sc = s; | ||
|
||
while (*sc != '\0') | ||
sc++; | ||
return sc - s; | ||
} | ||
|
||
int memcmp(const void *cs, const void *ct, size_t count) | ||
{ | ||
const unsigned char *su1 = cs, *su2 = ct, *end = su1 + count; | ||
int res = 0; | ||
|
||
while (su1 < end) { | ||
res = *su1++ - *su2++; | ||
if (res) | ||
break; | ||
} | ||
return res; | ||
} | ||
|
||
int strcmp(const char *cs, const char *ct) | ||
{ | ||
unsigned char c1, c2; | ||
int res = 0; | ||
|
||
do { | ||
c1 = *cs++; | ||
c2 = *ct++; | ||
res = c1 - c2; | ||
if (res) | ||
break; | ||
} while (c1); | ||
return res; | ||
} | ||
|
||
void *memchr(const void *s, int c, size_t count) | ||
{ | ||
const unsigned char *p = s; | ||
|
||
while (count--) | ||
if ((unsigned char)c == *p++) | ||
return (void *)(p - 1); | ||
return NULL; | ||
} | ||
|
||
char *strchr(const char *s, int c) | ||
{ | ||
while (*s != (char)c) | ||
if (*s++ == '\0') | ||
return NULL; | ||
return (char *)s; | ||
} | ||
|
||
#undef memset | ||
|
||
void *memset(void *s, int c, size_t count) | ||
{ | ||
char *xs = s; | ||
while (count--) | ||
*xs++ = c; | ||
return s; | ||
} | ||
|
||
void __memzero(void *s, size_t count) | ||
{ | ||
memset(s, 0, count); | ||
} |