Commit e3d9aaff authored by Evan Hunt's avatar Evan Hunt

[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]
parent 23b81977
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
......
......@@ -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"
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment