Skip to content

Commit b4fd0ca

Browse files
committed
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.
1 parent 7fb886b commit b4fd0ca

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

configure.ac

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,39 @@ fi
758758

759759
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])
760760

761+
# FD_ZERO may be dependent on a declaration of memcpy, e.g. in SmartOS
762+
# check that it fails to build without memcpy, then that it builds with
763+
AC_MSG_CHECKING(FD_ZERO memcpy dependence)
764+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
765+
#include <cstddef>
766+
#if HAVE_SYS_SELECT_H
767+
#include <sys/select.h>
768+
#endif
769+
]],[[
770+
#if HAVE_SYS_SELECT_H
771+
fd_set fds;
772+
FD_ZERO(&fds);
773+
#endif
774+
]])],
775+
[ AC_MSG_RESULT(no) ],
776+
[
777+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
778+
#include <cstring>
779+
#if HAVE_SYS_SELECT_H
780+
#include <sys/select.h>
781+
#endif
782+
]], [[
783+
#if HAVE_SYS_SELECT_H
784+
fd_set fds;
785+
FD_ZERO(&fds);
786+
#endif
787+
]])],
788+
[ 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]) ],
789+
[ AC_MSG_ERROR(failed with cstring include) ]
790+
)
791+
]
792+
)
793+
761794
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
762795
[#include <sys/types.h>
763796
#include <ifaddrs.h>]

src/compat/glibc_sanity_fdelt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#endif
88

99
#if defined(HAVE_SYS_SELECT_H)
10+
#ifdef HAVE_CSTRING_DEPENDENT_FD_ZERO
11+
#include <cstring>
12+
#endif
1013
#include <sys/select.h>
1114

1215
// trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined

0 commit comments

Comments
 (0)