24 lines
508 B
C
24 lines
508 B
C
#ifndef STDMEM_H
|
|
#define STDMEM_H
|
|
|
|
#include "types.h"
|
|
|
|
static inline void *__memmove(void *dest, const void *src, uint64_t n) {
|
|
unsigned char *__d = (unsigned char *)dest;
|
|
const unsigned char *__s = (const unsigned char *)src;
|
|
|
|
if (__d < __s) {
|
|
for (unsigned long long i = 0; i < n; i++) {
|
|
__d[i] = __s[i];
|
|
}
|
|
} else {
|
|
for (unsigned long long i = n; i > 0; i--) {
|
|
__d[i - 1] = __s[i - 1];
|
|
}
|
|
}
|
|
|
|
return dest;
|
|
}
|
|
|
|
#endif // STDMEM_H
|