summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-12-26 06:22:47 -0800
committerH. Peter Anvin <hpa@zytor.com>2018-12-26 06:22:47 -0800
commit06f72bb968a3f0a10d0ed37524075bd6388e2090 (patch)
tree433288cdf6b4a61cbe9d2e60b01966284bf153fb
parent77703ae4a4fedbea22d80cad77e5a637e164ba76 (diff)
downloadnasm-06f72bb968a3f0a10d0ed37524075bd6388e2090.tar.gz
Test for the mempcpy() function and add alternative if missing
If memcpy() doesn't exist, then add an inline alternative using memcpy(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--configure.ac1
-rw-r--r--include/compiler.h7
2 files changed, 8 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 2ab74ed0..e94d8109 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,7 @@ AC_CHECK_FUNCS(strnlen)
AC_CHECK_FUNCS(strrchrnul)
AC_CHECK_FUNCS(iscntrl)
AC_CHECK_FUNCS(isascii)
+AC_CHECK_FUNCS(mempcpy)
AC_CHECK_FUNCS(getuid)
AC_CHECK_FUNCS(getgid)
diff --git a/include/compiler.h b/include/compiler.h
index 7a80e2e4..b390bc2d 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -219,6 +219,13 @@ char *strsep(char **, const char *);
size_t strnlen(const char *s, size_t maxlen);
#endif
+#ifndef HAVE_MEMPCPY
+static inline void *mempcpy(void *dst, const void *src, size_t n)
+{
+ return memcpy(dst, src, n) + n;
+}
+#endif
+
/*
* Hack to support external-linkage inline functions
*/