From 7c36869fdff2cdff1373b895c9424cb89dc08e67 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Mon, 22 Jan 2018 13:35:29 +0530 Subject: [PATCH] Fix configure issue detecting stdatomic.h support (#46959) (cherry picked from commit 63d0c6a3fc890ff02bd8f0f6215e5b495eb076b8) (cherry picked from commit 7e1ed157621bf554d5f2dff29a3c249037d214f3) (cherry picked from commit fd82c70695888c134287b8018296028c252d100e) --- CHANGES | 4 ++++ config.h.in | 3 --- configure | 40 +++++++++++++++++++++++++++------------- configure.in | 19 ++++++++++++++----- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index cc6fe7e53b..2a3955c155 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4871. [bug] Fix configure glitch in detecting stdatomic.h + support on systems with multiple compilers. + [RT #46959] + 4870. [test] Update included ATF library to atf-0.21 preserving the ATF tool. [RT #46967] diff --git a/config.h.in b/config.h.in index 3ff8f1639a..49eaffb3dd 100644 --- a/config.h.in +++ b/config.h.in @@ -453,9 +453,6 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the `setresuid' function. */ #undef HAVE_SETRESUID -/* Define to 1 if you have the header file. */ -#undef HAVE_STDATOMIC_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/configure b/configure index 4eba85a05a..5fbd916b1b 100755 --- a/configure +++ b/configure @@ -20093,22 +20093,36 @@ done # Machine architecture dependent features # have_stdatomic=no -for ac_header in stdatomic.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdatomic.h" "ac_cv_header_stdatomic_h" "$ac_includes_default" -if test "x$ac_cv_header_stdatomic_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDATOMIC_H 1 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usable stdatomic.h" >&5 +$as_echo_n "checking for usable stdatomic.h... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + +atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed); + + ; + return 0; +} _ACEOF - have_stdatomic=yes - ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1" +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_stdatomic=yes + ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1" else - have_stdatomic=no - ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + have_stdatomic=no + ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC" fi - -done - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Check whether --enable-atomic was given. if test "${enable_atomic+set}" = set; then : diff --git a/configure.in b/configure.in index 924585ed5d..cefbeba2de 100644 --- a/configure.in +++ b/configure.in @@ -4037,11 +4037,20 @@ AC_CHECK_FUNCS(nanosleep usleep explicit_bzero) # Machine architecture dependent features # have_stdatomic=no -AC_CHECK_HEADERS(stdatomic.h, - [have_stdatomic=yes - ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"], - [have_stdatomic=no - ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"]) +AC_MSG_CHECKING(for usable stdatomic.h) +AC_TRY_COMPILE([ +#include +#include +], +[ +atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed); +], + [AC_MSG_RESULT(yes) + have_stdatomic=yes + ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"], + [AC_MSG_RESULT(no) + have_stdatomic=no + ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"]) AC_ARG_ENABLE(atomic, AS_HELP_STRING([--enable-atomic],