2
2
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3
3
dnl University Research and Technology
4
4
dnl Corporation. All rights reserved.
5
- dnl Copyright (c) 2004-2015 The University of Tennessee and The University
5
+ dnl Copyright (c) 2004-2018 The University of Tennessee and The University
6
6
dnl of Tennessee Research Foundation. All rights
7
7
dnl reserved.
8
8
dnl Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
27
27
28
28
AC_DEFUN ( [ OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128] , [
29
29
30
- OPAL_VAR_SCOPE_PUSH([ sync_bool_compare_and_swap_128_result CFLAGS_save] )
30
+ OPAL_VAR_SCOPE_PUSH([ sync_bool_compare_and_swap_128_result CFLAGS_save LDFLAGS_save ] )
31
31
32
32
AC_ARG_ENABLE ( [ cross-cmpset128] ,[ AC_HELP_STRING ([ --enable-cross-cmpset128] ,
33
33
[ enable the use of the __sync builtin atomic compare-and-swap 128 when cross compiling] )] )
@@ -57,6 +57,22 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
57
57
58
58
CFLAGS=$CFLAGS_save
59
59
fi
60
+
61
+ if test $sync_bool_compare_and_swap_128_result = 0 ; then
62
+ LDFLAGS_save=$LDFLAGS
63
+ LDFLAGS="$LDFLAGS -latomic"
64
+
65
+ AC_MSG_CHECKING ( [ for __sync builtin atomic compare-and-swap on 128-bit values with -latomic] )
66
+ AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ __int128 x = 0; __sync_bool_compare_and_swap (&x, 0, 1);] ) ] ,
67
+ [ AC_MSG_RESULT ( [ yes] )
68
+ sync_bool_compare_and_swap_128_result=1
69
+ LDFLAGS_save="$LDFLAGS"] ,
70
+ [ AC_MSG_RESULT ( [ no] ) ] ,
71
+ [ AC_MSG_RESULT ( [ no (cross compiling)] ) ] )
72
+
73
+ LDFLAGS=$LDFLAGS_save
74
+ fi
75
+
60
76
else
61
77
AC_MSG_CHECKING ( [ for compiler support of __sync builtin atomic compare-and-swap on 128-bit values] )
62
78
@@ -79,6 +95,21 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
79
95
80
96
CFLAGS=$CFLAGS_save
81
97
fi
98
+
99
+ if test $sync_bool_compare_and_swap_128_result = 0 ; then
100
+ LDFLAGS_save=$LDFLAGS
101
+ LDFLAGS="$LDFLAGS -latomic"
102
+
103
+ AC_MSG_CHECKING ( [ for __sync builtin atomic compare-and-swap on 128-bit values with -latomic] )
104
+ AC_TRY_LINK ( [ ] , [ __int128 x = 0; __sync_bool_compare_and_swap (&x, 0, 1);] ,
105
+ [ AC_MSG_RESULT ( [ yes] )
106
+ sync_bool_compare_and_swap_128_result=1
107
+ LDFLAGS_save="$LDFLAGS"] ,
108
+ [ AC_MSG_RESULT ( [ no] ) ] )
109
+
110
+ LDFLAGS=$LDFLAGS_save
111
+ fi
112
+
82
113
fi
83
114
84
115
AC_DEFINE_UNQUOTED ( [ OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128] , [ $sync_bool_compare_and_swap_128_result] ,
@@ -120,7 +151,7 @@ __sync_add_and_fetch(&tmp, 1);],
120
151
121
152
AC_DEFUN ( [ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128] , [
122
153
123
- OPAL_VAR_SCOPE_PUSH([ atomic_compare_exchange_n_128_result CFLAGS_save] )
154
+ OPAL_VAR_SCOPE_PUSH([ atomic_compare_exchange_n_128_result CFLAGS_save LDFLAGS_save ] )
124
155
125
156
AC_ARG_ENABLE ( [ cross-cmpset128] ,[ AC_HELP_STRING ([ --enable-cross-cmpset128] ,
126
157
[ enable the use of the __sync builtin atomic compare-and-swap 128 when cross compiling] )] )
@@ -151,15 +182,35 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
151
182
CFLAGS=$CFLAGS_save
152
183
fi
153
184
185
+ if test $atomic_compare_exchange_n_128_result = 0 ; then
186
+ LDFLAGS_save=$LDFLAGS
187
+ LDFLAGS="$LDFLAGS -latomic"
188
+
189
+ AC_MSG_CHECKING ( [ for __atomic builtin atomic compare-and-swap on 128-bit values with -latomic] )
190
+ AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ __int128 x = 0, y = 0; __atomic_compare_exchange_n (&x, &y, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);] ) ] ,
191
+ [ AC_MSG_RESULT ( [ yes] )
192
+ atomic_compare_exchange_n_128_result=1
193
+ LDFLAGS_save="$LDFLAGS"] ,
194
+ [ AC_MSG_RESULT ( [ no] ) ] ,
195
+ [ AC_MSG_RESULT ( [ no (cross compiling)] ) ] )
196
+
197
+ LDFLAGS=$LDFLAGS_save
198
+ fi
199
+
154
200
if test $atomic_compare_exchange_n_128_result = 1 ; then
155
- AC_MSG_CHECKING ( [ if __int128 atomic compare-and-swap is always lock-free] )
201
+ AC_MSG_CHECKING ( [ if __int128 atomic compare-and-swap is always lock-free] )
156
202
AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ if (!__atomic_always_lock_free(16, 0)) { return 1; }] ) ] ,
157
203
[ AC_MSG_RESULT ( [ yes] ) ] ,
158
204
[ AC_MSG_RESULT ( [ no] )
205
+ dnl Because of the variable PUSH/POP scope we need to manually unset these 2 variables
206
+ dnl before going into OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
207
+ unset CFLAGS_save
208
+ unset LDFLAGS_save
159
209
OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
160
210
atomic_compare_exchange_n_128_result=0] ,
161
211
[ AC_MSG_RESULT ( [ no (cross compiling)] ) ] )
162
212
fi
213
+
163
214
else
164
215
AC_MSG_CHECKING ( [ for compiler support of __atomic builtin atomic compare-and-swap on 128-bit values] )
165
216
@@ -182,6 +233,21 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
182
233
183
234
CFLAGS=$CFLAGS_save
184
235
fi
236
+
237
+ if test $atomic_compare_exchange_n_128_result = 0 ; then
238
+ LDFLAGS_save=$LDFLAGS
239
+ LDFLAGS="$LDFLAGS -latomic"
240
+
241
+ AC_MSG_CHECKING ( [ for __atomic builtin atomic compare-and-swap on 128-bit values with -latomic] )
242
+ AC_TRY_LINK ( [ ] , [ __int128 x = 0, y = 0; __atomic_compare_exchange_n (&x, &y, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);] ,
243
+ [ AC_MSG_RESULT ( [ yes] )
244
+ atomic_compare_exchange_n_128_result=1
245
+ LDFLAGS_save="$LDFLAGS"] ,
246
+ [ AC_MSG_RESULT ( [ no] ) ] )
247
+
248
+ LDFLAGS=$LDFLAGS_save
249
+ fi
250
+
185
251
fi
186
252
187
253
AC_DEFINE_UNQUOTED ( [ OPAL_HAVE_GCC_BUILTIN_CSWAP_INT128] , [ $atomic_compare_exchange_n_128_result] ,
0 commit comments