/*
* mcopy - copy memory.
*/
static void
mcopy (from, to, size)
regist char *from, *to;
regist int size;
{
regist char *frome, *toe;
if (size <= 0) return;
frome = from + size;
if (from >= to || frome <= to) {
bcopy (from, to, size);
}
else {
/* Source and destination overlap with destination above source.
Therefore a forward copy will bash later source to be copied.
Use a backward copy instead. */
toe = to + size;
if ((((unsigned)to ^ (unsigned)from) & 3) != 0 || size < 4) {
/* alignment of source and destination not identical;
use a simple byte copy. */
do {
*--toe = *--frome;
} while (frome != from);
}
else {
while (((unsigned)toe & 3) != 0) {
*--toe = *--frome;
size -= 1;
}
size -= 16;
while (size >= 0) {
toe -= 16;
frome -= 16;
((int*)toe)[3] = ((int*)frome)[3];
((int*)toe)[2] = ((int*)frome)[2];
((int*)toe)[1] = ((int*)frome)[1];
((int*)toe)[0] = ((int*)frome)[0];
size -= 16;
}
size += 16 - 4;
while (size >= 0) {
toe -= 4;
frome -= 4;
((int*)toe)[0] = ((int*)frome)[0];
size -= 4;
}
size += 4;
while (size > 0) {
*--toe = *--frome;
size -= 1;
}
}
}
}
c해라
댓글 0