memcpy.c 1.0 KB

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