From: Evan Hunt Date: Tue, 7 Nov 2017 21:27:14 +0000 (-0800) Subject: [master] Check if -latomic is needed to handle 64-bit stdatomic.h types X-Git-Tag: v9.12.0b2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3d9aafff0f2749469d5edf6dacd4ecf2f7224c0;p=thirdparty%2Fbind9.git [master] Check if -latomic is needed to handle 64-bit stdatomic.h types 4809. [port] Check at configure time whether -latomic is needed for stdatomic.h. [RT #46324] --- diff --git a/CHANGES b/CHANGES index 23f3d073705..d49df623dce 100644 --- 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 diff --git a/configure b/configure index bb5ebdb120a..136d531ff6d 100755 --- 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 +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" diff --git a/configure.in b/configure.in index 31089024192..81788165b9a 100644 --- a/configure.in +++ b/configure.in @@ -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 ], + [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"