bcopy.c 741 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. void attribute_hidden __bcopy(const void *s2, void *s1, size_t n)
  9. {
  10. #if 1
  11. __memmove(s1, s2, n);
  12. #else
  13. #ifdef __BCC__
  14. register char *s;
  15. register const char *p;
  16. s = s1;
  17. p = s2;
  18. if (p >= s) {
  19. while (n--) {
  20. *s++ = *p++;
  21. }
  22. } else {
  23. s += n;
  24. p += n;
  25. while (n--) {
  26. *--s = *--p;
  27. }
  28. }
  29. #else
  30. register char *s;
  31. register const char *p;
  32. s = s1;
  33. p = s2;
  34. if (p >= s) {
  35. while (n) {
  36. *s++ = *p++;
  37. --n;
  38. }
  39. } else {
  40. while (n) {
  41. --n;
  42. s[n] = p[n];
  43. }
  44. }
  45. #endif
  46. #endif
  47. }
  48. strong_alias(__bcopy,bcopy)