Go to the documentation of this file. 1 #ifndef _XRDSYSATOMICS_
2 #define _XRDSYSATOMICS_
48 #define AtomicBeg(Mtx)
49 #define AtomicEnd(Mtx)
50 #define AtomicAdd(x, y) __sync_fetch_and_add(&x, y)
51 #define AtomicFAdd(w,x,y) w = __sync_fetch_and_add(&x, y)
52 #define AtomicCAS(x, y, z) __sync_bool_compare_and_swap(&x, y, z)
53 #define AtomicDec(x) __sync_fetch_and_sub(&x, 1)
54 #define AtomicFAZ(x) __sync_fetch_and_and(&x, 0)
55 #define AtomicFZAP(w,x) w = __sync_fetch_and_and(&x, 0)
56 #define AtomicGet(x) __sync_fetch_and_or(&x, 0)
57 #define AtomicInc(x) __sync_fetch_and_add(&x, 1)
58 #define AtomicSub(x, y) __sync_fetch_and_sub(&x, y)
59 #define AtomicFSub(w,x,y) w = __sync_fetch_and_sub(&x, y)
60 #define AtomicZAP(x) __sync_fetch_and_and(&x, 0)
62 #define AtomicBeg(Mtx) Mtx.Lock()
63 #define AtomicEnd(Mtx) Mtx.UnLock()
64 #define AtomicAdd(x, y) x += y // When assigning use AtomicFAdd!
65 #define AtomicFAdd(w,x,y) {w = x; x += y;}
66 #define AtomicCAS(x, y, z) if (x == y) x = z
67 #define AtomicDec(x) x--
68 #define AtomicFAZ(x) x; x = 0 // Braces when used with if-else!
69 #define AtomicFZAP(w,x) {w = x; x = 0;}
70 #define AtomicGet(x) x
71 #define AtomicInc(x) x++
72 #define AtomicSub(x, y) x -= y // When assigning use AtomicFSub!
73 #define AtomicFSub(w,x,y) {w = x; x -= y;}
74 #define AtomicZAP(x) x = 0
86 #if __cplusplus >= 201103L
88 #define CPP_ATOMIC_LOAD(x, order) x.load(order)
89 #define CPP_ATOMIC_STORE(x, val, order) x.store(val, order)
90 #define CPP_ATOMIC_TYPE(kind) std::atomic<kind>
92 #define CPP_ATOMIC_LOAD(x, order) x
93 #define CPP_ATOMIC_STORE(x, val, order) x = val
94 #define CPP_ATOMIC_TYPE(kind) kind