@@ -4597,16 +4597,62 @@ then
4597
4597
fi
4598
4598
AC_MSG_RESULT ( $with_doc_strings )
4599
4599
4600
+ # Check for stdatomic.h, required for mimalloc.
4601
+ AC_CACHE_CHECK ( [ for stdatomic.h] , [ ac_cv_header_stdatomic_h] , [
4602
+ AC_LINK_IFELSE (
4603
+ [
4604
+ AC_LANG_SOURCE ( [ [
4605
+ #include <stdatomic.h>
4606
+ atomic_int int_var;
4607
+ atomic_uintptr_t uintptr_var;
4608
+ int main() {
4609
+ atomic_store_explicit(&int_var, 5, memory_order_relaxed);
4610
+ atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
4611
+ int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
4612
+ return 0;
4613
+ }
4614
+ ] ] )
4615
+ ] ,[ ac_cv_header_stdatomic_h=yes] ,[ ac_cv_header_stdatomic_h=no] )
4616
+ ] )
4617
+
4618
+ AS_VAR_IF ( [ ac_cv_header_stdatomic_h] , [ yes] , [
4619
+ AC_DEFINE ( HAVE_STD_ATOMIC , 1 ,
4620
+ [ Has stdatomic.h with atomic_int and atomic_uintptr_t] )
4621
+ ] )
4622
+
4623
+ # Check for GCC >= 4.7 and clang __atomic builtin functions
4624
+ AC_CACHE_CHECK ( [ for builtin __atomic_load_n and __atomic_store_n functions] , [ ac_cv_builtin_atomic] , [
4625
+ AC_LINK_IFELSE (
4626
+ [
4627
+ AC_LANG_SOURCE ( [ [
4628
+ int val;
4629
+ int main() {
4630
+ __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
4631
+ (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
4632
+ return 0;
4633
+ }
4634
+ ] ] )
4635
+ ] ,[ ac_cv_builtin_atomic=yes] ,[ ac_cv_builtin_atomic=no] )
4636
+ ] )
4637
+
4638
+ AS_VAR_IF ( [ ac_cv_builtin_atomic] , [ yes] , [
4639
+ AC_DEFINE ( HAVE_BUILTIN_ATOMIC , 1 , [ Has builtin __atomic_load_n() and __atomic_store_n() functions] )
4640
+ ] )
4641
+
4600
4642
# --with-mimalloc
4601
4643
AC_MSG_CHECKING ( [ for --with-mimalloc] )
4602
4644
AC_ARG_WITH ( [ mimalloc] ,
4603
4645
[ AS_HELP_STRING ( [ --with-mimalloc] ,
4604
- [ build with mimalloc memory allocator (default is yes)] ) ] ,
4646
+ [ build with mimalloc memory allocator (default is yes if C11 stdatomic.h is available. )] ) ] ,
4605
4647
[ ] ,
4606
- [ with_mimalloc="yes "]
4648
+ [ with_mimalloc="$ac_cv_header_stdatomic_h "]
4607
4649
)
4608
4650
4609
4651
if test "$with_mimalloc" != no; then
4652
+ if test "$ac_cv_header_stdatomic_h" != yes; then
4653
+ # mimalloc-atomic.h wants C11 stdatomic.h on POSIX
4654
+ AC_MSG_ERROR ( [ mimalloc requires stdatomic.h, use --without-mimalloc to disable mimalloc.] )
4655
+ fi
4610
4656
with_mimalloc=yes
4611
4657
AC_DEFINE ( [ WITH_MIMALLOC] , [ 1] , [ Define if you want to compile in mimalloc memory allocator.] )
4612
4658
AC_SUBST ( [ MIMALLOC_HEADERS] , [ '$(MIMALLOC_HEADERS)'] )
@@ -6749,53 +6795,6 @@ if test "$ac_cv_gcc_asm_for_x87" = yes; then
6749
6795
esac
6750
6796
fi
6751
6797
6752
- # Check for stdatomic.h
6753
- AC_CACHE_CHECK ( [ for stdatomic.h] , [ ac_cv_header_stdatomic_h] , [
6754
- AC_LINK_IFELSE (
6755
- [
6756
- AC_LANG_SOURCE ( [ [
6757
- #include <stdatomic.h>
6758
- atomic_int int_var;
6759
- atomic_uintptr_t uintptr_var;
6760
- int main() {
6761
- atomic_store_explicit(&int_var, 5, memory_order_relaxed);
6762
- atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
6763
- int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
6764
- return 0;
6765
- }
6766
- ] ] )
6767
- ] ,[ ac_cv_header_stdatomic_h=yes] ,[ ac_cv_header_stdatomic_h=no] )
6768
- ] )
6769
-
6770
- AS_VAR_IF ( [ ac_cv_header_stdatomic_h] , [ yes] , [
6771
- AC_DEFINE ( HAVE_STD_ATOMIC , 1 ,
6772
- [ Has stdatomic.h with atomic_int and atomic_uintptr_t] )
6773
- ] )
6774
-
6775
- if test "$ac_cv_header_stdatomic_h" != yes -a "$with_mimalloc" != no; then
6776
- # mimalloc-atomic.h wants C11 stdatomic.h on POSIX
6777
- AC_MSG_ERROR ( [ mimalloc requires stdatomic.h, use --without-mimalloc to disable mimalloc. A future version of Python will require stdatomic.h.] )
6778
- fi
6779
-
6780
- # Check for GCC >= 4.7 and clang __atomic builtin functions
6781
- AC_CACHE_CHECK ( [ for builtin __atomic_load_n and __atomic_store_n functions] , [ ac_cv_builtin_atomic] , [
6782
- AC_LINK_IFELSE (
6783
- [
6784
- AC_LANG_SOURCE ( [ [
6785
- int val;
6786
- int main() {
6787
- __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
6788
- (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
6789
- return 0;
6790
- }
6791
- ] ] )
6792
- ] ,[ ac_cv_builtin_atomic=yes] ,[ ac_cv_builtin_atomic=no] )
6793
- ] )
6794
-
6795
- AS_VAR_IF ( [ ac_cv_builtin_atomic] , [ yes] , [
6796
- AC_DEFINE ( HAVE_BUILTIN_ATOMIC , 1 , [ Has builtin __atomic_load_n() and __atomic_store_n() functions] )
6797
- ] )
6798
-
6799
6798
# ensurepip option
6800
6799
AC_MSG_CHECKING ( for ensurepip )
6801
6800
AC_ARG_WITH ( ensurepip ,
@@ -7455,3 +7454,10 @@ AS_VAR_IF([PY_SUPPORT_TIER], [0], [AC_MSG_WARN([
7455
7454
Platform "$host" with compiler "$ac_cv_cc_name" is not supported by the
7456
7455
CPython core team, see https://peps.python.org/pep-0011/ for more information.
7457
7456
] ) ] )
7457
+
7458
+ if test "$ac_cv_header_stdatomic_h" != "yes"; then
7459
+ AC_MSG_NOTICE ( m4_normalize ( [
7460
+ Your compiler or platform does have a working C11 stdatomic.h. A future
7461
+ version of Python may require stdatomic.h.
7462
+ ] ) )
7463
+ fi
0 commit comments