blob: 4731e4f47a1acf17709a64878d12bc2571a3b765 [file] [log] [blame]
Howard Hinnant8f73c632010-09-27 21:17:381// -*- C++ -*-
2//===--------------------------- atomic -----------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_ATOMIC
12#define _LIBCPP_ATOMIC
13
14/*
15 atomic synopsis
16
17namespace std
18{
19
20// order and consistency
21
22typedef enum memory_order
23{
Howard Hinnantd1176e22010-09-28 17:13:3824 memory_order_relaxed,
25 memory_order_consume, // load-consume
26 memory_order_acquire, // load-acquire
27 memory_order_release, // store-release
28 memory_order_acq_rel, // store-release load-acquire
29 memory_order_seq_cst // store-release load-acquire
Howard Hinnant8f73c632010-09-27 21:17:3830} memory_order;
31
Howard Hinnant300c67a2012-04-11 20:14:2132template <class T> T kill_dependency(T y) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:3833
34// lock-free property
35
36#define ATOMIC_CHAR_LOCK_FREE unspecified
37#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
38#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
39#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
40#define ATOMIC_SHORT_LOCK_FREE unspecified
41#define ATOMIC_INT_LOCK_FREE unspecified
42#define ATOMIC_LONG_LOCK_FREE unspecified
43#define ATOMIC_LLONG_LOCK_FREE unspecified
Howard Hinnant8f73c632010-09-27 21:17:3844
Howard Hinnant8f73c632010-09-27 21:17:3845// flag type and operations
46
47typedef struct atomic_flag
48{
Howard Hinnant300c67a2012-04-11 20:14:2149 bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
50 bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
51 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
52 void clear(memory_order m = memory_order_seq_cst) noexcept;
53 atomic_flag() noexcept = default;
Howard Hinnant8f73c632010-09-27 21:17:3854 atomic_flag(const atomic_flag&) = delete;
55 atomic_flag& operator=(const atomic_flag&) = delete;
56 atomic_flag& operator=(const atomic_flag&) volatile = delete;
57} atomic_flag;
58
Howard Hinnant4777bf22010-12-06 23:10:0859bool
Howard Hinnant300c67a2012-04-11 20:14:2160 atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0861
62bool
Howard Hinnant300c67a2012-04-11 20:14:2163 atomic_flag_test_and_set(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0864
65bool
66 atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
Howard Hinnant300c67a2012-04-11 20:14:2167 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0868
69bool
Howard Hinnant300c67a2012-04-11 20:14:2170 atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0871
72void
Howard Hinnant300c67a2012-04-11 20:14:2173 atomic_flag_clear(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0874
75void
Howard Hinnant300c67a2012-04-11 20:14:2176 atomic_flag_clear(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0877
78void
Howard Hinnant300c67a2012-04-11 20:14:2179 atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0880
81void
Howard Hinnant300c67a2012-04-11 20:14:2182 atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:3883
84#define ATOMIC_FLAG_INIT see below
Howard Hinnante7385012010-10-19 16:51:1885#define ATOMIC_VAR_INIT(value) see below
Howard Hinnant8f73c632010-09-27 21:17:3886
Howard Hinnant8f73c632010-09-27 21:17:3887template <class T>
88struct atomic
89{
Howard Hinnant300c67a2012-04-11 20:14:2190 bool is_lock_free() const volatile noexcept;
91 bool is_lock_free() const noexcept;
92 void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
93 void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
94 T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
95 T load(memory_order m = memory_order_seq_cst) const noexcept;
96 operator T() const volatile noexcept;
97 operator T() const noexcept;
98 T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
99 T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08100 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21101 memory_order s, memory_order f) volatile noexcept;
102 bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08103 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21104 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08105 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21106 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08107 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21108 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08109 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21110 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08111 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21112 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08113 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21114 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38115
Howard Hinnant300c67a2012-04-11 20:14:21116 atomic() noexcept = default;
117 constexpr atomic(T desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38118 atomic(const atomic&) = delete;
119 atomic& operator=(const atomic&) = delete;
120 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21121 T operator=(T) volatile noexcept;
122 T operator=(T) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38123};
124
125template <>
Howard Hinnant4777bf22010-12-06 23:10:08126struct atomic<integral>
Howard Hinnant8f73c632010-09-27 21:17:38127{
Howard Hinnant300c67a2012-04-11 20:14:21128 bool is_lock_free() const volatile noexcept;
129 bool is_lock_free() const noexcept;
130 void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
131 void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
132 integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
133 integral load(memory_order m = memory_order_seq_cst) const noexcept;
134 operator integral() const volatile noexcept;
135 operator integral() const noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08136 integral exchange(integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21137 memory_order m = memory_order_seq_cst) volatile noexcept;
138 integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08139 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21140 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08141 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21142 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08143 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21144 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08145 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21146 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08147 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21148 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08149 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21150 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08151 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21152 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08153 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21154 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38155
Howard Hinnant4777bf22010-12-06 23:10:08156 integral
Howard Hinnant300c67a2012-04-11 20:14:21157 fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
158 integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08159 integral
Howard Hinnant300c67a2012-04-11 20:14:21160 fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
161 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08162 integral
Howard Hinnant300c67a2012-04-11 20:14:21163 fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
164 integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08165 integral
Howard Hinnant300c67a2012-04-11 20:14:21166 fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
167 integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08168 integral
Howard Hinnant300c67a2012-04-11 20:14:21169 fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
170 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38171
Howard Hinnant300c67a2012-04-11 20:14:21172 atomic() noexcept = default;
173 constexpr atomic(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38174 atomic(const atomic&) = delete;
175 atomic& operator=(const atomic&) = delete;
176 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21177 integral operator=(integral desr) volatile noexcept;
178 integral operator=(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38179
Howard Hinnant300c67a2012-04-11 20:14:21180 integral operator++(int) volatile noexcept;
181 integral operator++(int) noexcept;
182 integral operator--(int) volatile noexcept;
183 integral operator--(int) noexcept;
184 integral operator++() volatile noexcept;
185 integral operator++() noexcept;
186 integral operator--() volatile noexcept;
187 integral operator--() noexcept;
188 integral operator+=(integral op) volatile noexcept;
189 integral operator+=(integral op) noexcept;
190 integral operator-=(integral op) volatile noexcept;
191 integral operator-=(integral op) noexcept;
192 integral operator&=(integral op) volatile noexcept;
193 integral operator&=(integral op) noexcept;
194 integral operator|=(integral op) volatile noexcept;
195 integral operator|=(integral op) noexcept;
196 integral operator^=(integral op) volatile noexcept;
197 integral operator^=(integral op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38198};
199
200template <class T>
201struct atomic<T*>
Howard Hinnant8f73c632010-09-27 21:17:38202{
Howard Hinnant300c67a2012-04-11 20:14:21203 bool is_lock_free() const volatile noexcept;
204 bool is_lock_free() const noexcept;
205 void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
206 void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
207 T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
208 T* load(memory_order m = memory_order_seq_cst) const noexcept;
209 operator T*() const volatile noexcept;
210 operator T*() const noexcept;
211 T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
212 T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08213 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21214 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08215 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21216 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08217 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21218 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08219 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21220 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08221 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21222 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08223 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21224 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08225 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21226 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08227 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21228 memory_order m = memory_order_seq_cst) noexcept;
229 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
230 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
231 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
232 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08233
Howard Hinnant300c67a2012-04-11 20:14:21234 atomic() noexcept = default;
235 constexpr atomic(T* desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38236 atomic(const atomic&) = delete;
237 atomic& operator=(const atomic&) = delete;
238 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant4777bf22010-12-06 23:10:08239
Howard Hinnant300c67a2012-04-11 20:14:21240 T* operator=(T*) volatile noexcept;
241 T* operator=(T*) noexcept;
242 T* operator++(int) volatile noexcept;
243 T* operator++(int) noexcept;
244 T* operator--(int) volatile noexcept;
245 T* operator--(int) noexcept;
246 T* operator++() volatile noexcept;
247 T* operator++() noexcept;
248 T* operator--() volatile noexcept;
249 T* operator--() noexcept;
250 T* operator+=(ptrdiff_t op) volatile noexcept;
251 T* operator+=(ptrdiff_t op) noexcept;
252 T* operator-=(ptrdiff_t op) volatile noexcept;
253 T* operator-=(ptrdiff_t op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38254};
255
Howard Hinnant4777bf22010-12-06 23:10:08256
257template <class T>
258 bool
Howard Hinnant300c67a2012-04-11 20:14:21259 atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08260
261template <class T>
262 bool
Howard Hinnant300c67a2012-04-11 20:14:21263 atomic_is_lock_free(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08264
265template <class T>
266 void
Howard Hinnant300c67a2012-04-11 20:14:21267 atomic_init(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08268
269template <class T>
270 void
Howard Hinnant300c67a2012-04-11 20:14:21271 atomic_init(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08272
273template <class T>
274 void
Howard Hinnant300c67a2012-04-11 20:14:21275 atomic_store(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08276
277template <class T>
278 void
Howard Hinnant300c67a2012-04-11 20:14:21279 atomic_store(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08280
281template <class T>
282 void
Howard Hinnant300c67a2012-04-11 20:14:21283 atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08284
285template <class T>
286 void
Howard Hinnant300c67a2012-04-11 20:14:21287 atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08288
289template <class T>
290 T
Howard Hinnant300c67a2012-04-11 20:14:21291 atomic_load(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08292
293template <class T>
294 T
Howard Hinnant300c67a2012-04-11 20:14:21295 atomic_load(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08296
297template <class T>
298 T
Howard Hinnant300c67a2012-04-11 20:14:21299 atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08300
301template <class T>
302 T
Howard Hinnant300c67a2012-04-11 20:14:21303 atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08304
305template <class T>
306 T
Howard Hinnant300c67a2012-04-11 20:14:21307 atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08308
309template <class T>
310 T
Howard Hinnant300c67a2012-04-11 20:14:21311 atomic_exchange(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08312
313template <class T>
314 T
Howard Hinnant300c67a2012-04-11 20:14:21315 atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08316
317template <class T>
318 T
Howard Hinnant300c67a2012-04-11 20:14:21319 atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08320
321template <class T>
322 bool
Howard Hinnant300c67a2012-04-11 20:14:21323 atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08324
325template <class T>
326 bool
Howard Hinnant300c67a2012-04-11 20:14:21327 atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08328
329template <class T>
330 bool
Howard Hinnant300c67a2012-04-11 20:14:21331 atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08332
333template <class T>
334 bool
Howard Hinnant300c67a2012-04-11 20:14:21335 atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08336
337template <class T>
338 bool
339 atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
340 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21341 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08342
343template <class T>
344 bool
345 atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21346 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08347
348template <class T>
349 bool
350 atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
351 T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21352 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08353
354template <class T>
355 bool
356 atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
357 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21358 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08359
360template <class Integral>
361 Integral
Howard Hinnant300c67a2012-04-11 20:14:21362 atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08363
364template <class Integral>
365 Integral
Howard Hinnant300c67a2012-04-11 20:14:21366 atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08367
368template <class Integral>
369 Integral
370 atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21371 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08372template <class Integral>
373 Integral
374 atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21375 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08376template <class Integral>
377 Integral
Howard Hinnant300c67a2012-04-11 20:14:21378 atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08379
380template <class Integral>
381 Integral
Howard Hinnant300c67a2012-04-11 20:14:21382 atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08383
384template <class Integral>
385 Integral
386 atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21387 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08388template <class Integral>
389 Integral
390 atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21391 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08392template <class Integral>
393 Integral
Howard Hinnant300c67a2012-04-11 20:14:21394 atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08395
396template <class Integral>
397 Integral
Howard Hinnant300c67a2012-04-11 20:14:21398 atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08399
400template <class Integral>
401 Integral
402 atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21403 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08404template <class Integral>
405 Integral
406 atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21407 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08408template <class Integral>
409 Integral
Howard Hinnant300c67a2012-04-11 20:14:21410 atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08411
412template <class Integral>
413 Integral
Howard Hinnant300c67a2012-04-11 20:14:21414 atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08415
416template <class Integral>
417 Integral
418 atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21419 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08420template <class Integral>
421 Integral
422 atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21423 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08424template <class Integral>
425 Integral
Howard Hinnant300c67a2012-04-11 20:14:21426 atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08427
428template <class Integral>
429 Integral
Howard Hinnant300c67a2012-04-11 20:14:21430 atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08431
432template <class Integral>
433 Integral
434 atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21435 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08436template <class Integral>
437 Integral
438 atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21439 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08440
441template <class T>
442 T*
Howard Hinnant300c67a2012-04-11 20:14:21443 atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08444
445template <class T>
446 T*
Howard Hinnant300c67a2012-04-11 20:14:21447 atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08448
449template <class T>
450 T*
451 atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21452 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08453template <class T>
454 T*
Howard Hinnant300c67a2012-04-11 20:14:21455 atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08456
457template <class T>
458 T*
Howard Hinnant300c67a2012-04-11 20:14:21459 atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08460
461template <class T>
462 T*
Howard Hinnant300c67a2012-04-11 20:14:21463 atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08464
465template <class T>
466 T*
467 atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21468 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08469template <class T>
470 T*
Howard Hinnant300c67a2012-04-11 20:14:21471 atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08472
473// Atomics for standard typedef types
474
Howard Hinnant6ae47052013-01-04 18:58:50475typedef atomic<bool> atomic_bool;
Howard Hinnant4777bf22010-12-06 23:10:08476typedef atomic<char> atomic_char;
477typedef atomic<signed char> atomic_schar;
478typedef atomic<unsigned char> atomic_uchar;
479typedef atomic<short> atomic_short;
480typedef atomic<unsigned short> atomic_ushort;
481typedef atomic<int> atomic_int;
482typedef atomic<unsigned int> atomic_uint;
483typedef atomic<long> atomic_long;
484typedef atomic<unsigned long> atomic_ulong;
485typedef atomic<long long> atomic_llong;
486typedef atomic<unsigned long long> atomic_ullong;
487typedef atomic<char16_t> atomic_char16_t;
488typedef atomic<char32_t> atomic_char32_t;
489typedef atomic<wchar_t> atomic_wchar_t;
490
491typedef atomic<int_least8_t> atomic_int_least8_t;
492typedef atomic<uint_least8_t> atomic_uint_least8_t;
493typedef atomic<int_least16_t> atomic_int_least16_t;
494typedef atomic<uint_least16_t> atomic_uint_least16_t;
495typedef atomic<int_least32_t> atomic_int_least32_t;
496typedef atomic<uint_least32_t> atomic_uint_least32_t;
497typedef atomic<int_least64_t> atomic_int_least64_t;
498typedef atomic<uint_least64_t> atomic_uint_least64_t;
499
500typedef atomic<int_fast8_t> atomic_int_fast8_t;
501typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
502typedef atomic<int_fast16_t> atomic_int_fast16_t;
503typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
504typedef atomic<int_fast32_t> atomic_int_fast32_t;
505typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
506typedef atomic<int_fast64_t> atomic_int_fast64_t;
507typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
508
509typedef atomic<intptr_t> atomic_intptr_t;
510typedef atomic<uintptr_t> atomic_uintptr_t;
511typedef atomic<size_t> atomic_size_t;
512typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
513typedef atomic<intmax_t> atomic_intmax_t;
514typedef atomic<uintmax_t> atomic_uintmax_t;
515
Howard Hinnant8f73c632010-09-27 21:17:38516// fences
517
Howard Hinnant300c67a2012-04-11 20:14:21518void atomic_thread_fence(memory_order m) noexcept;
519void atomic_signal_fence(memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38520
521} // std
522
523*/
524
525#include <__config>
Howard Hinnant4777bf22010-12-06 23:10:08526#include <cstddef>
527#include <cstdint>
528#include <type_traits>
Howard Hinnant8f73c632010-09-27 21:17:38529
Howard Hinnant08e17472011-10-17 20:05:10530#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant8f73c632010-09-27 21:17:38531#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10532#endif
Howard Hinnant8f73c632010-09-27 21:17:38533
534_LIBCPP_BEGIN_NAMESPACE_STD
535
Howard Hinnant154002b2011-03-31 16:39:39536#if !__has_feature(cxx_atomic)
537#error <atomic> is not implemented
538#else
539
Howard Hinnantd1176e22010-09-28 17:13:38540typedef enum memory_order
541{
542 memory_order_relaxed, memory_order_consume, memory_order_acquire,
543 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
544} memory_order;
545
546template <class _Tp>
547inline _LIBCPP_INLINE_VISIBILITY
548_Tp
Howard Hinnant300c67a2012-04-11 20:14:21549kill_dependency(_Tp __y) _NOEXCEPT
Howard Hinnantd1176e22010-09-28 17:13:38550{
551 return __y;
552}
Howard Hinnant8f73c632010-09-27 21:17:38553
Howard Hinnant91e2f262010-12-07 20:46:14554// general atomic<T>
555
556template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
557struct __atomic_base // false
558{
Howard Hinnant7eb9f1e2012-09-16 20:33:09559 mutable _Atomic(_Tp) __a_;
Howard Hinnant91e2f262010-12-07 20:46:14560
561 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21562 bool is_lock_free() const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46563 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14564 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21565 bool is_lock_free() const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46566 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14567 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21568 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46569 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14570 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21571 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46572 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14573 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21574 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46575 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14576 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21577 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46578 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14579 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21580 operator _Tp() const volatile _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14581 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21582 operator _Tp() const _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14583 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21584 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46585 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21587 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46588 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14589 _LIBCPP_INLINE_VISIBILITY
590 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21591 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46592 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14593 _LIBCPP_INLINE_VISIBILITY
594 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21595 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46596 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14597 _LIBCPP_INLINE_VISIBILITY
598 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21599 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46600 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14601 _LIBCPP_INLINE_VISIBILITY
602 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21603 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46604 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14605 _LIBCPP_INLINE_VISIBILITY
606 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21607 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46608 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14609 _LIBCPP_INLINE_VISIBILITY
610 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21611 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46612 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14613 _LIBCPP_INLINE_VISIBILITY
614 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21615 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46616 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14617 _LIBCPP_INLINE_VISIBILITY
618 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21619 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46620 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14621
622 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21623 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14624 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21625 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
Howard Hinnant770d1c42010-12-08 17:20:28626#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14627 __atomic_base(const __atomic_base&) = delete;
628 __atomic_base& operator=(const __atomic_base&) = delete;
629 __atomic_base& operator=(const __atomic_base&) volatile = delete;
Howard Hinnant770d1c42010-12-08 17:20:28630#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
631private:
632 __atomic_base(const __atomic_base&);
633 __atomic_base& operator=(const __atomic_base&);
634 __atomic_base& operator=(const __atomic_base&) volatile;
635#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14636};
637
638// atomic<Integral>
639
640template <class _Tp>
641struct __atomic_base<_Tp, true>
642 : public __atomic_base<_Tp, false>
643{
644 typedef __atomic_base<_Tp, false> __base;
645 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21646 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14647 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21648 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14649
650 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21651 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46652 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14653 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21654 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46655 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14656 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21657 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46658 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21660 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46661 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14662 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21663 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46664 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14665 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21666 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46667 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21669 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46670 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14671 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21672 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46673 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14674 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21675 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46676 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21678 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46679 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14680
681 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21682 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14683 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21684 _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14685 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21686 _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14687 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21688 _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14689 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21690 _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14691 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21692 _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14693 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21694 _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14695 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21696 _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14697 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21698 _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14699 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21700 _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14701 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21702 _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14703 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21704 _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14705 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21706 _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14707 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21708 _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14709 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21710 _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14711 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21712 _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14713 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21714 _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21716 _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14717};
718
719// atomic<T>
720
721template <class _Tp>
722struct atomic
723 : public __atomic_base<_Tp>
724{
725 typedef __atomic_base<_Tp> __base;
726 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21727 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14728 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21729 _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnantd2f6afb2010-12-07 23:24:41730
731 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21732 _Tp operator=(_Tp __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41733 {__base::store(__d); return __d;}
734 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21735 _Tp operator=(_Tp __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41736 {__base::store(__d); return __d;}
Howard Hinnant91e2f262010-12-07 20:46:14737};
738
739// atomic<T*>
740
741template <class _Tp>
742struct atomic<_Tp*>
743 : public __atomic_base<_Tp*>
744{
Howard Hinnantd2f6afb2010-12-07 23:24:41745 typedef __atomic_base<_Tp*> __base;
Howard Hinnant91e2f262010-12-07 20:46:14746 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21747 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14748 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21749 _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14750
751 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21752 _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41753 {__base::store(__d); return __d;}
754 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21755 _Tp* operator=(_Tp* __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41756 {__base::store(__d); return __d;}
757
758 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant91e2f262010-12-07 20:46:14759 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21760 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46761 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14762 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21763 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46764 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14765 _LIBCPP_INLINE_VISIBILITY
766 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21767 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46768 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14769 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21770 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46771 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14772
773 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21774 _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14775 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21776 _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14777 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21778 _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14779 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21780 _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14781 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21782 _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14783 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21784 _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14785 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21786 _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14787 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21788 _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14789 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21790 _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14791 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21792 _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14793 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21794 _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14795 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21796 _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14797};
Howard Hinnant4777bf22010-12-06 23:10:08798
799// atomic_is_lock_free
800
801template <class _Tp>
802inline _LIBCPP_INLINE_VISIBILITY
803bool
Howard Hinnant300c67a2012-04-11 20:14:21804atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08805{
Howard Hinnant91e2f262010-12-07 20:46:14806 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08807}
808
809template <class _Tp>
810inline _LIBCPP_INLINE_VISIBILITY
811bool
Howard Hinnant300c67a2012-04-11 20:14:21812atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08813{
Howard Hinnant91e2f262010-12-07 20:46:14814 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08815}
816
817// atomic_init
818
819template <class _Tp>
820inline _LIBCPP_INLINE_VISIBILITY
821void
Howard Hinnant300c67a2012-04-11 20:14:21822atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08823{
Richard Smith6186c7f2012-04-11 18:55:46824 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08825}
826
827template <class _Tp>
828inline _LIBCPP_INLINE_VISIBILITY
829void
Howard Hinnant300c67a2012-04-11 20:14:21830atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08831{
Richard Smith6186c7f2012-04-11 18:55:46832 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08833}
834
835// atomic_store
836
837template <class _Tp>
838inline _LIBCPP_INLINE_VISIBILITY
839void
Howard Hinnant300c67a2012-04-11 20:14:21840atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08841{
Howard Hinnant91e2f262010-12-07 20:46:14842 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08843}
844
845template <class _Tp>
846inline _LIBCPP_INLINE_VISIBILITY
847void
Howard Hinnant300c67a2012-04-11 20:14:21848atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08849{
Howard Hinnant91e2f262010-12-07 20:46:14850 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08851}
852
853// atomic_store_explicit
854
855template <class _Tp>
856inline _LIBCPP_INLINE_VISIBILITY
857void
Howard Hinnant300c67a2012-04-11 20:14:21858atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08859{
Howard Hinnant91e2f262010-12-07 20:46:14860 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08861}
862
863template <class _Tp>
864inline _LIBCPP_INLINE_VISIBILITY
865void
Howard Hinnant300c67a2012-04-11 20:14:21866atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08867{
Howard Hinnant91e2f262010-12-07 20:46:14868 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08869}
870
871// atomic_load
872
873template <class _Tp>
874inline _LIBCPP_INLINE_VISIBILITY
875_Tp
Howard Hinnant300c67a2012-04-11 20:14:21876atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08877{
Howard Hinnant91e2f262010-12-07 20:46:14878 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08879}
880
881template <class _Tp>
882inline _LIBCPP_INLINE_VISIBILITY
883_Tp
Howard Hinnant300c67a2012-04-11 20:14:21884atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08885{
Howard Hinnant91e2f262010-12-07 20:46:14886 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08887}
888
889// atomic_load_explicit
890
891template <class _Tp>
892inline _LIBCPP_INLINE_VISIBILITY
893_Tp
Howard Hinnant300c67a2012-04-11 20:14:21894atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08895{
Howard Hinnant91e2f262010-12-07 20:46:14896 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08897}
898
899template <class _Tp>
900inline _LIBCPP_INLINE_VISIBILITY
901_Tp
Howard Hinnant300c67a2012-04-11 20:14:21902atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08903{
Howard Hinnant91e2f262010-12-07 20:46:14904 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08905}
906
907// atomic_exchange
908
909template <class _Tp>
910inline _LIBCPP_INLINE_VISIBILITY
911_Tp
Howard Hinnant300c67a2012-04-11 20:14:21912atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08913{
Howard Hinnant91e2f262010-12-07 20:46:14914 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08915}
916
917template <class _Tp>
918inline _LIBCPP_INLINE_VISIBILITY
919_Tp
Howard Hinnant300c67a2012-04-11 20:14:21920atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08921{
Howard Hinnant91e2f262010-12-07 20:46:14922 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08923}
924
925// atomic_exchange_explicit
926
927template <class _Tp>
928inline _LIBCPP_INLINE_VISIBILITY
929_Tp
Howard Hinnant300c67a2012-04-11 20:14:21930atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08931{
Howard Hinnant91e2f262010-12-07 20:46:14932 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08933}
934
935template <class _Tp>
936inline _LIBCPP_INLINE_VISIBILITY
937_Tp
Howard Hinnant300c67a2012-04-11 20:14:21938atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08939{
Howard Hinnant91e2f262010-12-07 20:46:14940 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08941}
942
943// atomic_compare_exchange_weak
944
945template <class _Tp>
946inline _LIBCPP_INLINE_VISIBILITY
947bool
Howard Hinnant300c67a2012-04-11 20:14:21948atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08949{
Howard Hinnant91e2f262010-12-07 20:46:14950 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08951}
952
953template <class _Tp>
954inline _LIBCPP_INLINE_VISIBILITY
955bool
Howard Hinnant300c67a2012-04-11 20:14:21956atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08957{
Howard Hinnant91e2f262010-12-07 20:46:14958 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08959}
960
961// atomic_compare_exchange_strong
962
963template <class _Tp>
964inline _LIBCPP_INLINE_VISIBILITY
965bool
Howard Hinnant300c67a2012-04-11 20:14:21966atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08967{
Howard Hinnant91e2f262010-12-07 20:46:14968 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08969}
970
971template <class _Tp>
972inline _LIBCPP_INLINE_VISIBILITY
973bool
Howard Hinnant300c67a2012-04-11 20:14:21974atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08975{
Howard Hinnant91e2f262010-12-07 20:46:14976 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08977}
978
979// atomic_compare_exchange_weak_explicit
980
981template <class _Tp>
982inline _LIBCPP_INLINE_VISIBILITY
983bool
984atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
985 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21986 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08987{
Howard Hinnant91e2f262010-12-07 20:46:14988 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08989}
990
991template <class _Tp>
992inline _LIBCPP_INLINE_VISIBILITY
993bool
994atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21995 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08996{
Howard Hinnant91e2f262010-12-07 20:46:14997 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08998}
999
1000// atomic_compare_exchange_strong_explicit
1001
1002template <class _Tp>
1003inline _LIBCPP_INLINE_VISIBILITY
1004bool
1005atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
1006 _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211007 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081008{
Howard Hinnant91e2f262010-12-07 20:46:141009 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081010}
1011
1012template <class _Tp>
1013inline _LIBCPP_INLINE_VISIBILITY
1014bool
1015atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
1016 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211017 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081018{
Howard Hinnant91e2f262010-12-07 20:46:141019 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081020}
1021
Howard Hinnant91e2f262010-12-07 20:46:141022// atomic_fetch_add
Howard Hinnant4777bf22010-12-06 23:10:081023
1024template <class _Tp>
Howard Hinnant91e2f262010-12-07 20:46:141025inline _LIBCPP_INLINE_VISIBILITY
1026typename enable_if
1027<
1028 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1029 _Tp
1030>::type
Howard Hinnant300c67a2012-04-11 20:14:211031atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081032{
Howard Hinnant91e2f262010-12-07 20:46:141033 return __o->fetch_add(__op);
1034}
Howard Hinnant4777bf22010-12-06 23:10:081035
Howard Hinnant91e2f262010-12-07 20:46:141036template <class _Tp>
1037inline _LIBCPP_INLINE_VISIBILITY
1038typename enable_if
1039<
1040 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1041 _Tp
1042>::type
Howard Hinnant300c67a2012-04-11 20:14:211043atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141044{
1045 return __o->fetch_add(__op);
1046}
Howard Hinnant4777bf22010-12-06 23:10:081047
Howard Hinnant91e2f262010-12-07 20:46:141048template <class _Tp>
1049inline _LIBCPP_INLINE_VISIBILITY
1050_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211051atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141052{
1053 return __o->fetch_add(__op);
1054}
1055
1056template <class _Tp>
1057inline _LIBCPP_INLINE_VISIBILITY
1058_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211059atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141060{
1061 return __o->fetch_add(__op);
1062}
1063
1064// atomic_fetch_add_explicit
1065
1066template <class _Tp>
1067inline _LIBCPP_INLINE_VISIBILITY
1068typename enable_if
1069<
1070 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1071 _Tp
1072>::type
Howard Hinnant300c67a2012-04-11 20:14:211073atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141074{
1075 return __o->fetch_add(__op, __m);
1076}
1077
1078template <class _Tp>
1079inline _LIBCPP_INLINE_VISIBILITY
1080typename enable_if
1081<
1082 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1083 _Tp
1084>::type
Howard Hinnant300c67a2012-04-11 20:14:211085atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141086{
1087 return __o->fetch_add(__op, __m);
1088}
1089
1090template <class _Tp>
1091inline _LIBCPP_INLINE_VISIBILITY
1092_Tp*
1093atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211094 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141095{
1096 return __o->fetch_add(__op, __m);
1097}
1098
1099template <class _Tp>
1100inline _LIBCPP_INLINE_VISIBILITY
1101_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211102atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141103{
1104 return __o->fetch_add(__op, __m);
1105}
1106
1107// atomic_fetch_sub
1108
1109template <class _Tp>
1110inline _LIBCPP_INLINE_VISIBILITY
1111typename enable_if
1112<
1113 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1114 _Tp
1115>::type
Howard Hinnant300c67a2012-04-11 20:14:211116atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141117{
1118 return __o->fetch_sub(__op);
1119}
1120
1121template <class _Tp>
1122inline _LIBCPP_INLINE_VISIBILITY
1123typename enable_if
1124<
1125 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1126 _Tp
1127>::type
Howard Hinnant300c67a2012-04-11 20:14:211128atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141129{
1130 return __o->fetch_sub(__op);
1131}
1132
1133template <class _Tp>
1134inline _LIBCPP_INLINE_VISIBILITY
1135_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211136atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141137{
1138 return __o->fetch_sub(__op);
1139}
1140
1141template <class _Tp>
1142inline _LIBCPP_INLINE_VISIBILITY
1143_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211144atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141145{
1146 return __o->fetch_sub(__op);
1147}
1148
1149// atomic_fetch_sub_explicit
1150
1151template <class _Tp>
1152inline _LIBCPP_INLINE_VISIBILITY
1153typename enable_if
1154<
1155 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1156 _Tp
1157>::type
Howard Hinnant300c67a2012-04-11 20:14:211158atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141159{
1160 return __o->fetch_sub(__op, __m);
1161}
1162
1163template <class _Tp>
1164inline _LIBCPP_INLINE_VISIBILITY
1165typename enable_if
1166<
1167 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1168 _Tp
1169>::type
Howard Hinnant300c67a2012-04-11 20:14:211170atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141171{
1172 return __o->fetch_sub(__op, __m);
1173}
1174
1175template <class _Tp>
1176inline _LIBCPP_INLINE_VISIBILITY
1177_Tp*
1178atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211179 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141180{
1181 return __o->fetch_sub(__op, __m);
1182}
1183
1184template <class _Tp>
1185inline _LIBCPP_INLINE_VISIBILITY
1186_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211187atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141188{
1189 return __o->fetch_sub(__op, __m);
1190}
1191
1192// atomic_fetch_and
1193
1194template <class _Tp>
1195inline _LIBCPP_INLINE_VISIBILITY
1196typename enable_if
1197<
1198 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1199 _Tp
1200>::type
Howard Hinnant300c67a2012-04-11 20:14:211201atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141202{
1203 return __o->fetch_and(__op);
1204}
1205
1206template <class _Tp>
1207inline _LIBCPP_INLINE_VISIBILITY
1208typename enable_if
1209<
1210 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1211 _Tp
1212>::type
Howard Hinnant300c67a2012-04-11 20:14:211213atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141214{
1215 return __o->fetch_and(__op);
1216}
1217
1218// atomic_fetch_and_explicit
1219
1220template <class _Tp>
1221inline _LIBCPP_INLINE_VISIBILITY
1222typename enable_if
1223<
1224 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1225 _Tp
1226>::type
Howard Hinnant300c67a2012-04-11 20:14:211227atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141228{
1229 return __o->fetch_and(__op, __m);
1230}
1231
1232template <class _Tp>
1233inline _LIBCPP_INLINE_VISIBILITY
1234typename enable_if
1235<
1236 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1237 _Tp
1238>::type
Howard Hinnant300c67a2012-04-11 20:14:211239atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141240{
1241 return __o->fetch_and(__op, __m);
1242}
1243
1244// atomic_fetch_or
1245
1246template <class _Tp>
1247inline _LIBCPP_INLINE_VISIBILITY
1248typename enable_if
1249<
1250 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1251 _Tp
1252>::type
Howard Hinnant300c67a2012-04-11 20:14:211253atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141254{
1255 return __o->fetch_or(__op);
1256}
1257
1258template <class _Tp>
1259inline _LIBCPP_INLINE_VISIBILITY
1260typename enable_if
1261<
1262 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1263 _Tp
1264>::type
Howard Hinnant300c67a2012-04-11 20:14:211265atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141266{
1267 return __o->fetch_or(__op);
1268}
1269
1270// atomic_fetch_or_explicit
1271
1272template <class _Tp>
1273inline _LIBCPP_INLINE_VISIBILITY
1274typename enable_if
1275<
1276 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1277 _Tp
1278>::type
Howard Hinnant300c67a2012-04-11 20:14:211279atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141280{
1281 return __o->fetch_or(__op, __m);
1282}
1283
1284template <class _Tp>
1285inline _LIBCPP_INLINE_VISIBILITY
1286typename enable_if
1287<
1288 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1289 _Tp
1290>::type
Howard Hinnant300c67a2012-04-11 20:14:211291atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141292{
1293 return __o->fetch_or(__op, __m);
1294}
1295
1296// atomic_fetch_xor
1297
1298template <class _Tp>
1299inline _LIBCPP_INLINE_VISIBILITY
1300typename enable_if
1301<
1302 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1303 _Tp
1304>::type
Howard Hinnant300c67a2012-04-11 20:14:211305atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141306{
1307 return __o->fetch_xor(__op);
1308}
1309
1310template <class _Tp>
1311inline _LIBCPP_INLINE_VISIBILITY
1312typename enable_if
1313<
1314 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1315 _Tp
1316>::type
Howard Hinnant300c67a2012-04-11 20:14:211317atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141318{
1319 return __o->fetch_xor(__op);
1320}
1321
1322// atomic_fetch_xor_explicit
1323
1324template <class _Tp>
1325inline _LIBCPP_INLINE_VISIBILITY
1326typename enable_if
1327<
1328 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1329 _Tp
1330>::type
Howard Hinnant300c67a2012-04-11 20:14:211331atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141332{
1333 return __o->fetch_xor(__op, __m);
1334}
1335
1336template <class _Tp>
1337inline _LIBCPP_INLINE_VISIBILITY
1338typename enable_if
1339<
1340 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1341 _Tp
1342>::type
Howard Hinnant300c67a2012-04-11 20:14:211343atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141344{
1345 return __o->fetch_xor(__op, __m);
1346}
Howard Hinnant4777bf22010-12-06 23:10:081347
Howard Hinnant770d1c42010-12-08 17:20:281348// flag type and operations
1349
1350typedef struct atomic_flag
1351{
David Chisnall83b2c842011-12-19 11:44:201352 _Atomic(bool) __a_;
Howard Hinnant770d1c42010-12-08 17:20:281353
1354 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211355 bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461356 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281357 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211358 bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461359 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281360 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211361 void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461362 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281363 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211364 void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461365 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281366
1367 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211368 atomic_flag() _NOEXCEPT {} // = default;
Howard Hinnant770d1c42010-12-08 17:20:281369 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211370 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
Howard Hinnant770d1c42010-12-08 17:20:281371
1372#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1373 atomic_flag(const atomic_flag&) = delete;
1374 atomic_flag& operator=(const atomic_flag&) = delete;
1375 atomic_flag& operator=(const atomic_flag&) volatile = delete;
1376#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1377private:
1378 atomic_flag(const atomic_flag&);
1379 atomic_flag& operator=(const atomic_flag&);
1380 atomic_flag& operator=(const atomic_flag&) volatile;
1381#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1382} atomic_flag;
1383
1384inline _LIBCPP_INLINE_VISIBILITY
1385bool
Howard Hinnant300c67a2012-04-11 20:14:211386atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281387{
1388 return __o->test_and_set();
1389}
1390
1391inline _LIBCPP_INLINE_VISIBILITY
1392bool
Howard Hinnant300c67a2012-04-11 20:14:211393atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281394{
1395 return __o->test_and_set();
1396}
1397
1398inline _LIBCPP_INLINE_VISIBILITY
1399bool
Howard Hinnant300c67a2012-04-11 20:14:211400atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281401{
1402 return __o->test_and_set(__m);
1403}
1404
1405inline _LIBCPP_INLINE_VISIBILITY
1406bool
Howard Hinnant300c67a2012-04-11 20:14:211407atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281408{
1409 return __o->test_and_set(__m);
1410}
1411
1412inline _LIBCPP_INLINE_VISIBILITY
1413void
Howard Hinnant300c67a2012-04-11 20:14:211414atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281415{
1416 __o->clear();
1417}
1418
1419inline _LIBCPP_INLINE_VISIBILITY
1420void
Howard Hinnant300c67a2012-04-11 20:14:211421atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281422{
1423 __o->clear();
1424}
1425
1426inline _LIBCPP_INLINE_VISIBILITY
1427void
Howard Hinnant300c67a2012-04-11 20:14:211428atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281429{
1430 __o->clear(__m);
1431}
1432
1433inline _LIBCPP_INLINE_VISIBILITY
1434void
Howard Hinnant300c67a2012-04-11 20:14:211435atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281436{
1437 __o->clear(__m);
1438}
1439
1440// fences
1441
1442inline _LIBCPP_INLINE_VISIBILITY
1443void
Howard Hinnant300c67a2012-04-11 20:14:211444atomic_thread_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281445{
Richard Smith6186c7f2012-04-11 18:55:461446 __c11_atomic_thread_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281447}
1448
1449inline _LIBCPP_INLINE_VISIBILITY
1450void
Howard Hinnant300c67a2012-04-11 20:14:211451atomic_signal_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281452{
Richard Smith6186c7f2012-04-11 18:55:461453 __c11_atomic_signal_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281454}
1455
Howard Hinnantd2f6afb2010-12-07 23:24:411456// Atomics for standard typedef types
1457
Howard Hinnant6ae47052013-01-04 18:58:501458typedef atomic<bool> atomic_bool;
Howard Hinnantd2f6afb2010-12-07 23:24:411459typedef atomic<char> atomic_char;
1460typedef atomic<signed char> atomic_schar;
1461typedef atomic<unsigned char> atomic_uchar;
1462typedef atomic<short> atomic_short;
1463typedef atomic<unsigned short> atomic_ushort;
1464typedef atomic<int> atomic_int;
1465typedef atomic<unsigned int> atomic_uint;
1466typedef atomic<long> atomic_long;
1467typedef atomic<unsigned long> atomic_ulong;
1468typedef atomic<long long> atomic_llong;
1469typedef atomic<unsigned long long> atomic_ullong;
1470typedef atomic<char16_t> atomic_char16_t;
1471typedef atomic<char32_t> atomic_char32_t;
1472typedef atomic<wchar_t> atomic_wchar_t;
1473
1474typedef atomic<int_least8_t> atomic_int_least8_t;
1475typedef atomic<uint_least8_t> atomic_uint_least8_t;
1476typedef atomic<int_least16_t> atomic_int_least16_t;
1477typedef atomic<uint_least16_t> atomic_uint_least16_t;
1478typedef atomic<int_least32_t> atomic_int_least32_t;
1479typedef atomic<uint_least32_t> atomic_uint_least32_t;
1480typedef atomic<int_least64_t> atomic_int_least64_t;
1481typedef atomic<uint_least64_t> atomic_uint_least64_t;
1482
1483typedef atomic<int_fast8_t> atomic_int_fast8_t;
1484typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
1485typedef atomic<int_fast16_t> atomic_int_fast16_t;
1486typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
1487typedef atomic<int_fast32_t> atomic_int_fast32_t;
1488typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
1489typedef atomic<int_fast64_t> atomic_int_fast64_t;
1490typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
1491
1492typedef atomic<intptr_t> atomic_intptr_t;
1493typedef atomic<uintptr_t> atomic_uintptr_t;
1494typedef atomic<size_t> atomic_size_t;
1495typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
1496typedef atomic<intmax_t> atomic_intmax_t;
1497typedef atomic<uintmax_t> atomic_uintmax_t;
1498
Howard Hinnant767ae2b2010-09-29 21:20:031499#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:541500#define ATOMIC_VAR_INIT(__v) {__v}
1501
Howard Hinnant770d1c42010-12-08 17:20:281502// lock-free property
Howard Hinnant611fdaf2010-10-04 18:52:541503
Howard Hinnant770d1c42010-12-08 17:20:281504#define ATOMIC_CHAR_LOCK_FREE 0
1505#define ATOMIC_CHAR16_T_LOCK_FREE 0
1506#define ATOMIC_CHAR32_T_LOCK_FREE 0
1507#define ATOMIC_WCHAR_T_LOCK_FREE 0
1508#define ATOMIC_SHORT_LOCK_FREE 0
1509#define ATOMIC_INT_LOCK_FREE 0
1510#define ATOMIC_LONG_LOCK_FREE 0
1511#define ATOMIC_LLONG_LOCK_FREE 0
1512
Howard Hinnant154002b2011-03-31 16:39:391513#endif // !__has_feature(cxx_atomic)
1514
Howard Hinnant8f73c632010-09-27 21:17:381515_LIBCPP_END_NAMESPACE_STD
1516
1517#endif // _LIBCPP_ATOMIC