29#ifndef _GLIBCXX_ATOMICITY_H
30#define _GLIBCXX_ATOMICITY_H 1
33#pragma GCC system_header
39#if __has_include(<sys/single_threaded.h>)
40# include <sys/single_threaded.h>
42#if __cplusplus >= 201103L
46namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
50 __attribute__((__always_inline__))
52 __is_single_threaded() _GLIBCXX_NOTHROW
56#elif __has_include(<sys/single_threaded.h>)
57 return ::__libc_single_threaded;
59 return !__gthread_active_p();
67#ifdef _GLIBCXX_ATOMIC_WORD_BUILTINS
69 __attribute__((__always_inline__))
70 __exchange_and_add(
volatile _Atomic_word* __mem,
int __val)
71 {
return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
74 __attribute__((__always_inline__))
75 __atomic_add(
volatile _Atomic_word* __mem,
int __val)
76 { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
79 __exchange_and_add(
volatile _Atomic_word*,
int) _GLIBCXX_NOTHROW;
82 __atomic_add(
volatile _Atomic_word*,
int) _GLIBCXX_NOTHROW;
85#if __cplusplus < 201103L
90 _Atomic_word_fits_in_long[
sizeof(_Atomic_word) <=
sizeof(
long) ? 1 : -1];
94 __attribute__((__always_inline__))
95 __exchange_and_add_single(_Atomic_word* __mem,
int __val)
97 _Atomic_word __result = *__mem;
99#if __cplusplus >= 201103L
100 std::make_unsigned<_Atomic_word>::type __u;
114 __attribute__((__always_inline__))
115 __atomic_add_single(_Atomic_word* __mem,
int __val)
117#if __cplusplus >= 201103L
118 std::make_unsigned<_Atomic_word>::type __u;
128 __attribute__ ((__always_inline__))
129 __exchange_and_add_dispatch(_Atomic_word* __mem,
int __val)
131 if (__is_single_threaded())
132 return __exchange_and_add_single(__mem, __val);
134 return __exchange_and_add(__mem, __val);
138 __attribute__ ((__always_inline__))
139 __atomic_add_dispatch(_Atomic_word* __mem,
int __val)
141 if (__is_single_threaded())
142 __atomic_add_single(__mem, __val);
144 __atomic_add(__mem, __val);
147_GLIBCXX_END_NAMESPACE_VERSION
153#ifndef _GLIBCXX_READ_MEM_BARRIER
154#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
156#ifndef _GLIBCXX_WRITE_MEM_BARRIER
157#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
GNU extensions for public use.