memcopy.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 02111-1307, USA. */
  17. #include "../generic/memcopy.h"
  18. /* We override the word-copying macros, partly because misalignment in one
  19. pointer isn't cause for a special function, partly because we want to
  20. get rid of all the static functions in generic/memcopy.c; these macros
  21. are only used in memmove.c since we have arch-specific mempcpy, memcpy and
  22. memset. */
  23. #undef OP_T_THRES
  24. #define OP_T_THRES OPSIZ
  25. #undef WORD_COPY_FWD
  26. #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
  27. do \
  28. { \
  29. unsigned long enddst_bp = dst_bp + nbytes - (nbytes % OPSIZ); \
  30. nbytes_left = (nbytes % OPSIZ); \
  31. while (dst_bp < (unsigned long) enddst_bp) \
  32. { \
  33. op_t x = *(op_t *) src_bp; \
  34. src_bp += sizeof x; \
  35. *(op_t *) dst_bp = x; \
  36. dst_bp += sizeof x; \
  37. } \
  38. } while (0)
  39. #undef WORD_COPY_BWD
  40. #define WORD_COPY_BWD(dst_bp, src_bp, nbytes_left, nbytes) \
  41. do \
  42. { \
  43. unsigned long enddst_bp = dst_bp - nbytes + (nbytes % OPSIZ); \
  44. nbytes_left = (nbytes % OPSIZ); \
  45. while (dst_bp > enddst_bp) \
  46. { \
  47. op_t x; \
  48. src_bp -= sizeof x; \
  49. x = *(op_t *) src_bp; \
  50. dst_bp -= sizeof x; \
  51. *(op_t *) dst_bp = x; \
  52. } \
  53. } while (0)