linux/arch/m68knommu/lib/memcpy.c
<<
>>
Prefs
   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}
  63