meta: move photon/libc to root
This commit is contained in:
27
libc/string/memmove.c
Normal file
27
libc/string/memmove.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <string.h>
|
||||
|
||||
#define ALIGNED(p) (!((long)p & (sizeof(long) - 1)))
|
||||
#define QUADBLOCKSIZE (sizeof(long) << 2)
|
||||
#define BLOCKSIZE (sizeof(long))
|
||||
|
||||
static void *memcpy_r(void *dest, const void *src, size_t sz)
|
||||
{
|
||||
unsigned char *d = dest;
|
||||
const unsigned char *s = src;
|
||||
|
||||
for (size_t i = 0; i < sz; i++) {
|
||||
size_t b = sz - i - 1;
|
||||
d[b] = s[b];
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
if (dest < src) {
|
||||
return memcpy(dest, src, n);
|
||||
} else {
|
||||
return memcpy_r(dest, src, n);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user