POK
memcpy.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #include <libc/string.h>
19 
20 void *memcpy(void * to, const void * from, size_t n)
21 {
22  int d0;
23  int d1;
24  int d2;
25 
26  __asm__ __volatile__(
27  "rep ; movsl\n\t"
28  "testb $2,%b4\n\t"
29  "je 1f\n\t"
30  "movsw\n"
31  "1:\ttestb $1,%b4\n\t"
32  "je 2f\n\t"
33  "movsb\n"
34  "2:"
35  : "=&c" (d0), "=&D" (d1), "=&S" (d2)
36  :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
37  : "memory");
38  return (to);
39 }
40