bcopy.c 719 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. libc_hidden_proto(memmove)
  9. void bcopy(const void *s2, void *s1, size_t n)
  10. {
  11. #if 1
  12. memmove(s1, s2, n);
  13. #else
  14. #ifdef __BCC__
  15. register char *s;
  16. register const char *p;
  17. s = s1;
  18. p = s2;
  19. if (p >= s) {
  20. while (n--) {
  21. *s++ = *p++;
  22. }
  23. } else {
  24. s += n;
  25. p += n;
  26. while (n--) {
  27. *--s = *--p;
  28. }
  29. }
  30. #else
  31. register char *s;
  32. register const char *p;
  33. s = s1;
  34. p = 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. #endif
  47. #endif
  48. }