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

Kernel+AK: Remove AK/StdLibExtras.cpp, moving kernel stuff to Kernel/.

We had some kernel-specific gizmos in AK that should really just be in the
Kernel subdirectory instead. The only thing remaining after moving those
was mmx_memcpy() which I moved to the ARCH(i386)-specific section of
LibC/string.cpp.
This commit is contained in:
Andreas Kling 2019-07-29 11:58:44 +02:00
parent c59fdcc021
commit 57c29491a3
6 changed files with 146 additions and 161 deletions

View file

@ -134,6 +134,54 @@ int memcmp(const void* v1, const void* v2, size_t n)
}
#if ARCH(I386)
void* mmx_memcpy(void* dest, const void* src, size_t len)
{
ASSERT(len >= 1024);
auto* dest_ptr = (u8*)dest;
auto* src_ptr = (const u8*)src;
if ((u32)dest_ptr & 7) {
u32 prologue = 8 - ((u32)dest_ptr & 7);
len -= prologue;
asm volatile(
"rep movsb\n"
: "=S"(src_ptr), "=D"(dest_ptr), "=c"(prologue)
: "0"(src_ptr), "1"(dest_ptr), "2"(prologue)
: "memory");
}
for (u32 i = len / 64; i; --i) {
asm volatile(
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
"movq 16(%0), %%mm2\n"
"movq 24(%0), %%mm3\n"
"movq 32(%0), %%mm4\n"
"movq 40(%0), %%mm5\n"
"movq 48(%0), %%mm6\n"
"movq 56(%0), %%mm7\n"
"movq %%mm0, (%1)\n"
"movq %%mm1, 8(%1)\n"
"movq %%mm2, 16(%1)\n"
"movq %%mm3, 24(%1)\n"
"movq %%mm4, 32(%1)\n"
"movq %%mm5, 40(%1)\n"
"movq %%mm6, 48(%1)\n"
"movq %%mm7, 56(%1)\n" ::"r"(src_ptr),
"r"(dest_ptr)
: "memory");
src_ptr += 64;
dest_ptr += 64;
}
asm volatile("emms" ::
: "memory");
// Whatever remains we'll have to memcpy.
len %= 64;
if (len)
memcpy(dest_ptr, src_ptr, len);
return dest;
}
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
{
if (n >= 1024)