Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/klibc/memcpy.c

Source at commit 1308 created 12 years 8 months ago.
By meklort, Add a few placeholders for file io
1/*
2 * memcpy.c
3 */
4
5#include <string.h>
6#include <stdint.h>
7
8void *memcpy(void *dst, const void *src, size_t n)
9{
10const char *p = src;
11char *q = dst;
12#if defined(__i386__)
13size_t nl = n >> 2;
14asm 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__)
18size_t nq = n >> 3;
19asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c"
20 (nq), "+S"(p), "+D"(q)
21 :"r"((uint32_t) (n & 7)));
22#else
23while (n--) {
24*q++ = *p++;
25}
26#endif
27
28return dst;
29}
30

Archive Download this file

Revision: 1308