mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-19 07:21:20 +03:00
import KernelEx-4.0-RC1
This commit is contained in:
28
kexcrt/memcpy.c
Normal file
28
kexcrt/memcpy.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* memcpy.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void *memcpy(void *dst, const void *src, size_t n)
|
||||
{
|
||||
const char *p = src;
|
||||
char *q = dst;
|
||||
#if defined(__i386__)
|
||||
size_t nl = n >> 2;
|
||||
asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl),
|
||||
"+S"(p), "+D"(q)
|
||||
:"r"(n & 3));
|
||||
#elif defined(__x86_64__)
|
||||
size_t nq = n >> 3;
|
||||
asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c"
|
||||
(nq), "+S"(p), "+D"(q)
|
||||
:"r"((uint32_t) (n & 7)));
|
||||
#else
|
||||
while (n--) {
|
||||
*q++ = *p++;
|
||||
}
|
||||
#endif
|
||||
|
||||
return dst;
|
||||
}
|
Reference in New Issue
Block a user