Linux-2.6.12-rc2
[cascardo/linux.git] / arch / m68knommu / lib / memcpy.c
1
2 #include <linux/types.h>
3 #include <linux/autoconf.h>
4
5 void * memcpy(void * to, const void * from, size_t n)
6 {
7 #ifdef CONFIG_COLDFIRE
8   void *xto = to;
9   size_t temp;
10
11   if (!n)
12     return xto;
13   if ((long) to & 1)
14     {
15       char *cto = to;
16       const char *cfrom = from;
17       *cto++ = *cfrom++;
18       to = cto;
19       from = cfrom;
20       n--;
21     }
22   if (n > 2 && (long) to & 2)
23     {
24       short *sto = to;
25       const short *sfrom = from;
26       *sto++ = *sfrom++;
27       to = sto;
28       from = sfrom;
29       n -= 2;
30     }
31   temp = n >> 2;
32   if (temp)
33     {
34       long *lto = to;
35       const long *lfrom = from;
36       for (; temp; temp--)
37         *lto++ = *lfrom++;
38       to = lto;
39       from = lfrom;
40     }
41   if (n & 2)
42     {
43       short *sto = to;
44       const short *sfrom = from;
45       *sto++ = *sfrom++;
46       to = sto;
47       from = sfrom;
48     }
49   if (n & 1)
50     {
51       char *cto = to;
52       const char *cfrom = from;
53       *cto = *cfrom;
54     }
55   return xto;
56 #else
57   const char *c_from = from;
58   char *c_to = to;
59   while (n-- > 0)
60     *c_to++ = *c_from++;
61   return((void *) to);
62 #endif
63 }