Skip to content

Commit e77874b

Browse files
committed
configury: fix gcc builtin atomic detection
test for both 32 and 64 bits. clang only support 32 bits builtin atomics when -m32 is used Thanks Paul Hargrove for reporting this. Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent f2c6e70 commit e77874b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

config/opal_config_asm.m4

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,23 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
193193
AC_DEFUN([OPAL_CHECK_GCC_ATOMIC_BUILTINS], [
194194
AC_MSG_CHECKING([for __atomic builtin atomics])
195195
196-
AC_TRY_LINK([long tmp, old = 0;], [__atomic_thread_fence(__ATOMIC_SEQ_CST);
196+
AC_TRY_LINK([
197+
#include <stdint.h>
198+
uint32_t tmp, old = 0;
199+
uint64_t tmp64, old64 = 0;], [
200+
__atomic_thread_fence(__ATOMIC_SEQ_CST);
197201
__atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
198-
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);],
202+
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
203+
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
204+
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);],
199205
[AC_MSG_RESULT([yes])
200206
$1],
201207
[AC_MSG_RESULT([no])
202208
$2])
203209
210+
AC_DEFINE_UNQUOTED([OPAL_ASM_SYNC_HAVE_64BIT],[$opal_asm_sync_have_64bit],
211+
[Whether 64-bit is supported by the __sync builtin atomics])
212+
204213
# Check for 128-bit support
205214
OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
206215
])

0 commit comments

Comments
 (0)