1# 2# Contains macros to detect CPU features. 3# 4 5 6# DRUNTIME_CPU_SOURCES 7# ------------------- 8# Detect target CPU and add DRUNTIME_CPU_XXX conditionals. 9AC_DEFUN([DRUNTIME_CPU_SOURCES], 10[ 11 druntime_target_cpu_parsed="" 12 case "$target_cpu" in 13 aarch64*) 14 druntime_target_cpu_parsed="aarch64" 15 ;; 16 arm*) druntime_target_cpu_parsed="arm" 17 ;; 18 mips*) druntime_target_cpu_parsed="mips" 19 ;; 20 powerpc) druntime_target_cpu_parsed="powerpc" 21 ;; 22 powerpc64) 23 druntime_target_cpu_parsed="powerpc64" 24 ;; 25 i[[34567]]86|x86_64) 26 druntime_target_cpu_parsed="x86" 27 ;; 28 esac 29 AM_CONDITIONAL([DRUNTIME_CPU_AARCH64], 30 [test "$druntime_target_cpu_parsed" = "aarch64"]) 31 AM_CONDITIONAL([DRUNTIME_CPU_ARM], 32 [test "$druntime_target_cpu_parsed" = "arm"]) 33 AM_CONDITIONAL([DRUNTIME_CPU_MIPS], 34 [test "$druntime_target_cpu_parsed" = "mips"]) 35 AM_CONDITIONAL([DRUNTIME_CPU_POWERPC], 36 [test "$druntime_target_cpu_parsed" = "powerpc"]) 37 AM_CONDITIONAL([DRUNTIME_CPU_POWERPC64], 38 [test "$druntime_target_cpu_parsed" = "powerpc64"]) 39 AM_CONDITIONAL([DRUNTIME_CPU_X86], 40 [test "$druntime_target_cpu_parsed" = "x86"]) 41]) 42 43 44# DRUNTIME_ENABLE_ATOMIC_BUILTINS 45# ------------------------- 46# Check support for atomic builtins up to 64 bit. 47AC_DEFUN([DRUNTIME_ENABLE_ATOMIC_BUILTINS], 48[ 49 # This checks to see if the host supports the compiler-generated builtins 50 # for atomic operations for various integral sizes. Note, this is intended 51 # to be an all-or-nothing switch, so all the atomic operations that are 52 # used should be checked. 53 AC_MSG_CHECKING([for atomic builtins for byte]) 54 AC_CACHE_VAL(druntime_cv_atomic_byte, [ 55 AC_TRY_LINK( 56 [import gcc.builtins;], [ 57 shared(byte) c1; 58 byte c2, c3; 59 __atomic_compare_exchange_1(&c1, &c2, c3, false, 5, 5); 60 __atomic_load_1(&c1, 5); 61 __atomic_store_1(&c1, c2, 5); 62 return 0; 63 ], 64 [druntime_cv_atomic_byte=yes], 65 [druntime_cv_atomic_byte=no]) 66 ]) 67 AC_MSG_RESULT($druntime_cv_atomic_byte) 68 69 AC_MSG_CHECKING([for atomic builtins for short]) 70 AC_CACHE_VAL(druntime_cv_atomic_short, [ 71 AC_TRY_LINK( 72 [import gcc.builtins;], [ 73 shared(short) c1; 74 short c2, c3; 75 __atomic_compare_exchange_2(&c1, &c2, c3, false, 5, 5); 76 __atomic_load_2(&c1, 5); 77 __atomic_store_2(&c1, c2, 5); 78 return 0; 79 ], 80 [druntime_cv_atomic_short=yes], 81 [druntime_cv_atomic_short=no]) 82 ]) 83 AC_MSG_RESULT($druntime_cv_atomic_short) 84 85 AC_MSG_CHECKING([for atomic builtins for int]) 86 AC_CACHE_VAL(druntime_cv_atomic_int, [ 87 AC_TRY_LINK( 88 [import gcc.builtins;], [ 89 shared(int) c1; 90 int c2, c3; 91 __atomic_compare_exchange_4(&c1, &c2, c3, false, 5, 5); 92 __atomic_load_4(&c1, 5); 93 __atomic_store_4(&c1, c2, 5); 94 return 0; 95 ], 96 [druntime_cv_atomic_int=yes], 97 [druntime_cv_atomic_int=no]) 98 ]) 99 AC_MSG_RESULT($druntime_cv_atomic_int) 100 101 AC_MSG_CHECKING([for atomic builtins for long]) 102 AC_CACHE_VAL(druntime_cv_atomic_long, [ 103 AC_TRY_LINK( 104 [import gcc.builtins;], [ 105 shared(long) c1; 106 long c2, c3; 107 __atomic_compare_exchange_8(&c1, &c2, c3, false, 5, 5); 108 __atomic_load_8(&c1, 5); 109 __atomic_store_8(&c1, c2, 5); 110 return 0; 111 ], 112 [druntime_cv_atomic_long=yes], 113 [druntime_cv_atomic_long=no]) 114 ]) 115 AC_MSG_RESULT($druntime_cv_atomic_long) 116 117 # Have atomic builtin support if all but the long test above passes. 118 DCFG_HAVE_ATOMIC_BUILTINS=false 119 if test "$druntime_cv_atomic_byte" = yes \ 120 && test "$druntime_cv_atomic_short" = yes \ 121 && test "$druntime_cv_atomic_int" = yes; then \ 122 DCFG_HAVE_ATOMIC_BUILTINS=true 123 fi 124 125 # Have 64-bit atomic support if the long test above passes. 126 DCFG_HAVE_64BIT_ATOMICS=false 127 if test "$druntime_cv_atomic_long" = yes; then 128 DCFG_HAVE_64BIT_ATOMICS=true 129 fi 130 131 AC_SUBST(DCFG_HAVE_ATOMIC_BUILTINS) 132 AC_SUBST(DCFG_HAVE_64BIT_ATOMICS) 133]) 134