30 #ifndef _GLIBCXX_ATOMICITY_H
31 #define _GLIBCXX_ATOMICITY_H 1
34 #include <bits/gthr.h>
37 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 #ifdef _GLIBCXX_ATOMIC_BUILTINS
46 static inline _Atomic_word
47 __exchange_and_add(
volatile _Atomic_word* __mem,
int __val)
48 {
return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
51 __atomic_add(
volatile _Atomic_word* __mem,
int __val)
52 { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
55 __attribute__ ((__unused__))
56 __exchange_and_add(volatile _Atomic_word*,
int) throw ();
59 __attribute__ ((__unused__))
60 __atomic_add(volatile _Atomic_word*,
int) throw ();
63 static inline _Atomic_word
64 __exchange_and_add_single(_Atomic_word* __mem,
int __val)
66 _Atomic_word __result = *__mem;
72 __atomic_add_single(_Atomic_word* __mem,
int __val)
75 static inline _Atomic_word
76 __attribute__ ((__unused__))
77 __exchange_and_add_dispatch(_Atomic_word* __mem,
int __val)
80 if (__gthread_active_p())
81 return __exchange_and_add(__mem, __val);
83 return __exchange_and_add_single(__mem, __val);
85 return __exchange_and_add_single(__mem, __val);
90 __attribute__ ((__unused__))
91 __atomic_add_dispatch(_Atomic_word* __mem,
int __val)
94 if (__gthread_active_p())
95 __atomic_add(__mem, __val);
97 __atomic_add_single(__mem, __val);
99 __atomic_add_single(__mem, __val);
103 _GLIBCXX_END_NAMESPACE_VERSION
109 #ifndef _GLIBCXX_READ_MEM_BARRIER
110 #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
112 #ifndef _GLIBCXX_WRITE_MEM_BARRIER
113 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")