memmove.c 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef WANT_WIDE
  9. # define __Wmemmove __wmemmove
  10. # define Wmemmove wmemmove
  11. #else
  12. # define __Wmemmove __memmove
  13. # define Wmemmove memmove
  14. #endif
  15. Wvoid attribute_hidden *__Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
  16. {
  17. #ifdef __BCC__
  18. register Wchar *s = (Wchar *) s1;
  19. register const Wchar *p = (const Wchar *) s2;
  20. if (p >= s) {
  21. while (n--) {
  22. *s++ = *p++;
  23. }
  24. } else {
  25. s += n;
  26. p += n;
  27. while (n--) {
  28. *--s = *--p;
  29. }
  30. }
  31. return s1;
  32. #else
  33. register Wchar *s = (Wchar *) s1;
  34. register const Wchar *p = (const Wchar *) s2;
  35. if (p >= s) {
  36. while (n) {
  37. *s++ = *p++;
  38. --n;
  39. }
  40. } else {
  41. while (n) {
  42. --n;
  43. s[n] = p[n];
  44. }
  45. }
  46. return s1;
  47. #endif
  48. }
  49. strong_alias(__Wmemmove,Wmemmove)