AC_SUBST(glibcxx_PCHFLAGS)
])
-
dnl
dnl Check for atomic builtins.
dnl See:
dnl http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
dnl
-dnl This checks to see if the host supports the compiler-generated
-dnl builtins for atomic operations for various integral sizes. Note, this
-dnl is intended to be an all-or-nothing switch, so all the atomic operations
-dnl that are used should be checked.
+dnl This checks to see if the host supports __atomic_fetch_add on _Atomic_word.
+dnl
+dnl We don't want libstdc++.so to depend on libatomic.so for basic
+dnl functionality like library-internal reference counting. This means we
+dnl should not use atomics for reference counting unless it can be done
+dnl using native instructions and not by calling into libatomic.
+dnl This policy could change if linking to libatomic.so becomes implicit.
+dnl
+dnl Defines:
+dnl GLIBCXX_ATOMIC_WORD_BUILTINS - if atomic builtins should be used for
+dnl increments and decrements of _Atomic_word.
dnl
dnl Note:
dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
AC_LANG_CPLUSPLUS
old_CXXFLAGS="$CXXFLAGS"
- # Do link tests if possible, instead asm tests, limited to some platforms
+ # Do link tests if possible, otherwise asm tests. Limited to some platforms
# see discussion in PR target/40134, PR libstdc++/40133 and the thread
# starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
atomic_builtins_link_tests=no
esac
fi
- if test x$atomic_builtins_link_tests = xyes; then
-
- # Do link tests.
+ if test "$atomic_builtins_link_tests" = yes; then
- CXXFLAGS="$CXXFLAGS -fno-exceptions"
-
- AC_CACHE_CHECK([for atomic builtins for bool],
- glibcxx_cv_atomic_bool, [
- AC_TRY_LINK(
- [ ],
- [typedef bool atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- // N.B. __atomic_fetch_add is not supported for bool.
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
- ],
- [glibcxx_cv_atomic_bool=yes],
- [glibcxx_cv_atomic_bool=no])
- ])
-
- AC_CACHE_CHECK([for atomic builtins for short],
- glibcxx_cv_atomic_short, [
- AC_TRY_LINK(
- [ ],
- [typedef short atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
- ],
- [glibcxx_cv_atomic_short=yes],
- [glibcxx_cv_atomic_short=no])
- ])
+ # Do link tests.
- AC_CACHE_CHECK([for atomic builtins for int],
- glibcxx_cv_atomic_int, [
- AC_TRY_LINK(
- [ ],
- [typedef int atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
- ],
- [glibcxx_cv_atomic_int=yes],
- [glibcxx_cv_atomic_int=no])
- ])
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
- AC_CACHE_CHECK([for atomic builtins for long long],
- glibcxx_cv_atomic_long_long, [
- AC_TRY_LINK(
- [ ],
- [typedef long long atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
- ],
- [glibcxx_cv_atomic_long_long=yes],
- [glibcxx_cv_atomic_long_long=no])
- ])
+ AC_CACHE_CHECK([for atomic builtins for _Atomic_word],
+ glibcxx_cv_atomic_word,
+ [AC_TRY_LINK([#include "${glibcxx_srcdir}/config/$atomic_word_dir/atomic_word.h"],
+ [_Atomic_word a = 0, b;
+ b = __atomic_fetch_add(&a, 1, __ATOMIC_ACQ_REL);],
+ [glibcxx_cv_atomic_word=yes],
+ [glibcxx_cv_atomic_word=no])])
else
+ # Do asm tests.
- # Do asm tests.
-
- # Compile unoptimized.
- CXXFLAGS='-O0 -S'
-
- # Fake what AC_TRY_COMPILE does.
-
- cat > conftest.$ac_ext << EOF
-[#]line __oline__ "configure"
-int main()
-{
- typedef bool atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- // N.B. __atomic_fetch_add is not supported for bool.
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
-}
-EOF
-
- AC_MSG_CHECKING([for atomic builtins for bool])
- if AC_TRY_EVAL(ac_compile); then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_bool=no
- else
- glibcxx_cv_atomic_bool=yes
- fi
- fi
- AC_MSG_RESULT($glibcxx_cv_atomic_bool)
- rm -f conftest*
-
- cat > conftest.$ac_ext << EOF
-[#]line __oline__ "configure"
-int main()
-{
- typedef short atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
-}
-EOF
-
- AC_MSG_CHECKING([for atomic builtins for short])
- if AC_TRY_EVAL(ac_compile); then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_short=no
- else
- glibcxx_cv_atomic_short=yes
- fi
- fi
- AC_MSG_RESULT($glibcxx_cv_atomic_short)
- rm -f conftest*
-
- cat > conftest.$ac_ext << EOF
-[#]line __oline__ "configure"
-int main()
-{
- // NB: _Atomic_word not necessarily int.
- typedef int atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
+ # Compile unoptimized.
+ CXXFLAGS='-O0 -S'
- return 0;
-}
-EOF
-
- AC_MSG_CHECKING([for atomic builtins for int])
- if AC_TRY_EVAL(ac_compile); then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_int=no
- else
- glibcxx_cv_atomic_int=yes
- fi
- fi
- AC_MSG_RESULT($glibcxx_cv_atomic_int)
- rm -f conftest*
+ # Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure"
+[#]include "${glibcxx_srcdir}/config/$atomic_word_dir/atomic_word.h"
int main()
{
- typedef long long atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
+ _Atomic_word a = 0, b;
+ b = __atomic_fetch_add(&a, 1, __ATOMIC_ACQ_REL);
}
EOF
- AC_MSG_CHECKING([for atomic builtins for long long])
+ AC_MSG_CHECKING([for atomic builtins for _Atomic_word])
if AC_TRY_EVAL(ac_compile); then
if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_long_long=no
+ glibcxx_cv_atomic_word=no
else
- glibcxx_cv_atomic_long_long=yes
+ glibcxx_cv_atomic_word=yes
fi
fi
- AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
+ AC_MSG_RESULT($glibcxx_cv_atomic_word)
rm -f conftest*
-
fi
CXXFLAGS="$old_CXXFLAGS"
AC_LANG_RESTORE
- # Set atomicity_dir to builtins if all but the long long test above passes,
+ # Set atomicity_dir to builtins if the test above passes,
# or if the builtins were already chosen (e.g. by configure.host).
- if { test "$glibcxx_cv_atomic_bool" = yes \
- && test "$glibcxx_cv_atomic_short" = yes \
- && test "$glibcxx_cv_atomic_int" = yes; } \
+ if test "$glibcxx_cv_atomic_word" = yes \
|| test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
- AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1,
- [Define if the compiler supports C++11 atomics.])
+ AC_DEFINE(_GLIBCXX_ATOMIC_WORD_BUILTINS, 1,
+ [Define if the compiler supports native atomics for _Atomic_word.])
atomicity_dir=cpu/generic/atomicity_builtins
fi
BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
- # libbacktrace only needs atomics for int, which we've already tested
- if test "$glibcxx_cv_atomic_int" = "yes"; then
+ GLIBCXX_LANG_PUSH
+
+ # libbacktrace's own configure.ac only tests atomics for int,
+ # but the code actually uses atomics for size_t and pointers as well.
+ if test "$atomic_builtins_link_tests" = yes; then
+
+ CXXFLAGS='-O0'
+
+ AC_CACHE_CHECK([for atomic builtins for libbacktrace],
+ glibcxx_cv_libbacktrace_atomics,
+ [AC_TRY_LINK([], [
+ int i = 0;
+ int* p = &i;
+ size_t s = 0;
+ // backtrace_atomic_load_pointer
+ void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_load_int
+ int i2 = __atomic_load_n(&i, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_store_pointer
+ __atomic_store_n(&p, &i, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_size_t
+ __atomic_store_n(&s, s, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_int
+ __atomic_store_n(&i, i, __ATOMIC_RELEASE);
+ ],
+ [glibcxx_cv_libbacktrace_atomics=yes],
+ [glibcxx_cv_libbacktrace_atomics=no])])
+
+ else
+ # Do asm tests.
+
+ CXXFLAGS='-O0 -S'
+
+ cat > conftest.$ac_ext << EOF
+[#]line __oline__ "configure"
+[#]include <stddef.h>
+int main()
+{
+ int i = 0;
+ int* p = &i;
+ size_t s = 0;
+ // backtrace_atomic_load_pointer
+ void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_load_int
+ int i2 = __atomic_load_n(&i, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_store_pointer
+ __atomic_store_n(&p, &i, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_size_t
+ __atomic_store_n(&s, s, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_int
+ __atomic_store_n(&i, i, __ATOMIC_RELEASE);
+}
+EOF
+
+ AC_MSG_CHECKING([for atomic builtins for libbacktrace])
+ if AC_TRY_EVAL(ac_compile); then
+ if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
+ glibcxx_cv_libbacktrace_atomics=no
+ else
+ glibcxx_cv_libbacktrace_atomics=yes
+ fi
+ fi
+ AC_MSG_RESULT($glibcxx_cv_libbacktrace_atomics)
+ rm -f conftest*
+ fi
+
+ GLIBCXX_LANG_POP
+
+ if test "$glibcxx_cv_libbacktrace_atomics" = yes; then
BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_ATOMIC_FUNCTIONS=1"
fi
old_CXXFLAGS="$CXXFLAGS"
- # Do link tests if possible, instead asm tests, limited to some platforms
+ # Do link tests if possible, otherwise asm tests. Limited to some platforms
# see discussion in PR target/40134, PR libstdc++/40133 and the thread
# starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
atomic_builtins_link_tests=no
esac
fi
- if test x$atomic_builtins_link_tests = xyes; then
+ if test "$atomic_builtins_link_tests" = yes; then
- # Do link tests.
+ # Do link tests.
- CXXFLAGS="$CXXFLAGS -fno-exceptions"
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for bool" >&5
-$as_echo_n "checking for atomic builtins for bool... " >&6; }
-if ${glibcxx_cv_atomic_bool+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-typedef bool atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- // N.B. __atomic_fetch_add is not supported for bool.
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- glibcxx_cv_atomic_bool=yes
-else
- glibcxx_cv_atomic_bool=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_bool" >&5
-$as_echo "$glibcxx_cv_atomic_bool" >&6; }
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for short" >&5
-$as_echo_n "checking for atomic builtins for short... " >&6; }
-if ${glibcxx_cv_atomic_short+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-typedef short atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- glibcxx_cv_atomic_short=yes
-else
- glibcxx_cv_atomic_short=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_short" >&5
-$as_echo "$glibcxx_cv_atomic_short" >&6; }
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for int" >&5
-$as_echo_n "checking for atomic builtins for int... " >&6; }
-if ${glibcxx_cv_atomic_int+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-typedef int atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- glibcxx_cv_atomic_int=yes
-else
- glibcxx_cv_atomic_int=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_int" >&5
-$as_echo "$glibcxx_cv_atomic_int" >&6; }
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for long long" >&5
-$as_echo_n "checking for atomic builtins for long long... " >&6; }
-if ${glibcxx_cv_atomic_long_long+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for _Atomic_word" >&5
+$as_echo_n "checking for atomic builtins for _Atomic_word... " >&6; }
+if ${glibcxx_cv_atomic_word+:} false; then :
$as_echo_n "(cached) " >&6
else
-
- if test x$gcc_no_link = xyes; then
+ if test x$gcc_no_link = xyes; then
as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
+#include "${glibcxx_srcdir}/config/$atomic_word_dir/atomic_word.h"
int
main ()
{
-typedef long long atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
+_Atomic_word a = 0, b;
+ b = __atomic_fetch_add(&a, 1, __ATOMIC_ACQ_REL);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
- glibcxx_cv_atomic_long_long=yes
+ glibcxx_cv_atomic_word=yes
else
- glibcxx_cv_atomic_long_long=no
+ glibcxx_cv_atomic_word=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_long_long" >&5
-$as_echo "$glibcxx_cv_atomic_long_long" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_word" >&5
+$as_echo "$glibcxx_cv_atomic_word" >&6; }
else
+ # Do asm tests.
- # Do asm tests.
-
- # Compile unoptimized.
- CXXFLAGS='-O0 -S'
-
- # Fake what AC_TRY_COMPILE does.
-
- cat > conftest.$ac_ext << EOF
-#line 16185 "configure"
-int main()
-{
- typedef bool atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- // N.B. __atomic_fetch_add is not supported for bool.
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
-}
-EOF
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for bool" >&5
-$as_echo_n "checking for atomic builtins for bool... " >&6; }
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_bool=no
- else
- glibcxx_cv_atomic_bool=yes
- fi
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_bool" >&5
-$as_echo "$glibcxx_cv_atomic_bool" >&6; }
- rm -f conftest*
-
- cat > conftest.$ac_ext << EOF
-#line 16220 "configure"
-int main()
-{
- typedef short atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
-}
-EOF
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for short" >&5
-$as_echo_n "checking for atomic builtins for short... " >&6; }
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_short=no
- else
- glibcxx_cv_atomic_short=yes
- fi
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_short" >&5
-$as_echo "$glibcxx_cv_atomic_short" >&6; }
- rm -f conftest*
-
- cat > conftest.$ac_ext << EOF
-#line 16255 "configure"
-int main()
-{
- // NB: _Atomic_word not necessarily int.
- typedef int atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
-}
-EOF
+ # Compile unoptimized.
+ CXXFLAGS='-O0 -S'
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for int" >&5
-$as_echo_n "checking for atomic builtins for int... " >&6; }
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_int=no
- else
- glibcxx_cv_atomic_int=yes
- fi
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_int" >&5
-$as_echo "$glibcxx_cv_atomic_int" >&6; }
- rm -f conftest*
+ # Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 16291 "configure"
+#line 16051 "configure"
+#include "${glibcxx_srcdir}/config/$atomic_word_dir/atomic_word.h"
int main()
{
- typedef long long atomic_type;
- atomic_type c1;
- atomic_type c2;
- atomic_type c3(0);
- __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
- __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED);
- __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
- __atomic_load_n(&c1, __ATOMIC_RELAXED);
-
- return 0;
+ _Atomic_word a = 0, b;
+ b = __atomic_fetch_add(&a, 1, __ATOMIC_ACQ_REL);
}
EOF
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for long long" >&5
-$as_echo_n "checking for atomic builtins for long long... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for _Atomic_word" >&5
+$as_echo_n "checking for atomic builtins for _Atomic_word... " >&6; }
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
- glibcxx_cv_atomic_long_long=no
+ glibcxx_cv_atomic_word=no
else
- glibcxx_cv_atomic_long_long=yes
+ glibcxx_cv_atomic_word=yes
fi
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_long_long" >&5
-$as_echo "$glibcxx_cv_atomic_long_long" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_word" >&5
+$as_echo "$glibcxx_cv_atomic_word" >&6; }
rm -f conftest*
-
fi
CXXFLAGS="$old_CXXFLAGS"
ac_compiler_gnu=$ac_cv_c_compiler_gnu
- # Set atomicity_dir to builtins if all but the long long test above passes,
+ # Set atomicity_dir to builtins if the test above passes,
# or if the builtins were already chosen (e.g. by configure.host).
- if { test "$glibcxx_cv_atomic_bool" = yes \
- && test "$glibcxx_cv_atomic_short" = yes \
- && test "$glibcxx_cv_atomic_int" = yes; } \
+ if test "$glibcxx_cv_atomic_word" = yes \
|| test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
-$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS 1" >>confdefs.h
+$as_echo "#define _GLIBCXX_ATOMIC_WORD_BUILTINS 1" >>confdefs.h
atomicity_dir=cpu/generic/atomicity_builtins
fi
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16448 "configure"
+#line 16197 "configure"
int main()
{
_Decimal32 d1;
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16490 "configure"
+#line 16239 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
- # libbacktrace only needs atomics for int, which we've already tested
- if test "$glibcxx_cv_atomic_int" = "yes"; then
+ GLIBCXX_LANG_PUSH
+
+ # libbacktrace's own configure.ac only tests atomics for int,
+ # but the code actually uses atomics for size_t and pointers as well.
+ if test "$atomic_builtins_link_tests" = yes; then
+
+ CXXFLAGS='-O0'
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for libbacktrace" >&5
+$as_echo_n "checking for atomic builtins for libbacktrace... " >&6; }
+if ${glibcxx_cv_libbacktrace_atomics+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ int i = 0;
+ int* p = &i;
+ size_t s = 0;
+ // backtrace_atomic_load_pointer
+ void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_load_int
+ int i2 = __atomic_load_n(&i, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_store_pointer
+ __atomic_store_n(&p, &i, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_size_t
+ __atomic_store_n(&s, s, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_int
+ __atomic_store_n(&i, i, __ATOMIC_RELEASE);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ glibcxx_cv_libbacktrace_atomics=yes
+else
+ glibcxx_cv_libbacktrace_atomics=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_libbacktrace_atomics" >&5
+$as_echo "$glibcxx_cv_libbacktrace_atomics" >&6; }
+
+ else
+ # Do asm tests.
+
+ CXXFLAGS='-O0 -S'
+
+ cat > conftest.$ac_ext << EOF
+#line 53598 "configure"
+#include <stddef.h>
+int main()
+{
+ int i = 0;
+ int* p = &i;
+ size_t s = 0;
+ // backtrace_atomic_load_pointer
+ void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_load_int
+ int i2 = __atomic_load_n(&i, __ATOMIC_ACQUIRE);
+ // backtrace_atomic_store_pointer
+ __atomic_store_n(&p, &i, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_size_t
+ __atomic_store_n(&s, s, __ATOMIC_RELEASE);
+ // backtrace_atomic_store_int
+ __atomic_store_n(&i, i, __ATOMIC_RELEASE);
+}
+EOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic builtins for libbacktrace" >&5
+$as_echo_n "checking for atomic builtins for libbacktrace... " >&6; }
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
+ glibcxx_cv_libbacktrace_atomics=no
+ else
+ glibcxx_cv_libbacktrace_atomics=yes
+ fi
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_libbacktrace_atomics" >&5
+$as_echo "$glibcxx_cv_libbacktrace_atomics" >&6; }
+ rm -f conftest*
+ fi
+
+ GLIBCXX_LANG_POP
+
+ if test "$glibcxx_cv_libbacktrace_atomics" = yes; then
BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_ATOMIC_FUNCTIONS=1"
fi