Went back to original fast versions. Redid using unions to get rid of the
gcc 3.x warnings.
This commit is contained in:
parent
93758f1c10
commit
d31d8fb2cc
|
@ -1,21 +1,85 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This is a _fast_ block move routine! */
|
||||
typedef union {
|
||||
void *v;
|
||||
char *c;
|
||||
short *s;
|
||||
long *l;
|
||||
} val;
|
||||
void bcopy(const void *s1,void *s2,size_t n)
|
||||
{
|
||||
unsigned char *ch1 = s1;
|
||||
unsigned char *ch2 = s2;
|
||||
if (ch1 < ch2) {
|
||||
while (n > 0) {
|
||||
*ch2++ = *ch1++;
|
||||
n--;
|
||||
}
|
||||
{
|
||||
size_t m;
|
||||
val v1, v2;
|
||||
v1.v = s1;
|
||||
v2.v = s2;
|
||||
|
||||
if(!n)
|
||||
return;
|
||||
|
||||
if(s2 < s1) {
|
||||
if(n > 15) {
|
||||
if((long)s1 & 1) {
|
||||
*v2.c++ = *v1.c++;
|
||||
n--;
|
||||
}
|
||||
if(!((long)s2 & 1)) {
|
||||
if((long)s1 & 2) {
|
||||
*v2.s++ = *v1.s++;
|
||||
n-=2;
|
||||
}
|
||||
for(m=n/(8*sizeof(long));m;--m) {
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
*v2.l++ = *v1.l++;
|
||||
}
|
||||
n &= 8 * sizeof(long) - 1;
|
||||
for(m = n / sizeof(long); m; --m)
|
||||
*v2.l++ = *v1.l++;
|
||||
n &= sizeof(long) - 1;
|
||||
}
|
||||
if(!n)
|
||||
return;
|
||||
}
|
||||
do;
|
||||
while(*v2.c++ = *v1.c++, --n);
|
||||
} else {
|
||||
ch1 += n;
|
||||
ch2 += n;
|
||||
while (n > 0) {
|
||||
*ch2-- = *ch1--;
|
||||
n--;
|
||||
}
|
||||
v1.c += n;
|
||||
v2.c += n;
|
||||
if(n > 15) {
|
||||
if((long)s1&1) {
|
||||
*--v2.c = *--v1.c;
|
||||
n--;
|
||||
}
|
||||
if(!((long)s2 & 1)) {
|
||||
if((long)s1 & 2) {
|
||||
*--v2.s=*--v1.s;
|
||||
n -= 2;
|
||||
}
|
||||
for(m = n / (8*sizeof(long)); m; --m) {
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
*--v2.l = *--v1.l;
|
||||
}
|
||||
n &= 8*sizeof(long)-1;
|
||||
for(m = n / sizeof(long); m; --m)
|
||||
*--v2.l = *--v1.l;
|
||||
n &= sizeof(long)-1;
|
||||
}
|
||||
if(!n)
|
||||
return;
|
||||
}
|
||||
do;
|
||||
while(*--v2.c = *--v1.c,--n);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,44 @@
|
|||
#include <memory.h>
|
||||
#include <string.h>
|
||||
typedef union {
|
||||
void *v;
|
||||
char *c;
|
||||
short *s;
|
||||
long *l;
|
||||
} val;
|
||||
|
||||
void bzero(void *b,size_t n)
|
||||
{
|
||||
unsigned char *ch = (unsigned char *)b;
|
||||
while (n > 0) {
|
||||
*ch++ = 0;
|
||||
n--;
|
||||
{
|
||||
val v;
|
||||
size_t m;
|
||||
v.v = b;
|
||||
|
||||
if(!n)
|
||||
return;
|
||||
if(n > 15) {
|
||||
if((long)v.l & 1) {
|
||||
*v.c++ = 0;
|
||||
n--;
|
||||
}
|
||||
if((long)v.l & 2) {
|
||||
*v.s++ = 0;
|
||||
n-= 2;
|
||||
}
|
||||
for(m = n / (8 * sizeof(long)); m; --m) {
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
*v.l++ = 0;
|
||||
}
|
||||
n &= 8 * sizeof(long) - 1;
|
||||
for(m = n / sizeof(long); m; --m)
|
||||
*v.l++ = 0;
|
||||
if((n &= sizeof(long) - 1)==0)
|
||||
return;
|
||||
}
|
||||
do;
|
||||
while(*v.c++ = 0, --n);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,47 @@
|
|||
#include <string.h>
|
||||
|
||||
typedef union {
|
||||
void *v;
|
||||
char *c;
|
||||
short *s;
|
||||
long *l;
|
||||
} val;
|
||||
void *memset(void *s,int c,size_t n)
|
||||
{
|
||||
unsigned char *ch = (unsigned char *)s;
|
||||
while (n > 0) {
|
||||
*ch++ = c;
|
||||
n--;
|
||||
size_t m;
|
||||
val v;
|
||||
v.v = s;
|
||||
|
||||
if(n) {
|
||||
if(n > 15) {
|
||||
c *= 0x01010101;
|
||||
if((long)v.l & 1) {
|
||||
*v.c++ = c;
|
||||
n--;
|
||||
}
|
||||
if((long)v.l & 2) {
|
||||
*v.s++ = c;
|
||||
n-=2;
|
||||
}
|
||||
for(m= n / (8 * sizeof(long)); m; --m) {
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
*v.l++ = c;
|
||||
}
|
||||
n &= (8 * sizeof(long)-1);
|
||||
for(m = n / sizeof(long); m; --m)
|
||||
*v.l++ = c;
|
||||
if((n &= sizeof(long) - 1)==0)
|
||||
goto leave;
|
||||
}
|
||||
do;
|
||||
while(*v.c++ = c, --n);
|
||||
}
|
||||
leave:
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue