Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/memmove.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 534 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /*
2 * memmove.c
3 */
4
5 #include <string.h>
6
7 void *memmove(void *dst, const void *src, size_t n)
8 {
9 const char *p = src;
10 char *q = dst;
11 #if defined(__i386__) || defined(__x86_64__)
12 if (q < p) {
13 asm volatile("cld ; rep ; movsb"
14 : "+c" (n), "+S"(p), "+D"(q));
15 } else {
16 p += (n - 1);
17 q += (n - 1);
18 asm volatile("std ; rep ; movsb"
19 : "+c" (n), "+S"(p), "+D"(q));
20 }
21 #else
22 if (q < p) {
23 while (n--) {
24 *q++ = *p++;
25 }
26 } else {
27 p += n;
28 q += n;
29 while (n--) {
30 *--q = *--p;
31 }
32 }
33 #endif
34
35 return dst;
36 }