Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/memcpy.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 560 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 560 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 | * memcpy.c |
3 | */ |
4 | |
5 | #include <string.h> |
6 | #include <stdint.h> |
7 | |
8 | void *memcpy(void *dst, const void *src, size_t n) |
9 | { |
10 | const char *p = src; |
11 | char *q = dst; |
12 | #if defined(__i386__) |
13 | size_t nl = n >> 2; |
14 | asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl), |
15 | "+S"(p), "+D"(q) |
16 | :"r"(n & 3)); |
17 | #elif defined(__x86_64__) |
18 | size_t nq = n >> 3; |
19 | asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c" |
20 | (nq), "+S"(p), "+D"(q) |
21 | :"r"((uint32_t) (n & 7))); |
22 | #else |
23 | while (n--) { |
24 | *q++ = *p++; |
25 | } |
26 | #endif |
27 | |
28 | return dst; |
29 | } |