133965Sjdp/* bcopy -- copy memory regions of arbitary length
233965Sjdp
389857Sobrien@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
433965Sjdp
589857SobrienCopies @var{length} bytes from memory region @var{in} to region
689857Sobrien@var{out}.  The use of @code{bcopy} is deprecated in new programs.
733965Sjdp
889857Sobrien@end deftypefn
933965Sjdp
1033965Sjdp*/
1133965Sjdp
12218822Sdim#include <stddef.h>
13218822Sdim
1433965Sjdpvoid
15218822Sdimbcopy (const void *src, void *dest, size_t len)
1633965Sjdp{
1733965Sjdp  if (dest < src)
18218822Sdim    {
19218822Sdim      const char *firsts = (const char *) src;
20218822Sdim      char *firstd = (char *) dest;
21218822Sdim      while (len--)
22218822Sdim	*firstd++ = *firsts++;
23218822Sdim    }
2433965Sjdp  else
2533965Sjdp    {
26218822Sdim      const char *lasts = (const char *)src + (len-1);
27218822Sdim      char *lastd = (char *)dest + (len-1);
2833965Sjdp      while (len--)
29218822Sdim        *lastd-- = *lasts--;
3033965Sjdp    }
3133965Sjdp}
32