home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
c
/
memcpy
< prev
next >
Wrap
Text File
|
1994-03-08
|
2KB
|
112 lines
#ifdef __STDC__
static char sccs_id[] = "@(#) memcpy.c 1.0 " __DATE__ " HJR";
#else
static char sccs_id[] = "@(#) memcpy.c 1.0 26/9/90 HJR";
#endif
/* memcpy.c (c) Copyright 1990 H.Rogers */
#include <string.h>
#ifdef ARCH
extern void *__memcpy (void *, const void *, size_t);
#endif
#ifdef __STDC__
void *(memcpy) (register void *s1, register const void *s2, register size_t n)
#else
void *(memcpy) (s1, s2, n)
register void *s1;
register const void *s2;
register size_t n;
#endif
#ifdef ARCH
{
return (__memcpy (s1, s2, n));
}
#else
{
register unsigned char *_s1 = (unsigned char *) s1, *_s2 = (unsigned char *) s2;
if (_s1 == _s2)
return (s1);
if (_s1 < _s2)
{
while (n & 0x07)
{
n--;
*_s1++ = *_s2++;
}
n >>= 3;
while (n)
{
n--;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
*_s1++ = *_s2++;
}
}
else
{
_s1 += n;
_s2 += n;
while (n & 0x07)
{
n--;
*--_s1 = *--_s2;
}
n >>= 3;
while (n)
{
n--;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
*--_s1 = *--_s2;
}
}
return (s1);
}
#endif
#ifdef __STDC__
void *(memmove) (register void *s1, register const void *s2, register size_t n)
#else
void *(memmove) (s1, s2, n)
register void *s1;
register const void *s2;
register size_t n;
#endif
#ifdef ARCH
{
return (__memcpy (s1, s2, n));
}
#else
{
return (memcpy (s1, s2, n));
}
#endif
#ifdef __STDC__
void *(bcopy) (register const void *s1, register void *s2, register size_t n)
#else
void *(bcopy) (s1, s2, n)
register void *s1;
register const void *s2;
register size_t n;
#endif
{
return (bcopy (s1, s2, n));
}