mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:38:10 +00:00
LibC: Add general implementation for memcpy and memset
This commit is contained in:
parent
a98c0c3e51
commit
cff6af9f75
1 changed files with 11 additions and 14 deletions
|
@ -136,29 +136,26 @@ void* memcpy(void* dest_ptr, void const* src_ptr, size_t n)
|
||||||
"rep movsb"
|
"rep movsb"
|
||||||
: "+D"(dest_ptr), "+S"(src_ptr), "+c"(n)::"memory");
|
: "+D"(dest_ptr), "+S"(src_ptr), "+c"(n)::"memory");
|
||||||
return original_dest;
|
return original_dest;
|
||||||
#elif ARCH(AARCH64)
|
|
||||||
(void)dest_ptr;
|
|
||||||
(void)src_ptr;
|
|
||||||
(void)n;
|
|
||||||
TODO_AARCH64();
|
|
||||||
#else
|
#else
|
||||||
# error Unknown architecture
|
u8* pd = (u8*)dest_ptr;
|
||||||
|
u8 const* ps = (u8 const*)src_ptr;
|
||||||
|
for (; n--;)
|
||||||
|
*pd++ = *ps++;
|
||||||
|
return dest_ptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html
|
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html
|
||||||
// For x86-64, an optimized ASM implementation is found in ./arch/x86_64/memset.S
|
// For x86-64, an optimized ASM implementation is found in ./arch/x86_64/memset.S
|
||||||
#if ARCH(AARCH64)
|
#if ARCH(X86_64)
|
||||||
|
#else
|
||||||
void* memset(void* dest_ptr, int c, size_t n)
|
void* memset(void* dest_ptr, int c, size_t n)
|
||||||
{
|
{
|
||||||
(void)dest_ptr;
|
u8* pd = (u8*)dest_ptr;
|
||||||
(void)c;
|
for (; n--;)
|
||||||
(void)n;
|
*pd++ = c;
|
||||||
TODO_AARCH64();
|
return dest_ptr;
|
||||||
}
|
}
|
||||||
#elif ARCH(X86_64)
|
|
||||||
#else
|
|
||||||
# error Unknown architecture
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memmove.html
|
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memmove.html
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue