memcopy.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* memcopy.h -- definitions for memory copy functions. Motorola 68020 version.
  2. Copyright (C) 1991-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <sysdeps/generic/memcopy.h>
  16. #if defined(__mc68020__) || defined(mc68020)
  17. /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020,
  18. because of its weird instruction overlap characteristics. */
  19. #undef WORD_COPY_FWD
  20. #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
  21. do \
  22. { \
  23. size_t __nwords = (nbytes) / sizeof (op_t); \
  24. size_t __nblocks = __nwords / 8 + 1; \
  25. dst_bp -= (8 - __nwords % 8) * sizeof (op_t); \
  26. src_bp -= (8 - __nwords % 8) * sizeof (op_t); \
  27. switch (__nwords % 8) \
  28. do \
  29. { \
  30. ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0]; \
  31. /* Fall through. */ \
  32. case 7: \
  33. ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1]; \
  34. /* Fall through. */ \
  35. case 6: \
  36. ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2]; \
  37. /* Fall through. */ \
  38. case 5: \
  39. ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3]; \
  40. /* Fall through. */ \
  41. case 4: \
  42. ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4]; \
  43. /* Fall through. */ \
  44. case 3: \
  45. ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5]; \
  46. /* Fall through. */ \
  47. case 2: \
  48. ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6]; \
  49. /* Fall through. */ \
  50. case 1: \
  51. ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7]; \
  52. /* Fall through. */ \
  53. case 0: \
  54. src_bp += 32; \
  55. dst_bp += 32; \
  56. __nblocks--; \
  57. } \
  58. while (__nblocks != 0); \
  59. (nbytes_left) = (nbytes) % sizeof (op_t); \
  60. } while (0)
  61. #undef WORD_COPY_BWD
  62. #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
  63. do \
  64. { \
  65. size_t __nblocks = (nbytes) / 32 + 1; \
  66. op_t *__dst_ep = (op_t *) (dst_ep); \
  67. op_t *__src_ep = (op_t *) (src_ep); \
  68. switch ((nbytes) / sizeof (op_t) % 8) \
  69. do \
  70. { \
  71. *--__dst_ep = *--__src_ep; \
  72. /* Fall through. */ \
  73. case 7: \
  74. *--__dst_ep = *--__src_ep; \
  75. /* Fall through. */ \
  76. case 6: \
  77. *--__dst_ep = *--__src_ep; \
  78. /* Fall through. */ \
  79. case 5: \
  80. *--__dst_ep = *--__src_ep; \
  81. /* Fall through. */ \
  82. case 4: \
  83. *--__dst_ep = *--__src_ep; \
  84. /* Fall through. */ \
  85. case 3: \
  86. *--__dst_ep = *--__src_ep; \
  87. /* Fall through. */ \
  88. case 2: \
  89. *--__dst_ep = *--__src_ep; \
  90. /* Fall through. */ \
  91. case 1: \
  92. *--__dst_ep = *--__src_ep; \
  93. /* Fall through. */ \
  94. case 0: \
  95. __nblocks--; \
  96. } \
  97. while (__nblocks != 0); \
  98. (nbytes_left) = (nbytes) % sizeof (op_t); \
  99. (dst_ep) = (unsigned long) __dst_ep; \
  100. (src_ep) = (unsigned long) __src_ep; \
  101. } while (0)
  102. #endif