bcopy.c 758 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 __UCLIBC_SUSV3_LEGACY__
  9. libc_hidden_proto(memmove)
  10. void bcopy(const void *s2, void *s1, size_t n)
  11. {
  12. #if 1
  13. memmove(s1, s2, n);
  14. #else
  15. #ifdef __BCC__
  16. register char *s;
  17. register const char *p;
  18. s = s1;
  19. p = 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. #else
  32. register char *s;
  33. register const char *p;
  34. s = s1;
  35. p = s2;
  36. if (p >= s) {
  37. while (n) {
  38. *s++ = *p++;
  39. --n;
  40. }
  41. } else {
  42. while (n) {
  43. --n;
  44. s[n] = p[n];
  45. }
  46. }
  47. #endif
  48. #endif
  49. }
  50. #endif