]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix configure issue detecting stdatomic.h support (#46959)
authorMukund Sivaraman <muks@isc.org>
Mon, 22 Jan 2018 08:05:29 +0000 (13:35 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 22 Jan 2018 08:20:38 +0000 (13:50 +0530)
(cherry picked from commit 63d0c6a3fc890ff02bd8f0f6215e5b495eb076b8)
(cherry picked from commit 7e1ed157621bf554d5f2dff29a3c249037d214f3)

CHANGES
config.h.in
configure
configure.in

diff --git a/CHANGES b/CHANGES
index b9ea23c4f514bb9bbb89a2e7f6fd0760e60d81ab..72f0fee3079a80ccaffa0d9dff14a71ea1aa3977 100644 (file)
--- 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]
 
index 5eb8b8ddc28912fef66b758befca6a927ae6048e..701526c820a01260d20d1320008cd2ab5d4a85af 100644 (file)
@@ -449,9 +449,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 <stdatomic.h> header file. */
-#undef HAVE_STDATOMIC_H
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
index 572035eb82fea1c357f0e404d857754ac8ddcd5c..b03ca330096b2e97d7d9fcece0ad758a0306a576 100755 (executable)
--- a/configure
+++ b/configure
@@ -20411,22 +20411,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 <stdio.h>
+#include <stdatomic.h>
+
+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 :
index d0079aaa75b00e632f892baf91cb4c6eb2bf6f65..1c80c3f6482f77c15b0d3c73a11d9d2674fa4ab0 100644 (file)
@@ -4169,11 +4169,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 <stdio.h>
+#include <stdatomic.h>
+],
+[
+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],