]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] Check if -latomic is needed to handle 64-bit stdatomic.h types
authorEvan Hunt <each@isc.org>
Tue, 7 Nov 2017 21:27:14 +0000 (13:27 -0800)
committerEvan Hunt <each@isc.org>
Tue, 7 Nov 2017 21:27:14 +0000 (13:27 -0800)
4809. [port] Check at configure time whether -latomic is needed
for stdatomic.h. [RT #46324]

CHANGES
configure
configure.in

diff --git a/CHANGES b/CHANGES
index 23f3d07370501c8eeb493a512823cd7d355673ec..d49df623dce660458fb7a6991f50acead7bce0ce 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4809.  [port]          Check at configure time whether -latomic is needed
+                       for stdatomic.h. [RT #46324]
+
 4808.  [bug]           Properly test for zlib.h. [RT #46504]
 
 4807.  [cleanup]       isc_rng_randombytes() returns a specified number of
index bb5ebdb120ae1ff9673a727b29c74d1245456e77..136d531ff6d174b554c2cdd0c5603ac7b875a026 100755 (executable)
--- a/configure
+++ b/configure
@@ -20129,6 +20129,7 @@ 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"
@@ -20136,9 +20137,11 @@ if test "x$ac_cv_header_stdatomic_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_STDATOMIC_H 1
 _ACEOF
- ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"
+ have_stdatomic=yes
+                 ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"
 else
-  ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"
+  have_stdatomic=no
+                 ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"
 fi
 
 done
@@ -20219,12 +20222,42 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
                esac
                ;;
        no)
+               have_stdatomic=no
                ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"
                use_atomic=no
                arch=noatomic
                ;;
 esac
 
+if test "X$have_stdatomic" = "Xyes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -latomic is needed to use 64-bit stdatomic.h primitives" >&5
+$as_echo_n "checking if -latomic is needed to use 64-bit stdatomic.h primitives... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdatomic.h>
+int
+main ()
+{
+atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+        ISC_ATOMIC_LIBS=""
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+        ISC_ATOMIC_LIBS="-latomic"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$LIBS $ISC_ATOMIC_LIBS"
+fi
+
 
 
 ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"
index 31089024192fd35ae3d4b07ef4eaa056a7038d2e..81788165b9a8688b2b34b86d78461ecc17e48797 100644 (file)
@@ -4006,9 +4006,12 @@ AC_CHECK_FUNCS(nanosleep usleep explicit_bzero)
 #
 # Machine architecture dependent features
 #
+have_stdatomic=no
 AC_CHECK_HEADERS(stdatomic.h,
-                [ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"],
-                [ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"])
+                [have_stdatomic=yes
+                 ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"],
+                [have_stdatomic=no
+                 ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"])
 
 AC_ARG_ENABLE(atomic,
        [  --enable-atomic        enable machine specific atomic operations
@@ -4052,12 +4055,26 @@ case "$enable_atomic" in
                esac
                ;;
        no)
+               have_stdatomic=no
                ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"
                use_atomic=no
                arch=noatomic
                ;;
 esac
 
+if test "X$have_stdatomic" = "Xyes"; then
+    AC_MSG_CHECKING(if -latomic is needed to use 64-bit stdatomic.h primitives)
+    AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM([#include <stdatomic.h>],
+                        [atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);])],
+       [AC_MSG_RESULT(no)
+        ISC_ATOMIC_LIBS=""],
+       [AC_MSG_RESULT(yes)
+        ISC_ATOMIC_LIBS="-latomic"]
+    )
+    LIBS="$LIBS $ISC_ATOMIC_LIBS"
+fi
+
 AC_SUBST(ISC_PLATFORM_HAVESTDATOMIC)
 
 ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"