2 * This provides an optimized implementation of memcpy, and a simplified
3 * implementation of memset and memmove. These are used here because the
4 * standard kernel runtime versions are not yet available and we don't
5 * trust the gcc built-in implementations as they may do unexpected things
6 * (e.g. FPU ops) in the minimal decompression stub execution environment.
10 #include "../string.c"
13 void *memcpy(void *dest, const void *src, size_t n)
20 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
21 : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
27 void *memcpy(void *dest, const void *src, size_t n)
34 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
35 : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
42 void *memset(void *s, int c, size_t n)
47 for (i = 0; i < n; i++)
52 void *memmove(void *dest, const void *src, size_t n)
54 unsigned char *d = dest;
55 const unsigned char *s = src;
57 if (d <= s || d - s >= n)
58 return memcpy(dest, src, n);