memcopy.h 3.7 KB

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