memcopy.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (C) 2001 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Modified for use in uClibc (C) 2007 Axis Communications AB.
  4. Minimal modifications: include path name and #undef of WORD_COPY_FWD/BWD
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. 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. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If not,
  15. see <http://www.gnu.org/licenses/>. */
  16. #include "../generic/memcopy.h"
  17. /* We override the word-copying macros, partly because misalignment in one
  18. pointer isn't cause for a special function, partly because we want to
  19. get rid of all the static functions in generic/memcopy.c; these macros
  20. are only used in memmove.c since we have arch-specific mempcpy, memcpy and
  21. memset. */
  22. #undef OP_T_THRES
  23. #define OP_T_THRES OPSIZ
  24. #undef WORD_COPY_FWD
  25. #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
  26. do \
  27. { \
  28. unsigned long enddst_bp = dst_bp + nbytes - (nbytes % OPSIZ); \
  29. nbytes_left = (nbytes % OPSIZ); \
  30. while (dst_bp < (unsigned long) enddst_bp) \
  31. { \
  32. op_t x = *(op_t *) src_bp; \
  33. src_bp += sizeof x; \
  34. *(op_t *) dst_bp = x; \
  35. dst_bp += sizeof x; \
  36. } \
  37. } while (0)
  38. #undef WORD_COPY_BWD
  39. #define WORD_COPY_BWD(dst_bp, src_bp, nbytes_left, nbytes) \
  40. do \
  41. { \
  42. unsigned long enddst_bp = dst_bp - nbytes + (nbytes % OPSIZ); \
  43. nbytes_left = (nbytes % OPSIZ); \
  44. while (dst_bp > enddst_bp) \
  45. { \
  46. op_t x; \
  47. src_bp -= sizeof x; \
  48. x = *(op_t *) src_bp; \
  49. dst_bp -= sizeof x; \
  50. *(op_t *) dst_bp = x; \
  51. } \
  52. } while (0)