mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
Add memcpy() and strcmp() to LibC.
This commit is contained in:
parent
0af9254812
commit
ac738b03d6
2 changed files with 19 additions and 0 deletions
|
@ -12,6 +12,23 @@ size_t strlen(const char* str)
|
|||
return len;
|
||||
}
|
||||
|
||||
int strcmp(const char* s1, const char* s2)
|
||||
{
|
||||
for (; *s1 == *s2; ++s1, ++s2) {
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
}
|
||||
return *(const unsigned char*)s1 < *(const unsigned char*)s2 ? -1 : 1;
|
||||
}
|
||||
|
||||
void memcpy(void* dest, const void* src, size_t n)
|
||||
{
|
||||
auto* bdest = (unsigned char*)dest;
|
||||
auto* bsrc = (const unsigned char*)src;
|
||||
for (; n; --n)
|
||||
*(bdest++) = *(bsrc++);
|
||||
}
|
||||
|
||||
const char* strerror(int errnum)
|
||||
{
|
||||
switch (errnum) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue