diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-09 01:13:19 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-09 01:13:19 (GMT) |
commit | 4f5366e65a4d773fb5dda3329bd7b7c5425718fb (patch) | |
tree | c70447430a17fd84b9b2270a4707e36334a69d3e /configure.ac | |
parent | b551fac136940975e646ba8ed97dad455890bc3b (diff) | |
download | cpython-4f5366e65a4d773fb5dda3329bd7b7c5425718fb.zip cpython-4f5366e65a4d773fb5dda3329bd7b7c5425718fb.tar.gz cpython-4f5366e65a4d773fb5dda3329bd7b7c5425718fb.tar.bz2 |
Issue #22038: pyatomic.h now uses stdatomic.h or GCC built-in functions for
atomic memory access if available. Patch written by Vitor de Lima and Gustavo
Temple.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index c7504a2..da096a7 100644 --- a/configure.ac +++ b/configure.ac @@ -4884,6 +4884,45 @@ if test "$have_gcc_asm_for_x87" = yes; then esac fi +# Check for stdatomic.h +AC_MSG_CHECKING(for stdatomic.h) +AC_LINK_IFELSE( +[ + AC_LANG_SOURCE([[ + #include <stdatomic.h> + _Atomic int value = ATOMIC_VAR_INIT(1); + int main() { + int loaded_value = atomic_load(&value); + return 0; + } + ]]) +],[have_stdatomic_h=yes],[have_stdatomic_h=no]) + +AC_MSG_RESULT($have_stdatomic_h) + +if test "$have_stdatomic_h" = yes; then + AC_DEFINE(HAVE_STD_ATOMIC, 1, [Has stdatomic.h]) +fi + +# Check for GCC >= 4.7 __atomic builtins +AC_MSG_CHECKING(for GCC >= 4.7 __atomic builtins) +AC_LINK_IFELSE( +[ + AC_LANG_SOURCE([[ + volatile int val = 1; + int main() { + __atomic_load_n(&val, __ATOMIC_SEQ_CST); + return 0; + } + ]]) +],[have_builtin_atomic=yes],[have_builtin_atomic=no]) + +AC_MSG_RESULT($have_builtin_atomic) + +if test "$have_builtin_atomic" = yes; then + AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin atomics]) +fi + # ensurepip option AC_MSG_CHECKING(for ensurepip) AC_ARG_WITH(ensurepip, |