Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
833 B

  1. #include "byte.h"
  2. /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
  3. * to out[len-1]. */
  4. void byte_copy(void* out, unsigned long len, const void* in) {
  5. register char* s=out;
  6. register const char* t=in;
  7. register const char* u=t+len;
  8. if (len>127) {
  9. while ((unsigned long)s&(sizeof(unsigned long)-1)) {
  10. if (t==u) break; *s=*t; ++s; ++t;
  11. }
  12. /* s (destination) is now unsigned long aligned */
  13. #ifndef __i386__
  14. if (!((unsigned long)t&(sizeof(unsigned long)-1)))
  15. #endif
  16. while (t+sizeof(unsigned long)<=u) {
  17. *(unsigned long*)s=*(unsigned long*)t;
  18. s+=sizeof(unsigned long); t+=sizeof(unsigned long);
  19. }
  20. }
  21. for (;;) {
  22. if (t==u) break; *s=*t; ++s; ++t;
  23. if (t==u) break; *s=*t; ++s; ++t;
  24. if (t==u) break; *s=*t; ++s; ++t;
  25. if (t==u) break; *s=*t; ++s; ++t;
  26. }
  27. }