Chris@102
|
1 /*
|
Chris@102
|
2 * Distributed under the Boost Software License, Version 1.0.
|
Chris@102
|
3 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
4 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
5 *
|
Chris@102
|
6 * Copyright (c) 2014 Andrey Semashev
|
Chris@102
|
7 */
|
Chris@102
|
8 /*!
|
Chris@102
|
9 * \file atomic/detail/ops_gcc_atomic.hpp
|
Chris@102
|
10 *
|
Chris@102
|
11 * This header contains implementation of the \c operations template.
|
Chris@102
|
12 */
|
Chris@102
|
13
|
Chris@102
|
14 #ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_
|
Chris@102
|
15 #define BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_
|
Chris@102
|
16
|
Chris@102
|
17 #include <boost/memory_order.hpp>
|
Chris@102
|
18 #include <boost/atomic/detail/config.hpp>
|
Chris@102
|
19 #include <boost/atomic/detail/storage_type.hpp>
|
Chris@102
|
20 #include <boost/atomic/detail/operations_fwd.hpp>
|
Chris@102
|
21 #include <boost/atomic/capabilities.hpp>
|
Chris@102
|
22 #if defined(__clang__) && (defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B))
|
Chris@102
|
23 #include <boost/atomic/detail/ops_gcc_x86_dcas.hpp>
|
Chris@102
|
24 #include <boost/atomic/detail/ops_cas_based.hpp>
|
Chris@102
|
25 #endif
|
Chris@102
|
26
|
Chris@102
|
27 #if __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE ||\
|
Chris@102
|
28 __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE || __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE ||\
|
Chris@102
|
29 __GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE || __GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE ||\
|
Chris@102
|
30 __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE
|
Chris@102
|
31 // There are platforms where we need to use larger storage types
|
Chris@102
|
32 #include <boost/atomic/detail/int_sizes.hpp>
|
Chris@102
|
33 #include <boost/atomic/detail/ops_extending_cas_based.hpp>
|
Chris@102
|
34 #endif
|
Chris@102
|
35
|
Chris@102
|
36 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@102
|
37 #pragma once
|
Chris@102
|
38 #endif
|
Chris@102
|
39
|
Chris@102
|
40 #if defined(__INTEL_COMPILER)
|
Chris@102
|
41 // This is used to suppress warning #32013 described below for Intel Compiler.
|
Chris@102
|
42 // In debug builds the compiler does not inline any functions, so basically
|
Chris@102
|
43 // every atomic function call results in this warning. I don't know any other
|
Chris@102
|
44 // way to selectively disable just this one warning.
|
Chris@102
|
45 #pragma system_header
|
Chris@102
|
46 #endif
|
Chris@102
|
47
|
Chris@102
|
48 namespace boost {
|
Chris@102
|
49 namespace atomics {
|
Chris@102
|
50 namespace detail {
|
Chris@102
|
51
|
Chris@102
|
52 /*!
|
Chris@102
|
53 * The function converts \c boost::memory_order values to the compiler-specific constants.
|
Chris@102
|
54 *
|
Chris@102
|
55 * NOTE: The intention is that the function is optimized away by the compiler, and the
|
Chris@102
|
56 * compiler-specific constants are passed to the intrinsics. I know constexpr doesn't
|
Chris@102
|
57 * work in this case because the standard atomics interface require memory ordering
|
Chris@102
|
58 * constants to be passed as function arguments, at which point they stop being constexpr.
|
Chris@102
|
59 * However it is crucial that the compiler sees constants and not runtime values,
|
Chris@102
|
60 * because otherwise it just ignores the ordering value and always uses seq_cst.
|
Chris@102
|
61 * This is the case with Intel C++ Compiler 14.0.3 (Composer XE 2013 SP1, update 3) and
|
Chris@102
|
62 * gcc 4.8.2. Intel Compiler issues a warning in this case:
|
Chris@102
|
63 *
|
Chris@102
|
64 * warning #32013: Invalid memory order specified. Defaulting to seq_cst memory order.
|
Chris@102
|
65 *
|
Chris@102
|
66 * while gcc acts silently.
|
Chris@102
|
67 *
|
Chris@102
|
68 * To mitigate the problem ALL functions, including the atomic<> members must be
|
Chris@102
|
69 * declared with BOOST_FORCEINLINE. In this case the compilers are able to see that
|
Chris@102
|
70 * all functions are called with constant orderings and call intrinstcts properly.
|
Chris@102
|
71 *
|
Chris@102
|
72 * Unfortunately, this still doesn't work in debug mode as the compiler doesn't
|
Chris@102
|
73 * inline functions even when marked with BOOST_FORCEINLINE. In this case all atomic
|
Chris@102
|
74 * operaions will be executed with seq_cst semantics.
|
Chris@102
|
75 */
|
Chris@102
|
76 BOOST_FORCEINLINE BOOST_CONSTEXPR int convert_memory_order_to_gcc(memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
77 {
|
Chris@102
|
78 return (order == memory_order_relaxed ? __ATOMIC_RELAXED : (order == memory_order_consume ? __ATOMIC_CONSUME :
|
Chris@102
|
79 (order == memory_order_acquire ? __ATOMIC_ACQUIRE : (order == memory_order_release ? __ATOMIC_RELEASE :
|
Chris@102
|
80 (order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_SEQ_CST)))));
|
Chris@102
|
81 }
|
Chris@102
|
82
|
Chris@102
|
83 template< typename T >
|
Chris@102
|
84 struct gcc_atomic_operations
|
Chris@102
|
85 {
|
Chris@102
|
86 typedef T storage_type;
|
Chris@102
|
87
|
Chris@102
|
88 static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
89 {
|
Chris@102
|
90 __atomic_store_n(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
91 }
|
Chris@102
|
92
|
Chris@102
|
93 static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
94 {
|
Chris@102
|
95 return __atomic_load_n(&storage, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
96 }
|
Chris@102
|
97
|
Chris@102
|
98 static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
99 {
|
Chris@102
|
100 return __atomic_fetch_add(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
101 }
|
Chris@102
|
102
|
Chris@102
|
103 static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
104 {
|
Chris@102
|
105 return __atomic_fetch_sub(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
106 }
|
Chris@102
|
107
|
Chris@102
|
108 static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
109 {
|
Chris@102
|
110 return __atomic_exchange_n(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
111 }
|
Chris@102
|
112
|
Chris@102
|
113 static BOOST_FORCEINLINE bool compare_exchange_strong(
|
Chris@102
|
114 storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT
|
Chris@102
|
115 {
|
Chris@102
|
116 return __atomic_compare_exchange_n
|
Chris@102
|
117 (
|
Chris@102
|
118 &storage, &expected, desired, false,
|
Chris@102
|
119 atomics::detail::convert_memory_order_to_gcc(success_order),
|
Chris@102
|
120 atomics::detail::convert_memory_order_to_gcc(failure_order)
|
Chris@102
|
121 );
|
Chris@102
|
122 }
|
Chris@102
|
123
|
Chris@102
|
124 static BOOST_FORCEINLINE bool compare_exchange_weak(
|
Chris@102
|
125 storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT
|
Chris@102
|
126 {
|
Chris@102
|
127 return __atomic_compare_exchange_n
|
Chris@102
|
128 (
|
Chris@102
|
129 &storage, &expected, desired, true,
|
Chris@102
|
130 atomics::detail::convert_memory_order_to_gcc(success_order),
|
Chris@102
|
131 atomics::detail::convert_memory_order_to_gcc(failure_order)
|
Chris@102
|
132 );
|
Chris@102
|
133 }
|
Chris@102
|
134
|
Chris@102
|
135 static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
136 {
|
Chris@102
|
137 return __atomic_fetch_and(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
138 }
|
Chris@102
|
139
|
Chris@102
|
140 static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
141 {
|
Chris@102
|
142 return __atomic_fetch_or(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
143 }
|
Chris@102
|
144
|
Chris@102
|
145 static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
146 {
|
Chris@102
|
147 return __atomic_fetch_xor(&storage, v, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
148 }
|
Chris@102
|
149
|
Chris@102
|
150 static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
151 {
|
Chris@102
|
152 return __atomic_test_and_set(&storage, atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
153 }
|
Chris@102
|
154
|
Chris@102
|
155 static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
156 {
|
Chris@102
|
157 __atomic_clear(const_cast< storage_type* >(&storage), atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
158 }
|
Chris@102
|
159
|
Chris@102
|
160 static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile& storage) BOOST_NOEXCEPT
|
Chris@102
|
161 {
|
Chris@102
|
162 return __atomic_is_lock_free(sizeof(storage_type), &storage);
|
Chris@102
|
163 }
|
Chris@102
|
164 };
|
Chris@102
|
165
|
Chris@102
|
166 #if BOOST_ATOMIC_INT128_LOCK_FREE > 0
|
Chris@102
|
167 #if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
|
Chris@102
|
168
|
Chris@102
|
169 // Workaround for clang bug: http://llvm.org/bugs/show_bug.cgi?id=19149
|
Chris@102
|
170 // Clang 3.4 does not implement 128-bit __atomic* intrinsics even though it defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
|
Chris@102
|
171 template< bool Signed >
|
Chris@102
|
172 struct operations< 16u, Signed > :
|
Chris@102
|
173 public cas_based_operations< gcc_dcas_x86_64< Signed > >
|
Chris@102
|
174 {
|
Chris@102
|
175 };
|
Chris@102
|
176
|
Chris@102
|
177 #else
|
Chris@102
|
178
|
Chris@102
|
179 template< bool Signed >
|
Chris@102
|
180 struct operations< 16u, Signed > :
|
Chris@102
|
181 public gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >
|
Chris@102
|
182 {
|
Chris@102
|
183 };
|
Chris@102
|
184
|
Chris@102
|
185 #endif
|
Chris@102
|
186 #endif
|
Chris@102
|
187
|
Chris@102
|
188
|
Chris@102
|
189 #if BOOST_ATOMIC_INT64_LOCK_FREE > 0
|
Chris@102
|
190 #if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B)
|
Chris@102
|
191
|
Chris@102
|
192 // Workaround for clang bug http://llvm.org/bugs/show_bug.cgi?id=19355
|
Chris@102
|
193 template< bool Signed >
|
Chris@102
|
194 struct operations< 8u, Signed > :
|
Chris@102
|
195 public cas_based_operations< gcc_dcas_x86< Signed > >
|
Chris@102
|
196 {
|
Chris@102
|
197 };
|
Chris@102
|
198
|
Chris@102
|
199 #elif (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
|
Chris@102
|
200 (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
|
Chris@102
|
201 (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
|
Chris@102
|
202 (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
|
Chris@102
|
203 (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
|
Chris@102
|
204
|
Chris@102
|
205 #define BOOST_ATOMIC_DETAIL_INT64_EXTENDED
|
Chris@102
|
206
|
Chris@102
|
207 template< bool Signed >
|
Chris@102
|
208 struct operations< 8u, Signed > :
|
Chris@102
|
209 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed >
|
Chris@102
|
210 {
|
Chris@102
|
211 };
|
Chris@102
|
212
|
Chris@102
|
213 #else
|
Chris@102
|
214
|
Chris@102
|
215 template< bool Signed >
|
Chris@102
|
216 struct operations< 8u, Signed > :
|
Chris@102
|
217 public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >
|
Chris@102
|
218 {
|
Chris@102
|
219 };
|
Chris@102
|
220
|
Chris@102
|
221 #endif
|
Chris@102
|
222 #endif
|
Chris@102
|
223
|
Chris@102
|
224 #if BOOST_ATOMIC_INT32_LOCK_FREE > 0
|
Chris@102
|
225 #if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
|
Chris@102
|
226 (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
|
Chris@102
|
227 (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
|
Chris@102
|
228 (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
|
Chris@102
|
229 (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
|
Chris@102
|
230
|
Chris@102
|
231 #define BOOST_ATOMIC_DETAIL_INT32_EXTENDED
|
Chris@102
|
232
|
Chris@102
|
233 #if !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
|
Chris@102
|
234
|
Chris@102
|
235 template< bool Signed >
|
Chris@102
|
236 struct operations< 4u, Signed > :
|
Chris@102
|
237 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 4u, Signed >
|
Chris@102
|
238 {
|
Chris@102
|
239 };
|
Chris@102
|
240
|
Chris@102
|
241 #else // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
|
Chris@102
|
242
|
Chris@102
|
243 template< bool Signed >
|
Chris@102
|
244 struct operations< 4u, Signed > :
|
Chris@102
|
245 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed >
|
Chris@102
|
246 {
|
Chris@102
|
247 };
|
Chris@102
|
248
|
Chris@102
|
249 #endif // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
|
Chris@102
|
250
|
Chris@102
|
251 #else
|
Chris@102
|
252
|
Chris@102
|
253 template< bool Signed >
|
Chris@102
|
254 struct operations< 4u, Signed > :
|
Chris@102
|
255 public gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >
|
Chris@102
|
256 {
|
Chris@102
|
257 };
|
Chris@102
|
258
|
Chris@102
|
259 #endif
|
Chris@102
|
260 #endif
|
Chris@102
|
261
|
Chris@102
|
262 #if BOOST_ATOMIC_INT16_LOCK_FREE > 0
|
Chris@102
|
263 #if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
|
Chris@102
|
264 (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
|
Chris@102
|
265 (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
|
Chris@102
|
266 (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
|
Chris@102
|
267 (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
|
Chris@102
|
268
|
Chris@102
|
269 #define BOOST_ATOMIC_DETAIL_INT16_EXTENDED
|
Chris@102
|
270
|
Chris@102
|
271 #if !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED)
|
Chris@102
|
272
|
Chris@102
|
273 template< bool Signed >
|
Chris@102
|
274 struct operations< 2u, Signed > :
|
Chris@102
|
275 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 2u, Signed >
|
Chris@102
|
276 {
|
Chris@102
|
277 };
|
Chris@102
|
278
|
Chris@102
|
279 #elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
|
Chris@102
|
280
|
Chris@102
|
281 template< bool Signed >
|
Chris@102
|
282 struct operations< 2u, Signed > :
|
Chris@102
|
283 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 2u, Signed >
|
Chris@102
|
284 {
|
Chris@102
|
285 };
|
Chris@102
|
286
|
Chris@102
|
287 #else
|
Chris@102
|
288
|
Chris@102
|
289 template< bool Signed >
|
Chris@102
|
290 struct operations< 2u, Signed > :
|
Chris@102
|
291 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed >
|
Chris@102
|
292 {
|
Chris@102
|
293 };
|
Chris@102
|
294
|
Chris@102
|
295 #endif
|
Chris@102
|
296
|
Chris@102
|
297 #else
|
Chris@102
|
298
|
Chris@102
|
299 template< bool Signed >
|
Chris@102
|
300 struct operations< 2u, Signed > :
|
Chris@102
|
301 public gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >
|
Chris@102
|
302 {
|
Chris@102
|
303 };
|
Chris@102
|
304
|
Chris@102
|
305 #endif
|
Chris@102
|
306 #endif
|
Chris@102
|
307
|
Chris@102
|
308 #if BOOST_ATOMIC_INT8_LOCK_FREE > 0
|
Chris@102
|
309 #if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 1 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
|
Chris@102
|
310 (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 1 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
|
Chris@102
|
311 (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 1 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
|
Chris@102
|
312 (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 1 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
|
Chris@102
|
313 (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) ||\
|
Chris@102
|
314 (__GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE) ||\
|
Chris@102
|
315 (__GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE)
|
Chris@102
|
316
|
Chris@102
|
317 #if !defined(BOOST_ATOMIC_DETAIL_INT16_EXTENDED)
|
Chris@102
|
318
|
Chris@102
|
319 template< bool Signed >
|
Chris@102
|
320 struct operations< 1u, Signed > :
|
Chris@102
|
321 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >, 1u, Signed >
|
Chris@102
|
322 {
|
Chris@102
|
323 };
|
Chris@102
|
324
|
Chris@102
|
325 #elif !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED)
|
Chris@102
|
326
|
Chris@102
|
327 template< bool Signed >
|
Chris@102
|
328 struct operations< 1u, Signed > :
|
Chris@102
|
329 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 1u, Signed >
|
Chris@102
|
330 {
|
Chris@102
|
331 };
|
Chris@102
|
332
|
Chris@102
|
333 #elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
|
Chris@102
|
334
|
Chris@102
|
335 template< bool Signed >
|
Chris@102
|
336 struct operations< 1u, Signed > :
|
Chris@102
|
337 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 1u, Signed >
|
Chris@102
|
338 {
|
Chris@102
|
339 };
|
Chris@102
|
340
|
Chris@102
|
341 #else
|
Chris@102
|
342
|
Chris@102
|
343 template< bool Signed >
|
Chris@102
|
344 struct operations< 1u, Signed > :
|
Chris@102
|
345 public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed >
|
Chris@102
|
346 {
|
Chris@102
|
347 };
|
Chris@102
|
348
|
Chris@102
|
349 #endif
|
Chris@102
|
350
|
Chris@102
|
351 #else
|
Chris@102
|
352
|
Chris@102
|
353 template< bool Signed >
|
Chris@102
|
354 struct operations< 1u, Signed > :
|
Chris@102
|
355 public gcc_atomic_operations< typename make_storage_type< 1u, Signed >::type >
|
Chris@102
|
356 {
|
Chris@102
|
357 };
|
Chris@102
|
358
|
Chris@102
|
359 #endif
|
Chris@102
|
360 #endif
|
Chris@102
|
361
|
Chris@102
|
362 #undef BOOST_ATOMIC_DETAIL_INT16_EXTENDED
|
Chris@102
|
363 #undef BOOST_ATOMIC_DETAIL_INT32_EXTENDED
|
Chris@102
|
364 #undef BOOST_ATOMIC_DETAIL_INT64_EXTENDED
|
Chris@102
|
365
|
Chris@102
|
366 BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
367 {
|
Chris@102
|
368 __atomic_thread_fence(atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
369 }
|
Chris@102
|
370
|
Chris@102
|
371 BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
|
Chris@102
|
372 {
|
Chris@102
|
373 __atomic_signal_fence(atomics::detail::convert_memory_order_to_gcc(order));
|
Chris@102
|
374 }
|
Chris@102
|
375
|
Chris@102
|
376 } // namespace detail
|
Chris@102
|
377 } // namespace atomics
|
Chris@102
|
378 } // namespace boost
|
Chris@102
|
379
|
Chris@102
|
380 #endif // BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_
|