1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

Kernel: Build MiniStdLib.cpp in aarch64 builds

This commit is contained in:
Nico Weber 2021-09-06 20:49:38 -04:00 committed by Linus Groh
parent 208aa05cf3
commit a8d96df8e0
2 changed files with 20 additions and 7 deletions

View file

@ -10,6 +10,7 @@ extern "C" {
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
{
#if ARCH(I386) || ARCH(X86_64)
size_t dest = (size_t)dest_ptr;
size_t src = (size_t)src_ptr;
// FIXME: Support starting at an unaligned address.
@ -35,6 +36,12 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
asm volatile(
"rep movsb\n" ::"S"(src), "D"(dest), "c"(n)
: "memory");
#else
u8* pd = (u8*)dest_ptr;
u8 const* ps = (u8 const*)src_ptr;
for (; n--;)
*pd++ = *ps++;
#endif
return dest_ptr;
}
@ -52,6 +59,7 @@ void* memmove(void* dest, const void* src, size_t n)
void* memset(void* dest_ptr, int c, size_t n)
{
#if ARCH(I386) || ARCH(X86_64)
size_t dest = (size_t)dest_ptr;
// FIXME: Support starting at an unaligned address.
if (!(dest & 0x3) && n >= 12) {
@ -79,6 +87,11 @@ void* memset(void* dest_ptr, int c, size_t n)
: "=D"(dest), "=c"(n)
: "0"(dest), "1"(n), "a"(c)
: "memory");
#else
u8* pd = (u8*)dest_ptr;
for (; n--;)
*pd++ = c;
#endif
return dest_ptr;
}

View file

@ -1,5 +1,6 @@
set(SOURCES
UBSanitizer.cpp
../MiniStdLib.cpp
)
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(SOURCES
@ -14,7 +15,6 @@ else()
Arch/x86/multiboot.S
# FIXME: Eventually, some of these should build on aarch64 too.
init.cpp
../MiniStdLib.cpp
../../Userland/Libraries/LibELF/Relocation.cpp
)
endif()