From b4fd0ca9be14c81023db759c405c0f67cfa78166 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Sat, 9 Mar 2019 12:37:09 -0500 Subject: [PATCH] Include cstring for sanity_test_fdelt if required SmartOS FD_ZERO is implemented in a way that requires an external declaration of memcpy. We can not simply include cstring in the existing file because sanity_test_memcpy is attempting to replace memcpy, but we can do so here, now that the fdelt test is split out. --- configure.ac | 33 +++++++++++++++++++++++++++++++ src/compat/glibc_sanity_fdelt.cpp | 3 +++ 2 files changed, 36 insertions(+) diff --git a/configure.ac b/configure.ac index a3ba8ce80..579aeed49 100644 --- a/configure.ac +++ b/configure.ac @@ -758,6 +758,39 @@ fi AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) +# FD_ZERO may be dependent on a declaration of memcpy, e.g. in SmartOS +# check that it fails to build without memcpy, then that it builds with +AC_MSG_CHECKING(FD_ZERO memcpy dependence) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #if HAVE_SYS_SELECT_H + #include + #endif + ]],[[ + #if HAVE_SYS_SELECT_H + fd_set fds; + FD_ZERO(&fds); + #endif + ]])], + [ AC_MSG_RESULT(no) ], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #if HAVE_SYS_SELECT_H + #include + #endif + ]], [[ + #if HAVE_SYS_SELECT_H + fd_set fds; + FD_ZERO(&fds); + #endif + ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CSTRING_DEPENDENT_FD_ZERO, 1, [Define this symbol if FD_ZERO is dependent of a memcpy declaration being available]) ], + [ AC_MSG_ERROR(failed with cstring include) ] + ) + ] +) + AC_CHECK_DECLS([getifaddrs, freeifaddrs],,, [#include #include ] diff --git a/src/compat/glibc_sanity_fdelt.cpp b/src/compat/glibc_sanity_fdelt.cpp index 13661d3ee..87140d0c7 100644 --- a/src/compat/glibc_sanity_fdelt.cpp +++ b/src/compat/glibc_sanity_fdelt.cpp @@ -7,6 +7,9 @@ #endif #if defined(HAVE_SYS_SELECT_H) +#ifdef HAVE_CSTRING_DEPENDENT_FD_ZERO +#include +#endif #include // trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined