blob: db67e7625b81161b93721a3cd423eeeeb5d1b3e5 [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 Hinnant300c67a2012-04-11 20:14:21625 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14626 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21627 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
Howard Hinnant770d1c42010-12-08 17:20:28628#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14629 __atomic_base(const __atomic_base&) = delete;
630 __atomic_base& operator=(const __atomic_base&) = delete;
631 __atomic_base& operator=(const __atomic_base&) volatile = delete;
Howard Hinnant770d1c42010-12-08 17:20:28632#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
633private:
634 __atomic_base(const __atomic_base&);
635 __atomic_base& operator=(const __atomic_base&);
636 __atomic_base& operator=(const __atomic_base&) volatile;
637#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14638};
639
640// atomic<Integral>
641
642template <class _Tp>
643struct __atomic_base<_Tp, true>
644 : public __atomic_base<_Tp, false>
645{
646 typedef __atomic_base<_Tp, false> __base;
647 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21648 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14649 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21650 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14651
652 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21653 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46654 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14655 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21656 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46657 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14658 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21659 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46660 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14661 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21662 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46663 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14664 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21665 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46666 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14667 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21668 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46669 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21671 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46672 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14673 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21674 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46675 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14676 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21677 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46678 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14679 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21680 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46681 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14682
683 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21684 _Tp operator++(int) volatile _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) _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14687 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21688 _Tp operator--(int) volatile _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--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14691 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21692 _Tp operator++() volatile _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++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14695 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21696 _Tp operator--() volatile _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--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14699 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21700 _Tp operator+=(_Tp __op) volatile _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) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14703 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21704 _Tp operator-=(_Tp __op) volatile _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) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14707 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21708 _Tp operator&=(_Tp __op) volatile _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) _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14711 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21712 _Tp operator|=(_Tp __op) volatile _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) _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21716 _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14717 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21718 _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14719};
720
721// atomic<T>
722
723template <class _Tp>
724struct atomic
725 : public __atomic_base<_Tp>
726{
727 typedef __atomic_base<_Tp> __base;
728 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21729 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14730 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21731 _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnantd2f6afb2010-12-07 23:24:41732
733 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21734 _Tp operator=(_Tp __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41735 {__base::store(__d); return __d;}
736 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21737 _Tp operator=(_Tp __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41738 {__base::store(__d); return __d;}
Howard Hinnant91e2f262010-12-07 20:46:14739};
740
741// atomic<T*>
742
743template <class _Tp>
744struct atomic<_Tp*>
745 : public __atomic_base<_Tp*>
746{
Howard Hinnantd2f6afb2010-12-07 23:24:41747 typedef __atomic_base<_Tp*> __base;
Howard Hinnant91e2f262010-12-07 20:46:14748 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21749 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14750 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21751 _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14752
753 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21754 _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41755 {__base::store(__d); return __d;}
756 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21757 _Tp* operator=(_Tp* __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41758 {__base::store(__d); return __d;}
759
760 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant91e2f262010-12-07 20:46:14761 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21762 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46763 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14764 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21765 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46766 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14767 _LIBCPP_INLINE_VISIBILITY
768 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21769 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46770 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14771 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21772 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46773 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14774
775 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21776 _Tp* operator++(int) volatile _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) _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14779 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21780 _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14781 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21782 _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14783 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21784 _Tp* operator++() volatile _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++() _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14787 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21788 _Tp* operator--() volatile _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--() _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14791 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21792 _Tp* operator+=(ptrdiff_t __op) volatile _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) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14795 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21796 _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14797 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21798 _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14799};
Howard Hinnant4777bf22010-12-06 23:10:08800
801// atomic_is_lock_free
802
803template <class _Tp>
804inline _LIBCPP_INLINE_VISIBILITY
805bool
Howard Hinnant300c67a2012-04-11 20:14:21806atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08807{
Howard Hinnant91e2f262010-12-07 20:46:14808 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08809}
810
811template <class _Tp>
812inline _LIBCPP_INLINE_VISIBILITY
813bool
Howard Hinnant300c67a2012-04-11 20:14:21814atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08815{
Howard Hinnant91e2f262010-12-07 20:46:14816 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08817}
818
819// atomic_init
820
821template <class _Tp>
822inline _LIBCPP_INLINE_VISIBILITY
823void
Howard Hinnant300c67a2012-04-11 20:14:21824atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08825{
Richard Smith6186c7f2012-04-11 18:55:46826 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08827}
828
829template <class _Tp>
830inline _LIBCPP_INLINE_VISIBILITY
831void
Howard Hinnant300c67a2012-04-11 20:14:21832atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08833{
Richard Smith6186c7f2012-04-11 18:55:46834 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08835}
836
837// atomic_store
838
839template <class _Tp>
840inline _LIBCPP_INLINE_VISIBILITY
841void
Howard Hinnant300c67a2012-04-11 20:14:21842atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08843{
Howard Hinnant91e2f262010-12-07 20:46:14844 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08845}
846
847template <class _Tp>
848inline _LIBCPP_INLINE_VISIBILITY
849void
Howard Hinnant300c67a2012-04-11 20:14:21850atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08851{
Howard Hinnant91e2f262010-12-07 20:46:14852 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08853}
854
855// atomic_store_explicit
856
857template <class _Tp>
858inline _LIBCPP_INLINE_VISIBILITY
859void
Howard Hinnant300c67a2012-04-11 20:14:21860atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08861{
Howard Hinnant91e2f262010-12-07 20:46:14862 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08863}
864
865template <class _Tp>
866inline _LIBCPP_INLINE_VISIBILITY
867void
Howard Hinnant300c67a2012-04-11 20:14:21868atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08869{
Howard Hinnant91e2f262010-12-07 20:46:14870 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08871}
872
873// atomic_load
874
875template <class _Tp>
876inline _LIBCPP_INLINE_VISIBILITY
877_Tp
Howard Hinnant300c67a2012-04-11 20:14:21878atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08879{
Howard Hinnant91e2f262010-12-07 20:46:14880 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08881}
882
883template <class _Tp>
884inline _LIBCPP_INLINE_VISIBILITY
885_Tp
Howard Hinnant300c67a2012-04-11 20:14:21886atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08887{
Howard Hinnant91e2f262010-12-07 20:46:14888 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08889}
890
891// atomic_load_explicit
892
893template <class _Tp>
894inline _LIBCPP_INLINE_VISIBILITY
895_Tp
Howard Hinnant300c67a2012-04-11 20:14:21896atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08897{
Howard Hinnant91e2f262010-12-07 20:46:14898 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08899}
900
901template <class _Tp>
902inline _LIBCPP_INLINE_VISIBILITY
903_Tp
Howard Hinnant300c67a2012-04-11 20:14:21904atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08905{
Howard Hinnant91e2f262010-12-07 20:46:14906 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08907}
908
909// atomic_exchange
910
911template <class _Tp>
912inline _LIBCPP_INLINE_VISIBILITY
913_Tp
Howard Hinnant300c67a2012-04-11 20:14:21914atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08915{
Howard Hinnant91e2f262010-12-07 20:46:14916 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08917}
918
919template <class _Tp>
920inline _LIBCPP_INLINE_VISIBILITY
921_Tp
Howard Hinnant300c67a2012-04-11 20:14:21922atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08923{
Howard Hinnant91e2f262010-12-07 20:46:14924 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08925}
926
927// atomic_exchange_explicit
928
929template <class _Tp>
930inline _LIBCPP_INLINE_VISIBILITY
931_Tp
Howard Hinnant300c67a2012-04-11 20:14:21932atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08933{
Howard Hinnant91e2f262010-12-07 20:46:14934 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08935}
936
937template <class _Tp>
938inline _LIBCPP_INLINE_VISIBILITY
939_Tp
Howard Hinnant300c67a2012-04-11 20:14:21940atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08941{
Howard Hinnant91e2f262010-12-07 20:46:14942 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08943}
944
945// atomic_compare_exchange_weak
946
947template <class _Tp>
948inline _LIBCPP_INLINE_VISIBILITY
949bool
Howard Hinnant300c67a2012-04-11 20:14:21950atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08951{
Howard Hinnant91e2f262010-12-07 20:46:14952 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08953}
954
955template <class _Tp>
956inline _LIBCPP_INLINE_VISIBILITY
957bool
Howard Hinnant300c67a2012-04-11 20:14:21958atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08959{
Howard Hinnant91e2f262010-12-07 20:46:14960 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08961}
962
963// atomic_compare_exchange_strong
964
965template <class _Tp>
966inline _LIBCPP_INLINE_VISIBILITY
967bool
Howard Hinnant300c67a2012-04-11 20:14:21968atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08969{
Howard Hinnant91e2f262010-12-07 20:46:14970 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08971}
972
973template <class _Tp>
974inline _LIBCPP_INLINE_VISIBILITY
975bool
Howard Hinnant300c67a2012-04-11 20:14:21976atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08977{
Howard Hinnant91e2f262010-12-07 20:46:14978 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08979}
980
981// atomic_compare_exchange_weak_explicit
982
983template <class _Tp>
984inline _LIBCPP_INLINE_VISIBILITY
985bool
986atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
987 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21988 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08989{
Howard Hinnant91e2f262010-12-07 20:46:14990 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08991}
992
993template <class _Tp>
994inline _LIBCPP_INLINE_VISIBILITY
995bool
996atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21997 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08998{
Howard Hinnant91e2f262010-12-07 20:46:14999 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081000}
1001
1002// atomic_compare_exchange_strong_explicit
1003
1004template <class _Tp>
1005inline _LIBCPP_INLINE_VISIBILITY
1006bool
1007atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
1008 _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211009 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081010{
Howard Hinnant91e2f262010-12-07 20:46:141011 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081012}
1013
1014template <class _Tp>
1015inline _LIBCPP_INLINE_VISIBILITY
1016bool
1017atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
1018 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211019 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081020{
Howard Hinnant91e2f262010-12-07 20:46:141021 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081022}
1023
Howard Hinnant91e2f262010-12-07 20:46:141024// atomic_fetch_add
Howard Hinnant4777bf22010-12-06 23:10:081025
1026template <class _Tp>
Howard Hinnant91e2f262010-12-07 20:46:141027inline _LIBCPP_INLINE_VISIBILITY
1028typename enable_if
1029<
1030 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1031 _Tp
1032>::type
Howard Hinnant300c67a2012-04-11 20:14:211033atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081034{
Howard Hinnant91e2f262010-12-07 20:46:141035 return __o->fetch_add(__op);
1036}
Howard Hinnant4777bf22010-12-06 23:10:081037
Howard Hinnant91e2f262010-12-07 20:46:141038template <class _Tp>
1039inline _LIBCPP_INLINE_VISIBILITY
1040typename enable_if
1041<
1042 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1043 _Tp
1044>::type
Howard Hinnant300c67a2012-04-11 20:14:211045atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141046{
1047 return __o->fetch_add(__op);
1048}
Howard Hinnant4777bf22010-12-06 23:10:081049
Howard Hinnant91e2f262010-12-07 20:46:141050template <class _Tp>
1051inline _LIBCPP_INLINE_VISIBILITY
1052_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211053atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141054{
1055 return __o->fetch_add(__op);
1056}
1057
1058template <class _Tp>
1059inline _LIBCPP_INLINE_VISIBILITY
1060_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211061atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141062{
1063 return __o->fetch_add(__op);
1064}
1065
1066// atomic_fetch_add_explicit
1067
1068template <class _Tp>
1069inline _LIBCPP_INLINE_VISIBILITY
1070typename enable_if
1071<
1072 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1073 _Tp
1074>::type
Howard Hinnant300c67a2012-04-11 20:14:211075atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141076{
1077 return __o->fetch_add(__op, __m);
1078}
1079
1080template <class _Tp>
1081inline _LIBCPP_INLINE_VISIBILITY
1082typename enable_if
1083<
1084 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1085 _Tp
1086>::type
Howard Hinnant300c67a2012-04-11 20:14:211087atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141088{
1089 return __o->fetch_add(__op, __m);
1090}
1091
1092template <class _Tp>
1093inline _LIBCPP_INLINE_VISIBILITY
1094_Tp*
1095atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211096 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141097{
1098 return __o->fetch_add(__op, __m);
1099}
1100
1101template <class _Tp>
1102inline _LIBCPP_INLINE_VISIBILITY
1103_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211104atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141105{
1106 return __o->fetch_add(__op, __m);
1107}
1108
1109// atomic_fetch_sub
1110
1111template <class _Tp>
1112inline _LIBCPP_INLINE_VISIBILITY
1113typename enable_if
1114<
1115 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1116 _Tp
1117>::type
Howard Hinnant300c67a2012-04-11 20:14:211118atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141119{
1120 return __o->fetch_sub(__op);
1121}
1122
1123template <class _Tp>
1124inline _LIBCPP_INLINE_VISIBILITY
1125typename enable_if
1126<
1127 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1128 _Tp
1129>::type
Howard Hinnant300c67a2012-04-11 20:14:211130atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141131{
1132 return __o->fetch_sub(__op);
1133}
1134
1135template <class _Tp>
1136inline _LIBCPP_INLINE_VISIBILITY
1137_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211138atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141139{
1140 return __o->fetch_sub(__op);
1141}
1142
1143template <class _Tp>
1144inline _LIBCPP_INLINE_VISIBILITY
1145_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211146atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141147{
1148 return __o->fetch_sub(__op);
1149}
1150
1151// atomic_fetch_sub_explicit
1152
1153template <class _Tp>
1154inline _LIBCPP_INLINE_VISIBILITY
1155typename enable_if
1156<
1157 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1158 _Tp
1159>::type
Howard Hinnant300c67a2012-04-11 20:14:211160atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141161{
1162 return __o->fetch_sub(__op, __m);
1163}
1164
1165template <class _Tp>
1166inline _LIBCPP_INLINE_VISIBILITY
1167typename enable_if
1168<
1169 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1170 _Tp
1171>::type
Howard Hinnant300c67a2012-04-11 20:14:211172atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141173{
1174 return __o->fetch_sub(__op, __m);
1175}
1176
1177template <class _Tp>
1178inline _LIBCPP_INLINE_VISIBILITY
1179_Tp*
1180atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211181 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141182{
1183 return __o->fetch_sub(__op, __m);
1184}
1185
1186template <class _Tp>
1187inline _LIBCPP_INLINE_VISIBILITY
1188_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211189atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141190{
1191 return __o->fetch_sub(__op, __m);
1192}
1193
1194// atomic_fetch_and
1195
1196template <class _Tp>
1197inline _LIBCPP_INLINE_VISIBILITY
1198typename enable_if
1199<
1200 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1201 _Tp
1202>::type
Howard Hinnant300c67a2012-04-11 20:14:211203atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141204{
1205 return __o->fetch_and(__op);
1206}
1207
1208template <class _Tp>
1209inline _LIBCPP_INLINE_VISIBILITY
1210typename enable_if
1211<
1212 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1213 _Tp
1214>::type
Howard Hinnant300c67a2012-04-11 20:14:211215atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141216{
1217 return __o->fetch_and(__op);
1218}
1219
1220// atomic_fetch_and_explicit
1221
1222template <class _Tp>
1223inline _LIBCPP_INLINE_VISIBILITY
1224typename enable_if
1225<
1226 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1227 _Tp
1228>::type
Howard Hinnant300c67a2012-04-11 20:14:211229atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141230{
1231 return __o->fetch_and(__op, __m);
1232}
1233
1234template <class _Tp>
1235inline _LIBCPP_INLINE_VISIBILITY
1236typename enable_if
1237<
1238 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1239 _Tp
1240>::type
Howard Hinnant300c67a2012-04-11 20:14:211241atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141242{
1243 return __o->fetch_and(__op, __m);
1244}
1245
1246// atomic_fetch_or
1247
1248template <class _Tp>
1249inline _LIBCPP_INLINE_VISIBILITY
1250typename enable_if
1251<
1252 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1253 _Tp
1254>::type
Howard Hinnant300c67a2012-04-11 20:14:211255atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141256{
1257 return __o->fetch_or(__op);
1258}
1259
1260template <class _Tp>
1261inline _LIBCPP_INLINE_VISIBILITY
1262typename enable_if
1263<
1264 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1265 _Tp
1266>::type
Howard Hinnant300c67a2012-04-11 20:14:211267atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141268{
1269 return __o->fetch_or(__op);
1270}
1271
1272// atomic_fetch_or_explicit
1273
1274template <class _Tp>
1275inline _LIBCPP_INLINE_VISIBILITY
1276typename enable_if
1277<
1278 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1279 _Tp
1280>::type
Howard Hinnant300c67a2012-04-11 20:14:211281atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141282{
1283 return __o->fetch_or(__op, __m);
1284}
1285
1286template <class _Tp>
1287inline _LIBCPP_INLINE_VISIBILITY
1288typename enable_if
1289<
1290 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1291 _Tp
1292>::type
Howard Hinnant300c67a2012-04-11 20:14:211293atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141294{
1295 return __o->fetch_or(__op, __m);
1296}
1297
1298// atomic_fetch_xor
1299
1300template <class _Tp>
1301inline _LIBCPP_INLINE_VISIBILITY
1302typename enable_if
1303<
1304 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1305 _Tp
1306>::type
Howard Hinnant300c67a2012-04-11 20:14:211307atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141308{
1309 return __o->fetch_xor(__op);
1310}
1311
1312template <class _Tp>
1313inline _LIBCPP_INLINE_VISIBILITY
1314typename enable_if
1315<
1316 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1317 _Tp
1318>::type
Howard Hinnant300c67a2012-04-11 20:14:211319atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141320{
1321 return __o->fetch_xor(__op);
1322}
1323
1324// atomic_fetch_xor_explicit
1325
1326template <class _Tp>
1327inline _LIBCPP_INLINE_VISIBILITY
1328typename enable_if
1329<
1330 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1331 _Tp
1332>::type
Howard Hinnant300c67a2012-04-11 20:14:211333atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141334{
1335 return __o->fetch_xor(__op, __m);
1336}
1337
1338template <class _Tp>
1339inline _LIBCPP_INLINE_VISIBILITY
1340typename enable_if
1341<
1342 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1343 _Tp
1344>::type
Howard Hinnant300c67a2012-04-11 20:14:211345atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141346{
1347 return __o->fetch_xor(__op, __m);
1348}
Howard Hinnant4777bf22010-12-06 23:10:081349
Howard Hinnant770d1c42010-12-08 17:20:281350// flag type and operations
1351
1352typedef struct atomic_flag
1353{
David Chisnall83b2c842011-12-19 11:44:201354 _Atomic(bool) __a_;
Howard Hinnant770d1c42010-12-08 17:20:281355
1356 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211357 bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461358 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281359 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211360 bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461361 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281362 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211363 void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461364 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281365 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211366 void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461367 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281368
1369 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211370 atomic_flag() _NOEXCEPT {} // = default;
Howard Hinnant770d1c42010-12-08 17:20:281371 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211372 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
Howard Hinnant770d1c42010-12-08 17:20:281373
1374#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1375 atomic_flag(const atomic_flag&) = delete;
1376 atomic_flag& operator=(const atomic_flag&) = delete;
1377 atomic_flag& operator=(const atomic_flag&) volatile = delete;
1378#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1379private:
1380 atomic_flag(const atomic_flag&);
1381 atomic_flag& operator=(const atomic_flag&);
1382 atomic_flag& operator=(const atomic_flag&) volatile;
1383#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1384} atomic_flag;
1385
1386inline _LIBCPP_INLINE_VISIBILITY
1387bool
Howard Hinnant300c67a2012-04-11 20:14:211388atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281389{
1390 return __o->test_and_set();
1391}
1392
1393inline _LIBCPP_INLINE_VISIBILITY
1394bool
Howard Hinnant300c67a2012-04-11 20:14:211395atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281396{
1397 return __o->test_and_set();
1398}
1399
1400inline _LIBCPP_INLINE_VISIBILITY
1401bool
Howard Hinnant300c67a2012-04-11 20:14:211402atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281403{
1404 return __o->test_and_set(__m);
1405}
1406
1407inline _LIBCPP_INLINE_VISIBILITY
1408bool
Howard Hinnant300c67a2012-04-11 20:14:211409atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281410{
1411 return __o->test_and_set(__m);
1412}
1413
1414inline _LIBCPP_INLINE_VISIBILITY
1415void
Howard Hinnant300c67a2012-04-11 20:14:211416atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281417{
1418 __o->clear();
1419}
1420
1421inline _LIBCPP_INLINE_VISIBILITY
1422void
Howard Hinnant300c67a2012-04-11 20:14:211423atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281424{
1425 __o->clear();
1426}
1427
1428inline _LIBCPP_INLINE_VISIBILITY
1429void
Howard Hinnant300c67a2012-04-11 20:14:211430atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281431{
1432 __o->clear(__m);
1433}
1434
1435inline _LIBCPP_INLINE_VISIBILITY
1436void
Howard Hinnant300c67a2012-04-11 20:14:211437atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281438{
1439 __o->clear(__m);
1440}
1441
1442// fences
1443
1444inline _LIBCPP_INLINE_VISIBILITY
1445void
Howard Hinnant300c67a2012-04-11 20:14:211446atomic_thread_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281447{
Richard Smith6186c7f2012-04-11 18:55:461448 __c11_atomic_thread_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281449}
1450
1451inline _LIBCPP_INLINE_VISIBILITY
1452void
Howard Hinnant300c67a2012-04-11 20:14:211453atomic_signal_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281454{
Richard Smith6186c7f2012-04-11 18:55:461455 __c11_atomic_signal_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281456}
1457
Howard Hinnantd2f6afb2010-12-07 23:24:411458// Atomics for standard typedef types
1459
Howard Hinnant6ae47052013-01-04 18:58:501460typedef atomic<bool> atomic_bool;
Howard Hinnantd2f6afb2010-12-07 23:24:411461typedef atomic<char> atomic_char;
1462typedef atomic<signed char> atomic_schar;
1463typedef atomic<unsigned char> atomic_uchar;
1464typedef atomic<short> atomic_short;
1465typedef atomic<unsigned short> atomic_ushort;
1466typedef atomic<int> atomic_int;
1467typedef atomic<unsigned int> atomic_uint;
1468typedef atomic<long> atomic_long;
1469typedef atomic<unsigned long> atomic_ulong;
1470typedef atomic<long long> atomic_llong;
1471typedef atomic<unsigned long long> atomic_ullong;
1472typedef atomic<char16_t> atomic_char16_t;
1473typedef atomic<char32_t> atomic_char32_t;
1474typedef atomic<wchar_t> atomic_wchar_t;
1475
1476typedef atomic<int_least8_t> atomic_int_least8_t;
1477typedef atomic<uint_least8_t> atomic_uint_least8_t;
1478typedef atomic<int_least16_t> atomic_int_least16_t;
1479typedef atomic<uint_least16_t> atomic_uint_least16_t;
1480typedef atomic<int_least32_t> atomic_int_least32_t;
1481typedef atomic<uint_least32_t> atomic_uint_least32_t;
1482typedef atomic<int_least64_t> atomic_int_least64_t;
1483typedef atomic<uint_least64_t> atomic_uint_least64_t;
1484
1485typedef atomic<int_fast8_t> atomic_int_fast8_t;
1486typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
1487typedef atomic<int_fast16_t> atomic_int_fast16_t;
1488typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
1489typedef atomic<int_fast32_t> atomic_int_fast32_t;
1490typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
1491typedef atomic<int_fast64_t> atomic_int_fast64_t;
1492typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
1493
1494typedef atomic<intptr_t> atomic_intptr_t;
1495typedef atomic<uintptr_t> atomic_uintptr_t;
1496typedef atomic<size_t> atomic_size_t;
1497typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
1498typedef atomic<intmax_t> atomic_intmax_t;
1499typedef atomic<uintmax_t> atomic_uintmax_t;
1500
Howard Hinnant767ae2b2010-09-29 21:20:031501#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:541502#define ATOMIC_VAR_INIT(__v) {__v}
1503
Howard Hinnant770d1c42010-12-08 17:20:281504// lock-free property
Howard Hinnant611fdaf2010-10-04 18:52:541505
Howard Hinnant7b9d6a82013-01-21 20:39:411506#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
1507#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
1508#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
1509#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
1510#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
1511#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
1512#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
1513#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
1514#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
1515#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
Howard Hinnant770d1c42010-12-08 17:20:281516
Howard Hinnant154002b2011-03-31 16:39:391517#endif // !__has_feature(cxx_atomic)
1518
Howard Hinnant8f73c632010-09-27 21:17:381519_LIBCPP_END_NAMESPACE_STD
1520
1521#endif // _LIBCPP_ATOMIC