avoid SIGBUS in byte_copy
This commit is contained in:
parent
52b12478c6
commit
a0dbb50dc7
2
CHANGES
2
CHANGES
@ -1,5 +1,5 @@
|
|||||||
0.14:
|
0.14:
|
||||||
only use faster byte_copy on i386
|
avoid bus errors in byte_copy
|
||||||
|
|
||||||
0.13:
|
0.13:
|
||||||
fixed several bugs in test/uudecode.c
|
fixed several bugs in test/uudecode.c
|
||||||
|
@ -6,23 +6,18 @@ void byte_copy(void* out, unsigned int len, const void* in) {
|
|||||||
register char* s=out;
|
register char* s=out;
|
||||||
register const char* t=in;
|
register const char* t=in;
|
||||||
register const char* u=t+len;
|
register const char* u=t+len;
|
||||||
#ifdef __i386__
|
|
||||||
if (len>127) {
|
if (len>127) {
|
||||||
if (sizeof(unsigned long)>4) { /* a good compiler should optimize this check away */
|
while ((unsigned long)s&(sizeof(unsigned long)-1))
|
||||||
for (;(unsigned long)t&7;) {
|
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
if (t==u) break; *s=*t; ++s; ++t;
|
||||||
}
|
}
|
||||||
} else {
|
/* s (destination) is now unsigned long aligned */
|
||||||
for (;(unsigned long)t&3;) {
|
#ifndef __i386__
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
if (!((unsigned long)t&(sizeof(unsigned long)-1)))
|
||||||
}
|
|
||||||
}
|
|
||||||
while (t+sizeof(long)<=u) {
|
|
||||||
*(unsigned long*)s=*(unsigned long*)t;
|
|
||||||
s+=sizeof(long); t+=sizeof(long);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
while (t+sizeof(unsigned long)<=u) {
|
||||||
|
*(unsigned long*)s=*(unsigned long*)t;
|
||||||
|
s+=sizeof(unsigned long); t+=sizeof(unsigned long);
|
||||||
|
}
|
||||||
for (;;) {
|
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user