1 #ifndef __FACE_SDK__PBIO__ATOMIC_EXCHANGE_ADD_H__85f16090e1cc420091945dab3a112af4
2 #define __FACE_SDK__PBIO__ATOMIC_EXCHANGE_ADD_H__85f16090e1cc420091945dab3a112af4
7 #if defined __INTEL_COMPILER && !(defined WIN32 || defined _WIN32)
11 static inline int atomic_exchange_add(
int &x,
const int delta) {
return (
int)_InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(&x)), delta); }
15 #elif defined __GNUC__
16 # if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__)
17 # ifdef __ATOMIC_ACQ_REL
21 static inline int atomic_exchange_add(
int &x,
const int delta) {
return __c11_atomic_fetch_add((_Atomic(
int)*)(&x), delta, __ATOMIC_ACQ_REL); }
29 static inline int atomic_exchange_add(
int &x,
const int delta) {
return __atomic_fetch_add((_Atomic(
int)*)(&x), delta, 4); }
35 # if defined __ATOMIC_ACQ_REL && !defined __clang__
40 static inline int atomic_exchange_add(
int &x,
const int delta) {
return (
int)__atomic_fetch_add((
int*)(&x), (
int)(delta), __ATOMIC_ACQ_REL); }
48 static inline int atomic_exchange_add(
int &x,
const int delta) {
return (
int)__sync_fetch_and_add((
int*)(&x), (
int)(delta)); }
54 #elif defined _MSC_VER && !defined RC_INVOKED
60 static inline int atomic_exchange_add(
int &x,
const int delta) {
return (
int)_InterlockedExchangeAdd((
long volatile*)(&x), delta); }
66 #error no atomic_exchange_add implementation
72 #endif // __FACE_SDK__PBIO__ATOMIC_EXCHANGE_ADD_H__85f16090e1cc420091945dab3a112af4