PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/m68knommu/lib/memcpy.c

https://bitbucket.org/cresqo/cm7-p500-kernel
C | 62 lines | 59 code | 3 blank | 0 comment | 9 complexity | bf42e89c138d4262e9c8f0b81d6b458c MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
 1
 2#include <linux/types.h>
 3
 4void * memcpy(void * to, const void * from, size_t n)
 5{
 6#ifdef CONFIG_COLDFIRE
 7  void *xto = to;
 8  size_t temp;
 9
10  if (!n)
11    return xto;
12  if ((long) to & 1)
13    {
14      char *cto = to;
15      const char *cfrom = from;
16      *cto++ = *cfrom++;
17      to = cto;
18      from = cfrom;
19      n--;
20    }
21  if (n > 2 && (long) to & 2)
22    {
23      short *sto = to;
24      const short *sfrom = from;
25      *sto++ = *sfrom++;
26      to = sto;
27      from = sfrom;
28      n -= 2;
29    }
30  temp = n >> 2;
31  if (temp)
32    {
33      long *lto = to;
34      const long *lfrom = from;
35      for (; temp; temp--)
36	*lto++ = *lfrom++;
37      to = lto;
38      from = lfrom;
39    }
40  if (n & 2)
41    {
42      short *sto = to;
43      const short *sfrom = from;
44      *sto++ = *sfrom++;
45      to = sto;
46      from = sfrom;
47    }
48  if (n & 1)
49    {
50      char *cto = to;
51      const char *cfrom = from;
52      *cto = *cfrom;
53    }
54  return xto;
55#else
56  const char *c_from = from;
57  char *c_to = to;
58  while (n-- > 0)
59    *c_to++ = *c_from++;
60  return((void *) to);
61#endif
62}