123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #ifndef _GLIBCXX_ATOMICITY_H
- #define _GLIBCXX_ATOMICITY_H 1
- #pragma GCC system_header
- #include <bits/c++config.h>
- #include <bits/gthr.h>
- #include <bits/atomic_word.h>
- namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-
-
-
- #ifdef _GLIBCXX_ATOMIC_BUILTINS
- static inline _Atomic_word
- __exchange_and_add(volatile _Atomic_word* __mem, int __val)
- { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
- static inline void
- __atomic_add(volatile _Atomic_word* __mem, int __val)
- { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
- #else
- _Atomic_word
- __attribute__ ((__unused__))
- __exchange_and_add(volatile _Atomic_word*, int) throw ();
- void
- __attribute__ ((__unused__))
- __atomic_add(volatile _Atomic_word*, int) throw ();
- #endif
- static inline _Atomic_word
- __exchange_and_add_single(_Atomic_word* __mem, int __val)
- {
- _Atomic_word __result = *__mem;
- *__mem += __val;
- return __result;
- }
- static inline void
- __atomic_add_single(_Atomic_word* __mem, int __val)
- { *__mem += __val; }
- static inline _Atomic_word
- __attribute__ ((__unused__))
- __exchange_and_add_dispatch(_Atomic_word* __mem, int __val)
- {
- #ifdef __GTHREADS
- if (__gthread_active_p())
- return __exchange_and_add(__mem, __val);
- else
- return __exchange_and_add_single(__mem, __val);
- #else
- return __exchange_and_add_single(__mem, __val);
- #endif
- }
- static inline void
- __attribute__ ((__unused__))
- __atomic_add_dispatch(_Atomic_word* __mem, int __val)
- {
- #ifdef __GTHREADS
- if (__gthread_active_p())
- __atomic_add(__mem, __val);
- else
- __atomic_add_single(__mem, __val);
- #else
- __atomic_add_single(__mem, __val);
- #endif
- }
- _GLIBCXX_END_NAMESPACE_VERSION
- }
- #ifndef _GLIBCXX_READ_MEM_BARRIER
- #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
- #endif
- #ifndef _GLIBCXX_WRITE_MEM_BARRIER
- #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
- #endif
- #endif
|