From 0efe6baf649e9d6ee5facb61c2b0570b30143685 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Thu, 4 Dec 2014 14:25:53 -0700 Subject: [PATCH] Add check for -mcx16 flag for 128-bit compare and swap Some versions of gcc require this flag to be set before the __sync builtin atomic compare and swap will support 128-bit values. If the flag is required this check adds the flag to the CFLAGS. --- config/opal_config_asm.m4 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/config/opal_config_asm.m4 b/config/opal_config_asm.m4 index f3be9801dd..41672d65d7 100644 --- a/config/opal_config_asm.m4 +++ b/config/opal_config_asm.m4 @@ -20,16 +20,30 @@ dnl AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [ + + OPAL_VAR_SCOPE_PUSH([sync_bool_compare_and_swap_128_result CFLAGS_save]) + AC_MSG_CHECKING([for __sync builtin atomic compare-and-swap on 128-bit values]) - - OPAL_VAR_SCOPE_PUSH([sync_bool_compare_and_swap_128_result]) - AC_TRY_COMPILE([], [__int128 x = 0; __sync_bool_compare_and_swap (&x, 0, 1);], [AC_MSG_RESULT([yes]) sync_bool_compare_and_swap_128_result=1], [AC_MSG_RESULT([no]) sync_bool_compare_and_swap_128_result=0]) + if test $sync_bool_compare_and_swap_128_result = 0 ; then + CFLAGS_save=$CFLAGS + CFLAGS="$CFLAGS -mcx16" + + AC_MSG_CHECKING([for __sync builtin atomic compare-and-swap on 128-bit values with -mcx16 flag]) + AC_TRY_COMPILE([], [__int128 x = 0; __sync_bool_compare_and_swap (&x, 0, 1);], + [AC_MSG_RESULT([yes]) + sync_bool_compare_and_swap_128_result=1 + CFLAGS_save="$CFLAGS"], + [AC_MSG_RESULT([no])]) + + CFLAGS=$CFLAGS_save + fi + AC_DEFINE_UNQUOTED([OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128], [$sync_bool_compare_and_swap_128_result], [Whether the __sync builtin atomic compare and swap supports 128-bit values])