#include <config.h>
#include "ansidecl.h"

#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif

#ifndef HAVE_BCOPY
#undef bcopy
void
  bcopy (src, dest, len)
     register char *src, *dest;
     int len;
{
  if (dest < src)
    while (len--)
      *dest++ = *src++;
  else
    {
      char *lasts = src + (len - 1);
      char *lastd = dest + (len - 1);
      while (len--)
	*(char *) lastd-- = *(char *) lasts--;
    }
}
#endif /* !HAVE_BCOPY */

#ifdef HAVE_MEMCPY
PTR
  memcpy (out, in, length)
     PTR out;
     CONST PTR in;
     size_t length;
{
  bcopy (in, out, length);
  return out;
}
#endif /* ! HAVE_MEMCPY */

#ifdef HAVE_MEMMOVE
PTR
  memmove (s1, s2, n)
     PTR s1;
     CONST PTR s2;
     size_t n;
{
  bcopy (s2, s1, n);
  return s1;
}
#endif /* !HAVE_MEMMOVE */
