29 #ifndef _GLIBCXX_ATOMICITY_H 30 #define _GLIBCXX_ATOMICITY_H 1 32 #pragma GCC system_header 35 #include <bits/gthr.h> 38 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 #ifdef _GLIBCXX_ATOMIC_BUILTINS 47 static inline _Atomic_word
48 __exchange_and_add(
volatile _Atomic_word* __mem,
int __val)
49 {
return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
52 __atomic_add(
volatile _Atomic_word* __mem,
int __val)
53 { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
56 __attribute__ ((__unused__))
57 __exchange_and_add(volatile _Atomic_word*,
int) throw ();
60 __attribute__ ((__unused__))
61 __atomic_add(volatile _Atomic_word*,
int) throw ();
64 static inline _Atomic_word
65 __exchange_and_add_single(_Atomic_word* __mem,
int __val)
67 _Atomic_word __result = *__mem;
73 __atomic_add_single(_Atomic_word* __mem,
int __val)
76 static inline _Atomic_word
77 __attribute__ ((__unused__))
78 __exchange_and_add_dispatch(_Atomic_word* __mem,
int __val)
81 if (__gthread_active_p())
82 return __exchange_and_add(__mem, __val);
84 return __exchange_and_add_single(__mem, __val);
86 return __exchange_and_add_single(__mem, __val);
91 __attribute__ ((__unused__))
92 __atomic_add_dispatch(_Atomic_word* __mem,
int __val)
95 if (__gthread_active_p())
96 __atomic_add(__mem, __val);
98 __atomic_add_single(__mem, __val);
100 __atomic_add_single(__mem, __val);
104 _GLIBCXX_END_NAMESPACE_VERSION
110 #ifndef _GLIBCXX_READ_MEM_BARRIER 111 #define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) 113 #ifndef _GLIBCXX_WRITE_MEM_BARRIER 114 #define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
GNU extensions for public use.