Add implementations of memcmp and memcpy to ulib
This is necessary because gcc may generate calls to memcmp, memset, memcpy, and memmove when compiling with -nostdlib.
This commit is contained in:
parent
a52d296814
commit
8509784d80
20
user/ulib.c
20
user/ulib.c
|
@ -107,3 +107,23 @@ memmove(void *vdst, const void *vsrc, int n)
|
|||
*dst++ = *src++;
|
||||
return vdst;
|
||||
}
|
||||
|
||||
int
|
||||
memcmp(const void *s1, const void *s2, uint n)
|
||||
{
|
||||
const char *p1 = s1, *p2 = s2;
|
||||
while (n-- > 0) {
|
||||
if (*p1 != *p2) {
|
||||
return *p1 - *p2;
|
||||
}
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
memcpy(void *dst, const void *src, uint n)
|
||||
{
|
||||
return memmove(dst, src, n);
|
||||
}
|
||||
|
|
|
@ -38,3 +38,5 @@ void* memset(void*, int, uint);
|
|||
void* malloc(uint);
|
||||
void free(void*);
|
||||
int atoi(const char*);
|
||||
int memcmp(const void *, const void *, uint);
|
||||
void *memcpy(void *, const void *, uint);
|
||||
|
|
Loading…
Reference in a new issue