@@ -148,11 +148,21 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
148148
149149 CFLAGS=$CFLAGS_save
150150 fi
151+
152+ if test $atomic_compare_exchange_n_128_result = 1 ; then
153+ AC_MSG_CHECKING ( [ if __int128 atomic compare-and-swap is always lock-free] )
154+ AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ if (!__atomic_always_lock_free(16, 0)) { return 1; }] ) ] ,
155+ [ AC_MSG_RESULT ( [ yes] ) ] ,
156+ [ AC_MSG_RESULT ( [ no] )
157+ OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
158+ atomic_compare_exchange_n_128_result=0] ,
159+ [ AC_MSG_RESULT ( [ no (cross compiling)] ) ] )
160+ fi
151161 else
152162 AC_MSG_CHECKING ( [ for compiler support of __atomic builtin atomic compare-and-swap on 128-bit values] )
153163
154164 # Check if the compiler supports the __atomic builtin
155- AC_TRY_LINK ( [ ] , [ __int128 x = 0; __atomic_bool_compare_and_swap (&x, 0 , 1);] ,
165+ AC_TRY_LINK ( [ ] , [ __int128 x = 0, y = 0; __atomic_compare_exchange_n (&x, &y , 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED );] ,
156166 [ AC_MSG_RESULT ( [ yes] )
157167 atomic_compare_exchange_n_128_result=1] ,
158168 [ AC_MSG_RESULT ( [ no] ) ] )
@@ -162,7 +172,7 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
162172 CFLAGS="$CFLAGS -mcx16"
163173
164174 AC_MSG_CHECKING ( [ for __atomic builtin atomic compare-and-swap on 128-bit values with -mcx16 flag] )
165- AC_TRY_LINK ( [ ] , [ __int128 x = 0; __atomic_bool_compare_and_swap (&x, 0 , 1);] ,
175+ AC_TRY_LINK ( [ ] , [ __int128 x = 0, y = 0; __atomic_compare_exchange_n (&x, &y , 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED );] ,
166176 [ AC_MSG_RESULT ( [ yes] )
167177 atomic_compare_exchange_n_128_result=1
168178 CFLAGS_save="$CFLAGS"] ,
@@ -173,7 +183,7 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
173183 fi
174184
175185 AC_DEFINE_UNQUOTED ( [ OPAL_HAVE_GCC_BUILTIN_CSWAP_INT128] , [ $atomic_compare_exchange_n_128_result] ,
176- [ Whether the __atomic builtin atomic compare and swap supports 128-bit values] )
186+ [ Whether the __atomic builtin atomic compare and swap is lock-free on 128-bit values] )
177187
178188 OPAL_VAR_SCOPE_POP
179189] )
0 commit comments