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
48 __attribute__((__always_inline__))
49 __exchange_and_add(
volatile _Atomic_word* __mem,
int __val)
50 {
return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
53 __attribute__((__always_inline__))
54 __atomic_add(
volatile _Atomic_word* __mem,
int __val)
55 { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
58 __exchange_and_add(
volatile _Atomic_word*,
int) _GLIBCXX_NOTHROW;
61 __atomic_add(
volatile _Atomic_word*,
int) _GLIBCXX_NOTHROW;
65 __attribute__((__always_inline__))
66 __exchange_and_add_single(_Atomic_word* __mem,
int __val)
68 _Atomic_word __result = *__mem;
74 __attribute__((__always_inline__))
75 __atomic_add_single(_Atomic_word* __mem,
int __val)
79 __attribute__ ((__always_inline__))
80 __exchange_and_add_dispatch(_Atomic_word* __mem,
int __val)
83 if (__gthread_active_p())
84 return __exchange_and_add(__mem, __val);
86 return __exchange_and_add_single(__mem, __val);
90 __attribute__ ((__always_inline__))
91 __atomic_add_dispatch(_Atomic_word* __mem,
int __val)
94 if (__gthread_active_p())
96 __atomic_add(__mem, __val);
100 __atomic_add_single(__mem, __val);
103 _GLIBCXX_END_NAMESPACE_VERSION
109 #ifndef _GLIBCXX_READ_MEM_BARRIER
110 #define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
112 #ifndef _GLIBCXX_WRITE_MEM_BARRIER
113 #define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
GNU extensions for public use.