blob: f6ab1cbaf49fbbc8c3c3ea278f34249aea2f1cc8 [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
Howard Hinnant7b9d6a82013-01-21 20:39:4136#define ATOMIC_BOOL_LOCK_FREE unspecified
Howard Hinnant8f73c632010-09-27 21:17:3837#define ATOMIC_CHAR_LOCK_FREE unspecified
38#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
39#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
40#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
41#define ATOMIC_SHORT_LOCK_FREE unspecified
42#define ATOMIC_INT_LOCK_FREE unspecified
43#define ATOMIC_LONG_LOCK_FREE unspecified
44#define ATOMIC_LLONG_LOCK_FREE unspecified
Howard Hinnant7b9d6a82013-01-21 20:39:4145#define ATOMIC_POINTER_LOCK_FREE unspecified
Howard Hinnant8f73c632010-09-27 21:17:3846
Howard Hinnant8f73c632010-09-27 21:17:3847// flag type and operations
48
49typedef struct atomic_flag
50{
Howard Hinnant300c67a2012-04-11 20:14:2151 bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
52 bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
53 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
54 void clear(memory_order m = memory_order_seq_cst) noexcept;
55 atomic_flag() noexcept = default;
Howard Hinnant8f73c632010-09-27 21:17:3856 atomic_flag(const atomic_flag&) = delete;
57 atomic_flag& operator=(const atomic_flag&) = delete;
58 atomic_flag& operator=(const atomic_flag&) volatile = delete;
59} atomic_flag;
60
Howard Hinnant4777bf22010-12-06 23:10:0861bool
Howard Hinnant300c67a2012-04-11 20:14:2162 atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0863
64bool
Howard Hinnant300c67a2012-04-11 20:14:2165 atomic_flag_test_and_set(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0866
67bool
68 atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
Howard Hinnant300c67a2012-04-11 20:14:2169 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0870
71bool
Howard Hinnant300c67a2012-04-11 20:14:2172 atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0873
74void
Howard Hinnant300c67a2012-04-11 20:14:2175 atomic_flag_clear(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0876
77void
Howard Hinnant300c67a2012-04-11 20:14:2178 atomic_flag_clear(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0879
80void
Howard Hinnant300c67a2012-04-11 20:14:2181 atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0882
83void
Howard Hinnant300c67a2012-04-11 20:14:2184 atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:3885
86#define ATOMIC_FLAG_INIT see below
Howard Hinnante7385012010-10-19 16:51:1887#define ATOMIC_VAR_INIT(value) see below
Howard Hinnant8f73c632010-09-27 21:17:3888
Howard Hinnant8f73c632010-09-27 21:17:3889template <class T>
90struct atomic
91{
Howard Hinnant300c67a2012-04-11 20:14:2192 bool is_lock_free() const volatile noexcept;
93 bool is_lock_free() const noexcept;
94 void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
95 void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
96 T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
97 T load(memory_order m = memory_order_seq_cst) const noexcept;
98 operator T() const volatile noexcept;
99 operator T() const noexcept;
100 T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
101 T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08102 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21103 memory_order s, memory_order f) volatile noexcept;
104 bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08107 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21108 memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08111 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21112 memory_order m = memory_order_seq_cst) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08115 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21116 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38117
Howard Hinnant300c67a2012-04-11 20:14:21118 atomic() noexcept = default;
119 constexpr atomic(T desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38120 atomic(const atomic&) = delete;
121 atomic& operator=(const atomic&) = delete;
122 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21123 T operator=(T) volatile noexcept;
124 T operator=(T) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38125};
126
127template <>
Howard Hinnant4777bf22010-12-06 23:10:08128struct atomic<integral>
Howard Hinnant8f73c632010-09-27 21:17:38129{
Howard Hinnant300c67a2012-04-11 20:14:21130 bool is_lock_free() const volatile noexcept;
131 bool is_lock_free() const noexcept;
132 void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
133 void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
134 integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
135 integral load(memory_order m = memory_order_seq_cst) const noexcept;
136 operator integral() const volatile noexcept;
137 operator integral() const noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08138 integral exchange(integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21139 memory_order m = memory_order_seq_cst) volatile noexcept;
140 integral exchange(integral desr, memory_order m = memory_order_seq_cst) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08143 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21144 memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08147 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21148 memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08151 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21152 memory_order m = memory_order_seq_cst) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08155 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21156 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38157
Howard Hinnant4777bf22010-12-06 23:10:08158 integral
Howard Hinnant300c67a2012-04-11 20:14:21159 fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
160 integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08161 integral
Howard Hinnant300c67a2012-04-11 20:14:21162 fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
163 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08164 integral
Howard Hinnant300c67a2012-04-11 20:14:21165 fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
166 integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08167 integral
Howard Hinnant300c67a2012-04-11 20:14:21168 fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
169 integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08170 integral
Howard Hinnant300c67a2012-04-11 20:14:21171 fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
172 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38173
Howard Hinnant300c67a2012-04-11 20:14:21174 atomic() noexcept = default;
175 constexpr atomic(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38176 atomic(const atomic&) = delete;
177 atomic& operator=(const atomic&) = delete;
178 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21179 integral operator=(integral desr) volatile noexcept;
180 integral operator=(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38181
Howard Hinnant300c67a2012-04-11 20:14:21182 integral operator++(int) volatile noexcept;
183 integral operator++(int) noexcept;
184 integral operator--(int) volatile noexcept;
185 integral operator--(int) noexcept;
186 integral operator++() volatile noexcept;
187 integral operator++() noexcept;
188 integral operator--() volatile noexcept;
189 integral operator--() 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;
198 integral operator^=(integral op) volatile noexcept;
199 integral operator^=(integral op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38200};
201
202template <class T>
203struct atomic<T*>
Howard Hinnant8f73c632010-09-27 21:17:38204{
Howard Hinnant300c67a2012-04-11 20:14:21205 bool is_lock_free() const volatile noexcept;
206 bool is_lock_free() const noexcept;
207 void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
208 void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
209 T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
210 T* load(memory_order m = memory_order_seq_cst) const noexcept;
211 operator T*() const volatile noexcept;
212 operator T*() const noexcept;
213 T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
214 T* exchange(T* desr, memory_order m = memory_order_seq_cst) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08217 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21218 memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08221 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21222 memory_order s, memory_order f) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08225 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21226 memory_order m = memory_order_seq_cst) 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) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08229 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21230 memory_order m = memory_order_seq_cst) noexcept;
231 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
232 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
233 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
234 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08235
Howard Hinnant300c67a2012-04-11 20:14:21236 atomic() noexcept = default;
237 constexpr atomic(T* desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38238 atomic(const atomic&) = delete;
239 atomic& operator=(const atomic&) = delete;
240 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant4777bf22010-12-06 23:10:08241
Howard Hinnant300c67a2012-04-11 20:14:21242 T* operator=(T*) volatile noexcept;
243 T* operator=(T*) noexcept;
244 T* operator++(int) volatile noexcept;
245 T* operator++(int) noexcept;
246 T* operator--(int) volatile noexcept;
247 T* operator--(int) noexcept;
248 T* operator++() volatile noexcept;
249 T* operator++() noexcept;
250 T* operator--() volatile noexcept;
251 T* operator--() noexcept;
252 T* operator+=(ptrdiff_t op) volatile noexcept;
253 T* operator+=(ptrdiff_t op) noexcept;
254 T* operator-=(ptrdiff_t op) volatile noexcept;
255 T* operator-=(ptrdiff_t op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38256};
257
Howard Hinnant4777bf22010-12-06 23:10:08258
259template <class T>
260 bool
Howard Hinnant300c67a2012-04-11 20:14:21261 atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08262
263template <class T>
264 bool
Howard Hinnant300c67a2012-04-11 20:14:21265 atomic_is_lock_free(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08266
267template <class T>
268 void
Howard Hinnant300c67a2012-04-11 20:14:21269 atomic_init(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08270
271template <class T>
272 void
Howard Hinnant300c67a2012-04-11 20:14:21273 atomic_init(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08274
275template <class T>
276 void
Howard Hinnant300c67a2012-04-11 20:14:21277 atomic_store(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08278
279template <class T>
280 void
Howard Hinnant300c67a2012-04-11 20:14:21281 atomic_store(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08282
283template <class T>
284 void
Howard Hinnant300c67a2012-04-11 20:14:21285 atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08286
287template <class T>
288 void
Howard Hinnant300c67a2012-04-11 20:14:21289 atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08290
291template <class T>
292 T
Howard Hinnant300c67a2012-04-11 20:14:21293 atomic_load(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08294
295template <class T>
296 T
Howard Hinnant300c67a2012-04-11 20:14:21297 atomic_load(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08298
299template <class T>
300 T
Howard Hinnant300c67a2012-04-11 20:14:21301 atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08302
303template <class T>
304 T
Howard Hinnant300c67a2012-04-11 20:14:21305 atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08306
307template <class T>
308 T
Howard Hinnant300c67a2012-04-11 20:14:21309 atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08310
311template <class T>
312 T
Howard Hinnant300c67a2012-04-11 20:14:21313 atomic_exchange(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08314
315template <class T>
316 T
Howard Hinnant300c67a2012-04-11 20:14:21317 atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08318
319template <class T>
320 T
Howard Hinnant300c67a2012-04-11 20:14:21321 atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08322
323template <class T>
324 bool
Howard Hinnant300c67a2012-04-11 20:14:21325 atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08326
327template <class T>
328 bool
Howard Hinnant300c67a2012-04-11 20:14:21329 atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08330
331template <class T>
332 bool
Howard Hinnant300c67a2012-04-11 20:14:21333 atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08334
335template <class T>
336 bool
Howard Hinnant300c67a2012-04-11 20:14:21337 atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08338
339template <class T>
340 bool
341 atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
342 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21343 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08344
345template <class T>
346 bool
347 atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21348 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08349
350template <class T>
351 bool
352 atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
353 T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21354 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08355
356template <class T>
357 bool
358 atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
359 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21360 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08361
362template <class Integral>
363 Integral
Howard Hinnant300c67a2012-04-11 20:14:21364 atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08365
366template <class Integral>
367 Integral
Howard Hinnant300c67a2012-04-11 20:14:21368 atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08369
370template <class Integral>
371 Integral
372 atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21373 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08374template <class Integral>
375 Integral
376 atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21377 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08378template <class Integral>
379 Integral
Howard Hinnant300c67a2012-04-11 20:14:21380 atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08381
382template <class Integral>
383 Integral
Howard Hinnant300c67a2012-04-11 20:14:21384 atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08385
386template <class Integral>
387 Integral
388 atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21389 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08390template <class Integral>
391 Integral
392 atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21393 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08394template <class Integral>
395 Integral
Howard Hinnant300c67a2012-04-11 20:14:21396 atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08397
398template <class Integral>
399 Integral
Howard Hinnant300c67a2012-04-11 20:14:21400 atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08401
402template <class Integral>
403 Integral
404 atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21405 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08406template <class Integral>
407 Integral
408 atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21409 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08410template <class Integral>
411 Integral
Howard Hinnant300c67a2012-04-11 20:14:21412 atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08413
414template <class Integral>
415 Integral
Howard Hinnant300c67a2012-04-11 20:14:21416 atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08417
418template <class Integral>
419 Integral
420 atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21421 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08422template <class Integral>
423 Integral
424 atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21425 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08426template <class Integral>
427 Integral
Howard Hinnant300c67a2012-04-11 20:14:21428 atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08429
430template <class Integral>
431 Integral
Howard Hinnant300c67a2012-04-11 20:14:21432 atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08433
434template <class Integral>
435 Integral
436 atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21437 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08438template <class Integral>
439 Integral
440 atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21441 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08442
443template <class T>
444 T*
Howard Hinnant300c67a2012-04-11 20:14:21445 atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08446
447template <class T>
448 T*
Howard Hinnant300c67a2012-04-11 20:14:21449 atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08450
451template <class T>
452 T*
453 atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21454 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08455template <class T>
456 T*
Howard Hinnant300c67a2012-04-11 20:14:21457 atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08458
459template <class T>
460 T*
Howard Hinnant300c67a2012-04-11 20:14:21461 atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08462
463template <class T>
464 T*
Howard Hinnant300c67a2012-04-11 20:14:21465 atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08466
467template <class T>
468 T*
469 atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21470 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08471template <class T>
472 T*
Howard Hinnant300c67a2012-04-11 20:14:21473 atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08474
475// Atomics for standard typedef types
476
Howard Hinnant6ae47052013-01-04 18:58:50477typedef atomic<bool> atomic_bool;
Howard Hinnant4777bf22010-12-06 23:10:08478typedef atomic<char> atomic_char;
479typedef atomic<signed char> atomic_schar;
480typedef atomic<unsigned char> atomic_uchar;
481typedef atomic<short> atomic_short;
482typedef atomic<unsigned short> atomic_ushort;
483typedef atomic<int> atomic_int;
484typedef atomic<unsigned int> atomic_uint;
485typedef atomic<long> atomic_long;
486typedef atomic<unsigned long> atomic_ulong;
487typedef atomic<long long> atomic_llong;
488typedef atomic<unsigned long long> atomic_ullong;
489typedef atomic<char16_t> atomic_char16_t;
490typedef atomic<char32_t> atomic_char32_t;
491typedef atomic<wchar_t> atomic_wchar_t;
492
493typedef atomic<int_least8_t> atomic_int_least8_t;
494typedef atomic<uint_least8_t> atomic_uint_least8_t;
495typedef atomic<int_least16_t> atomic_int_least16_t;
496typedef atomic<uint_least16_t> atomic_uint_least16_t;
497typedef atomic<int_least32_t> atomic_int_least32_t;
498typedef atomic<uint_least32_t> atomic_uint_least32_t;
499typedef atomic<int_least64_t> atomic_int_least64_t;
500typedef atomic<uint_least64_t> atomic_uint_least64_t;
501
502typedef atomic<int_fast8_t> atomic_int_fast8_t;
503typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
504typedef atomic<int_fast16_t> atomic_int_fast16_t;
505typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
506typedef atomic<int_fast32_t> atomic_int_fast32_t;
507typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
508typedef atomic<int_fast64_t> atomic_int_fast64_t;
509typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
510
511typedef atomic<intptr_t> atomic_intptr_t;
512typedef atomic<uintptr_t> atomic_uintptr_t;
513typedef atomic<size_t> atomic_size_t;
514typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
515typedef atomic<intmax_t> atomic_intmax_t;
516typedef atomic<uintmax_t> atomic_uintmax_t;
517
Howard Hinnant8f73c632010-09-27 21:17:38518// fences
519
Howard Hinnant300c67a2012-04-11 20:14:21520void atomic_thread_fence(memory_order m) noexcept;
521void atomic_signal_fence(memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38522
523} // std
524
525*/
526
527#include <__config>
Howard Hinnant4777bf22010-12-06 23:10:08528#include <cstddef>
529#include <cstdint>
530#include <type_traits>
Howard Hinnant8f73c632010-09-27 21:17:38531
Howard Hinnant08e17472011-10-17 20:05:10532#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant8f73c632010-09-27 21:17:38533#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10534#endif
Howard Hinnant8f73c632010-09-27 21:17:38535
536_LIBCPP_BEGIN_NAMESPACE_STD
537
Howard Hinnant154002b2011-03-31 16:39:39538#if !__has_feature(cxx_atomic)
539#error <atomic> is not implemented
540#else
541
Howard Hinnantd1176e22010-09-28 17:13:38542typedef enum memory_order
543{
544 memory_order_relaxed, memory_order_consume, memory_order_acquire,
545 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
546} memory_order;
547
548template <class _Tp>
549inline _LIBCPP_INLINE_VISIBILITY
550_Tp
Howard Hinnant300c67a2012-04-11 20:14:21551kill_dependency(_Tp __y) _NOEXCEPT
Howard Hinnantd1176e22010-09-28 17:13:38552{
553 return __y;
554}
Howard Hinnant8f73c632010-09-27 21:17:38555
Howard Hinnant91e2f262010-12-07 20:46:14556// general atomic<T>
557
558template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
559struct __atomic_base // false
560{
Howard Hinnant7eb9f1e2012-09-16 20:33:09561 mutable _Atomic(_Tp) __a_;
Howard Hinnant91e2f262010-12-07 20:46:14562
563 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21564 bool is_lock_free() const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46565 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14566 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21567 bool is_lock_free() const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46568 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14569 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21570 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46571 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14572 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21573 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46574 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14575 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21576 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46577 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14578 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21579 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46580 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14581 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21582 operator _Tp() const volatile _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14583 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21584 operator _Tp() const _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14585 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21586 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46587 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14588 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21589 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46590 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14591 _LIBCPP_INLINE_VISIBILITY
592 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21593 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46594 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14595 _LIBCPP_INLINE_VISIBILITY
596 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21597 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46598 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14599 _LIBCPP_INLINE_VISIBILITY
600 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21601 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46602 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14603 _LIBCPP_INLINE_VISIBILITY
604 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21605 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46606 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14607 _LIBCPP_INLINE_VISIBILITY
608 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21609 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46610 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14611 _LIBCPP_INLINE_VISIBILITY
612 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21613 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46614 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14615 _LIBCPP_INLINE_VISIBILITY
616 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21617 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46618 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14619 _LIBCPP_INLINE_VISIBILITY
620 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21621 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46622 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14623
624 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f4da72013-05-02 20:18:43625#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
626 __atomic_base() _NOEXCEPT = default;
627#else
628 __atomic_base() _NOEXCEPT : __a_() {}
629#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
630
Howard Hinnant91e2f262010-12-07 20:46:14631 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21632 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
Howard Hinnant770d1c42010-12-08 17:20:28633#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14634 __atomic_base(const __atomic_base&) = delete;
635 __atomic_base& operator=(const __atomic_base&) = delete;
636 __atomic_base& operator=(const __atomic_base&) volatile = delete;
Howard Hinnant770d1c42010-12-08 17:20:28637#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
638private:
639 __atomic_base(const __atomic_base&);
640 __atomic_base& operator=(const __atomic_base&);
641 __atomic_base& operator=(const __atomic_base&) volatile;
642#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14643};
644
645// atomic<Integral>
646
647template <class _Tp>
648struct __atomic_base<_Tp, true>
649 : public __atomic_base<_Tp, false>
650{
651 typedef __atomic_base<_Tp, false> __base;
652 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f4da72013-05-02 20:18:43653 __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
Howard Hinnant91e2f262010-12-07 20:46:14654 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21655 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14656
657 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21658 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46659 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14660 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21661 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46662 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14663 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21664 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46665 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14666 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21667 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46668 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14669 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21670 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46671 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14672 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21673 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46674 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14675 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21676 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46677 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14678 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21679 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46680 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14681 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21682 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46683 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14684 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21685 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46686 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14687
688 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21689 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14690 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21691 _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14692 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21693 _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14694 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21695 _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14696 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21697 _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14698 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21699 _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14700 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21701 _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14702 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21703 _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14704 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21705 _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14706 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21707 _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14708 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21709 _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14710 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21711 _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14712 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21713 _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14714 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21715 _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14716 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21717 _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14718 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21719 _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14720 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21721 _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14722 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21723 _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14724};
725
726// atomic<T>
727
728template <class _Tp>
729struct atomic
730 : public __atomic_base<_Tp>
731{
732 typedef __atomic_base<_Tp> __base;
733 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f4da72013-05-02 20:18:43734 atomic() _NOEXCEPT _LIBCPP_DEFAULT
Howard Hinnant91e2f262010-12-07 20:46:14735 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21736 _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnantd2f6afb2010-12-07 23:24:41737
738 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21739 _Tp operator=(_Tp __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41740 {__base::store(__d); return __d;}
741 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21742 _Tp operator=(_Tp __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41743 {__base::store(__d); return __d;}
Howard Hinnant91e2f262010-12-07 20:46:14744};
745
746// atomic<T*>
747
748template <class _Tp>
749struct atomic<_Tp*>
750 : public __atomic_base<_Tp*>
751{
Howard Hinnantd2f6afb2010-12-07 23:24:41752 typedef __atomic_base<_Tp*> __base;
Howard Hinnant91e2f262010-12-07 20:46:14753 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f4da72013-05-02 20:18:43754 atomic() _NOEXCEPT _LIBCPP_DEFAULT
Howard Hinnant91e2f262010-12-07 20:46:14755 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21756 _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14757
758 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21759 _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41760 {__base::store(__d); return __d;}
761 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21762 _Tp* operator=(_Tp* __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41763 {__base::store(__d); return __d;}
764
765 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant91e2f262010-12-07 20:46:14766 _Tp* fetch_add(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_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14769 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21770 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46771 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14772 _LIBCPP_INLINE_VISIBILITY
773 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21774 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46775 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14776 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21777 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46778 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14779
780 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21781 _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14782 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21783 _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14784 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21785 _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14786 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21787 _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14788 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21789 _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14790 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21791 _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14792 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21793 _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14794 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21795 _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14796 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21797 _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14798 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21799 _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14800 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21801 _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14802 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21803 _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14804};
Howard Hinnant4777bf22010-12-06 23:10:08805
806// atomic_is_lock_free
807
808template <class _Tp>
809inline _LIBCPP_INLINE_VISIBILITY
810bool
Howard Hinnant300c67a2012-04-11 20:14:21811atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08812{
Howard Hinnant91e2f262010-12-07 20:46:14813 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08814}
815
816template <class _Tp>
817inline _LIBCPP_INLINE_VISIBILITY
818bool
Howard Hinnant300c67a2012-04-11 20:14:21819atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08820{
Howard Hinnant91e2f262010-12-07 20:46:14821 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08822}
823
824// atomic_init
825
826template <class _Tp>
827inline _LIBCPP_INLINE_VISIBILITY
828void
Howard Hinnant300c67a2012-04-11 20:14:21829atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08830{
Richard Smith6186c7f2012-04-11 18:55:46831 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08832}
833
834template <class _Tp>
835inline _LIBCPP_INLINE_VISIBILITY
836void
Howard Hinnant300c67a2012-04-11 20:14:21837atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08838{
Richard Smith6186c7f2012-04-11 18:55:46839 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08840}
841
842// atomic_store
843
844template <class _Tp>
845inline _LIBCPP_INLINE_VISIBILITY
846void
Howard Hinnant300c67a2012-04-11 20:14:21847atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08848{
Howard Hinnant91e2f262010-12-07 20:46:14849 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08850}
851
852template <class _Tp>
853inline _LIBCPP_INLINE_VISIBILITY
854void
Howard Hinnant300c67a2012-04-11 20:14:21855atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08856{
Howard Hinnant91e2f262010-12-07 20:46:14857 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08858}
859
860// atomic_store_explicit
861
862template <class _Tp>
863inline _LIBCPP_INLINE_VISIBILITY
864void
Howard Hinnant300c67a2012-04-11 20:14:21865atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08866{
Howard Hinnant91e2f262010-12-07 20:46:14867 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08868}
869
870template <class _Tp>
871inline _LIBCPP_INLINE_VISIBILITY
872void
Howard Hinnant300c67a2012-04-11 20:14:21873atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08874{
Howard Hinnant91e2f262010-12-07 20:46:14875 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08876}
877
878// atomic_load
879
880template <class _Tp>
881inline _LIBCPP_INLINE_VISIBILITY
882_Tp
Howard Hinnant300c67a2012-04-11 20:14:21883atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08884{
Howard Hinnant91e2f262010-12-07 20:46:14885 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08886}
887
888template <class _Tp>
889inline _LIBCPP_INLINE_VISIBILITY
890_Tp
Howard Hinnant300c67a2012-04-11 20:14:21891atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08892{
Howard Hinnant91e2f262010-12-07 20:46:14893 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08894}
895
896// atomic_load_explicit
897
898template <class _Tp>
899inline _LIBCPP_INLINE_VISIBILITY
900_Tp
Howard Hinnant300c67a2012-04-11 20:14:21901atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08902{
Howard Hinnant91e2f262010-12-07 20:46:14903 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08904}
905
906template <class _Tp>
907inline _LIBCPP_INLINE_VISIBILITY
908_Tp
Howard Hinnant300c67a2012-04-11 20:14:21909atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08910{
Howard Hinnant91e2f262010-12-07 20:46:14911 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08912}
913
914// atomic_exchange
915
916template <class _Tp>
917inline _LIBCPP_INLINE_VISIBILITY
918_Tp
Howard Hinnant300c67a2012-04-11 20:14:21919atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08920{
Howard Hinnant91e2f262010-12-07 20:46:14921 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08922}
923
924template <class _Tp>
925inline _LIBCPP_INLINE_VISIBILITY
926_Tp
Howard Hinnant300c67a2012-04-11 20:14:21927atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08928{
Howard Hinnant91e2f262010-12-07 20:46:14929 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08930}
931
932// atomic_exchange_explicit
933
934template <class _Tp>
935inline _LIBCPP_INLINE_VISIBILITY
936_Tp
Howard Hinnant300c67a2012-04-11 20:14:21937atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08938{
Howard Hinnant91e2f262010-12-07 20:46:14939 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08940}
941
942template <class _Tp>
943inline _LIBCPP_INLINE_VISIBILITY
944_Tp
Howard Hinnant300c67a2012-04-11 20:14:21945atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08946{
Howard Hinnant91e2f262010-12-07 20:46:14947 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08948}
949
950// atomic_compare_exchange_weak
951
952template <class _Tp>
953inline _LIBCPP_INLINE_VISIBILITY
954bool
Howard Hinnant300c67a2012-04-11 20:14:21955atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08956{
Howard Hinnant91e2f262010-12-07 20:46:14957 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08958}
959
960template <class _Tp>
961inline _LIBCPP_INLINE_VISIBILITY
962bool
Howard Hinnant300c67a2012-04-11 20:14:21963atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08964{
Howard Hinnant91e2f262010-12-07 20:46:14965 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08966}
967
968// atomic_compare_exchange_strong
969
970template <class _Tp>
971inline _LIBCPP_INLINE_VISIBILITY
972bool
Howard Hinnant300c67a2012-04-11 20:14:21973atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08974{
Howard Hinnant91e2f262010-12-07 20:46:14975 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08976}
977
978template <class _Tp>
979inline _LIBCPP_INLINE_VISIBILITY
980bool
Howard Hinnant300c67a2012-04-11 20:14:21981atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08982{
Howard Hinnant91e2f262010-12-07 20:46:14983 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08984}
985
986// atomic_compare_exchange_weak_explicit
987
988template <class _Tp>
989inline _LIBCPP_INLINE_VISIBILITY
990bool
991atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
992 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21993 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08994{
Howard Hinnant91e2f262010-12-07 20:46:14995 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08996}
997
998template <class _Tp>
999inline _LIBCPP_INLINE_VISIBILITY
1000bool
1001atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211002 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081003{
Howard Hinnant91e2f262010-12-07 20:46:141004 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081005}
1006
1007// atomic_compare_exchange_strong_explicit
1008
1009template <class _Tp>
1010inline _LIBCPP_INLINE_VISIBILITY
1011bool
1012atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
1013 _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211014 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081015{
Howard Hinnant91e2f262010-12-07 20:46:141016 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081017}
1018
1019template <class _Tp>
1020inline _LIBCPP_INLINE_VISIBILITY
1021bool
1022atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
1023 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211024 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081025{
Howard Hinnant91e2f262010-12-07 20:46:141026 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081027}
1028
Howard Hinnant91e2f262010-12-07 20:46:141029// atomic_fetch_add
Howard Hinnant4777bf22010-12-06 23:10:081030
1031template <class _Tp>
Howard Hinnant91e2f262010-12-07 20:46:141032inline _LIBCPP_INLINE_VISIBILITY
1033typename enable_if
1034<
1035 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1036 _Tp
1037>::type
Howard Hinnant300c67a2012-04-11 20:14:211038atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081039{
Howard Hinnant91e2f262010-12-07 20:46:141040 return __o->fetch_add(__op);
1041}
Howard Hinnant4777bf22010-12-06 23:10:081042
Howard Hinnant91e2f262010-12-07 20:46:141043template <class _Tp>
1044inline _LIBCPP_INLINE_VISIBILITY
1045typename enable_if
1046<
1047 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1048 _Tp
1049>::type
Howard Hinnant300c67a2012-04-11 20:14:211050atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141051{
1052 return __o->fetch_add(__op);
1053}
Howard Hinnant4777bf22010-12-06 23:10:081054
Howard Hinnant91e2f262010-12-07 20:46:141055template <class _Tp>
1056inline _LIBCPP_INLINE_VISIBILITY
1057_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211058atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141059{
1060 return __o->fetch_add(__op);
1061}
1062
1063template <class _Tp>
1064inline _LIBCPP_INLINE_VISIBILITY
1065_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211066atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141067{
1068 return __o->fetch_add(__op);
1069}
1070
1071// atomic_fetch_add_explicit
1072
1073template <class _Tp>
1074inline _LIBCPP_INLINE_VISIBILITY
1075typename enable_if
1076<
1077 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1078 _Tp
1079>::type
Howard Hinnant300c67a2012-04-11 20:14:211080atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141081{
1082 return __o->fetch_add(__op, __m);
1083}
1084
1085template <class _Tp>
1086inline _LIBCPP_INLINE_VISIBILITY
1087typename enable_if
1088<
1089 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1090 _Tp
1091>::type
Howard Hinnant300c67a2012-04-11 20:14:211092atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141093{
1094 return __o->fetch_add(__op, __m);
1095}
1096
1097template <class _Tp>
1098inline _LIBCPP_INLINE_VISIBILITY
1099_Tp*
1100atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211101 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141102{
1103 return __o->fetch_add(__op, __m);
1104}
1105
1106template <class _Tp>
1107inline _LIBCPP_INLINE_VISIBILITY
1108_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211109atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141110{
1111 return __o->fetch_add(__op, __m);
1112}
1113
1114// atomic_fetch_sub
1115
1116template <class _Tp>
1117inline _LIBCPP_INLINE_VISIBILITY
1118typename enable_if
1119<
1120 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1121 _Tp
1122>::type
Howard Hinnant300c67a2012-04-11 20:14:211123atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141124{
1125 return __o->fetch_sub(__op);
1126}
1127
1128template <class _Tp>
1129inline _LIBCPP_INLINE_VISIBILITY
1130typename enable_if
1131<
1132 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1133 _Tp
1134>::type
Howard Hinnant300c67a2012-04-11 20:14:211135atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141136{
1137 return __o->fetch_sub(__op);
1138}
1139
1140template <class _Tp>
1141inline _LIBCPP_INLINE_VISIBILITY
1142_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211143atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141144{
1145 return __o->fetch_sub(__op);
1146}
1147
1148template <class _Tp>
1149inline _LIBCPP_INLINE_VISIBILITY
1150_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211151atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141152{
1153 return __o->fetch_sub(__op);
1154}
1155
1156// atomic_fetch_sub_explicit
1157
1158template <class _Tp>
1159inline _LIBCPP_INLINE_VISIBILITY
1160typename enable_if
1161<
1162 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1163 _Tp
1164>::type
Howard Hinnant300c67a2012-04-11 20:14:211165atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141166{
1167 return __o->fetch_sub(__op, __m);
1168}
1169
1170template <class _Tp>
1171inline _LIBCPP_INLINE_VISIBILITY
1172typename enable_if
1173<
1174 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1175 _Tp
1176>::type
Howard Hinnant300c67a2012-04-11 20:14:211177atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141178{
1179 return __o->fetch_sub(__op, __m);
1180}
1181
1182template <class _Tp>
1183inline _LIBCPP_INLINE_VISIBILITY
1184_Tp*
1185atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211186 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141187{
1188 return __o->fetch_sub(__op, __m);
1189}
1190
1191template <class _Tp>
1192inline _LIBCPP_INLINE_VISIBILITY
1193_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211194atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141195{
1196 return __o->fetch_sub(__op, __m);
1197}
1198
1199// atomic_fetch_and
1200
1201template <class _Tp>
1202inline _LIBCPP_INLINE_VISIBILITY
1203typename enable_if
1204<
1205 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1206 _Tp
1207>::type
Howard Hinnant300c67a2012-04-11 20:14:211208atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141209{
1210 return __o->fetch_and(__op);
1211}
1212
1213template <class _Tp>
1214inline _LIBCPP_INLINE_VISIBILITY
1215typename enable_if
1216<
1217 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1218 _Tp
1219>::type
Howard Hinnant300c67a2012-04-11 20:14:211220atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141221{
1222 return __o->fetch_and(__op);
1223}
1224
1225// atomic_fetch_and_explicit
1226
1227template <class _Tp>
1228inline _LIBCPP_INLINE_VISIBILITY
1229typename enable_if
1230<
1231 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1232 _Tp
1233>::type
Howard Hinnant300c67a2012-04-11 20:14:211234atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141235{
1236 return __o->fetch_and(__op, __m);
1237}
1238
1239template <class _Tp>
1240inline _LIBCPP_INLINE_VISIBILITY
1241typename enable_if
1242<
1243 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1244 _Tp
1245>::type
Howard Hinnant300c67a2012-04-11 20:14:211246atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141247{
1248 return __o->fetch_and(__op, __m);
1249}
1250
1251// atomic_fetch_or
1252
1253template <class _Tp>
1254inline _LIBCPP_INLINE_VISIBILITY
1255typename enable_if
1256<
1257 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1258 _Tp
1259>::type
Howard Hinnant300c67a2012-04-11 20:14:211260atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141261{
1262 return __o->fetch_or(__op);
1263}
1264
1265template <class _Tp>
1266inline _LIBCPP_INLINE_VISIBILITY
1267typename enable_if
1268<
1269 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1270 _Tp
1271>::type
Howard Hinnant300c67a2012-04-11 20:14:211272atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141273{
1274 return __o->fetch_or(__op);
1275}
1276
1277// atomic_fetch_or_explicit
1278
1279template <class _Tp>
1280inline _LIBCPP_INLINE_VISIBILITY
1281typename enable_if
1282<
1283 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1284 _Tp
1285>::type
Howard Hinnant300c67a2012-04-11 20:14:211286atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141287{
1288 return __o->fetch_or(__op, __m);
1289}
1290
1291template <class _Tp>
1292inline _LIBCPP_INLINE_VISIBILITY
1293typename enable_if
1294<
1295 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1296 _Tp
1297>::type
Howard Hinnant300c67a2012-04-11 20:14:211298atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141299{
1300 return __o->fetch_or(__op, __m);
1301}
1302
1303// atomic_fetch_xor
1304
1305template <class _Tp>
1306inline _LIBCPP_INLINE_VISIBILITY
1307typename enable_if
1308<
1309 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1310 _Tp
1311>::type
Howard Hinnant300c67a2012-04-11 20:14:211312atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141313{
1314 return __o->fetch_xor(__op);
1315}
1316
1317template <class _Tp>
1318inline _LIBCPP_INLINE_VISIBILITY
1319typename enable_if
1320<
1321 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1322 _Tp
1323>::type
Howard Hinnant300c67a2012-04-11 20:14:211324atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141325{
1326 return __o->fetch_xor(__op);
1327}
1328
1329// atomic_fetch_xor_explicit
1330
1331template <class _Tp>
1332inline _LIBCPP_INLINE_VISIBILITY
1333typename enable_if
1334<
1335 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1336 _Tp
1337>::type
Howard Hinnant300c67a2012-04-11 20:14:211338atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141339{
1340 return __o->fetch_xor(__op, __m);
1341}
1342
1343template <class _Tp>
1344inline _LIBCPP_INLINE_VISIBILITY
1345typename enable_if
1346<
1347 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1348 _Tp
1349>::type
Howard Hinnant300c67a2012-04-11 20:14:211350atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141351{
1352 return __o->fetch_xor(__op, __m);
1353}
Howard Hinnant4777bf22010-12-06 23:10:081354
Howard Hinnant770d1c42010-12-08 17:20:281355// flag type and operations
1356
1357typedef struct atomic_flag
1358{
David Chisnall83b2c842011-12-19 11:44:201359 _Atomic(bool) __a_;
Howard Hinnant770d1c42010-12-08 17:20:281360
1361 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211362 bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461363 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281364 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211365 bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461366 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281367 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211368 void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461369 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281370 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211371 void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461372 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281373
1374 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f4da72013-05-02 20:18:431375#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
1376 atomic_flag() _NOEXCEPT = default;
1377#else
1378 atomic_flag() _NOEXCEPT : __a_() {}
1379#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
1380
Howard Hinnant770d1c42010-12-08 17:20:281381 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211382 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
Howard Hinnant770d1c42010-12-08 17:20:281383
1384#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1385 atomic_flag(const atomic_flag&) = delete;
1386 atomic_flag& operator=(const atomic_flag&) = delete;
1387 atomic_flag& operator=(const atomic_flag&) volatile = delete;
1388#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1389private:
1390 atomic_flag(const atomic_flag&);
1391 atomic_flag& operator=(const atomic_flag&);
1392 atomic_flag& operator=(const atomic_flag&) volatile;
1393#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1394} atomic_flag;
1395
1396inline _LIBCPP_INLINE_VISIBILITY
1397bool
Howard Hinnant300c67a2012-04-11 20:14:211398atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281399{
1400 return __o->test_and_set();
1401}
1402
1403inline _LIBCPP_INLINE_VISIBILITY
1404bool
Howard Hinnant300c67a2012-04-11 20:14:211405atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281406{
1407 return __o->test_and_set();
1408}
1409
1410inline _LIBCPP_INLINE_VISIBILITY
1411bool
Howard Hinnant300c67a2012-04-11 20:14:211412atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281413{
1414 return __o->test_and_set(__m);
1415}
1416
1417inline _LIBCPP_INLINE_VISIBILITY
1418bool
Howard Hinnant300c67a2012-04-11 20:14:211419atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281420{
1421 return __o->test_and_set(__m);
1422}
1423
1424inline _LIBCPP_INLINE_VISIBILITY
1425void
Howard Hinnant300c67a2012-04-11 20:14:211426atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281427{
1428 __o->clear();
1429}
1430
1431inline _LIBCPP_INLINE_VISIBILITY
1432void
Howard Hinnant300c67a2012-04-11 20:14:211433atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281434{
1435 __o->clear();
1436}
1437
1438inline _LIBCPP_INLINE_VISIBILITY
1439void
Howard Hinnant300c67a2012-04-11 20:14:211440atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281441{
1442 __o->clear(__m);
1443}
1444
1445inline _LIBCPP_INLINE_VISIBILITY
1446void
Howard Hinnant300c67a2012-04-11 20:14:211447atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281448{
1449 __o->clear(__m);
1450}
1451
1452// fences
1453
1454inline _LIBCPP_INLINE_VISIBILITY
1455void
Howard Hinnant300c67a2012-04-11 20:14:211456atomic_thread_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281457{
Richard Smith6186c7f2012-04-11 18:55:461458 __c11_atomic_thread_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281459}
1460
1461inline _LIBCPP_INLINE_VISIBILITY
1462void
Howard Hinnant300c67a2012-04-11 20:14:211463atomic_signal_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281464{
Richard Smith6186c7f2012-04-11 18:55:461465 __c11_atomic_signal_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281466}
1467
Howard Hinnantd2f6afb2010-12-07 23:24:411468// Atomics for standard typedef types
1469
Howard Hinnant6ae47052013-01-04 18:58:501470typedef atomic<bool> atomic_bool;
Howard Hinnantd2f6afb2010-12-07 23:24:411471typedef atomic<char> atomic_char;
1472typedef atomic<signed char> atomic_schar;
1473typedef atomic<unsigned char> atomic_uchar;
1474typedef atomic<short> atomic_short;
1475typedef atomic<unsigned short> atomic_ushort;
1476typedef atomic<int> atomic_int;
1477typedef atomic<unsigned int> atomic_uint;
1478typedef atomic<long> atomic_long;
1479typedef atomic<unsigned long> atomic_ulong;
1480typedef atomic<long long> atomic_llong;
1481typedef atomic<unsigned long long> atomic_ullong;
1482typedef atomic<char16_t> atomic_char16_t;
1483typedef atomic<char32_t> atomic_char32_t;
1484typedef atomic<wchar_t> atomic_wchar_t;
1485
1486typedef atomic<int_least8_t> atomic_int_least8_t;
1487typedef atomic<uint_least8_t> atomic_uint_least8_t;
1488typedef atomic<int_least16_t> atomic_int_least16_t;
1489typedef atomic<uint_least16_t> atomic_uint_least16_t;
1490typedef atomic<int_least32_t> atomic_int_least32_t;
1491typedef atomic<uint_least32_t> atomic_uint_least32_t;
1492typedef atomic<int_least64_t> atomic_int_least64_t;
1493typedef atomic<uint_least64_t> atomic_uint_least64_t;
1494
1495typedef atomic<int_fast8_t> atomic_int_fast8_t;
1496typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
1497typedef atomic<int_fast16_t> atomic_int_fast16_t;
1498typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
1499typedef atomic<int_fast32_t> atomic_int_fast32_t;
1500typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
1501typedef atomic<int_fast64_t> atomic_int_fast64_t;
1502typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
1503
1504typedef atomic<intptr_t> atomic_intptr_t;
1505typedef atomic<uintptr_t> atomic_uintptr_t;
1506typedef atomic<size_t> atomic_size_t;
1507typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
1508typedef atomic<intmax_t> atomic_intmax_t;
1509typedef atomic<uintmax_t> atomic_uintmax_t;
1510
Howard Hinnant767ae2b2010-09-29 21:20:031511#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:541512#define ATOMIC_VAR_INIT(__v) {__v}
1513
Howard Hinnant770d1c42010-12-08 17:20:281514// lock-free property
Howard Hinnant611fdaf2010-10-04 18:52:541515
Howard Hinnant7b9d6a82013-01-21 20:39:411516#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
1517#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
1518#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
1519#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
1520#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
1521#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
1522#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
1523#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
1524#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
1525#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
Howard Hinnant770d1c42010-12-08 17:20:281526
Howard Hinnant154002b2011-03-31 16:39:391527#endif // !__has_feature(cxx_atomic)
1528
Howard Hinnant8f73c632010-09-27 21:17:381529_LIBCPP_END_NAMESPACE_STD
1530
1531#endif // _LIBCPP_ATOMIC