@@ -285,37 +285,6 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
285
285
OPAL_VAR_SCOPE_POP
286
286
] )
287
287
288
- AC_DEFUN ( [ OPAL_CHECK_SYNC_BUILTINS] , [
289
- AC_MSG_CHECKING ( [ for __sync builtin atomics] )
290
-
291
- AC_TRY_LINK ( [ long tmp;] , [ __sync_synchronize();
292
- __sync_bool_compare_and_swap(&tmp, 0, 1);
293
- __sync_add_and_fetch(&tmp, 1);] ,
294
- [ AC_MSG_RESULT ( [ yes] )
295
- $1 ] ,
296
- [ AC_MSG_RESULT ( [ no] )
297
- $2 ] )
298
-
299
- AC_MSG_CHECKING ( [ for 64-bit __sync builtin atomics] )
300
-
301
- AC_TRY_LINK ( [
302
- #include <stdint.h>
303
- uint64_t tmp;] , [
304
- __sync_bool_compare_and_swap(&tmp, 0, 1);
305
- __sync_add_and_fetch(&tmp, 1);] ,
306
- [ AC_MSG_RESULT ( [ yes] )
307
- opal_asm_sync_have_64bit=1] ,
308
- [ AC_MSG_RESULT ( [ no] )
309
- opal_asm_sync_have_64bit=0] )
310
-
311
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SYNC_HAVE_64BIT] ,[ $opal_asm_sync_have_64bit] ,
312
- [ Whether 64-bit is supported by the __sync builtin atomics] )
313
-
314
- # Check for 128-bit support
315
- OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
316
- ] )
317
-
318
-
319
288
AC_DEFUN ( [ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128] , [
320
289
OPAL_VAR_SCOPE_PUSH([ atomic_compare_exchange_n_128_result atomic_compare_exchange_n_128_CFLAGS_save atomic_compare_exchange_n_128_LIBS_save] )
321
290
@@ -361,9 +330,10 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
361
330
] )
362
331
363
332
AC_DEFUN ( [ OPAL_CHECK_GCC_ATOMIC_BUILTINS] , [
364
- AC_MSG_CHECKING ( [ for __atomic builtin atomics] )
333
+ if test -z "$opal_cv_have___atomic" ; then
334
+ AC_MSG_CHECKING ( [ for 32-bit GCC built-in atomics] )
365
335
366
- AC_TRY_LINK ( [
336
+ AC_TRY_LINK ( [
367
337
#include <stdint.h>
368
338
uint32_t tmp, old = 0;
369
339
uint64_t tmp64, old64 = 0;] , [
@@ -372,13 +342,39 @@ __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED
372
342
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
373
343
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
374
344
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
375
- [ AC_MSG_RESULT ( [ yes] )
376
- $1 ] ,
377
- [ AC_MSG_RESULT ( [ no] )
378
- $2 ] )
345
+ [ opal_cv_have___atomic=yes] ,
346
+ [ opal_cv_have___atomic=no] )
347
+
348
+ AC_MSG_RESULT ( [ $opal_cv_have___atomic] )
349
+
350
+ if test $opal_cv_have___atomic = "yes" ; then
351
+ AC_MSG_CHECKING ( [ for 64-bit GCC built-in atomics] )
379
352
380
- # Check for 128-bit support
381
- OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
353
+ AC_TRY_LINK ( [
354
+ #include <stdint.h>
355
+ uint64_t tmp64, old64 = 0;] , [
356
+ __atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
357
+ __atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
358
+ [ opal_cv_have___atomic_64=yes] ,
359
+ [ opal_cv_have___atomic_64=no] )
360
+
361
+ AC_MSG_RESULT ( [ $opal_cv_have___atomic_64] )
362
+
363
+ if test $opal_cv_have___atomic_64 = "yes" ; then
364
+ AC_MSG_CHECKING ( [ if 64-bit GCC built-in atomics are lock-free] )
365
+ AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ if (!__atomic_is_lock_free (8, 0)) { return 1; }] ) ] ,
366
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
367
+ [ AC_MSG_RESULT ( [ no] )
368
+ opal_cv_have___atomic_64=no] ,
369
+ [ AC_MSG_RESULT ( [ cannot test -- assume yes (cross compiling)] ) ] )
370
+ fi
371
+ else
372
+ opal_cv_have___atomic_64=no
373
+ fi
374
+
375
+ # Check for 128-bit support
376
+ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
377
+ fi
382
378
] )
383
379
384
380
AC_DEFUN ( [ OPAL_CHECK_C11_CSWAP_INT128] , [
@@ -425,28 +421,6 @@ AC_DEFUN([OPAL_CHECK_C11_CSWAP_INT128], [
425
421
OPAL_VAR_SCOPE_POP
426
422
] )
427
423
428
- AC_DEFUN ( [ OPAL_CHECK_GCC_ATOMIC_BUILTINS] , [
429
- AC_MSG_CHECKING ( [ for __atomic builtin atomics] )
430
-
431
- AC_TRY_LINK ( [
432
- #include <stdint.h>
433
- uint32_t tmp, old = 0;
434
- uint64_t tmp64, old64 = 0;] , [
435
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
436
- __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
437
- __atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
438
- __atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
439
- __atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
440
- [ AC_MSG_RESULT ( [ yes] )
441
- $1 ] ,
442
- [ AC_MSG_RESULT ( [ no] )
443
- $2 ] )
444
-
445
- # Check for 128-bit support
446
- OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
447
- ] )
448
-
449
-
450
424
dnl #################################################################
451
425
dnl
452
426
dnl OPAL_CHECK_ASM_TEXT
@@ -1142,24 +1116,25 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1142
1116
1143
1117
AC_ARG_ENABLE ( [ builtin-atomics] ,
1144
1118
[ AC_HELP_STRING ([ --enable-builtin-atomics] ,
1145
- [ Enable use of __sync builtin atomics (default: disabled )] )] )
1119
+ [ Enable use of GCC built-in atomics (default: autodetect )] )] )
1146
1120
1147
1121
OPAL_CHECK_C11_CSWAP_INT128
1122
+ opal_cv_asm_builtin="BUILTIN_NO"
1123
+ OPAL_CHECK_GCC_ATOMIC_BUILTINS
1148
1124
1149
1125
if test "x$enable_c11_atomics" != "xno" && test "$opal_cv_c11_supported" = "yes" ; then
1150
1126
opal_cv_asm_builtin="BUILTIN_C11"
1151
1127
OPAL_CHECK_C11_CSWAP_INT128
1152
1128
elif test "x$enable_c11_atomics" = "xyes"; then
1153
1129
AC_MSG_WARN ( [ C11 atomics were requested but are not supported] )
1154
1130
AC_MSG_ERROR ( [ Cannot continue] )
1155
- else
1156
- opal_cv_asm_builtin="BUILTIN_NO"
1157
- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1158
- [ OPAL_CHECK_GCC_ATOMIC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_GCC"] , [ ] )] )
1159
- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1160
- [ OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] , [ ] )] )
1161
- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1162
- [ AC_MSG_ERROR ( [ __sync builtin atomics requested but not found.] ) ] )
1131
+ elif test "$enable_builtin_atomics" = "yes" ; then
1132
+ if test $opal_cv_have___atomic = "yes" ; then
1133
+ opal_cv_asm_builtin="BUILTIN_GCC"
1134
+ else
1135
+ AC_MSG_WARN ( [ GCC built-in atomics requested but not found.] )
1136
+ AC_MSG_ERROR ( [ Cannot continue] )
1137
+ fi
1163
1138
fi
1164
1139
1165
1140
OPAL_CHECK_ASM_PROC
@@ -1176,7 +1151,12 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1176
1151
# find our architecture for purposes of assembly stuff
1177
1152
opal_cv_asm_arch="UNSUPPORTED"
1178
1153
OPAL_GCC_INLINE_ASSIGN=""
1179
- OPAL_ASM_SUPPORT_64BIT=0
1154
+ if test "$opal_cv_have___atomic_64" ; then
1155
+ OPAL_ASM_SUPPORT_64BIT=1
1156
+ else
1157
+ OPAL_ASM_SUPPORT_64BIT=0
1158
+ fi
1159
+
1180
1160
case "${host}" in
1181
1161
x86_64-*x32)
1182
1162
opal_cv_asm_arch="X86_64"
@@ -1198,17 +1178,13 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1198
1178
opal_cv_asm_arch="ARM64"
1199
1179
OPAL_ASM_SUPPORT_64BIT=1
1200
1180
OPAL_ASM_ARM_VERSION=8
1201
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1202
- [ What ARM assembly version to use] )
1203
1181
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1204
1182
;;
1205
1183
1206
1184
armv7*|arm-*-linux-gnueabihf)
1207
1185
opal_cv_asm_arch="ARM"
1208
1186
OPAL_ASM_SUPPORT_64BIT=1
1209
1187
OPAL_ASM_ARM_VERSION=7
1210
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1211
- [ What ARM assembly version to use] )
1212
1188
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1213
1189
;;
1214
1190
@@ -1217,8 +1193,6 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1217
1193
OPAL_ASM_SUPPORT_64BIT=0
1218
1194
OPAL_ASM_ARM_VERSION=6
1219
1195
CCASFLAGS="$CCASFLAGS -march=armv7-a"
1220
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1221
- [ What ARM assembly version to use] )
1222
1196
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1223
1197
;;
1224
1198
@@ -1269,37 +1243,27 @@ AC_MSG_ERROR([Can not continue.])
1269
1243
;;
1270
1244
1271
1245
*)
1272
- OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] ,
1273
- [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
1274
- ;;
1246
+ if test $opal_cv_have___atomic = "yes" ; then
1247
+ opal_cv_asm_builtin="BUILTIN_GCC"
1248
+ else
1249
+ AC_MSG_ERROR ( [ No atomic primitives available for $host] )
1250
+ fi
1251
+ ;;
1275
1252
esac
1276
1253
1277
- if test "x$OPAL_ASM_SUPPORT_64BIT" = "x1" && test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" &&
1278
- test "$opal_asm_sync_have_64bit" = "0" ; then
1279
- # __sync builtins exist but do not implement 64-bit support. Fall back on inline asm.
1280
- opal_cv_asm_builtin="BUILTIN_NO"
1281
- fi
1254
+ if ! test -z "$OPAL_ASM_ARM_VERSION" ; then
1255
+ AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1256
+ [ What ARM assembly version to use] )
1257
+ fi
1282
1258
1283
- if test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" || test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
1284
- AC_DEFINE ( [ OPAL_C_GCC_INLINE_ASSEMBLY] , [ 1] ,
1285
- [ Whether C compiler supports GCC style inline assembly] )
1286
- else
1287
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SUPPORT_64BIT] ,
1288
- [ $OPAL_ASM_SUPPORT_64BIT] ,
1289
- [ Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files] )
1290
- AC_SUBST ( [ OPAL_ASM_SUPPORT_64BIT] )
1291
-
1292
- #
1293
- # figure out if we need any special function start / stop code
1294
- #
1295
- case $host_os in
1296
- aix*)
1297
- opal_asm_arch_config="aix"
1298
- ;;
1299
- *)
1300
- opal_asm_arch_config="default"
1301
- ;;
1302
- esac
1259
+ if test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
1260
+ AC_DEFINE ( [ OPAL_C_GCC_INLINE_ASSEMBLY] , [ 1] ,
1261
+ [ Whether C compiler supports GCC style inline assembly] )
1262
+ else
1263
+ AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SUPPORT_64BIT] ,
1264
+ [ $OPAL_ASM_SUPPORT_64BIT] ,
1265
+ [ Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files] )
1266
+ AC_SUBST ( [ OPAL_ASM_SUPPORT_64BIT] )
1303
1267
1304
1268
opal_cv_asm_inline_supported="no"
1305
1269
# now that we know our architecture, try to inline assemble
@@ -1330,7 +1294,7 @@ AC_MSG_ERROR([Can not continue.])
1330
1294
AC_DEFINE_UNQUOTED ( [ OPAL_ASSEMBLY_FORMAT] , [ "$OPAL_ASSEMBLY_FORMAT"] ,
1331
1295
[ Format of assembly file] )
1332
1296
AC_SUBST ( [ OPAL_ASSEMBLY_FORMAT] )
1333
- fi # if opal_cv_asm_builtin = BUILTIN_SYNC
1297
+ fi # if opal_cv_asm_builtin = BUILTIN_GCC
1334
1298
1335
1299
result="OPAL_$opal_cv_asm_arch"
1336
1300
OPAL_ASSEMBLY_ARCH="$opal_cv_asm_arch"
@@ -1388,7 +1352,7 @@ AC_DEFUN([OPAL_ASM_FIND_FILE], [
1388
1352
AC_REQUIRE ( [ AC_PROG_GREP ] )
1389
1353
AC_REQUIRE ( [ AC_PROG_FGREP ] )
1390
1354
1391
- if test "$opal_cv_asm_arch" != "WINDOWS" && test "$opal_cv_asm_builtin" != "BUILTIN_SYNC" && test "$opal_cv_asm_builtin" != " BUILTIN_GCC" && test "$opal_cv_asm_builtin" != "BUILTIN_OSX" && test "$opal_cv_asm_inline_arch" = "no" ; then
1355
+ if test "$opal_cv_asm_arch" != "WINDOWS" && test "$opal_cv_asm_builtin" != "BUILTIN_GCC" && test "$opal_cv_asm_builtin" != "BUILTIN_OSX" && test "$opal_cv_asm_inline_arch" = "no" ; then
1392
1356
AC_MSG_ERROR ( [ no atomic support available. exiting] )
1393
1357
else
1394
1358
# On windows with VC++, atomics are done with compiler primitives
0 commit comments