-/* this is a drop-in replacement for bcopy(), except for the return
- * value, which we need to be able to emulate memcpy() */
-#if !defined(HAS_MEMCPY) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY))
-void *
-Perl_my_bcopy(const void *vfrom, void *vto, size_t len)
-{
-#if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
- bcopy(vfrom, vto, len);
-#else
- const unsigned char *from = (const unsigned char *)vfrom;
- unsigned char *to = (unsigned char *)vto;
-
- PERL_ARGS_ASSERT_MY_BCOPY;
-
- if (from - to >= 0) {
- while (len--)
- *to++ = *from++;
- }
- else {
- to += len;
- from += len;
- while (len--)
- *(--to) = *(--from);
- }
-#endif
-
- return vto;
-}
-#endif
-
-/* this is a drop-in replacement for memset() */
-#ifndef HAS_MEMSET
-void *
-Perl_my_memset(void *vloc, int ch, size_t len)
-{
- unsigned char *loc = (unsigned char *)vloc;
-
- PERL_ARGS_ASSERT_MY_MEMSET;
-
- while (len--)
- *loc++ = ch;
- return vloc;
-}
-#endif
-
-/* this is a drop-in replacement for bzero() */
-#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-void *
-Perl_my_bzero(void *vloc, size_t len)
-{
- unsigned char *loc = (unsigned char *)vloc;
-
- PERL_ARGS_ASSERT_MY_BZERO;
-
- while (len--)
- *loc++ = 0;
- return vloc;
-}
-#endif
-
-/* this is a drop-in replacement for memcmp() */
-#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
-int
-Perl_my_memcmp(const void *vs1, const void *vs2, size_t len)
-{
- const U8 *a = (const U8 *)vs1;
- const U8 *b = (const U8 *)vs2;
- int tmp;
-
- PERL_ARGS_ASSERT_MY_MEMCMP;
-
- while (len--) {
- if ((tmp = *a++ - *b++))
- return tmp;
- }
- return 0;
-}
-#endif /* !HAS_MEMCMP || !HAS_SANE_MEMCMP */
-
-#ifndef HAS_VPRINTF
-/* This vsprintf replacement should generally never get used, since
- vsprintf was available in both System V and BSD 2.11. (There may
- be some cross-compilation or embedded set-ups where it is needed,
- however.)
-
- If you encounter a problem in this function, it's probably a symptom
- that Configure failed to detect your system's vprintf() function.
- See the section on "item vsprintf" in the INSTALL file.
-
- This version may compile on systems with BSD-ish <stdio.h>,
- but probably won't on others.
-*/
-
-#ifdef USE_CHAR_VSPRINTF
-char *
-#else
-int
-#endif
-vsprintf(char *dest, const char *pat, void *args)
-{
- FILE fakebuf;
-
-#if defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
- FILE_ptr(&fakebuf) = (STDCHAR *) dest;
- FILE_cnt(&fakebuf) = 32767;
-#else
- /* These probably won't compile -- If you really need
- this, you'll have to figure out some other method. */
- fakebuf._ptr = dest;
- fakebuf._cnt = 32767;
-#endif
-#ifndef _IOSTRG
-#define _IOSTRG 0
-#endif
- fakebuf._flag = _IOWRT|_IOSTRG;
- _doprnt(pat, args, &fakebuf); /* what a kludge */
-#if defined(STDIO_PTR_LVALUE)
- *(FILE_ptr(&fakebuf)++) = '\0';
-#else
- /* PerlIO has probably #defined away fputc, but we want it here. */
-# ifdef fputc
-# undef fputc /* XXX Should really restore it later */
-# endif
- (void)fputc('\0', &fakebuf);
-#endif
-#ifdef USE_CHAR_VSPRINTF
- return(dest);
-#else
- return 0; /* perl doesn't use return value */
-#endif
-}
-
-#endif /* HAS_VPRINTF */
-