From 02887b73ebdbf3a222b87d8f09c65b58b7b9a696 Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Wed, 30 Jan 2013 18:49:08 -0500 Subject: [PATCH] Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable --- configure.ac | 1 + include/strutils.h | 3 +++ lib/strutils.c | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 9024809e7e..df989efb5d 100644 --- a/configure.ac +++ b/configure.ac @@ -313,6 +313,7 @@ AC_CHECK_FUNCS([ \ lchown \ llseek \ lseek64 \ + mempcpy \ nanosleep \ personality \ posix_fadvise \ diff --git a/include/strutils.h b/include/strutils.h index 123907fc98..00598cf622 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -28,6 +28,9 @@ extern double strtod_or_err(const char *str, const char *errmesg); extern long strtol_or_err(const char *str, const char *errmesg); extern unsigned long strtoul_or_err(const char *str, const char *errmesg); +#ifndef HAVE_MEMPCPY +extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n); +#endif #ifndef HAVE_STRNLEN extern size_t strnlen(const char *s, size_t maxlen); #endif diff --git a/lib/strutils.c b/lib/strutils.c index 5dda138051..2337b07b96 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -132,6 +132,13 @@ err: return -1; } +#ifndef HAVE_MEMPCPY +void *mempcpy(void *restrict dest, const void *restrict src, size_t n) +{ + return ((char *)memcpy(dest, src, n)) + n; +} +#endif + #ifndef HAVE_STRNLEN size_t strnlen(const char *s, size_t maxlen) { -- 2.39.5