8#ifndef INCLUDED_BSLS_ATOMICOPERATIONS_ALL_ALL_CLANGINTRINSICS
9#define INCLUDED_BSLS_ATOMICOPERATIONS_ALL_ALL_CLANGINTRINSICS
55#include <bsls_atomicoperations_default.h>
59#if defined(BSLS_PLATFORM_CMP_CLANG)
60#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
66struct AtomicOperations_ALL_ALL_ClangIntrinsics;
67typedef AtomicOperations_ALL_ALL_ClangIntrinsics AtomicOperations_Imp;
74struct Atomic_TypeTraits<AtomicOperations_ALL_ALL_ClangIntrinsics>
76 struct __attribute__((__aligned__(sizeof(int)))) Int
81 struct __attribute__((__aligned__(sizeof(Types::Int64)))) Int64
83 _Atomic(Types::Int64) d_value;
86 struct __attribute__((__aligned__(sizeof(unsigned int)))) Uint
88 _Atomic(
unsigned int) d_value;
91 struct __attribute__((__aligned__(sizeof(Types::Uint64)))) Uint64
93 _Atomic(Types::Uint64) d_value;
96 struct __attribute__((__aligned__(sizeof(void *)))) Pointer
98 _Atomic(
void *) d_value;
106struct AtomicOperations_ALL_ALL_ClangIntrinsics
107 #ifdef BSLS_PLATFORM_CPU_64_BIT
108 : AtomicOperations_Default64<AtomicOperations_ALL_ALL_ClangIntrinsics>
110 : AtomicOperations_Default32<AtomicOperations_ALL_ALL_ClangIntrinsics>
113 typedef Atomic_TypeTraits<AtomicOperations_ALL_ALL_ClangIntrinsics>
117 typedef char AtomicInt_SizeCheck[
sizeof(int) == 4 ? 1 : -1];
121 static void initInt(AtomicTypes::Int *atomicInt,
int value);
123 static int getInt(
const AtomicTypes::Int *atomicInt);
125 static int getIntAcquire(
const AtomicTypes::Int *atomicInt);
127 static int getIntRelaxed(
const AtomicTypes::Int *atomicInt);
129 static void setInt(AtomicTypes::Int *atomicInt,
int value);
131 static void setIntRelease(AtomicTypes::Int *atomicInt,
int value);
133 static void setIntRelaxed(AtomicTypes::Int *atomicInt,
int value);
135 static int swapInt(AtomicTypes::Int *atomicInt,
int swapValue);
137 static int swapIntAcqRel(AtomicTypes::Int *atomicInt,
int swapValue);
139 static int testAndSwapInt(AtomicTypes::Int *atomicInt,
143 static int testAndSwapIntAcqRel(AtomicTypes::Int *atomicInt,
147 static int addIntNv(AtomicTypes::Int *atomicInt,
int value);
149 static int addIntNvAcqRel(AtomicTypes::Int *atomicInt,
int value);
151 static int addIntNvRelaxed(AtomicTypes::Int *atomicInt,
int value);
155 static void initInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value);
157 static Types::Int64 getInt64(
const AtomicTypes::Int64 *atomicInt);
159 static Types::Int64 getInt64Acquire(
const AtomicTypes::Int64 *atomicInt);
161 static Types::Int64 getInt64Relaxed(
const AtomicTypes::Int64 *atomicInt);
163 static void setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value);
165 static void setInt64Release(AtomicTypes::Int64 *atomicInt,
168 static void setInt64Relaxed(AtomicTypes::Int64 *atomicInt,
171 static Types::Int64 swapInt64(AtomicTypes::Int64 *atomicInt,
172 Types::Int64 swapValue);
174 static Types::Int64 swapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
175 Types::Int64 swapValue);
177 static Types::Int64 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
178 Types::Int64 compareValue,
179 Types::Int64 swapValue);
181 static Types::Int64 testAndSwapInt64AcqRel(
182 AtomicTypes::Int64 *atomicInt,
183 Types::Int64 compareValue,
184 Types::Int64 swapValue);
186 static Types::Int64 addInt64Nv(AtomicTypes::Int64 *atomicInt,
189 static Types::Int64 addInt64NvAcqRel(AtomicTypes::Int64 *atomicInt,
192 static Types::Int64 addInt64NvRelaxed(AtomicTypes::Int64 *atomicInt,
205void AtomicOperations_ALL_ALL_ClangIntrinsics::
206 initInt(AtomicTypes::Int *atomicInt,
int value)
208 __c11_atomic_init(&atomicInt->d_value, value);
212int AtomicOperations_ALL_ALL_ClangIntrinsics::
213 getInt(
const AtomicTypes::Int *atomicInt)
215 return __c11_atomic_load(
216 const_cast<_Atomic(
int) *
>(&atomicInt->d_value),
221int AtomicOperations_ALL_ALL_ClangIntrinsics::
222 getIntAcquire(
const AtomicTypes::Int *atomicInt)
224 return __c11_atomic_load(
225 const_cast<_Atomic(
int) *
>(&atomicInt->d_value),
230int AtomicOperations_ALL_ALL_ClangIntrinsics::
231 getIntRelaxed(
const AtomicTypes::Int *atomicInt)
233 return __c11_atomic_load(
234 const_cast<_Atomic(
int) *
>(&atomicInt->d_value),
239void AtomicOperations_ALL_ALL_ClangIntrinsics::
240 setInt(AtomicTypes::Int *atomicInt,
int value)
242 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_SEQ_CST);
246void AtomicOperations_ALL_ALL_ClangIntrinsics::
247 setIntRelease(AtomicTypes::Int *atomicInt,
int value)
249 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_RELEASE);
253void AtomicOperations_ALL_ALL_ClangIntrinsics::
254 setIntRelaxed(AtomicTypes::Int *atomicInt,
int value)
256 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_RELAXED);
260int AtomicOperations_ALL_ALL_ClangIntrinsics::
261 swapInt(AtomicTypes::Int *atomicInt,
int swapValue)
264 __c11_atomic_exchange(&atomicInt->d_value, swapValue, __ATOMIC_SEQ_CST);
268int AtomicOperations_ALL_ALL_ClangIntrinsics::
269 swapIntAcqRel(AtomicTypes::Int *atomicInt,
int swapValue)
272 __c11_atomic_exchange(&atomicInt->d_value, swapValue, __ATOMIC_ACQ_REL);
276int AtomicOperations_ALL_ALL_ClangIntrinsics::
277 testAndSwapInt(AtomicTypes::Int *atomicInt,
281 __c11_atomic_compare_exchange_strong(&atomicInt->d_value,
290int AtomicOperations_ALL_ALL_ClangIntrinsics::
291 testAndSwapIntAcqRel(AtomicTypes::Int *atomicInt,
295 __c11_atomic_compare_exchange_strong(&atomicInt->d_value,
304int AtomicOperations_ALL_ALL_ClangIntrinsics::
305 addIntNv(AtomicTypes::Int *atomicInt,
int value)
307 return static_cast<unsigned>(__c11_atomic_fetch_add(&atomicInt->d_value,
314int AtomicOperations_ALL_ALL_ClangIntrinsics::
315 addIntNvAcqRel(AtomicTypes::Int *atomicInt,
int value)
317 return static_cast<unsigned>(__c11_atomic_fetch_add(&atomicInt->d_value,
324int AtomicOperations_ALL_ALL_ClangIntrinsics::
325 addIntNvRelaxed(AtomicTypes::Int *atomicInt,
int value)
327 return static_cast<unsigned>(__c11_atomic_fetch_add(&atomicInt->d_value,
334void AtomicOperations_ALL_ALL_ClangIntrinsics::
335 initInt64(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
337 __c11_atomic_init(&atomicInt->d_value, value);
342 getInt64(
const AtomicTypes::Int64 *atomicInt)
344 return __c11_atomic_load(
345 const_cast<_Atomic(
Types::Int64) *
>(&atomicInt->d_value),
351 getInt64Acquire(
const AtomicTypes::Int64 *atomicInt)
353 return __c11_atomic_load(
354 const_cast<_Atomic(
Types::Int64) *
>(&atomicInt->d_value),
360 getInt64Relaxed(
const AtomicTypes::Int64 *atomicInt)
362 return __c11_atomic_load(
363 const_cast<_Atomic(
Types::Int64) *
>(&atomicInt->d_value),
368void AtomicOperations_ALL_ALL_ClangIntrinsics::
369 setInt64(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
371 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_SEQ_CST);
375void AtomicOperations_ALL_ALL_ClangIntrinsics::
376 setInt64Release(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
378 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_RELEASE);
382void AtomicOperations_ALL_ALL_ClangIntrinsics::
383 setInt64Relaxed(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
385 __c11_atomic_store(&atomicInt->d_value, value, __ATOMIC_RELAXED);
390 swapInt64(AtomicTypes::Int64 *atomicInt,
Types::Int64 swapValue)
393 __c11_atomic_exchange(&atomicInt->d_value,
400 swapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
Types::Int64 swapValue)
403 __c11_atomic_exchange(&atomicInt->d_value,
410 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
414 __c11_atomic_compare_exchange_strong(&atomicInt->d_value,
424 testAndSwapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
428 __c11_atomic_compare_exchange_strong(&atomicInt->d_value,
438 addInt64Nv(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
441 __c11_atomic_fetch_add(&atomicInt->d_value,
449 addInt64NvAcqRel(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
452 __c11_atomic_fetch_add(&atomicInt->d_value,
460 addInt64NvRelaxed(AtomicTypes::Int64 *atomicInt,
Types::Int64 value)
463 __c11_atomic_fetch_add(&atomicInt->d_value,
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691
unsigned long long Uint64
Definition bsls_types.h:137
long long Int64
Definition bsls_types.h:132