blob: 43154669f2b9b2a782f09c593e9a3958c642146d [file] [log] [blame]
Howard Hinnant8f73c632010-09-27 21:17:38 +00001// -*- 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:38 +000024 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:38 +000030} memory_order;
31
32template <class T> T kill_dependency(T y);
33
34// lock-free property
35
36#define ATOMIC_CHAR_LOCK_FREE unspecified
37#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
38#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
39#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
40#define ATOMIC_SHORT_LOCK_FREE unspecified
41#define ATOMIC_INT_LOCK_FREE unspecified
42#define ATOMIC_LONG_LOCK_FREE unspecified
43#define ATOMIC_LLONG_LOCK_FREE unspecified
Howard Hinnant8f73c632010-09-27 21:17:38 +000044
Howard Hinnant8f73c632010-09-27 21:17:38 +000045// flag type and operations
46
47typedef struct atomic_flag
48{
Howard Hinnant4777bf22010-12-06 23:10:08 +000049 bool test_and_set(memory_order m = memory_order_seq_cst) volatile;
50 bool test_and_set(memory_order m = memory_order_seq_cst);
51 void clear(memory_order m = memory_order_seq_cst) volatile;
52 void clear(memory_order m = memory_order_seq_cst);
Howard Hinnant8f73c632010-09-27 21:17:38 +000053 atomic_flag() = default;
54 atomic_flag(const atomic_flag&) = delete;
55 atomic_flag& operator=(const atomic_flag&) = delete;
56 atomic_flag& operator=(const atomic_flag&) volatile = delete;
57} atomic_flag;
58
Howard Hinnant4777bf22010-12-06 23:10:08 +000059bool
60 atomic_flag_test_and_set(volatile atomic_flag* obj);
61
62bool
63 atomic_flag_test_and_set(atomic_flag* obj);
64
65bool
66 atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
67 memory_order m);
68
69bool
70 atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m);
71
72void
73 atomic_flag_clear(volatile atomic_flag* obj);
74
75void
76 atomic_flag_clear(atomic_flag* obj);
77
78void
79 atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m);
80
81void
82 atomic_flag_clear_explicit(atomic_flag* obj, memory_order m);
Howard Hinnant8f73c632010-09-27 21:17:38 +000083
84#define ATOMIC_FLAG_INIT see below
Howard Hinnante7385012010-10-19 16:51:18 +000085#define ATOMIC_VAR_INIT(value) see below
Howard Hinnant8f73c632010-09-27 21:17:38 +000086
Howard Hinnant8f73c632010-09-27 21:17:38 +000087template <class T>
88struct atomic
89{
90 bool is_lock_free() const volatile;
91 bool is_lock_free() const;
Howard Hinnant4777bf22010-12-06 23:10:08 +000092 void store(T desr, memory_order m = memory_order_seq_cst) volatile;
93 void store(T desr, memory_order m = memory_order_seq_cst);
94 T load(memory_order m = memory_order_seq_cst) const volatile;
95 T load(memory_order m = memory_order_seq_cst) const;
Howard Hinnant8f73c632010-09-27 21:17:38 +000096 operator T() const volatile;
97 operator T() const;
Howard Hinnant4777bf22010-12-06 23:10:08 +000098 T exchange(T desr, memory_order m = memory_order_seq_cst) volatile;
99 T exchange(T desr, memory_order m = memory_order_seq_cst);
100 bool compare_exchange_weak(T& expc, T desr,
101 memory_order s, memory_order f) volatile;
102 bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f);
103 bool compare_exchange_strong(T& expc, T desr,
104 memory_order s, memory_order f) volatile;
105 bool compare_exchange_strong(T& expc, T desr,
106 memory_order s, memory_order f);
107 bool compare_exchange_weak(T& expc, T desr,
108 memory_order m = memory_order_seq_cst) volatile;
109 bool compare_exchange_weak(T& expc, T desr,
110 memory_order m = memory_order_seq_cst);
111 bool compare_exchange_strong(T& expc, T desr,
112 memory_order m = memory_order_seq_cst) volatile;
113 bool compare_exchange_strong(T& expc, T desr,
114 memory_order m = memory_order_seq_cst);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000115
116 atomic() = default;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000117 constexpr atomic(T desr);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000118 atomic(const atomic&) = delete;
119 atomic& operator=(const atomic&) = delete;
120 atomic& operator=(const atomic&) volatile = delete;
121 T operator=(T) volatile;
122 T operator=(T);
123};
124
125template <>
Howard Hinnant4777bf22010-12-06 23:10:08 +0000126struct atomic<integral>
Howard Hinnant8f73c632010-09-27 21:17:38 +0000127{
Howard Hinnant4777bf22010-12-06 23:10:08 +0000128 bool is_lock_free() const volatile;
129 bool is_lock_free() const;
130 void store(integral desr, memory_order m = memory_order_seq_cst) volatile;
131 void store(integral desr, memory_order m = memory_order_seq_cst);
132 integral load(memory_order m = memory_order_seq_cst) const volatile;
133 integral load(memory_order m = memory_order_seq_cst) const;
134 operator integral() const volatile;
135 operator integral() const;
136 integral exchange(integral desr,
137 memory_order m = memory_order_seq_cst) volatile;
138 integral exchange(integral desr, memory_order m = memory_order_seq_cst);
139 bool compare_exchange_weak(integral& expc, integral desr,
140 memory_order s, memory_order f) volatile;
141 bool compare_exchange_weak(integral& expc, integral desr,
142 memory_order s, memory_order f);
143 bool compare_exchange_strong(integral& expc, integral desr,
144 memory_order s, memory_order f) volatile;
145 bool compare_exchange_strong(integral& expc, integral desr,
146 memory_order s, memory_order f);
147 bool compare_exchange_weak(integral& expc, integral desr,
148 memory_order m = memory_order_seq_cst) volatile;
149 bool compare_exchange_weak(integral& expc, integral desr,
150 memory_order m = memory_order_seq_cst);
151 bool compare_exchange_strong(integral& expc, integral desr,
152 memory_order m = memory_order_seq_cst) volatile;
153 bool compare_exchange_strong(integral& expc, integral desr,
154 memory_order m = memory_order_seq_cst);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000155
Howard Hinnant4777bf22010-12-06 23:10:08 +0000156 integral
157 fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile;
158 integral fetch_add(integral op, memory_order m = memory_order_seq_cst);
159 integral
160 fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile;
161 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst);
162 integral
163 fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile;
164 integral fetch_and(integral op, memory_order m = memory_order_seq_cst);
165 integral
166 fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile;
167 integral fetch_or(integral op, memory_order m = memory_order_seq_cst);
168 integral
169 fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile;
170 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000171
Howard Hinnant8f73c632010-09-27 21:17:38 +0000172 atomic() = default;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000173 constexpr atomic(integral desr);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000174 atomic(const atomic&) = delete;
175 atomic& operator=(const atomic&) = delete;
176 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000177 integral operator=(integral desr) volatile;
178 integral operator=(integral desr);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000179
Howard Hinnant4777bf22010-12-06 23:10:08 +0000180 integral operator++(int) volatile;
181 integral operator++(int);
182 integral operator--(int) volatile;
183 integral operator--(int);
184 integral operator++() volatile;
185 integral operator++();
186 integral operator--() volatile;
187 integral operator--();
188 integral operator+=(integral op) volatile;
189 integral operator+=(integral op);
190 integral operator-=(integral op) volatile;
191 integral operator-=(integral op);
192 integral operator&=(integral op) volatile;
193 integral operator&=(integral op);
194 integral operator|=(integral op) volatile;
195 integral operator|=(integral op);
196 integral operatorˆ=(integral op) volatile;
197 integral operatorˆ=(integral op);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000198};
199
200template <class T>
201struct atomic<T*>
Howard Hinnant8f73c632010-09-27 21:17:38 +0000202{
Howard Hinnant4777bf22010-12-06 23:10:08 +0000203 bool is_lock_free() const volatile;
204 bool is_lock_free() const;
205 void store(T* desr, memory_order m = memory_order_seq_cst) volatile;
206 void store(T* desr, memory_order m = memory_order_seq_cst);
207 T* load(memory_order m = memory_order_seq_cst) const volatile;
208 T* load(memory_order m = memory_order_seq_cst) const;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000209 operator T*() const volatile;
210 operator T*() const;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000211 T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile;
212 T* exchange(T* desr, memory_order m = memory_order_seq_cst);
213 bool compare_exchange_weak(T*& expc, T* desr,
214 memory_order s, memory_order f) volatile;
215 bool compare_exchange_weak(T*& expc, T* desr,
216 memory_order s, memory_order f);
217 bool compare_exchange_strong(T*& expc, T* desr,
218 memory_order s, memory_order f) volatile;
219 bool compare_exchange_strong(T*& expc, T* desr,
220 memory_order s, memory_order f);
221 bool compare_exchange_weak(T*& expc, T* desr,
222 memory_order m = memory_order_seq_cst) volatile;
223 bool compare_exchange_weak(T*& expc, T* desr,
224 memory_order m = memory_order_seq_cst);
225 bool compare_exchange_strong(T*& expc, T* desr,
226 memory_order m = memory_order_seq_cst) volatile;
227 bool compare_exchange_strong(T*& expc, T* desr,
228 memory_order m = memory_order_seq_cst);
229 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
230 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst);
231 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
232 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst);
233
Howard Hinnant8f73c632010-09-27 21:17:38 +0000234 atomic() = default;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000235 constexpr atomic(T* desr);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000236 atomic(const atomic&) = delete;
237 atomic& operator=(const atomic&) = delete;
238 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant4777bf22010-12-06 23:10:08 +0000239
Howard Hinnant8f73c632010-09-27 21:17:38 +0000240 T* operator=(T*) volatile;
241 T* operator=(T*);
242 T* operator++(int) volatile;
243 T* operator++(int);
244 T* operator--(int) volatile;
245 T* operator--(int);
246 T* operator++() volatile;
247 T* operator++();
248 T* operator--() volatile;
249 T* operator--();
Howard Hinnant4777bf22010-12-06 23:10:08 +0000250 T* operator+=(ptrdiff_t op) volatile;
251 T* operator+=(ptrdiff_t op);
252 T* operator-=(ptrdiff_t op) volatile;
253 T* operator-=(ptrdiff_t op);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000254};
255
Howard Hinnant4777bf22010-12-06 23:10:08 +0000256
257template <class T>
258 bool
259 atomic_is_lock_free(const volatile atomic<T>* obj);
260
261template <class T>
262 bool
263 atomic_is_lock_free(const atomic<T>* obj);
264
265template <class T>
266 void
267 atomic_init(volatile atomic<T>* obj, T desr);
268
269template <class T>
270 void
271 atomic_init(atomic<T>* obj, T desr);
272
273template <class T>
274 void
275 atomic_store(volatile atomic<T>* obj, T desr);
276
277template <class T>
278 void
279 atomic_store(atomic<T>* obj, T desr);
280
281template <class T>
282 void
283 atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m);
284
285template <class T>
286 void
287 atomic_store_explicit(atomic<T>* obj, T desr, memory_order m);
288
289template <class T>
290 T
291 atomic_load(const volatile atomic<T>* obj);
292
293template <class T>
294 T
295 atomic_load(const atomic<T>* obj);
296
297template <class T>
298 T
299 atomic_load_explicit(const volatile atomic<T>* obj, memory_order m);
300
301template <class T>
302 T
303 atomic_load_explicit(const atomic<T>* obj, memory_order m);
304
305template <class T>
306 T
307 atomic_exchange(volatile atomic<T>* obj, T desr);
308
309template <class T>
310 T
311 atomic_exchange(atomic<T>* obj, T desr);
312
313template <class T>
314 T
315 atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m);
316
317template <class T>
318 T
319 atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m);
320
321template <class T>
322 bool
323 atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr);
324
325template <class T>
326 bool
327 atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr);
328
329template <class T>
330 bool
331 atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
332
333template <class T>
334 bool
335 atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
336
337template <class T>
338 bool
339 atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
340 T desr,
341 memory_order s, memory_order f);
342
343template <class T>
344 bool
345 atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
346 memory_order s, memory_order f);
347
348template <class T>
349 bool
350 atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
351 T* expc, T desr,
352 memory_order s, memory_order f);
353
354template <class T>
355 bool
356 atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
357 T desr,
358 memory_order s, memory_order f);
359
360template <class Integral>
361 Integral
362 atomic_fetch_add(volatile atomic<Integral>* obj, Integral op);
363
364template <class Integral>
365 Integral
366 atomic_fetch_add(atomic<Integral>* obj, Integral op);
367
368template <class Integral>
369 Integral
370 atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
371 memory_order m);
372template <class Integral>
373 Integral
374 atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
375 memory_order m);
376template <class Integral>
377 Integral
378 atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op);
379
380template <class Integral>
381 Integral
382 atomic_fetch_sub(atomic<Integral>* obj, Integral op);
383
384template <class Integral>
385 Integral
386 atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
387 memory_order m);
388template <class Integral>
389 Integral
390 atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
391 memory_order m);
392template <class Integral>
393 Integral
394 atomic_fetch_and(volatile atomic<Integral>* obj, Integral op);
395
396template <class Integral>
397 Integral
398 atomic_fetch_and(atomic<Integral>* obj, Integral op);
399
400template <class Integral>
401 Integral
402 atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
403 memory_order m);
404template <class Integral>
405 Integral
406 atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
407 memory_order m);
408template <class Integral>
409 Integral
410 atomic_fetch_or(volatile atomic<Integral>* obj, Integral op);
411
412template <class Integral>
413 Integral
414 atomic_fetch_or(atomic<Integral>* obj, Integral op);
415
416template <class Integral>
417 Integral
418 atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
419 memory_order m);
420template <class Integral>
421 Integral
422 atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
423 memory_order m);
424template <class Integral>
425 Integral
426 atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op);
427
428template <class Integral>
429 Integral
430 atomic_fetch_xor(atomic<Integral>* obj, Integral op);
431
432template <class Integral>
433 Integral
434 atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
435 memory_order m);
436template <class Integral>
437 Integral
438 atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
439 memory_order m);
440
441template <class T>
442 T*
443 atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op);
444
445template <class T>
446 T*
447 atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op);
448
449template <class T>
450 T*
451 atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
452 memory_order m);
453template <class T>
454 T*
455 atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
456
457template <class T>
458 T*
459 atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op);
460
461template <class T>
462 T*
463 atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op);
464
465template <class T>
466 T*
467 atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
468 memory_order m);
469template <class T>
470 T*
471 atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
472
473// Atomics for standard typedef types
474
475typedef atomic<char> atomic_char;
476typedef atomic<signed char> atomic_schar;
477typedef atomic<unsigned char> atomic_uchar;
478typedef atomic<short> atomic_short;
479typedef atomic<unsigned short> atomic_ushort;
480typedef atomic<int> atomic_int;
481typedef atomic<unsigned int> atomic_uint;
482typedef atomic<long> atomic_long;
483typedef atomic<unsigned long> atomic_ulong;
484typedef atomic<long long> atomic_llong;
485typedef atomic<unsigned long long> atomic_ullong;
486typedef atomic<char16_t> atomic_char16_t;
487typedef atomic<char32_t> atomic_char32_t;
488typedef atomic<wchar_t> atomic_wchar_t;
489
490typedef atomic<int_least8_t> atomic_int_least8_t;
491typedef atomic<uint_least8_t> atomic_uint_least8_t;
492typedef atomic<int_least16_t> atomic_int_least16_t;
493typedef atomic<uint_least16_t> atomic_uint_least16_t;
494typedef atomic<int_least32_t> atomic_int_least32_t;
495typedef atomic<uint_least32_t> atomic_uint_least32_t;
496typedef atomic<int_least64_t> atomic_int_least64_t;
497typedef atomic<uint_least64_t> atomic_uint_least64_t;
498
499typedef atomic<int_fast8_t> atomic_int_fast8_t;
500typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
501typedef atomic<int_fast16_t> atomic_int_fast16_t;
502typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
503typedef atomic<int_fast32_t> atomic_int_fast32_t;
504typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
505typedef atomic<int_fast64_t> atomic_int_fast64_t;
506typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
507
508typedef atomic<intptr_t> atomic_intptr_t;
509typedef atomic<uintptr_t> atomic_uintptr_t;
510typedef atomic<size_t> atomic_size_t;
511typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
512typedef atomic<intmax_t> atomic_intmax_t;
513typedef atomic<uintmax_t> atomic_uintmax_t;
514
Howard Hinnant8f73c632010-09-27 21:17:38 +0000515// fences
516
Howard Hinnant4777bf22010-12-06 23:10:08 +0000517void atomic_thread_fence(memory_order m);
518void atomic_signal_fence(memory_order m);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000519
520} // std
521
522*/
523
524#include <__config>
Howard Hinnant4777bf22010-12-06 23:10:08 +0000525#include <cstddef>
526#include <cstdint>
527#include <type_traits>
Howard Hinnant8f73c632010-09-27 21:17:38 +0000528
529#pragma GCC system_header
530
Howard Hinnant4777bf22010-12-06 23:10:08 +0000531//// Begin Temporary Intrinsics ////
532
533template <class _Tp>
534inline _LIBCPP_INLINE_VISIBILITY
535bool
536__atomic_is_lock_free(_Tp)
537{
538 return false;
539}
540
541template <class _Tp>
542inline _LIBCPP_INLINE_VISIBILITY
543_Tp
544__atomic_load(const volatile _Tp* __t, int)
545{
546 return *__t;
547}
548
549template <class _Tp>
550inline _LIBCPP_INLINE_VISIBILITY
551void
552__atomic_store(volatile _Tp* __t, _Tp __d, int)
553{
554 *__t = __d;
555}
556
557template <class _Tp>
558inline _LIBCPP_INLINE_VISIBILITY
559_Tp
560__atomic_exchange(volatile _Tp* __t, _Tp __d, int)
561{
562 _Tp __tmp = *__t;
563 *__t = __d;
564 return __tmp;
565}
566
567template <class _Tp>
568inline _LIBCPP_INLINE_VISIBILITY
569bool
570__atomic_compare_exchange_strong(volatile _Tp* __o, _Tp* __e, _Tp __d, int, int)
571{
572 if (const_cast<_Tp&>(*__o) == *__e)
573 {
574 *__o = __d;
575 return true;
576 }
577 *__e = __d;
578 return false;
579}
580
581template <class _Tp>
582inline _LIBCPP_INLINE_VISIBILITY
583bool
584__atomic_compare_exchange_weak(volatile _Tp* __o, _Tp* __e, _Tp __d, int, int)
585{
586 if (const_cast<_Tp&>(*__o) == *__e)
587 {
588 *__o = __d;
589 return true;
590 }
591 *__e = __d;
592 return false;
593}
594
595//// End Temporary Intrinsics ////
596
Howard Hinnant8f73c632010-09-27 21:17:38 +0000597_LIBCPP_BEGIN_NAMESPACE_STD
598
Howard Hinnantd1176e22010-09-28 17:13:38 +0000599typedef enum memory_order
600{
601 memory_order_relaxed, memory_order_consume, memory_order_acquire,
602 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
603} memory_order;
604
605template <class _Tp>
606inline _LIBCPP_INLINE_VISIBILITY
607_Tp
608kill_dependency(_Tp __y)
609{
610 return __y;
611}
Howard Hinnant8f73c632010-09-27 21:17:38 +0000612
Howard Hinnant4777bf22010-12-06 23:10:08 +0000613template <class T> struct atomic;
614
615// atomic_is_lock_free
616
617template <class _Tp>
618inline _LIBCPP_INLINE_VISIBILITY
619bool
620atomic_is_lock_free(const volatile atomic<_Tp>*)
621{
622 return __atomic_is_lock_free(_Tp());
623}
624
625template <class _Tp>
626inline _LIBCPP_INLINE_VISIBILITY
627bool
628atomic_is_lock_free(const atomic<_Tp>*)
629{
630 return __atomic_is_lock_free(_Tp());
631}
632
633// atomic_init
634
635template <class _Tp>
636inline _LIBCPP_INLINE_VISIBILITY
637void
638atomic_init(volatile atomic<_Tp>* __o, _Tp __d)
639{
640 __o->__a_ = __d;
641}
642
643template <class _Tp>
644inline _LIBCPP_INLINE_VISIBILITY
645void
646atomic_init(atomic<_Tp>* __o, _Tp __d)
647{
648 __o->__a_ = __d;
649}
650
651// atomic_store
652
653template <class _Tp>
654inline _LIBCPP_INLINE_VISIBILITY
655void
656atomic_store(volatile atomic<_Tp>* __o, _Tp __d)
657{
658 __atomic_store(&__o->__a_, __d, memory_order_seq_cst);
659}
660
661template <class _Tp>
662inline _LIBCPP_INLINE_VISIBILITY
663void
664atomic_store(atomic<_Tp>* __o, _Tp __d)
665{
666 __atomic_store(&__o->__a_, __d, memory_order_seq_cst);
667}
668
669// atomic_store_explicit
670
671template <class _Tp>
672inline _LIBCPP_INLINE_VISIBILITY
673void
674atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m)
675{
676 __atomic_store(&__o->__a_, __d, __m);
677}
678
679template <class _Tp>
680inline _LIBCPP_INLINE_VISIBILITY
681void
682atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m)
683{
684 __atomic_store(&__o->__a_, __d, __m);
685}
686
687// atomic_load
688
689template <class _Tp>
690inline _LIBCPP_INLINE_VISIBILITY
691_Tp
692atomic_load(const volatile atomic<_Tp>* __o)
693{
694 return __atomic_load(&__o->__a_, memory_order_seq_cst);
695}
696
697template <class _Tp>
698inline _LIBCPP_INLINE_VISIBILITY
699_Tp
700atomic_load(const atomic<_Tp>* __o)
701{
702 return __atomic_load(&__o->__a_, memory_order_seq_cst);
703}
704
705// atomic_load_explicit
706
707template <class _Tp>
708inline _LIBCPP_INLINE_VISIBILITY
709_Tp
710atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m)
711{
712 return __atomic_load(&__o->__a_, __m);
713}
714
715template <class _Tp>
716inline _LIBCPP_INLINE_VISIBILITY
717_Tp
718atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m)
719{
720 return __atomic_load(&__o->__a_, __m);
721}
722
723// atomic_exchange
724
725template <class _Tp>
726inline _LIBCPP_INLINE_VISIBILITY
727_Tp
728atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d)
729{
730 return __atomic_exchange(&__o->__a_, __d, memory_order_seq_cst);
731}
732
733template <class _Tp>
734inline _LIBCPP_INLINE_VISIBILITY
735_Tp
736atomic_exchange(atomic<_Tp>* __o, _Tp __d)
737{
738 return __atomic_exchange(&__o->__a_, __d, memory_order_seq_cst);
739}
740
741// atomic_exchange_explicit
742
743template <class _Tp>
744inline _LIBCPP_INLINE_VISIBILITY
745_Tp
746atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m)
747{
748 return __atomic_exchange(&__o->__a_, __d, __m);
749}
750
751template <class _Tp>
752inline _LIBCPP_INLINE_VISIBILITY
753_Tp
754atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m)
755{
756 return __atomic_exchange(&__o->__a_, __d, __m);
757}
758
759// atomic_compare_exchange_weak
760
761template <class _Tp>
762inline _LIBCPP_INLINE_VISIBILITY
763bool
764atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d)
765{
766 return __atomic_compare_exchange_weak(&__o->__a_, __e, __d,
767 memory_order_seq_cst,
768 memory_order_seq_cst);
769}
770
771template <class _Tp>
772inline _LIBCPP_INLINE_VISIBILITY
773bool
774atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d)
775{
776 return __atomic_compare_exchange_weak(&__o->__a_, __e, __d,
777 memory_order_seq_cst,
778 memory_order_seq_cst);
779}
780
781// atomic_compare_exchange_strong
782
783template <class _Tp>
784inline _LIBCPP_INLINE_VISIBILITY
785bool
786atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d)
787{
788 return __atomic_compare_exchange_strong(&__o->__a_, __e, __d,
789 memory_order_seq_cst,
790 memory_order_seq_cst);
791}
792
793template <class _Tp>
794inline _LIBCPP_INLINE_VISIBILITY
795bool
796atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d)
797{
798 return __atomic_compare_exchange_strong(&__o->__a_, __e, __d,
799 memory_order_seq_cst,
800 memory_order_seq_cst);
801}
802
803// atomic_compare_exchange_weak_explicit
804
805template <class _Tp>
806inline _LIBCPP_INLINE_VISIBILITY
807bool
808atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
809 _Tp __d,
810 memory_order __s, memory_order __f)
811{
812 return __atomic_compare_exchange_weak(&__o->__a_, __e, __d, __s, __f);
813}
814
815template <class _Tp>
816inline _LIBCPP_INLINE_VISIBILITY
817bool
818atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
819 memory_order __s, memory_order __f)
820{
821 return __atomic_compare_exchange_weak(&__o->__a_, __e, __d, __s, __f);
822}
823
824// atomic_compare_exchange_strong_explicit
825
826template <class _Tp>
827inline _LIBCPP_INLINE_VISIBILITY
828bool
829atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
830 _Tp* __e, _Tp __d,
831 memory_order __s, memory_order __f)
832{
833 return __atomic_compare_exchange_strong(&__o->__a_, __e, __d, __s, __f);
834}
835
836template <class _Tp>
837inline _LIBCPP_INLINE_VISIBILITY
838bool
839atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
840 _Tp __d,
841 memory_order __s, memory_order __f)
842{
843 return __atomic_compare_exchange_strong(&__o->__a_, __e, __d, __s, __f);
844}
845
846
847// atomic<T>
848
849template <class _Tp>
850struct atomic
851{
852 _Tp __a_;
853
854 bool is_lock_free() const volatile;
855 bool is_lock_free() const;
856 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile;
857 void store(_Tp __d, memory_order __m = memory_order_seq_cst);
858 _LIBCPP_INLINE_VISIBILITY
859 _Tp load(memory_order __m = memory_order_seq_cst) const volatile
860 {return atomic_load_explicit(this, __m);}
861 _LIBCPP_INLINE_VISIBILITY
862 _Tp load(memory_order __m = memory_order_seq_cst) const
863 {return atomic_load_explicit(this, __m);}
864 _LIBCPP_INLINE_VISIBILITY
865 operator _Tp() const volatile {return load();}
866 _LIBCPP_INLINE_VISIBILITY
867 operator _Tp() const {return load();}
868 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile;
869 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst);
870 bool compare_exchange_weak(_Tp& __e, _Tp __d,
871 memory_order __s, memory_order __f) volatile;
872 bool compare_exchange_weak(_Tp& __e, _Tp __d,
873 memory_order __s, memory_order __f);
874 bool compare_exchange_strong(_Tp& __e, _Tp __d,
875 memory_order __s, memory_order __f) volatile;
876 bool compare_exchange_strong(_Tp& __e, _Tp __d,
877 memory_order __s, memory_order __f);
878 bool compare_exchange_weak(_Tp& __e, _Tp __d,
879 memory_order __m = memory_order_seq_cst) volatile;
880 bool compare_exchange_weak(_Tp& __e, _Tp __d,
881 memory_order __m = memory_order_seq_cst);
882 bool compare_exchange_strong(_Tp& __e, _Tp __d,
883 memory_order __m = memory_order_seq_cst) volatile;
884 bool compare_exchange_strong(_Tp& __e, _Tp __d,
885 memory_order __m = memory_order_seq_cst);
886
887 atomic() {} // = default;
888 constexpr atomic(_Tp __d);
889 atomic(const atomic&) = delete;
890 atomic& operator=(const atomic&) = delete;
891 atomic& operator=(const atomic&) volatile = delete;
892 _Tp operator=(_Tp) volatile;
893 _Tp operator=(_Tp);
894};
895
896/*
Howard Hinnanted760f42010-09-29 18:13:54 +0000897// flag type and operations
898
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000899typedef bool __atomic_flag__;
Howard Hinnant6cac2c22010-10-05 14:02:23 +0000900
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000901struct atomic_flag;
Howard Hinnanted760f42010-09-29 18:13:54 +0000902
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000903bool atomic_flag_test_and_set(volatile atomic_flag*);
904bool atomic_flag_test_and_set(atomic_flag*);
905bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
906bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
907void atomic_flag_clear(volatile atomic_flag*);
908void atomic_flag_clear(atomic_flag*);
909void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
910void atomic_flag_clear_explicit(atomic_flag*, memory_order);
911
912typedef struct _LIBCPP_VISIBLE atomic_flag
Howard Hinnanted760f42010-09-29 18:13:54 +0000913{
Howard Hinnant6cac2c22010-10-05 14:02:23 +0000914 __atomic_flag__ __flg_;
Howard Hinnanted760f42010-09-29 18:13:54 +0000915
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000916 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000917 bool test_and_set(memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000918 {return atomic_flag_test_and_set_explicit(this, __o);}
919 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000920 bool test_and_set(memory_order __o = memory_order_seq_cst)
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000921 {return atomic_flag_test_and_set_explicit(this, __o);}
Howard Hinnanted760f42010-09-29 18:13:54 +0000922
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000923 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000924 void clear(memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000925 {atomic_flag_clear_explicit(this, __o);}
926 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000927 void clear(memory_order __o = memory_order_seq_cst)
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000928 {atomic_flag_clear_explicit(this, __o);}
Howard Hinnanted760f42010-09-29 18:13:54 +0000929
930#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
931 atomic_flag() = default;
932#else
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000933 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant79101ae2010-09-30 21:05:29 +0000934 atomic_flag() {};
Howard Hinnanted760f42010-09-29 18:13:54 +0000935#endif
936
Howard Hinnanted760f42010-09-29 18:13:54 +0000937#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
938 atomic_flag(const atomic_flag&) = delete;
939 atomic_flag& operator=(const atomic_flag&) = delete;
940 atomic_flag& operator=(const atomic_flag&) volatile = delete;
941#else
942private:
943 atomic_flag(const atomic_flag&);
944 atomic_flag& operator=(const atomic_flag&);
945 atomic_flag& operator=(const atomic_flag&) volatile;
946public:
947#endif
Howard Hinnanted760f42010-09-29 18:13:54 +0000948} atomic_flag;
949
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000950inline _LIBCPP_INLINE_VISIBILITY
951bool
952atomic_flag_test_and_set(volatile atomic_flag* __f)
953{
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000954 return __atomic_exchange(&__f->__flg_, __atomic_flag__(true),
955 memory_order_seq_cst)
Howard Hinnant6cac2c22010-10-05 14:02:23 +0000956 == __atomic_flag__(true);
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000957}
Howard Hinnanted760f42010-09-29 18:13:54 +0000958
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000959inline _LIBCPP_INLINE_VISIBILITY
960bool
961atomic_flag_test_and_set(atomic_flag* __f)
962{
963 return atomic_flag_test_and_set(const_cast<volatile atomic_flag*>(__f));
964}
965
966inline _LIBCPP_INLINE_VISIBILITY
967bool
968atomic_flag_test_and_set_explicit(volatile atomic_flag* __f, memory_order __o)
969{
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000970 return __atomic_exchange(&__f->__flg_, __atomic_flag__(true), __o)
Howard Hinnant6cac2c22010-10-05 14:02:23 +0000971 == __atomic_flag__(true);
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000972}
973
974inline _LIBCPP_INLINE_VISIBILITY
975bool
976atomic_flag_test_and_set_explicit(atomic_flag* __f, memory_order __o)
977{
Howard Hinnant611fdaf2010-10-04 18:52:54 +0000978 return atomic_flag_test_and_set_explicit(const_cast<volatile atomic_flag*>
979 (__f), __o);
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000980}
981
982inline _LIBCPP_INLINE_VISIBILITY
983void
984atomic_flag_clear(volatile atomic_flag* __f)
985{
Howard Hinnant21ef47f2010-10-18 20:39:07 +0000986 __atomic_store(&__f->__flg_, __atomic_flag__(false), memory_order_seq_cst);
Howard Hinnant767ae2b2010-09-29 21:20:03 +0000987}
988
989inline _LIBCPP_INLINE_VISIBILITY
990void
991atomic_flag_clear(atomic_flag* __f)
992{
993 atomic_flag_clear(const_cast<volatile atomic_flag*>(__f));
994}
995
996inline _LIBCPP_INLINE_VISIBILITY
997void
998atomic_flag_clear_explicit(volatile atomic_flag* __f, memory_order __o)
999{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001000 __atomic_store(&__f->__flg_, __atomic_flag__(false), __o);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00001001}
1002
1003inline _LIBCPP_INLINE_VISIBILITY
1004void
1005atomic_flag_clear_explicit(atomic_flag* __f, memory_order __o)
1006{
1007 atomic_flag_clear_explicit(const_cast<volatile atomic_flag*>(__f), __o);
1008}
1009
1010#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001011#define ATOMIC_VAR_INIT(__v) {__v}
1012
1013inline _LIBCPP_INLINE_VISIBILITY
1014memory_order
1015__translate_memory_order(memory_order __o)
1016{
1017 switch (__o)
1018 {
1019 case memory_order_acq_rel:
1020 return memory_order_acquire;
1021 case memory_order_release:
1022 return memory_order_relaxed;
1023 }
1024 return __o;
1025}
1026
1027// atomic_bool
1028
1029struct atomic_bool;
1030
1031bool atomic_is_lock_free(const volatile atomic_bool*);
1032bool atomic_is_lock_free(const atomic_bool*);
1033void atomic_init(volatile atomic_bool*, bool);
1034void atomic_init(atomic_bool*, bool);
1035void atomic_store(volatile atomic_bool*, bool);
1036void atomic_store(atomic_bool*, bool);
1037void atomic_store_explicit(volatile atomic_bool*, bool, memory_order);
1038void atomic_store_explicit(atomic_bool*, bool, memory_order);
1039bool atomic_load(const volatile atomic_bool*);
1040bool atomic_load(const atomic_bool*);
1041bool atomic_load_explicit(const volatile atomic_bool*, memory_order);
1042bool atomic_load_explicit(const atomic_bool*, memory_order);
1043bool atomic_exchange(volatile atomic_bool*, bool);
1044bool atomic_exchange(atomic_bool*, bool);
1045bool atomic_exchange_explicit(volatile atomic_bool*, bool, memory_order);
1046bool atomic_exchange_explicit(atomic_bool*, bool, memory_order);
1047bool atomic_compare_exchange_weak(volatile atomic_bool*, bool*, bool);
1048bool atomic_compare_exchange_weak(atomic_bool*, bool*, bool);
1049bool atomic_compare_exchange_strong(volatile atomic_bool*, bool*, bool);
1050bool atomic_compare_exchange_strong(atomic_bool*, bool*, bool);
1051bool atomic_compare_exchange_weak_explicit(volatile atomic_bool*, bool*, bool,
1052 memory_order, memory_order);
1053bool atomic_compare_exchange_weak_explicit(atomic_bool*, bool*, bool,
1054 memory_order, memory_order);
1055bool atomic_compare_exchange_strong_explicit(volatile atomic_bool*, bool*, bool,
1056 memory_order, memory_order);
1057bool atomic_compare_exchange_strong_explicit(atomic_bool*, bool*, bool,
1058 memory_order, memory_order);
1059
1060typedef struct atomic_bool
1061{
1062 bool __v_;
1063
1064 _LIBCPP_INLINE_VISIBILITY
1065 bool is_lock_free() const volatile
1066 {return atomic_is_lock_free(this);}
1067 _LIBCPP_INLINE_VISIBILITY
1068 bool is_lock_free() const
1069 {return atomic_is_lock_free(this);}
1070 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001071 void store(bool __v, memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001072 {atomic_store_explicit(this, __v, __o);}
1073 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001074 void store(bool __v, memory_order __o = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001075 {atomic_store_explicit(this, __v, __o);}
1076 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001077 bool load(memory_order __o = memory_order_seq_cst) const volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001078 {return atomic_load_explicit(this, __o);}
1079 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001080 bool load(memory_order __o = memory_order_seq_cst) const
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001081 {return atomic_load_explicit(this, __o);}
1082 _LIBCPP_INLINE_VISIBILITY
1083 operator bool() const volatile
1084 {return load();}
1085 _LIBCPP_INLINE_VISIBILITY
1086 operator bool() const
1087 {return load();}
1088 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001089 bool exchange(bool __v, memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001090 {return atomic_exchange_explicit(this, __v, __o);}
1091 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001092 bool exchange(bool __v, memory_order __o = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001093 {return atomic_exchange_explicit(this, __v, __o);}
1094 _LIBCPP_INLINE_VISIBILITY
1095 bool compare_exchange_weak(bool& __v, bool __e, memory_order __s,
1096 memory_order __f) volatile
1097 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1098 __f);}
1099 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001100 bool compare_exchange_weak(bool& __v, bool __e,
1101 memory_order __s = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001102 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001103 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001104 _LIBCPP_INLINE_VISIBILITY
1105 bool compare_exchange_weak(bool& __v, bool __e, memory_order __s,
1106 memory_order __f)
1107 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1108 __f);}
1109 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001110 bool compare_exchange_weak(bool& __v, bool __e,
1111 memory_order __s = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001112 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001113 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001114 _LIBCPP_INLINE_VISIBILITY
1115 bool compare_exchange_strong(bool& __v, bool __e, memory_order __s,
1116 memory_order __f) volatile
1117 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1118 __f);}
1119 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001120 bool compare_exchange_strong(bool& __v, bool __e,
1121 memory_order __s = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001122 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001123 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001124 _LIBCPP_INLINE_VISIBILITY
1125 bool compare_exchange_strong(bool& __v, bool __e, memory_order __s,
1126 memory_order __f)
1127 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1128 __f);}
1129 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001130 bool compare_exchange_strong(bool& __v, bool __e,
1131 memory_order __s = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001132 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001133 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001134#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
1135 atomic_bool() = default;
1136#else
1137 _LIBCPP_INLINE_VISIBILITY
1138 atomic_bool() {}
1139#endif
1140 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00001141 constexpr atomic_bool(bool __v)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001142 : __v_(__v) {}
1143#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1144 atomic_bool(const atomic_bool&) = delete;
1145 atomic_bool& operator=(const atomic_bool&) = delete;
1146 atomic_bool& operator=(const atomic_bool&) volatile = delete;
1147#else
1148private:
1149 atomic_bool(const atomic_bool&);
1150 atomic_bool& operator=(const atomic_bool&);
1151 atomic_bool& operator=(const atomic_bool&) volatile;
1152public:
1153#endif
1154 _LIBCPP_INLINE_VISIBILITY
1155 bool operator=(bool __v) volatile
1156 {store(__v); return __v;}
Howard Hinnante7385012010-10-19 16:51:18 +00001157 _LIBCPP_INLINE_VISIBILITY
1158 bool operator=(bool __v)
1159 {store(__v); return __v;}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001160} atomic_bool;
1161
1162inline _LIBCPP_INLINE_VISIBILITY
1163bool atomic_is_lock_free(const volatile atomic_bool*)
1164{
Howard Hinnante7385012010-10-19 16:51:18 +00001165 typedef bool type;
1166 return __atomic_is_lock_free(type);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001167}
1168
1169inline _LIBCPP_INLINE_VISIBILITY
1170bool atomic_is_lock_free(const atomic_bool* __obj)
1171{
1172 return atomic_is_lock_free(const_cast<const volatile atomic_bool*>(__obj));
1173}
1174
1175inline _LIBCPP_INLINE_VISIBILITY
1176void atomic_init(volatile atomic_bool* __obj, bool __desr)
1177{
1178 __obj->__v_ = __desr;
1179}
1180
1181inline _LIBCPP_INLINE_VISIBILITY
1182void atomic_init(atomic_bool* __obj, bool __desr)
1183{
1184 __obj->__v_ = __desr;
1185}
1186
1187inline _LIBCPP_INLINE_VISIBILITY
1188void atomic_store(volatile atomic_bool* __obj, bool __desr)
1189{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001190 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001191}
1192
1193inline _LIBCPP_INLINE_VISIBILITY
1194void atomic_store(atomic_bool* __obj, bool __desr)
1195{
1196 atomic_store(const_cast<volatile atomic_bool*>(__obj), __desr);
1197}
1198
1199inline _LIBCPP_INLINE_VISIBILITY
1200void atomic_store_explicit(volatile atomic_bool* __obj, bool __desr,
1201 memory_order __o)
1202{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001203 __atomic_store(&__obj->__v_, __desr, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001204}
1205
1206inline _LIBCPP_INLINE_VISIBILITY
1207void atomic_store_explicit(atomic_bool* __obj, bool __desr, memory_order __o)
1208{
1209 atomic_store_explicit(const_cast<volatile atomic_bool*>(__obj), __desr,
1210 __o);
1211}
1212
1213inline _LIBCPP_INLINE_VISIBILITY
1214bool atomic_load(const volatile atomic_bool* __obj)
1215{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001216 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001217}
1218
1219inline _LIBCPP_INLINE_VISIBILITY
1220bool atomic_load(const atomic_bool* __obj)
1221{
1222 return atomic_load(const_cast<const volatile atomic_bool*>(__obj));
1223}
1224
1225inline _LIBCPP_INLINE_VISIBILITY
1226bool atomic_load_explicit(const volatile atomic_bool* __obj, memory_order __o)
1227{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001228 return __atomic_load(&__obj->__v_, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001229}
1230
1231inline _LIBCPP_INLINE_VISIBILITY
1232bool atomic_load_explicit(const atomic_bool* __obj, memory_order __o)
1233{
1234 return atomic_load_explicit(const_cast<const volatile atomic_bool*>
1235 (__obj), __o);
1236}
1237
1238inline _LIBCPP_INLINE_VISIBILITY
1239bool atomic_exchange(volatile atomic_bool* __obj, bool __desr)
1240{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001241 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001242}
1243
1244inline _LIBCPP_INLINE_VISIBILITY
1245bool atomic_exchange(atomic_bool* __obj, bool __desr)
1246{
1247 return atomic_exchange(const_cast<volatile atomic_bool*>(__obj), __desr);
1248}
1249
1250inline _LIBCPP_INLINE_VISIBILITY
1251bool atomic_exchange_explicit(volatile atomic_bool* __obj, bool __desr,
1252 memory_order __o)
1253{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001254 return __atomic_exchange(&__obj->__v_, __desr, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001255}
1256
1257inline _LIBCPP_INLINE_VISIBILITY
1258bool atomic_exchange_explicit(atomic_bool* __obj, bool __desr, memory_order __o)
1259{
1260 return atomic_exchange_explicit(const_cast<volatile atomic_bool*>
1261 (__obj), __desr, __o);
1262}
1263
1264inline _LIBCPP_INLINE_VISIBILITY
1265bool atomic_compare_exchange_weak(volatile atomic_bool* __obj, bool* __exp,
1266 bool __desr)
1267{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001268 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
1269 memory_order_seq_cst, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001270}
1271
1272inline _LIBCPP_INLINE_VISIBILITY
1273bool atomic_compare_exchange_weak(atomic_bool* __obj, bool* __exp, bool __desr)
1274{
1275 return atomic_compare_exchange_weak(const_cast<volatile atomic_bool*>
1276 (__obj), __exp, __desr);
1277}
1278
1279inline _LIBCPP_INLINE_VISIBILITY
1280bool atomic_compare_exchange_weak_explicit(volatile atomic_bool* __obj,
1281 bool* __exp, bool __desr,
1282 memory_order __s, memory_order __f)
1283{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001284 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
1285 __f);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001286}
1287
1288inline _LIBCPP_INLINE_VISIBILITY
1289bool atomic_compare_exchange_weak_explicit(atomic_bool* __obj, bool* __exp,
1290 bool __desr,
1291 memory_order __s, memory_order __f)
1292{
1293 return atomic_compare_exchange_weak_explicit(
1294 const_cast<volatile atomic_bool*>(__obj), __exp, __desr, __s, __f);
1295}
1296
1297inline _LIBCPP_INLINE_VISIBILITY
1298bool atomic_compare_exchange_strong(volatile atomic_bool* __obj, bool* __exp,
1299 bool __desr)
1300{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001301 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
1302 memory_order_seq_cst, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001303}
1304
1305inline _LIBCPP_INLINE_VISIBILITY
1306bool atomic_compare_exchange_strong(atomic_bool* __obj, bool* __exp,
1307 bool __desr)
1308{
1309 return atomic_compare_exchange_strong(const_cast<volatile atomic_bool*>
1310 (__obj), __exp, __desr);
1311}
1312
1313inline _LIBCPP_INLINE_VISIBILITY
1314bool atomic_compare_exchange_strong_explicit(volatile atomic_bool* __obj,
1315 bool* __exp, bool __desr,
1316 memory_order __s, memory_order __f)
1317{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00001318 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
1319 __f);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00001320}
1321
1322inline _LIBCPP_INLINE_VISIBILITY
1323bool atomic_compare_exchange_strong_explicit(atomic_bool* __obj, bool* __exp,
1324 bool __desr,
1325 memory_order __s, memory_order __f)
1326{
1327 return atomic_compare_exchange_strong_explicit(
1328 const_cast<volatile atomic_bool*>(__obj), __exp, __desr, __s, __f);
1329}
Howard Hinnanted760f42010-09-29 18:13:54 +00001330
Howard Hinnante7385012010-10-19 16:51:18 +00001331// atomic_char
1332
1333struct atomic_char;
1334
1335bool atomic_is_lock_free(const volatile atomic_char*);
1336bool atomic_is_lock_free(const atomic_char*);
1337void atomic_init(volatile atomic_char*, char);
1338void atomic_init(atomic_char*, char);
1339void atomic_store(volatile atomic_char*, char);
1340void atomic_store(atomic_char*, char);
1341void atomic_store_explicit(volatile atomic_char*, char, memory_order);
1342void atomic_store_explicit(atomic_char*, char, memory_order);
1343char atomic_load(const volatile atomic_char*);
1344char atomic_load(const atomic_char*);
1345char atomic_load_explicit(const volatile atomic_char*, memory_order);
1346char atomic_load_explicit(const atomic_char*, memory_order);
1347char atomic_exchange(volatile atomic_char*, char);
1348char atomic_exchange(atomic_char*, char);
1349char atomic_exchange_explicit(volatile atomic_char*, char, memory_order);
1350char atomic_exchange_explicit(atomic_char*, char, memory_order);
1351bool atomic_compare_exchange_weak(volatile atomic_char*, char*, char);
1352bool atomic_compare_exchange_weak(atomic_char*, char*, char);
1353bool atomic_compare_exchange_strong(volatile atomic_char*, char*, char);
1354bool atomic_compare_exchange_strong(atomic_char*, char*, char);
1355bool atomic_compare_exchange_weak_explicit(volatile atomic_char*, char*, char,
1356 memory_order, memory_order);
1357bool atomic_compare_exchange_weak_explicit(atomic_char*, char*, char,
1358 memory_order, memory_order);
1359bool atomic_compare_exchange_strong_explicit(volatile atomic_char*, char*, char,
1360 memory_order, memory_order);
1361bool atomic_compare_exchange_strong_explicit(atomic_char*, char*, char,
1362 memory_order, memory_order);
1363char atomic_fetch_add(volatile atomic_char*, char);
1364char atomic_fetch_add(atomic_char*, char);
1365char atomic_fetch_add_explicit(volatile atomic_char*, char, memory_order);
1366char atomic_fetch_add_explicit(atomic_char*, char, memory_order);
1367char atomic_fetch_sub(volatile atomic_char*, char);
1368char atomic_fetch_sub(atomic_char*, char);
1369char atomic_fetch_sub_explicit(volatile atomic_char*, char, memory_order);
1370char atomic_fetch_sub_explicit(atomic_char*, char, memory_order);
1371char atomic_fetch_and(volatile atomic_char*, char);
1372char atomic_fetch_and(atomic_char*, char);
1373char atomic_fetch_and_explicit(volatile atomic_char*, char, memory_order);
1374char atomic_fetch_and_explicit(atomic_char*, char, memory_order);
1375char atomic_fetch_or(volatile atomic_char*, char);
1376char atomic_fetch_or(atomic_char*, char);
1377char atomic_fetch_or_explicit(volatile atomic_char*, char, memory_order);
1378char atomic_fetch_or_explicit(atomic_char*, char, memory_order);
1379char atomic_fetch_xor(volatile atomic_char*, char);
1380char atomic_fetch_xor(atomic_char*, char);
1381char atomic_fetch_xor_explicit(volatile atomic_char*, char, memory_order);
1382char atomic_fetch_xor_explicit(atomic_char*, char, memory_order);
1383
1384typedef struct atomic_char
1385{
1386 char __v_;
1387
1388 _LIBCPP_INLINE_VISIBILITY
1389 bool is_lock_free() const volatile
1390 {return atomic_is_lock_free(this);}
1391 _LIBCPP_INLINE_VISIBILITY
1392 bool is_lock_free() const
1393 {return atomic_is_lock_free(this);}
1394 _LIBCPP_INLINE_VISIBILITY
1395 void store(char __v, memory_order __o = memory_order_seq_cst) volatile
1396 {atomic_store_explicit(this, __v, __o);}
1397 _LIBCPP_INLINE_VISIBILITY
1398 void store(char __v, memory_order __o = memory_order_seq_cst)
1399 {atomic_store_explicit(this, __v, __o);}
1400 _LIBCPP_INLINE_VISIBILITY
1401 char load(memory_order __o = memory_order_seq_cst) const volatile
1402 {return atomic_load_explicit(this, __o);}
1403 _LIBCPP_INLINE_VISIBILITY
1404 char load(memory_order __o = memory_order_seq_cst) const
1405 {return atomic_load_explicit(this, __o);}
1406 _LIBCPP_INLINE_VISIBILITY
1407 operator char() const volatile
1408 {return load();}
1409 _LIBCPP_INLINE_VISIBILITY
1410 operator char() const
1411 {return load();}
1412 _LIBCPP_INLINE_VISIBILITY
1413 char exchange(char __v, memory_order __o = memory_order_seq_cst) volatile
1414 {return atomic_exchange_explicit(this, __v, __o);}
1415 _LIBCPP_INLINE_VISIBILITY
1416 char exchange(char __v, memory_order __o = memory_order_seq_cst)
1417 {return atomic_exchange_explicit(this, __v, __o);}
1418 _LIBCPP_INLINE_VISIBILITY
1419 bool compare_exchange_weak(char& __v, char __e, memory_order __s,
1420 memory_order __f) volatile
1421 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1422 __f);}
1423 _LIBCPP_INLINE_VISIBILITY
1424 bool compare_exchange_weak(char& __v, char __e, memory_order __s,
1425 memory_order __f)
1426 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1427 __f);}
1428 _LIBCPP_INLINE_VISIBILITY
1429 bool compare_exchange_strong(char& __v, char __e, memory_order __s,
1430 memory_order __f) volatile
1431 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1432 __f);}
1433 _LIBCPP_INLINE_VISIBILITY
1434 bool compare_exchange_strong(char& __v, char __e, memory_order __s,
1435 memory_order __f)
1436 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1437 __f);}
1438 _LIBCPP_INLINE_VISIBILITY
1439 bool compare_exchange_weak(char& __v, char __e,
1440 memory_order __s = memory_order_seq_cst) volatile
1441 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1442 __translate_memory_order(__s));}
1443 _LIBCPP_INLINE_VISIBILITY
1444 bool compare_exchange_weak(char& __v, char __e,
1445 memory_order __s = memory_order_seq_cst)
1446 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
1447 __translate_memory_order(__s));}
1448 _LIBCPP_INLINE_VISIBILITY
1449 bool compare_exchange_strong(char& __v, char __e,
1450 memory_order __s = memory_order_seq_cst) volatile
1451 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1452 __translate_memory_order(__s));}
1453 _LIBCPP_INLINE_VISIBILITY
1454 bool compare_exchange_strong(char& __v, char __e,
1455 memory_order __s = memory_order_seq_cst)
1456 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
1457 __translate_memory_order(__s));}
1458 _LIBCPP_INLINE_VISIBILITY
1459 char fetch_add(char __v, memory_order __o = memory_order_seq_cst) volatile
1460 {return atomic_fetch_add_explicit(this, __v, __o);}
1461 _LIBCPP_INLINE_VISIBILITY
1462 char fetch_add(char __v, memory_order __o = memory_order_seq_cst)
1463 {return atomic_fetch_add_explicit(this, __v, __o);}
1464 _LIBCPP_INLINE_VISIBILITY
1465 char fetch_sub(char __v, memory_order __o = memory_order_seq_cst) volatile
1466 {return atomic_fetch_sub_explicit(this, __v, __o);}
1467 _LIBCPP_INLINE_VISIBILITY
1468 char fetch_sub(char __v, memory_order __o = memory_order_seq_cst)
1469 {return atomic_fetch_sub_explicit(this, __v, __o);}
1470 _LIBCPP_INLINE_VISIBILITY
1471 char fetch_and(char __v, memory_order __o = memory_order_seq_cst) volatile
1472 {return atomic_fetch_and_explicit(this, __v, __o);}
1473 _LIBCPP_INLINE_VISIBILITY
1474 char fetch_and(char __v, memory_order __o = memory_order_seq_cst)
1475 {return atomic_fetch_and_explicit(this, __v, __o);}
1476 _LIBCPP_INLINE_VISIBILITY
1477 char fetch_or(char __v, memory_order __o = memory_order_seq_cst) volatile
1478 {return atomic_fetch_or_explicit(this, __v, __o);}
1479 _LIBCPP_INLINE_VISIBILITY
1480 char fetch_or(char __v, memory_order __o = memory_order_seq_cst)
1481 {return atomic_fetch_or_explicit(this, __v, __o);}
1482 _LIBCPP_INLINE_VISIBILITY
1483 char fetch_xor(char __v, memory_order __o = memory_order_seq_cst) volatile
1484 {return atomic_fetch_xor_explicit(this, __v, __o);}
1485 _LIBCPP_INLINE_VISIBILITY
1486 char fetch_xor(char __v, memory_order __o = memory_order_seq_cst)
1487 {return atomic_fetch_xor_explicit(this, __v, __o);}
1488#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
1489 atomic_char() = default;
1490#else
1491 _LIBCPP_INLINE_VISIBILITY
1492 atomic_char() {}
1493#endif
1494 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00001495 constexpr atomic_char(char __v)
Howard Hinnante7385012010-10-19 16:51:18 +00001496 : __v_(__v) {}
1497#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1498 atomic_char(const atomic_char&) = delete;
1499 atomic_char& operator=(const atomic_char&) = delete;
1500 atomic_char& operator=(const atomic_char&) volatile = delete;
1501#else
1502private:
1503 atomic_char(const atomic_char&);
1504 atomic_char& operator=(const atomic_char&);
1505 atomic_char& operator=(const atomic_char&) volatile;
1506public:
1507#endif
1508 _LIBCPP_INLINE_VISIBILITY
1509 char operator=(char __v) volatile
1510 {store(__v); return __v;}
1511 _LIBCPP_INLINE_VISIBILITY
1512 char operator=(char __v)
1513 {store(__v); return __v;}
1514 _LIBCPP_INLINE_VISIBILITY
1515 char operator++(int) volatile
1516 {return fetch_add(char(1));}
1517 _LIBCPP_INLINE_VISIBILITY
1518 char operator++(int)
1519 {return fetch_add(char(1));}
1520 _LIBCPP_INLINE_VISIBILITY
1521 char operator--(int) volatile
1522 {return fetch_sub(char(1));}
1523 _LIBCPP_INLINE_VISIBILITY
1524 char operator--(int)
1525 {return fetch_sub(char(1));}
1526 _LIBCPP_INLINE_VISIBILITY
1527 char operator++() volatile
1528 {return char(fetch_add(char(1)) + 1);}
1529 _LIBCPP_INLINE_VISIBILITY
1530 char operator++()
1531 {return char(fetch_add(char(1)) + 1);}
1532 _LIBCPP_INLINE_VISIBILITY
1533 char operator--() volatile
1534 {return char(fetch_sub(char(1)) - 1);}
1535 _LIBCPP_INLINE_VISIBILITY
1536 char operator--()
1537 {return char(fetch_sub(char(1)) - 1);}
1538 _LIBCPP_INLINE_VISIBILITY
1539 char operator+=(char __v) volatile
1540 {return char(fetch_add(__v) + __v);}
1541 _LIBCPP_INLINE_VISIBILITY
1542 char operator+=(char __v)
1543 {return char(fetch_add(__v) + __v);}
1544 _LIBCPP_INLINE_VISIBILITY
1545 char operator-=(char __v) volatile
1546 {return char(fetch_sub(__v) - __v);}
1547 _LIBCPP_INLINE_VISIBILITY
1548 char operator-=(char __v)
1549 {return char(fetch_sub(__v) - __v);}
1550 _LIBCPP_INLINE_VISIBILITY
1551 char operator&=(char __v) volatile
1552 {return char(fetch_and(__v) & __v);}
1553 _LIBCPP_INLINE_VISIBILITY
1554 char operator&=(char __v)
1555 {return char(fetch_and(__v) & __v);}
1556 _LIBCPP_INLINE_VISIBILITY
1557 char operator|=(char __v) volatile
1558 {return char(fetch_or(__v) | __v);}
1559 _LIBCPP_INLINE_VISIBILITY
1560 char operator|=(char __v)
1561 {return char(fetch_or(__v) | __v);}
1562 _LIBCPP_INLINE_VISIBILITY
1563 char operator^=(char __v) volatile
1564 {return char(fetch_xor(__v) ^ __v);}
1565 _LIBCPP_INLINE_VISIBILITY
1566 char operator^=(char __v)
1567 {return char(fetch_xor(__v) ^ __v);}
1568} atomic_char;
1569
1570inline _LIBCPP_INLINE_VISIBILITY
1571bool
1572atomic_is_lock_free(const volatile atomic_char*)
1573{
1574 typedef char type;
1575 return __atomic_is_lock_free(type);
1576}
1577
1578inline _LIBCPP_INLINE_VISIBILITY
1579bool
1580atomic_is_lock_free(const atomic_char* __obj)
1581{
1582 return atomic_is_lock_free(const_cast<volatile atomic_char*>(__obj));
1583}
1584
1585inline _LIBCPP_INLINE_VISIBILITY
1586void
1587atomic_init(volatile atomic_char* __obj, char __desr)
1588{
1589 __obj->__v_ = __desr;
1590}
1591
1592inline _LIBCPP_INLINE_VISIBILITY
1593void
1594atomic_init(atomic_char* __obj, char __desr)
1595{
1596 __obj->__v_ = __desr;
1597}
1598
1599inline _LIBCPP_INLINE_VISIBILITY
1600void
1601atomic_store(volatile atomic_char* __obj, char __desr)
1602{
1603 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
1604}
1605
1606inline _LIBCPP_INLINE_VISIBILITY
1607void
1608atomic_store(atomic_char* __obj, char __desr)
1609{
1610 atomic_store(const_cast<volatile atomic_char*>(__obj), __desr);
1611}
1612
1613inline _LIBCPP_INLINE_VISIBILITY
1614void
1615atomic_store_explicit(volatile atomic_char* __obj, char __desr,
1616 memory_order __o)
1617{
1618 __atomic_store(&__obj->__v_, __desr, __o);
1619}
1620
1621inline _LIBCPP_INLINE_VISIBILITY
1622void
1623atomic_store_explicit(atomic_char* __obj, char __desr, memory_order __o)
1624{
1625 atomic_store_explicit(const_cast<volatile atomic_char*>(__obj), __desr,
1626 __o);
1627}
1628
1629inline _LIBCPP_INLINE_VISIBILITY
1630char
1631atomic_load(const volatile atomic_char* __obj)
1632{
1633 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
1634}
1635
1636inline _LIBCPP_INLINE_VISIBILITY
1637char
1638atomic_load(const atomic_char* __obj)
1639{
1640 return atomic_load(const_cast<const volatile atomic_char*>(__obj));
1641}
1642
1643inline _LIBCPP_INLINE_VISIBILITY
1644char
1645atomic_load_explicit(const volatile atomic_char* __obj, memory_order __o)
1646{
1647 return __atomic_load(&__obj->__v_, __o);
1648}
1649
1650inline _LIBCPP_INLINE_VISIBILITY
1651char
1652atomic_load_explicit(const atomic_char* __obj, memory_order __o)
1653{
1654 return atomic_load_explicit(const_cast<const volatile atomic_char*>
1655 (__obj), __o);
1656}
1657
1658inline _LIBCPP_INLINE_VISIBILITY
1659char
1660atomic_exchange(volatile atomic_char* __obj, char __desr)
1661{
1662 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
1663}
1664
1665inline _LIBCPP_INLINE_VISIBILITY
1666char
1667atomic_exchange(atomic_char* __obj, char __desr)
1668{
1669 return atomic_exchange(const_cast<volatile atomic_char*>(__obj), __desr);
1670}
1671
1672inline _LIBCPP_INLINE_VISIBILITY
1673char
1674atomic_exchange_explicit(volatile atomic_char* __obj, char __desr,
1675 memory_order __o)
1676{
1677 return __atomic_exchange(&__obj->__v_, __desr, __o);
1678}
1679
1680inline _LIBCPP_INLINE_VISIBILITY
1681char
1682atomic_exchange_explicit(atomic_char* __obj, char __desr, memory_order __o)
1683{
1684 return atomic_exchange_explicit(const_cast<volatile atomic_char*>
1685 (__obj), __desr, __o);
1686}
1687
1688inline _LIBCPP_INLINE_VISIBILITY
1689bool
1690atomic_compare_exchange_weak(volatile atomic_char* __obj, char* __exp,
1691 char __desr)
1692{
1693 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
1694 memory_order_seq_cst, memory_order_seq_cst);
1695}
1696
1697inline _LIBCPP_INLINE_VISIBILITY
1698bool
1699atomic_compare_exchange_weak(atomic_char* __obj, char* __exp, char __desr)
1700{
1701 return atomic_compare_exchange_weak(const_cast<volatile atomic_char*>
1702 (__obj), __exp, __desr);
1703}
1704
1705inline _LIBCPP_INLINE_VISIBILITY
1706bool
1707atomic_compare_exchange_strong(volatile atomic_char* __obj, char* __exp,
1708 char __desr)
1709{
1710 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
1711 memory_order_seq_cst, memory_order_seq_cst);
1712}
1713
1714inline _LIBCPP_INLINE_VISIBILITY
1715bool
1716atomic_compare_exchange_strong(atomic_char* __obj, char* __exp, char __desr)
1717{
1718 return atomic_compare_exchange_strong(const_cast<volatile atomic_char*>
1719 (__obj), __exp, __desr);
1720}
1721
1722inline _LIBCPP_INLINE_VISIBILITY
1723bool
1724atomic_compare_exchange_weak_explicit(volatile atomic_char* __obj, char* __exp,
1725 char __desr, memory_order __s,
1726 memory_order __f)
1727{
1728 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
1729 __f);
1730}
1731
1732inline _LIBCPP_INLINE_VISIBILITY
1733bool
1734atomic_compare_exchange_weak_explicit(atomic_char* __obj, char* __exp,
1735 char __desr, memory_order __s,
1736 memory_order __f)
1737{
1738 return atomic_compare_exchange_weak_explicit(
1739 const_cast<volatile atomic_char*>(__obj), __exp, __desr, __s, __f);
1740}
1741
1742inline _LIBCPP_INLINE_VISIBILITY
1743bool
1744atomic_compare_exchange_strong_explicit(volatile atomic_char* __obj,
1745 char* __exp, char __desr,
1746 memory_order __s, memory_order __f)
1747{
1748 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
1749 __f);
1750}
1751
1752inline _LIBCPP_INLINE_VISIBILITY
1753bool
1754atomic_compare_exchange_strong_explicit(atomic_char* __obj, char* __exp,
1755 char __desr, memory_order __s,
1756 memory_order __f)
1757{
1758 return atomic_compare_exchange_strong_explicit(
1759 const_cast<volatile atomic_char*>(__obj), __exp, __desr, __s, __f);
1760}
1761
1762inline _LIBCPP_INLINE_VISIBILITY
1763char
1764atomic_fetch_add(volatile atomic_char* __obj, char __v)
1765{
1766 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
1767}
1768
1769inline _LIBCPP_INLINE_VISIBILITY
1770char
1771atomic_fetch_add(atomic_char* __obj, char __v)
1772{
1773 return atomic_fetch_add(const_cast<volatile atomic_char*>(__obj), __v);
1774}
1775
1776inline _LIBCPP_INLINE_VISIBILITY
1777char
1778atomic_fetch_add_explicit(volatile atomic_char* __obj, char __v,
1779 memory_order __o)
1780{
1781 return __atomic_fetch_add(&__obj->__v_, __v, __o);
1782}
1783
1784inline _LIBCPP_INLINE_VISIBILITY
1785char
1786atomic_fetch_add_explicit(atomic_char* __obj, char __v, memory_order __o)
1787{
1788 return atomic_fetch_add_explicit(const_cast<volatile atomic_char*>(__obj),
1789 __v, __o);
1790}
1791
1792inline _LIBCPP_INLINE_VISIBILITY
1793char
1794atomic_fetch_sub(volatile atomic_char* __obj, char __v)
1795{
1796 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
1797}
1798
1799inline _LIBCPP_INLINE_VISIBILITY
1800char
1801atomic_fetch_sub(atomic_char* __obj, char __v)
1802{
1803 return atomic_fetch_sub(const_cast<volatile atomic_char*>(__obj), __v);
1804}
1805
1806inline _LIBCPP_INLINE_VISIBILITY
1807char
1808atomic_fetch_sub_explicit(volatile atomic_char* __obj, char __v,
1809 memory_order __o)
1810{
1811 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
1812}
1813
1814inline _LIBCPP_INLINE_VISIBILITY
1815char
1816atomic_fetch_sub_explicit(atomic_char* __obj, char __v, memory_order __o)
1817{
1818 return atomic_fetch_sub_explicit(const_cast<volatile atomic_char*>(__obj),
1819 __v, __o);
1820}
1821
1822inline _LIBCPP_INLINE_VISIBILITY
1823char
1824atomic_fetch_and(volatile atomic_char* __obj, char __v)
1825{
1826 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
1827}
1828
1829inline _LIBCPP_INLINE_VISIBILITY
1830char
1831atomic_fetch_and(atomic_char* __obj, char __v)
1832{
1833 return atomic_fetch_and(const_cast<volatile atomic_char*>(__obj), __v);
1834}
1835
1836inline _LIBCPP_INLINE_VISIBILITY
1837char
1838atomic_fetch_and_explicit(volatile atomic_char* __obj, char __v,
1839 memory_order __o)
1840{
1841 return __atomic_fetch_and(&__obj->__v_, __v, __o);
1842}
1843
1844inline _LIBCPP_INLINE_VISIBILITY
1845char
1846atomic_fetch_and_explicit(atomic_char* __obj, char __v, memory_order __o)
1847{
1848 return atomic_fetch_and_explicit(const_cast<volatile atomic_char*>(__obj),
1849 __v, __o);
1850}
1851
1852inline _LIBCPP_INLINE_VISIBILITY
1853char
1854atomic_fetch_or(volatile atomic_char* __obj, char __v)
1855{
1856 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
1857}
1858
1859inline _LIBCPP_INLINE_VISIBILITY
1860char
1861atomic_fetch_or(atomic_char* __obj, char __v)
1862{
1863 return atomic_fetch_or(const_cast<volatile atomic_char*>(__obj), __v);
1864}
1865
1866inline _LIBCPP_INLINE_VISIBILITY
1867char
1868atomic_fetch_or_explicit(volatile atomic_char* __obj, char __v,
1869 memory_order __o)
1870{
1871 return __atomic_fetch_or(&__obj->__v_, __v, __o);
1872}
1873
1874inline _LIBCPP_INLINE_VISIBILITY
1875char
1876atomic_fetch_or_explicit(atomic_char* __obj, char __v, memory_order __o)
1877{
1878 return atomic_fetch_or_explicit(const_cast<volatile atomic_char*>(__obj),
1879 __v, __o);
1880}
1881
1882inline _LIBCPP_INLINE_VISIBILITY
1883char
1884atomic_fetch_xor(volatile atomic_char* __obj, char __v)
1885{
1886 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
1887}
1888
1889inline _LIBCPP_INLINE_VISIBILITY
1890char
1891atomic_fetch_xor(atomic_char* __obj, char __v)
1892{
1893 return atomic_fetch_xor(const_cast<volatile atomic_char*>(__obj), __v);
1894}
1895
1896inline _LIBCPP_INLINE_VISIBILITY
1897char
1898atomic_fetch_xor_explicit(volatile atomic_char* __obj, char __v,
1899 memory_order __o)
1900{
1901 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
1902}
1903
1904inline _LIBCPP_INLINE_VISIBILITY
1905char
1906atomic_fetch_xor_explicit(atomic_char* __obj, char __v, memory_order __o)
1907{
1908 return atomic_fetch_xor_explicit(const_cast<volatile atomic_char*>(__obj),
1909 __v, __o);
1910}
1911
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00001912// atomic_schar
1913
1914struct atomic_schar;
1915
1916bool atomic_is_lock_free(const volatile atomic_schar*);
1917bool atomic_is_lock_free(const atomic_schar*);
1918void atomic_init(volatile atomic_schar*, signed char);
1919void atomic_init(atomic_schar*, signed char);
1920void atomic_store(volatile atomic_schar*, signed char);
1921void atomic_store(atomic_schar*, signed char);
1922void atomic_store_explicit(volatile atomic_schar*, signed char, memory_order);
1923void atomic_store_explicit(atomic_schar*, signed char, memory_order);
1924signed char atomic_load(const volatile atomic_schar*);
1925signed char atomic_load(const atomic_schar*);
1926signed char atomic_load_explicit(const volatile atomic_schar*, memory_order);
1927signed char atomic_load_explicit(const atomic_schar*, memory_order);
1928signed char atomic_exchange(volatile atomic_schar*, signed char);
1929signed char atomic_exchange(atomic_schar*, signed char);
1930signed char atomic_exchange_explicit(volatile atomic_schar*, signed char,
1931 memory_order);
1932signed char atomic_exchange_explicit(atomic_schar*, signed char, memory_order);
1933bool atomic_compare_exchange_weak(volatile atomic_schar*, signed char*,
1934 signed char);
1935bool atomic_compare_exchange_weak(atomic_schar*, signed char*, signed char);
1936bool atomic_compare_exchange_strong(volatile atomic_schar*, signed char*,
1937 signed char);
1938bool atomic_compare_exchange_strong(atomic_schar*, signed char*, signed char);
1939bool atomic_compare_exchange_weak_explicit(volatile atomic_schar*, signed char*,
1940 signed char, memory_order,
1941 memory_order);
1942bool atomic_compare_exchange_weak_explicit(atomic_schar*, signed char*,
1943 signed char, memory_order,
1944 memory_order);
1945bool atomic_compare_exchange_strong_explicit(volatile atomic_schar*,
1946 signed char*, signed char,
1947 memory_order, memory_order);
1948bool atomic_compare_exchange_strong_explicit(atomic_schar*, signed char*,
1949 signed char, memory_order,
1950 memory_order);
1951signed char atomic_fetch_add(volatile atomic_schar*, signed char);
1952signed char atomic_fetch_add(atomic_schar*, signed char);
1953signed char atomic_fetch_add_explicit(volatile atomic_schar*, signed char,
1954 memory_order);
1955signed char atomic_fetch_add_explicit(atomic_schar*, signed char, memory_order);
1956signed char atomic_fetch_sub(volatile atomic_schar*, signed char);
1957signed char atomic_fetch_sub(atomic_schar*, signed char);
1958signed char atomic_fetch_sub_explicit(volatile atomic_schar*, signed char,
1959 memory_order);
1960signed char atomic_fetch_sub_explicit(atomic_schar*, signed char, memory_order);
1961signed char atomic_fetch_and(volatile atomic_schar*, signed char);
1962signed char atomic_fetch_and(atomic_schar*, signed char);
1963signed char atomic_fetch_and_explicit(volatile atomic_schar*, signed char,
1964 memory_order);
1965signed char atomic_fetch_and_explicit(atomic_schar*, signed char, memory_order);
1966signed char atomic_fetch_or(volatile atomic_schar*, signed char);
1967signed char atomic_fetch_or(atomic_schar*, signed char);
1968signed char atomic_fetch_or_explicit(volatile atomic_schar*, signed char,
1969 memory_order);
1970signed char atomic_fetch_or_explicit(atomic_schar*, signed char, memory_order);
1971signed char atomic_fetch_xor(volatile atomic_schar*, signed char);
1972signed char atomic_fetch_xor(atomic_schar*, signed char);
1973signed char atomic_fetch_xor_explicit(volatile atomic_schar*, signed char,
1974 memory_order);
1975signed char atomic_fetch_xor_explicit(atomic_schar*, signed char, memory_order);
1976
1977typedef struct atomic_schar
1978{
1979 signed char __v_;
1980
1981 _LIBCPP_INLINE_VISIBILITY
1982 bool is_lock_free() const volatile
1983 {return atomic_is_lock_free(this);}
1984 _LIBCPP_INLINE_VISIBILITY
1985 bool is_lock_free() const
1986 {return atomic_is_lock_free(this);}
1987 _LIBCPP_INLINE_VISIBILITY
1988 void store(signed char __v,
1989 memory_order __o = memory_order_seq_cst) volatile
1990 {atomic_store_explicit(this, __v, __o);}
1991 _LIBCPP_INLINE_VISIBILITY
1992 void store(signed char __v, memory_order __o = memory_order_seq_cst)
1993 {atomic_store_explicit(this, __v, __o);}
1994 _LIBCPP_INLINE_VISIBILITY
1995 signed char load(memory_order __o = memory_order_seq_cst) const volatile
1996 {return atomic_load_explicit(this, __o);}
1997 _LIBCPP_INLINE_VISIBILITY
1998 signed char load(memory_order __o = memory_order_seq_cst) const
1999 {return atomic_load_explicit(this, __o);}
2000 _LIBCPP_INLINE_VISIBILITY
2001 operator signed char() const volatile
2002 {return load();}
2003 _LIBCPP_INLINE_VISIBILITY
2004 operator signed char() const
2005 {return load();}
2006 _LIBCPP_INLINE_VISIBILITY
2007 signed char exchange(signed char __v,
2008 memory_order __o = memory_order_seq_cst) volatile
2009 {return atomic_exchange_explicit(this, __v, __o);}
2010 _LIBCPP_INLINE_VISIBILITY
2011 signed char exchange(signed char __v,
2012 memory_order __o = memory_order_seq_cst)
2013 {return atomic_exchange_explicit(this, __v, __o);}
2014 _LIBCPP_INLINE_VISIBILITY
2015 bool compare_exchange_weak(signed char& __v, signed char __e,
2016 memory_order __s, memory_order __f) volatile
2017 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2018 __f);}
2019 _LIBCPP_INLINE_VISIBILITY
2020 bool compare_exchange_weak(signed char& __v, signed char __e,
2021 memory_order __s, memory_order __f)
2022 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2023 __f);}
2024 _LIBCPP_INLINE_VISIBILITY
2025 bool compare_exchange_strong(signed char& __v, signed char __e,
2026 memory_order __s, memory_order __f) volatile
2027 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2028 __f);}
2029 _LIBCPP_INLINE_VISIBILITY
2030 bool compare_exchange_strong(signed char& __v, signed char __e,
2031 memory_order __s, memory_order __f)
2032 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2033 __f);}
2034 _LIBCPP_INLINE_VISIBILITY
2035 bool compare_exchange_weak(signed char& __v, signed char __e,
2036 memory_order __s = memory_order_seq_cst) volatile
2037 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2038 __translate_memory_order(__s));}
2039 _LIBCPP_INLINE_VISIBILITY
2040 bool compare_exchange_weak(signed char& __v, signed char __e,
2041 memory_order __s = memory_order_seq_cst)
2042 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2043 __translate_memory_order(__s));}
2044 _LIBCPP_INLINE_VISIBILITY
2045 bool compare_exchange_strong(signed char& __v, signed char __e,
2046 memory_order __s = memory_order_seq_cst) volatile
2047 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2048 __translate_memory_order(__s));}
2049 _LIBCPP_INLINE_VISIBILITY
2050 bool compare_exchange_strong(signed char& __v, signed char __e,
2051 memory_order __s = memory_order_seq_cst)
2052 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2053 __translate_memory_order(__s));}
2054 _LIBCPP_INLINE_VISIBILITY
2055 signed char fetch_add(signed char __v,
2056 memory_order __o = memory_order_seq_cst) volatile
2057 {return atomic_fetch_add_explicit(this, __v, __o);}
2058 _LIBCPP_INLINE_VISIBILITY
2059 signed char fetch_add(signed char __v,
2060 memory_order __o = memory_order_seq_cst)
2061 {return atomic_fetch_add_explicit(this, __v, __o);}
2062 _LIBCPP_INLINE_VISIBILITY
2063 signed char fetch_sub(signed char __v,
2064 memory_order __o = memory_order_seq_cst) volatile
2065 {return atomic_fetch_sub_explicit(this, __v, __o);}
2066 _LIBCPP_INLINE_VISIBILITY
2067 signed char fetch_sub(signed char __v,
2068 memory_order __o = memory_order_seq_cst)
2069 {return atomic_fetch_sub_explicit(this, __v, __o);}
2070 _LIBCPP_INLINE_VISIBILITY
2071 signed char fetch_and(signed char __v,
2072 memory_order __o = memory_order_seq_cst) volatile
2073 {return atomic_fetch_and_explicit(this, __v, __o);}
2074 _LIBCPP_INLINE_VISIBILITY
2075 signed char fetch_and(signed char __v,
2076 memory_order __o = memory_order_seq_cst)
2077 {return atomic_fetch_and_explicit(this, __v, __o);}
2078 _LIBCPP_INLINE_VISIBILITY
2079 signed char fetch_or(signed char __v,
2080 memory_order __o = memory_order_seq_cst) volatile
2081 {return atomic_fetch_or_explicit(this, __v, __o);}
2082 _LIBCPP_INLINE_VISIBILITY
2083 signed char fetch_or(signed char __v,
2084 memory_order __o = memory_order_seq_cst)
2085 {return atomic_fetch_or_explicit(this, __v, __o);}
2086 _LIBCPP_INLINE_VISIBILITY
2087 signed char fetch_xor(signed char __v,
2088 memory_order __o = memory_order_seq_cst) volatile
2089 {return atomic_fetch_xor_explicit(this, __v, __o);}
2090 _LIBCPP_INLINE_VISIBILITY
2091 signed char fetch_xor(signed char __v,
2092 memory_order __o = memory_order_seq_cst)
2093 {return atomic_fetch_xor_explicit(this, __v, __o);}
2094#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2095 atomic_schar() = default;
2096#else
2097 _LIBCPP_INLINE_VISIBILITY
2098 atomic_schar() {}
2099#endif
2100 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00002101 constexpr atomic_schar(signed char __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00002102 : __v_(__v) {}
2103#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
2104 atomic_schar(const atomic_schar&) = delete;
2105 atomic_schar& operator=(const atomic_schar&) = delete;
2106 atomic_schar& operator=(const atomic_schar&) volatile = delete;
2107#else
2108private:
2109 atomic_schar(const atomic_schar&);
2110 atomic_schar& operator=(const atomic_schar&);
2111 atomic_schar& operator=(const atomic_schar&) volatile;
2112public:
2113#endif
2114 _LIBCPP_INLINE_VISIBILITY
2115 signed char operator=(signed char __v) volatile
2116 {store(__v); return __v;}
2117 _LIBCPP_INLINE_VISIBILITY
2118 signed char operator=(signed char __v)
2119 {store(__v); return __v;}
2120 _LIBCPP_INLINE_VISIBILITY
2121 signed char operator++(int) volatile
2122 {typedef signed char type; return fetch_add(type(1));}
2123 _LIBCPP_INLINE_VISIBILITY
2124 char operator++(int)
2125 {typedef signed char type; return fetch_add(type(1));}
2126 _LIBCPP_INLINE_VISIBILITY
2127 char operator--(int) volatile
2128 {typedef signed char type; return fetch_sub(type(1));}
2129 _LIBCPP_INLINE_VISIBILITY
2130 char operator--(int)
2131 {typedef signed char type; return fetch_sub(type(1));}
2132 _LIBCPP_INLINE_VISIBILITY
2133 char operator++() volatile
2134 {typedef signed char type; return type(fetch_add(type(1)) + 1);}
2135 _LIBCPP_INLINE_VISIBILITY
2136 char operator++()
2137 {typedef signed char type; return type(fetch_add(type(1)) + 1);}
2138 _LIBCPP_INLINE_VISIBILITY
2139 char operator--() volatile
2140 {typedef signed char type; return type(fetch_sub(type(1)) - 1);}
2141 _LIBCPP_INLINE_VISIBILITY
2142 char operator--()
2143 {typedef signed char type; return type(fetch_sub(type(1)) - 1);}
2144 _LIBCPP_INLINE_VISIBILITY
2145 char operator+=(char __v) volatile
2146 {typedef signed char type; return type(fetch_add(__v) + __v);}
2147 _LIBCPP_INLINE_VISIBILITY
2148 char operator+=(char __v)
2149 {typedef signed char type; return type(fetch_add(__v) + __v);}
2150 _LIBCPP_INLINE_VISIBILITY
2151 char operator-=(char __v) volatile
2152 {typedef signed char type; return type(fetch_sub(__v) - __v);}
2153 _LIBCPP_INLINE_VISIBILITY
2154 char operator-=(char __v)
2155 {typedef signed char type; return type(fetch_sub(__v) - __v);}
2156 _LIBCPP_INLINE_VISIBILITY
2157 char operator&=(char __v) volatile
2158 {typedef signed char type; return type(fetch_and(__v) & __v);}
2159 _LIBCPP_INLINE_VISIBILITY
2160 char operator&=(char __v)
2161 {typedef signed char type; return type(fetch_and(__v) & __v);}
2162 _LIBCPP_INLINE_VISIBILITY
2163 char operator|=(char __v) volatile
2164 {typedef signed char type; return type(fetch_or(__v) | __v);}
2165 _LIBCPP_INLINE_VISIBILITY
2166 char operator|=(char __v)
2167 {typedef signed char type; return type(fetch_or(__v) | __v);}
2168 _LIBCPP_INLINE_VISIBILITY
2169 char operator^=(char __v) volatile
2170 {typedef signed char type; return type(fetch_xor(__v) ^ __v);}
2171 _LIBCPP_INLINE_VISIBILITY
2172 char operator^=(char __v)
2173 {typedef signed char type; return type(fetch_xor(__v) ^ __v);}
2174} atomic_schar;
2175
2176inline _LIBCPP_INLINE_VISIBILITY
2177bool
2178atomic_is_lock_free(const volatile atomic_schar*)
2179{
2180 typedef signed char type;
2181 return __atomic_is_lock_free(type);
2182}
2183
2184inline _LIBCPP_INLINE_VISIBILITY
2185bool
2186atomic_is_lock_free(const atomic_schar* __obj)
2187{
2188 return atomic_is_lock_free(const_cast<volatile atomic_schar*>(__obj));
2189}
2190
2191inline _LIBCPP_INLINE_VISIBILITY
2192void
2193atomic_init(volatile atomic_schar* __obj, signed char __desr)
2194{
2195 __obj->__v_ = __desr;
2196}
2197
2198inline _LIBCPP_INLINE_VISIBILITY
2199void
2200atomic_init(atomic_schar* __obj, signed char __desr)
2201{
2202 __obj->__v_ = __desr;
2203}
2204
2205inline _LIBCPP_INLINE_VISIBILITY
2206void
2207atomic_store(volatile atomic_schar* __obj, signed char __desr)
2208{
2209 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
2210}
2211
2212inline _LIBCPP_INLINE_VISIBILITY
2213void
2214atomic_store(atomic_schar* __obj, signed char __desr)
2215{
2216 atomic_store(const_cast<volatile atomic_schar*>(__obj), __desr);
2217}
2218
2219inline _LIBCPP_INLINE_VISIBILITY
2220void
2221atomic_store_explicit(volatile atomic_schar* __obj, signed char __desr,
2222 memory_order __o)
2223{
2224 __atomic_store(&__obj->__v_, __desr, __o);
2225}
2226
2227inline _LIBCPP_INLINE_VISIBILITY
2228void
2229atomic_store_explicit(atomic_schar* __obj, signed char __desr, memory_order __o)
2230{
2231 atomic_store_explicit(const_cast<volatile atomic_schar*>(__obj), __desr,
2232 __o);
2233}
2234
2235inline _LIBCPP_INLINE_VISIBILITY
2236signed char
2237atomic_load(const volatile atomic_schar* __obj)
2238{
2239 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
2240}
2241
2242inline _LIBCPP_INLINE_VISIBILITY
2243signed char
2244atomic_load(const atomic_schar* __obj)
2245{
2246 return atomic_load(const_cast<const volatile atomic_schar*>(__obj));
2247}
2248
2249inline _LIBCPP_INLINE_VISIBILITY
2250signed char
2251atomic_load_explicit(const volatile atomic_schar* __obj, memory_order __o)
2252{
2253 return __atomic_load(&__obj->__v_, __o);
2254}
2255
2256inline _LIBCPP_INLINE_VISIBILITY
2257signed char
2258atomic_load_explicit(const atomic_schar* __obj, memory_order __o)
2259{
2260 return atomic_load_explicit(const_cast<const volatile atomic_schar*>
2261 (__obj), __o);
2262}
2263
2264inline _LIBCPP_INLINE_VISIBILITY
2265signed char
2266atomic_exchange(volatile atomic_schar* __obj, signed char __desr)
2267{
2268 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
2269}
2270
2271inline _LIBCPP_INLINE_VISIBILITY
2272signed char
2273atomic_exchange(atomic_schar* __obj, signed char __desr)
2274{
2275 return atomic_exchange(const_cast<volatile atomic_schar*>(__obj), __desr);
2276}
2277
2278inline _LIBCPP_INLINE_VISIBILITY
2279signed char
2280atomic_exchange_explicit(volatile atomic_schar* __obj, signed char __desr,
2281 memory_order __o)
2282{
2283 return __atomic_exchange(&__obj->__v_, __desr, __o);
2284}
2285
2286inline _LIBCPP_INLINE_VISIBILITY
2287signed char
2288atomic_exchange_explicit(atomic_schar* __obj, signed char __desr,
2289 memory_order __o)
2290{
2291 return atomic_exchange_explicit(const_cast<volatile atomic_schar*>
2292 (__obj), __desr, __o);
2293}
2294
2295inline _LIBCPP_INLINE_VISIBILITY
2296bool
2297atomic_compare_exchange_weak(volatile atomic_schar* __obj, signed char* __exp,
2298 signed char __desr)
2299{
2300 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
2301 memory_order_seq_cst, memory_order_seq_cst);
2302}
2303
2304inline _LIBCPP_INLINE_VISIBILITY
2305bool
2306atomic_compare_exchange_weak(atomic_schar* __obj, signed char* __exp,
2307 signed char __desr)
2308{
2309 return atomic_compare_exchange_weak(const_cast<volatile atomic_schar*>
2310 (__obj), __exp, __desr);
2311}
2312
2313inline _LIBCPP_INLINE_VISIBILITY
2314bool
2315atomic_compare_exchange_strong(volatile atomic_schar* __obj, signed char* __exp,
2316 signed char __desr)
2317{
2318 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
2319 memory_order_seq_cst, memory_order_seq_cst);
2320}
2321
2322inline _LIBCPP_INLINE_VISIBILITY
2323bool
2324atomic_compare_exchange_strong(atomic_schar* __obj, signed char* __exp,
2325 signed char __desr)
2326{
2327 return atomic_compare_exchange_strong(const_cast<volatile atomic_schar*>
2328 (__obj), __exp, __desr);
2329}
2330
2331inline _LIBCPP_INLINE_VISIBILITY
2332bool
2333atomic_compare_exchange_weak_explicit(volatile atomic_schar* __obj,
2334 signed char* __exp, signed char __desr,
2335 memory_order __s, memory_order __f)
2336{
2337 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
2338 __f);
2339}
2340
2341inline _LIBCPP_INLINE_VISIBILITY
2342bool
2343atomic_compare_exchange_weak_explicit(atomic_schar* __obj, signed char* __exp,
2344 signed char __desr, memory_order __s,
2345 memory_order __f)
2346{
2347 return atomic_compare_exchange_weak_explicit(
2348 const_cast<volatile atomic_schar*>(__obj), __exp, __desr, __s, __f);
2349}
2350
2351inline _LIBCPP_INLINE_VISIBILITY
2352bool
2353atomic_compare_exchange_strong_explicit(volatile atomic_schar* __obj,
2354 signed char* __exp, signed char __desr,
2355 memory_order __s, memory_order __f)
2356{
2357 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
2358 __f);
2359}
2360
2361inline _LIBCPP_INLINE_VISIBILITY
2362bool
2363atomic_compare_exchange_strong_explicit(atomic_schar* __obj, signed char* __exp,
2364 signed char __desr, memory_order __s,
2365 memory_order __f)
2366{
2367 return atomic_compare_exchange_strong_explicit(
2368 const_cast<volatile atomic_schar*>(__obj), __exp, __desr, __s, __f);
2369}
2370
2371inline _LIBCPP_INLINE_VISIBILITY
2372signed char
2373atomic_fetch_add(volatile atomic_schar* __obj, signed char __v)
2374{
2375 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
2376}
2377
2378inline _LIBCPP_INLINE_VISIBILITY
2379signed char
2380atomic_fetch_add(atomic_schar* __obj, signed char __v)
2381{
2382 return atomic_fetch_add(const_cast<volatile atomic_schar*>(__obj), __v);
2383}
2384
2385inline _LIBCPP_INLINE_VISIBILITY
2386signed char
2387atomic_fetch_add_explicit(volatile atomic_schar* __obj, signed char __v,
2388 memory_order __o)
2389{
2390 return __atomic_fetch_add(&__obj->__v_, __v, __o);
2391}
2392
2393inline _LIBCPP_INLINE_VISIBILITY
2394signed char
2395atomic_fetch_add_explicit(atomic_schar* __obj, signed char __v,
2396 memory_order __o)
2397{
2398 return atomic_fetch_add_explicit(const_cast<volatile atomic_schar*>(__obj),
2399 __v, __o);
2400}
2401
2402inline _LIBCPP_INLINE_VISIBILITY
2403signed char
2404atomic_fetch_sub(volatile atomic_schar* __obj, signed char __v)
2405{
2406 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
2407}
2408
2409inline _LIBCPP_INLINE_VISIBILITY
2410signed char
2411atomic_fetch_sub(atomic_schar* __obj, signed char __v)
2412{
2413 return atomic_fetch_sub(const_cast<volatile atomic_schar*>(__obj), __v);
2414}
2415
2416inline _LIBCPP_INLINE_VISIBILITY
2417signed char
2418atomic_fetch_sub_explicit(volatile atomic_schar* __obj, signed char __v,
2419 memory_order __o)
2420{
2421 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
2422}
2423
2424inline _LIBCPP_INLINE_VISIBILITY
2425signed char
2426atomic_fetch_sub_explicit(atomic_schar* __obj, signed char __v,
2427 memory_order __o)
2428{
2429 return atomic_fetch_sub_explicit(const_cast<volatile atomic_schar*>(__obj),
2430 __v, __o);
2431}
2432
2433inline _LIBCPP_INLINE_VISIBILITY
2434signed char
2435atomic_fetch_and(volatile atomic_schar* __obj, signed char __v)
2436{
2437 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
2438}
2439
2440inline _LIBCPP_INLINE_VISIBILITY
2441signed char
2442atomic_fetch_and(atomic_schar* __obj, signed char __v)
2443{
2444 return atomic_fetch_and(const_cast<volatile atomic_schar*>(__obj), __v);
2445}
2446
2447inline _LIBCPP_INLINE_VISIBILITY
2448signed char
2449atomic_fetch_and_explicit(volatile atomic_schar* __obj, signed char __v,
2450 memory_order __o)
2451{
2452 return __atomic_fetch_and(&__obj->__v_, __v, __o);
2453}
2454
2455inline _LIBCPP_INLINE_VISIBILITY
2456signed char
2457atomic_fetch_and_explicit(atomic_schar* __obj, signed char __v,
2458 memory_order __o)
2459{
2460 return atomic_fetch_and_explicit(const_cast<volatile atomic_schar*>(__obj),
2461 __v, __o);
2462}
2463
2464inline _LIBCPP_INLINE_VISIBILITY
2465signed char
2466atomic_fetch_or(volatile atomic_schar* __obj, signed char __v)
2467{
2468 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
2469}
2470
2471inline _LIBCPP_INLINE_VISIBILITY
2472signed char
2473atomic_fetch_or(atomic_schar* __obj, signed char __v)
2474{
2475 return atomic_fetch_or(const_cast<volatile atomic_schar*>(__obj), __v);
2476}
2477
2478inline _LIBCPP_INLINE_VISIBILITY
2479signed char
2480atomic_fetch_or_explicit(volatile atomic_schar* __obj, signed char __v,
2481 memory_order __o)
2482{
2483 return __atomic_fetch_or(&__obj->__v_, __v, __o);
2484}
2485
2486inline _LIBCPP_INLINE_VISIBILITY
2487signed char
2488atomic_fetch_or_explicit(atomic_schar* __obj, signed char __v, memory_order __o)
2489{
2490 return atomic_fetch_or_explicit(const_cast<volatile atomic_schar*>(__obj),
2491 __v, __o);
2492}
2493
2494inline _LIBCPP_INLINE_VISIBILITY
2495signed char
2496atomic_fetch_xor(volatile atomic_schar* __obj, signed char __v)
2497{
2498 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
2499}
2500
2501inline _LIBCPP_INLINE_VISIBILITY
2502signed char
2503atomic_fetch_xor(atomic_schar* __obj, signed char __v)
2504{
2505 return atomic_fetch_xor(const_cast<volatile atomic_schar*>(__obj), __v);
2506}
2507
2508inline _LIBCPP_INLINE_VISIBILITY
2509signed char
2510atomic_fetch_xor_explicit(volatile atomic_schar* __obj, signed char __v,
2511 memory_order __o)
2512{
2513 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
2514}
2515
2516inline _LIBCPP_INLINE_VISIBILITY
2517signed char
2518atomic_fetch_xor_explicit(atomic_schar* __obj, signed char __v,
2519 memory_order __o)
2520{
2521 return atomic_fetch_xor_explicit(const_cast<volatile atomic_schar*>(__obj),
2522 __v, __o);
2523}
2524
2525// atomic_uchar
2526
2527struct atomic_uchar;
2528
2529bool atomic_is_lock_free(const volatile atomic_uchar*);
2530bool atomic_is_lock_free(const atomic_uchar*);
2531void atomic_init(volatile atomic_uchar*, unsigned char);
2532void atomic_init(atomic_uchar*, unsigned char);
2533void atomic_store(volatile atomic_uchar*, unsigned char);
2534void atomic_store(atomic_uchar*, unsigned char);
2535void atomic_store_explicit(volatile atomic_uchar*, unsigned char, memory_order);
2536void atomic_store_explicit(atomic_uchar*, unsigned char, memory_order);
2537unsigned char atomic_load(const volatile atomic_uchar*);
2538unsigned char atomic_load(const atomic_uchar*);
2539unsigned char atomic_load_explicit(const volatile atomic_uchar*, memory_order);
2540unsigned char atomic_load_explicit(const atomic_uchar*, memory_order);
2541unsigned char atomic_exchange(volatile atomic_uchar*, unsigned char);
2542unsigned char atomic_exchange(atomic_uchar*, unsigned char);
2543unsigned char atomic_exchange_explicit(volatile atomic_uchar*, unsigned char,
2544 memory_order);
2545unsigned char atomic_exchange_explicit(atomic_uchar*, unsigned char,
2546 memory_order);
2547bool atomic_compare_exchange_weak(volatile atomic_uchar*, unsigned char*,
2548 unsigned char);
2549bool atomic_compare_exchange_weak(atomic_uchar*, unsigned char*, unsigned char);
2550bool atomic_compare_exchange_strong(volatile atomic_uchar*, unsigned char*,
2551 unsigned char);
2552bool atomic_compare_exchange_strong(atomic_uchar*, unsigned char*,
2553 unsigned char);
2554bool atomic_compare_exchange_weak_explicit(volatile atomic_uchar*,
2555 unsigned char*, unsigned char,
2556 memory_order, memory_order);
2557bool atomic_compare_exchange_weak_explicit(atomic_uchar*, unsigned char*,
2558 unsigned char, memory_order,
2559 memory_order);
2560bool atomic_compare_exchange_strong_explicit(volatile atomic_uchar*,
2561 unsigned char*, unsigned char,
2562 memory_order, memory_order);
2563bool atomic_compare_exchange_strong_explicit(atomic_uchar*, unsigned char*,
2564 unsigned char, memory_order,
2565 memory_order);
2566unsigned char atomic_fetch_add(volatile atomic_uchar*, unsigned char);
2567unsigned char atomic_fetch_add(atomic_uchar*, unsigned char);
2568unsigned char atomic_fetch_add_explicit(volatile atomic_uchar*, unsigned char,
2569 memory_order);
2570unsigned char atomic_fetch_add_explicit(atomic_uchar*, unsigned char,
2571 memory_order);
2572unsigned char atomic_fetch_sub(volatile atomic_uchar*, unsigned char);
2573unsigned char atomic_fetch_sub(atomic_uchar*, unsigned char);
2574unsigned char atomic_fetch_sub_explicit(volatile atomic_uchar*, unsigned char,
2575 memory_order);
2576unsigned char atomic_fetch_sub_explicit(atomic_uchar*, unsigned char,
2577 memory_order);
2578unsigned char atomic_fetch_and(volatile atomic_uchar*, unsigned char);
2579unsigned char atomic_fetch_and(atomic_uchar*, unsigned char);
2580unsigned char atomic_fetch_and_explicit(volatile atomic_uchar*, unsigned char,
2581 memory_order);
2582unsigned char atomic_fetch_and_explicit(atomic_uchar*, unsigned char,
2583 memory_order);
2584unsigned char atomic_fetch_or(volatile atomic_uchar*, unsigned char);
2585unsigned char atomic_fetch_or(atomic_uchar*, unsigned char);
2586unsigned char atomic_fetch_or_explicit(volatile atomic_uchar*, unsigned char,
2587 memory_order);
2588unsigned char atomic_fetch_or_explicit(atomic_uchar*, unsigned char,
2589 memory_order);
2590unsigned char atomic_fetch_xor(volatile atomic_uchar*, unsigned char);
2591unsigned char atomic_fetch_xor(atomic_uchar*, unsigned char);
2592unsigned char atomic_fetch_xor_explicit(volatile atomic_uchar*, unsigned char,
2593 memory_order);
2594unsigned char atomic_fetch_xor_explicit(atomic_uchar*, unsigned char,
2595 memory_order);
2596
2597typedef struct atomic_uchar
2598{
2599 unsigned char __v_;
2600
2601 _LIBCPP_INLINE_VISIBILITY
2602 bool is_lock_free() const volatile
2603 {return atomic_is_lock_free(this);}
2604 _LIBCPP_INLINE_VISIBILITY
2605 bool is_lock_free() const
2606 {return atomic_is_lock_free(this);}
2607 _LIBCPP_INLINE_VISIBILITY
2608 void store(unsigned char __v,
2609 memory_order __o = memory_order_seq_cst) volatile
2610 {atomic_store_explicit(this, __v, __o);}
2611 _LIBCPP_INLINE_VISIBILITY
2612 void store(unsigned char __v, memory_order __o = memory_order_seq_cst)
2613 {atomic_store_explicit(this, __v, __o);}
2614 _LIBCPP_INLINE_VISIBILITY
2615 unsigned char load(memory_order __o = memory_order_seq_cst) const volatile
2616 {return atomic_load_explicit(this, __o);}
2617 _LIBCPP_INLINE_VISIBILITY
2618 unsigned char load(memory_order __o = memory_order_seq_cst) const
2619 {return atomic_load_explicit(this, __o);}
2620 _LIBCPP_INLINE_VISIBILITY
2621 operator unsigned char() const volatile
2622 {return load();}
2623 _LIBCPP_INLINE_VISIBILITY
2624 operator unsigned char() const
2625 {return load();}
2626 _LIBCPP_INLINE_VISIBILITY
2627 unsigned char exchange(unsigned char __v,
2628 memory_order __o = memory_order_seq_cst) volatile
2629 {return atomic_exchange_explicit(this, __v, __o);}
2630 _LIBCPP_INLINE_VISIBILITY
2631 unsigned char exchange(unsigned char __v,
2632 memory_order __o = memory_order_seq_cst)
2633 {return atomic_exchange_explicit(this, __v, __o);}
2634 _LIBCPP_INLINE_VISIBILITY
2635 bool compare_exchange_weak(unsigned char& __v, unsigned char __e,
2636 memory_order __s, memory_order __f) volatile
2637 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2638 __f);}
2639 _LIBCPP_INLINE_VISIBILITY
2640 bool compare_exchange_weak(unsigned char& __v, unsigned char __e,
2641 memory_order __s, memory_order __f)
2642 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2643 __f);}
2644 _LIBCPP_INLINE_VISIBILITY
2645 bool compare_exchange_strong(unsigned char& __v, unsigned char __e,
2646 memory_order __s, memory_order __f) volatile
2647 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2648 __f);}
2649 _LIBCPP_INLINE_VISIBILITY
2650 bool compare_exchange_strong(unsigned char& __v, unsigned char __e,
2651 memory_order __s, memory_order __f)
2652 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2653 __f);}
2654 _LIBCPP_INLINE_VISIBILITY
2655 bool compare_exchange_weak(unsigned char& __v, unsigned char __e,
2656 memory_order __s = memory_order_seq_cst) volatile
2657 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2658 __translate_memory_order(__s));}
2659 _LIBCPP_INLINE_VISIBILITY
2660 bool compare_exchange_weak(unsigned char& __v, unsigned char __e,
2661 memory_order __s = memory_order_seq_cst)
2662 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2663 __translate_memory_order(__s));}
2664 _LIBCPP_INLINE_VISIBILITY
2665 bool compare_exchange_strong(unsigned char& __v, unsigned char __e,
2666 memory_order __s = memory_order_seq_cst) volatile
2667 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2668 __translate_memory_order(__s));}
2669 _LIBCPP_INLINE_VISIBILITY
2670 bool compare_exchange_strong(unsigned char& __v, unsigned char __e,
2671 memory_order __s = memory_order_seq_cst)
2672 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2673 __translate_memory_order(__s));}
2674 _LIBCPP_INLINE_VISIBILITY
2675 unsigned char fetch_add(unsigned char __v,
2676 memory_order __o = memory_order_seq_cst) volatile
2677 {return atomic_fetch_add_explicit(this, __v, __o);}
2678 _LIBCPP_INLINE_VISIBILITY
2679 unsigned char fetch_add(unsigned char __v,
2680 memory_order __o = memory_order_seq_cst)
2681 {return atomic_fetch_add_explicit(this, __v, __o);}
2682 _LIBCPP_INLINE_VISIBILITY
2683 unsigned char fetch_sub(unsigned char __v,
2684 memory_order __o = memory_order_seq_cst) volatile
2685 {return atomic_fetch_sub_explicit(this, __v, __o);}
2686 _LIBCPP_INLINE_VISIBILITY
2687 unsigned char fetch_sub(unsigned char __v,
2688 memory_order __o = memory_order_seq_cst)
2689 {return atomic_fetch_sub_explicit(this, __v, __o);}
2690 _LIBCPP_INLINE_VISIBILITY
2691 unsigned char fetch_and(unsigned char __v,
2692 memory_order __o = memory_order_seq_cst) volatile
2693 {return atomic_fetch_and_explicit(this, __v, __o);}
2694 _LIBCPP_INLINE_VISIBILITY
2695 unsigned char fetch_and(unsigned char __v,
2696 memory_order __o = memory_order_seq_cst)
2697 {return atomic_fetch_and_explicit(this, __v, __o);}
2698 _LIBCPP_INLINE_VISIBILITY
2699 unsigned char fetch_or(unsigned char __v,
2700 memory_order __o = memory_order_seq_cst) volatile
2701 {return atomic_fetch_or_explicit(this, __v, __o);}
2702 _LIBCPP_INLINE_VISIBILITY
2703 unsigned char fetch_or(unsigned char __v,
2704 memory_order __o = memory_order_seq_cst)
2705 {return atomic_fetch_or_explicit(this, __v, __o);}
2706 _LIBCPP_INLINE_VISIBILITY
2707 unsigned char fetch_xor(unsigned char __v,
2708 memory_order __o = memory_order_seq_cst) volatile
2709 {return atomic_fetch_xor_explicit(this, __v, __o);}
2710 _LIBCPP_INLINE_VISIBILITY
2711 unsigned char fetch_xor(unsigned char __v,
2712 memory_order __o = memory_order_seq_cst)
2713 {return atomic_fetch_xor_explicit(this, __v, __o);}
2714#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2715 atomic_uchar() = default;
2716#else
2717 _LIBCPP_INLINE_VISIBILITY
2718 atomic_uchar() {}
2719#endif
2720 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00002721 constexpr atomic_uchar(unsigned char __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00002722 : __v_(__v) {}
2723#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
2724 atomic_uchar(const atomic_uchar&) = delete;
2725 atomic_uchar& operator=(const atomic_uchar&) = delete;
2726 atomic_uchar& operator=(const atomic_uchar&) volatile = delete;
2727#else
2728private:
2729 atomic_uchar(const atomic_uchar&);
2730 atomic_uchar& operator=(const atomic_uchar&);
2731 atomic_uchar& operator=(const atomic_uchar&) volatile;
2732public:
2733#endif
2734 _LIBCPP_INLINE_VISIBILITY
2735 unsigned char operator=(unsigned char __v) volatile
2736 {store(__v); return __v;}
2737 _LIBCPP_INLINE_VISIBILITY
2738 unsigned char operator=(unsigned char __v)
2739 {store(__v); return __v;}
2740 _LIBCPP_INLINE_VISIBILITY
2741 unsigned char operator++(int) volatile
2742 {typedef unsigned char type; return fetch_add(type(1));}
2743 _LIBCPP_INLINE_VISIBILITY
2744 char operator++(int)
2745 {typedef unsigned char type; return fetch_add(type(1));}
2746 _LIBCPP_INLINE_VISIBILITY
2747 char operator--(int) volatile
2748 {typedef unsigned char type; return fetch_sub(type(1));}
2749 _LIBCPP_INLINE_VISIBILITY
2750 char operator--(int)
2751 {typedef unsigned char type; return fetch_sub(type(1));}
2752 _LIBCPP_INLINE_VISIBILITY
2753 char operator++() volatile
2754 {typedef unsigned char type; return type(fetch_add(type(1)) + 1);}
2755 _LIBCPP_INLINE_VISIBILITY
2756 char operator++()
2757 {typedef unsigned char type; return type(fetch_add(type(1)) + 1);}
2758 _LIBCPP_INLINE_VISIBILITY
2759 char operator--() volatile
2760 {typedef unsigned char type; return type(fetch_sub(type(1)) - 1);}
2761 _LIBCPP_INLINE_VISIBILITY
2762 char operator--()
2763 {typedef unsigned char type; return type(fetch_sub(type(1)) - 1);}
2764 _LIBCPP_INLINE_VISIBILITY
2765 char operator+=(char __v) volatile
2766 {typedef unsigned char type; return type(fetch_add(__v) + __v);}
2767 _LIBCPP_INLINE_VISIBILITY
2768 char operator+=(char __v)
2769 {typedef unsigned char type; return type(fetch_add(__v) + __v);}
2770 _LIBCPP_INLINE_VISIBILITY
2771 char operator-=(char __v) volatile
2772 {typedef unsigned char type; return type(fetch_sub(__v) - __v);}
2773 _LIBCPP_INLINE_VISIBILITY
2774 char operator-=(char __v)
2775 {typedef unsigned char type; return type(fetch_sub(__v) - __v);}
2776 _LIBCPP_INLINE_VISIBILITY
2777 char operator&=(char __v) volatile
2778 {typedef unsigned char type; return type(fetch_and(__v) & __v);}
2779 _LIBCPP_INLINE_VISIBILITY
2780 char operator&=(char __v)
2781 {typedef unsigned char type; return type(fetch_and(__v) & __v);}
2782 _LIBCPP_INLINE_VISIBILITY
2783 char operator|=(char __v) volatile
2784 {typedef unsigned char type; return type(fetch_or(__v) | __v);}
2785 _LIBCPP_INLINE_VISIBILITY
2786 char operator|=(char __v)
2787 {typedef unsigned char type; return type(fetch_or(__v) | __v);}
2788 _LIBCPP_INLINE_VISIBILITY
2789 char operator^=(char __v) volatile
2790 {typedef unsigned char type; return type(fetch_xor(__v) ^ __v);}
2791 _LIBCPP_INLINE_VISIBILITY
2792 char operator^=(char __v)
2793 {typedef unsigned char type; return type(fetch_xor(__v) ^ __v);}
2794} atomic_uchar;
2795
2796inline _LIBCPP_INLINE_VISIBILITY
2797bool
2798atomic_is_lock_free(const volatile atomic_uchar*)
2799{
2800 typedef unsigned char type;
2801 return __atomic_is_lock_free(type);
2802}
2803
2804inline _LIBCPP_INLINE_VISIBILITY
2805bool
2806atomic_is_lock_free(const atomic_uchar* __obj)
2807{
2808 return atomic_is_lock_free(const_cast<volatile atomic_uchar*>(__obj));
2809}
2810
2811inline _LIBCPP_INLINE_VISIBILITY
2812void
2813atomic_init(volatile atomic_uchar* __obj, unsigned char __desr)
2814{
2815 __obj->__v_ = __desr;
2816}
2817
2818inline _LIBCPP_INLINE_VISIBILITY
2819void
2820atomic_init(atomic_uchar* __obj, unsigned char __desr)
2821{
2822 __obj->__v_ = __desr;
2823}
2824
2825inline _LIBCPP_INLINE_VISIBILITY
2826void
2827atomic_store(volatile atomic_uchar* __obj, unsigned char __desr)
2828{
2829 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
2830}
2831
2832inline _LIBCPP_INLINE_VISIBILITY
2833void
2834atomic_store(atomic_uchar* __obj, unsigned char __desr)
2835{
2836 atomic_store(const_cast<volatile atomic_uchar*>(__obj), __desr);
2837}
2838
2839inline _LIBCPP_INLINE_VISIBILITY
2840void
2841atomic_store_explicit(volatile atomic_uchar* __obj, unsigned char __desr,
2842 memory_order __o)
2843{
2844 __atomic_store(&__obj->__v_, __desr, __o);
2845}
2846
2847inline _LIBCPP_INLINE_VISIBILITY
2848void
2849atomic_store_explicit(atomic_uchar* __obj, unsigned char __desr,
2850 memory_order __o)
2851{
2852 atomic_store_explicit(const_cast<volatile atomic_uchar*>(__obj), __desr,
2853 __o);
2854}
2855
2856inline _LIBCPP_INLINE_VISIBILITY
2857unsigned char
2858atomic_load(const volatile atomic_uchar* __obj)
2859{
2860 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
2861}
2862
2863inline _LIBCPP_INLINE_VISIBILITY
2864unsigned char
2865atomic_load(const atomic_uchar* __obj)
2866{
2867 return atomic_load(const_cast<const volatile atomic_uchar*>(__obj));
2868}
2869
2870inline _LIBCPP_INLINE_VISIBILITY
2871unsigned char
2872atomic_load_explicit(const volatile atomic_uchar* __obj, memory_order __o)
2873{
2874 return __atomic_load(&__obj->__v_, __o);
2875}
2876
2877inline _LIBCPP_INLINE_VISIBILITY
2878unsigned char
2879atomic_load_explicit(const atomic_uchar* __obj, memory_order __o)
2880{
2881 return atomic_load_explicit(const_cast<const volatile atomic_uchar*>
2882 (__obj), __o);
2883}
2884
2885inline _LIBCPP_INLINE_VISIBILITY
2886unsigned char
2887atomic_exchange(volatile atomic_uchar* __obj, unsigned char __desr)
2888{
2889 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
2890}
2891
2892inline _LIBCPP_INLINE_VISIBILITY
2893unsigned char
2894atomic_exchange(atomic_uchar* __obj, unsigned char __desr)
2895{
2896 return atomic_exchange(const_cast<volatile atomic_uchar*>(__obj), __desr);
2897}
2898
2899inline _LIBCPP_INLINE_VISIBILITY
2900unsigned char
2901atomic_exchange_explicit(volatile atomic_uchar* __obj, unsigned char __desr,
2902 memory_order __o)
2903{
2904 return __atomic_exchange(&__obj->__v_, __desr, __o);
2905}
2906
2907inline _LIBCPP_INLINE_VISIBILITY
2908unsigned char
2909atomic_exchange_explicit(atomic_uchar* __obj, unsigned char __desr,
2910 memory_order __o)
2911{
2912 return atomic_exchange_explicit(const_cast<volatile atomic_uchar*>
2913 (__obj), __desr, __o);
2914}
2915
2916inline _LIBCPP_INLINE_VISIBILITY
2917bool
2918atomic_compare_exchange_weak(volatile atomic_uchar* __obj, unsigned char* __exp,
2919 unsigned char __desr)
2920{
2921 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
2922 memory_order_seq_cst, memory_order_seq_cst);
2923}
2924
2925inline _LIBCPP_INLINE_VISIBILITY
2926bool
2927atomic_compare_exchange_weak(atomic_uchar* __obj, unsigned char* __exp,
2928 unsigned char __desr)
2929{
2930 return atomic_compare_exchange_weak(const_cast<volatile atomic_uchar*>
2931 (__obj), __exp, __desr);
2932}
2933
2934inline _LIBCPP_INLINE_VISIBILITY
2935bool
2936atomic_compare_exchange_strong(volatile atomic_uchar* __obj,
2937 unsigned char* __exp, unsigned char __desr)
2938{
2939 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
2940 memory_order_seq_cst, memory_order_seq_cst);
2941}
2942
2943inline _LIBCPP_INLINE_VISIBILITY
2944bool
2945atomic_compare_exchange_strong(atomic_uchar* __obj, unsigned char* __exp,
2946 unsigned char __desr)
2947{
2948 return atomic_compare_exchange_strong(const_cast<volatile atomic_uchar*>
2949 (__obj), __exp, __desr);
2950}
2951
2952inline _LIBCPP_INLINE_VISIBILITY
2953bool
2954atomic_compare_exchange_weak_explicit(volatile atomic_uchar* __obj,
2955 unsigned char* __exp,
2956 unsigned char __desr, memory_order __s,
2957 memory_order __f)
2958{
2959 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
2960 __f);
2961}
2962
2963inline _LIBCPP_INLINE_VISIBILITY
2964bool
2965atomic_compare_exchange_weak_explicit(atomic_uchar* __obj, unsigned char* __exp,
2966 unsigned char __desr, memory_order __s,
2967 memory_order __f)
2968{
2969 return atomic_compare_exchange_weak_explicit(
2970 const_cast<volatile atomic_uchar*>(__obj), __exp, __desr, __s, __f);
2971}
2972
2973inline _LIBCPP_INLINE_VISIBILITY
2974bool
2975atomic_compare_exchange_strong_explicit(volatile atomic_uchar* __obj,
2976 unsigned char* __exp,
2977 unsigned char __desr, memory_order __s,
2978 memory_order __f)
2979{
2980 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
2981 __f);
2982}
2983
2984inline _LIBCPP_INLINE_VISIBILITY
2985bool
2986atomic_compare_exchange_strong_explicit(atomic_uchar* __obj,
2987 unsigned char* __exp,
2988 unsigned char __desr, memory_order __s,
2989 memory_order __f)
2990{
2991 return atomic_compare_exchange_strong_explicit(
2992 const_cast<volatile atomic_uchar*>(__obj), __exp, __desr, __s, __f);
2993}
2994
2995inline _LIBCPP_INLINE_VISIBILITY
2996unsigned char
2997atomic_fetch_add(volatile atomic_uchar* __obj, unsigned char __v)
2998{
2999 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
3000}
3001
3002inline _LIBCPP_INLINE_VISIBILITY
3003unsigned char
3004atomic_fetch_add(atomic_uchar* __obj, unsigned char __v)
3005{
3006 return atomic_fetch_add(const_cast<volatile atomic_uchar*>(__obj), __v);
3007}
3008
3009inline _LIBCPP_INLINE_VISIBILITY
3010unsigned char
3011atomic_fetch_add_explicit(volatile atomic_uchar* __obj, unsigned char __v,
3012 memory_order __o)
3013{
3014 return __atomic_fetch_add(&__obj->__v_, __v, __o);
3015}
3016
3017inline _LIBCPP_INLINE_VISIBILITY
3018unsigned char
3019atomic_fetch_add_explicit(atomic_uchar* __obj, unsigned char __v,
3020 memory_order __o)
3021{
3022 return atomic_fetch_add_explicit(const_cast<volatile atomic_uchar*>(__obj),
3023 __v, __o);
3024}
3025
3026inline _LIBCPP_INLINE_VISIBILITY
3027unsigned char
3028atomic_fetch_sub(volatile atomic_uchar* __obj, unsigned char __v)
3029{
3030 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
3031}
3032
3033inline _LIBCPP_INLINE_VISIBILITY
3034unsigned char
3035atomic_fetch_sub(atomic_uchar* __obj, unsigned char __v)
3036{
3037 return atomic_fetch_sub(const_cast<volatile atomic_uchar*>(__obj), __v);
3038}
3039
3040inline _LIBCPP_INLINE_VISIBILITY
3041unsigned char
3042atomic_fetch_sub_explicit(volatile atomic_uchar* __obj, unsigned char __v,
3043 memory_order __o)
3044{
3045 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
3046}
3047
3048inline _LIBCPP_INLINE_VISIBILITY
3049unsigned char
3050atomic_fetch_sub_explicit(atomic_uchar* __obj, unsigned char __v,
3051 memory_order __o)
3052{
3053 return atomic_fetch_sub_explicit(const_cast<volatile atomic_uchar*>(__obj),
3054 __v, __o);
3055}
3056
3057inline _LIBCPP_INLINE_VISIBILITY
3058unsigned char
3059atomic_fetch_and(volatile atomic_uchar* __obj, unsigned char __v)
3060{
3061 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
3062}
3063
3064inline _LIBCPP_INLINE_VISIBILITY
3065unsigned char
3066atomic_fetch_and(atomic_uchar* __obj, unsigned char __v)
3067{
3068 return atomic_fetch_and(const_cast<volatile atomic_uchar*>(__obj), __v);
3069}
3070
3071inline _LIBCPP_INLINE_VISIBILITY
3072unsigned char
3073atomic_fetch_and_explicit(volatile atomic_uchar* __obj, unsigned char __v,
3074 memory_order __o)
3075{
3076 return __atomic_fetch_and(&__obj->__v_, __v, __o);
3077}
3078
3079inline _LIBCPP_INLINE_VISIBILITY
3080unsigned char
3081atomic_fetch_and_explicit(atomic_uchar* __obj, unsigned char __v,
3082 memory_order __o)
3083{
3084 return atomic_fetch_and_explicit(const_cast<volatile atomic_uchar*>(__obj),
3085 __v, __o);
3086}
3087
3088inline _LIBCPP_INLINE_VISIBILITY
3089unsigned char
3090atomic_fetch_or(volatile atomic_uchar* __obj, unsigned char __v)
3091{
3092 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
3093}
3094
3095inline _LIBCPP_INLINE_VISIBILITY
3096unsigned char
3097atomic_fetch_or(atomic_uchar* __obj, unsigned char __v)
3098{
3099 return atomic_fetch_or(const_cast<volatile atomic_uchar*>(__obj), __v);
3100}
3101
3102inline _LIBCPP_INLINE_VISIBILITY
3103unsigned char
3104atomic_fetch_or_explicit(volatile atomic_uchar* __obj, unsigned char __v,
3105 memory_order __o)
3106{
3107 return __atomic_fetch_or(&__obj->__v_, __v, __o);
3108}
3109
3110inline _LIBCPP_INLINE_VISIBILITY
3111unsigned char
3112atomic_fetch_or_explicit(atomic_uchar* __obj, unsigned char __v,
3113 memory_order __o)
3114{
3115 return atomic_fetch_or_explicit(const_cast<volatile atomic_uchar*>(__obj),
3116 __v, __o);
3117}
3118
3119inline _LIBCPP_INLINE_VISIBILITY
3120unsigned char
3121atomic_fetch_xor(volatile atomic_uchar* __obj, unsigned char __v)
3122{
3123 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
3124}
3125
3126inline _LIBCPP_INLINE_VISIBILITY
3127unsigned char
3128atomic_fetch_xor(atomic_uchar* __obj, unsigned char __v)
3129{
3130 return atomic_fetch_xor(const_cast<volatile atomic_uchar*>(__obj), __v);
3131}
3132
3133inline _LIBCPP_INLINE_VISIBILITY
3134unsigned char
3135atomic_fetch_xor_explicit(volatile atomic_uchar* __obj, unsigned char __v,
3136 memory_order __o)
3137{
3138 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
3139}
3140
3141inline _LIBCPP_INLINE_VISIBILITY
3142unsigned char
3143atomic_fetch_xor_explicit(atomic_uchar* __obj, unsigned char __v,
3144 memory_order __o)
3145{
3146 return atomic_fetch_xor_explicit(const_cast<volatile atomic_uchar*>(__obj),
3147 __v, __o);
3148}
3149
3150// atomic_short
3151
3152struct atomic_short;
3153
3154bool atomic_is_lock_free(const volatile atomic_short*);
3155bool atomic_is_lock_free(const atomic_short*);
3156void atomic_init(volatile atomic_short*, short);
3157void atomic_init(atomic_short*, short);
3158void atomic_store(volatile atomic_short*, short);
3159void atomic_store(atomic_short*, short);
3160void atomic_store_explicit(volatile atomic_short*, short, memory_order);
3161void atomic_store_explicit(atomic_short*, short, memory_order);
3162short atomic_load(const volatile atomic_short*);
3163short atomic_load(const atomic_short*);
3164short atomic_load_explicit(const volatile atomic_short*, memory_order);
3165short atomic_load_explicit(const atomic_short*, memory_order);
3166short atomic_exchange(volatile atomic_short*, short);
3167short atomic_exchange(atomic_short*, short);
3168short atomic_exchange_explicit(volatile atomic_short*, short, memory_order);
3169short atomic_exchange_explicit(atomic_short*, short, memory_order);
3170bool atomic_compare_exchange_weak(volatile atomic_short*, short*, short);
3171bool atomic_compare_exchange_weak(atomic_short*, short*, short);
3172bool atomic_compare_exchange_strong(volatile atomic_short*, short*, short);
3173bool atomic_compare_exchange_strong(atomic_short*, short*, short);
3174bool atomic_compare_exchange_weak_explicit(volatile atomic_short*, short*,
3175 short, memory_order, memory_order);
3176bool atomic_compare_exchange_weak_explicit(atomic_short*, short*, short,
3177 memory_order, memory_order);
3178bool atomic_compare_exchange_strong_explicit(volatile atomic_short*, short*,
3179 short, memory_order, memory_order);
3180bool atomic_compare_exchange_strong_explicit(atomic_short*, short*, short,
3181 memory_order, memory_order);
3182short atomic_fetch_add(volatile atomic_short*, short);
3183short atomic_fetch_add(atomic_short*, short);
3184short atomic_fetch_add_explicit(volatile atomic_short*, short, memory_order);
3185short atomic_fetch_add_explicit(atomic_short*, short, memory_order);
3186short atomic_fetch_sub(volatile atomic_short*, short);
3187short atomic_fetch_sub(atomic_short*, short);
3188short atomic_fetch_sub_explicit(volatile atomic_short*, short, memory_order);
3189short atomic_fetch_sub_explicit(atomic_short*, short, memory_order);
3190short atomic_fetch_and(volatile atomic_short*, short);
3191short atomic_fetch_and(atomic_short*, short);
3192short atomic_fetch_and_explicit(volatile atomic_short*, short, memory_order);
3193short atomic_fetch_and_explicit(atomic_short*, short, memory_order);
3194short atomic_fetch_or(volatile atomic_short*, short);
3195short atomic_fetch_or(atomic_short*, short);
3196short atomic_fetch_or_explicit(volatile atomic_short*, short, memory_order);
3197short atomic_fetch_or_explicit(atomic_short*, short, memory_order);
3198short atomic_fetch_xor(volatile atomic_short*, short);
3199short atomic_fetch_xor(atomic_short*, short);
3200short atomic_fetch_xor_explicit(volatile atomic_short*, short, memory_order);
3201short atomic_fetch_xor_explicit(atomic_short*, short, memory_order);
3202
3203typedef struct atomic_short
3204{
3205 short __v_;
3206
3207 _LIBCPP_INLINE_VISIBILITY
3208 bool is_lock_free() const volatile
3209 {return atomic_is_lock_free(this);}
3210 _LIBCPP_INLINE_VISIBILITY
3211 bool is_lock_free() const
3212 {return atomic_is_lock_free(this);}
3213 _LIBCPP_INLINE_VISIBILITY
3214 void store(short __v, memory_order __o = memory_order_seq_cst) volatile
3215 {atomic_store_explicit(this, __v, __o);}
3216 _LIBCPP_INLINE_VISIBILITY
3217 void store(short __v, memory_order __o = memory_order_seq_cst)
3218 {atomic_store_explicit(this, __v, __o);}
3219 _LIBCPP_INLINE_VISIBILITY
3220 short load(memory_order __o = memory_order_seq_cst) const volatile
3221 {return atomic_load_explicit(this, __o);}
3222 _LIBCPP_INLINE_VISIBILITY
3223 short load(memory_order __o = memory_order_seq_cst) const
3224 {return atomic_load_explicit(this, __o);}
3225 _LIBCPP_INLINE_VISIBILITY
3226 operator short() const volatile
3227 {return load();}
3228 _LIBCPP_INLINE_VISIBILITY
3229 operator short() const
3230 {return load();}
3231 _LIBCPP_INLINE_VISIBILITY
3232 short exchange(short __v, memory_order __o = memory_order_seq_cst) volatile
3233 {return atomic_exchange_explicit(this, __v, __o);}
3234 _LIBCPP_INLINE_VISIBILITY
3235 short exchange(short __v, memory_order __o = memory_order_seq_cst)
3236 {return atomic_exchange_explicit(this, __v, __o);}
3237 _LIBCPP_INLINE_VISIBILITY
3238 bool compare_exchange_weak(short& __v, short __e, memory_order __s,
3239 memory_order __f) volatile
3240 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3241 __f);}
3242 _LIBCPP_INLINE_VISIBILITY
3243 bool compare_exchange_weak(short& __v, short __e, memory_order __s,
3244 memory_order __f)
3245 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3246 __f);}
3247 _LIBCPP_INLINE_VISIBILITY
3248 bool compare_exchange_strong(short& __v, short __e, memory_order __s,
3249 memory_order __f) volatile
3250 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3251 __f);}
3252 _LIBCPP_INLINE_VISIBILITY
3253 bool compare_exchange_strong(short& __v, short __e, memory_order __s,
3254 memory_order __f)
3255 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3256 __f);}
3257 _LIBCPP_INLINE_VISIBILITY
3258 bool compare_exchange_weak(short& __v, short __e,
3259 memory_order __s = memory_order_seq_cst) volatile
3260 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3261 __translate_memory_order(__s));}
3262 _LIBCPP_INLINE_VISIBILITY
3263 bool compare_exchange_weak(short& __v, short __e,
3264 memory_order __s = memory_order_seq_cst)
3265 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3266 __translate_memory_order(__s));}
3267 _LIBCPP_INLINE_VISIBILITY
3268 bool compare_exchange_strong(short& __v, short __e,
3269 memory_order __s = memory_order_seq_cst) volatile
3270 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3271 __translate_memory_order(__s));}
3272 _LIBCPP_INLINE_VISIBILITY
3273 bool compare_exchange_strong(short& __v, short __e,
3274 memory_order __s = memory_order_seq_cst)
3275 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3276 __translate_memory_order(__s));}
3277 _LIBCPP_INLINE_VISIBILITY
3278 short fetch_add(short __v, memory_order __o = memory_order_seq_cst) volatile
3279 {return atomic_fetch_add_explicit(this, __v, __o);}
3280 _LIBCPP_INLINE_VISIBILITY
3281 short fetch_add(short __v, memory_order __o = memory_order_seq_cst)
3282 {return atomic_fetch_add_explicit(this, __v, __o);}
3283 _LIBCPP_INLINE_VISIBILITY
3284 short fetch_sub(short __v, memory_order __o = memory_order_seq_cst) volatile
3285 {return atomic_fetch_sub_explicit(this, __v, __o);}
3286 _LIBCPP_INLINE_VISIBILITY
3287 short fetch_sub(short __v, memory_order __o = memory_order_seq_cst)
3288 {return atomic_fetch_sub_explicit(this, __v, __o);}
3289 _LIBCPP_INLINE_VISIBILITY
3290 short fetch_and(short __v, memory_order __o = memory_order_seq_cst) volatile
3291 {return atomic_fetch_and_explicit(this, __v, __o);}
3292 _LIBCPP_INLINE_VISIBILITY
3293 short fetch_and(short __v, memory_order __o = memory_order_seq_cst)
3294 {return atomic_fetch_and_explicit(this, __v, __o);}
3295 _LIBCPP_INLINE_VISIBILITY
3296 short fetch_or(short __v, memory_order __o = memory_order_seq_cst) volatile
3297 {return atomic_fetch_or_explicit(this, __v, __o);}
3298 _LIBCPP_INLINE_VISIBILITY
3299 short fetch_or(short __v, memory_order __o = memory_order_seq_cst)
3300 {return atomic_fetch_or_explicit(this, __v, __o);}
3301 _LIBCPP_INLINE_VISIBILITY
3302 short fetch_xor(short __v, memory_order __o = memory_order_seq_cst) volatile
3303 {return atomic_fetch_xor_explicit(this, __v, __o);}
3304 _LIBCPP_INLINE_VISIBILITY
3305 short fetch_xor(short __v, memory_order __o = memory_order_seq_cst)
3306 {return atomic_fetch_xor_explicit(this, __v, __o);}
3307#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
3308 atomic_short() = default;
3309#else
3310 _LIBCPP_INLINE_VISIBILITY
3311 atomic_short() {}
3312#endif
3313 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00003314 constexpr atomic_short(short __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00003315 : __v_(__v) {}
3316#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
3317 atomic_short(const atomic_short&) = delete;
3318 atomic_short& operator=(const atomic_short&) = delete;
3319 atomic_short& operator=(const atomic_short&) volatile = delete;
3320#else
3321private:
3322 atomic_short(const atomic_short&);
3323 atomic_short& operator=(const atomic_short&);
3324 atomic_short& operator=(const atomic_short&) volatile;
3325public:
3326#endif
3327 _LIBCPP_INLINE_VISIBILITY
3328 short operator=(short __v) volatile
3329 {store(__v); return __v;}
3330 _LIBCPP_INLINE_VISIBILITY
3331 short operator=(short __v)
3332 {store(__v); return __v;}
3333 _LIBCPP_INLINE_VISIBILITY
3334 short operator++(int) volatile
3335 {return fetch_add(short(1));}
3336 _LIBCPP_INLINE_VISIBILITY
3337 short operator++(int)
3338 {return fetch_add(short(1));}
3339 _LIBCPP_INLINE_VISIBILITY
3340 short operator--(int) volatile
3341 {return fetch_sub(short(1));}
3342 _LIBCPP_INLINE_VISIBILITY
3343 short operator--(int)
3344 {return fetch_sub(short(1));}
3345 _LIBCPP_INLINE_VISIBILITY
3346 short operator++() volatile
3347 {return short(fetch_add(short(1)) + 1);}
3348 _LIBCPP_INLINE_VISIBILITY
3349 short operator++()
3350 {return short(fetch_add(short(1)) + 1);}
3351 _LIBCPP_INLINE_VISIBILITY
3352 short operator--() volatile
3353 {return short(fetch_sub(short(1)) - 1);}
3354 _LIBCPP_INLINE_VISIBILITY
3355 short operator--()
3356 {return short(fetch_sub(short(1)) - 1);}
3357 _LIBCPP_INLINE_VISIBILITY
3358 short operator+=(short __v) volatile
3359 {return short(fetch_add(__v) + __v);}
3360 _LIBCPP_INLINE_VISIBILITY
3361 short operator+=(short __v)
3362 {return short(fetch_add(__v) + __v);}
3363 _LIBCPP_INLINE_VISIBILITY
3364 short operator-=(short __v) volatile
3365 {return short(fetch_sub(__v) - __v);}
3366 _LIBCPP_INLINE_VISIBILITY
3367 short operator-=(short __v)
3368 {return short(fetch_sub(__v) - __v);}
3369 _LIBCPP_INLINE_VISIBILITY
3370 short operator&=(short __v) volatile
3371 {return short(fetch_and(__v) & __v);}
3372 _LIBCPP_INLINE_VISIBILITY
3373 short operator&=(short __v)
3374 {return short(fetch_and(__v) & __v);}
3375 _LIBCPP_INLINE_VISIBILITY
3376 short operator|=(short __v) volatile
3377 {return short(fetch_or(__v) | __v);}
3378 _LIBCPP_INLINE_VISIBILITY
3379 short operator|=(short __v)
3380 {return short(fetch_or(__v) | __v);}
3381 _LIBCPP_INLINE_VISIBILITY
3382 short operator^=(short __v) volatile
3383 {return short(fetch_xor(__v) ^ __v);}
3384 _LIBCPP_INLINE_VISIBILITY
3385 short operator^=(short __v)
3386 {return short(fetch_xor(__v) ^ __v);}
3387} atomic_short;
3388
3389inline _LIBCPP_INLINE_VISIBILITY
3390bool
3391atomic_is_lock_free(const volatile atomic_short*)
3392{
3393 typedef short type;
3394 return __atomic_is_lock_free(type);
3395}
3396
3397inline _LIBCPP_INLINE_VISIBILITY
3398bool
3399atomic_is_lock_free(const atomic_short* __obj)
3400{
3401 return atomic_is_lock_free(const_cast<volatile atomic_short*>(__obj));
3402}
3403
3404inline _LIBCPP_INLINE_VISIBILITY
3405void
3406atomic_init(volatile atomic_short* __obj, short __desr)
3407{
3408 __obj->__v_ = __desr;
3409}
3410
3411inline _LIBCPP_INLINE_VISIBILITY
3412void
3413atomic_init(atomic_short* __obj, short __desr)
3414{
3415 __obj->__v_ = __desr;
3416}
3417
3418inline _LIBCPP_INLINE_VISIBILITY
3419void
3420atomic_store(volatile atomic_short* __obj, short __desr)
3421{
3422 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
3423}
3424
3425inline _LIBCPP_INLINE_VISIBILITY
3426void
3427atomic_store(atomic_short* __obj, short __desr)
3428{
3429 atomic_store(const_cast<volatile atomic_short*>(__obj), __desr);
3430}
3431
3432inline _LIBCPP_INLINE_VISIBILITY
3433void
3434atomic_store_explicit(volatile atomic_short* __obj, short __desr,
3435 memory_order __o)
3436{
3437 __atomic_store(&__obj->__v_, __desr, __o);
3438}
3439
3440inline _LIBCPP_INLINE_VISIBILITY
3441void
3442atomic_store_explicit(atomic_short* __obj, short __desr, memory_order __o)
3443{
3444 atomic_store_explicit(const_cast<volatile atomic_short*>(__obj), __desr,
3445 __o);
3446}
3447
3448inline _LIBCPP_INLINE_VISIBILITY
3449short
3450atomic_load(const volatile atomic_short* __obj)
3451{
3452 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
3453}
3454
3455inline _LIBCPP_INLINE_VISIBILITY
3456short
3457atomic_load(const atomic_short* __obj)
3458{
3459 return atomic_load(const_cast<const volatile atomic_short*>(__obj));
3460}
3461
3462inline _LIBCPP_INLINE_VISIBILITY
3463short
3464atomic_load_explicit(const volatile atomic_short* __obj, memory_order __o)
3465{
3466 return __atomic_load(&__obj->__v_, __o);
3467}
3468
3469inline _LIBCPP_INLINE_VISIBILITY
3470short
3471atomic_load_explicit(const atomic_short* __obj, memory_order __o)
3472{
3473 return atomic_load_explicit(const_cast<const volatile atomic_short*>
3474 (__obj), __o);
3475}
3476
3477inline _LIBCPP_INLINE_VISIBILITY
3478short
3479atomic_exchange(volatile atomic_short* __obj, short __desr)
3480{
3481 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
3482}
3483
3484inline _LIBCPP_INLINE_VISIBILITY
3485short
3486atomic_exchange(atomic_short* __obj, short __desr)
3487{
3488 return atomic_exchange(const_cast<volatile atomic_short*>(__obj), __desr);
3489}
3490
3491inline _LIBCPP_INLINE_VISIBILITY
3492short
3493atomic_exchange_explicit(volatile atomic_short* __obj, short __desr,
3494 memory_order __o)
3495{
3496 return __atomic_exchange(&__obj->__v_, __desr, __o);
3497}
3498
3499inline _LIBCPP_INLINE_VISIBILITY
3500short
3501atomic_exchange_explicit(atomic_short* __obj, short __desr, memory_order __o)
3502{
3503 return atomic_exchange_explicit(const_cast<volatile atomic_short*>
3504 (__obj), __desr, __o);
3505}
3506
3507inline _LIBCPP_INLINE_VISIBILITY
3508bool
3509atomic_compare_exchange_weak(volatile atomic_short* __obj, short* __exp,
3510 short __desr)
3511{
3512 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
3513 memory_order_seq_cst, memory_order_seq_cst);
3514}
3515
3516inline _LIBCPP_INLINE_VISIBILITY
3517bool
3518atomic_compare_exchange_weak(atomic_short* __obj, short* __exp, short __desr)
3519{
3520 return atomic_compare_exchange_weak(const_cast<volatile atomic_short*>
3521 (__obj), __exp, __desr);
3522}
3523
3524inline _LIBCPP_INLINE_VISIBILITY
3525bool
3526atomic_compare_exchange_strong(volatile atomic_short* __obj, short* __exp,
3527 short __desr)
3528{
3529 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
3530 memory_order_seq_cst, memory_order_seq_cst);
3531}
3532
3533inline _LIBCPP_INLINE_VISIBILITY
3534bool
3535atomic_compare_exchange_strong(atomic_short* __obj, short* __exp, short __desr)
3536{
3537 return atomic_compare_exchange_strong(const_cast<volatile atomic_short*>
3538 (__obj), __exp, __desr);
3539}
3540
3541inline _LIBCPP_INLINE_VISIBILITY
3542bool
3543atomic_compare_exchange_weak_explicit(volatile atomic_short* __obj,
3544 short* __exp, short __desr,
3545 memory_order __s, memory_order __f)
3546{
3547 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
3548 __f);
3549}
3550
3551inline _LIBCPP_INLINE_VISIBILITY
3552bool
3553atomic_compare_exchange_weak_explicit(atomic_short* __obj, short* __exp,
3554 short __desr, memory_order __s,
3555 memory_order __f)
3556{
3557 return atomic_compare_exchange_weak_explicit(
3558 const_cast<volatile atomic_short*>(__obj), __exp, __desr, __s, __f);
3559}
3560
3561inline _LIBCPP_INLINE_VISIBILITY
3562bool
3563atomic_compare_exchange_strong_explicit(volatile atomic_short* __obj,
3564 short* __exp, short __desr,
3565 memory_order __s, memory_order __f)
3566{
3567 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
3568 __f);
3569}
3570
3571inline _LIBCPP_INLINE_VISIBILITY
3572bool
3573atomic_compare_exchange_strong_explicit(atomic_short* __obj, short* __exp,
3574 short __desr, memory_order __s,
3575 memory_order __f)
3576{
3577 return atomic_compare_exchange_strong_explicit(
3578 const_cast<volatile atomic_short*>(__obj), __exp, __desr, __s, __f);
3579}
3580
3581inline _LIBCPP_INLINE_VISIBILITY
3582short
3583atomic_fetch_add(volatile atomic_short* __obj, short __v)
3584{
3585 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
3586}
3587
3588inline _LIBCPP_INLINE_VISIBILITY
3589short
3590atomic_fetch_add(atomic_short* __obj, short __v)
3591{
3592 return atomic_fetch_add(const_cast<volatile atomic_short*>(__obj), __v);
3593}
3594
3595inline _LIBCPP_INLINE_VISIBILITY
3596short
3597atomic_fetch_add_explicit(volatile atomic_short* __obj, short __v,
3598 memory_order __o)
3599{
3600 return __atomic_fetch_add(&__obj->__v_, __v, __o);
3601}
3602
3603inline _LIBCPP_INLINE_VISIBILITY
3604short
3605atomic_fetch_add_explicit(atomic_short* __obj, short __v, memory_order __o)
3606{
3607 return atomic_fetch_add_explicit(const_cast<volatile atomic_short*>(__obj),
3608 __v, __o);
3609}
3610
3611inline _LIBCPP_INLINE_VISIBILITY
3612short
3613atomic_fetch_sub(volatile atomic_short* __obj, short __v)
3614{
3615 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
3616}
3617
3618inline _LIBCPP_INLINE_VISIBILITY
3619short
3620atomic_fetch_sub(atomic_short* __obj, short __v)
3621{
3622 return atomic_fetch_sub(const_cast<volatile atomic_short*>(__obj), __v);
3623}
3624
3625inline _LIBCPP_INLINE_VISIBILITY
3626short
3627atomic_fetch_sub_explicit(volatile atomic_short* __obj, short __v,
3628 memory_order __o)
3629{
3630 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
3631}
3632
3633inline _LIBCPP_INLINE_VISIBILITY
3634short
3635atomic_fetch_sub_explicit(atomic_short* __obj, short __v, memory_order __o)
3636{
3637 return atomic_fetch_sub_explicit(const_cast<volatile atomic_short*>(__obj),
3638 __v, __o);
3639}
3640
3641inline _LIBCPP_INLINE_VISIBILITY
3642short
3643atomic_fetch_and(volatile atomic_short* __obj, short __v)
3644{
3645 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
3646}
3647
3648inline _LIBCPP_INLINE_VISIBILITY
3649short
3650atomic_fetch_and(atomic_short* __obj, short __v)
3651{
3652 return atomic_fetch_and(const_cast<volatile atomic_short*>(__obj), __v);
3653}
3654
3655inline _LIBCPP_INLINE_VISIBILITY
3656short
3657atomic_fetch_and_explicit(volatile atomic_short* __obj, short __v,
3658 memory_order __o)
3659{
3660 return __atomic_fetch_and(&__obj->__v_, __v, __o);
3661}
3662
3663inline _LIBCPP_INLINE_VISIBILITY
3664short
3665atomic_fetch_and_explicit(atomic_short* __obj, short __v, memory_order __o)
3666{
3667 return atomic_fetch_and_explicit(const_cast<volatile atomic_short*>(__obj),
3668 __v, __o);
3669}
3670
3671inline _LIBCPP_INLINE_VISIBILITY
3672short
3673atomic_fetch_or(volatile atomic_short* __obj, short __v)
3674{
3675 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
3676}
3677
3678inline _LIBCPP_INLINE_VISIBILITY
3679short
3680atomic_fetch_or(atomic_short* __obj, short __v)
3681{
3682 return atomic_fetch_or(const_cast<volatile atomic_short*>(__obj), __v);
3683}
3684
3685inline _LIBCPP_INLINE_VISIBILITY
3686short
3687atomic_fetch_or_explicit(volatile atomic_short* __obj, short __v,
3688 memory_order __o)
3689{
3690 return __atomic_fetch_or(&__obj->__v_, __v, __o);
3691}
3692
3693inline _LIBCPP_INLINE_VISIBILITY
3694short
3695atomic_fetch_or_explicit(atomic_short* __obj, short __v, memory_order __o)
3696{
3697 return atomic_fetch_or_explicit(const_cast<volatile atomic_short*>(__obj),
3698 __v, __o);
3699}
3700
3701inline _LIBCPP_INLINE_VISIBILITY
3702short
3703atomic_fetch_xor(volatile atomic_short* __obj, short __v)
3704{
3705 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
3706}
3707
3708inline _LIBCPP_INLINE_VISIBILITY
3709short
3710atomic_fetch_xor(atomic_short* __obj, short __v)
3711{
3712 return atomic_fetch_xor(const_cast<volatile atomic_short*>(__obj), __v);
3713}
3714
3715inline _LIBCPP_INLINE_VISIBILITY
3716short
3717atomic_fetch_xor_explicit(volatile atomic_short* __obj, short __v,
3718 memory_order __o)
3719{
3720 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
3721}
3722
3723inline _LIBCPP_INLINE_VISIBILITY
3724short
3725atomic_fetch_xor_explicit(atomic_short* __obj, short __v, memory_order __o)
3726{
3727 return atomic_fetch_xor_explicit(const_cast<volatile atomic_short*>(__obj),
3728 __v, __o);
3729}
3730
3731// atomic_ushort
3732
3733struct atomic_ushort;
3734
3735bool atomic_is_lock_free(const volatile atomic_ushort*);
3736bool atomic_is_lock_free(const atomic_ushort*);
3737void atomic_init(volatile atomic_ushort*, unsigned short);
3738void atomic_init(atomic_ushort*, unsigned short);
3739void atomic_store(volatile atomic_ushort*, unsigned short);
3740void atomic_store(atomic_ushort*, unsigned short);
3741void atomic_store_explicit(volatile atomic_ushort*, unsigned short,
3742 memory_order);
3743void atomic_store_explicit(atomic_ushort*, unsigned short, memory_order);
3744unsigned short atomic_load(const volatile atomic_ushort*);
3745unsigned short atomic_load(const atomic_ushort*);
3746unsigned short atomic_load_explicit(const volatile atomic_ushort*,
3747 memory_order);
3748unsigned short atomic_load_explicit(const atomic_ushort*, memory_order);
3749unsigned short atomic_exchange(volatile atomic_ushort*, unsigned short);
3750unsigned short atomic_exchange(atomic_ushort*, unsigned short);
3751unsigned short atomic_exchange_explicit(volatile atomic_ushort*, unsigned short,
3752 memory_order);
3753unsigned short atomic_exchange_explicit(atomic_ushort*, unsigned short,
3754 memory_order);
3755bool atomic_compare_exchange_weak(volatile atomic_ushort*, unsigned short*,
3756 unsigned short);
3757bool atomic_compare_exchange_weak(atomic_ushort*, unsigned short*,
3758 unsigned short);
3759bool atomic_compare_exchange_strong(volatile atomic_ushort*, unsigned short*,
3760 unsigned short);
3761bool atomic_compare_exchange_strong(atomic_ushort*, unsigned short*,
3762 unsigned short);
3763bool atomic_compare_exchange_weak_explicit(volatile atomic_ushort*,
3764 unsigned short*, unsigned short,
3765 memory_order, memory_order);
3766bool atomic_compare_exchange_weak_explicit(atomic_ushort*, unsigned short*,
3767 unsigned short, memory_order,
3768 memory_order);
3769bool atomic_compare_exchange_strong_explicit(volatile atomic_ushort*,
3770 unsigned short*, unsigned short,
3771 memory_order, memory_order);
3772bool atomic_compare_exchange_strong_explicit(atomic_ushort*, unsigned short*,
3773 unsigned short, memory_order,
3774 memory_order);
3775unsigned short atomic_fetch_add(volatile atomic_ushort*, unsigned short);
3776unsigned short atomic_fetch_add(atomic_ushort*, unsigned short);
3777unsigned short atomic_fetch_add_explicit(volatile atomic_ushort*,
3778 unsigned short, memory_order);
3779unsigned short atomic_fetch_add_explicit(atomic_ushort*, unsigned short,
3780 memory_order);
3781unsigned short atomic_fetch_sub(volatile atomic_ushort*, unsigned short);
3782unsigned short atomic_fetch_sub(atomic_ushort*, unsigned short);
3783unsigned short atomic_fetch_sub_explicit(volatile atomic_ushort*,
3784 unsigned short, memory_order);
3785unsigned short atomic_fetch_sub_explicit(atomic_ushort*, unsigned short,
3786 memory_order);
3787unsigned short atomic_fetch_and(volatile atomic_ushort*, unsigned short);
3788unsigned short atomic_fetch_and(atomic_ushort*, unsigned short);
3789unsigned short atomic_fetch_and_explicit(volatile atomic_ushort*,
3790 unsigned short, memory_order);
3791unsigned short atomic_fetch_and_explicit(atomic_ushort*, unsigned short,
3792 memory_order);
3793unsigned short atomic_fetch_or(volatile atomic_ushort*, unsigned short);
3794unsigned short atomic_fetch_or(atomic_ushort*, unsigned short);
3795unsigned short atomic_fetch_or_explicit(volatile atomic_ushort*, unsigned short,
3796 memory_order);
3797unsigned short atomic_fetch_or_explicit(atomic_ushort*, unsigned short,
3798 memory_order);
3799unsigned short atomic_fetch_xor(volatile atomic_ushort*, unsigned short);
3800unsigned short atomic_fetch_xor(atomic_ushort*, unsigned short);
3801unsigned short atomic_fetch_xor_explicit(volatile atomic_ushort*,
3802 unsigned short, memory_order);
3803unsigned short atomic_fetch_xor_explicit(atomic_ushort*, unsigned short,
3804 memory_order);
3805
3806typedef struct atomic_ushort
3807{
3808 unsigned short __v_;
3809
3810 _LIBCPP_INLINE_VISIBILITY
3811 bool is_lock_free() const volatile
3812 {return atomic_is_lock_free(this);}
3813 _LIBCPP_INLINE_VISIBILITY
3814 bool is_lock_free() const
3815 {return atomic_is_lock_free(this);}
3816 _LIBCPP_INLINE_VISIBILITY
3817 void store(unsigned short __v,
3818 memory_order __o = memory_order_seq_cst) volatile
3819 {atomic_store_explicit(this, __v, __o);}
3820 _LIBCPP_INLINE_VISIBILITY
3821 void store(unsigned short __v, memory_order __o = memory_order_seq_cst)
3822 {atomic_store_explicit(this, __v, __o);}
3823 _LIBCPP_INLINE_VISIBILITY
3824 unsigned short load(memory_order __o = memory_order_seq_cst) const volatile
3825 {return atomic_load_explicit(this, __o);}
3826 _LIBCPP_INLINE_VISIBILITY
3827 unsigned short load(memory_order __o = memory_order_seq_cst) const
3828 {return atomic_load_explicit(this, __o);}
3829 _LIBCPP_INLINE_VISIBILITY
3830 operator unsigned short() const volatile
3831 {return load();}
3832 _LIBCPP_INLINE_VISIBILITY
3833 operator unsigned short() const
3834 {return load();}
3835 _LIBCPP_INLINE_VISIBILITY
3836 unsigned short exchange(unsigned short __v,
3837 memory_order __o = memory_order_seq_cst) volatile
3838 {return atomic_exchange_explicit(this, __v, __o);}
3839 _LIBCPP_INLINE_VISIBILITY
3840 unsigned short exchange(unsigned short __v,
3841 memory_order __o = memory_order_seq_cst)
3842 {return atomic_exchange_explicit(this, __v, __o);}
3843 _LIBCPP_INLINE_VISIBILITY
3844 bool compare_exchange_weak(unsigned short& __v, unsigned short __e,
3845 memory_order __s, memory_order __f) volatile
3846 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3847 __f);}
3848 _LIBCPP_INLINE_VISIBILITY
3849 bool compare_exchange_weak(unsigned short& __v, unsigned short __e,
3850 memory_order __s, memory_order __f)
3851 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3852 __f);}
3853 _LIBCPP_INLINE_VISIBILITY
3854 bool compare_exchange_strong(unsigned short& __v, unsigned short __e,
3855 memory_order __s, memory_order __f) volatile
3856 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3857 __f);}
3858 _LIBCPP_INLINE_VISIBILITY
3859 bool compare_exchange_strong(unsigned short& __v, unsigned short __e,
3860 memory_order __s, memory_order __f)
3861 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3862 __f);}
3863 _LIBCPP_INLINE_VISIBILITY
3864 bool compare_exchange_weak(unsigned short& __v, unsigned short __e,
3865 memory_order __s = memory_order_seq_cst) volatile
3866 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3867 __translate_memory_order(__s));}
3868 _LIBCPP_INLINE_VISIBILITY
3869 bool compare_exchange_weak(unsigned short& __v, unsigned short __e,
3870 memory_order __s = memory_order_seq_cst)
3871 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
3872 __translate_memory_order(__s));}
3873 _LIBCPP_INLINE_VISIBILITY
3874 bool compare_exchange_strong(unsigned short& __v, unsigned short __e,
3875 memory_order __s = memory_order_seq_cst) volatile
3876 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3877 __translate_memory_order(__s));}
3878 _LIBCPP_INLINE_VISIBILITY
3879 bool compare_exchange_strong(unsigned short& __v, unsigned short __e,
3880 memory_order __s = memory_order_seq_cst)
3881 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
3882 __translate_memory_order(__s));}
3883 _LIBCPP_INLINE_VISIBILITY
3884 unsigned short fetch_add(unsigned short __v,
3885 memory_order __o = memory_order_seq_cst) volatile
3886 {return atomic_fetch_add_explicit(this, __v, __o);}
3887 _LIBCPP_INLINE_VISIBILITY
3888 unsigned short fetch_add(unsigned short __v,
3889 memory_order __o = memory_order_seq_cst)
3890 {return atomic_fetch_add_explicit(this, __v, __o);}
3891 _LIBCPP_INLINE_VISIBILITY
3892 unsigned short fetch_sub(unsigned short __v,
3893 memory_order __o = memory_order_seq_cst) volatile
3894 {return atomic_fetch_sub_explicit(this, __v, __o);}
3895 _LIBCPP_INLINE_VISIBILITY
3896 unsigned short fetch_sub(unsigned short __v,
3897 memory_order __o = memory_order_seq_cst)
3898 {return atomic_fetch_sub_explicit(this, __v, __o);}
3899 _LIBCPP_INLINE_VISIBILITY
3900 unsigned short fetch_and(unsigned short __v,
3901 memory_order __o = memory_order_seq_cst) volatile
3902 {return atomic_fetch_and_explicit(this, __v, __o);}
3903 _LIBCPP_INLINE_VISIBILITY
3904 unsigned short fetch_and(unsigned short __v,
3905 memory_order __o = memory_order_seq_cst)
3906 {return atomic_fetch_and_explicit(this, __v, __o);}
3907 _LIBCPP_INLINE_VISIBILITY
3908 unsigned short fetch_or(unsigned short __v,
3909 memory_order __o = memory_order_seq_cst) volatile
3910 {return atomic_fetch_or_explicit(this, __v, __o);}
3911 _LIBCPP_INLINE_VISIBILITY
3912 unsigned short fetch_or(unsigned short __v,
3913 memory_order __o = memory_order_seq_cst)
3914 {return atomic_fetch_or_explicit(this, __v, __o);}
3915 _LIBCPP_INLINE_VISIBILITY
3916 unsigned short fetch_xor(unsigned short __v,
3917 memory_order __o = memory_order_seq_cst) volatile
3918 {return atomic_fetch_xor_explicit(this, __v, __o);}
3919 _LIBCPP_INLINE_VISIBILITY
3920 unsigned short fetch_xor(unsigned short __v,
3921 memory_order __o = memory_order_seq_cst)
3922 {return atomic_fetch_xor_explicit(this, __v, __o);}
3923#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
3924 atomic_ushort() = default;
3925#else
3926 _LIBCPP_INLINE_VISIBILITY
3927 atomic_ushort() {}
3928#endif
3929 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00003930 constexpr atomic_ushort(unsigned short __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00003931 : __v_(__v) {}
3932#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
3933 atomic_ushort(const atomic_ushort&) = delete;
3934 atomic_ushort& operator=(const atomic_ushort&) = delete;
3935 atomic_ushort& operator=(const atomic_ushort&) volatile = delete;
3936#else
3937private:
3938 atomic_ushort(const atomic_ushort&);
3939 atomic_ushort& operator=(const atomic_ushort&);
3940 atomic_ushort& operator=(const atomic_ushort&) volatile;
3941public:
3942#endif
3943 _LIBCPP_INLINE_VISIBILITY
3944 unsigned short operator=(unsigned short __v) volatile
3945 {store(__v); return __v;}
3946 _LIBCPP_INLINE_VISIBILITY
3947 unsigned short operator=(unsigned short __v)
3948 {store(__v); return __v;}
3949 _LIBCPP_INLINE_VISIBILITY
3950 unsigned short operator++(int) volatile
3951 {typedef unsigned short type; return fetch_add(type(1));}
3952 _LIBCPP_INLINE_VISIBILITY
3953 short operator++(int)
3954 {typedef unsigned short type; return fetch_add(type(1));}
3955 _LIBCPP_INLINE_VISIBILITY
3956 short operator--(int) volatile
3957 {typedef unsigned short type; return fetch_sub(type(1));}
3958 _LIBCPP_INLINE_VISIBILITY
3959 short operator--(int)
3960 {typedef unsigned short type; return fetch_sub(type(1));}
3961 _LIBCPP_INLINE_VISIBILITY
3962 short operator++() volatile
3963 {typedef unsigned short type; return type(fetch_add(type(1)) + 1);}
3964 _LIBCPP_INLINE_VISIBILITY
3965 short operator++()
3966 {typedef unsigned short type; return type(fetch_add(type(1)) + 1);}
3967 _LIBCPP_INLINE_VISIBILITY
3968 short operator--() volatile
3969 {typedef unsigned short type; return type(fetch_sub(type(1)) - 1);}
3970 _LIBCPP_INLINE_VISIBILITY
3971 short operator--()
3972 {typedef unsigned short type; return type(fetch_sub(type(1)) - 1);}
3973 _LIBCPP_INLINE_VISIBILITY
3974 short operator+=(short __v) volatile
3975 {typedef unsigned short type; return type(fetch_add(__v) + __v);}
3976 _LIBCPP_INLINE_VISIBILITY
3977 short operator+=(short __v)
3978 {typedef unsigned short type; return type(fetch_add(__v) + __v);}
3979 _LIBCPP_INLINE_VISIBILITY
3980 short operator-=(short __v) volatile
3981 {typedef unsigned short type; return type(fetch_sub(__v) - __v);}
3982 _LIBCPP_INLINE_VISIBILITY
3983 short operator-=(short __v)
3984 {typedef unsigned short type; return type(fetch_sub(__v) - __v);}
3985 _LIBCPP_INLINE_VISIBILITY
3986 short operator&=(short __v) volatile
3987 {typedef unsigned short type; return type(fetch_and(__v) & __v);}
3988 _LIBCPP_INLINE_VISIBILITY
3989 short operator&=(short __v)
3990 {typedef unsigned short type; return type(fetch_and(__v) & __v);}
3991 _LIBCPP_INLINE_VISIBILITY
3992 short operator|=(short __v) volatile
3993 {typedef unsigned short type; return type(fetch_or(__v) | __v);}
3994 _LIBCPP_INLINE_VISIBILITY
3995 short operator|=(short __v)
3996 {typedef unsigned short type; return type(fetch_or(__v) | __v);}
3997 _LIBCPP_INLINE_VISIBILITY
3998 short operator^=(short __v) volatile
3999 {typedef unsigned short type; return type(fetch_xor(__v) ^ __v);}
4000 _LIBCPP_INLINE_VISIBILITY
4001 short operator^=(short __v)
4002 {typedef unsigned short type; return type(fetch_xor(__v) ^ __v);}
4003} atomic_ushort;
4004
4005inline _LIBCPP_INLINE_VISIBILITY
4006bool
4007atomic_is_lock_free(const volatile atomic_ushort*)
4008{
4009 typedef unsigned short type;
4010 return __atomic_is_lock_free(type);
4011}
4012
4013inline _LIBCPP_INLINE_VISIBILITY
4014bool
4015atomic_is_lock_free(const atomic_ushort* __obj)
4016{
4017 return atomic_is_lock_free(const_cast<volatile atomic_ushort*>(__obj));
4018}
4019
4020inline _LIBCPP_INLINE_VISIBILITY
4021void
4022atomic_init(volatile atomic_ushort* __obj, unsigned short __desr)
4023{
4024 __obj->__v_ = __desr;
4025}
4026
4027inline _LIBCPP_INLINE_VISIBILITY
4028void
4029atomic_init(atomic_ushort* __obj, unsigned short __desr)
4030{
4031 __obj->__v_ = __desr;
4032}
4033
4034inline _LIBCPP_INLINE_VISIBILITY
4035void
4036atomic_store(volatile atomic_ushort* __obj, unsigned short __desr)
4037{
4038 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
4039}
4040
4041inline _LIBCPP_INLINE_VISIBILITY
4042void
4043atomic_store(atomic_ushort* __obj, unsigned short __desr)
4044{
4045 atomic_store(const_cast<volatile atomic_ushort*>(__obj), __desr);
4046}
4047
4048inline _LIBCPP_INLINE_VISIBILITY
4049void
4050atomic_store_explicit(volatile atomic_ushort* __obj, unsigned short __desr,
4051 memory_order __o)
4052{
4053 __atomic_store(&__obj->__v_, __desr, __o);
4054}
4055
4056inline _LIBCPP_INLINE_VISIBILITY
4057void
4058atomic_store_explicit(atomic_ushort* __obj, unsigned short __desr,
4059 memory_order __o)
4060{
4061 atomic_store_explicit(const_cast<volatile atomic_ushort*>(__obj), __desr,
4062 __o);
4063}
4064
4065inline _LIBCPP_INLINE_VISIBILITY
4066unsigned short
4067atomic_load(const volatile atomic_ushort* __obj)
4068{
4069 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
4070}
4071
4072inline _LIBCPP_INLINE_VISIBILITY
4073unsigned short
4074atomic_load(const atomic_ushort* __obj)
4075{
4076 return atomic_load(const_cast<const volatile atomic_ushort*>(__obj));
4077}
4078
4079inline _LIBCPP_INLINE_VISIBILITY
4080unsigned short
4081atomic_load_explicit(const volatile atomic_ushort* __obj, memory_order __o)
4082{
4083 return __atomic_load(&__obj->__v_, __o);
4084}
4085
4086inline _LIBCPP_INLINE_VISIBILITY
4087unsigned short
4088atomic_load_explicit(const atomic_ushort* __obj, memory_order __o)
4089{
4090 return atomic_load_explicit(const_cast<const volatile atomic_ushort*>
4091 (__obj), __o);
4092}
4093
4094inline _LIBCPP_INLINE_VISIBILITY
4095unsigned short
4096atomic_exchange(volatile atomic_ushort* __obj, unsigned short __desr)
4097{
4098 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
4099}
4100
4101inline _LIBCPP_INLINE_VISIBILITY
4102unsigned short
4103atomic_exchange(atomic_ushort* __obj, unsigned short __desr)
4104{
4105 return atomic_exchange(const_cast<volatile atomic_ushort*>(__obj), __desr);
4106}
4107
4108inline _LIBCPP_INLINE_VISIBILITY
4109unsigned short
4110atomic_exchange_explicit(volatile atomic_ushort* __obj, unsigned short __desr,
4111 memory_order __o)
4112{
4113 return __atomic_exchange(&__obj->__v_, __desr, __o);
4114}
4115
4116inline _LIBCPP_INLINE_VISIBILITY
4117unsigned short
4118atomic_exchange_explicit(atomic_ushort* __obj, unsigned short __desr,
4119 memory_order __o)
4120{
4121 return atomic_exchange_explicit(const_cast<volatile atomic_ushort*>
4122 (__obj), __desr, __o);
4123}
4124
4125inline _LIBCPP_INLINE_VISIBILITY
4126bool
4127atomic_compare_exchange_weak(volatile atomic_ushort* __obj,
4128 unsigned short* __exp, unsigned short __desr)
4129{
4130 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
4131 memory_order_seq_cst, memory_order_seq_cst);
4132}
4133
4134inline _LIBCPP_INLINE_VISIBILITY
4135bool
4136atomic_compare_exchange_weak(atomic_ushort* __obj, unsigned short* __exp,
4137 unsigned short __desr)
4138{
4139 return atomic_compare_exchange_weak(const_cast<volatile atomic_ushort*>
4140 (__obj), __exp, __desr);
4141}
4142
4143inline _LIBCPP_INLINE_VISIBILITY
4144bool
4145atomic_compare_exchange_strong(volatile atomic_ushort* __obj,
4146 unsigned short* __exp, unsigned short __desr)
4147{
4148 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
4149 memory_order_seq_cst, memory_order_seq_cst);
4150}
4151
4152inline _LIBCPP_INLINE_VISIBILITY
4153bool
4154atomic_compare_exchange_strong(atomic_ushort* __obj, unsigned short* __exp,
4155 unsigned short __desr)
4156{
4157 return atomic_compare_exchange_strong(const_cast<volatile atomic_ushort*>
4158 (__obj), __exp, __desr);
4159}
4160
4161inline _LIBCPP_INLINE_VISIBILITY
4162bool
4163atomic_compare_exchange_weak_explicit(volatile atomic_ushort* __obj,
4164 unsigned short* __exp,
4165 unsigned short __desr, memory_order __s,
4166 memory_order __f)
4167{
4168 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
4169 __f);
4170}
4171
4172inline _LIBCPP_INLINE_VISIBILITY
4173bool
4174atomic_compare_exchange_weak_explicit(atomic_ushort* __obj,
4175 unsigned short* __exp,
4176 unsigned short __desr, memory_order __s,
4177 memory_order __f)
4178{
4179 return atomic_compare_exchange_weak_explicit(
4180 const_cast<volatile atomic_ushort*>(__obj), __exp, __desr, __s, __f);
4181}
4182
4183inline _LIBCPP_INLINE_VISIBILITY
4184bool
4185atomic_compare_exchange_strong_explicit(volatile atomic_ushort* __obj,
4186 unsigned short* __exp,
4187 unsigned short __desr, memory_order __s,
4188 memory_order __f)
4189{
4190 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
4191 __f);
4192}
4193
4194inline _LIBCPP_INLINE_VISIBILITY
4195bool
4196atomic_compare_exchange_strong_explicit(atomic_ushort* __obj,
4197 unsigned short* __exp,
4198 unsigned short __desr, memory_order __s,
4199 memory_order __f)
4200{
4201 return atomic_compare_exchange_strong_explicit(
4202 const_cast<volatile atomic_ushort*>(__obj), __exp, __desr, __s, __f);
4203}
4204
4205inline _LIBCPP_INLINE_VISIBILITY
4206unsigned short
4207atomic_fetch_add(volatile atomic_ushort* __obj, unsigned short __v)
4208{
4209 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
4210}
4211
4212inline _LIBCPP_INLINE_VISIBILITY
4213unsigned short
4214atomic_fetch_add(atomic_ushort* __obj, unsigned short __v)
4215{
4216 return atomic_fetch_add(const_cast<volatile atomic_ushort*>(__obj), __v);
4217}
4218
4219inline _LIBCPP_INLINE_VISIBILITY
4220unsigned short
4221atomic_fetch_add_explicit(volatile atomic_ushort* __obj, unsigned short __v,
4222 memory_order __o)
4223{
4224 return __atomic_fetch_add(&__obj->__v_, __v, __o);
4225}
4226
4227inline _LIBCPP_INLINE_VISIBILITY
4228unsigned short
4229atomic_fetch_add_explicit(atomic_ushort* __obj, unsigned short __v,
4230 memory_order __o)
4231{
4232 return atomic_fetch_add_explicit(const_cast<volatile atomic_ushort*>(__obj),
4233 __v, __o);
4234}
4235
4236inline _LIBCPP_INLINE_VISIBILITY
4237unsigned short
4238atomic_fetch_sub(volatile atomic_ushort* __obj, unsigned short __v)
4239{
4240 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
4241}
4242
4243inline _LIBCPP_INLINE_VISIBILITY
4244unsigned short
4245atomic_fetch_sub(atomic_ushort* __obj, unsigned short __v)
4246{
4247 return atomic_fetch_sub(const_cast<volatile atomic_ushort*>(__obj), __v);
4248}
4249
4250inline _LIBCPP_INLINE_VISIBILITY
4251unsigned short
4252atomic_fetch_sub_explicit(volatile atomic_ushort* __obj, unsigned short __v,
4253 memory_order __o)
4254{
4255 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
4256}
4257
4258inline _LIBCPP_INLINE_VISIBILITY
4259unsigned short
4260atomic_fetch_sub_explicit(atomic_ushort* __obj, unsigned short __v,
4261 memory_order __o)
4262{
4263 return atomic_fetch_sub_explicit(const_cast<volatile atomic_ushort*>(__obj),
4264 __v, __o);
4265}
4266
4267inline _LIBCPP_INLINE_VISIBILITY
4268unsigned short
4269atomic_fetch_and(volatile atomic_ushort* __obj, unsigned short __v)
4270{
4271 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
4272}
4273
4274inline _LIBCPP_INLINE_VISIBILITY
4275unsigned short
4276atomic_fetch_and(atomic_ushort* __obj, unsigned short __v)
4277{
4278 return atomic_fetch_and(const_cast<volatile atomic_ushort*>(__obj), __v);
4279}
4280
4281inline _LIBCPP_INLINE_VISIBILITY
4282unsigned short
4283atomic_fetch_and_explicit(volatile atomic_ushort* __obj, unsigned short __v,
4284 memory_order __o)
4285{
4286 return __atomic_fetch_and(&__obj->__v_, __v, __o);
4287}
4288
4289inline _LIBCPP_INLINE_VISIBILITY
4290unsigned short
4291atomic_fetch_and_explicit(atomic_ushort* __obj, unsigned short __v,
4292 memory_order __o)
4293{
4294 return atomic_fetch_and_explicit(const_cast<volatile atomic_ushort*>(__obj),
4295 __v, __o);
4296}
4297
4298inline _LIBCPP_INLINE_VISIBILITY
4299unsigned short
4300atomic_fetch_or(volatile atomic_ushort* __obj, unsigned short __v)
4301{
4302 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
4303}
4304
4305inline _LIBCPP_INLINE_VISIBILITY
4306unsigned short
4307atomic_fetch_or(atomic_ushort* __obj, unsigned short __v)
4308{
4309 return atomic_fetch_or(const_cast<volatile atomic_ushort*>(__obj), __v);
4310}
4311
4312inline _LIBCPP_INLINE_VISIBILITY
4313unsigned short
4314atomic_fetch_or_explicit(volatile atomic_ushort* __obj, unsigned short __v,
4315 memory_order __o)
4316{
4317 return __atomic_fetch_or(&__obj->__v_, __v, __o);
4318}
4319
4320inline _LIBCPP_INLINE_VISIBILITY
4321unsigned short
4322atomic_fetch_or_explicit(atomic_ushort* __obj, unsigned short __v,
4323 memory_order __o)
4324{
4325 return atomic_fetch_or_explicit(const_cast<volatile atomic_ushort*>(__obj),
4326 __v, __o);
4327}
4328
4329inline _LIBCPP_INLINE_VISIBILITY
4330unsigned short
4331atomic_fetch_xor(volatile atomic_ushort* __obj, unsigned short __v)
4332{
4333 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
4334}
4335
4336inline _LIBCPP_INLINE_VISIBILITY
4337unsigned short
4338atomic_fetch_xor(atomic_ushort* __obj, unsigned short __v)
4339{
4340 return atomic_fetch_xor(const_cast<volatile atomic_ushort*>(__obj), __v);
4341}
4342
4343inline _LIBCPP_INLINE_VISIBILITY
4344unsigned short
4345atomic_fetch_xor_explicit(volatile atomic_ushort* __obj, unsigned short __v,
4346 memory_order __o)
4347{
4348 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
4349}
4350
4351inline _LIBCPP_INLINE_VISIBILITY
4352unsigned short
4353atomic_fetch_xor_explicit(atomic_ushort* __obj, unsigned short __v,
4354 memory_order __o)
4355{
4356 return atomic_fetch_xor_explicit(const_cast<volatile atomic_ushort*>(__obj),
4357 __v, __o);
4358}
4359
4360// atomic_int
4361
4362struct atomic_int;
4363
4364bool atomic_is_lock_free(const volatile atomic_int*);
4365bool atomic_is_lock_free(const atomic_int*);
4366void atomic_init(volatile atomic_int*, int);
4367void atomic_init(atomic_int*, int);
4368void atomic_store(volatile atomic_int*, int);
4369void atomic_store(atomic_int*, int);
4370void atomic_store_explicit(volatile atomic_int*, int, memory_order);
4371void atomic_store_explicit(atomic_int*, int, memory_order);
4372int atomic_load(const volatile atomic_int*);
4373int atomic_load(const atomic_int*);
4374int atomic_load_explicit(const volatile atomic_int*, memory_order);
4375int atomic_load_explicit(const atomic_int*, memory_order);
4376int atomic_exchange(volatile atomic_int*, int);
4377int atomic_exchange(atomic_int*, int);
4378int atomic_exchange_explicit(volatile atomic_int*, int, memory_order);
4379int atomic_exchange_explicit(atomic_int*, int, memory_order);
4380bool atomic_compare_exchange_weak(volatile atomic_int*, int*, int);
4381bool atomic_compare_exchange_weak(atomic_int*, int*, int);
4382bool atomic_compare_exchange_strong(volatile atomic_int*, int*, int);
4383bool atomic_compare_exchange_strong(atomic_int*, int*, int);
4384bool atomic_compare_exchange_weak_explicit(volatile atomic_int*, int*, int,
4385 memory_order, memory_order);
4386bool atomic_compare_exchange_weak_explicit(atomic_int*, int*, int,
4387 memory_order, memory_order);
4388bool atomic_compare_exchange_strong_explicit(volatile atomic_int*, int*, int,
4389 memory_order, memory_order);
4390bool atomic_compare_exchange_strong_explicit(atomic_int*, int*, int,
4391 memory_order, memory_order);
4392int atomic_fetch_add(volatile atomic_int*, int);
4393int atomic_fetch_add(atomic_int*, int);
4394int atomic_fetch_add_explicit(volatile atomic_int*, int, memory_order);
4395int atomic_fetch_add_explicit(atomic_int*, int, memory_order);
4396int atomic_fetch_sub(volatile atomic_int*, int);
4397int atomic_fetch_sub(atomic_int*, int);
4398int atomic_fetch_sub_explicit(volatile atomic_int*, int, memory_order);
4399int atomic_fetch_sub_explicit(atomic_int*, int, memory_order);
4400int atomic_fetch_and(volatile atomic_int*, int);
4401int atomic_fetch_and(atomic_int*, int);
4402int atomic_fetch_and_explicit(volatile atomic_int*, int, memory_order);
4403int atomic_fetch_and_explicit(atomic_int*, int, memory_order);
4404int atomic_fetch_or(volatile atomic_int*, int);
4405int atomic_fetch_or(atomic_int*, int);
4406int atomic_fetch_or_explicit(volatile atomic_int*, int, memory_order);
4407int atomic_fetch_or_explicit(atomic_int*, int, memory_order);
4408int atomic_fetch_xor(volatile atomic_int*, int);
4409int atomic_fetch_xor(atomic_int*, int);
4410int atomic_fetch_xor_explicit(volatile atomic_int*, int, memory_order);
4411int atomic_fetch_xor_explicit(atomic_int*, int, memory_order);
4412
4413typedef struct atomic_int
4414{
4415 int __v_;
4416
4417 _LIBCPP_INLINE_VISIBILITY
4418 bool is_lock_free() const volatile
4419 {return atomic_is_lock_free(this);}
4420 _LIBCPP_INLINE_VISIBILITY
4421 bool is_lock_free() const
4422 {return atomic_is_lock_free(this);}
4423 _LIBCPP_INLINE_VISIBILITY
4424 void store(int __v, memory_order __o = memory_order_seq_cst) volatile
4425 {atomic_store_explicit(this, __v, __o);}
4426 _LIBCPP_INLINE_VISIBILITY
4427 void store(int __v, memory_order __o = memory_order_seq_cst)
4428 {atomic_store_explicit(this, __v, __o);}
4429 _LIBCPP_INLINE_VISIBILITY
4430 int load(memory_order __o = memory_order_seq_cst) const volatile
4431 {return atomic_load_explicit(this, __o);}
4432 _LIBCPP_INLINE_VISIBILITY
4433 int load(memory_order __o = memory_order_seq_cst) const
4434 {return atomic_load_explicit(this, __o);}
4435 _LIBCPP_INLINE_VISIBILITY
4436 operator int() const volatile
4437 {return load();}
4438 _LIBCPP_INLINE_VISIBILITY
4439 operator int() const
4440 {return load();}
4441 _LIBCPP_INLINE_VISIBILITY
4442 int exchange(int __v, memory_order __o = memory_order_seq_cst) volatile
4443 {return atomic_exchange_explicit(this, __v, __o);}
4444 _LIBCPP_INLINE_VISIBILITY
4445 int exchange(int __v, memory_order __o = memory_order_seq_cst)
4446 {return atomic_exchange_explicit(this, __v, __o);}
4447 _LIBCPP_INLINE_VISIBILITY
4448 bool compare_exchange_weak(int& __v, int __e, memory_order __s,
4449 memory_order __f) volatile
4450 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
4451 __f);}
4452 _LIBCPP_INLINE_VISIBILITY
4453 bool compare_exchange_weak(int& __v, int __e, memory_order __s,
4454 memory_order __f)
4455 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
4456 __f);}
4457 _LIBCPP_INLINE_VISIBILITY
4458 bool compare_exchange_strong(int& __v, int __e, memory_order __s,
4459 memory_order __f) volatile
4460 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
4461 __f);}
4462 _LIBCPP_INLINE_VISIBILITY
4463 bool compare_exchange_strong(int& __v, int __e, memory_order __s,
4464 memory_order __f)
4465 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
4466 __f);}
4467 _LIBCPP_INLINE_VISIBILITY
4468 bool compare_exchange_weak(int& __v, int __e,
4469 memory_order __s = memory_order_seq_cst) volatile
4470 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
4471 __translate_memory_order(__s));}
4472 _LIBCPP_INLINE_VISIBILITY
4473 bool compare_exchange_weak(int& __v, int __e,
4474 memory_order __s = memory_order_seq_cst)
4475 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
4476 __translate_memory_order(__s));}
4477 _LIBCPP_INLINE_VISIBILITY
4478 bool compare_exchange_strong(int& __v, int __e,
4479 memory_order __s = memory_order_seq_cst) volatile
4480 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
4481 __translate_memory_order(__s));}
4482 _LIBCPP_INLINE_VISIBILITY
4483 bool compare_exchange_strong(int& __v, int __e,
4484 memory_order __s = memory_order_seq_cst)
4485 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
4486 __translate_memory_order(__s));}
4487 _LIBCPP_INLINE_VISIBILITY
4488 int fetch_add(int __v, memory_order __o = memory_order_seq_cst) volatile
4489 {return atomic_fetch_add_explicit(this, __v, __o);}
4490 _LIBCPP_INLINE_VISIBILITY
4491 int fetch_add(int __v, memory_order __o = memory_order_seq_cst)
4492 {return atomic_fetch_add_explicit(this, __v, __o);}
4493 _LIBCPP_INLINE_VISIBILITY
4494 int fetch_sub(int __v, memory_order __o = memory_order_seq_cst) volatile
4495 {return atomic_fetch_sub_explicit(this, __v, __o);}
4496 _LIBCPP_INLINE_VISIBILITY
4497 int fetch_sub(int __v, memory_order __o = memory_order_seq_cst)
4498 {return atomic_fetch_sub_explicit(this, __v, __o);}
4499 _LIBCPP_INLINE_VISIBILITY
4500 int fetch_and(int __v, memory_order __o = memory_order_seq_cst) volatile
4501 {return atomic_fetch_and_explicit(this, __v, __o);}
4502 _LIBCPP_INLINE_VISIBILITY
4503 int fetch_and(int __v, memory_order __o = memory_order_seq_cst)
4504 {return atomic_fetch_and_explicit(this, __v, __o);}
4505 _LIBCPP_INLINE_VISIBILITY
4506 int fetch_or(int __v, memory_order __o = memory_order_seq_cst) volatile
4507 {return atomic_fetch_or_explicit(this, __v, __o);}
4508 _LIBCPP_INLINE_VISIBILITY
4509 int fetch_or(int __v, memory_order __o = memory_order_seq_cst)
4510 {return atomic_fetch_or_explicit(this, __v, __o);}
4511 _LIBCPP_INLINE_VISIBILITY
4512 int fetch_xor(int __v, memory_order __o = memory_order_seq_cst) volatile
4513 {return atomic_fetch_xor_explicit(this, __v, __o);}
4514 _LIBCPP_INLINE_VISIBILITY
4515 int fetch_xor(int __v, memory_order __o = memory_order_seq_cst)
4516 {return atomic_fetch_xor_explicit(this, __v, __o);}
4517#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
4518 atomic_int() = default;
4519#else
4520 _LIBCPP_INLINE_VISIBILITY
4521 atomic_int() {}
4522#endif
4523 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00004524 constexpr atomic_int(int __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00004525 : __v_(__v) {}
4526#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
4527 atomic_int(const atomic_int&) = delete;
4528 atomic_int& operator=(const atomic_int&) = delete;
4529 atomic_int& operator=(const atomic_int&) volatile = delete;
4530#else
4531private:
4532 atomic_int(const atomic_int&);
4533 atomic_int& operator=(const atomic_int&);
4534 atomic_int& operator=(const atomic_int&) volatile;
4535public:
4536#endif
4537 _LIBCPP_INLINE_VISIBILITY
4538 int operator=(int __v) volatile
4539 {store(__v); return __v;}
4540 _LIBCPP_INLINE_VISIBILITY
4541 int operator=(int __v)
4542 {store(__v); return __v;}
4543 _LIBCPP_INLINE_VISIBILITY
4544 int operator++(int) volatile
4545 {return fetch_add(int(1));}
4546 _LIBCPP_INLINE_VISIBILITY
4547 int operator++(int)
4548 {return fetch_add(int(1));}
4549 _LIBCPP_INLINE_VISIBILITY
4550 int operator--(int) volatile
4551 {return fetch_sub(int(1));}
4552 _LIBCPP_INLINE_VISIBILITY
4553 int operator--(int)
4554 {return fetch_sub(int(1));}
4555 _LIBCPP_INLINE_VISIBILITY
4556 int operator++() volatile
4557 {return int(fetch_add(int(1)) + 1);}
4558 _LIBCPP_INLINE_VISIBILITY
4559 int operator++()
4560 {return int(fetch_add(int(1)) + 1);}
4561 _LIBCPP_INLINE_VISIBILITY
4562 int operator--() volatile
4563 {return int(fetch_sub(int(1)) - 1);}
4564 _LIBCPP_INLINE_VISIBILITY
4565 int operator--()
4566 {return int(fetch_sub(int(1)) - 1);}
4567 _LIBCPP_INLINE_VISIBILITY
4568 int operator+=(int __v) volatile
4569 {return int(fetch_add(__v) + __v);}
4570 _LIBCPP_INLINE_VISIBILITY
4571 int operator+=(int __v)
4572 {return int(fetch_add(__v) + __v);}
4573 _LIBCPP_INLINE_VISIBILITY
4574 int operator-=(int __v) volatile
4575 {return int(fetch_sub(__v) - __v);}
4576 _LIBCPP_INLINE_VISIBILITY
4577 int operator-=(int __v)
4578 {return int(fetch_sub(__v) - __v);}
4579 _LIBCPP_INLINE_VISIBILITY
4580 int operator&=(int __v) volatile
4581 {return int(fetch_and(__v) & __v);}
4582 _LIBCPP_INLINE_VISIBILITY
4583 int operator&=(int __v)
4584 {return int(fetch_and(__v) & __v);}
4585 _LIBCPP_INLINE_VISIBILITY
4586 int operator|=(int __v) volatile
4587 {return int(fetch_or(__v) | __v);}
4588 _LIBCPP_INLINE_VISIBILITY
4589 int operator|=(int __v)
4590 {return int(fetch_or(__v) | __v);}
4591 _LIBCPP_INLINE_VISIBILITY
4592 int operator^=(int __v) volatile
4593 {return int(fetch_xor(__v) ^ __v);}
4594 _LIBCPP_INLINE_VISIBILITY
4595 int operator^=(int __v)
4596 {return int(fetch_xor(__v) ^ __v);}
4597} atomic_int;
4598
4599inline _LIBCPP_INLINE_VISIBILITY
4600bool
4601atomic_is_lock_free(const volatile atomic_int*)
4602{
4603 typedef int type;
4604 return __atomic_is_lock_free(type);
4605}
4606
4607inline _LIBCPP_INLINE_VISIBILITY
4608bool
4609atomic_is_lock_free(const atomic_int* __obj)
4610{
4611 return atomic_is_lock_free(const_cast<volatile atomic_int*>(__obj));
4612}
4613
4614inline _LIBCPP_INLINE_VISIBILITY
4615void
4616atomic_init(volatile atomic_int* __obj, int __desr)
4617{
4618 __obj->__v_ = __desr;
4619}
4620
4621inline _LIBCPP_INLINE_VISIBILITY
4622void
4623atomic_init(atomic_int* __obj, int __desr)
4624{
4625 __obj->__v_ = __desr;
4626}
4627
4628inline _LIBCPP_INLINE_VISIBILITY
4629void
4630atomic_store(volatile atomic_int* __obj, int __desr)
4631{
4632 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
4633}
4634
4635inline _LIBCPP_INLINE_VISIBILITY
4636void
4637atomic_store(atomic_int* __obj, int __desr)
4638{
4639 atomic_store(const_cast<volatile atomic_int*>(__obj), __desr);
4640}
4641
4642inline _LIBCPP_INLINE_VISIBILITY
4643void
4644atomic_store_explicit(volatile atomic_int* __obj, int __desr,
4645 memory_order __o)
4646{
4647 __atomic_store(&__obj->__v_, __desr, __o);
4648}
4649
4650inline _LIBCPP_INLINE_VISIBILITY
4651void
4652atomic_store_explicit(atomic_int* __obj, int __desr, memory_order __o)
4653{
4654 atomic_store_explicit(const_cast<volatile atomic_int*>(__obj), __desr,
4655 __o);
4656}
4657
4658inline _LIBCPP_INLINE_VISIBILITY
4659int
4660atomic_load(const volatile atomic_int* __obj)
4661{
4662 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
4663}
4664
4665inline _LIBCPP_INLINE_VISIBILITY
4666int
4667atomic_load(const atomic_int* __obj)
4668{
4669 return atomic_load(const_cast<const volatile atomic_int*>(__obj));
4670}
4671
4672inline _LIBCPP_INLINE_VISIBILITY
4673int
4674atomic_load_explicit(const volatile atomic_int* __obj, memory_order __o)
4675{
4676 return __atomic_load(&__obj->__v_, __o);
4677}
4678
4679inline _LIBCPP_INLINE_VISIBILITY
4680int
4681atomic_load_explicit(const atomic_int* __obj, memory_order __o)
4682{
4683 return atomic_load_explicit(const_cast<const volatile atomic_int*>
4684 (__obj), __o);
4685}
4686
4687inline _LIBCPP_INLINE_VISIBILITY
4688int
4689atomic_exchange(volatile atomic_int* __obj, int __desr)
4690{
4691 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
4692}
4693
4694inline _LIBCPP_INLINE_VISIBILITY
4695int
4696atomic_exchange(atomic_int* __obj, int __desr)
4697{
4698 return atomic_exchange(const_cast<volatile atomic_int*>(__obj), __desr);
4699}
4700
4701inline _LIBCPP_INLINE_VISIBILITY
4702int
4703atomic_exchange_explicit(volatile atomic_int* __obj, int __desr,
4704 memory_order __o)
4705{
4706 return __atomic_exchange(&__obj->__v_, __desr, __o);
4707}
4708
4709inline _LIBCPP_INLINE_VISIBILITY
4710int
4711atomic_exchange_explicit(atomic_int* __obj, int __desr, memory_order __o)
4712{
4713 return atomic_exchange_explicit(const_cast<volatile atomic_int*>
4714 (__obj), __desr, __o);
4715}
4716
4717inline _LIBCPP_INLINE_VISIBILITY
4718bool
4719atomic_compare_exchange_weak(volatile atomic_int* __obj, int* __exp,
4720 int __desr)
4721{
4722 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
4723 memory_order_seq_cst, memory_order_seq_cst);
4724}
4725
4726inline _LIBCPP_INLINE_VISIBILITY
4727bool
4728atomic_compare_exchange_weak(atomic_int* __obj, int* __exp, int __desr)
4729{
4730 return atomic_compare_exchange_weak(const_cast<volatile atomic_int*>
4731 (__obj), __exp, __desr);
4732}
4733
4734inline _LIBCPP_INLINE_VISIBILITY
4735bool
4736atomic_compare_exchange_strong(volatile atomic_int* __obj, int* __exp,
4737 int __desr)
4738{
4739 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
4740 memory_order_seq_cst, memory_order_seq_cst);
4741}
4742
4743inline _LIBCPP_INLINE_VISIBILITY
4744bool
4745atomic_compare_exchange_strong(atomic_int* __obj, int* __exp, int __desr)
4746{
4747 return atomic_compare_exchange_strong(const_cast<volatile atomic_int*>
4748 (__obj), __exp, __desr);
4749}
4750
4751inline _LIBCPP_INLINE_VISIBILITY
4752bool
4753atomic_compare_exchange_weak_explicit(volatile atomic_int* __obj, int* __exp,
4754 int __desr, memory_order __s,
4755 memory_order __f)
4756{
4757 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
4758 __f);
4759}
4760
4761inline _LIBCPP_INLINE_VISIBILITY
4762bool
4763atomic_compare_exchange_weak_explicit(atomic_int* __obj, int* __exp,
4764 int __desr, memory_order __s,
4765 memory_order __f)
4766{
4767 return atomic_compare_exchange_weak_explicit(
4768 const_cast<volatile atomic_int*>(__obj), __exp, __desr, __s, __f);
4769}
4770
4771inline _LIBCPP_INLINE_VISIBILITY
4772bool
4773atomic_compare_exchange_strong_explicit(volatile atomic_int* __obj,
4774 int* __exp, int __desr,
4775 memory_order __s, memory_order __f)
4776{
4777 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
4778 __f);
4779}
4780
4781inline _LIBCPP_INLINE_VISIBILITY
4782bool
4783atomic_compare_exchange_strong_explicit(atomic_int* __obj, int* __exp,
4784 int __desr, memory_order __s,
4785 memory_order __f)
4786{
4787 return atomic_compare_exchange_strong_explicit(
4788 const_cast<volatile atomic_int*>(__obj), __exp, __desr, __s, __f);
4789}
4790
4791inline _LIBCPP_INLINE_VISIBILITY
4792int
4793atomic_fetch_add(volatile atomic_int* __obj, int __v)
4794{
4795 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
4796}
4797
4798inline _LIBCPP_INLINE_VISIBILITY
4799int
4800atomic_fetch_add(atomic_int* __obj, int __v)
4801{
4802 return atomic_fetch_add(const_cast<volatile atomic_int*>(__obj), __v);
4803}
4804
4805inline _LIBCPP_INLINE_VISIBILITY
4806int
4807atomic_fetch_add_explicit(volatile atomic_int* __obj, int __v,
4808 memory_order __o)
4809{
4810 return __atomic_fetch_add(&__obj->__v_, __v, __o);
4811}
4812
4813inline _LIBCPP_INLINE_VISIBILITY
4814int
4815atomic_fetch_add_explicit(atomic_int* __obj, int __v, memory_order __o)
4816{
4817 return atomic_fetch_add_explicit(const_cast<volatile atomic_int*>(__obj),
4818 __v, __o);
4819}
4820
4821inline _LIBCPP_INLINE_VISIBILITY
4822int
4823atomic_fetch_sub(volatile atomic_int* __obj, int __v)
4824{
4825 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
4826}
4827
4828inline _LIBCPP_INLINE_VISIBILITY
4829int
4830atomic_fetch_sub(atomic_int* __obj, int __v)
4831{
4832 return atomic_fetch_sub(const_cast<volatile atomic_int*>(__obj), __v);
4833}
4834
4835inline _LIBCPP_INLINE_VISIBILITY
4836int
4837atomic_fetch_sub_explicit(volatile atomic_int* __obj, int __v,
4838 memory_order __o)
4839{
4840 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
4841}
4842
4843inline _LIBCPP_INLINE_VISIBILITY
4844int
4845atomic_fetch_sub_explicit(atomic_int* __obj, int __v, memory_order __o)
4846{
4847 return atomic_fetch_sub_explicit(const_cast<volatile atomic_int*>(__obj),
4848 __v, __o);
4849}
4850
4851inline _LIBCPP_INLINE_VISIBILITY
4852int
4853atomic_fetch_and(volatile atomic_int* __obj, int __v)
4854{
4855 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
4856}
4857
4858inline _LIBCPP_INLINE_VISIBILITY
4859int
4860atomic_fetch_and(atomic_int* __obj, int __v)
4861{
4862 return atomic_fetch_and(const_cast<volatile atomic_int*>(__obj), __v);
4863}
4864
4865inline _LIBCPP_INLINE_VISIBILITY
4866int
4867atomic_fetch_and_explicit(volatile atomic_int* __obj, int __v,
4868 memory_order __o)
4869{
4870 return __atomic_fetch_and(&__obj->__v_, __v, __o);
4871}
4872
4873inline _LIBCPP_INLINE_VISIBILITY
4874int
4875atomic_fetch_and_explicit(atomic_int* __obj, int __v, memory_order __o)
4876{
4877 return atomic_fetch_and_explicit(const_cast<volatile atomic_int*>(__obj),
4878 __v, __o);
4879}
4880
4881inline _LIBCPP_INLINE_VISIBILITY
4882int
4883atomic_fetch_or(volatile atomic_int* __obj, int __v)
4884{
4885 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
4886}
4887
4888inline _LIBCPP_INLINE_VISIBILITY
4889int
4890atomic_fetch_or(atomic_int* __obj, int __v)
4891{
4892 return atomic_fetch_or(const_cast<volatile atomic_int*>(__obj), __v);
4893}
4894
4895inline _LIBCPP_INLINE_VISIBILITY
4896int
4897atomic_fetch_or_explicit(volatile atomic_int* __obj, int __v,
4898 memory_order __o)
4899{
4900 return __atomic_fetch_or(&__obj->__v_, __v, __o);
4901}
4902
4903inline _LIBCPP_INLINE_VISIBILITY
4904int
4905atomic_fetch_or_explicit(atomic_int* __obj, int __v, memory_order __o)
4906{
4907 return atomic_fetch_or_explicit(const_cast<volatile atomic_int*>(__obj),
4908 __v, __o);
4909}
4910
4911inline _LIBCPP_INLINE_VISIBILITY
4912int
4913atomic_fetch_xor(volatile atomic_int* __obj, int __v)
4914{
4915 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
4916}
4917
4918inline _LIBCPP_INLINE_VISIBILITY
4919int
4920atomic_fetch_xor(atomic_int* __obj, int __v)
4921{
4922 return atomic_fetch_xor(const_cast<volatile atomic_int*>(__obj), __v);
4923}
4924
4925inline _LIBCPP_INLINE_VISIBILITY
4926int
4927atomic_fetch_xor_explicit(volatile atomic_int* __obj, int __v,
4928 memory_order __o)
4929{
4930 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
4931}
4932
4933inline _LIBCPP_INLINE_VISIBILITY
4934int
4935atomic_fetch_xor_explicit(atomic_int* __obj, int __v, memory_order __o)
4936{
4937 return atomic_fetch_xor_explicit(const_cast<volatile atomic_int*>(__obj),
4938 __v, __o);
4939}
4940
4941// atomic_uint
4942
4943struct atomic_uint;
4944
4945bool atomic_is_lock_free(const volatile atomic_uint*);
4946bool atomic_is_lock_free(const atomic_uint*);
4947void atomic_init(volatile atomic_uint*, unsigned int);
4948void atomic_init(atomic_uint*, unsigned int);
4949void atomic_store(volatile atomic_uint*, unsigned int);
4950void atomic_store(atomic_uint*, unsigned int);
4951void atomic_store_explicit(volatile atomic_uint*, unsigned int, memory_order);
4952void atomic_store_explicit(atomic_uint*, unsigned int, memory_order);
4953unsigned int atomic_load(const volatile atomic_uint*);
4954unsigned int atomic_load(const atomic_uint*);
4955unsigned int atomic_load_explicit(const volatile atomic_uint*, memory_order);
4956unsigned int atomic_load_explicit(const atomic_uint*, memory_order);
4957unsigned int atomic_exchange(volatile atomic_uint*, unsigned int);
4958unsigned int atomic_exchange(atomic_uint*, unsigned int);
4959unsigned int atomic_exchange_explicit(volatile atomic_uint*, unsigned int,
4960 memory_order);
4961unsigned int atomic_exchange_explicit(atomic_uint*, unsigned int,
4962 memory_order);
4963bool atomic_compare_exchange_weak(volatile atomic_uint*, unsigned int*,
4964 unsigned int);
4965bool atomic_compare_exchange_weak(atomic_uint*, unsigned int*, unsigned int);
4966bool atomic_compare_exchange_strong(volatile atomic_uint*, unsigned int*,
4967 unsigned int);
4968bool atomic_compare_exchange_strong(atomic_uint*, unsigned int*,
4969 unsigned int);
4970bool atomic_compare_exchange_weak_explicit(volatile atomic_uint*,
4971 unsigned int*, unsigned int,
4972 memory_order, memory_order);
4973bool atomic_compare_exchange_weak_explicit(atomic_uint*, unsigned int*,
4974 unsigned int, memory_order,
4975 memory_order);
4976bool atomic_compare_exchange_strong_explicit(volatile atomic_uint*,
4977 unsigned int*, unsigned int,
4978 memory_order, memory_order);
4979bool atomic_compare_exchange_strong_explicit(atomic_uint*, unsigned int*,
4980 unsigned int, memory_order,
4981 memory_order);
4982unsigned int atomic_fetch_add(volatile atomic_uint*, unsigned int);
4983unsigned int atomic_fetch_add(atomic_uint*, unsigned int);
4984unsigned int atomic_fetch_add_explicit(volatile atomic_uint*, unsigned int,
4985 memory_order);
4986unsigned int atomic_fetch_add_explicit(atomic_uint*, unsigned int,
4987 memory_order);
4988unsigned int atomic_fetch_sub(volatile atomic_uint*, unsigned int);
4989unsigned int atomic_fetch_sub(atomic_uint*, unsigned int);
4990unsigned int atomic_fetch_sub_explicit(volatile atomic_uint*, unsigned int,
4991 memory_order);
4992unsigned int atomic_fetch_sub_explicit(atomic_uint*, unsigned int,
4993 memory_order);
4994unsigned int atomic_fetch_and(volatile atomic_uint*, unsigned int);
4995unsigned int atomic_fetch_and(atomic_uint*, unsigned int);
4996unsigned int atomic_fetch_and_explicit(volatile atomic_uint*, unsigned int,
4997 memory_order);
4998unsigned int atomic_fetch_and_explicit(atomic_uint*, unsigned int,
4999 memory_order);
5000unsigned int atomic_fetch_or(volatile atomic_uint*, unsigned int);
5001unsigned int atomic_fetch_or(atomic_uint*, unsigned int);
5002unsigned int atomic_fetch_or_explicit(volatile atomic_uint*, unsigned int,
5003 memory_order);
5004unsigned int atomic_fetch_or_explicit(atomic_uint*, unsigned int,
5005 memory_order);
5006unsigned int atomic_fetch_xor(volatile atomic_uint*, unsigned int);
5007unsigned int atomic_fetch_xor(atomic_uint*, unsigned int);
5008unsigned int atomic_fetch_xor_explicit(volatile atomic_uint*, unsigned int,
5009 memory_order);
5010unsigned int atomic_fetch_xor_explicit(atomic_uint*, unsigned int,
5011 memory_order);
5012
5013typedef struct atomic_uint
5014{
5015 unsigned int __v_;
5016
5017 _LIBCPP_INLINE_VISIBILITY
5018 bool is_lock_free() const volatile
5019 {return atomic_is_lock_free(this);}
5020 _LIBCPP_INLINE_VISIBILITY
5021 bool is_lock_free() const
5022 {return atomic_is_lock_free(this);}
5023 _LIBCPP_INLINE_VISIBILITY
5024 void store(unsigned int __v,
5025 memory_order __o = memory_order_seq_cst) volatile
5026 {atomic_store_explicit(this, __v, __o);}
5027 _LIBCPP_INLINE_VISIBILITY
5028 void store(unsigned int __v, memory_order __o = memory_order_seq_cst)
5029 {atomic_store_explicit(this, __v, __o);}
5030 _LIBCPP_INLINE_VISIBILITY
5031 unsigned int load(memory_order __o = memory_order_seq_cst) const volatile
5032 {return atomic_load_explicit(this, __o);}
5033 _LIBCPP_INLINE_VISIBILITY
5034 unsigned int load(memory_order __o = memory_order_seq_cst) const
5035 {return atomic_load_explicit(this, __o);}
5036 _LIBCPP_INLINE_VISIBILITY
5037 operator unsigned int() const volatile
5038 {return load();}
5039 _LIBCPP_INLINE_VISIBILITY
5040 operator unsigned int() const
5041 {return load();}
5042 _LIBCPP_INLINE_VISIBILITY
5043 unsigned int exchange(unsigned int __v,
5044 memory_order __o = memory_order_seq_cst) volatile
5045 {return atomic_exchange_explicit(this, __v, __o);}
5046 _LIBCPP_INLINE_VISIBILITY
5047 unsigned int exchange(unsigned int __v,
5048 memory_order __o = memory_order_seq_cst)
5049 {return atomic_exchange_explicit(this, __v, __o);}
5050 _LIBCPP_INLINE_VISIBILITY
5051 bool compare_exchange_weak(unsigned int& __v, unsigned int __e,
5052 memory_order __s, memory_order __f) volatile
5053 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5054 __f);}
5055 _LIBCPP_INLINE_VISIBILITY
5056 bool compare_exchange_weak(unsigned int& __v, unsigned int __e,
5057 memory_order __s, memory_order __f)
5058 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5059 __f);}
5060 _LIBCPP_INLINE_VISIBILITY
5061 bool compare_exchange_strong(unsigned int& __v, unsigned int __e,
5062 memory_order __s, memory_order __f) volatile
5063 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5064 __f);}
5065 _LIBCPP_INLINE_VISIBILITY
5066 bool compare_exchange_strong(unsigned int& __v, unsigned int __e,
5067 memory_order __s, memory_order __f)
5068 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5069 __f);}
5070 _LIBCPP_INLINE_VISIBILITY
5071 bool compare_exchange_weak(unsigned int& __v, unsigned int __e,
5072 memory_order __s = memory_order_seq_cst) volatile
5073 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5074 __translate_memory_order(__s));}
5075 _LIBCPP_INLINE_VISIBILITY
5076 bool compare_exchange_weak(unsigned int& __v, unsigned int __e,
5077 memory_order __s = memory_order_seq_cst)
5078 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5079 __translate_memory_order(__s));}
5080 _LIBCPP_INLINE_VISIBILITY
5081 bool compare_exchange_strong(unsigned int& __v, unsigned int __e,
5082 memory_order __s = memory_order_seq_cst) volatile
5083 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5084 __translate_memory_order(__s));}
5085 _LIBCPP_INLINE_VISIBILITY
5086 bool compare_exchange_strong(unsigned int& __v, unsigned int __e,
5087 memory_order __s = memory_order_seq_cst)
5088 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5089 __translate_memory_order(__s));}
5090 _LIBCPP_INLINE_VISIBILITY
5091 unsigned int fetch_add(unsigned int __v,
5092 memory_order __o = memory_order_seq_cst) volatile
5093 {return atomic_fetch_add_explicit(this, __v, __o);}
5094 _LIBCPP_INLINE_VISIBILITY
5095 unsigned int fetch_add(unsigned int __v,
5096 memory_order __o = memory_order_seq_cst)
5097 {return atomic_fetch_add_explicit(this, __v, __o);}
5098 _LIBCPP_INLINE_VISIBILITY
5099 unsigned int fetch_sub(unsigned int __v,
5100 memory_order __o = memory_order_seq_cst) volatile
5101 {return atomic_fetch_sub_explicit(this, __v, __o);}
5102 _LIBCPP_INLINE_VISIBILITY
5103 unsigned int fetch_sub(unsigned int __v,
5104 memory_order __o = memory_order_seq_cst)
5105 {return atomic_fetch_sub_explicit(this, __v, __o);}
5106 _LIBCPP_INLINE_VISIBILITY
5107 unsigned int fetch_and(unsigned int __v,
5108 memory_order __o = memory_order_seq_cst) volatile
5109 {return atomic_fetch_and_explicit(this, __v, __o);}
5110 _LIBCPP_INLINE_VISIBILITY
5111 unsigned int fetch_and(unsigned int __v,
5112 memory_order __o = memory_order_seq_cst)
5113 {return atomic_fetch_and_explicit(this, __v, __o);}
5114 _LIBCPP_INLINE_VISIBILITY
5115 unsigned int fetch_or(unsigned int __v,
5116 memory_order __o = memory_order_seq_cst) volatile
5117 {return atomic_fetch_or_explicit(this, __v, __o);}
5118 _LIBCPP_INLINE_VISIBILITY
5119 unsigned int fetch_or(unsigned int __v,
5120 memory_order __o = memory_order_seq_cst)
5121 {return atomic_fetch_or_explicit(this, __v, __o);}
5122 _LIBCPP_INLINE_VISIBILITY
5123 unsigned int fetch_xor(unsigned int __v,
5124 memory_order __o = memory_order_seq_cst) volatile
5125 {return atomic_fetch_xor_explicit(this, __v, __o);}
5126 _LIBCPP_INLINE_VISIBILITY
5127 unsigned int fetch_xor(unsigned int __v,
5128 memory_order __o = memory_order_seq_cst)
5129 {return atomic_fetch_xor_explicit(this, __v, __o);}
5130#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
5131 atomic_uint() = default;
5132#else
5133 _LIBCPP_INLINE_VISIBILITY
5134 atomic_uint() {}
5135#endif
5136 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00005137 constexpr atomic_uint(unsigned int __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00005138 : __v_(__v) {}
5139#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
5140 atomic_uint(const atomic_uint&) = delete;
5141 atomic_uint& operator=(const atomic_uint&) = delete;
5142 atomic_uint& operator=(const atomic_uint&) volatile = delete;
5143#else
5144private:
5145 atomic_uint(const atomic_uint&);
5146 atomic_uint& operator=(const atomic_uint&);
5147 atomic_uint& operator=(const atomic_uint&) volatile;
5148public:
5149#endif
5150 _LIBCPP_INLINE_VISIBILITY
5151 unsigned int operator=(unsigned int __v) volatile
5152 {store(__v); return __v;}
5153 _LIBCPP_INLINE_VISIBILITY
5154 unsigned int operator=(unsigned int __v)
5155 {store(__v); return __v;}
5156 _LIBCPP_INLINE_VISIBILITY
5157 unsigned int operator++(int) volatile
5158 {typedef unsigned int type; return fetch_add(type(1));}
5159 _LIBCPP_INLINE_VISIBILITY
5160 int operator++(int)
5161 {typedef unsigned int type; return fetch_add(type(1));}
5162 _LIBCPP_INLINE_VISIBILITY
5163 int operator--(int) volatile
5164 {typedef unsigned int type; return fetch_sub(type(1));}
5165 _LIBCPP_INLINE_VISIBILITY
5166 int operator--(int)
5167 {typedef unsigned int type; return fetch_sub(type(1));}
5168 _LIBCPP_INLINE_VISIBILITY
5169 int operator++() volatile
5170 {typedef unsigned int type; return type(fetch_add(type(1)) + 1);}
5171 _LIBCPP_INLINE_VISIBILITY
5172 int operator++()
5173 {typedef unsigned int type; return type(fetch_add(type(1)) + 1);}
5174 _LIBCPP_INLINE_VISIBILITY
5175 int operator--() volatile
5176 {typedef unsigned int type; return type(fetch_sub(type(1)) - 1);}
5177 _LIBCPP_INLINE_VISIBILITY
5178 int operator--()
5179 {typedef unsigned int type; return type(fetch_sub(type(1)) - 1);}
5180 _LIBCPP_INLINE_VISIBILITY
5181 int operator+=(int __v) volatile
5182 {typedef unsigned int type; return type(fetch_add(__v) + __v);}
5183 _LIBCPP_INLINE_VISIBILITY
5184 int operator+=(int __v)
5185 {typedef unsigned int type; return type(fetch_add(__v) + __v);}
5186 _LIBCPP_INLINE_VISIBILITY
5187 int operator-=(int __v) volatile
5188 {typedef unsigned int type; return type(fetch_sub(__v) - __v);}
5189 _LIBCPP_INLINE_VISIBILITY
5190 int operator-=(int __v)
5191 {typedef unsigned int type; return type(fetch_sub(__v) - __v);}
5192 _LIBCPP_INLINE_VISIBILITY
5193 int operator&=(int __v) volatile
5194 {typedef unsigned int type; return type(fetch_and(__v) & __v);}
5195 _LIBCPP_INLINE_VISIBILITY
5196 int operator&=(int __v)
5197 {typedef unsigned int type; return type(fetch_and(__v) & __v);}
5198 _LIBCPP_INLINE_VISIBILITY
5199 int operator|=(int __v) volatile
5200 {typedef unsigned int type; return type(fetch_or(__v) | __v);}
5201 _LIBCPP_INLINE_VISIBILITY
5202 int operator|=(int __v)
5203 {typedef unsigned int type; return type(fetch_or(__v) | __v);}
5204 _LIBCPP_INLINE_VISIBILITY
5205 int operator^=(int __v) volatile
5206 {typedef unsigned int type; return type(fetch_xor(__v) ^ __v);}
5207 _LIBCPP_INLINE_VISIBILITY
5208 int operator^=(int __v)
5209 {typedef unsigned int type; return type(fetch_xor(__v) ^ __v);}
5210} atomic_uint;
5211
5212inline _LIBCPP_INLINE_VISIBILITY
5213bool
5214atomic_is_lock_free(const volatile atomic_uint*)
5215{
5216 typedef unsigned int type;
5217 return __atomic_is_lock_free(type);
5218}
5219
5220inline _LIBCPP_INLINE_VISIBILITY
5221bool
5222atomic_is_lock_free(const atomic_uint* __obj)
5223{
5224 return atomic_is_lock_free(const_cast<volatile atomic_uint*>(__obj));
5225}
5226
5227inline _LIBCPP_INLINE_VISIBILITY
5228void
5229atomic_init(volatile atomic_uint* __obj, unsigned int __desr)
5230{
5231 __obj->__v_ = __desr;
5232}
5233
5234inline _LIBCPP_INLINE_VISIBILITY
5235void
5236atomic_init(atomic_uint* __obj, unsigned int __desr)
5237{
5238 __obj->__v_ = __desr;
5239}
5240
5241inline _LIBCPP_INLINE_VISIBILITY
5242void
5243atomic_store(volatile atomic_uint* __obj, unsigned int __desr)
5244{
5245 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
5246}
5247
5248inline _LIBCPP_INLINE_VISIBILITY
5249void
5250atomic_store(atomic_uint* __obj, unsigned int __desr)
5251{
5252 atomic_store(const_cast<volatile atomic_uint*>(__obj), __desr);
5253}
5254
5255inline _LIBCPP_INLINE_VISIBILITY
5256void
5257atomic_store_explicit(volatile atomic_uint* __obj, unsigned int __desr,
5258 memory_order __o)
5259{
5260 __atomic_store(&__obj->__v_, __desr, __o);
5261}
5262
5263inline _LIBCPP_INLINE_VISIBILITY
5264void
5265atomic_store_explicit(atomic_uint* __obj, unsigned int __desr,
5266 memory_order __o)
5267{
5268 atomic_store_explicit(const_cast<volatile atomic_uint*>(__obj), __desr,
5269 __o);
5270}
5271
5272inline _LIBCPP_INLINE_VISIBILITY
5273unsigned int
5274atomic_load(const volatile atomic_uint* __obj)
5275{
5276 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
5277}
5278
5279inline _LIBCPP_INLINE_VISIBILITY
5280unsigned int
5281atomic_load(const atomic_uint* __obj)
5282{
5283 return atomic_load(const_cast<const volatile atomic_uint*>(__obj));
5284}
5285
5286inline _LIBCPP_INLINE_VISIBILITY
5287unsigned int
5288atomic_load_explicit(const volatile atomic_uint* __obj, memory_order __o)
5289{
5290 return __atomic_load(&__obj->__v_, __o);
5291}
5292
5293inline _LIBCPP_INLINE_VISIBILITY
5294unsigned int
5295atomic_load_explicit(const atomic_uint* __obj, memory_order __o)
5296{
5297 return atomic_load_explicit(const_cast<const volatile atomic_uint*>
5298 (__obj), __o);
5299}
5300
5301inline _LIBCPP_INLINE_VISIBILITY
5302unsigned int
5303atomic_exchange(volatile atomic_uint* __obj, unsigned int __desr)
5304{
5305 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
5306}
5307
5308inline _LIBCPP_INLINE_VISIBILITY
5309unsigned int
5310atomic_exchange(atomic_uint* __obj, unsigned int __desr)
5311{
5312 return atomic_exchange(const_cast<volatile atomic_uint*>(__obj), __desr);
5313}
5314
5315inline _LIBCPP_INLINE_VISIBILITY
5316unsigned int
5317atomic_exchange_explicit(volatile atomic_uint* __obj, unsigned int __desr,
5318 memory_order __o)
5319{
5320 return __atomic_exchange(&__obj->__v_, __desr, __o);
5321}
5322
5323inline _LIBCPP_INLINE_VISIBILITY
5324unsigned int
5325atomic_exchange_explicit(atomic_uint* __obj, unsigned int __desr,
5326 memory_order __o)
5327{
5328 return atomic_exchange_explicit(const_cast<volatile atomic_uint*>
5329 (__obj), __desr, __o);
5330}
5331
5332inline _LIBCPP_INLINE_VISIBILITY
5333bool
5334atomic_compare_exchange_weak(volatile atomic_uint* __obj, unsigned int* __exp,
5335 unsigned int __desr)
5336{
5337 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
5338 memory_order_seq_cst, memory_order_seq_cst);
5339}
5340
5341inline _LIBCPP_INLINE_VISIBILITY
5342bool
5343atomic_compare_exchange_weak(atomic_uint* __obj, unsigned int* __exp,
5344 unsigned int __desr)
5345{
5346 return atomic_compare_exchange_weak(const_cast<volatile atomic_uint*>
5347 (__obj), __exp, __desr);
5348}
5349
5350inline _LIBCPP_INLINE_VISIBILITY
5351bool
5352atomic_compare_exchange_strong(volatile atomic_uint* __obj,
5353 unsigned int* __exp, unsigned int __desr)
5354{
5355 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
5356 memory_order_seq_cst, memory_order_seq_cst);
5357}
5358
5359inline _LIBCPP_INLINE_VISIBILITY
5360bool
5361atomic_compare_exchange_strong(atomic_uint* __obj, unsigned int* __exp,
5362 unsigned int __desr)
5363{
5364 return atomic_compare_exchange_strong(const_cast<volatile atomic_uint*>
5365 (__obj), __exp, __desr);
5366}
5367
5368inline _LIBCPP_INLINE_VISIBILITY
5369bool
5370atomic_compare_exchange_weak_explicit(volatile atomic_uint* __obj,
5371 unsigned int* __exp,
5372 unsigned int __desr, memory_order __s,
5373 memory_order __f)
5374{
5375 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
5376 __f);
5377}
5378
5379inline _LIBCPP_INLINE_VISIBILITY
5380bool
5381atomic_compare_exchange_weak_explicit(atomic_uint* __obj, unsigned int* __exp,
5382 unsigned int __desr, memory_order __s,
5383 memory_order __f)
5384{
5385 return atomic_compare_exchange_weak_explicit(
5386 const_cast<volatile atomic_uint*>(__obj), __exp, __desr, __s, __f);
5387}
5388
5389inline _LIBCPP_INLINE_VISIBILITY
5390bool
5391atomic_compare_exchange_strong_explicit(volatile atomic_uint* __obj,
5392 unsigned int* __exp,
5393 unsigned int __desr, memory_order __s,
5394 memory_order __f)
5395{
5396 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
5397 __f);
5398}
5399
5400inline _LIBCPP_INLINE_VISIBILITY
5401bool
5402atomic_compare_exchange_strong_explicit(atomic_uint* __obj,
5403 unsigned int* __exp,
5404 unsigned int __desr, memory_order __s,
5405 memory_order __f)
5406{
5407 return atomic_compare_exchange_strong_explicit(
5408 const_cast<volatile atomic_uint*>(__obj), __exp, __desr, __s, __f);
5409}
5410
5411inline _LIBCPP_INLINE_VISIBILITY
5412unsigned int
5413atomic_fetch_add(volatile atomic_uint* __obj, unsigned int __v)
5414{
5415 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
5416}
5417
5418inline _LIBCPP_INLINE_VISIBILITY
5419unsigned int
5420atomic_fetch_add(atomic_uint* __obj, unsigned int __v)
5421{
5422 return atomic_fetch_add(const_cast<volatile atomic_uint*>(__obj), __v);
5423}
5424
5425inline _LIBCPP_INLINE_VISIBILITY
5426unsigned int
5427atomic_fetch_add_explicit(volatile atomic_uint* __obj, unsigned int __v,
5428 memory_order __o)
5429{
5430 return __atomic_fetch_add(&__obj->__v_, __v, __o);
5431}
5432
5433inline _LIBCPP_INLINE_VISIBILITY
5434unsigned int
5435atomic_fetch_add_explicit(atomic_uint* __obj, unsigned int __v,
5436 memory_order __o)
5437{
5438 return atomic_fetch_add_explicit(const_cast<volatile atomic_uint*>(__obj),
5439 __v, __o);
5440}
5441
5442inline _LIBCPP_INLINE_VISIBILITY
5443unsigned int
5444atomic_fetch_sub(volatile atomic_uint* __obj, unsigned int __v)
5445{
5446 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
5447}
5448
5449inline _LIBCPP_INLINE_VISIBILITY
5450unsigned int
5451atomic_fetch_sub(atomic_uint* __obj, unsigned int __v)
5452{
5453 return atomic_fetch_sub(const_cast<volatile atomic_uint*>(__obj), __v);
5454}
5455
5456inline _LIBCPP_INLINE_VISIBILITY
5457unsigned int
5458atomic_fetch_sub_explicit(volatile atomic_uint* __obj, unsigned int __v,
5459 memory_order __o)
5460{
5461 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
5462}
5463
5464inline _LIBCPP_INLINE_VISIBILITY
5465unsigned int
5466atomic_fetch_sub_explicit(atomic_uint* __obj, unsigned int __v,
5467 memory_order __o)
5468{
5469 return atomic_fetch_sub_explicit(const_cast<volatile atomic_uint*>(__obj),
5470 __v, __o);
5471}
5472
5473inline _LIBCPP_INLINE_VISIBILITY
5474unsigned int
5475atomic_fetch_and(volatile atomic_uint* __obj, unsigned int __v)
5476{
5477 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
5478}
5479
5480inline _LIBCPP_INLINE_VISIBILITY
5481unsigned int
5482atomic_fetch_and(atomic_uint* __obj, unsigned int __v)
5483{
5484 return atomic_fetch_and(const_cast<volatile atomic_uint*>(__obj), __v);
5485}
5486
5487inline _LIBCPP_INLINE_VISIBILITY
5488unsigned int
5489atomic_fetch_and_explicit(volatile atomic_uint* __obj, unsigned int __v,
5490 memory_order __o)
5491{
5492 return __atomic_fetch_and(&__obj->__v_, __v, __o);
5493}
5494
5495inline _LIBCPP_INLINE_VISIBILITY
5496unsigned int
5497atomic_fetch_and_explicit(atomic_uint* __obj, unsigned int __v,
5498 memory_order __o)
5499{
5500 return atomic_fetch_and_explicit(const_cast<volatile atomic_uint*>(__obj),
5501 __v, __o);
5502}
5503
5504inline _LIBCPP_INLINE_VISIBILITY
5505unsigned int
5506atomic_fetch_or(volatile atomic_uint* __obj, unsigned int __v)
5507{
5508 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
5509}
5510
5511inline _LIBCPP_INLINE_VISIBILITY
5512unsigned int
5513atomic_fetch_or(atomic_uint* __obj, unsigned int __v)
5514{
5515 return atomic_fetch_or(const_cast<volatile atomic_uint*>(__obj), __v);
5516}
5517
5518inline _LIBCPP_INLINE_VISIBILITY
5519unsigned int
5520atomic_fetch_or_explicit(volatile atomic_uint* __obj, unsigned int __v,
5521 memory_order __o)
5522{
5523 return __atomic_fetch_or(&__obj->__v_, __v, __o);
5524}
5525
5526inline _LIBCPP_INLINE_VISIBILITY
5527unsigned int
5528atomic_fetch_or_explicit(atomic_uint* __obj, unsigned int __v,
5529 memory_order __o)
5530{
5531 return atomic_fetch_or_explicit(const_cast<volatile atomic_uint*>(__obj),
5532 __v, __o);
5533}
5534
5535inline _LIBCPP_INLINE_VISIBILITY
5536unsigned int
5537atomic_fetch_xor(volatile atomic_uint* __obj, unsigned int __v)
5538{
5539 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
5540}
5541
5542inline _LIBCPP_INLINE_VISIBILITY
5543unsigned int
5544atomic_fetch_xor(atomic_uint* __obj, unsigned int __v)
5545{
5546 return atomic_fetch_xor(const_cast<volatile atomic_uint*>(__obj), __v);
5547}
5548
5549inline _LIBCPP_INLINE_VISIBILITY
5550unsigned int
5551atomic_fetch_xor_explicit(volatile atomic_uint* __obj, unsigned int __v,
5552 memory_order __o)
5553{
5554 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
5555}
5556
5557inline _LIBCPP_INLINE_VISIBILITY
5558unsigned int
5559atomic_fetch_xor_explicit(atomic_uint* __obj, unsigned int __v,
5560 memory_order __o)
5561{
5562 return atomic_fetch_xor_explicit(const_cast<volatile atomic_uint*>(__obj),
5563 __v, __o);
5564}
5565
5566// atomic_long
5567
5568struct atomic_long;
5569
5570bool atomic_is_lock_free(const volatile atomic_long*);
5571bool atomic_is_lock_free(const atomic_long*);
5572void atomic_init(volatile atomic_long*, long);
5573void atomic_init(atomic_long*, long);
5574void atomic_store(volatile atomic_long*, long);
5575void atomic_store(atomic_long*, long);
5576void atomic_store_explicit(volatile atomic_long*, long, memory_order);
5577void atomic_store_explicit(atomic_long*, long, memory_order);
5578long atomic_load(const volatile atomic_long*);
5579long atomic_load(const atomic_long*);
5580long atomic_load_explicit(const volatile atomic_long*, memory_order);
5581long atomic_load_explicit(const atomic_long*, memory_order);
5582long atomic_exchange(volatile atomic_long*, long);
5583long atomic_exchange(atomic_long*, long);
5584long atomic_exchange_explicit(volatile atomic_long*, long, memory_order);
5585long atomic_exchange_explicit(atomic_long*, long, memory_order);
5586bool atomic_compare_exchange_weak(volatile atomic_long*, long*, long);
5587bool atomic_compare_exchange_weak(atomic_long*, long*, long);
5588bool atomic_compare_exchange_strong(volatile atomic_long*, long*, long);
5589bool atomic_compare_exchange_strong(atomic_long*, long*, long);
5590bool atomic_compare_exchange_weak_explicit(volatile atomic_long*, long*, long,
5591 memory_order, memory_order);
5592bool atomic_compare_exchange_weak_explicit(atomic_long*, long*, long,
5593 memory_order, memory_order);
5594bool atomic_compare_exchange_strong_explicit(volatile atomic_long*, long*, long,
5595 memory_order, memory_order);
5596bool atomic_compare_exchange_strong_explicit(atomic_long*, long*, long,
5597 memory_order, memory_order);
5598long atomic_fetch_add(volatile atomic_long*, long);
5599long atomic_fetch_add(atomic_long*, long);
5600long atomic_fetch_add_explicit(volatile atomic_long*, long, memory_order);
5601long atomic_fetch_add_explicit(atomic_long*, long, memory_order);
5602long atomic_fetch_sub(volatile atomic_long*, long);
5603long atomic_fetch_sub(atomic_long*, long);
5604long atomic_fetch_sub_explicit(volatile atomic_long*, long, memory_order);
5605long atomic_fetch_sub_explicit(atomic_long*, long, memory_order);
5606long atomic_fetch_and(volatile atomic_long*, long);
5607long atomic_fetch_and(atomic_long*, long);
5608long atomic_fetch_and_explicit(volatile atomic_long*, long, memory_order);
5609long atomic_fetch_and_explicit(atomic_long*, long, memory_order);
5610long atomic_fetch_or(volatile atomic_long*, long);
5611long atomic_fetch_or(atomic_long*, long);
5612long atomic_fetch_or_explicit(volatile atomic_long*, long, memory_order);
5613long atomic_fetch_or_explicit(atomic_long*, long, memory_order);
5614long atomic_fetch_xor(volatile atomic_long*, long);
5615long atomic_fetch_xor(atomic_long*, long);
5616long atomic_fetch_xor_explicit(volatile atomic_long*, long, memory_order);
5617long atomic_fetch_xor_explicit(atomic_long*, long, memory_order);
5618
5619typedef struct atomic_long
5620{
5621 long __v_;
5622
5623 _LIBCPP_INLINE_VISIBILITY
5624 bool is_lock_free() const volatile
5625 {return atomic_is_lock_free(this);}
5626 _LIBCPP_INLINE_VISIBILITY
5627 bool is_lock_free() const
5628 {return atomic_is_lock_free(this);}
5629 _LIBCPP_INLINE_VISIBILITY
5630 void store(long __v, memory_order __o = memory_order_seq_cst) volatile
5631 {atomic_store_explicit(this, __v, __o);}
5632 _LIBCPP_INLINE_VISIBILITY
5633 void store(long __v, memory_order __o = memory_order_seq_cst)
5634 {atomic_store_explicit(this, __v, __o);}
5635 _LIBCPP_INLINE_VISIBILITY
5636 long load(memory_order __o = memory_order_seq_cst) const volatile
5637 {return atomic_load_explicit(this, __o);}
5638 _LIBCPP_INLINE_VISIBILITY
5639 long load(memory_order __o = memory_order_seq_cst) const
5640 {return atomic_load_explicit(this, __o);}
5641 _LIBCPP_INLINE_VISIBILITY
5642 operator long() const volatile
5643 {return load();}
5644 _LIBCPP_INLINE_VISIBILITY
5645 operator long() const
5646 {return load();}
5647 _LIBCPP_INLINE_VISIBILITY
5648 long exchange(long __v, memory_order __o = memory_order_seq_cst) volatile
5649 {return atomic_exchange_explicit(this, __v, __o);}
5650 _LIBCPP_INLINE_VISIBILITY
5651 long exchange(long __v, memory_order __o = memory_order_seq_cst)
5652 {return atomic_exchange_explicit(this, __v, __o);}
5653 _LIBCPP_INLINE_VISIBILITY
5654 bool compare_exchange_weak(long& __v, long __e, memory_order __s,
5655 memory_order __f) volatile
5656 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5657 __f);}
5658 _LIBCPP_INLINE_VISIBILITY
5659 bool compare_exchange_weak(long& __v, long __e, memory_order __s,
5660 memory_order __f)
5661 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5662 __f);}
5663 _LIBCPP_INLINE_VISIBILITY
5664 bool compare_exchange_strong(long& __v, long __e, memory_order __s,
5665 memory_order __f) volatile
5666 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5667 __f);}
5668 _LIBCPP_INLINE_VISIBILITY
5669 bool compare_exchange_strong(long& __v, long __e, memory_order __s,
5670 memory_order __f)
5671 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5672 __f);}
5673 _LIBCPP_INLINE_VISIBILITY
5674 bool compare_exchange_weak(long& __v, long __e,
5675 memory_order __s = memory_order_seq_cst) volatile
5676 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5677 __translate_memory_order(__s));}
5678 _LIBCPP_INLINE_VISIBILITY
5679 bool compare_exchange_weak(long& __v, long __e,
5680 memory_order __s = memory_order_seq_cst)
5681 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
5682 __translate_memory_order(__s));}
5683 _LIBCPP_INLINE_VISIBILITY
5684 bool compare_exchange_strong(long& __v, long __e,
5685 memory_order __s = memory_order_seq_cst) volatile
5686 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5687 __translate_memory_order(__s));}
5688 _LIBCPP_INLINE_VISIBILITY
5689 bool compare_exchange_strong(long& __v, long __e,
5690 memory_order __s = memory_order_seq_cst)
5691 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
5692 __translate_memory_order(__s));}
5693 _LIBCPP_INLINE_VISIBILITY
5694 long fetch_add(long __v, memory_order __o = memory_order_seq_cst) volatile
5695 {return atomic_fetch_add_explicit(this, __v, __o);}
5696 _LIBCPP_INLINE_VISIBILITY
5697 long fetch_add(long __v, memory_order __o = memory_order_seq_cst)
5698 {return atomic_fetch_add_explicit(this, __v, __o);}
5699 _LIBCPP_INLINE_VISIBILITY
5700 long fetch_sub(long __v, memory_order __o = memory_order_seq_cst) volatile
5701 {return atomic_fetch_sub_explicit(this, __v, __o);}
5702 _LIBCPP_INLINE_VISIBILITY
5703 long fetch_sub(long __v, memory_order __o = memory_order_seq_cst)
5704 {return atomic_fetch_sub_explicit(this, __v, __o);}
5705 _LIBCPP_INLINE_VISIBILITY
5706 long fetch_and(long __v, memory_order __o = memory_order_seq_cst) volatile
5707 {return atomic_fetch_and_explicit(this, __v, __o);}
5708 _LIBCPP_INLINE_VISIBILITY
5709 long fetch_and(long __v, memory_order __o = memory_order_seq_cst)
5710 {return atomic_fetch_and_explicit(this, __v, __o);}
5711 _LIBCPP_INLINE_VISIBILITY
5712 long fetch_or(long __v, memory_order __o = memory_order_seq_cst) volatile
5713 {return atomic_fetch_or_explicit(this, __v, __o);}
5714 _LIBCPP_INLINE_VISIBILITY
5715 long fetch_or(long __v, memory_order __o = memory_order_seq_cst)
5716 {return atomic_fetch_or_explicit(this, __v, __o);}
5717 _LIBCPP_INLINE_VISIBILITY
5718 long fetch_xor(long __v, memory_order __o = memory_order_seq_cst) volatile
5719 {return atomic_fetch_xor_explicit(this, __v, __o);}
5720 _LIBCPP_INLINE_VISIBILITY
5721 long fetch_xor(long __v, memory_order __o = memory_order_seq_cst)
5722 {return atomic_fetch_xor_explicit(this, __v, __o);}
5723#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
5724 atomic_long() = default;
5725#else
5726 _LIBCPP_INLINE_VISIBILITY
5727 atomic_long() {}
5728#endif
5729 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00005730 constexpr atomic_long(long __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00005731 : __v_(__v) {}
5732#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
5733 atomic_long(const atomic_long&) = delete;
5734 atomic_long& operator=(const atomic_long&) = delete;
5735 atomic_long& operator=(const atomic_long&) volatile = delete;
5736#else
5737private:
5738 atomic_long(const atomic_long&);
5739 atomic_long& operator=(const atomic_long&);
5740 atomic_long& operator=(const atomic_long&) volatile;
5741public:
5742#endif
5743 _LIBCPP_INLINE_VISIBILITY
5744 long operator=(long __v) volatile
5745 {store(__v); return __v;}
5746 _LIBCPP_INLINE_VISIBILITY
5747 long operator=(long __v)
5748 {store(__v); return __v;}
5749 _LIBCPP_INLINE_VISIBILITY
5750 long operator++(int) volatile
5751 {return fetch_add(long(1));}
5752 _LIBCPP_INLINE_VISIBILITY
5753 long operator++(int)
5754 {return fetch_add(long(1));}
5755 _LIBCPP_INLINE_VISIBILITY
5756 long operator--(int) volatile
5757 {return fetch_sub(long(1));}
5758 _LIBCPP_INLINE_VISIBILITY
5759 long operator--(int)
5760 {return fetch_sub(long(1));}
5761 _LIBCPP_INLINE_VISIBILITY
5762 long operator++() volatile
5763 {return long(fetch_add(long(1)) + 1);}
5764 _LIBCPP_INLINE_VISIBILITY
5765 long operator++()
5766 {return long(fetch_add(long(1)) + 1);}
5767 _LIBCPP_INLINE_VISIBILITY
5768 long operator--() volatile
5769 {return long(fetch_sub(long(1)) - 1);}
5770 _LIBCPP_INLINE_VISIBILITY
5771 long operator--()
5772 {return long(fetch_sub(long(1)) - 1);}
5773 _LIBCPP_INLINE_VISIBILITY
5774 long operator+=(long __v) volatile
5775 {return long(fetch_add(__v) + __v);}
5776 _LIBCPP_INLINE_VISIBILITY
5777 long operator+=(long __v)
5778 {return long(fetch_add(__v) + __v);}
5779 _LIBCPP_INLINE_VISIBILITY
5780 long operator-=(long __v) volatile
5781 {return long(fetch_sub(__v) - __v);}
5782 _LIBCPP_INLINE_VISIBILITY
5783 long operator-=(long __v)
5784 {return long(fetch_sub(__v) - __v);}
5785 _LIBCPP_INLINE_VISIBILITY
5786 long operator&=(long __v) volatile
5787 {return long(fetch_and(__v) & __v);}
5788 _LIBCPP_INLINE_VISIBILITY
5789 long operator&=(long __v)
5790 {return long(fetch_and(__v) & __v);}
5791 _LIBCPP_INLINE_VISIBILITY
5792 long operator|=(long __v) volatile
5793 {return long(fetch_or(__v) | __v);}
5794 _LIBCPP_INLINE_VISIBILITY
5795 long operator|=(long __v)
5796 {return long(fetch_or(__v) | __v);}
5797 _LIBCPP_INLINE_VISIBILITY
5798 long operator^=(long __v) volatile
5799 {return long(fetch_xor(__v) ^ __v);}
5800 _LIBCPP_INLINE_VISIBILITY
5801 long operator^=(long __v)
5802 {return long(fetch_xor(__v) ^ __v);}
5803} atomic_long;
5804
5805inline _LIBCPP_INLINE_VISIBILITY
5806bool
5807atomic_is_lock_free(const volatile atomic_long*)
5808{
5809 typedef long type;
5810 return __atomic_is_lock_free(type);
5811}
5812
5813inline _LIBCPP_INLINE_VISIBILITY
5814bool
5815atomic_is_lock_free(const atomic_long* __obj)
5816{
5817 return atomic_is_lock_free(const_cast<volatile atomic_long*>(__obj));
5818}
5819
5820inline _LIBCPP_INLINE_VISIBILITY
5821void
5822atomic_init(volatile atomic_long* __obj, long __desr)
5823{
5824 __obj->__v_ = __desr;
5825}
5826
5827inline _LIBCPP_INLINE_VISIBILITY
5828void
5829atomic_init(atomic_long* __obj, long __desr)
5830{
5831 __obj->__v_ = __desr;
5832}
5833
5834inline _LIBCPP_INLINE_VISIBILITY
5835void
5836atomic_store(volatile atomic_long* __obj, long __desr)
5837{
5838 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
5839}
5840
5841inline _LIBCPP_INLINE_VISIBILITY
5842void
5843atomic_store(atomic_long* __obj, long __desr)
5844{
5845 atomic_store(const_cast<volatile atomic_long*>(__obj), __desr);
5846}
5847
5848inline _LIBCPP_INLINE_VISIBILITY
5849void
5850atomic_store_explicit(volatile atomic_long* __obj, long __desr,
5851 memory_order __o)
5852{
5853 __atomic_store(&__obj->__v_, __desr, __o);
5854}
5855
5856inline _LIBCPP_INLINE_VISIBILITY
5857void
5858atomic_store_explicit(atomic_long* __obj, long __desr, memory_order __o)
5859{
5860 atomic_store_explicit(const_cast<volatile atomic_long*>(__obj), __desr,
5861 __o);
5862}
5863
5864inline _LIBCPP_INLINE_VISIBILITY
5865long
5866atomic_load(const volatile atomic_long* __obj)
5867{
5868 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
5869}
5870
5871inline _LIBCPP_INLINE_VISIBILITY
5872long
5873atomic_load(const atomic_long* __obj)
5874{
5875 return atomic_load(const_cast<const volatile atomic_long*>(__obj));
5876}
5877
5878inline _LIBCPP_INLINE_VISIBILITY
5879long
5880atomic_load_explicit(const volatile atomic_long* __obj, memory_order __o)
5881{
5882 return __atomic_load(&__obj->__v_, __o);
5883}
5884
5885inline _LIBCPP_INLINE_VISIBILITY
5886long
5887atomic_load_explicit(const atomic_long* __obj, memory_order __o)
5888{
5889 return atomic_load_explicit(const_cast<const volatile atomic_long*>
5890 (__obj), __o);
5891}
5892
5893inline _LIBCPP_INLINE_VISIBILITY
5894long
5895atomic_exchange(volatile atomic_long* __obj, long __desr)
5896{
5897 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
5898}
5899
5900inline _LIBCPP_INLINE_VISIBILITY
5901long
5902atomic_exchange(atomic_long* __obj, long __desr)
5903{
5904 return atomic_exchange(const_cast<volatile atomic_long*>(__obj), __desr);
5905}
5906
5907inline _LIBCPP_INLINE_VISIBILITY
5908long
5909atomic_exchange_explicit(volatile atomic_long* __obj, long __desr,
5910 memory_order __o)
5911{
5912 return __atomic_exchange(&__obj->__v_, __desr, __o);
5913}
5914
5915inline _LIBCPP_INLINE_VISIBILITY
5916long
5917atomic_exchange_explicit(atomic_long* __obj, long __desr, memory_order __o)
5918{
5919 return atomic_exchange_explicit(const_cast<volatile atomic_long*>
5920 (__obj), __desr, __o);
5921}
5922
5923inline _LIBCPP_INLINE_VISIBILITY
5924bool
5925atomic_compare_exchange_weak(volatile atomic_long* __obj, long* __exp,
5926 long __desr)
5927{
5928 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
5929 memory_order_seq_cst, memory_order_seq_cst);
5930}
5931
5932inline _LIBCPP_INLINE_VISIBILITY
5933bool
5934atomic_compare_exchange_weak(atomic_long* __obj, long* __exp, long __desr)
5935{
5936 return atomic_compare_exchange_weak(const_cast<volatile atomic_long*>
5937 (__obj), __exp, __desr);
5938}
5939
5940inline _LIBCPP_INLINE_VISIBILITY
5941bool
5942atomic_compare_exchange_strong(volatile atomic_long* __obj, long* __exp,
5943 long __desr)
5944{
5945 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
5946 memory_order_seq_cst, memory_order_seq_cst);
5947}
5948
5949inline _LIBCPP_INLINE_VISIBILITY
5950bool
5951atomic_compare_exchange_strong(atomic_long* __obj, long* __exp, long __desr)
5952{
5953 return atomic_compare_exchange_strong(const_cast<volatile atomic_long*>
5954 (__obj), __exp, __desr);
5955}
5956
5957inline _LIBCPP_INLINE_VISIBILITY
5958bool
5959atomic_compare_exchange_weak_explicit(volatile atomic_long* __obj, long* __exp,
5960 long __desr, memory_order __s,
5961 memory_order __f)
5962{
5963 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
5964 __f);
5965}
5966
5967inline _LIBCPP_INLINE_VISIBILITY
5968bool
5969atomic_compare_exchange_weak_explicit(atomic_long* __obj, long* __exp,
5970 long __desr, memory_order __s,
5971 memory_order __f)
5972{
5973 return atomic_compare_exchange_weak_explicit(
5974 const_cast<volatile atomic_long*>(__obj), __exp, __desr, __s, __f);
5975}
5976
5977inline _LIBCPP_INLINE_VISIBILITY
5978bool
5979atomic_compare_exchange_strong_explicit(volatile atomic_long* __obj,
5980 long* __exp, long __desr,
5981 memory_order __s, memory_order __f)
5982{
5983 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
5984 __f);
5985}
5986
5987inline _LIBCPP_INLINE_VISIBILITY
5988bool
5989atomic_compare_exchange_strong_explicit(atomic_long* __obj, long* __exp,
5990 long __desr, memory_order __s,
5991 memory_order __f)
5992{
5993 return atomic_compare_exchange_strong_explicit(
5994 const_cast<volatile atomic_long*>(__obj), __exp, __desr, __s, __f);
5995}
5996
5997inline _LIBCPP_INLINE_VISIBILITY
5998long
5999atomic_fetch_add(volatile atomic_long* __obj, long __v)
6000{
6001 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
6002}
6003
6004inline _LIBCPP_INLINE_VISIBILITY
6005long
6006atomic_fetch_add(atomic_long* __obj, long __v)
6007{
6008 return atomic_fetch_add(const_cast<volatile atomic_long*>(__obj), __v);
6009}
6010
6011inline _LIBCPP_INLINE_VISIBILITY
6012long
6013atomic_fetch_add_explicit(volatile atomic_long* __obj, long __v,
6014 memory_order __o)
6015{
6016 return __atomic_fetch_add(&__obj->__v_, __v, __o);
6017}
6018
6019inline _LIBCPP_INLINE_VISIBILITY
6020long
6021atomic_fetch_add_explicit(atomic_long* __obj, long __v, memory_order __o)
6022{
6023 return atomic_fetch_add_explicit(const_cast<volatile atomic_long*>(__obj),
6024 __v, __o);
6025}
6026
6027inline _LIBCPP_INLINE_VISIBILITY
6028long
6029atomic_fetch_sub(volatile atomic_long* __obj, long __v)
6030{
6031 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
6032}
6033
6034inline _LIBCPP_INLINE_VISIBILITY
6035long
6036atomic_fetch_sub(atomic_long* __obj, long __v)
6037{
6038 return atomic_fetch_sub(const_cast<volatile atomic_long*>(__obj), __v);
6039}
6040
6041inline _LIBCPP_INLINE_VISIBILITY
6042long
6043atomic_fetch_sub_explicit(volatile atomic_long* __obj, long __v,
6044 memory_order __o)
6045{
6046 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
6047}
6048
6049inline _LIBCPP_INLINE_VISIBILITY
6050long
6051atomic_fetch_sub_explicit(atomic_long* __obj, long __v, memory_order __o)
6052{
6053 return atomic_fetch_sub_explicit(const_cast<volatile atomic_long*>(__obj),
6054 __v, __o);
6055}
6056
6057inline _LIBCPP_INLINE_VISIBILITY
6058long
6059atomic_fetch_and(volatile atomic_long* __obj, long __v)
6060{
6061 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
6062}
6063
6064inline _LIBCPP_INLINE_VISIBILITY
6065long
6066atomic_fetch_and(atomic_long* __obj, long __v)
6067{
6068 return atomic_fetch_and(const_cast<volatile atomic_long*>(__obj), __v);
6069}
6070
6071inline _LIBCPP_INLINE_VISIBILITY
6072long
6073atomic_fetch_and_explicit(volatile atomic_long* __obj, long __v,
6074 memory_order __o)
6075{
6076 return __atomic_fetch_and(&__obj->__v_, __v, __o);
6077}
6078
6079inline _LIBCPP_INLINE_VISIBILITY
6080long
6081atomic_fetch_and_explicit(atomic_long* __obj, long __v, memory_order __o)
6082{
6083 return atomic_fetch_and_explicit(const_cast<volatile atomic_long*>(__obj),
6084 __v, __o);
6085}
6086
6087inline _LIBCPP_INLINE_VISIBILITY
6088long
6089atomic_fetch_or(volatile atomic_long* __obj, long __v)
6090{
6091 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
6092}
6093
6094inline _LIBCPP_INLINE_VISIBILITY
6095long
6096atomic_fetch_or(atomic_long* __obj, long __v)
6097{
6098 return atomic_fetch_or(const_cast<volatile atomic_long*>(__obj), __v);
6099}
6100
6101inline _LIBCPP_INLINE_VISIBILITY
6102long
6103atomic_fetch_or_explicit(volatile atomic_long* __obj, long __v,
6104 memory_order __o)
6105{
6106 return __atomic_fetch_or(&__obj->__v_, __v, __o);
6107}
6108
6109inline _LIBCPP_INLINE_VISIBILITY
6110long
6111atomic_fetch_or_explicit(atomic_long* __obj, long __v, memory_order __o)
6112{
6113 return atomic_fetch_or_explicit(const_cast<volatile atomic_long*>(__obj),
6114 __v, __o);
6115}
6116
6117inline _LIBCPP_INLINE_VISIBILITY
6118long
6119atomic_fetch_xor(volatile atomic_long* __obj, long __v)
6120{
6121 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
6122}
6123
6124inline _LIBCPP_INLINE_VISIBILITY
6125long
6126atomic_fetch_xor(atomic_long* __obj, long __v)
6127{
6128 return atomic_fetch_xor(const_cast<volatile atomic_long*>(__obj), __v);
6129}
6130
6131inline _LIBCPP_INLINE_VISIBILITY
6132long
6133atomic_fetch_xor_explicit(volatile atomic_long* __obj, long __v,
6134 memory_order __o)
6135{
6136 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
6137}
6138
6139inline _LIBCPP_INLINE_VISIBILITY
6140long
6141atomic_fetch_xor_explicit(atomic_long* __obj, long __v, memory_order __o)
6142{
6143 return atomic_fetch_xor_explicit(const_cast<volatile atomic_long*>(__obj),
6144 __v, __o);
6145}
6146
6147// atomic_ulong
6148
6149struct atomic_ulong;
6150
6151bool atomic_is_lock_free(const volatile atomic_ulong*);
6152bool atomic_is_lock_free(const atomic_ulong*);
6153void atomic_init(volatile atomic_ulong*, unsigned long);
6154void atomic_init(atomic_ulong*, unsigned long);
6155void atomic_store(volatile atomic_ulong*, unsigned long);
6156void atomic_store(atomic_ulong*, unsigned long);
6157void atomic_store_explicit(volatile atomic_ulong*, unsigned long, memory_order);
6158void atomic_store_explicit(atomic_ulong*, unsigned long, memory_order);
6159unsigned long atomic_load(const volatile atomic_ulong*);
6160unsigned long atomic_load(const atomic_ulong*);
6161unsigned long atomic_load_explicit(const volatile atomic_ulong*, memory_order);
6162unsigned long atomic_load_explicit(const atomic_ulong*, memory_order);
6163unsigned long atomic_exchange(volatile atomic_ulong*, unsigned long);
6164unsigned long atomic_exchange(atomic_ulong*, unsigned long);
6165unsigned long atomic_exchange_explicit(volatile atomic_ulong*, unsigned long,
6166 memory_order);
6167unsigned long atomic_exchange_explicit(atomic_ulong*, unsigned long,
6168 memory_order);
6169bool atomic_compare_exchange_weak(volatile atomic_ulong*, unsigned long*,
6170 unsigned long);
6171bool atomic_compare_exchange_weak(atomic_ulong*, unsigned long*, unsigned long);
6172bool atomic_compare_exchange_strong(volatile atomic_ulong*, unsigned long*,
6173 unsigned long);
6174bool atomic_compare_exchange_strong(atomic_ulong*, unsigned long*,
6175 unsigned long);
6176bool atomic_compare_exchange_weak_explicit(volatile atomic_ulong*,
6177 unsigned long*, unsigned long,
6178 memory_order, memory_order);
6179bool atomic_compare_exchange_weak_explicit(atomic_ulong*, unsigned long*,
6180 unsigned long, memory_order,
6181 memory_order);
6182bool atomic_compare_exchange_strong_explicit(volatile atomic_ulong*,
6183 unsigned long*, unsigned long,
6184 memory_order, memory_order);
6185bool atomic_compare_exchange_strong_explicit(atomic_ulong*, unsigned long*,
6186 unsigned long, memory_order,
6187 memory_order);
6188unsigned long atomic_fetch_add(volatile atomic_ulong*, unsigned long);
6189unsigned long atomic_fetch_add(atomic_ulong*, unsigned long);
6190unsigned long atomic_fetch_add_explicit(volatile atomic_ulong*, unsigned long,
6191 memory_order);
6192unsigned long atomic_fetch_add_explicit(atomic_ulong*, unsigned long,
6193 memory_order);
6194unsigned long atomic_fetch_sub(volatile atomic_ulong*, unsigned long);
6195unsigned long atomic_fetch_sub(atomic_ulong*, unsigned long);
6196unsigned long atomic_fetch_sub_explicit(volatile atomic_ulong*, unsigned long,
6197 memory_order);
6198unsigned long atomic_fetch_sub_explicit(atomic_ulong*, unsigned long,
6199 memory_order);
6200unsigned long atomic_fetch_and(volatile atomic_ulong*, unsigned long);
6201unsigned long atomic_fetch_and(atomic_ulong*, unsigned long);
6202unsigned long atomic_fetch_and_explicit(volatile atomic_ulong*, unsigned long,
6203 memory_order);
6204unsigned long atomic_fetch_and_explicit(atomic_ulong*, unsigned long,
6205 memory_order);
6206unsigned long atomic_fetch_or(volatile atomic_ulong*, unsigned long);
6207unsigned long atomic_fetch_or(atomic_ulong*, unsigned long);
6208unsigned long atomic_fetch_or_explicit(volatile atomic_ulong*, unsigned long,
6209 memory_order);
6210unsigned long atomic_fetch_or_explicit(atomic_ulong*, unsigned long,
6211 memory_order);
6212unsigned long atomic_fetch_xor(volatile atomic_ulong*, unsigned long);
6213unsigned long atomic_fetch_xor(atomic_ulong*, unsigned long);
6214unsigned long atomic_fetch_xor_explicit(volatile atomic_ulong*, unsigned long,
6215 memory_order);
6216unsigned long atomic_fetch_xor_explicit(atomic_ulong*, unsigned long,
6217 memory_order);
6218
6219typedef struct atomic_ulong
6220{
6221 unsigned long __v_;
6222
6223 _LIBCPP_INLINE_VISIBILITY
6224 bool is_lock_free() const volatile
6225 {return atomic_is_lock_free(this);}
6226 _LIBCPP_INLINE_VISIBILITY
6227 bool is_lock_free() const
6228 {return atomic_is_lock_free(this);}
6229 _LIBCPP_INLINE_VISIBILITY
6230 void store(unsigned long __v,
6231 memory_order __o = memory_order_seq_cst) volatile
6232 {atomic_store_explicit(this, __v, __o);}
6233 _LIBCPP_INLINE_VISIBILITY
6234 void store(unsigned long __v, memory_order __o = memory_order_seq_cst)
6235 {atomic_store_explicit(this, __v, __o);}
6236 _LIBCPP_INLINE_VISIBILITY
6237 unsigned long load(memory_order __o = memory_order_seq_cst) const volatile
6238 {return atomic_load_explicit(this, __o);}
6239 _LIBCPP_INLINE_VISIBILITY
6240 unsigned long load(memory_order __o = memory_order_seq_cst) const
6241 {return atomic_load_explicit(this, __o);}
6242 _LIBCPP_INLINE_VISIBILITY
6243 operator unsigned long() const volatile
6244 {return load();}
6245 _LIBCPP_INLINE_VISIBILITY
6246 operator unsigned long() const
6247 {return load();}
6248 _LIBCPP_INLINE_VISIBILITY
6249 unsigned long exchange(unsigned long __v,
6250 memory_order __o = memory_order_seq_cst) volatile
6251 {return atomic_exchange_explicit(this, __v, __o);}
6252 _LIBCPP_INLINE_VISIBILITY
6253 unsigned long exchange(unsigned long __v,
6254 memory_order __o = memory_order_seq_cst)
6255 {return atomic_exchange_explicit(this, __v, __o);}
6256 _LIBCPP_INLINE_VISIBILITY
6257 bool compare_exchange_weak(unsigned long& __v, unsigned long __e,
6258 memory_order __s, memory_order __f) volatile
6259 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6260 __f);}
6261 _LIBCPP_INLINE_VISIBILITY
6262 bool compare_exchange_weak(unsigned long& __v, unsigned long __e,
6263 memory_order __s, memory_order __f)
6264 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6265 __f);}
6266 _LIBCPP_INLINE_VISIBILITY
6267 bool compare_exchange_strong(unsigned long& __v, unsigned long __e,
6268 memory_order __s, memory_order __f) volatile
6269 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6270 __f);}
6271 _LIBCPP_INLINE_VISIBILITY
6272 bool compare_exchange_strong(unsigned long& __v, unsigned long __e,
6273 memory_order __s, memory_order __f)
6274 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6275 __f);}
6276 _LIBCPP_INLINE_VISIBILITY
6277 bool compare_exchange_weak(unsigned long& __v, unsigned long __e,
6278 memory_order __s = memory_order_seq_cst) volatile
6279 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6280 __translate_memory_order(__s));}
6281 _LIBCPP_INLINE_VISIBILITY
6282 bool compare_exchange_weak(unsigned long& __v, unsigned long __e,
6283 memory_order __s = memory_order_seq_cst)
6284 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6285 __translate_memory_order(__s));}
6286 _LIBCPP_INLINE_VISIBILITY
6287 bool compare_exchange_strong(unsigned long& __v, unsigned long __e,
6288 memory_order __s = memory_order_seq_cst) volatile
6289 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6290 __translate_memory_order(__s));}
6291 _LIBCPP_INLINE_VISIBILITY
6292 bool compare_exchange_strong(unsigned long& __v, unsigned long __e,
6293 memory_order __s = memory_order_seq_cst)
6294 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6295 __translate_memory_order(__s));}
6296 _LIBCPP_INLINE_VISIBILITY
6297 unsigned long fetch_add(unsigned long __v,
6298 memory_order __o = memory_order_seq_cst) volatile
6299 {return atomic_fetch_add_explicit(this, __v, __o);}
6300 _LIBCPP_INLINE_VISIBILITY
6301 unsigned long fetch_add(unsigned long __v,
6302 memory_order __o = memory_order_seq_cst)
6303 {return atomic_fetch_add_explicit(this, __v, __o);}
6304 _LIBCPP_INLINE_VISIBILITY
6305 unsigned long fetch_sub(unsigned long __v,
6306 memory_order __o = memory_order_seq_cst) volatile
6307 {return atomic_fetch_sub_explicit(this, __v, __o);}
6308 _LIBCPP_INLINE_VISIBILITY
6309 unsigned long fetch_sub(unsigned long __v,
6310 memory_order __o = memory_order_seq_cst)
6311 {return atomic_fetch_sub_explicit(this, __v, __o);}
6312 _LIBCPP_INLINE_VISIBILITY
6313 unsigned long fetch_and(unsigned long __v,
6314 memory_order __o = memory_order_seq_cst) volatile
6315 {return atomic_fetch_and_explicit(this, __v, __o);}
6316 _LIBCPP_INLINE_VISIBILITY
6317 unsigned long fetch_and(unsigned long __v,
6318 memory_order __o = memory_order_seq_cst)
6319 {return atomic_fetch_and_explicit(this, __v, __o);}
6320 _LIBCPP_INLINE_VISIBILITY
6321 unsigned long fetch_or(unsigned long __v,
6322 memory_order __o = memory_order_seq_cst) volatile
6323 {return atomic_fetch_or_explicit(this, __v, __o);}
6324 _LIBCPP_INLINE_VISIBILITY
6325 unsigned long fetch_or(unsigned long __v,
6326 memory_order __o = memory_order_seq_cst)
6327 {return atomic_fetch_or_explicit(this, __v, __o);}
6328 _LIBCPP_INLINE_VISIBILITY
6329 unsigned long fetch_xor(unsigned long __v,
6330 memory_order __o = memory_order_seq_cst) volatile
6331 {return atomic_fetch_xor_explicit(this, __v, __o);}
6332 _LIBCPP_INLINE_VISIBILITY
6333 unsigned long fetch_xor(unsigned long __v,
6334 memory_order __o = memory_order_seq_cst)
6335 {return atomic_fetch_xor_explicit(this, __v, __o);}
6336#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
6337 atomic_ulong() = default;
6338#else
6339 _LIBCPP_INLINE_VISIBILITY
6340 atomic_ulong() {}
6341#endif
6342 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00006343 constexpr atomic_ulong(unsigned long __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00006344 : __v_(__v) {}
6345#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
6346 atomic_ulong(const atomic_ulong&) = delete;
6347 atomic_ulong& operator=(const atomic_ulong&) = delete;
6348 atomic_ulong& operator=(const atomic_ulong&) volatile = delete;
6349#else
6350private:
6351 atomic_ulong(const atomic_ulong&);
6352 atomic_ulong& operator=(const atomic_ulong&);
6353 atomic_ulong& operator=(const atomic_ulong&) volatile;
6354public:
6355#endif
6356 _LIBCPP_INLINE_VISIBILITY
6357 unsigned long operator=(unsigned long __v) volatile
6358 {store(__v); return __v;}
6359 _LIBCPP_INLINE_VISIBILITY
6360 unsigned long operator=(unsigned long __v)
6361 {store(__v); return __v;}
6362 _LIBCPP_INLINE_VISIBILITY
6363 unsigned long operator++(int) volatile
6364 {typedef unsigned long type; return fetch_add(type(1));}
6365 _LIBCPP_INLINE_VISIBILITY
6366 long operator++(int)
6367 {typedef unsigned long type; return fetch_add(type(1));}
6368 _LIBCPP_INLINE_VISIBILITY
6369 long operator--(int) volatile
6370 {typedef unsigned long type; return fetch_sub(type(1));}
6371 _LIBCPP_INLINE_VISIBILITY
6372 long operator--(int)
6373 {typedef unsigned long type; return fetch_sub(type(1));}
6374 _LIBCPP_INLINE_VISIBILITY
6375 long operator++() volatile
6376 {typedef unsigned long type; return type(fetch_add(type(1)) + 1);}
6377 _LIBCPP_INLINE_VISIBILITY
6378 long operator++()
6379 {typedef unsigned long type; return type(fetch_add(type(1)) + 1);}
6380 _LIBCPP_INLINE_VISIBILITY
6381 long operator--() volatile
6382 {typedef unsigned long type; return type(fetch_sub(type(1)) - 1);}
6383 _LIBCPP_INLINE_VISIBILITY
6384 long operator--()
6385 {typedef unsigned long type; return type(fetch_sub(type(1)) - 1);}
6386 _LIBCPP_INLINE_VISIBILITY
6387 long operator+=(long __v) volatile
6388 {typedef unsigned long type; return type(fetch_add(__v) + __v);}
6389 _LIBCPP_INLINE_VISIBILITY
6390 long operator+=(long __v)
6391 {typedef unsigned long type; return type(fetch_add(__v) + __v);}
6392 _LIBCPP_INLINE_VISIBILITY
6393 long operator-=(long __v) volatile
6394 {typedef unsigned long type; return type(fetch_sub(__v) - __v);}
6395 _LIBCPP_INLINE_VISIBILITY
6396 long operator-=(long __v)
6397 {typedef unsigned long type; return type(fetch_sub(__v) - __v);}
6398 _LIBCPP_INLINE_VISIBILITY
6399 long operator&=(long __v) volatile
6400 {typedef unsigned long type; return type(fetch_and(__v) & __v);}
6401 _LIBCPP_INLINE_VISIBILITY
6402 long operator&=(long __v)
6403 {typedef unsigned long type; return type(fetch_and(__v) & __v);}
6404 _LIBCPP_INLINE_VISIBILITY
6405 long operator|=(long __v) volatile
6406 {typedef unsigned long type; return type(fetch_or(__v) | __v);}
6407 _LIBCPP_INLINE_VISIBILITY
6408 long operator|=(long __v)
6409 {typedef unsigned long type; return type(fetch_or(__v) | __v);}
6410 _LIBCPP_INLINE_VISIBILITY
6411 long operator^=(long __v) volatile
6412 {typedef unsigned long type; return type(fetch_xor(__v) ^ __v);}
6413 _LIBCPP_INLINE_VISIBILITY
6414 long operator^=(long __v)
6415 {typedef unsigned long type; return type(fetch_xor(__v) ^ __v);}
6416} atomic_ulong;
6417
6418inline _LIBCPP_INLINE_VISIBILITY
6419bool
6420atomic_is_lock_free(const volatile atomic_ulong*)
6421{
6422 typedef unsigned long type;
6423 return __atomic_is_lock_free(type);
6424}
6425
6426inline _LIBCPP_INLINE_VISIBILITY
6427bool
6428atomic_is_lock_free(const atomic_ulong* __obj)
6429{
6430 return atomic_is_lock_free(const_cast<volatile atomic_ulong*>(__obj));
6431}
6432
6433inline _LIBCPP_INLINE_VISIBILITY
6434void
6435atomic_init(volatile atomic_ulong* __obj, unsigned long __desr)
6436{
6437 __obj->__v_ = __desr;
6438}
6439
6440inline _LIBCPP_INLINE_VISIBILITY
6441void
6442atomic_init(atomic_ulong* __obj, unsigned long __desr)
6443{
6444 __obj->__v_ = __desr;
6445}
6446
6447inline _LIBCPP_INLINE_VISIBILITY
6448void
6449atomic_store(volatile atomic_ulong* __obj, unsigned long __desr)
6450{
6451 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
6452}
6453
6454inline _LIBCPP_INLINE_VISIBILITY
6455void
6456atomic_store(atomic_ulong* __obj, unsigned long __desr)
6457{
6458 atomic_store(const_cast<volatile atomic_ulong*>(__obj), __desr);
6459}
6460
6461inline _LIBCPP_INLINE_VISIBILITY
6462void
6463atomic_store_explicit(volatile atomic_ulong* __obj, unsigned long __desr,
6464 memory_order __o)
6465{
6466 __atomic_store(&__obj->__v_, __desr, __o);
6467}
6468
6469inline _LIBCPP_INLINE_VISIBILITY
6470void
6471atomic_store_explicit(atomic_ulong* __obj, unsigned long __desr,
6472 memory_order __o)
6473{
6474 atomic_store_explicit(const_cast<volatile atomic_ulong*>(__obj), __desr,
6475 __o);
6476}
6477
6478inline _LIBCPP_INLINE_VISIBILITY
6479unsigned long
6480atomic_load(const volatile atomic_ulong* __obj)
6481{
6482 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
6483}
6484
6485inline _LIBCPP_INLINE_VISIBILITY
6486unsigned long
6487atomic_load(const atomic_ulong* __obj)
6488{
6489 return atomic_load(const_cast<const volatile atomic_ulong*>(__obj));
6490}
6491
6492inline _LIBCPP_INLINE_VISIBILITY
6493unsigned long
6494atomic_load_explicit(const volatile atomic_ulong* __obj, memory_order __o)
6495{
6496 return __atomic_load(&__obj->__v_, __o);
6497}
6498
6499inline _LIBCPP_INLINE_VISIBILITY
6500unsigned long
6501atomic_load_explicit(const atomic_ulong* __obj, memory_order __o)
6502{
6503 return atomic_load_explicit(const_cast<const volatile atomic_ulong*>
6504 (__obj), __o);
6505}
6506
6507inline _LIBCPP_INLINE_VISIBILITY
6508unsigned long
6509atomic_exchange(volatile atomic_ulong* __obj, unsigned long __desr)
6510{
6511 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
6512}
6513
6514inline _LIBCPP_INLINE_VISIBILITY
6515unsigned long
6516atomic_exchange(atomic_ulong* __obj, unsigned long __desr)
6517{
6518 return atomic_exchange(const_cast<volatile atomic_ulong*>(__obj), __desr);
6519}
6520
6521inline _LIBCPP_INLINE_VISIBILITY
6522unsigned long
6523atomic_exchange_explicit(volatile atomic_ulong* __obj, unsigned long __desr,
6524 memory_order __o)
6525{
6526 return __atomic_exchange(&__obj->__v_, __desr, __o);
6527}
6528
6529inline _LIBCPP_INLINE_VISIBILITY
6530unsigned long
6531atomic_exchange_explicit(atomic_ulong* __obj, unsigned long __desr,
6532 memory_order __o)
6533{
6534 return atomic_exchange_explicit(const_cast<volatile atomic_ulong*>
6535 (__obj), __desr, __o);
6536}
6537
6538inline _LIBCPP_INLINE_VISIBILITY
6539bool
6540atomic_compare_exchange_weak(volatile atomic_ulong* __obj, unsigned long* __exp,
6541 unsigned long __desr)
6542{
6543 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
6544 memory_order_seq_cst, memory_order_seq_cst);
6545}
6546
6547inline _LIBCPP_INLINE_VISIBILITY
6548bool
6549atomic_compare_exchange_weak(atomic_ulong* __obj, unsigned long* __exp,
6550 unsigned long __desr)
6551{
6552 return atomic_compare_exchange_weak(const_cast<volatile atomic_ulong*>
6553 (__obj), __exp, __desr);
6554}
6555
6556inline _LIBCPP_INLINE_VISIBILITY
6557bool
6558atomic_compare_exchange_strong(volatile atomic_ulong* __obj,
6559 unsigned long* __exp, unsigned long __desr)
6560{
6561 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
6562 memory_order_seq_cst, memory_order_seq_cst);
6563}
6564
6565inline _LIBCPP_INLINE_VISIBILITY
6566bool
6567atomic_compare_exchange_strong(atomic_ulong* __obj, unsigned long* __exp,
6568 unsigned long __desr)
6569{
6570 return atomic_compare_exchange_strong(const_cast<volatile atomic_ulong*>
6571 (__obj), __exp, __desr);
6572}
6573
6574inline _LIBCPP_INLINE_VISIBILITY
6575bool
6576atomic_compare_exchange_weak_explicit(volatile atomic_ulong* __obj,
6577 unsigned long* __exp,
6578 unsigned long __desr, memory_order __s,
6579 memory_order __f)
6580{
6581 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
6582 __f);
6583}
6584
6585inline _LIBCPP_INLINE_VISIBILITY
6586bool
6587atomic_compare_exchange_weak_explicit(atomic_ulong* __obj, unsigned long* __exp,
6588 unsigned long __desr, memory_order __s,
6589 memory_order __f)
6590{
6591 return atomic_compare_exchange_weak_explicit(
6592 const_cast<volatile atomic_ulong*>(__obj), __exp, __desr, __s, __f);
6593}
6594
6595inline _LIBCPP_INLINE_VISIBILITY
6596bool
6597atomic_compare_exchange_strong_explicit(volatile atomic_ulong* __obj,
6598 unsigned long* __exp,
6599 unsigned long __desr, memory_order __s,
6600 memory_order __f)
6601{
6602 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
6603 __f);
6604}
6605
6606inline _LIBCPP_INLINE_VISIBILITY
6607bool
6608atomic_compare_exchange_strong_explicit(atomic_ulong* __obj,
6609 unsigned long* __exp,
6610 unsigned long __desr, memory_order __s,
6611 memory_order __f)
6612{
6613 return atomic_compare_exchange_strong_explicit(
6614 const_cast<volatile atomic_ulong*>(__obj), __exp, __desr, __s, __f);
6615}
6616
6617inline _LIBCPP_INLINE_VISIBILITY
6618unsigned long
6619atomic_fetch_add(volatile atomic_ulong* __obj, unsigned long __v)
6620{
6621 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
6622}
6623
6624inline _LIBCPP_INLINE_VISIBILITY
6625unsigned long
6626atomic_fetch_add(atomic_ulong* __obj, unsigned long __v)
6627{
6628 return atomic_fetch_add(const_cast<volatile atomic_ulong*>(__obj), __v);
6629}
6630
6631inline _LIBCPP_INLINE_VISIBILITY
6632unsigned long
6633atomic_fetch_add_explicit(volatile atomic_ulong* __obj, unsigned long __v,
6634 memory_order __o)
6635{
6636 return __atomic_fetch_add(&__obj->__v_, __v, __o);
6637}
6638
6639inline _LIBCPP_INLINE_VISIBILITY
6640unsigned long
6641atomic_fetch_add_explicit(atomic_ulong* __obj, unsigned long __v,
6642 memory_order __o)
6643{
6644 return atomic_fetch_add_explicit(const_cast<volatile atomic_ulong*>(__obj),
6645 __v, __o);
6646}
6647
6648inline _LIBCPP_INLINE_VISIBILITY
6649unsigned long
6650atomic_fetch_sub(volatile atomic_ulong* __obj, unsigned long __v)
6651{
6652 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
6653}
6654
6655inline _LIBCPP_INLINE_VISIBILITY
6656unsigned long
6657atomic_fetch_sub(atomic_ulong* __obj, unsigned long __v)
6658{
6659 return atomic_fetch_sub(const_cast<volatile atomic_ulong*>(__obj), __v);
6660}
6661
6662inline _LIBCPP_INLINE_VISIBILITY
6663unsigned long
6664atomic_fetch_sub_explicit(volatile atomic_ulong* __obj, unsigned long __v,
6665 memory_order __o)
6666{
6667 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
6668}
6669
6670inline _LIBCPP_INLINE_VISIBILITY
6671unsigned long
6672atomic_fetch_sub_explicit(atomic_ulong* __obj, unsigned long __v,
6673 memory_order __o)
6674{
6675 return atomic_fetch_sub_explicit(const_cast<volatile atomic_ulong*>(__obj),
6676 __v, __o);
6677}
6678
6679inline _LIBCPP_INLINE_VISIBILITY
6680unsigned long
6681atomic_fetch_and(volatile atomic_ulong* __obj, unsigned long __v)
6682{
6683 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
6684}
6685
6686inline _LIBCPP_INLINE_VISIBILITY
6687unsigned long
6688atomic_fetch_and(atomic_ulong* __obj, unsigned long __v)
6689{
6690 return atomic_fetch_and(const_cast<volatile atomic_ulong*>(__obj), __v);
6691}
6692
6693inline _LIBCPP_INLINE_VISIBILITY
6694unsigned long
6695atomic_fetch_and_explicit(volatile atomic_ulong* __obj, unsigned long __v,
6696 memory_order __o)
6697{
6698 return __atomic_fetch_and(&__obj->__v_, __v, __o);
6699}
6700
6701inline _LIBCPP_INLINE_VISIBILITY
6702unsigned long
6703atomic_fetch_and_explicit(atomic_ulong* __obj, unsigned long __v,
6704 memory_order __o)
6705{
6706 return atomic_fetch_and_explicit(const_cast<volatile atomic_ulong*>(__obj),
6707 __v, __o);
6708}
6709
6710inline _LIBCPP_INLINE_VISIBILITY
6711unsigned long
6712atomic_fetch_or(volatile atomic_ulong* __obj, unsigned long __v)
6713{
6714 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
6715}
6716
6717inline _LIBCPP_INLINE_VISIBILITY
6718unsigned long
6719atomic_fetch_or(atomic_ulong* __obj, unsigned long __v)
6720{
6721 return atomic_fetch_or(const_cast<volatile atomic_ulong*>(__obj), __v);
6722}
6723
6724inline _LIBCPP_INLINE_VISIBILITY
6725unsigned long
6726atomic_fetch_or_explicit(volatile atomic_ulong* __obj, unsigned long __v,
6727 memory_order __o)
6728{
6729 return __atomic_fetch_or(&__obj->__v_, __v, __o);
6730}
6731
6732inline _LIBCPP_INLINE_VISIBILITY
6733unsigned long
6734atomic_fetch_or_explicit(atomic_ulong* __obj, unsigned long __v,
6735 memory_order __o)
6736{
6737 return atomic_fetch_or_explicit(const_cast<volatile atomic_ulong*>(__obj),
6738 __v, __o);
6739}
6740
6741inline _LIBCPP_INLINE_VISIBILITY
6742unsigned long
6743atomic_fetch_xor(volatile atomic_ulong* __obj, unsigned long __v)
6744{
6745 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
6746}
6747
6748inline _LIBCPP_INLINE_VISIBILITY
6749unsigned long
6750atomic_fetch_xor(atomic_ulong* __obj, unsigned long __v)
6751{
6752 return atomic_fetch_xor(const_cast<volatile atomic_ulong*>(__obj), __v);
6753}
6754
6755inline _LIBCPP_INLINE_VISIBILITY
6756unsigned long
6757atomic_fetch_xor_explicit(volatile atomic_ulong* __obj, unsigned long __v,
6758 memory_order __o)
6759{
6760 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
6761}
6762
6763inline _LIBCPP_INLINE_VISIBILITY
6764unsigned long
6765atomic_fetch_xor_explicit(atomic_ulong* __obj, unsigned long __v,
6766 memory_order __o)
6767{
6768 return atomic_fetch_xor_explicit(const_cast<volatile atomic_ulong*>(__obj),
6769 __v, __o);
6770}
6771
6772// atomic_llong
6773
6774struct atomic_llong;
6775
6776bool atomic_is_lock_free(const volatile atomic_llong*);
6777bool atomic_is_lock_free(const atomic_llong*);
6778void atomic_init(volatile atomic_llong*, long long);
6779void atomic_init(atomic_llong*, long long);
6780void atomic_store(volatile atomic_llong*, long long);
6781void atomic_store(atomic_llong*, long long);
6782void atomic_store_explicit(volatile atomic_llong*, long long, memory_order);
6783void atomic_store_explicit(atomic_llong*, long long, memory_order);
6784long long atomic_load(const volatile atomic_llong*);
6785long long atomic_load(const atomic_llong*);
6786long long atomic_load_explicit(const volatile atomic_llong*, memory_order);
6787long long atomic_load_explicit(const atomic_llong*, memory_order);
6788long long atomic_exchange(volatile atomic_llong*, long long);
6789long long atomic_exchange(atomic_llong*, long long);
6790long long atomic_exchange_explicit(volatile atomic_llong*, long long,
6791 memory_order);
6792long long atomic_exchange_explicit(atomic_llong*, long long,
6793 memory_order);
6794bool atomic_compare_exchange_weak(volatile atomic_llong*, long long*,
6795 long long);
6796bool atomic_compare_exchange_weak(atomic_llong*, long long*, long long);
6797bool atomic_compare_exchange_strong(volatile atomic_llong*, long long*,
6798 long long);
6799bool atomic_compare_exchange_strong(atomic_llong*, long long*,
6800 long long);
6801bool atomic_compare_exchange_weak_explicit(volatile atomic_llong*,
6802 long long*, long long,
6803 memory_order, memory_order);
6804bool atomic_compare_exchange_weak_explicit(atomic_llong*, long long*,
6805 long long, memory_order,
6806 memory_order);
6807bool atomic_compare_exchange_strong_explicit(volatile atomic_llong*,
6808 long long*, long long,
6809 memory_order, memory_order);
6810bool atomic_compare_exchange_strong_explicit(atomic_llong*, long long*,
6811 long long, memory_order,
6812 memory_order);
6813long long atomic_fetch_add(volatile atomic_llong*, long long);
6814long long atomic_fetch_add(atomic_llong*, long long);
6815long long atomic_fetch_add_explicit(volatile atomic_llong*, long long,
6816 memory_order);
6817long long atomic_fetch_add_explicit(atomic_llong*, long long,
6818 memory_order);
6819long long atomic_fetch_sub(volatile atomic_llong*, long long);
6820long long atomic_fetch_sub(atomic_llong*, long long);
6821long long atomic_fetch_sub_explicit(volatile atomic_llong*, long long,
6822 memory_order);
6823long long atomic_fetch_sub_explicit(atomic_llong*, long long,
6824 memory_order);
6825long long atomic_fetch_and(volatile atomic_llong*, long long);
6826long long atomic_fetch_and(atomic_llong*, long long);
6827long long atomic_fetch_and_explicit(volatile atomic_llong*, long long,
6828 memory_order);
6829long long atomic_fetch_and_explicit(atomic_llong*, long long,
6830 memory_order);
6831long long atomic_fetch_or(volatile atomic_llong*, long long);
6832long long atomic_fetch_or(atomic_llong*, long long);
6833long long atomic_fetch_or_explicit(volatile atomic_llong*, long long,
6834 memory_order);
6835long long atomic_fetch_or_explicit(atomic_llong*, long long,
6836 memory_order);
6837long long atomic_fetch_xor(volatile atomic_llong*, long long);
6838long long atomic_fetch_xor(atomic_llong*, long long);
6839long long atomic_fetch_xor_explicit(volatile atomic_llong*, long long,
6840 memory_order);
6841long long atomic_fetch_xor_explicit(atomic_llong*, long long,
6842 memory_order);
6843
6844typedef struct atomic_llong
6845{
6846 long long __v_;
6847
6848 _LIBCPP_INLINE_VISIBILITY
6849 bool is_lock_free() const volatile
6850 {return atomic_is_lock_free(this);}
6851 _LIBCPP_INLINE_VISIBILITY
6852 bool is_lock_free() const
6853 {return atomic_is_lock_free(this);}
6854 _LIBCPP_INLINE_VISIBILITY
6855 void store(long long __v,
6856 memory_order __o = memory_order_seq_cst) volatile
6857 {atomic_store_explicit(this, __v, __o);}
6858 _LIBCPP_INLINE_VISIBILITY
6859 void store(long long __v, memory_order __o = memory_order_seq_cst)
6860 {atomic_store_explicit(this, __v, __o);}
6861 _LIBCPP_INLINE_VISIBILITY
6862 long long load(memory_order __o = memory_order_seq_cst) const volatile
6863 {return atomic_load_explicit(this, __o);}
6864 _LIBCPP_INLINE_VISIBILITY
6865 long long load(memory_order __o = memory_order_seq_cst) const
6866 {return atomic_load_explicit(this, __o);}
6867 _LIBCPP_INLINE_VISIBILITY
6868 operator long long() const volatile
6869 {return load();}
6870 _LIBCPP_INLINE_VISIBILITY
6871 operator long long() const
6872 {return load();}
6873 _LIBCPP_INLINE_VISIBILITY
6874 long long exchange(long long __v,
6875 memory_order __o = memory_order_seq_cst) volatile
6876 {return atomic_exchange_explicit(this, __v, __o);}
6877 _LIBCPP_INLINE_VISIBILITY
6878 long long exchange(long long __v,
6879 memory_order __o = memory_order_seq_cst)
6880 {return atomic_exchange_explicit(this, __v, __o);}
6881 _LIBCPP_INLINE_VISIBILITY
6882 bool compare_exchange_weak(long long& __v, long long __e,
6883 memory_order __s, memory_order __f) volatile
6884 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6885 __f);}
6886 _LIBCPP_INLINE_VISIBILITY
6887 bool compare_exchange_weak(long long& __v, long long __e,
6888 memory_order __s, memory_order __f)
6889 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6890 __f);}
6891 _LIBCPP_INLINE_VISIBILITY
6892 bool compare_exchange_strong(long long& __v, long long __e,
6893 memory_order __s, memory_order __f) volatile
6894 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6895 __f);}
6896 _LIBCPP_INLINE_VISIBILITY
6897 bool compare_exchange_strong(long long& __v, long long __e,
6898 memory_order __s, memory_order __f)
6899 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6900 __f);}
6901 _LIBCPP_INLINE_VISIBILITY
6902 bool compare_exchange_weak(long long& __v, long long __e,
6903 memory_order __s = memory_order_seq_cst) volatile
6904 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6905 __translate_memory_order(__s));}
6906 _LIBCPP_INLINE_VISIBILITY
6907 bool compare_exchange_weak(long long& __v, long long __e,
6908 memory_order __s = memory_order_seq_cst)
6909 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
6910 __translate_memory_order(__s));}
6911 _LIBCPP_INLINE_VISIBILITY
6912 bool compare_exchange_strong(long long& __v, long long __e,
6913 memory_order __s = memory_order_seq_cst) volatile
6914 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6915 __translate_memory_order(__s));}
6916 _LIBCPP_INLINE_VISIBILITY
6917 bool compare_exchange_strong(long long& __v, long long __e,
6918 memory_order __s = memory_order_seq_cst)
6919 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
6920 __translate_memory_order(__s));}
6921 _LIBCPP_INLINE_VISIBILITY
6922 long long fetch_add(long long __v,
6923 memory_order __o = memory_order_seq_cst) volatile
6924 {return atomic_fetch_add_explicit(this, __v, __o);}
6925 _LIBCPP_INLINE_VISIBILITY
6926 long long fetch_add(long long __v,
6927 memory_order __o = memory_order_seq_cst)
6928 {return atomic_fetch_add_explicit(this, __v, __o);}
6929 _LIBCPP_INLINE_VISIBILITY
6930 long long fetch_sub(long long __v,
6931 memory_order __o = memory_order_seq_cst) volatile
6932 {return atomic_fetch_sub_explicit(this, __v, __o);}
6933 _LIBCPP_INLINE_VISIBILITY
6934 long long fetch_sub(long long __v,
6935 memory_order __o = memory_order_seq_cst)
6936 {return atomic_fetch_sub_explicit(this, __v, __o);}
6937 _LIBCPP_INLINE_VISIBILITY
6938 long long fetch_and(long long __v,
6939 memory_order __o = memory_order_seq_cst) volatile
6940 {return atomic_fetch_and_explicit(this, __v, __o);}
6941 _LIBCPP_INLINE_VISIBILITY
6942 long long fetch_and(long long __v,
6943 memory_order __o = memory_order_seq_cst)
6944 {return atomic_fetch_and_explicit(this, __v, __o);}
6945 _LIBCPP_INLINE_VISIBILITY
6946 long long fetch_or(long long __v,
6947 memory_order __o = memory_order_seq_cst) volatile
6948 {return atomic_fetch_or_explicit(this, __v, __o);}
6949 _LIBCPP_INLINE_VISIBILITY
6950 long long fetch_or(long long __v,
6951 memory_order __o = memory_order_seq_cst)
6952 {return atomic_fetch_or_explicit(this, __v, __o);}
6953 _LIBCPP_INLINE_VISIBILITY
6954 long long fetch_xor(long long __v,
6955 memory_order __o = memory_order_seq_cst) volatile
6956 {return atomic_fetch_xor_explicit(this, __v, __o);}
6957 _LIBCPP_INLINE_VISIBILITY
6958 long long fetch_xor(long long __v,
6959 memory_order __o = memory_order_seq_cst)
6960 {return atomic_fetch_xor_explicit(this, __v, __o);}
6961#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
6962 atomic_llong() = default;
6963#else
6964 _LIBCPP_INLINE_VISIBILITY
6965 atomic_llong() {}
6966#endif
6967 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00006968 constexpr atomic_llong(long long __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00006969 : __v_(__v) {}
6970#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
6971 atomic_llong(const atomic_llong&) = delete;
6972 atomic_llong& operator=(const atomic_llong&) = delete;
6973 atomic_llong& operator=(const atomic_llong&) volatile = delete;
6974#else
6975private:
6976 atomic_llong(const atomic_llong&);
6977 atomic_llong& operator=(const atomic_llong&);
6978 atomic_llong& operator=(const atomic_llong&) volatile;
6979public:
6980#endif
6981 _LIBCPP_INLINE_VISIBILITY
6982 long long operator=(long long __v) volatile
6983 {store(__v); return __v;}
6984 _LIBCPP_INLINE_VISIBILITY
6985 long long operator=(long long __v)
6986 {store(__v); return __v;}
6987 _LIBCPP_INLINE_VISIBILITY
6988 long long operator++(int) volatile
6989 {typedef long long type; return fetch_add(type(1));}
6990 _LIBCPP_INLINE_VISIBILITY
6991 long operator++(int)
6992 {typedef long long type; return fetch_add(type(1));}
6993 _LIBCPP_INLINE_VISIBILITY
6994 long operator--(int) volatile
6995 {typedef long long type; return fetch_sub(type(1));}
6996 _LIBCPP_INLINE_VISIBILITY
6997 long operator--(int)
6998 {typedef long long type; return fetch_sub(type(1));}
6999 _LIBCPP_INLINE_VISIBILITY
7000 long operator++() volatile
7001 {typedef long long type; return type(fetch_add(type(1)) + 1);}
7002 _LIBCPP_INLINE_VISIBILITY
7003 long operator++()
7004 {typedef long long type; return type(fetch_add(type(1)) + 1);}
7005 _LIBCPP_INLINE_VISIBILITY
7006 long operator--() volatile
7007 {typedef long long type; return type(fetch_sub(type(1)) - 1);}
7008 _LIBCPP_INLINE_VISIBILITY
7009 long operator--()
7010 {typedef long long type; return type(fetch_sub(type(1)) - 1);}
7011 _LIBCPP_INLINE_VISIBILITY
7012 long operator+=(long __v) volatile
7013 {typedef long long type; return type(fetch_add(__v) + __v);}
7014 _LIBCPP_INLINE_VISIBILITY
7015 long operator+=(long __v)
7016 {typedef long long type; return type(fetch_add(__v) + __v);}
7017 _LIBCPP_INLINE_VISIBILITY
7018 long operator-=(long __v) volatile
7019 {typedef long long type; return type(fetch_sub(__v) - __v);}
7020 _LIBCPP_INLINE_VISIBILITY
7021 long operator-=(long __v)
7022 {typedef long long type; return type(fetch_sub(__v) - __v);}
7023 _LIBCPP_INLINE_VISIBILITY
7024 long operator&=(long __v) volatile
7025 {typedef long long type; return type(fetch_and(__v) & __v);}
7026 _LIBCPP_INLINE_VISIBILITY
7027 long operator&=(long __v)
7028 {typedef long long type; return type(fetch_and(__v) & __v);}
7029 _LIBCPP_INLINE_VISIBILITY
7030 long operator|=(long __v) volatile
7031 {typedef long long type; return type(fetch_or(__v) | __v);}
7032 _LIBCPP_INLINE_VISIBILITY
7033 long operator|=(long __v)
7034 {typedef long long type; return type(fetch_or(__v) | __v);}
7035 _LIBCPP_INLINE_VISIBILITY
7036 long operator^=(long __v) volatile
7037 {typedef long long type; return type(fetch_xor(__v) ^ __v);}
7038 _LIBCPP_INLINE_VISIBILITY
7039 long operator^=(long __v)
7040 {typedef long long type; return type(fetch_xor(__v) ^ __v);}
7041} atomic_llong;
7042
7043inline _LIBCPP_INLINE_VISIBILITY
7044bool
7045atomic_is_lock_free(const volatile atomic_llong*)
7046{
7047 typedef long long type;
7048 return __atomic_is_lock_free(type);
7049}
7050
7051inline _LIBCPP_INLINE_VISIBILITY
7052bool
7053atomic_is_lock_free(const atomic_llong* __obj)
7054{
7055 return atomic_is_lock_free(const_cast<volatile atomic_llong*>(__obj));
7056}
7057
7058inline _LIBCPP_INLINE_VISIBILITY
7059void
7060atomic_init(volatile atomic_llong* __obj, long long __desr)
7061{
7062 __obj->__v_ = __desr;
7063}
7064
7065inline _LIBCPP_INLINE_VISIBILITY
7066void
7067atomic_init(atomic_llong* __obj, long long __desr)
7068{
7069 __obj->__v_ = __desr;
7070}
7071
7072inline _LIBCPP_INLINE_VISIBILITY
7073void
7074atomic_store(volatile atomic_llong* __obj, long long __desr)
7075{
7076 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
7077}
7078
7079inline _LIBCPP_INLINE_VISIBILITY
7080void
7081atomic_store(atomic_llong* __obj, long long __desr)
7082{
7083 atomic_store(const_cast<volatile atomic_llong*>(__obj), __desr);
7084}
7085
7086inline _LIBCPP_INLINE_VISIBILITY
7087void
7088atomic_store_explicit(volatile atomic_llong* __obj, long long __desr,
7089 memory_order __o)
7090{
7091 __atomic_store(&__obj->__v_, __desr, __o);
7092}
7093
7094inline _LIBCPP_INLINE_VISIBILITY
7095void
7096atomic_store_explicit(atomic_llong* __obj, long long __desr,
7097 memory_order __o)
7098{
7099 atomic_store_explicit(const_cast<volatile atomic_llong*>(__obj), __desr,
7100 __o);
7101}
7102
7103inline _LIBCPP_INLINE_VISIBILITY
7104long long
7105atomic_load(const volatile atomic_llong* __obj)
7106{
7107 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
7108}
7109
7110inline _LIBCPP_INLINE_VISIBILITY
7111long long
7112atomic_load(const atomic_llong* __obj)
7113{
7114 return atomic_load(const_cast<const volatile atomic_llong*>(__obj));
7115}
7116
7117inline _LIBCPP_INLINE_VISIBILITY
7118long long
7119atomic_load_explicit(const volatile atomic_llong* __obj, memory_order __o)
7120{
7121 return __atomic_load(&__obj->__v_, __o);
7122}
7123
7124inline _LIBCPP_INLINE_VISIBILITY
7125long long
7126atomic_load_explicit(const atomic_llong* __obj, memory_order __o)
7127{
7128 return atomic_load_explicit(const_cast<const volatile atomic_llong*>
7129 (__obj), __o);
7130}
7131
7132inline _LIBCPP_INLINE_VISIBILITY
7133long long
7134atomic_exchange(volatile atomic_llong* __obj, long long __desr)
7135{
7136 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
7137}
7138
7139inline _LIBCPP_INLINE_VISIBILITY
7140long long
7141atomic_exchange(atomic_llong* __obj, long long __desr)
7142{
7143 return atomic_exchange(const_cast<volatile atomic_llong*>(__obj), __desr);
7144}
7145
7146inline _LIBCPP_INLINE_VISIBILITY
7147long long
7148atomic_exchange_explicit(volatile atomic_llong* __obj, long long __desr,
7149 memory_order __o)
7150{
7151 return __atomic_exchange(&__obj->__v_, __desr, __o);
7152}
7153
7154inline _LIBCPP_INLINE_VISIBILITY
7155long long
7156atomic_exchange_explicit(atomic_llong* __obj, long long __desr,
7157 memory_order __o)
7158{
7159 return atomic_exchange_explicit(const_cast<volatile atomic_llong*>
7160 (__obj), __desr, __o);
7161}
7162
7163inline _LIBCPP_INLINE_VISIBILITY
7164bool
7165atomic_compare_exchange_weak(volatile atomic_llong* __obj, long long* __exp,
7166 long long __desr)
7167{
7168 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
7169 memory_order_seq_cst, memory_order_seq_cst);
7170}
7171
7172inline _LIBCPP_INLINE_VISIBILITY
7173bool
7174atomic_compare_exchange_weak(atomic_llong* __obj, long long* __exp,
7175 long long __desr)
7176{
7177 return atomic_compare_exchange_weak(const_cast<volatile atomic_llong*>
7178 (__obj), __exp, __desr);
7179}
7180
7181inline _LIBCPP_INLINE_VISIBILITY
7182bool
7183atomic_compare_exchange_strong(volatile atomic_llong* __obj,
7184 long long* __exp, long long __desr)
7185{
7186 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
7187 memory_order_seq_cst, memory_order_seq_cst);
7188}
7189
7190inline _LIBCPP_INLINE_VISIBILITY
7191bool
7192atomic_compare_exchange_strong(atomic_llong* __obj, long long* __exp,
7193 long long __desr)
7194{
7195 return atomic_compare_exchange_strong(const_cast<volatile atomic_llong*>
7196 (__obj), __exp, __desr);
7197}
7198
7199inline _LIBCPP_INLINE_VISIBILITY
7200bool
7201atomic_compare_exchange_weak_explicit(volatile atomic_llong* __obj,
7202 long long* __exp,
7203 long long __desr, memory_order __s,
7204 memory_order __f)
7205{
7206 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
7207 __f);
7208}
7209
7210inline _LIBCPP_INLINE_VISIBILITY
7211bool
7212atomic_compare_exchange_weak_explicit(atomic_llong* __obj, long long* __exp,
7213 long long __desr, memory_order __s,
7214 memory_order __f)
7215{
7216 return atomic_compare_exchange_weak_explicit(
7217 const_cast<volatile atomic_llong*>(__obj), __exp, __desr, __s, __f);
7218}
7219
7220inline _LIBCPP_INLINE_VISIBILITY
7221bool
7222atomic_compare_exchange_strong_explicit(volatile atomic_llong* __obj,
7223 long long* __exp,
7224 long long __desr, memory_order __s,
7225 memory_order __f)
7226{
7227 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
7228 __f);
7229}
7230
7231inline _LIBCPP_INLINE_VISIBILITY
7232bool
7233atomic_compare_exchange_strong_explicit(atomic_llong* __obj,
7234 long long* __exp,
7235 long long __desr, memory_order __s,
7236 memory_order __f)
7237{
7238 return atomic_compare_exchange_strong_explicit(
7239 const_cast<volatile atomic_llong*>(__obj), __exp, __desr, __s, __f);
7240}
7241
7242inline _LIBCPP_INLINE_VISIBILITY
7243long long
7244atomic_fetch_add(volatile atomic_llong* __obj, long long __v)
7245{
7246 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
7247}
7248
7249inline _LIBCPP_INLINE_VISIBILITY
7250long long
7251atomic_fetch_add(atomic_llong* __obj, long long __v)
7252{
7253 return atomic_fetch_add(const_cast<volatile atomic_llong*>(__obj), __v);
7254}
7255
7256inline _LIBCPP_INLINE_VISIBILITY
7257long long
7258atomic_fetch_add_explicit(volatile atomic_llong* __obj, long long __v,
7259 memory_order __o)
7260{
7261 return __atomic_fetch_add(&__obj->__v_, __v, __o);
7262}
7263
7264inline _LIBCPP_INLINE_VISIBILITY
7265long long
7266atomic_fetch_add_explicit(atomic_llong* __obj, long long __v,
7267 memory_order __o)
7268{
7269 return atomic_fetch_add_explicit(const_cast<volatile atomic_llong*>(__obj),
7270 __v, __o);
7271}
7272
7273inline _LIBCPP_INLINE_VISIBILITY
7274long long
7275atomic_fetch_sub(volatile atomic_llong* __obj, long long __v)
7276{
7277 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
7278}
7279
7280inline _LIBCPP_INLINE_VISIBILITY
7281long long
7282atomic_fetch_sub(atomic_llong* __obj, long long __v)
7283{
7284 return atomic_fetch_sub(const_cast<volatile atomic_llong*>(__obj), __v);
7285}
7286
7287inline _LIBCPP_INLINE_VISIBILITY
7288long long
7289atomic_fetch_sub_explicit(volatile atomic_llong* __obj, long long __v,
7290 memory_order __o)
7291{
7292 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
7293}
7294
7295inline _LIBCPP_INLINE_VISIBILITY
7296long long
7297atomic_fetch_sub_explicit(atomic_llong* __obj, long long __v,
7298 memory_order __o)
7299{
7300 return atomic_fetch_sub_explicit(const_cast<volatile atomic_llong*>(__obj),
7301 __v, __o);
7302}
7303
7304inline _LIBCPP_INLINE_VISIBILITY
7305long long
7306atomic_fetch_and(volatile atomic_llong* __obj, long long __v)
7307{
7308 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
7309}
7310
7311inline _LIBCPP_INLINE_VISIBILITY
7312long long
7313atomic_fetch_and(atomic_llong* __obj, long long __v)
7314{
7315 return atomic_fetch_and(const_cast<volatile atomic_llong*>(__obj), __v);
7316}
7317
7318inline _LIBCPP_INLINE_VISIBILITY
7319long long
7320atomic_fetch_and_explicit(volatile atomic_llong* __obj, long long __v,
7321 memory_order __o)
7322{
7323 return __atomic_fetch_and(&__obj->__v_, __v, __o);
7324}
7325
7326inline _LIBCPP_INLINE_VISIBILITY
7327long long
7328atomic_fetch_and_explicit(atomic_llong* __obj, long long __v,
7329 memory_order __o)
7330{
7331 return atomic_fetch_and_explicit(const_cast<volatile atomic_llong*>(__obj),
7332 __v, __o);
7333}
7334
7335inline _LIBCPP_INLINE_VISIBILITY
7336long long
7337atomic_fetch_or(volatile atomic_llong* __obj, long long __v)
7338{
7339 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
7340}
7341
7342inline _LIBCPP_INLINE_VISIBILITY
7343long long
7344atomic_fetch_or(atomic_llong* __obj, long long __v)
7345{
7346 return atomic_fetch_or(const_cast<volatile atomic_llong*>(__obj), __v);
7347}
7348
7349inline _LIBCPP_INLINE_VISIBILITY
7350long long
7351atomic_fetch_or_explicit(volatile atomic_llong* __obj, long long __v,
7352 memory_order __o)
7353{
7354 return __atomic_fetch_or(&__obj->__v_, __v, __o);
7355}
7356
7357inline _LIBCPP_INLINE_VISIBILITY
7358long long
7359atomic_fetch_or_explicit(atomic_llong* __obj, long long __v,
7360 memory_order __o)
7361{
7362 return atomic_fetch_or_explicit(const_cast<volatile atomic_llong*>(__obj),
7363 __v, __o);
7364}
7365
7366inline _LIBCPP_INLINE_VISIBILITY
7367long long
7368atomic_fetch_xor(volatile atomic_llong* __obj, long long __v)
7369{
7370 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
7371}
7372
7373inline _LIBCPP_INLINE_VISIBILITY
7374long long
7375atomic_fetch_xor(atomic_llong* __obj, long long __v)
7376{
7377 return atomic_fetch_xor(const_cast<volatile atomic_llong*>(__obj), __v);
7378}
7379
7380inline _LIBCPP_INLINE_VISIBILITY
7381long long
7382atomic_fetch_xor_explicit(volatile atomic_llong* __obj, long long __v,
7383 memory_order __o)
7384{
7385 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
7386}
7387
7388inline _LIBCPP_INLINE_VISIBILITY
7389long long
7390atomic_fetch_xor_explicit(atomic_llong* __obj, long long __v,
7391 memory_order __o)
7392{
7393 return atomic_fetch_xor_explicit(const_cast<volatile atomic_llong*>(__obj),
7394 __v, __o);
7395}
7396
7397// atomic_ullong
7398
7399struct atomic_ullong;
7400
7401bool atomic_is_lock_free(const volatile atomic_ullong*);
7402bool atomic_is_lock_free(const atomic_ullong*);
7403void atomic_init(volatile atomic_ullong*, unsigned long long);
7404void atomic_init(atomic_ullong*, unsigned long long);
7405void atomic_store(volatile atomic_ullong*, unsigned long long);
7406void atomic_store(atomic_ullong*, unsigned long long);
7407void atomic_store_explicit(volatile atomic_ullong*, unsigned long long,
7408 memory_order);
7409void atomic_store_explicit(atomic_ullong*, unsigned long long, memory_order);
7410unsigned long long atomic_load(const volatile atomic_ullong*);
7411unsigned long long atomic_load(const atomic_ullong*);
7412unsigned long long atomic_load_explicit(const volatile atomic_ullong*,
7413 memory_order);
7414unsigned long long atomic_load_explicit(const atomic_ullong*, memory_order);
7415unsigned long long atomic_exchange(volatile atomic_ullong*, unsigned long long);
7416unsigned long long atomic_exchange(atomic_ullong*, unsigned long long);
7417unsigned long long atomic_exchange_explicit(volatile atomic_ullong*,
7418 unsigned long long, memory_order);
7419unsigned long long atomic_exchange_explicit(atomic_ullong*, unsigned long long,
7420 memory_order);
7421bool atomic_compare_exchange_weak(volatile atomic_ullong*, unsigned long long*,
7422 unsigned long long);
7423bool atomic_compare_exchange_weak(atomic_ullong*, unsigned long long*,
7424 unsigned long long);
7425bool atomic_compare_exchange_strong(volatile atomic_ullong*,
7426 unsigned long long*, unsigned long long);
7427bool atomic_compare_exchange_strong(atomic_ullong*, unsigned long long*,
7428 unsigned long long);
7429bool atomic_compare_exchange_weak_explicit(volatile atomic_ullong*,
7430 unsigned long long*,
7431 unsigned long long,
7432 memory_order, memory_order);
7433bool atomic_compare_exchange_weak_explicit(atomic_ullong*, unsigned long long*,
7434 unsigned long long, memory_order,
7435 memory_order);
7436bool atomic_compare_exchange_strong_explicit(volatile atomic_ullong*,
7437 unsigned long long*,
7438 unsigned long long,
7439 memory_order, memory_order);
7440bool atomic_compare_exchange_strong_explicit(atomic_ullong*,
7441 unsigned long long*,
7442 unsigned long long, memory_order,
7443 memory_order);
7444unsigned long long atomic_fetch_add(volatile atomic_ullong*,
7445 unsigned long long);
7446unsigned long long atomic_fetch_add(atomic_ullong*, unsigned long long);
7447unsigned long long atomic_fetch_add_explicit(volatile atomic_ullong*,
7448 unsigned long long, memory_order);
7449unsigned long long atomic_fetch_add_explicit(atomic_ullong*, unsigned long long,
7450 memory_order);
7451unsigned long long atomic_fetch_sub(volatile atomic_ullong*,
7452 unsigned long long);
7453unsigned long long atomic_fetch_sub(atomic_ullong*, unsigned long long);
7454unsigned long long atomic_fetch_sub_explicit(volatile atomic_ullong*,
7455 unsigned long long, memory_order);
7456unsigned long long atomic_fetch_sub_explicit(atomic_ullong*, unsigned long long,
7457 memory_order);
7458unsigned long long atomic_fetch_and(volatile atomic_ullong*, unsigned long long);
7459unsigned long long atomic_fetch_and(atomic_ullong*, unsigned long long);
7460unsigned long long atomic_fetch_and_explicit(volatile atomic_ullong*,
7461 unsigned long long, memory_order);
7462unsigned long long atomic_fetch_and_explicit(atomic_ullong*, unsigned long long,
7463 memory_order);
7464unsigned long long atomic_fetch_or(volatile atomic_ullong*, unsigned long long);
7465unsigned long long atomic_fetch_or(atomic_ullong*, unsigned long long);
7466unsigned long long atomic_fetch_or_explicit(volatile atomic_ullong*,
7467 unsigned long long, memory_order);
7468unsigned long long atomic_fetch_or_explicit(atomic_ullong*, unsigned long long,
7469 memory_order);
7470unsigned long long atomic_fetch_xor(volatile atomic_ullong*,
7471 unsigned long long);
7472unsigned long long atomic_fetch_xor(atomic_ullong*, unsigned long long);
7473unsigned long long atomic_fetch_xor_explicit(volatile atomic_ullong*,
7474 unsigned long long, memory_order);
7475unsigned long long atomic_fetch_xor_explicit(atomic_ullong*, unsigned long long,
7476 memory_order);
7477
7478typedef struct atomic_ullong
7479{
7480 unsigned long long __v_;
7481
7482 _LIBCPP_INLINE_VISIBILITY
7483 bool is_lock_free() const volatile
7484 {return atomic_is_lock_free(this);}
7485 _LIBCPP_INLINE_VISIBILITY
7486 bool is_lock_free() const
7487 {return atomic_is_lock_free(this);}
7488 _LIBCPP_INLINE_VISIBILITY
7489 void store(unsigned long long __v,
7490 memory_order __o = memory_order_seq_cst) volatile
7491 {atomic_store_explicit(this, __v, __o);}
7492 _LIBCPP_INLINE_VISIBILITY
7493 void store(unsigned long long __v, memory_order __o = memory_order_seq_cst)
7494 {atomic_store_explicit(this, __v, __o);}
7495 _LIBCPP_INLINE_VISIBILITY
7496 unsigned long long load(memory_order __o = memory_order_seq_cst) const
7497 volatile
7498 {return atomic_load_explicit(this, __o);}
7499 _LIBCPP_INLINE_VISIBILITY
7500 unsigned long long load(memory_order __o = memory_order_seq_cst) const
7501 {return atomic_load_explicit(this, __o);}
7502 _LIBCPP_INLINE_VISIBILITY
7503 operator unsigned long long() const volatile
7504 {return load();}
7505 _LIBCPP_INLINE_VISIBILITY
7506 operator unsigned long long() const
7507 {return load();}
7508 _LIBCPP_INLINE_VISIBILITY
7509 unsigned long long exchange(unsigned long long __v,
7510 memory_order __o = memory_order_seq_cst) volatile
7511 {return atomic_exchange_explicit(this, __v, __o);}
7512 _LIBCPP_INLINE_VISIBILITY
7513 unsigned long long exchange(unsigned long long __v,
7514 memory_order __o = memory_order_seq_cst)
7515 {return atomic_exchange_explicit(this, __v, __o);}
7516 _LIBCPP_INLINE_VISIBILITY
7517 bool compare_exchange_weak(unsigned long long& __v, unsigned long long __e,
7518 memory_order __s, memory_order __f) volatile
7519 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
7520 __f);}
7521 _LIBCPP_INLINE_VISIBILITY
7522 bool compare_exchange_weak(unsigned long long& __v, unsigned long long __e,
7523 memory_order __s, memory_order __f)
7524 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
7525 __f);}
7526 _LIBCPP_INLINE_VISIBILITY
7527 bool compare_exchange_strong(unsigned long long& __v, unsigned long long __e,
7528 memory_order __s, memory_order __f) volatile
7529 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
7530 __f);}
7531 _LIBCPP_INLINE_VISIBILITY
7532 bool compare_exchange_strong(unsigned long long& __v, unsigned long long __e,
7533 memory_order __s, memory_order __f)
7534 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
7535 __f);}
7536 _LIBCPP_INLINE_VISIBILITY
7537 bool compare_exchange_weak(unsigned long long& __v, unsigned long long __e,
7538 memory_order __s = memory_order_seq_cst) volatile
7539 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
7540 __translate_memory_order(__s));}
7541 _LIBCPP_INLINE_VISIBILITY
7542 bool compare_exchange_weak(unsigned long long& __v, unsigned long long __e,
7543 memory_order __s = memory_order_seq_cst)
7544 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
7545 __translate_memory_order(__s));}
7546 _LIBCPP_INLINE_VISIBILITY
7547 bool compare_exchange_strong(unsigned long long& __v, unsigned long long __e,
7548 memory_order __s = memory_order_seq_cst) volatile
7549 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
7550 __translate_memory_order(__s));}
7551 _LIBCPP_INLINE_VISIBILITY
7552 bool compare_exchange_strong(unsigned long long& __v, unsigned long long __e,
7553 memory_order __s = memory_order_seq_cst)
7554 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
7555 __translate_memory_order(__s));}
7556 _LIBCPP_INLINE_VISIBILITY
7557 unsigned long long fetch_add(unsigned long long __v,
7558 memory_order __o = memory_order_seq_cst) volatile
7559 {return atomic_fetch_add_explicit(this, __v, __o);}
7560 _LIBCPP_INLINE_VISIBILITY
7561 unsigned long long fetch_add(unsigned long long __v,
7562 memory_order __o = memory_order_seq_cst)
7563 {return atomic_fetch_add_explicit(this, __v, __o);}
7564 _LIBCPP_INLINE_VISIBILITY
7565 unsigned long long fetch_sub(unsigned long long __v,
7566 memory_order __o = memory_order_seq_cst) volatile
7567 {return atomic_fetch_sub_explicit(this, __v, __o);}
7568 _LIBCPP_INLINE_VISIBILITY
7569 unsigned long long fetch_sub(unsigned long long __v,
7570 memory_order __o = memory_order_seq_cst)
7571 {return atomic_fetch_sub_explicit(this, __v, __o);}
7572 _LIBCPP_INLINE_VISIBILITY
7573 unsigned long long fetch_and(unsigned long long __v,
7574 memory_order __o = memory_order_seq_cst) volatile
7575 {return atomic_fetch_and_explicit(this, __v, __o);}
7576 _LIBCPP_INLINE_VISIBILITY
7577 unsigned long long fetch_and(unsigned long long __v,
7578 memory_order __o = memory_order_seq_cst)
7579 {return atomic_fetch_and_explicit(this, __v, __o);}
7580 _LIBCPP_INLINE_VISIBILITY
7581 unsigned long long fetch_or(unsigned long long __v,
7582 memory_order __o = memory_order_seq_cst) volatile
7583 {return atomic_fetch_or_explicit(this, __v, __o);}
7584 _LIBCPP_INLINE_VISIBILITY
7585 unsigned long long fetch_or(unsigned long long __v,
7586 memory_order __o = memory_order_seq_cst)
7587 {return atomic_fetch_or_explicit(this, __v, __o);}
7588 _LIBCPP_INLINE_VISIBILITY
7589 unsigned long long fetch_xor(unsigned long long __v,
7590 memory_order __o = memory_order_seq_cst) volatile
7591 {return atomic_fetch_xor_explicit(this, __v, __o);}
7592 _LIBCPP_INLINE_VISIBILITY
7593 unsigned long long fetch_xor(unsigned long long __v,
7594 memory_order __o = memory_order_seq_cst)
7595 {return atomic_fetch_xor_explicit(this, __v, __o);}
7596#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
7597 atomic_ullong() = default;
7598#else
7599 _LIBCPP_INLINE_VISIBILITY
7600 atomic_ullong() {}
7601#endif
7602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00007603 constexpr atomic_ullong(unsigned long long __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00007604 : __v_(__v) {}
7605#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
7606 atomic_ullong(const atomic_ullong&) = delete;
7607 atomic_ullong& operator=(const atomic_ullong&) = delete;
7608 atomic_ullong& operator=(const atomic_ullong&) volatile = delete;
7609#else
7610private:
7611 atomic_ullong(const atomic_ullong&);
7612 atomic_ullong& operator=(const atomic_ullong&);
7613 atomic_ullong& operator=(const atomic_ullong&) volatile;
7614public:
7615#endif
7616 _LIBCPP_INLINE_VISIBILITY
7617 unsigned long long operator=(unsigned long long __v) volatile
7618 {store(__v); return __v;}
7619 _LIBCPP_INLINE_VISIBILITY
7620 unsigned long long operator=(unsigned long long __v)
7621 {store(__v); return __v;}
7622 _LIBCPP_INLINE_VISIBILITY
7623 unsigned long long operator++(int) volatile
7624 {typedef unsigned long long type; return fetch_add(type(1));}
7625 _LIBCPP_INLINE_VISIBILITY
7626 long operator++(int)
7627 {typedef unsigned long long type; return fetch_add(type(1));}
7628 _LIBCPP_INLINE_VISIBILITY
7629 long operator--(int) volatile
7630 {typedef unsigned long long type; return fetch_sub(type(1));}
7631 _LIBCPP_INLINE_VISIBILITY
7632 long operator--(int)
7633 {typedef unsigned long long type; return fetch_sub(type(1));}
7634 _LIBCPP_INLINE_VISIBILITY
7635 long operator++() volatile
7636 {typedef unsigned long long type; return type(fetch_add(type(1)) + 1);}
7637 _LIBCPP_INLINE_VISIBILITY
7638 long operator++()
7639 {typedef unsigned long long type; return type(fetch_add(type(1)) + 1);}
7640 _LIBCPP_INLINE_VISIBILITY
7641 long operator--() volatile
7642 {typedef unsigned long long type; return type(fetch_sub(type(1)) - 1);}
7643 _LIBCPP_INLINE_VISIBILITY
7644 long operator--()
7645 {typedef unsigned long long type; return type(fetch_sub(type(1)) - 1);}
7646 _LIBCPP_INLINE_VISIBILITY
7647 long operator+=(long __v) volatile
7648 {typedef unsigned long long type; return type(fetch_add(__v) + __v);}
7649 _LIBCPP_INLINE_VISIBILITY
7650 long operator+=(long __v)
7651 {typedef unsigned long long type; return type(fetch_add(__v) + __v);}
7652 _LIBCPP_INLINE_VISIBILITY
7653 long operator-=(long __v) volatile
7654 {typedef unsigned long long type; return type(fetch_sub(__v) - __v);}
7655 _LIBCPP_INLINE_VISIBILITY
7656 long operator-=(long __v)
7657 {typedef unsigned long long type; return type(fetch_sub(__v) - __v);}
7658 _LIBCPP_INLINE_VISIBILITY
7659 long operator&=(long __v) volatile
7660 {typedef unsigned long long type; return type(fetch_and(__v) & __v);}
7661 _LIBCPP_INLINE_VISIBILITY
7662 long operator&=(long __v)
7663 {typedef unsigned long long type; return type(fetch_and(__v) & __v);}
7664 _LIBCPP_INLINE_VISIBILITY
7665 long operator|=(long __v) volatile
7666 {typedef unsigned long long type; return type(fetch_or(__v) | __v);}
7667 _LIBCPP_INLINE_VISIBILITY
7668 long operator|=(long __v)
7669 {typedef unsigned long long type; return type(fetch_or(__v) | __v);}
7670 _LIBCPP_INLINE_VISIBILITY
7671 long operator^=(long __v) volatile
7672 {typedef unsigned long long type; return type(fetch_xor(__v) ^ __v);}
7673 _LIBCPP_INLINE_VISIBILITY
7674 long operator^=(long __v)
7675 {typedef unsigned long long type; return type(fetch_xor(__v) ^ __v);}
7676} atomic_ullong;
7677
7678inline _LIBCPP_INLINE_VISIBILITY
7679bool
7680atomic_is_lock_free(const volatile atomic_ullong*)
7681{
7682 typedef unsigned long long type;
7683 return __atomic_is_lock_free(type);
7684}
7685
7686inline _LIBCPP_INLINE_VISIBILITY
7687bool
7688atomic_is_lock_free(const atomic_ullong* __obj)
7689{
7690 return atomic_is_lock_free(const_cast<volatile atomic_ullong*>(__obj));
7691}
7692
7693inline _LIBCPP_INLINE_VISIBILITY
7694void
7695atomic_init(volatile atomic_ullong* __obj, unsigned long long __desr)
7696{
7697 __obj->__v_ = __desr;
7698}
7699
7700inline _LIBCPP_INLINE_VISIBILITY
7701void
7702atomic_init(atomic_ullong* __obj, unsigned long long __desr)
7703{
7704 __obj->__v_ = __desr;
7705}
7706
7707inline _LIBCPP_INLINE_VISIBILITY
7708void
7709atomic_store(volatile atomic_ullong* __obj, unsigned long long __desr)
7710{
7711 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
7712}
7713
7714inline _LIBCPP_INLINE_VISIBILITY
7715void
7716atomic_store(atomic_ullong* __obj, unsigned long long __desr)
7717{
7718 atomic_store(const_cast<volatile atomic_ullong*>(__obj), __desr);
7719}
7720
7721inline _LIBCPP_INLINE_VISIBILITY
7722void
7723atomic_store_explicit(volatile atomic_ullong* __obj, unsigned long long __desr,
7724 memory_order __o)
7725{
7726 __atomic_store(&__obj->__v_, __desr, __o);
7727}
7728
7729inline _LIBCPP_INLINE_VISIBILITY
7730void
7731atomic_store_explicit(atomic_ullong* __obj, unsigned long long __desr,
7732 memory_order __o)
7733{
7734 atomic_store_explicit(const_cast<volatile atomic_ullong*>(__obj), __desr,
7735 __o);
7736}
7737
7738inline _LIBCPP_INLINE_VISIBILITY
7739unsigned long long
7740atomic_load(const volatile atomic_ullong* __obj)
7741{
7742 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
7743}
7744
7745inline _LIBCPP_INLINE_VISIBILITY
7746unsigned long long
7747atomic_load(const atomic_ullong* __obj)
7748{
7749 return atomic_load(const_cast<const volatile atomic_ullong*>(__obj));
7750}
7751
7752inline _LIBCPP_INLINE_VISIBILITY
7753unsigned long long
7754atomic_load_explicit(const volatile atomic_ullong* __obj, memory_order __o)
7755{
7756 return __atomic_load(&__obj->__v_, __o);
7757}
7758
7759inline _LIBCPP_INLINE_VISIBILITY
7760unsigned long long
7761atomic_load_explicit(const atomic_ullong* __obj, memory_order __o)
7762{
7763 return atomic_load_explicit(const_cast<const volatile atomic_ullong*>
7764 (__obj), __o);
7765}
7766
7767inline _LIBCPP_INLINE_VISIBILITY
7768unsigned long long
7769atomic_exchange(volatile atomic_ullong* __obj, unsigned long long __desr)
7770{
7771 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
7772}
7773
7774inline _LIBCPP_INLINE_VISIBILITY
7775unsigned long long
7776atomic_exchange(atomic_ullong* __obj, unsigned long long __desr)
7777{
7778 return atomic_exchange(const_cast<volatile atomic_ullong*>(__obj), __desr);
7779}
7780
7781inline _LIBCPP_INLINE_VISIBILITY
7782unsigned long long
7783atomic_exchange_explicit(volatile atomic_ullong* __obj,
7784 unsigned long long __desr, memory_order __o)
7785{
7786 return __atomic_exchange(&__obj->__v_, __desr, __o);
7787}
7788
7789inline _LIBCPP_INLINE_VISIBILITY
7790unsigned long long
7791atomic_exchange_explicit(atomic_ullong* __obj, unsigned long long __desr,
7792 memory_order __o)
7793{
7794 return atomic_exchange_explicit(const_cast<volatile atomic_ullong*>
7795 (__obj), __desr, __o);
7796}
7797
7798inline _LIBCPP_INLINE_VISIBILITY
7799bool
7800atomic_compare_exchange_weak(volatile atomic_ullong* __obj,
7801 unsigned long long* __exp,
7802 unsigned long long __desr)
7803{
7804 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
7805 memory_order_seq_cst, memory_order_seq_cst);
7806}
7807
7808inline _LIBCPP_INLINE_VISIBILITY
7809bool
7810atomic_compare_exchange_weak(atomic_ullong* __obj, unsigned long long* __exp,
7811 unsigned long long __desr)
7812{
7813 return atomic_compare_exchange_weak(const_cast<volatile atomic_ullong*>
7814 (__obj), __exp, __desr);
7815}
7816
7817inline _LIBCPP_INLINE_VISIBILITY
7818bool
7819atomic_compare_exchange_strong(volatile atomic_ullong* __obj,
7820 unsigned long long* __exp,
7821 unsigned long long __desr)
7822{
7823 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
7824 memory_order_seq_cst, memory_order_seq_cst);
7825}
7826
7827inline _LIBCPP_INLINE_VISIBILITY
7828bool
7829atomic_compare_exchange_strong(atomic_ullong* __obj, unsigned long long* __exp,
7830 unsigned long long __desr)
7831{
7832 return atomic_compare_exchange_strong(const_cast<volatile atomic_ullong*>
7833 (__obj), __exp, __desr);
7834}
7835
7836inline _LIBCPP_INLINE_VISIBILITY
7837bool
7838atomic_compare_exchange_weak_explicit(volatile atomic_ullong* __obj,
7839 unsigned long long* __exp,
7840 unsigned long long __desr,
7841 memory_order __s, memory_order __f)
7842{
7843 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
7844 __f);
7845}
7846
7847inline _LIBCPP_INLINE_VISIBILITY
7848bool
7849atomic_compare_exchange_weak_explicit(atomic_ullong* __obj,
7850 unsigned long long* __exp,
7851 unsigned long long __desr,
7852 memory_order __s, memory_order __f)
7853{
7854 return atomic_compare_exchange_weak_explicit(
7855 const_cast<volatile atomic_ullong*>(__obj), __exp, __desr, __s, __f);
7856}
7857
7858inline _LIBCPP_INLINE_VISIBILITY
7859bool
7860atomic_compare_exchange_strong_explicit(volatile atomic_ullong* __obj,
7861 unsigned long long* __exp,
7862 unsigned long long __desr,
7863 memory_order __s, memory_order __f)
7864{
7865 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
7866 __f);
7867}
7868
7869inline _LIBCPP_INLINE_VISIBILITY
7870bool
7871atomic_compare_exchange_strong_explicit(atomic_ullong* __obj,
7872 unsigned long long* __exp,
7873 unsigned long long __desr,
7874 memory_order __s, memory_order __f)
7875{
7876 return atomic_compare_exchange_strong_explicit(
7877 const_cast<volatile atomic_ullong*>(__obj), __exp, __desr, __s, __f);
7878}
7879
7880inline _LIBCPP_INLINE_VISIBILITY
7881unsigned long long
7882atomic_fetch_add(volatile atomic_ullong* __obj, unsigned long long __v)
7883{
7884 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
7885}
7886
7887inline _LIBCPP_INLINE_VISIBILITY
7888unsigned long long
7889atomic_fetch_add(atomic_ullong* __obj, unsigned long long __v)
7890{
7891 return atomic_fetch_add(const_cast<volatile atomic_ullong*>(__obj), __v);
7892}
7893
7894inline _LIBCPP_INLINE_VISIBILITY
7895unsigned long long
7896atomic_fetch_add_explicit(volatile atomic_ullong* __obj, unsigned long long __v,
7897 memory_order __o)
7898{
7899 return __atomic_fetch_add(&__obj->__v_, __v, __o);
7900}
7901
7902inline _LIBCPP_INLINE_VISIBILITY
7903unsigned long long
7904atomic_fetch_add_explicit(atomic_ullong* __obj, unsigned long long __v,
7905 memory_order __o)
7906{
7907 return atomic_fetch_add_explicit(const_cast<volatile atomic_ullong*>(__obj),
7908 __v, __o);
7909}
7910
7911inline _LIBCPP_INLINE_VISIBILITY
7912unsigned long long
7913atomic_fetch_sub(volatile atomic_ullong* __obj, unsigned long long __v)
7914{
7915 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
7916}
7917
7918inline _LIBCPP_INLINE_VISIBILITY
7919unsigned long long
7920atomic_fetch_sub(atomic_ullong* __obj, unsigned long long __v)
7921{
7922 return atomic_fetch_sub(const_cast<volatile atomic_ullong*>(__obj), __v);
7923}
7924
7925inline _LIBCPP_INLINE_VISIBILITY
7926unsigned long long
7927atomic_fetch_sub_explicit(volatile atomic_ullong* __obj, unsigned long long __v,
7928 memory_order __o)
7929{
7930 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
7931}
7932
7933inline _LIBCPP_INLINE_VISIBILITY
7934unsigned long long
7935atomic_fetch_sub_explicit(atomic_ullong* __obj, unsigned long long __v,
7936 memory_order __o)
7937{
7938 return atomic_fetch_sub_explicit(const_cast<volatile atomic_ullong*>(__obj),
7939 __v, __o);
7940}
7941
7942inline _LIBCPP_INLINE_VISIBILITY
7943unsigned long long
7944atomic_fetch_and(volatile atomic_ullong* __obj, unsigned long long __v)
7945{
7946 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
7947}
7948
7949inline _LIBCPP_INLINE_VISIBILITY
7950unsigned long long
7951atomic_fetch_and(atomic_ullong* __obj, unsigned long long __v)
7952{
7953 return atomic_fetch_and(const_cast<volatile atomic_ullong*>(__obj), __v);
7954}
7955
7956inline _LIBCPP_INLINE_VISIBILITY
7957unsigned long long
7958atomic_fetch_and_explicit(volatile atomic_ullong* __obj, unsigned long long __v,
7959 memory_order __o)
7960{
7961 return __atomic_fetch_and(&__obj->__v_, __v, __o);
7962}
7963
7964inline _LIBCPP_INLINE_VISIBILITY
7965unsigned long long
7966atomic_fetch_and_explicit(atomic_ullong* __obj, unsigned long long __v,
7967 memory_order __o)
7968{
7969 return atomic_fetch_and_explicit(const_cast<volatile atomic_ullong*>(__obj),
7970 __v, __o);
7971}
7972
7973inline _LIBCPP_INLINE_VISIBILITY
7974unsigned long long
7975atomic_fetch_or(volatile atomic_ullong* __obj, unsigned long long __v)
7976{
7977 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
7978}
7979
7980inline _LIBCPP_INLINE_VISIBILITY
7981unsigned long long
7982atomic_fetch_or(atomic_ullong* __obj, unsigned long long __v)
7983{
7984 return atomic_fetch_or(const_cast<volatile atomic_ullong*>(__obj), __v);
7985}
7986
7987inline _LIBCPP_INLINE_VISIBILITY
7988unsigned long long
7989atomic_fetch_or_explicit(volatile atomic_ullong* __obj, unsigned long long __v,
7990 memory_order __o)
7991{
7992 return __atomic_fetch_or(&__obj->__v_, __v, __o);
7993}
7994
7995inline _LIBCPP_INLINE_VISIBILITY
7996unsigned long long
7997atomic_fetch_or_explicit(atomic_ullong* __obj, unsigned long long __v,
7998 memory_order __o)
7999{
8000 return atomic_fetch_or_explicit(const_cast<volatile atomic_ullong*>(__obj),
8001 __v, __o);
8002}
8003
8004inline _LIBCPP_INLINE_VISIBILITY
8005unsigned long long
8006atomic_fetch_xor(volatile atomic_ullong* __obj, unsigned long long __v)
8007{
8008 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
8009}
8010
8011inline _LIBCPP_INLINE_VISIBILITY
8012unsigned long long
8013atomic_fetch_xor(atomic_ullong* __obj, unsigned long long __v)
8014{
8015 return atomic_fetch_xor(const_cast<volatile atomic_ullong*>(__obj), __v);
8016}
8017
8018inline _LIBCPP_INLINE_VISIBILITY
8019unsigned long long
8020atomic_fetch_xor_explicit(volatile atomic_ullong* __obj, unsigned long long __v,
8021 memory_order __o)
8022{
8023 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
8024}
8025
8026inline _LIBCPP_INLINE_VISIBILITY
8027unsigned long long
8028atomic_fetch_xor_explicit(atomic_ullong* __obj, unsigned long long __v,
8029 memory_order __o)
8030{
8031 return atomic_fetch_xor_explicit(const_cast<volatile atomic_ullong*>(__obj),
8032 __v, __o);
8033}
8034
8035#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
8036
8037// atomic_char16_t
8038
8039struct atomic_char16_t;
8040
8041bool atomic_is_lock_free(const volatile atomic_char16_t*);
8042bool atomic_is_lock_free(const atomic_char16_t*);
8043void atomic_init(volatile atomic_char16_t*, char16_t);
8044void atomic_init(atomic_char16_t*, char16_t);
8045void atomic_store(volatile atomic_char16_t*, char16_t);
8046void atomic_store(atomic_char16_t*, char16_t);
8047void atomic_store_explicit(volatile atomic_char16_t*, char16_t, memory_order);
8048void atomic_store_explicit(atomic_char16_t*, char16_t, memory_order);
8049char16_t atomic_load(const volatile atomic_char16_t*);
8050char16_t atomic_load(const atomic_char16_t*);
8051char16_t atomic_load_explicit(const volatile atomic_char16_t*, memory_order);
8052char16_t atomic_load_explicit(const atomic_char16_t*, memory_order);
8053char16_t atomic_exchange(volatile atomic_char16_t*, char16_t);
8054char16_t atomic_exchange(atomic_char16_t*, char16_t);
8055char16_t atomic_exchange_explicit(volatile atomic_char16_t*, char16_t,
8056 memory_order);
8057char16_t atomic_exchange_explicit(atomic_char16_t*, char16_t, memory_order);
8058bool atomic_compare_exchange_weak(volatile atomic_char16_t*, char16_t*,
8059 char16_t);
8060bool atomic_compare_exchange_weak(atomic_char16_t*, char16_t*, char16_t);
8061bool atomic_compare_exchange_strong(volatile atomic_char16_t*, char16_t*,
8062 char16_t);
8063bool atomic_compare_exchange_strong(atomic_char16_t*, char16_t*, char16_t);
8064bool atomic_compare_exchange_weak_explicit(volatile atomic_char16_t*, char16_t*,
8065 char16_t, memory_order,
8066 memory_order);
8067bool atomic_compare_exchange_weak_explicit(atomic_char16_t*, char16_t*,
8068 char16_t, memory_order,
8069 memory_order);
8070bool atomic_compare_exchange_strong_explicit(volatile atomic_char16_t*,
8071 char16_t*, char16_t, memory_order,
8072 memory_order);
8073bool atomic_compare_exchange_strong_explicit(atomic_char16_t*, char16_t*,
8074 char16_t, memory_order,
8075 memory_order);
8076char16_t atomic_fetch_add(volatile atomic_char16_t*, char16_t);
8077char16_t atomic_fetch_add(atomic_char16_t*, char16_t);
8078char16_t atomic_fetch_add_explicit(volatile atomic_char16_t*, char16_t,
8079 memory_order);
8080char16_t atomic_fetch_add_explicit(atomic_char16_t*, char16_t, memory_order);
8081char16_t atomic_fetch_sub(volatile atomic_char16_t*, char16_t);
8082char16_t atomic_fetch_sub(atomic_char16_t*, char16_t);
8083char16_t atomic_fetch_sub_explicit(volatile atomic_char16_t*, char16_t,
8084 memory_order);
8085char16_t atomic_fetch_sub_explicit(atomic_char16_t*, char16_t, memory_order);
8086char16_t atomic_fetch_and(volatile atomic_char16_t*, char16_t);
8087char16_t atomic_fetch_and(atomic_char16_t*, char16_t);
8088char16_t atomic_fetch_and_explicit(volatile atomic_char16_t*, char16_t,
8089 memory_order);
8090char16_t atomic_fetch_and_explicit(atomic_char16_t*, char16_t, memory_order);
8091char16_t atomic_fetch_or(volatile atomic_char16_t*, char16_t);
8092char16_t atomic_fetch_or(atomic_char16_t*, char16_t);
8093char16_t atomic_fetch_or_explicit(volatile atomic_char16_t*, char16_t,
8094 memory_order);
8095char16_t atomic_fetch_or_explicit(atomic_char16_t*, char16_t, memory_order);
8096char16_t atomic_fetch_xor(volatile atomic_char16_t*, char16_t);
8097char16_t atomic_fetch_xor(atomic_char16_t*, char16_t);
8098char16_t atomic_fetch_xor_explicit(volatile atomic_char16_t*, char16_t,
8099 memory_order);
8100char16_t atomic_fetch_xor_explicit(atomic_char16_t*, char16_t, memory_order);
8101
8102typedef struct atomic_char16_t
8103{
8104 char16_t __v_;
8105
8106 _LIBCPP_INLINE_VISIBILITY
8107 bool is_lock_free() const volatile
8108 {return atomic_is_lock_free(this);}
8109 _LIBCPP_INLINE_VISIBILITY
8110 bool is_lock_free() const
8111 {return atomic_is_lock_free(this);}
8112 _LIBCPP_INLINE_VISIBILITY
8113 void store(char16_t __v, memory_order __o = memory_order_seq_cst) volatile
8114 {atomic_store_explicit(this, __v, __o);}
8115 _LIBCPP_INLINE_VISIBILITY
8116 void store(char16_t __v, memory_order __o = memory_order_seq_cst)
8117 {atomic_store_explicit(this, __v, __o);}
8118 _LIBCPP_INLINE_VISIBILITY
8119 char16_t load(memory_order __o = memory_order_seq_cst) const volatile
8120 {return atomic_load_explicit(this, __o);}
8121 _LIBCPP_INLINE_VISIBILITY
8122 char16_t load(memory_order __o = memory_order_seq_cst) const
8123 {return atomic_load_explicit(this, __o);}
8124 _LIBCPP_INLINE_VISIBILITY
8125 operator char16_t() const volatile
8126 {return load();}
8127 _LIBCPP_INLINE_VISIBILITY
8128 operator char16_t() const
8129 {return load();}
8130 _LIBCPP_INLINE_VISIBILITY
8131 char16_t exchange(char16_t __v,
8132 memory_order __o = memory_order_seq_cst) volatile
8133 {return atomic_exchange_explicit(this, __v, __o);}
8134 _LIBCPP_INLINE_VISIBILITY
8135 char16_t exchange(char16_t __v, memory_order __o = memory_order_seq_cst)
8136 {return atomic_exchange_explicit(this, __v, __o);}
8137 _LIBCPP_INLINE_VISIBILITY
8138 bool compare_exchange_weak(char16_t& __v, char16_t __e, memory_order __s,
8139 memory_order __f) volatile
8140 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8141 __f);}
8142 _LIBCPP_INLINE_VISIBILITY
8143 bool compare_exchange_weak(char16_t& __v, char16_t __e, memory_order __s,
8144 memory_order __f)
8145 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8146 __f);}
8147 _LIBCPP_INLINE_VISIBILITY
8148 bool compare_exchange_strong(char16_t& __v, char16_t __e, memory_order __s,
8149 memory_order __f) volatile
8150 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8151 __f);}
8152 _LIBCPP_INLINE_VISIBILITY
8153 bool compare_exchange_strong(char16_t& __v, char16_t __e, memory_order __s,
8154 memory_order __f)
8155 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8156 __f);}
8157 _LIBCPP_INLINE_VISIBILITY
8158 bool compare_exchange_weak(char16_t& __v, char16_t __e,
8159 memory_order __s = memory_order_seq_cst) volatile
8160 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8161 __translate_memory_order(__s));}
8162 _LIBCPP_INLINE_VISIBILITY
8163 bool compare_exchange_weak(char16_t& __v, char16_t __e,
8164 memory_order __s = memory_order_seq_cst)
8165 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8166 __translate_memory_order(__s));}
8167 _LIBCPP_INLINE_VISIBILITY
8168 bool compare_exchange_strong(char16_t& __v, char16_t __e,
8169 memory_order __s = memory_order_seq_cst) volatile
8170 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8171 __translate_memory_order(__s));}
8172 _LIBCPP_INLINE_VISIBILITY
8173 bool compare_exchange_strong(char16_t& __v, char16_t __e,
8174 memory_order __s = memory_order_seq_cst)
8175 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8176 __translate_memory_order(__s));}
8177 _LIBCPP_INLINE_VISIBILITY
8178 char16_t fetch_add(char16_t __v,
8179 memory_order __o = memory_order_seq_cst) volatile
8180 {return atomic_fetch_add_explicit(this, __v, __o);}
8181 _LIBCPP_INLINE_VISIBILITY
8182 char16_t fetch_add(char16_t __v, memory_order __o = memory_order_seq_cst)
8183 {return atomic_fetch_add_explicit(this, __v, __o);}
8184 _LIBCPP_INLINE_VISIBILITY
8185 char16_t fetch_sub(char16_t __v,
8186 memory_order __o = memory_order_seq_cst) volatile
8187 {return atomic_fetch_sub_explicit(this, __v, __o);}
8188 _LIBCPP_INLINE_VISIBILITY
8189 char16_t fetch_sub(char16_t __v, memory_order __o = memory_order_seq_cst)
8190 {return atomic_fetch_sub_explicit(this, __v, __o);}
8191 _LIBCPP_INLINE_VISIBILITY
8192 char16_t fetch_and(char16_t __v,
8193 memory_order __o = memory_order_seq_cst) volatile
8194 {return atomic_fetch_and_explicit(this, __v, __o);}
8195 _LIBCPP_INLINE_VISIBILITY
8196 char16_t fetch_and(char16_t __v, memory_order __o = memory_order_seq_cst)
8197 {return atomic_fetch_and_explicit(this, __v, __o);}
8198 _LIBCPP_INLINE_VISIBILITY
8199 char16_t fetch_or(char16_t __v,
8200 memory_order __o = memory_order_seq_cst) volatile
8201 {return atomic_fetch_or_explicit(this, __v, __o);}
8202 _LIBCPP_INLINE_VISIBILITY
8203 char16_t fetch_or(char16_t __v, memory_order __o = memory_order_seq_cst)
8204 {return atomic_fetch_or_explicit(this, __v, __o);}
8205 _LIBCPP_INLINE_VISIBILITY
8206 char16_t fetch_xor(char16_t __v,
8207 memory_order __o = memory_order_seq_cst) volatile
8208 {return atomic_fetch_xor_explicit(this, __v, __o);}
8209 _LIBCPP_INLINE_VISIBILITY
8210 char16_t fetch_xor(char16_t __v, memory_order __o = memory_order_seq_cst)
8211 {return atomic_fetch_xor_explicit(this, __v, __o);}
8212#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
8213 atomic_char16_t() = default;
8214#else
8215 _LIBCPP_INLINE_VISIBILITY
8216 atomic_char16_t() {}
8217#endif
8218 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00008219 constexpr atomic_char16_t(char16_t __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00008220 : __v_(__v) {}
8221#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
8222 atomic_char16_t(const atomic_char16_t&) = delete;
8223 atomic_char16_t& operator=(const atomic_char16_t&) = delete;
8224 atomic_char16_t& operator=(const atomic_char16_t&) volatile = delete;
8225#else
8226private:
8227 atomic_char16_t(const atomic_char16_t&);
8228 atomic_char16_t& operator=(const atomic_char16_t&);
8229 atomic_char16_t& operator=(const atomic_char16_t&) volatile;
8230public:
8231#endif
8232 _LIBCPP_INLINE_VISIBILITY
8233 char16_t operator=(char16_t __v) volatile
8234 {store(__v); return __v;}
8235 _LIBCPP_INLINE_VISIBILITY
8236 char16_t operator=(char16_t __v)
8237 {store(__v); return __v;}
8238 _LIBCPP_INLINE_VISIBILITY
8239 char16_t operator++(int) volatile
8240 {return fetch_add(char16_t(1));}
8241 _LIBCPP_INLINE_VISIBILITY
8242 char16_t operator++(int)
8243 {return fetch_add(char16_t(1));}
8244 _LIBCPP_INLINE_VISIBILITY
8245 char16_t operator--(int) volatile
8246 {return fetch_sub(char16_t(1));}
8247 _LIBCPP_INLINE_VISIBILITY
8248 char16_t operator--(int)
8249 {return fetch_sub(char16_t(1));}
8250 _LIBCPP_INLINE_VISIBILITY
8251 char16_t operator++() volatile
8252 {return char16_t(fetch_add(char16_t(1)) + 1);}
8253 _LIBCPP_INLINE_VISIBILITY
8254 char16_t operator++()
8255 {return char16_t(fetch_add(char16_t(1)) + 1);}
8256 _LIBCPP_INLINE_VISIBILITY
8257 char16_t operator--() volatile
8258 {return char16_t(fetch_sub(char16_t(1)) - 1);}
8259 _LIBCPP_INLINE_VISIBILITY
8260 char16_t operator--()
8261 {return char16_t(fetch_sub(char16_t(1)) - 1);}
8262 _LIBCPP_INLINE_VISIBILITY
8263 char16_t operator+=(char16_t __v) volatile
8264 {return char16_t(fetch_add(__v) + __v);}
8265 _LIBCPP_INLINE_VISIBILITY
8266 char16_t operator+=(char16_t __v)
8267 {return char16_t(fetch_add(__v) + __v);}
8268 _LIBCPP_INLINE_VISIBILITY
8269 char16_t operator-=(char16_t __v) volatile
8270 {return char16_t(fetch_sub(__v) - __v);}
8271 _LIBCPP_INLINE_VISIBILITY
8272 char16_t operator-=(char16_t __v)
8273 {return char16_t(fetch_sub(__v) - __v);}
8274 _LIBCPP_INLINE_VISIBILITY
8275 char16_t operator&=(char16_t __v) volatile
8276 {return char16_t(fetch_and(__v) & __v);}
8277 _LIBCPP_INLINE_VISIBILITY
8278 char16_t operator&=(char16_t __v)
8279 {return char16_t(fetch_and(__v) & __v);}
8280 _LIBCPP_INLINE_VISIBILITY
8281 char16_t operator|=(char16_t __v) volatile
8282 {return char16_t(fetch_or(__v) | __v);}
8283 _LIBCPP_INLINE_VISIBILITY
8284 char16_t operator|=(char16_t __v)
8285 {return char16_t(fetch_or(__v) | __v);}
8286 _LIBCPP_INLINE_VISIBILITY
8287 char16_t operator^=(char16_t __v) volatile
8288 {return char16_t(fetch_xor(__v) ^ __v);}
8289 _LIBCPP_INLINE_VISIBILITY
8290 char16_t operator^=(char16_t __v)
8291 {return char16_t(fetch_xor(__v) ^ __v);}
8292} atomic_char16_t;
8293
8294inline _LIBCPP_INLINE_VISIBILITY
8295bool
8296atomic_is_lock_free(const volatile atomic_char16_t*)
8297{
8298 typedef char16_t type;
8299 return __atomic_is_lock_free(type);
8300}
8301
8302inline _LIBCPP_INLINE_VISIBILITY
8303bool
8304atomic_is_lock_free(const atomic_char16_t* __obj)
8305{
8306 return atomic_is_lock_free(const_cast<volatile atomic_char16_t*>(__obj));
8307}
8308
8309inline _LIBCPP_INLINE_VISIBILITY
8310void
8311atomic_init(volatile atomic_char16_t* __obj, char16_t __desr)
8312{
8313 __obj->__v_ = __desr;
8314}
8315
8316inline _LIBCPP_INLINE_VISIBILITY
8317void
8318atomic_init(atomic_char16_t* __obj, char16_t __desr)
8319{
8320 __obj->__v_ = __desr;
8321}
8322
8323inline _LIBCPP_INLINE_VISIBILITY
8324void
8325atomic_store(volatile atomic_char16_t* __obj, char16_t __desr)
8326{
8327 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
8328}
8329
8330inline _LIBCPP_INLINE_VISIBILITY
8331void
8332atomic_store(atomic_char16_t* __obj, char16_t __desr)
8333{
8334 atomic_store(const_cast<volatile atomic_char16_t*>(__obj), __desr);
8335}
8336
8337inline _LIBCPP_INLINE_VISIBILITY
8338void
8339atomic_store_explicit(volatile atomic_char16_t* __obj, char16_t __desr,
8340 memory_order __o)
8341{
8342 __atomic_store(&__obj->__v_, __desr, __o);
8343}
8344
8345inline _LIBCPP_INLINE_VISIBILITY
8346void
8347atomic_store_explicit(atomic_char16_t* __obj, char16_t __desr, memory_order __o)
8348{
8349 atomic_store_explicit(const_cast<volatile atomic_char16_t*>(__obj), __desr,
8350 __o);
8351}
8352
8353inline _LIBCPP_INLINE_VISIBILITY
8354char16_t
8355atomic_load(const volatile atomic_char16_t* __obj)
8356{
8357 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
8358}
8359
8360inline _LIBCPP_INLINE_VISIBILITY
8361char16_t
8362atomic_load(const atomic_char16_t* __obj)
8363{
8364 return atomic_load(const_cast<const volatile atomic_char16_t*>(__obj));
8365}
8366
8367inline _LIBCPP_INLINE_VISIBILITY
8368char16_t
8369atomic_load_explicit(const volatile atomic_char16_t* __obj, memory_order __o)
8370{
8371 return __atomic_load(&__obj->__v_, __o);
8372}
8373
8374inline _LIBCPP_INLINE_VISIBILITY
8375char16_t
8376atomic_load_explicit(const atomic_char16_t* __obj, memory_order __o)
8377{
8378 return atomic_load_explicit(const_cast<const volatile atomic_char16_t*>
8379 (__obj), __o);
8380}
8381
8382inline _LIBCPP_INLINE_VISIBILITY
8383char16_t
8384atomic_exchange(volatile atomic_char16_t* __obj, char16_t __desr)
8385{
8386 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
8387}
8388
8389inline _LIBCPP_INLINE_VISIBILITY
8390char16_t
8391atomic_exchange(atomic_char16_t* __obj, char16_t __desr)
8392{
8393 return atomic_exchange(const_cast<volatile atomic_char16_t*>(__obj), __desr);
8394}
8395
8396inline _LIBCPP_INLINE_VISIBILITY
8397char16_t
8398atomic_exchange_explicit(volatile atomic_char16_t* __obj, char16_t __desr,
8399 memory_order __o)
8400{
8401 return __atomic_exchange(&__obj->__v_, __desr, __o);
8402}
8403
8404inline _LIBCPP_INLINE_VISIBILITY
8405char16_t
8406atomic_exchange_explicit(atomic_char16_t* __obj, char16_t __desr,
8407 memory_order __o)
8408{
8409 return atomic_exchange_explicit(const_cast<volatile atomic_char16_t*>
8410 (__obj), __desr, __o);
8411}
8412
8413inline _LIBCPP_INLINE_VISIBILITY
8414bool
8415atomic_compare_exchange_weak(volatile atomic_char16_t* __obj, char16_t* __exp,
8416 char16_t __desr)
8417{
8418 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
8419 memory_order_seq_cst, memory_order_seq_cst);
8420}
8421
8422inline _LIBCPP_INLINE_VISIBILITY
8423bool
8424atomic_compare_exchange_weak(atomic_char16_t* __obj, char16_t* __exp,
8425 char16_t __desr)
8426{
8427 return atomic_compare_exchange_weak(const_cast<volatile atomic_char16_t*>
8428 (__obj), __exp, __desr);
8429}
8430
8431inline _LIBCPP_INLINE_VISIBILITY
8432bool
8433atomic_compare_exchange_strong(volatile atomic_char16_t* __obj, char16_t* __exp,
8434 char16_t __desr)
8435{
8436 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
8437 memory_order_seq_cst, memory_order_seq_cst);
8438}
8439
8440inline _LIBCPP_INLINE_VISIBILITY
8441bool
8442atomic_compare_exchange_strong(atomic_char16_t* __obj, char16_t* __exp,
8443 char16_t __desr)
8444{
8445 return atomic_compare_exchange_strong(const_cast<volatile atomic_char16_t*>
8446 (__obj), __exp, __desr);
8447}
8448
8449inline _LIBCPP_INLINE_VISIBILITY
8450bool
8451atomic_compare_exchange_weak_explicit(volatile atomic_char16_t* __obj,
8452 char16_t* __exp, char16_t __desr,
8453 memory_order __s, memory_order __f)
8454{
8455 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
8456 __f);
8457}
8458
8459inline _LIBCPP_INLINE_VISIBILITY
8460bool
8461atomic_compare_exchange_weak_explicit(atomic_char16_t* __obj, char16_t* __exp,
8462 char16_t __desr, memory_order __s,
8463 memory_order __f)
8464{
8465 return atomic_compare_exchange_weak_explicit(
8466 const_cast<volatile atomic_char16_t*>(__obj), __exp, __desr, __s, __f);
8467}
8468
8469inline _LIBCPP_INLINE_VISIBILITY
8470bool
8471atomic_compare_exchange_strong_explicit(volatile atomic_char16_t* __obj,
8472 char16_t* __exp, char16_t __desr,
8473 memory_order __s, memory_order __f)
8474{
8475 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
8476 __f);
8477}
8478
8479inline _LIBCPP_INLINE_VISIBILITY
8480bool
8481atomic_compare_exchange_strong_explicit(atomic_char16_t* __obj, char16_t* __exp,
8482 char16_t __desr, memory_order __s,
8483 memory_order __f)
8484{
8485 return atomic_compare_exchange_strong_explicit(
8486 const_cast<volatile atomic_char16_t*>(__obj), __exp, __desr, __s, __f);
8487}
8488
8489inline _LIBCPP_INLINE_VISIBILITY
8490char16_t
8491atomic_fetch_add(volatile atomic_char16_t* __obj, char16_t __v)
8492{
8493 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
8494}
8495
8496inline _LIBCPP_INLINE_VISIBILITY
8497char16_t
8498atomic_fetch_add(atomic_char16_t* __obj, char16_t __v)
8499{
8500 return atomic_fetch_add(const_cast<volatile atomic_char16_t*>(__obj), __v);
8501}
8502
8503inline _LIBCPP_INLINE_VISIBILITY
8504char16_t
8505atomic_fetch_add_explicit(volatile atomic_char16_t* __obj, char16_t __v,
8506 memory_order __o)
8507{
8508 return __atomic_fetch_add(&__obj->__v_, __v, __o);
8509}
8510
8511inline _LIBCPP_INLINE_VISIBILITY
8512char16_t
8513atomic_fetch_add_explicit(atomic_char16_t* __obj, char16_t __v,
8514 memory_order __o)
8515{
8516 return atomic_fetch_add_explicit(const_cast<volatile atomic_char16_t*>(__obj),
8517 __v, __o);
8518}
8519
8520inline _LIBCPP_INLINE_VISIBILITY
8521char16_t
8522atomic_fetch_sub(volatile atomic_char16_t* __obj, char16_t __v)
8523{
8524 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
8525}
8526
8527inline _LIBCPP_INLINE_VISIBILITY
8528char16_t
8529atomic_fetch_sub(atomic_char16_t* __obj, char16_t __v)
8530{
8531 return atomic_fetch_sub(const_cast<volatile atomic_char16_t*>(__obj), __v);
8532}
8533
8534inline _LIBCPP_INLINE_VISIBILITY
8535char16_t
8536atomic_fetch_sub_explicit(volatile atomic_char16_t* __obj, char16_t __v,
8537 memory_order __o)
8538{
8539 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
8540}
8541
8542inline _LIBCPP_INLINE_VISIBILITY
8543char16_t
8544atomic_fetch_sub_explicit(atomic_char16_t* __obj, char16_t __v,
8545 memory_order __o)
8546{
8547 return atomic_fetch_sub_explicit(const_cast<volatile atomic_char16_t*>(__obj),
8548 __v, __o);
8549}
8550
8551inline _LIBCPP_INLINE_VISIBILITY
8552char16_t
8553atomic_fetch_and(volatile atomic_char16_t* __obj, char16_t __v)
8554{
8555 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
8556}
8557
8558inline _LIBCPP_INLINE_VISIBILITY
8559char16_t
8560atomic_fetch_and(atomic_char16_t* __obj, char16_t __v)
8561{
8562 return atomic_fetch_and(const_cast<volatile atomic_char16_t*>(__obj), __v);
8563}
8564
8565inline _LIBCPP_INLINE_VISIBILITY
8566char16_t
8567atomic_fetch_and_explicit(volatile atomic_char16_t* __obj, char16_t __v,
8568 memory_order __o)
8569{
8570 return __atomic_fetch_and(&__obj->__v_, __v, __o);
8571}
8572
8573inline _LIBCPP_INLINE_VISIBILITY
8574char16_t
8575atomic_fetch_and_explicit(atomic_char16_t* __obj, char16_t __v,
8576 memory_order __o)
8577{
8578 return atomic_fetch_and_explicit(const_cast<volatile atomic_char16_t*>(__obj),
8579 __v, __o);
8580}
8581
8582inline _LIBCPP_INLINE_VISIBILITY
8583char16_t
8584atomic_fetch_or(volatile atomic_char16_t* __obj, char16_t __v)
8585{
8586 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
8587}
8588
8589inline _LIBCPP_INLINE_VISIBILITY
8590char16_t
8591atomic_fetch_or(atomic_char16_t* __obj, char16_t __v)
8592{
8593 return atomic_fetch_or(const_cast<volatile atomic_char16_t*>(__obj), __v);
8594}
8595
8596inline _LIBCPP_INLINE_VISIBILITY
8597char16_t
8598atomic_fetch_or_explicit(volatile atomic_char16_t* __obj, char16_t __v,
8599 memory_order __o)
8600{
8601 return __atomic_fetch_or(&__obj->__v_, __v, __o);
8602}
8603
8604inline _LIBCPP_INLINE_VISIBILITY
8605char16_t
8606atomic_fetch_or_explicit(atomic_char16_t* __obj, char16_t __v, memory_order __o)
8607{
8608 return atomic_fetch_or_explicit(const_cast<volatile atomic_char16_t*>(__obj),
8609 __v, __o);
8610}
8611
8612inline _LIBCPP_INLINE_VISIBILITY
8613char16_t
8614atomic_fetch_xor(volatile atomic_char16_t* __obj, char16_t __v)
8615{
8616 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
8617}
8618
8619inline _LIBCPP_INLINE_VISIBILITY
8620char16_t
8621atomic_fetch_xor(atomic_char16_t* __obj, char16_t __v)
8622{
8623 return atomic_fetch_xor(const_cast<volatile atomic_char16_t*>(__obj), __v);
8624}
8625
8626inline _LIBCPP_INLINE_VISIBILITY
8627char16_t
8628atomic_fetch_xor_explicit(volatile atomic_char16_t* __obj, char16_t __v,
8629 memory_order __o)
8630{
8631 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
8632}
8633
8634inline _LIBCPP_INLINE_VISIBILITY
8635char16_t
8636atomic_fetch_xor_explicit(atomic_char16_t* __obj, char16_t __v,
8637 memory_order __o)
8638{
8639 return atomic_fetch_xor_explicit(const_cast<volatile atomic_char16_t*>(__obj),
8640 __v, __o);
8641}
8642
8643// atomic_char32_t
8644
8645struct atomic_char32_t;
8646
8647bool atomic_is_lock_free(const volatile atomic_char32_t*);
8648bool atomic_is_lock_free(const atomic_char32_t*);
8649void atomic_init(volatile atomic_char32_t*, char32_t);
8650void atomic_init(atomic_char32_t*, char32_t);
8651void atomic_store(volatile atomic_char32_t*, char32_t);
8652void atomic_store(atomic_char32_t*, char32_t);
8653void atomic_store_explicit(volatile atomic_char32_t*, char32_t, memory_order);
8654void atomic_store_explicit(atomic_char32_t*, char32_t, memory_order);
8655char32_t atomic_load(const volatile atomic_char32_t*);
8656char32_t atomic_load(const atomic_char32_t*);
8657char32_t atomic_load_explicit(const volatile atomic_char32_t*, memory_order);
8658char32_t atomic_load_explicit(const atomic_char32_t*, memory_order);
8659char32_t atomic_exchange(volatile atomic_char32_t*, char32_t);
8660char32_t atomic_exchange(atomic_char32_t*, char32_t);
8661char32_t atomic_exchange_explicit(volatile atomic_char32_t*, char32_t,
8662 memory_order);
8663char32_t atomic_exchange_explicit(atomic_char32_t*, char32_t, memory_order);
8664bool atomic_compare_exchange_weak(volatile atomic_char32_t*, char32_t*,
8665 char32_t);
8666bool atomic_compare_exchange_weak(atomic_char32_t*, char32_t*, char32_t);
8667bool atomic_compare_exchange_strong(volatile atomic_char32_t*, char32_t*,
8668 char32_t);
8669bool atomic_compare_exchange_strong(atomic_char32_t*, char32_t*, char32_t);
8670bool atomic_compare_exchange_weak_explicit(volatile atomic_char32_t*, char32_t*,
8671 char32_t, memory_order,
8672 memory_order);
8673bool atomic_compare_exchange_weak_explicit(atomic_char32_t*, char32_t*,
8674 char32_t, memory_order,
8675 memory_order);
8676bool atomic_compare_exchange_strong_explicit(volatile atomic_char32_t*,
8677 char32_t*, char32_t, memory_order,
8678 memory_order);
8679bool atomic_compare_exchange_strong_explicit(atomic_char32_t*, char32_t*,
8680 char32_t, memory_order,
8681 memory_order);
8682char32_t atomic_fetch_add(volatile atomic_char32_t*, char32_t);
8683char32_t atomic_fetch_add(atomic_char32_t*, char32_t);
8684char32_t atomic_fetch_add_explicit(volatile atomic_char32_t*, char32_t,
8685 memory_order);
8686char32_t atomic_fetch_add_explicit(atomic_char32_t*, char32_t, memory_order);
8687char32_t atomic_fetch_sub(volatile atomic_char32_t*, char32_t);
8688char32_t atomic_fetch_sub(atomic_char32_t*, char32_t);
8689char32_t atomic_fetch_sub_explicit(volatile atomic_char32_t*, char32_t,
8690 memory_order);
8691char32_t atomic_fetch_sub_explicit(atomic_char32_t*, char32_t, memory_order);
8692char32_t atomic_fetch_and(volatile atomic_char32_t*, char32_t);
8693char32_t atomic_fetch_and(atomic_char32_t*, char32_t);
8694char32_t atomic_fetch_and_explicit(volatile atomic_char32_t*, char32_t,
8695 memory_order);
8696char32_t atomic_fetch_and_explicit(atomic_char32_t*, char32_t, memory_order);
8697char32_t atomic_fetch_or(volatile atomic_char32_t*, char32_t);
8698char32_t atomic_fetch_or(atomic_char32_t*, char32_t);
8699char32_t atomic_fetch_or_explicit(volatile atomic_char32_t*, char32_t,
8700 memory_order);
8701char32_t atomic_fetch_or_explicit(atomic_char32_t*, char32_t, memory_order);
8702char32_t atomic_fetch_xor(volatile atomic_char32_t*, char32_t);
8703char32_t atomic_fetch_xor(atomic_char32_t*, char32_t);
8704char32_t atomic_fetch_xor_explicit(volatile atomic_char32_t*, char32_t,
8705 memory_order);
8706char32_t atomic_fetch_xor_explicit(atomic_char32_t*, char32_t, memory_order);
8707
8708typedef struct atomic_char32_t
8709{
8710 char32_t __v_;
8711
8712 _LIBCPP_INLINE_VISIBILITY
8713 bool is_lock_free() const volatile
8714 {return atomic_is_lock_free(this);}
8715 _LIBCPP_INLINE_VISIBILITY
8716 bool is_lock_free() const
8717 {return atomic_is_lock_free(this);}
8718 _LIBCPP_INLINE_VISIBILITY
8719 void store(char32_t __v, memory_order __o = memory_order_seq_cst) volatile
8720 {atomic_store_explicit(this, __v, __o);}
8721 _LIBCPP_INLINE_VISIBILITY
8722 void store(char32_t __v, memory_order __o = memory_order_seq_cst)
8723 {atomic_store_explicit(this, __v, __o);}
8724 _LIBCPP_INLINE_VISIBILITY
8725 char32_t load(memory_order __o = memory_order_seq_cst) const volatile
8726 {return atomic_load_explicit(this, __o);}
8727 _LIBCPP_INLINE_VISIBILITY
8728 char32_t load(memory_order __o = memory_order_seq_cst) const
8729 {return atomic_load_explicit(this, __o);}
8730 _LIBCPP_INLINE_VISIBILITY
8731 operator char32_t() const volatile
8732 {return load();}
8733 _LIBCPP_INLINE_VISIBILITY
8734 operator char32_t() const
8735 {return load();}
8736 _LIBCPP_INLINE_VISIBILITY
8737 char32_t exchange(char32_t __v,
8738 memory_order __o = memory_order_seq_cst) volatile
8739 {return atomic_exchange_explicit(this, __v, __o);}
8740 _LIBCPP_INLINE_VISIBILITY
8741 char32_t exchange(char32_t __v, memory_order __o = memory_order_seq_cst)
8742 {return atomic_exchange_explicit(this, __v, __o);}
8743 _LIBCPP_INLINE_VISIBILITY
8744 bool compare_exchange_weak(char32_t& __v, char32_t __e, memory_order __s,
8745 memory_order __f) volatile
8746 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8747 __f);}
8748 _LIBCPP_INLINE_VISIBILITY
8749 bool compare_exchange_weak(char32_t& __v, char32_t __e, memory_order __s,
8750 memory_order __f)
8751 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8752 __f);}
8753 _LIBCPP_INLINE_VISIBILITY
8754 bool compare_exchange_strong(char32_t& __v, char32_t __e, memory_order __s,
8755 memory_order __f) volatile
8756 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8757 __f);}
8758 _LIBCPP_INLINE_VISIBILITY
8759 bool compare_exchange_strong(char32_t& __v, char32_t __e, memory_order __s,
8760 memory_order __f)
8761 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8762 __f);}
8763 _LIBCPP_INLINE_VISIBILITY
8764 bool compare_exchange_weak(char32_t& __v, char32_t __e,
8765 memory_order __s = memory_order_seq_cst) volatile
8766 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8767 __translate_memory_order(__s));}
8768 _LIBCPP_INLINE_VISIBILITY
8769 bool compare_exchange_weak(char32_t& __v, char32_t __e,
8770 memory_order __s = memory_order_seq_cst)
8771 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
8772 __translate_memory_order(__s));}
8773 _LIBCPP_INLINE_VISIBILITY
8774 bool compare_exchange_strong(char32_t& __v, char32_t __e,
8775 memory_order __s = memory_order_seq_cst) volatile
8776 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8777 __translate_memory_order(__s));}
8778 _LIBCPP_INLINE_VISIBILITY
8779 bool compare_exchange_strong(char32_t& __v, char32_t __e,
8780 memory_order __s = memory_order_seq_cst)
8781 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
8782 __translate_memory_order(__s));}
8783 _LIBCPP_INLINE_VISIBILITY
8784 char32_t fetch_add(char32_t __v,
8785 memory_order __o = memory_order_seq_cst) volatile
8786 {return atomic_fetch_add_explicit(this, __v, __o);}
8787 _LIBCPP_INLINE_VISIBILITY
8788 char32_t fetch_add(char32_t __v, memory_order __o = memory_order_seq_cst)
8789 {return atomic_fetch_add_explicit(this, __v, __o);}
8790 _LIBCPP_INLINE_VISIBILITY
8791 char32_t fetch_sub(char32_t __v,
8792 memory_order __o = memory_order_seq_cst) volatile
8793 {return atomic_fetch_sub_explicit(this, __v, __o);}
8794 _LIBCPP_INLINE_VISIBILITY
8795 char32_t fetch_sub(char32_t __v, memory_order __o = memory_order_seq_cst)
8796 {return atomic_fetch_sub_explicit(this, __v, __o);}
8797 _LIBCPP_INLINE_VISIBILITY
8798 char32_t fetch_and(char32_t __v,
8799 memory_order __o = memory_order_seq_cst) volatile
8800 {return atomic_fetch_and_explicit(this, __v, __o);}
8801 _LIBCPP_INLINE_VISIBILITY
8802 char32_t fetch_and(char32_t __v, memory_order __o = memory_order_seq_cst)
8803 {return atomic_fetch_and_explicit(this, __v, __o);}
8804 _LIBCPP_INLINE_VISIBILITY
8805 char32_t fetch_or(char32_t __v,
8806 memory_order __o = memory_order_seq_cst) volatile
8807 {return atomic_fetch_or_explicit(this, __v, __o);}
8808 _LIBCPP_INLINE_VISIBILITY
8809 char32_t fetch_or(char32_t __v, memory_order __o = memory_order_seq_cst)
8810 {return atomic_fetch_or_explicit(this, __v, __o);}
8811 _LIBCPP_INLINE_VISIBILITY
8812 char32_t fetch_xor(char32_t __v,
8813 memory_order __o = memory_order_seq_cst) volatile
8814 {return atomic_fetch_xor_explicit(this, __v, __o);}
8815 _LIBCPP_INLINE_VISIBILITY
8816 char32_t fetch_xor(char32_t __v, memory_order __o = memory_order_seq_cst)
8817 {return atomic_fetch_xor_explicit(this, __v, __o);}
8818#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
8819 atomic_char32_t() = default;
8820#else
8821 _LIBCPP_INLINE_VISIBILITY
8822 atomic_char32_t() {}
8823#endif
8824 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00008825 constexpr atomic_char32_t(char32_t __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00008826 : __v_(__v) {}
8827#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
8828 atomic_char32_t(const atomic_char32_t&) = delete;
8829 atomic_char32_t& operator=(const atomic_char32_t&) = delete;
8830 atomic_char32_t& operator=(const atomic_char32_t&) volatile = delete;
8831#else
8832private:
8833 atomic_char32_t(const atomic_char32_t&);
8834 atomic_char32_t& operator=(const atomic_char32_t&);
8835 atomic_char32_t& operator=(const atomic_char32_t&) volatile;
8836public:
8837#endif
8838 _LIBCPP_INLINE_VISIBILITY
8839 char32_t operator=(char32_t __v) volatile
8840 {store(__v); return __v;}
8841 _LIBCPP_INLINE_VISIBILITY
8842 char32_t operator=(char32_t __v)
8843 {store(__v); return __v;}
8844 _LIBCPP_INLINE_VISIBILITY
8845 char32_t operator++(int) volatile
8846 {return fetch_add(char32_t(1));}
8847 _LIBCPP_INLINE_VISIBILITY
8848 char32_t operator++(int)
8849 {return fetch_add(char32_t(1));}
8850 _LIBCPP_INLINE_VISIBILITY
8851 char32_t operator--(int) volatile
8852 {return fetch_sub(char32_t(1));}
8853 _LIBCPP_INLINE_VISIBILITY
8854 char32_t operator--(int)
8855 {return fetch_sub(char32_t(1));}
8856 _LIBCPP_INLINE_VISIBILITY
8857 char32_t operator++() volatile
8858 {return char32_t(fetch_add(char32_t(1)) + 1);}
8859 _LIBCPP_INLINE_VISIBILITY
8860 char32_t operator++()
8861 {return char32_t(fetch_add(char32_t(1)) + 1);}
8862 _LIBCPP_INLINE_VISIBILITY
8863 char32_t operator--() volatile
8864 {return char32_t(fetch_sub(char32_t(1)) - 1);}
8865 _LIBCPP_INLINE_VISIBILITY
8866 char32_t operator--()
8867 {return char32_t(fetch_sub(char32_t(1)) - 1);}
8868 _LIBCPP_INLINE_VISIBILITY
8869 char32_t operator+=(char32_t __v) volatile
8870 {return char32_t(fetch_add(__v) + __v);}
8871 _LIBCPP_INLINE_VISIBILITY
8872 char32_t operator+=(char32_t __v)
8873 {return char32_t(fetch_add(__v) + __v);}
8874 _LIBCPP_INLINE_VISIBILITY
8875 char32_t operator-=(char32_t __v) volatile
8876 {return char32_t(fetch_sub(__v) - __v);}
8877 _LIBCPP_INLINE_VISIBILITY
8878 char32_t operator-=(char32_t __v)
8879 {return char32_t(fetch_sub(__v) - __v);}
8880 _LIBCPP_INLINE_VISIBILITY
8881 char32_t operator&=(char32_t __v) volatile
8882 {return char32_t(fetch_and(__v) & __v);}
8883 _LIBCPP_INLINE_VISIBILITY
8884 char32_t operator&=(char32_t __v)
8885 {return char32_t(fetch_and(__v) & __v);}
8886 _LIBCPP_INLINE_VISIBILITY
8887 char32_t operator|=(char32_t __v) volatile
8888 {return char32_t(fetch_or(__v) | __v);}
8889 _LIBCPP_INLINE_VISIBILITY
8890 char32_t operator|=(char32_t __v)
8891 {return char32_t(fetch_or(__v) | __v);}
8892 _LIBCPP_INLINE_VISIBILITY
8893 char32_t operator^=(char32_t __v) volatile
8894 {return char32_t(fetch_xor(__v) ^ __v);}
8895 _LIBCPP_INLINE_VISIBILITY
8896 char32_t operator^=(char32_t __v)
8897 {return char32_t(fetch_xor(__v) ^ __v);}
8898} atomic_char32_t;
8899
8900inline _LIBCPP_INLINE_VISIBILITY
8901bool
8902atomic_is_lock_free(const volatile atomic_char32_t*)
8903{
8904 typedef char32_t type;
8905 return __atomic_is_lock_free(type);
8906}
8907
8908inline _LIBCPP_INLINE_VISIBILITY
8909bool
8910atomic_is_lock_free(const atomic_char32_t* __obj)
8911{
8912 return atomic_is_lock_free(const_cast<volatile atomic_char32_t*>(__obj));
8913}
8914
8915inline _LIBCPP_INLINE_VISIBILITY
8916void
8917atomic_init(volatile atomic_char32_t* __obj, char32_t __desr)
8918{
8919 __obj->__v_ = __desr;
8920}
8921
8922inline _LIBCPP_INLINE_VISIBILITY
8923void
8924atomic_init(atomic_char32_t* __obj, char32_t __desr)
8925{
8926 __obj->__v_ = __desr;
8927}
8928
8929inline _LIBCPP_INLINE_VISIBILITY
8930void
8931atomic_store(volatile atomic_char32_t* __obj, char32_t __desr)
8932{
8933 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
8934}
8935
8936inline _LIBCPP_INLINE_VISIBILITY
8937void
8938atomic_store(atomic_char32_t* __obj, char32_t __desr)
8939{
8940 atomic_store(const_cast<volatile atomic_char32_t*>(__obj), __desr);
8941}
8942
8943inline _LIBCPP_INLINE_VISIBILITY
8944void
8945atomic_store_explicit(volatile atomic_char32_t* __obj, char32_t __desr,
8946 memory_order __o)
8947{
8948 __atomic_store(&__obj->__v_, __desr, __o);
8949}
8950
8951inline _LIBCPP_INLINE_VISIBILITY
8952void
8953atomic_store_explicit(atomic_char32_t* __obj, char32_t __desr, memory_order __o)
8954{
8955 atomic_store_explicit(const_cast<volatile atomic_char32_t*>(__obj), __desr,
8956 __o);
8957}
8958
8959inline _LIBCPP_INLINE_VISIBILITY
8960char32_t
8961atomic_load(const volatile atomic_char32_t* __obj)
8962{
8963 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
8964}
8965
8966inline _LIBCPP_INLINE_VISIBILITY
8967char32_t
8968atomic_load(const atomic_char32_t* __obj)
8969{
8970 return atomic_load(const_cast<const volatile atomic_char32_t*>(__obj));
8971}
8972
8973inline _LIBCPP_INLINE_VISIBILITY
8974char32_t
8975atomic_load_explicit(const volatile atomic_char32_t* __obj, memory_order __o)
8976{
8977 return __atomic_load(&__obj->__v_, __o);
8978}
8979
8980inline _LIBCPP_INLINE_VISIBILITY
8981char32_t
8982atomic_load_explicit(const atomic_char32_t* __obj, memory_order __o)
8983{
8984 return atomic_load_explicit(const_cast<const volatile atomic_char32_t*>
8985 (__obj), __o);
8986}
8987
8988inline _LIBCPP_INLINE_VISIBILITY
8989char32_t
8990atomic_exchange(volatile atomic_char32_t* __obj, char32_t __desr)
8991{
8992 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
8993}
8994
8995inline _LIBCPP_INLINE_VISIBILITY
8996char32_t
8997atomic_exchange(atomic_char32_t* __obj, char32_t __desr)
8998{
8999 return atomic_exchange(const_cast<volatile atomic_char32_t*>(__obj), __desr);
9000}
9001
9002inline _LIBCPP_INLINE_VISIBILITY
9003char32_t
9004atomic_exchange_explicit(volatile atomic_char32_t* __obj, char32_t __desr,
9005 memory_order __o)
9006{
9007 return __atomic_exchange(&__obj->__v_, __desr, __o);
9008}
9009
9010inline _LIBCPP_INLINE_VISIBILITY
9011char32_t
9012atomic_exchange_explicit(atomic_char32_t* __obj, char32_t __desr,
9013 memory_order __o)
9014{
9015 return atomic_exchange_explicit(const_cast<volatile atomic_char32_t*>
9016 (__obj), __desr, __o);
9017}
9018
9019inline _LIBCPP_INLINE_VISIBILITY
9020bool
9021atomic_compare_exchange_weak(volatile atomic_char32_t* __obj, char32_t* __exp,
9022 char32_t __desr)
9023{
9024 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
9025 memory_order_seq_cst, memory_order_seq_cst);
9026}
9027
9028inline _LIBCPP_INLINE_VISIBILITY
9029bool
9030atomic_compare_exchange_weak(atomic_char32_t* __obj, char32_t* __exp,
9031 char32_t __desr)
9032{
9033 return atomic_compare_exchange_weak(const_cast<volatile atomic_char32_t*>
9034 (__obj), __exp, __desr);
9035}
9036
9037inline _LIBCPP_INLINE_VISIBILITY
9038bool
9039atomic_compare_exchange_strong(volatile atomic_char32_t* __obj, char32_t* __exp,
9040 char32_t __desr)
9041{
9042 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
9043 memory_order_seq_cst, memory_order_seq_cst);
9044}
9045
9046inline _LIBCPP_INLINE_VISIBILITY
9047bool
9048atomic_compare_exchange_strong(atomic_char32_t* __obj, char32_t* __exp,
9049 char32_t __desr)
9050{
9051 return atomic_compare_exchange_strong(const_cast<volatile atomic_char32_t*>
9052 (__obj), __exp, __desr);
9053}
9054
9055inline _LIBCPP_INLINE_VISIBILITY
9056bool
9057atomic_compare_exchange_weak_explicit(volatile atomic_char32_t* __obj,
9058 char32_t* __exp, char32_t __desr,
9059 memory_order __s, memory_order __f)
9060{
9061 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
9062 __f);
9063}
9064
9065inline _LIBCPP_INLINE_VISIBILITY
9066bool
9067atomic_compare_exchange_weak_explicit(atomic_char32_t* __obj, char32_t* __exp,
9068 char32_t __desr, memory_order __s,
9069 memory_order __f)
9070{
9071 return atomic_compare_exchange_weak_explicit(
9072 const_cast<volatile atomic_char32_t*>(__obj), __exp, __desr, __s, __f);
9073}
9074
9075inline _LIBCPP_INLINE_VISIBILITY
9076bool
9077atomic_compare_exchange_strong_explicit(volatile atomic_char32_t* __obj,
9078 char32_t* __exp, char32_t __desr,
9079 memory_order __s, memory_order __f)
9080{
9081 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
9082 __f);
9083}
9084
9085inline _LIBCPP_INLINE_VISIBILITY
9086bool
9087atomic_compare_exchange_strong_explicit(atomic_char32_t* __obj, char32_t* __exp,
9088 char32_t __desr, memory_order __s,
9089 memory_order __f)
9090{
9091 return atomic_compare_exchange_strong_explicit(
9092 const_cast<volatile atomic_char32_t*>(__obj), __exp, __desr, __s, __f);
9093}
9094
9095inline _LIBCPP_INLINE_VISIBILITY
9096char32_t
9097atomic_fetch_add(volatile atomic_char32_t* __obj, char32_t __v)
9098{
9099 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
9100}
9101
9102inline _LIBCPP_INLINE_VISIBILITY
9103char32_t
9104atomic_fetch_add(atomic_char32_t* __obj, char32_t __v)
9105{
9106 return atomic_fetch_add(const_cast<volatile atomic_char32_t*>(__obj), __v);
9107}
9108
9109inline _LIBCPP_INLINE_VISIBILITY
9110char32_t
9111atomic_fetch_add_explicit(volatile atomic_char32_t* __obj, char32_t __v,
9112 memory_order __o)
9113{
9114 return __atomic_fetch_add(&__obj->__v_, __v, __o);
9115}
9116
9117inline _LIBCPP_INLINE_VISIBILITY
9118char32_t
9119atomic_fetch_add_explicit(atomic_char32_t* __obj, char32_t __v,
9120 memory_order __o)
9121{
9122 return atomic_fetch_add_explicit(const_cast<volatile atomic_char32_t*>(__obj),
9123 __v, __o);
9124}
9125
9126inline _LIBCPP_INLINE_VISIBILITY
9127char32_t
9128atomic_fetch_sub(volatile atomic_char32_t* __obj, char32_t __v)
9129{
9130 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
9131}
9132
9133inline _LIBCPP_INLINE_VISIBILITY
9134char32_t
9135atomic_fetch_sub(atomic_char32_t* __obj, char32_t __v)
9136{
9137 return atomic_fetch_sub(const_cast<volatile atomic_char32_t*>(__obj), __v);
9138}
9139
9140inline _LIBCPP_INLINE_VISIBILITY
9141char32_t
9142atomic_fetch_sub_explicit(volatile atomic_char32_t* __obj, char32_t __v,
9143 memory_order __o)
9144{
9145 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
9146}
9147
9148inline _LIBCPP_INLINE_VISIBILITY
9149char32_t
9150atomic_fetch_sub_explicit(atomic_char32_t* __obj, char32_t __v,
9151 memory_order __o)
9152{
9153 return atomic_fetch_sub_explicit(const_cast<volatile atomic_char32_t*>(__obj),
9154 __v, __o);
9155}
9156
9157inline _LIBCPP_INLINE_VISIBILITY
9158char32_t
9159atomic_fetch_and(volatile atomic_char32_t* __obj, char32_t __v)
9160{
9161 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
9162}
9163
9164inline _LIBCPP_INLINE_VISIBILITY
9165char32_t
9166atomic_fetch_and(atomic_char32_t* __obj, char32_t __v)
9167{
9168 return atomic_fetch_and(const_cast<volatile atomic_char32_t*>(__obj), __v);
9169}
9170
9171inline _LIBCPP_INLINE_VISIBILITY
9172char32_t
9173atomic_fetch_and_explicit(volatile atomic_char32_t* __obj, char32_t __v,
9174 memory_order __o)
9175{
9176 return __atomic_fetch_and(&__obj->__v_, __v, __o);
9177}
9178
9179inline _LIBCPP_INLINE_VISIBILITY
9180char32_t
9181atomic_fetch_and_explicit(atomic_char32_t* __obj, char32_t __v,
9182 memory_order __o)
9183{
9184 return atomic_fetch_and_explicit(const_cast<volatile atomic_char32_t*>(__obj),
9185 __v, __o);
9186}
9187
9188inline _LIBCPP_INLINE_VISIBILITY
9189char32_t
9190atomic_fetch_or(volatile atomic_char32_t* __obj, char32_t __v)
9191{
9192 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
9193}
9194
9195inline _LIBCPP_INLINE_VISIBILITY
9196char32_t
9197atomic_fetch_or(atomic_char32_t* __obj, char32_t __v)
9198{
9199 return atomic_fetch_or(const_cast<volatile atomic_char32_t*>(__obj), __v);
9200}
9201
9202inline _LIBCPP_INLINE_VISIBILITY
9203char32_t
9204atomic_fetch_or_explicit(volatile atomic_char32_t* __obj, char32_t __v,
9205 memory_order __o)
9206{
9207 return __atomic_fetch_or(&__obj->__v_, __v, __o);
9208}
9209
9210inline _LIBCPP_INLINE_VISIBILITY
9211char32_t
9212atomic_fetch_or_explicit(atomic_char32_t* __obj, char32_t __v, memory_order __o)
9213{
9214 return atomic_fetch_or_explicit(const_cast<volatile atomic_char32_t*>(__obj),
9215 __v, __o);
9216}
9217
9218inline _LIBCPP_INLINE_VISIBILITY
9219char32_t
9220atomic_fetch_xor(volatile atomic_char32_t* __obj, char32_t __v)
9221{
9222 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
9223}
9224
9225inline _LIBCPP_INLINE_VISIBILITY
9226char32_t
9227atomic_fetch_xor(atomic_char32_t* __obj, char32_t __v)
9228{
9229 return atomic_fetch_xor(const_cast<volatile atomic_char32_t*>(__obj), __v);
9230}
9231
9232inline _LIBCPP_INLINE_VISIBILITY
9233char32_t
9234atomic_fetch_xor_explicit(volatile atomic_char32_t* __obj, char32_t __v,
9235 memory_order __o)
9236{
9237 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
9238}
9239
9240inline _LIBCPP_INLINE_VISIBILITY
9241char32_t
9242atomic_fetch_xor_explicit(atomic_char32_t* __obj, char32_t __v,
9243 memory_order __o)
9244{
9245 return atomic_fetch_xor_explicit(const_cast<volatile atomic_char32_t*>(__obj),
9246 __v, __o);
9247}
9248
9249#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
9250
9251// atomic_wchar_t
9252
9253struct atomic_wchar_t;
9254
9255bool atomic_is_lock_free(const volatile atomic_wchar_t*);
9256bool atomic_is_lock_free(const atomic_wchar_t*);
9257void atomic_init(volatile atomic_wchar_t*, wchar_t);
9258void atomic_init(atomic_wchar_t*, wchar_t);
9259void atomic_store(volatile atomic_wchar_t*, wchar_t);
9260void atomic_store(atomic_wchar_t*, wchar_t);
9261void atomic_store_explicit(volatile atomic_wchar_t*, wchar_t, memory_order);
9262void atomic_store_explicit(atomic_wchar_t*, wchar_t, memory_order);
9263wchar_t atomic_load(const volatile atomic_wchar_t*);
9264wchar_t atomic_load(const atomic_wchar_t*);
9265wchar_t atomic_load_explicit(const volatile atomic_wchar_t*, memory_order);
9266wchar_t atomic_load_explicit(const atomic_wchar_t*, memory_order);
9267wchar_t atomic_exchange(volatile atomic_wchar_t*, wchar_t);
9268wchar_t atomic_exchange(atomic_wchar_t*, wchar_t);
9269wchar_t atomic_exchange_explicit(volatile atomic_wchar_t*, wchar_t,
9270 memory_order);
9271wchar_t atomic_exchange_explicit(atomic_wchar_t*, wchar_t, memory_order);
9272bool atomic_compare_exchange_weak(volatile atomic_wchar_t*, wchar_t*,
9273 wchar_t);
9274bool atomic_compare_exchange_weak(atomic_wchar_t*, wchar_t*, wchar_t);
9275bool atomic_compare_exchange_strong(volatile atomic_wchar_t*, wchar_t*,
9276 wchar_t);
9277bool atomic_compare_exchange_strong(atomic_wchar_t*, wchar_t*, wchar_t);
9278bool atomic_compare_exchange_weak_explicit(volatile atomic_wchar_t*, wchar_t*,
9279 wchar_t, memory_order,
9280 memory_order);
9281bool atomic_compare_exchange_weak_explicit(atomic_wchar_t*, wchar_t*,
9282 wchar_t, memory_order,
9283 memory_order);
9284bool atomic_compare_exchange_strong_explicit(volatile atomic_wchar_t*,
9285 wchar_t*, wchar_t, memory_order,
9286 memory_order);
9287bool atomic_compare_exchange_strong_explicit(atomic_wchar_t*, wchar_t*,
9288 wchar_t, memory_order,
9289 memory_order);
9290wchar_t atomic_fetch_add(volatile atomic_wchar_t*, wchar_t);
9291wchar_t atomic_fetch_add(atomic_wchar_t*, wchar_t);
9292wchar_t atomic_fetch_add_explicit(volatile atomic_wchar_t*, wchar_t,
9293 memory_order);
9294wchar_t atomic_fetch_add_explicit(atomic_wchar_t*, wchar_t, memory_order);
9295wchar_t atomic_fetch_sub(volatile atomic_wchar_t*, wchar_t);
9296wchar_t atomic_fetch_sub(atomic_wchar_t*, wchar_t);
9297wchar_t atomic_fetch_sub_explicit(volatile atomic_wchar_t*, wchar_t,
9298 memory_order);
9299wchar_t atomic_fetch_sub_explicit(atomic_wchar_t*, wchar_t, memory_order);
9300wchar_t atomic_fetch_and(volatile atomic_wchar_t*, wchar_t);
9301wchar_t atomic_fetch_and(atomic_wchar_t*, wchar_t);
9302wchar_t atomic_fetch_and_explicit(volatile atomic_wchar_t*, wchar_t,
9303 memory_order);
9304wchar_t atomic_fetch_and_explicit(atomic_wchar_t*, wchar_t, memory_order);
9305wchar_t atomic_fetch_or(volatile atomic_wchar_t*, wchar_t);
9306wchar_t atomic_fetch_or(atomic_wchar_t*, wchar_t);
9307wchar_t atomic_fetch_or_explicit(volatile atomic_wchar_t*, wchar_t,
9308 memory_order);
9309wchar_t atomic_fetch_or_explicit(atomic_wchar_t*, wchar_t, memory_order);
9310wchar_t atomic_fetch_xor(volatile atomic_wchar_t*, wchar_t);
9311wchar_t atomic_fetch_xor(atomic_wchar_t*, wchar_t);
9312wchar_t atomic_fetch_xor_explicit(volatile atomic_wchar_t*, wchar_t,
9313 memory_order);
9314wchar_t atomic_fetch_xor_explicit(atomic_wchar_t*, wchar_t, memory_order);
9315
9316typedef struct atomic_wchar_t
9317{
9318 wchar_t __v_;
9319
9320 _LIBCPP_INLINE_VISIBILITY
9321 bool is_lock_free() const volatile
9322 {return atomic_is_lock_free(this);}
9323 _LIBCPP_INLINE_VISIBILITY
9324 bool is_lock_free() const
9325 {return atomic_is_lock_free(this);}
9326 _LIBCPP_INLINE_VISIBILITY
9327 void store(wchar_t __v, memory_order __o = memory_order_seq_cst) volatile
9328 {atomic_store_explicit(this, __v, __o);}
9329 _LIBCPP_INLINE_VISIBILITY
9330 void store(wchar_t __v, memory_order __o = memory_order_seq_cst)
9331 {atomic_store_explicit(this, __v, __o);}
9332 _LIBCPP_INLINE_VISIBILITY
9333 wchar_t load(memory_order __o = memory_order_seq_cst) const volatile
9334 {return atomic_load_explicit(this, __o);}
9335 _LIBCPP_INLINE_VISIBILITY
9336 wchar_t load(memory_order __o = memory_order_seq_cst) const
9337 {return atomic_load_explicit(this, __o);}
9338 _LIBCPP_INLINE_VISIBILITY
9339 operator wchar_t() const volatile
9340 {return load();}
9341 _LIBCPP_INLINE_VISIBILITY
9342 operator wchar_t() const
9343 {return load();}
9344 _LIBCPP_INLINE_VISIBILITY
9345 wchar_t exchange(wchar_t __v,
9346 memory_order __o = memory_order_seq_cst) volatile
9347 {return atomic_exchange_explicit(this, __v, __o);}
9348 _LIBCPP_INLINE_VISIBILITY
9349 wchar_t exchange(wchar_t __v, memory_order __o = memory_order_seq_cst)
9350 {return atomic_exchange_explicit(this, __v, __o);}
9351 _LIBCPP_INLINE_VISIBILITY
9352 bool compare_exchange_weak(wchar_t& __v, wchar_t __e, memory_order __s,
9353 memory_order __f) volatile
9354 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9355 __f);}
9356 _LIBCPP_INLINE_VISIBILITY
9357 bool compare_exchange_weak(wchar_t& __v, wchar_t __e, memory_order __s,
9358 memory_order __f)
9359 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9360 __f);}
9361 _LIBCPP_INLINE_VISIBILITY
9362 bool compare_exchange_strong(wchar_t& __v, wchar_t __e, memory_order __s,
9363 memory_order __f) volatile
9364 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9365 __f);}
9366 _LIBCPP_INLINE_VISIBILITY
9367 bool compare_exchange_strong(wchar_t& __v, wchar_t __e, memory_order __s,
9368 memory_order __f)
9369 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9370 __f);}
9371 _LIBCPP_INLINE_VISIBILITY
9372 bool compare_exchange_weak(wchar_t& __v, wchar_t __e,
9373 memory_order __s = memory_order_seq_cst) volatile
9374 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9375 __translate_memory_order(__s));}
9376 _LIBCPP_INLINE_VISIBILITY
9377 bool compare_exchange_weak(wchar_t& __v, wchar_t __e,
9378 memory_order __s = memory_order_seq_cst)
9379 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9380 __translate_memory_order(__s));}
9381 _LIBCPP_INLINE_VISIBILITY
9382 bool compare_exchange_strong(wchar_t& __v, wchar_t __e,
9383 memory_order __s = memory_order_seq_cst) volatile
9384 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9385 __translate_memory_order(__s));}
9386 _LIBCPP_INLINE_VISIBILITY
9387 bool compare_exchange_strong(wchar_t& __v, wchar_t __e,
9388 memory_order __s = memory_order_seq_cst)
9389 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9390 __translate_memory_order(__s));}
9391 _LIBCPP_INLINE_VISIBILITY
9392 wchar_t fetch_add(wchar_t __v,
9393 memory_order __o = memory_order_seq_cst) volatile
9394 {return atomic_fetch_add_explicit(this, __v, __o);}
9395 _LIBCPP_INLINE_VISIBILITY
9396 wchar_t fetch_add(wchar_t __v, memory_order __o = memory_order_seq_cst)
9397 {return atomic_fetch_add_explicit(this, __v, __o);}
9398 _LIBCPP_INLINE_VISIBILITY
9399 wchar_t fetch_sub(wchar_t __v,
9400 memory_order __o = memory_order_seq_cst) volatile
9401 {return atomic_fetch_sub_explicit(this, __v, __o);}
9402 _LIBCPP_INLINE_VISIBILITY
9403 wchar_t fetch_sub(wchar_t __v, memory_order __o = memory_order_seq_cst)
9404 {return atomic_fetch_sub_explicit(this, __v, __o);}
9405 _LIBCPP_INLINE_VISIBILITY
9406 wchar_t fetch_and(wchar_t __v,
9407 memory_order __o = memory_order_seq_cst) volatile
9408 {return atomic_fetch_and_explicit(this, __v, __o);}
9409 _LIBCPP_INLINE_VISIBILITY
9410 wchar_t fetch_and(wchar_t __v, memory_order __o = memory_order_seq_cst)
9411 {return atomic_fetch_and_explicit(this, __v, __o);}
9412 _LIBCPP_INLINE_VISIBILITY
9413 wchar_t fetch_or(wchar_t __v,
9414 memory_order __o = memory_order_seq_cst) volatile
9415 {return atomic_fetch_or_explicit(this, __v, __o);}
9416 _LIBCPP_INLINE_VISIBILITY
9417 wchar_t fetch_or(wchar_t __v, memory_order __o = memory_order_seq_cst)
9418 {return atomic_fetch_or_explicit(this, __v, __o);}
9419 _LIBCPP_INLINE_VISIBILITY
9420 wchar_t fetch_xor(wchar_t __v,
9421 memory_order __o = memory_order_seq_cst) volatile
9422 {return atomic_fetch_xor_explicit(this, __v, __o);}
9423 _LIBCPP_INLINE_VISIBILITY
9424 wchar_t fetch_xor(wchar_t __v, memory_order __o = memory_order_seq_cst)
9425 {return atomic_fetch_xor_explicit(this, __v, __o);}
9426#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
9427 atomic_wchar_t() = default;
9428#else
9429 _LIBCPP_INLINE_VISIBILITY
9430 atomic_wchar_t() {}
9431#endif
9432 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +00009433 constexpr atomic_wchar_t(wchar_t __v)
Howard Hinnant5bbe97d2010-10-19 21:22:10 +00009434 : __v_(__v) {}
9435#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
9436 atomic_wchar_t(const atomic_wchar_t&) = delete;
9437 atomic_wchar_t& operator=(const atomic_wchar_t&) = delete;
9438 atomic_wchar_t& operator=(const atomic_wchar_t&) volatile = delete;
9439#else
9440private:
9441 atomic_wchar_t(const atomic_wchar_t&);
9442 atomic_wchar_t& operator=(const atomic_wchar_t&);
9443 atomic_wchar_t& operator=(const atomic_wchar_t&) volatile;
9444public:
9445#endif
9446 _LIBCPP_INLINE_VISIBILITY
9447 wchar_t operator=(wchar_t __v) volatile
9448 {store(__v); return __v;}
9449 _LIBCPP_INLINE_VISIBILITY
9450 wchar_t operator=(wchar_t __v)
9451 {store(__v); return __v;}
9452 _LIBCPP_INLINE_VISIBILITY
9453 wchar_t operator++(int) volatile
9454 {return fetch_add(wchar_t(1));}
9455 _LIBCPP_INLINE_VISIBILITY
9456 wchar_t operator++(int)
9457 {return fetch_add(wchar_t(1));}
9458 _LIBCPP_INLINE_VISIBILITY
9459 wchar_t operator--(int) volatile
9460 {return fetch_sub(wchar_t(1));}
9461 _LIBCPP_INLINE_VISIBILITY
9462 wchar_t operator--(int)
9463 {return fetch_sub(wchar_t(1));}
9464 _LIBCPP_INLINE_VISIBILITY
9465 wchar_t operator++() volatile
9466 {return wchar_t(fetch_add(wchar_t(1)) + 1);}
9467 _LIBCPP_INLINE_VISIBILITY
9468 wchar_t operator++()
9469 {return wchar_t(fetch_add(wchar_t(1)) + 1);}
9470 _LIBCPP_INLINE_VISIBILITY
9471 wchar_t operator--() volatile
9472 {return wchar_t(fetch_sub(wchar_t(1)) - 1);}
9473 _LIBCPP_INLINE_VISIBILITY
9474 wchar_t operator--()
9475 {return wchar_t(fetch_sub(wchar_t(1)) - 1);}
9476 _LIBCPP_INLINE_VISIBILITY
9477 wchar_t operator+=(wchar_t __v) volatile
9478 {return wchar_t(fetch_add(__v) + __v);}
9479 _LIBCPP_INLINE_VISIBILITY
9480 wchar_t operator+=(wchar_t __v)
9481 {return wchar_t(fetch_add(__v) + __v);}
9482 _LIBCPP_INLINE_VISIBILITY
9483 wchar_t operator-=(wchar_t __v) volatile
9484 {return wchar_t(fetch_sub(__v) - __v);}
9485 _LIBCPP_INLINE_VISIBILITY
9486 wchar_t operator-=(wchar_t __v)
9487 {return wchar_t(fetch_sub(__v) - __v);}
9488 _LIBCPP_INLINE_VISIBILITY
9489 wchar_t operator&=(wchar_t __v) volatile
9490 {return wchar_t(fetch_and(__v) & __v);}
9491 _LIBCPP_INLINE_VISIBILITY
9492 wchar_t operator&=(wchar_t __v)
9493 {return wchar_t(fetch_and(__v) & __v);}
9494 _LIBCPP_INLINE_VISIBILITY
9495 wchar_t operator|=(wchar_t __v) volatile
9496 {return wchar_t(fetch_or(__v) | __v);}
9497 _LIBCPP_INLINE_VISIBILITY
9498 wchar_t operator|=(wchar_t __v)
9499 {return wchar_t(fetch_or(__v) | __v);}
9500 _LIBCPP_INLINE_VISIBILITY
9501 wchar_t operator^=(wchar_t __v) volatile
9502 {return wchar_t(fetch_xor(__v) ^ __v);}
9503 _LIBCPP_INLINE_VISIBILITY
9504 wchar_t operator^=(wchar_t __v)
9505 {return wchar_t(fetch_xor(__v) ^ __v);}
9506} atomic_wchar_t;
9507
9508inline _LIBCPP_INLINE_VISIBILITY
9509bool
9510atomic_is_lock_free(const volatile atomic_wchar_t*)
9511{
9512 typedef wchar_t type;
9513 return __atomic_is_lock_free(type);
9514}
9515
9516inline _LIBCPP_INLINE_VISIBILITY
9517bool
9518atomic_is_lock_free(const atomic_wchar_t* __obj)
9519{
9520 return atomic_is_lock_free(const_cast<volatile atomic_wchar_t*>(__obj));
9521}
9522
9523inline _LIBCPP_INLINE_VISIBILITY
9524void
9525atomic_init(volatile atomic_wchar_t* __obj, wchar_t __desr)
9526{
9527 __obj->__v_ = __desr;
9528}
9529
9530inline _LIBCPP_INLINE_VISIBILITY
9531void
9532atomic_init(atomic_wchar_t* __obj, wchar_t __desr)
9533{
9534 __obj->__v_ = __desr;
9535}
9536
9537inline _LIBCPP_INLINE_VISIBILITY
9538void
9539atomic_store(volatile atomic_wchar_t* __obj, wchar_t __desr)
9540{
9541 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
9542}
9543
9544inline _LIBCPP_INLINE_VISIBILITY
9545void
9546atomic_store(atomic_wchar_t* __obj, wchar_t __desr)
9547{
9548 atomic_store(const_cast<volatile atomic_wchar_t*>(__obj), __desr);
9549}
9550
9551inline _LIBCPP_INLINE_VISIBILITY
9552void
9553atomic_store_explicit(volatile atomic_wchar_t* __obj, wchar_t __desr,
9554 memory_order __o)
9555{
9556 __atomic_store(&__obj->__v_, __desr, __o);
9557}
9558
9559inline _LIBCPP_INLINE_VISIBILITY
9560void
9561atomic_store_explicit(atomic_wchar_t* __obj, wchar_t __desr, memory_order __o)
9562{
9563 atomic_store_explicit(const_cast<volatile atomic_wchar_t*>(__obj), __desr,
9564 __o);
9565}
9566
9567inline _LIBCPP_INLINE_VISIBILITY
9568wchar_t
9569atomic_load(const volatile atomic_wchar_t* __obj)
9570{
9571 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
9572}
9573
9574inline _LIBCPP_INLINE_VISIBILITY
9575wchar_t
9576atomic_load(const atomic_wchar_t* __obj)
9577{
9578 return atomic_load(const_cast<const volatile atomic_wchar_t*>(__obj));
9579}
9580
9581inline _LIBCPP_INLINE_VISIBILITY
9582wchar_t
9583atomic_load_explicit(const volatile atomic_wchar_t* __obj, memory_order __o)
9584{
9585 return __atomic_load(&__obj->__v_, __o);
9586}
9587
9588inline _LIBCPP_INLINE_VISIBILITY
9589wchar_t
9590atomic_load_explicit(const atomic_wchar_t* __obj, memory_order __o)
9591{
9592 return atomic_load_explicit(const_cast<const volatile atomic_wchar_t*>
9593 (__obj), __o);
9594}
9595
9596inline _LIBCPP_INLINE_VISIBILITY
9597wchar_t
9598atomic_exchange(volatile atomic_wchar_t* __obj, wchar_t __desr)
9599{
9600 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
9601}
9602
9603inline _LIBCPP_INLINE_VISIBILITY
9604wchar_t
9605atomic_exchange(atomic_wchar_t* __obj, wchar_t __desr)
9606{
9607 return atomic_exchange(const_cast<volatile atomic_wchar_t*>(__obj), __desr);
9608}
9609
9610inline _LIBCPP_INLINE_VISIBILITY
9611wchar_t
9612atomic_exchange_explicit(volatile atomic_wchar_t* __obj, wchar_t __desr,
9613 memory_order __o)
9614{
9615 return __atomic_exchange(&__obj->__v_, __desr, __o);
9616}
9617
9618inline _LIBCPP_INLINE_VISIBILITY
9619wchar_t
9620atomic_exchange_explicit(atomic_wchar_t* __obj, wchar_t __desr,
9621 memory_order __o)
9622{
9623 return atomic_exchange_explicit(const_cast<volatile atomic_wchar_t*>
9624 (__obj), __desr, __o);
9625}
9626
9627inline _LIBCPP_INLINE_VISIBILITY
9628bool
9629atomic_compare_exchange_weak(volatile atomic_wchar_t* __obj, wchar_t* __exp,
9630 wchar_t __desr)
9631{
9632 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
9633 memory_order_seq_cst, memory_order_seq_cst);
9634}
9635
9636inline _LIBCPP_INLINE_VISIBILITY
9637bool
9638atomic_compare_exchange_weak(atomic_wchar_t* __obj, wchar_t* __exp,
9639 wchar_t __desr)
9640{
9641 return atomic_compare_exchange_weak(const_cast<volatile atomic_wchar_t*>
9642 (__obj), __exp, __desr);
9643}
9644
9645inline _LIBCPP_INLINE_VISIBILITY
9646bool
9647atomic_compare_exchange_strong(volatile atomic_wchar_t* __obj, wchar_t* __exp,
9648 wchar_t __desr)
9649{
9650 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
9651 memory_order_seq_cst, memory_order_seq_cst);
9652}
9653
9654inline _LIBCPP_INLINE_VISIBILITY
9655bool
9656atomic_compare_exchange_strong(atomic_wchar_t* __obj, wchar_t* __exp,
9657 wchar_t __desr)
9658{
9659 return atomic_compare_exchange_strong(const_cast<volatile atomic_wchar_t*>
9660 (__obj), __exp, __desr);
9661}
9662
9663inline _LIBCPP_INLINE_VISIBILITY
9664bool
9665atomic_compare_exchange_weak_explicit(volatile atomic_wchar_t* __obj,
9666 wchar_t* __exp, wchar_t __desr,
9667 memory_order __s, memory_order __f)
9668{
9669 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
9670 __f);
9671}
9672
9673inline _LIBCPP_INLINE_VISIBILITY
9674bool
9675atomic_compare_exchange_weak_explicit(atomic_wchar_t* __obj, wchar_t* __exp,
9676 wchar_t __desr, memory_order __s,
9677 memory_order __f)
9678{
9679 return atomic_compare_exchange_weak_explicit(
9680 const_cast<volatile atomic_wchar_t*>(__obj), __exp, __desr, __s, __f);
9681}
9682
9683inline _LIBCPP_INLINE_VISIBILITY
9684bool
9685atomic_compare_exchange_strong_explicit(volatile atomic_wchar_t* __obj,
9686 wchar_t* __exp, wchar_t __desr,
9687 memory_order __s, memory_order __f)
9688{
9689 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
9690 __f);
9691}
9692
9693inline _LIBCPP_INLINE_VISIBILITY
9694bool
9695atomic_compare_exchange_strong_explicit(atomic_wchar_t* __obj, wchar_t* __exp,
9696 wchar_t __desr, memory_order __s,
9697 memory_order __f)
9698{
9699 return atomic_compare_exchange_strong_explicit(
9700 const_cast<volatile atomic_wchar_t*>(__obj), __exp, __desr, __s, __f);
9701}
9702
9703inline _LIBCPP_INLINE_VISIBILITY
9704wchar_t
9705atomic_fetch_add(volatile atomic_wchar_t* __obj, wchar_t __v)
9706{
9707 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
9708}
9709
9710inline _LIBCPP_INLINE_VISIBILITY
9711wchar_t
9712atomic_fetch_add(atomic_wchar_t* __obj, wchar_t __v)
9713{
9714 return atomic_fetch_add(const_cast<volatile atomic_wchar_t*>(__obj), __v);
9715}
9716
9717inline _LIBCPP_INLINE_VISIBILITY
9718wchar_t
9719atomic_fetch_add_explicit(volatile atomic_wchar_t* __obj, wchar_t __v,
9720 memory_order __o)
9721{
9722 return __atomic_fetch_add(&__obj->__v_, __v, __o);
9723}
9724
9725inline _LIBCPP_INLINE_VISIBILITY
9726wchar_t
9727atomic_fetch_add_explicit(atomic_wchar_t* __obj, wchar_t __v,
9728 memory_order __o)
9729{
9730 return atomic_fetch_add_explicit(const_cast<volatile atomic_wchar_t*>(__obj),
9731 __v, __o);
9732}
9733
9734inline _LIBCPP_INLINE_VISIBILITY
9735wchar_t
9736atomic_fetch_sub(volatile atomic_wchar_t* __obj, wchar_t __v)
9737{
9738 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
9739}
9740
9741inline _LIBCPP_INLINE_VISIBILITY
9742wchar_t
9743atomic_fetch_sub(atomic_wchar_t* __obj, wchar_t __v)
9744{
9745 return atomic_fetch_sub(const_cast<volatile atomic_wchar_t*>(__obj), __v);
9746}
9747
9748inline _LIBCPP_INLINE_VISIBILITY
9749wchar_t
9750atomic_fetch_sub_explicit(volatile atomic_wchar_t* __obj, wchar_t __v,
9751 memory_order __o)
9752{
9753 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
9754}
9755
9756inline _LIBCPP_INLINE_VISIBILITY
9757wchar_t
9758atomic_fetch_sub_explicit(atomic_wchar_t* __obj, wchar_t __v,
9759 memory_order __o)
9760{
9761 return atomic_fetch_sub_explicit(const_cast<volatile atomic_wchar_t*>(__obj),
9762 __v, __o);
9763}
9764
9765inline _LIBCPP_INLINE_VISIBILITY
9766wchar_t
9767atomic_fetch_and(volatile atomic_wchar_t* __obj, wchar_t __v)
9768{
9769 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
9770}
9771
9772inline _LIBCPP_INLINE_VISIBILITY
9773wchar_t
9774atomic_fetch_and(atomic_wchar_t* __obj, wchar_t __v)
9775{
9776 return atomic_fetch_and(const_cast<volatile atomic_wchar_t*>(__obj), __v);
9777}
9778
9779inline _LIBCPP_INLINE_VISIBILITY
9780wchar_t
9781atomic_fetch_and_explicit(volatile atomic_wchar_t* __obj, wchar_t __v,
9782 memory_order __o)
9783{
9784 return __atomic_fetch_and(&__obj->__v_, __v, __o);
9785}
9786
9787inline _LIBCPP_INLINE_VISIBILITY
9788wchar_t
9789atomic_fetch_and_explicit(atomic_wchar_t* __obj, wchar_t __v,
9790 memory_order __o)
9791{
9792 return atomic_fetch_and_explicit(const_cast<volatile atomic_wchar_t*>(__obj),
9793 __v, __o);
9794}
9795
9796inline _LIBCPP_INLINE_VISIBILITY
9797wchar_t
9798atomic_fetch_or(volatile atomic_wchar_t* __obj, wchar_t __v)
9799{
9800 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
9801}
9802
9803inline _LIBCPP_INLINE_VISIBILITY
9804wchar_t
9805atomic_fetch_or(atomic_wchar_t* __obj, wchar_t __v)
9806{
9807 return atomic_fetch_or(const_cast<volatile atomic_wchar_t*>(__obj), __v);
9808}
9809
9810inline _LIBCPP_INLINE_VISIBILITY
9811wchar_t
9812atomic_fetch_or_explicit(volatile atomic_wchar_t* __obj, wchar_t __v,
9813 memory_order __o)
9814{
9815 return __atomic_fetch_or(&__obj->__v_, __v, __o);
9816}
9817
9818inline _LIBCPP_INLINE_VISIBILITY
9819wchar_t
9820atomic_fetch_or_explicit(atomic_wchar_t* __obj, wchar_t __v, memory_order __o)
9821{
9822 return atomic_fetch_or_explicit(const_cast<volatile atomic_wchar_t*>(__obj),
9823 __v, __o);
9824}
9825
9826inline _LIBCPP_INLINE_VISIBILITY
9827wchar_t
9828atomic_fetch_xor(volatile atomic_wchar_t* __obj, wchar_t __v)
9829{
9830 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
9831}
9832
9833inline _LIBCPP_INLINE_VISIBILITY
9834wchar_t
9835atomic_fetch_xor(atomic_wchar_t* __obj, wchar_t __v)
9836{
9837 return atomic_fetch_xor(const_cast<volatile atomic_wchar_t*>(__obj), __v);
9838}
9839
9840inline _LIBCPP_INLINE_VISIBILITY
9841wchar_t
9842atomic_fetch_xor_explicit(volatile atomic_wchar_t* __obj, wchar_t __v,
9843 memory_order __o)
9844{
9845 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
9846}
9847
9848inline _LIBCPP_INLINE_VISIBILITY
9849wchar_t
9850atomic_fetch_xor_explicit(atomic_wchar_t* __obj, wchar_t __v,
9851 memory_order __o)
9852{
9853 return atomic_fetch_xor_explicit(const_cast<volatile atomic_wchar_t*>(__obj),
9854 __v, __o);
9855}
9856
Howard Hinnantbce9c312010-10-21 17:44:19 +00009857// atomic_address
9858
9859struct atomic_address;
9860
9861bool atomic_is_lock_free(const volatile atomic_address*);
9862bool atomic_is_lock_free(const atomic_address*);
9863void atomic_init(volatile atomic_address*, void*);
9864void atomic_init(atomic_address*, void*);
9865void atomic_store(volatile atomic_address*, void*);
9866void atomic_store(atomic_address*, void*);
9867void atomic_store_explicit(volatile atomic_address*, void*, memory_order);
9868void atomic_store_explicit(atomic_address*, void*, memory_order);
9869void* atomic_load(const volatile atomic_address*);
9870void* atomic_load(const atomic_address*);
9871void* atomic_load_explicit(const volatile atomic_address*, memory_order);
9872void* atomic_load_explicit(const atomic_address*, memory_order);
9873void* atomic_exchange(volatile atomic_address*, void*);
9874void* atomic_exchange(atomic_address*, void*);
9875void* atomic_exchange_explicit(volatile atomic_address*, void*, memory_order);
9876void* atomic_exchange_explicit(atomic_address*, void*, memory_order);
9877bool atomic_compare_exchange_weak(volatile atomic_address*, void**, void*);
9878bool atomic_compare_exchange_weak(atomic_address*, void**, void*);
9879bool atomic_compare_exchange_strong(volatile atomic_address*, void**, void*);
9880bool atomic_compare_exchange_strong(atomic_address*, void**, void*);
9881bool atomic_compare_exchange_weak_explicit(volatile atomic_address*, void**,
9882 void*, memory_order, memory_order);
9883bool atomic_compare_exchange_weak_explicit(atomic_address*, void**,
9884 void*, memory_order, memory_order);
9885bool atomic_compare_exchange_strong_explicit(volatile atomic_address*, void**,
9886 void*, memory_order, memory_order);
9887bool atomic_compare_exchange_strong_explicit(atomic_address*, void**,
9888 void*, memory_order, memory_order);
9889void* atomic_fetch_add(volatile atomic_address*, ptrdiff_t);
9890void* atomic_fetch_add(atomic_address*, ptrdiff_t);
9891void* atomic_fetch_add_explicit(volatile atomic_address*, ptrdiff_t,
9892 memory_order);
9893void* atomic_fetch_add_explicit(atomic_address*, ptrdiff_t, memory_order);
9894void* atomic_fetch_sub(volatile atomic_address*, ptrdiff_t);
9895void* atomic_fetch_sub(atomic_address*, ptrdiff_t);
9896void* atomic_fetch_sub_explicit(volatile atomic_address*, ptrdiff_t,
9897 memory_order);
9898void* atomic_fetch_sub_explicit(atomic_address*, ptrdiff_t, memory_order);
9899
9900typedef struct atomic_address
9901{
9902 void* __v_;
9903
9904 _LIBCPP_INLINE_VISIBILITY
9905 bool is_lock_free() const volatile
9906 {return atomic_is_lock_free(this);}
9907 _LIBCPP_INLINE_VISIBILITY
9908 bool is_lock_free() const
9909 {return atomic_is_lock_free(this);}
9910 _LIBCPP_INLINE_VISIBILITY
9911 void store(void* __v, memory_order __o = memory_order_seq_cst) volatile
9912 {atomic_store_explicit(this, __v, __o);}
9913 _LIBCPP_INLINE_VISIBILITY
9914 void store(void* __v, memory_order __o = memory_order_seq_cst)
9915 {atomic_store_explicit(this, __v, __o);}
9916 _LIBCPP_INLINE_VISIBILITY
9917 void* load(memory_order __o = memory_order_seq_cst) const volatile
9918 {return atomic_load_explicit(this, __o);}
9919 _LIBCPP_INLINE_VISIBILITY
9920 void* load(memory_order __o = memory_order_seq_cst) const
9921 {return atomic_load_explicit(this, __o);}
9922 _LIBCPP_INLINE_VISIBILITY
9923 operator void*() const volatile
9924 {return load();}
9925 _LIBCPP_INLINE_VISIBILITY
9926 operator void*() const
9927 {return load();}
9928 _LIBCPP_INLINE_VISIBILITY
9929 void* exchange(void* __v, memory_order __o = memory_order_seq_cst) volatile
9930 {return atomic_exchange_explicit(this, __v, __o);}
9931 _LIBCPP_INLINE_VISIBILITY
9932 void* exchange(void* __v, memory_order __o = memory_order_seq_cst)
9933 {return atomic_exchange_explicit(this, __v, __o);}
9934 _LIBCPP_INLINE_VISIBILITY
9935 bool compare_exchange_weak(void*& __v, void* __e, memory_order __s,
9936 memory_order __f) volatile
9937 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9938 __f);}
9939 _LIBCPP_INLINE_VISIBILITY
9940 bool compare_exchange_weak(void*& __v, void* __e, memory_order __s,
9941 memory_order __f)
9942 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9943 __f);}
9944 _LIBCPP_INLINE_VISIBILITY
9945 bool compare_exchange_strong(void*& __v, void* __e, memory_order __s,
9946 memory_order __f) volatile
9947 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9948 __f);}
9949 _LIBCPP_INLINE_VISIBILITY
9950 bool compare_exchange_strong(void*& __v, void* __e, memory_order __s,
9951 memory_order __f)
9952 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9953 __f);}
9954 _LIBCPP_INLINE_VISIBILITY
9955 bool compare_exchange_weak(void*& __v, void* __e,
9956 memory_order __s = memory_order_seq_cst) volatile
9957 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9958 __translate_memory_order(__s));}
9959 _LIBCPP_INLINE_VISIBILITY
9960 bool compare_exchange_weak(void*& __v, void* __e,
9961 memory_order __s = memory_order_seq_cst)
9962 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
9963 __translate_memory_order(__s));}
9964 _LIBCPP_INLINE_VISIBILITY
9965 bool compare_exchange_strong(void*& __v, void* __e,
9966 memory_order __s = memory_order_seq_cst) volatile
9967 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9968 __translate_memory_order(__s));}
9969 _LIBCPP_INLINE_VISIBILITY
9970 bool compare_exchange_strong(void*& __v, void* __e,
9971 memory_order __s = memory_order_seq_cst)
9972 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
9973 __translate_memory_order(__s));}
9974 _LIBCPP_INLINE_VISIBILITY
9975 bool compare_exchange_weak(const void*& __v, const void* __e,
9976 memory_order __s, memory_order __f) volatile
9977 {return atomic_compare_exchange_weak_explicit(this,
9978 &const_cast<void*&>(__v), const_cast<void*>(__e), __s, __f);}
9979 _LIBCPP_INLINE_VISIBILITY
9980 bool compare_exchange_weak(const void*& __v, const void* __e,
9981 memory_order __s, memory_order __f)
9982 {return atomic_compare_exchange_weak_explicit(this,
9983 &const_cast<void*&>(__v), const_cast<void*>(__e), __s, __f);}
9984 _LIBCPP_INLINE_VISIBILITY
9985 bool compare_exchange_strong(const void*& __v, const void* __e,
9986 memory_order __s, memory_order __f) volatile
9987 {return atomic_compare_exchange_strong_explicit(this,
9988 &const_cast<void*&>(__v), const_cast<void*>(__e), __s, __f);}
9989 _LIBCPP_INLINE_VISIBILITY
9990 bool compare_exchange_strong(const void*& __v, const void* __e,
9991 memory_order __s, memory_order __f)
9992 {return atomic_compare_exchange_strong_explicit(this,
9993 &const_cast<void*&>(__v), const_cast<void*>(__e), __s, __f);}
9994 _LIBCPP_INLINE_VISIBILITY
9995 bool compare_exchange_weak(const void*& __v, const void* __e,
9996 memory_order __s = memory_order_seq_cst) volatile
9997 {return atomic_compare_exchange_weak_explicit(this,
9998 &const_cast<void*&>(__v), const_cast<void*>(__e),
9999 __s, __translate_memory_order(__s));}
10000 _LIBCPP_INLINE_VISIBILITY
10001 bool compare_exchange_weak(const void*& __v, const void* __e,
10002 memory_order __s = memory_order_seq_cst)
10003 {return atomic_compare_exchange_weak_explicit(this,
10004 &const_cast<void*&>(__v), const_cast<void*>(__e),
10005 __s, __translate_memory_order(__s));}
10006 _LIBCPP_INLINE_VISIBILITY
10007 bool compare_exchange_strong(const void*& __v, const void* __e,
10008 memory_order __s = memory_order_seq_cst) volatile
10009 {return atomic_compare_exchange_strong_explicit(this,
10010 &const_cast<void*&>(__v), const_cast<void*>(__e),
10011 __s, __translate_memory_order(__s));}
10012 _LIBCPP_INLINE_VISIBILITY
10013 bool compare_exchange_strong(const void*& __v, const void* __e,
10014 memory_order __s = memory_order_seq_cst)
10015 {return atomic_compare_exchange_strong_explicit(this,
10016 &const_cast<void*&>(__v), const_cast<void*>(__e),
10017 __s, __translate_memory_order(__s));}
10018 _LIBCPP_INLINE_VISIBILITY
10019 void* fetch_add(ptrdiff_t __v,
10020 memory_order __o = memory_order_seq_cst) volatile
10021 {return atomic_fetch_add_explicit(this, __v, __o);}
10022 _LIBCPP_INLINE_VISIBILITY
10023 void* fetch_add(ptrdiff_t __v, memory_order __o = memory_order_seq_cst)
10024 {return atomic_fetch_add_explicit(this, __v, __o);}
10025 _LIBCPP_INLINE_VISIBILITY
10026 void* fetch_sub(ptrdiff_t __v,
10027 memory_order __o = memory_order_seq_cst) volatile
10028 {return atomic_fetch_sub_explicit(this, __v, __o);}
10029 _LIBCPP_INLINE_VISIBILITY
10030 void* fetch_sub(ptrdiff_t __v, memory_order __o = memory_order_seq_cst)
10031 {return atomic_fetch_sub_explicit(this, __v, __o);}
10032#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
10033 atomic_address() = default;
10034#else
10035 _LIBCPP_INLINE_VISIBILITY
10036 atomic_address() {}
10037#endif
10038 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4777bf22010-12-06 23:10:08 +000010039 constexpr atomic_address(void* __v)
Howard Hinnantbce9c312010-10-21 17:44:19 +000010040 : __v_(__v) {}
10041#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
10042 atomic_address(const atomic_address&) = delete;
10043 atomic_address& operator=(const atomic_address&) = delete;
10044 atomic_address& operator=(const atomic_address&) volatile = delete;
10045#else
10046private:
10047 atomic_address(const atomic_address&);
10048 atomic_address& operator=(const atomic_address&);
10049 atomic_address& operator=(const atomic_address&) volatile;
10050public:
10051#endif
10052 _LIBCPP_INLINE_VISIBILITY
10053 void* operator=(const void* __v) volatile
10054 {store(const_cast<void*>(__v)); return const_cast<void*>(__v);}
10055 _LIBCPP_INLINE_VISIBILITY
10056 void* operator=(const void* __v)
10057 {store(const_cast<void*>(__v)); return const_cast<void*>(__v);}
10058 _LIBCPP_INLINE_VISIBILITY
10059 void* operator+=(ptrdiff_t __v) volatile
10060 {return static_cast<char*>(fetch_add(__v)) + __v;}
10061 _LIBCPP_INLINE_VISIBILITY
10062 void* operator+=(ptrdiff_t __v)
10063 {return static_cast<char*>(fetch_add(__v)) + __v;}
10064 _LIBCPP_INLINE_VISIBILITY
10065 void* operator-=(ptrdiff_t __v) volatile
10066 {return static_cast<char*>(fetch_sub(__v)) - __v;}
10067 _LIBCPP_INLINE_VISIBILITY
10068 void* operator-=(ptrdiff_t __v)
10069 {return static_cast<char*>(fetch_sub(__v)) - __v;}
10070} atomic_address;
10071
10072inline _LIBCPP_INLINE_VISIBILITY
10073bool
10074atomic_is_lock_free(const volatile atomic_address*)
10075{
10076 typedef void* type;
10077 return __atomic_is_lock_free(type);
10078}
10079
10080inline _LIBCPP_INLINE_VISIBILITY
10081bool
10082atomic_is_lock_free(const atomic_address* __obj)
10083{
10084 return atomic_is_lock_free(const_cast<volatile atomic_address*>(__obj));
10085}
10086
10087inline _LIBCPP_INLINE_VISIBILITY
10088void
10089atomic_init(volatile atomic_address* __obj, void* __desr)
10090{
10091 __obj->__v_ = __desr;
10092}
10093
10094inline _LIBCPP_INLINE_VISIBILITY
10095void
10096atomic_init(atomic_address* __obj, void* __desr)
10097{
10098 __obj->__v_ = __desr;
10099}
10100
10101inline _LIBCPP_INLINE_VISIBILITY
10102void
10103atomic_store(volatile atomic_address* __obj, void* __desr)
10104{
10105 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
10106}
10107
10108inline _LIBCPP_INLINE_VISIBILITY
10109void
10110atomic_store(atomic_address* __obj, void* __desr)
10111{
10112 atomic_store(const_cast<volatile atomic_address*>(__obj), __desr);
10113}
10114
10115inline _LIBCPP_INLINE_VISIBILITY
10116void
10117atomic_store_explicit(volatile atomic_address* __obj, void* __desr,
10118 memory_order __o)
10119{
10120 __atomic_store(&__obj->__v_, __desr, __o);
10121}
10122
10123inline _LIBCPP_INLINE_VISIBILITY
10124void
10125atomic_store_explicit(atomic_address* __obj, void* __desr, memory_order __o)
10126{
10127 atomic_store_explicit(const_cast<volatile atomic_address*>(__obj), __desr,
10128 __o);
10129}
10130
10131inline _LIBCPP_INLINE_VISIBILITY
10132void*
10133atomic_load(const volatile atomic_address* __obj)
10134{
10135 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
10136}
10137
10138inline _LIBCPP_INLINE_VISIBILITY
10139void*
10140atomic_load(const atomic_address* __obj)
10141{
10142 return atomic_load(const_cast<const volatile atomic_address*>(__obj));
10143}
10144
10145inline _LIBCPP_INLINE_VISIBILITY
10146void*
10147atomic_load_explicit(const volatile atomic_address* __obj, memory_order __o)
10148{
10149 return __atomic_load(&__obj->__v_, __o);
10150}
10151
10152inline _LIBCPP_INLINE_VISIBILITY
10153void*
10154atomic_load_explicit(const atomic_address* __obj, memory_order __o)
10155{
10156 return atomic_load_explicit(const_cast<const volatile atomic_address*>
10157 (__obj), __o);
10158}
10159
10160inline _LIBCPP_INLINE_VISIBILITY
10161void*
10162atomic_exchange(volatile atomic_address* __obj, void* __desr)
10163{
10164 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
10165}
10166
10167inline _LIBCPP_INLINE_VISIBILITY
10168void*
10169atomic_exchange(atomic_address* __obj, void* __desr)
10170{
10171 return atomic_exchange(const_cast<volatile atomic_address*>(__obj), __desr);
10172}
10173
10174inline _LIBCPP_INLINE_VISIBILITY
10175void*
10176atomic_exchange_explicit(volatile atomic_address* __obj, void* __desr,
10177 memory_order __o)
10178{
10179 return __atomic_exchange(&__obj->__v_, __desr, __o);
10180}
10181
10182inline _LIBCPP_INLINE_VISIBILITY
10183void*
10184atomic_exchange_explicit(atomic_address* __obj, void* __desr, memory_order __o)
10185{
10186 return atomic_exchange_explicit(const_cast<volatile atomic_address*>
10187 (__obj), __desr, __o);
10188}
10189
10190inline _LIBCPP_INLINE_VISIBILITY
10191bool
10192atomic_compare_exchange_weak(volatile atomic_address* __obj, void** __exp,
10193 void* __desr)
10194{
10195 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
10196 memory_order_seq_cst, memory_order_seq_cst);
10197}
10198
10199inline _LIBCPP_INLINE_VISIBILITY
10200bool
10201atomic_compare_exchange_weak(atomic_address* __obj, void** __exp, void* __desr)
10202{
10203 return atomic_compare_exchange_weak(const_cast<volatile atomic_address*>
10204 (__obj), __exp, __desr);
10205}
10206
10207inline _LIBCPP_INLINE_VISIBILITY
10208bool
10209atomic_compare_exchange_strong(volatile atomic_address* __obj, void** __exp,
10210 void* __desr)
10211{
10212 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
10213 memory_order_seq_cst, memory_order_seq_cst);
10214}
10215
10216inline _LIBCPP_INLINE_VISIBILITY
10217bool
10218atomic_compare_exchange_strong(atomic_address* __obj, void** __exp,
10219 void* __desr)
10220{
10221 return atomic_compare_exchange_strong(const_cast<volatile atomic_address*>
10222 (__obj), __exp, __desr);
10223}
10224
10225inline _LIBCPP_INLINE_VISIBILITY
10226bool
10227atomic_compare_exchange_weak_explicit(volatile atomic_address* __obj,
10228 void** __exp, void* __desr,
10229 memory_order __s, memory_order __f)
10230{
10231 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
10232 __f);
10233}
10234
10235inline _LIBCPP_INLINE_VISIBILITY
10236bool
10237atomic_compare_exchange_weak_explicit(atomic_address* __obj, void** __exp,
10238 void* __desr, memory_order __s,
10239 memory_order __f)
10240{
10241 return atomic_compare_exchange_weak_explicit(
10242 const_cast<volatile atomic_address*>(__obj), __exp, __desr, __s, __f);
10243}
10244
10245inline _LIBCPP_INLINE_VISIBILITY
10246bool
10247atomic_compare_exchange_strong_explicit(volatile atomic_address* __obj,
10248 void** __exp, void* __desr,
10249 memory_order __s, memory_order __f)
10250{
10251 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
10252 __f);
10253}
10254
10255inline _LIBCPP_INLINE_VISIBILITY
10256bool
10257atomic_compare_exchange_strong_explicit(atomic_address* __obj, void** __exp,
10258 void* __desr, memory_order __s,
10259 memory_order __f)
10260{
10261 return atomic_compare_exchange_strong_explicit(
10262 const_cast<volatile atomic_address*>(__obj), __exp, __desr, __s, __f);
10263}
10264
10265inline _LIBCPP_INLINE_VISIBILITY
10266void*
10267atomic_fetch_add(volatile atomic_address* __obj, ptrdiff_t __v)
10268{
10269 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
10270}
10271
10272inline _LIBCPP_INLINE_VISIBILITY
10273void*
10274atomic_fetch_add(atomic_address* __obj, ptrdiff_t __v)
10275{
10276 return atomic_fetch_add(const_cast<volatile atomic_address*>(__obj), __v);
10277}
10278
10279inline _LIBCPP_INLINE_VISIBILITY
10280void*
10281atomic_fetch_add_explicit(volatile atomic_address* __obj, ptrdiff_t __v,
10282 memory_order __o)
10283{
10284 return __atomic_fetch_add(&__obj->__v_, __v, __o);
10285}
10286
10287inline _LIBCPP_INLINE_VISIBILITY
10288void*
10289atomic_fetch_add_explicit(atomic_address* __obj, ptrdiff_t __v,
10290 memory_order __o)
10291{
10292 return atomic_fetch_add_explicit(const_cast<volatile atomic_address*>(__obj),
10293 __v, __o);
10294}
10295
10296inline _LIBCPP_INLINE_VISIBILITY
10297void*
10298atomic_fetch_sub(volatile atomic_address* __obj, ptrdiff_t __v)
10299{
10300 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
10301}
10302
10303inline _LIBCPP_INLINE_VISIBILITY
10304void*
10305atomic_fetch_sub(atomic_address* __obj, ptrdiff_t __v)
10306{
10307 return atomic_fetch_sub(const_cast<volatile atomic_address*>(__obj), __v);
10308}
10309
10310inline _LIBCPP_INLINE_VISIBILITY
10311void*
10312atomic_fetch_sub_explicit(volatile atomic_address* __obj, ptrdiff_t __v,
10313 memory_order __o)
10314{
10315 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
10316}
10317
10318inline _LIBCPP_INLINE_VISIBILITY
10319void*
10320atomic_fetch_sub_explicit(atomic_address* __obj, ptrdiff_t __v,
10321 memory_order __o)
10322{
10323 return atomic_fetch_sub_explicit(const_cast<volatile atomic_address*>(__obj),
10324 __v, __o);
10325}
Howard Hinnant4777bf22010-12-06 23:10:08 +000010326*/
Howard Hinnant8f73c632010-09-27 21:17:38 +000010327_LIBCPP_END_NAMESPACE_STD
10328
10329#endif // _LIBCPP_ATOMIC