memcpy.c 1.1 KB

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