You cannot 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
C

24 years ago
#include "byte.h"
/* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
* to out[len-1]. */
void byte_copy(void* out, unsigned long len, const void* in) {
24 years ago
register char* s=out;
register const char* t=in;
23 years ago
register const char* u=t+len;
if (len>127) {
23 years ago
while ((unsigned long)s&(sizeof(unsigned long)-1)) {
if (t==u) break; *s=*t; ++s; ++t;
23 years ago
}
/* s (destination) is now unsigned long aligned */
#ifndef __i386__
23 years ago
if (!((unsigned long)t&(sizeof(unsigned long)-1)))
#endif
23 years ago
while (t+sizeof(unsigned long)<=u) {
*(unsigned long*)s=*(unsigned long*)t;
s+=sizeof(unsigned long); t+=sizeof(unsigned long);
}
}
24 years ago
for (;;) {
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
}
}