2
//===--------------------------- atomic -----------------------------------===//
4
// The LLVM Compiler Infrastructure
6
// This file is distributed under the University of Illinois Open Source
7
// License. See LICENSE.TXT for details.
9
//===----------------------------------------------------------------------===//
11
#ifndef _LIBCPP_ATOMIC
12
#define _LIBCPP_ATOMIC
20
// order and consistency
22
typedef enum memory_order
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
32
template <class T> T kill_dependency(T y) noexcept;
36
#define ATOMIC_BOOL_LOCK_FREE unspecified
37
#define ATOMIC_CHAR_LOCK_FREE unspecified
38
#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
39
#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
40
#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
41
#define ATOMIC_SHORT_LOCK_FREE unspecified
42
#define ATOMIC_INT_LOCK_FREE unspecified
43
#define ATOMIC_LONG_LOCK_FREE unspecified
44
#define ATOMIC_LLONG_LOCK_FREE unspecified
45
#define ATOMIC_POINTER_LOCK_FREE unspecified
47
// flag type and operations
49
typedef struct atomic_flag
51
bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
52
bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
53
void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
54
void clear(memory_order m = memory_order_seq_cst) noexcept;
55
atomic_flag() noexcept = default;
56
atomic_flag(const atomic_flag&) = delete;
57
atomic_flag& operator=(const atomic_flag&) = delete;
58
atomic_flag& operator=(const atomic_flag&) volatile = delete;
62
atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
65
atomic_flag_test_and_set(atomic_flag* obj) noexcept;
68
atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
69
memory_order m) noexcept;
72
atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
75
atomic_flag_clear(volatile atomic_flag* obj) noexcept;
78
atomic_flag_clear(atomic_flag* obj) noexcept;
81
atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
84
atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
86
#define ATOMIC_FLAG_INIT see below
87
#define ATOMIC_VAR_INIT(value) see below
92
bool is_lock_free() const volatile noexcept;
93
bool is_lock_free() const noexcept;
94
void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
95
void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
96
T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
97
T load(memory_order m = memory_order_seq_cst) const noexcept;
98
operator T() const volatile noexcept;
99
operator T() const noexcept;
100
T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
101
T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
102
bool compare_exchange_weak(T& expc, T desr,
103
memory_order s, memory_order f) volatile noexcept;
104
bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
105
bool compare_exchange_strong(T& expc, T desr,
106
memory_order s, memory_order f) volatile noexcept;
107
bool compare_exchange_strong(T& expc, T desr,
108
memory_order s, memory_order f) noexcept;
109
bool compare_exchange_weak(T& expc, T desr,
110
memory_order m = memory_order_seq_cst) volatile noexcept;
111
bool compare_exchange_weak(T& expc, T desr,
112
memory_order m = memory_order_seq_cst) noexcept;
113
bool compare_exchange_strong(T& expc, T desr,
114
memory_order m = memory_order_seq_cst) volatile noexcept;
115
bool compare_exchange_strong(T& expc, T desr,
116
memory_order m = memory_order_seq_cst) noexcept;
118
atomic() noexcept = default;
119
constexpr atomic(T desr) noexcept;
120
atomic(const atomic&) = delete;
121
atomic& operator=(const atomic&) = delete;
122
atomic& operator=(const atomic&) volatile = delete;
123
T operator=(T) volatile noexcept;
124
T operator=(T) noexcept;
128
struct atomic<integral>
130
bool is_lock_free() const volatile noexcept;
131
bool is_lock_free() const noexcept;
132
void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
133
void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
134
integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
135
integral load(memory_order m = memory_order_seq_cst) const noexcept;
136
operator integral() const volatile noexcept;
137
operator integral() const noexcept;
138
integral exchange(integral desr,
139
memory_order m = memory_order_seq_cst) volatile noexcept;
140
integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
141
bool compare_exchange_weak(integral& expc, integral desr,
142
memory_order s, memory_order f) volatile noexcept;
143
bool compare_exchange_weak(integral& expc, integral desr,
144
memory_order s, memory_order f) noexcept;
145
bool compare_exchange_strong(integral& expc, integral desr,
146
memory_order s, memory_order f) volatile noexcept;
147
bool compare_exchange_strong(integral& expc, integral desr,
148
memory_order s, memory_order f) noexcept;
149
bool compare_exchange_weak(integral& expc, integral desr,
150
memory_order m = memory_order_seq_cst) volatile noexcept;
151
bool compare_exchange_weak(integral& expc, integral desr,
152
memory_order m = memory_order_seq_cst) noexcept;
153
bool compare_exchange_strong(integral& expc, integral desr,
154
memory_order m = memory_order_seq_cst) volatile noexcept;
155
bool compare_exchange_strong(integral& expc, integral desr,
156
memory_order m = memory_order_seq_cst) noexcept;
159
fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
160
integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
162
fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
163
integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
165
fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
166
integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
168
fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
169
integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
171
fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
172
integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
174
atomic() noexcept = default;
175
constexpr atomic(integral desr) noexcept;
176
atomic(const atomic&) = delete;
177
atomic& operator=(const atomic&) = delete;
178
atomic& operator=(const atomic&) volatile = delete;
179
integral operator=(integral desr) volatile noexcept;
180
integral operator=(integral desr) noexcept;
182
integral operator++(int) volatile noexcept;
183
integral operator++(int) noexcept;
184
integral operator--(int) volatile noexcept;
185
integral operator--(int) noexcept;
186
integral operator++() volatile noexcept;
187
integral operator++() noexcept;
188
integral operator--() volatile noexcept;
189
integral operator--() noexcept;
190
integral operator+=(integral op) volatile noexcept;
191
integral operator+=(integral op) noexcept;
192
integral operator-=(integral op) volatile noexcept;
193
integral operator-=(integral op) noexcept;
194
integral operator&=(integral op) volatile noexcept;
195
integral operator&=(integral op) noexcept;
196
integral operator|=(integral op) volatile noexcept;
197
integral operator|=(integral op) noexcept;
198
integral operator^=(integral op) volatile noexcept;
199
integral operator^=(integral op) noexcept;
205
bool is_lock_free() const volatile noexcept;
206
bool is_lock_free() const noexcept;
207
void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
208
void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
209
T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
210
T* load(memory_order m = memory_order_seq_cst) const noexcept;
211
operator T*() const volatile noexcept;
212
operator T*() const noexcept;
213
T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
214
T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
215
bool compare_exchange_weak(T*& expc, T* desr,
216
memory_order s, memory_order f) volatile noexcept;
217
bool compare_exchange_weak(T*& expc, T* desr,
218
memory_order s, memory_order f) noexcept;
219
bool compare_exchange_strong(T*& expc, T* desr,
220
memory_order s, memory_order f) volatile noexcept;
221
bool compare_exchange_strong(T*& expc, T* desr,
222
memory_order s, memory_order f) noexcept;
223
bool compare_exchange_weak(T*& expc, T* desr,
224
memory_order m = memory_order_seq_cst) volatile noexcept;
225
bool compare_exchange_weak(T*& expc, T* desr,
226
memory_order m = memory_order_seq_cst) noexcept;
227
bool compare_exchange_strong(T*& expc, T* desr,
228
memory_order m = memory_order_seq_cst) volatile noexcept;
229
bool compare_exchange_strong(T*& expc, T* desr,
230
memory_order m = memory_order_seq_cst) noexcept;
231
T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
232
T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
233
T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
234
T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
236
atomic() noexcept = default;
237
constexpr atomic(T* desr) noexcept;
238
atomic(const atomic&) = delete;
239
atomic& operator=(const atomic&) = delete;
240
atomic& operator=(const atomic&) volatile = delete;
242
T* operator=(T*) volatile noexcept;
243
T* operator=(T*) noexcept;
244
T* operator++(int) volatile noexcept;
245
T* operator++(int) noexcept;
246
T* operator--(int) volatile noexcept;
247
T* operator--(int) noexcept;
248
T* operator++() volatile noexcept;
249
T* operator++() noexcept;
250
T* operator--() volatile noexcept;
251
T* operator--() noexcept;
252
T* operator+=(ptrdiff_t op) volatile noexcept;
253
T* operator+=(ptrdiff_t op) noexcept;
254
T* operator-=(ptrdiff_t op) volatile noexcept;
255
T* operator-=(ptrdiff_t op) noexcept;
261
atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
265
atomic_is_lock_free(const atomic<T>* obj) noexcept;
269
atomic_init(volatile atomic<T>* obj, T desr) noexcept;
273
atomic_init(atomic<T>* obj, T desr) noexcept;
277
atomic_store(volatile atomic<T>* obj, T desr) noexcept;
281
atomic_store(atomic<T>* obj, T desr) noexcept;
285
atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
289
atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
293
atomic_load(const volatile atomic<T>* obj) noexcept;
297
atomic_load(const atomic<T>* obj) noexcept;
301
atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
305
atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
309
atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
313
atomic_exchange(atomic<T>* obj, T desr) noexcept;
317
atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
321
atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
325
atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
329
atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
333
atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
337
atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
341
atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
343
memory_order s, memory_order f) noexcept;
347
atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
348
memory_order s, memory_order f) noexcept;
352
atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
354
memory_order s, memory_order f) noexcept;
358
atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
360
memory_order s, memory_order f) noexcept;
362
template <class Integral>
364
atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
366
template <class Integral>
368
atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
370
template <class Integral>
372
atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
373
memory_order m) noexcept;
374
template <class Integral>
376
atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
377
memory_order m) noexcept;
378
template <class Integral>
380
atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
382
template <class Integral>
384
atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
386
template <class Integral>
388
atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
389
memory_order m) noexcept;
390
template <class Integral>
392
atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
393
memory_order m) noexcept;
394
template <class Integral>
396
atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
398
template <class Integral>
400
atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
402
template <class Integral>
404
atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
405
memory_order m) noexcept;
406
template <class Integral>
408
atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
409
memory_order m) noexcept;
410
template <class Integral>
412
atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
414
template <class Integral>
416
atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
418
template <class Integral>
420
atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
421
memory_order m) noexcept;
422
template <class Integral>
424
atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
425
memory_order m) noexcept;
426
template <class Integral>
428
atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
430
template <class Integral>
432
atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
434
template <class Integral>
436
atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
437
memory_order m) noexcept;
438
template <class Integral>
440
atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
441
memory_order m) noexcept;
445
atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
449
atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
453
atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
454
memory_order m) noexcept;
457
atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
461
atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
465
atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
469
atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
470
memory_order m) noexcept;
473
atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
475
// Atomics for standard typedef types
477
typedef atomic<bool> atomic_bool;
478
typedef atomic<char> atomic_char;
479
typedef atomic<signed char> atomic_schar;
480
typedef atomic<unsigned char> atomic_uchar;
481
typedef atomic<short> atomic_short;
482
typedef atomic<unsigned short> atomic_ushort;
483
typedef atomic<int> atomic_int;
484
typedef atomic<unsigned int> atomic_uint;
485
typedef atomic<long> atomic_long;
486
typedef atomic<unsigned long> atomic_ulong;
487
typedef atomic<long long> atomic_llong;
488
typedef atomic<unsigned long long> atomic_ullong;
489
typedef atomic<char16_t> atomic_char16_t;
490
typedef atomic<char32_t> atomic_char32_t;
491
typedef atomic<wchar_t> atomic_wchar_t;
493
typedef atomic<int_least8_t> atomic_int_least8_t;
494
typedef atomic<uint_least8_t> atomic_uint_least8_t;
495
typedef atomic<int_least16_t> atomic_int_least16_t;
496
typedef atomic<uint_least16_t> atomic_uint_least16_t;
497
typedef atomic<int_least32_t> atomic_int_least32_t;
498
typedef atomic<uint_least32_t> atomic_uint_least32_t;
499
typedef atomic<int_least64_t> atomic_int_least64_t;
500
typedef atomic<uint_least64_t> atomic_uint_least64_t;
502
typedef atomic<int_fast8_t> atomic_int_fast8_t;
503
typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
504
typedef atomic<int_fast16_t> atomic_int_fast16_t;
505
typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
506
typedef atomic<int_fast32_t> atomic_int_fast32_t;
507
typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
508
typedef atomic<int_fast64_t> atomic_int_fast64_t;
509
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
511
typedef atomic<intptr_t> atomic_intptr_t;
512
typedef atomic<uintptr_t> atomic_uintptr_t;
513
typedef atomic<size_t> atomic_size_t;
514
typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
515
typedef atomic<intmax_t> atomic_intmax_t;
516
typedef atomic<uintmax_t> atomic_uintmax_t;
520
void atomic_thread_fence(memory_order m) noexcept;
521
void atomic_signal_fence(memory_order m) noexcept;
530
#include <type_traits>
532
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
533
#pragma GCC system_header
536
_LIBCPP_BEGIN_NAMESPACE_STD
538
#if !__has_feature(cxx_atomic)
539
#error <atomic> is not implemented
542
typedef enum memory_order
544
memory_order_relaxed, memory_order_consume, memory_order_acquire,
545
memory_order_release, memory_order_acq_rel, memory_order_seq_cst
549
inline _LIBCPP_INLINE_VISIBILITY
551
kill_dependency(_Tp __y) _NOEXCEPT
558
template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
559
struct __atomic_base // false
561
mutable _Atomic(_Tp) __a_;
563
_LIBCPP_INLINE_VISIBILITY
564
bool is_lock_free() const volatile _NOEXCEPT
565
{return __c11_atomic_is_lock_free(sizeof(_Tp));}
566
_LIBCPP_INLINE_VISIBILITY
567
bool is_lock_free() const _NOEXCEPT
568
{return __c11_atomic_is_lock_free(sizeof(_Tp));}
569
_LIBCPP_INLINE_VISIBILITY
570
void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
571
{__c11_atomic_store(&__a_, __d, __m);}
572
_LIBCPP_INLINE_VISIBILITY
573
void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
574
{__c11_atomic_store(&__a_, __d, __m);}
575
_LIBCPP_INLINE_VISIBILITY
576
_Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
577
{return __c11_atomic_load(&__a_, __m);}
578
_LIBCPP_INLINE_VISIBILITY
579
_Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
580
{return __c11_atomic_load(&__a_, __m);}
581
_LIBCPP_INLINE_VISIBILITY
582
operator _Tp() const volatile _NOEXCEPT {return load();}
583
_LIBCPP_INLINE_VISIBILITY
584
operator _Tp() const _NOEXCEPT {return load();}
585
_LIBCPP_INLINE_VISIBILITY
586
_Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
587
{return __c11_atomic_exchange(&__a_, __d, __m);}
588
_LIBCPP_INLINE_VISIBILITY
589
_Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
590
{return __c11_atomic_exchange(&__a_, __d, __m);}
591
_LIBCPP_INLINE_VISIBILITY
592
bool compare_exchange_weak(_Tp& __e, _Tp __d,
593
memory_order __s, memory_order __f) volatile _NOEXCEPT
594
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
595
_LIBCPP_INLINE_VISIBILITY
596
bool compare_exchange_weak(_Tp& __e, _Tp __d,
597
memory_order __s, memory_order __f) _NOEXCEPT
598
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
599
_LIBCPP_INLINE_VISIBILITY
600
bool compare_exchange_strong(_Tp& __e, _Tp __d,
601
memory_order __s, memory_order __f) volatile _NOEXCEPT
602
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
603
_LIBCPP_INLINE_VISIBILITY
604
bool compare_exchange_strong(_Tp& __e, _Tp __d,
605
memory_order __s, memory_order __f) _NOEXCEPT
606
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
607
_LIBCPP_INLINE_VISIBILITY
608
bool compare_exchange_weak(_Tp& __e, _Tp __d,
609
memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
610
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
611
_LIBCPP_INLINE_VISIBILITY
612
bool compare_exchange_weak(_Tp& __e, _Tp __d,
613
memory_order __m = memory_order_seq_cst) _NOEXCEPT
614
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
615
_LIBCPP_INLINE_VISIBILITY
616
bool compare_exchange_strong(_Tp& __e, _Tp __d,
617
memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
618
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
619
_LIBCPP_INLINE_VISIBILITY
620
bool compare_exchange_strong(_Tp& __e, _Tp __d,
621
memory_order __m = memory_order_seq_cst) _NOEXCEPT
622
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
624
_LIBCPP_INLINE_VISIBILITY
625
__atomic_base() _NOEXCEPT {} // = default;
626
_LIBCPP_INLINE_VISIBILITY
627
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
628
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
629
__atomic_base(const __atomic_base&) = delete;
630
__atomic_base& operator=(const __atomic_base&) = delete;
631
__atomic_base& operator=(const __atomic_base&) volatile = delete;
632
#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
634
__atomic_base(const __atomic_base&);
635
__atomic_base& operator=(const __atomic_base&);
636
__atomic_base& operator=(const __atomic_base&) volatile;
637
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
643
struct __atomic_base<_Tp, true>
644
: public __atomic_base<_Tp, false>
646
typedef __atomic_base<_Tp, false> __base;
647
_LIBCPP_INLINE_VISIBILITY
648
__atomic_base() _NOEXCEPT {} // = default;
649
_LIBCPP_INLINE_VISIBILITY
650
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
652
_LIBCPP_INLINE_VISIBILITY
653
_Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
654
{return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
655
_LIBCPP_INLINE_VISIBILITY
656
_Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
657
{return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
658
_LIBCPP_INLINE_VISIBILITY
659
_Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
660
{return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
661
_LIBCPP_INLINE_VISIBILITY
662
_Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
663
{return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
664
_LIBCPP_INLINE_VISIBILITY
665
_Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
666
{return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
667
_LIBCPP_INLINE_VISIBILITY
668
_Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
669
{return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
670
_LIBCPP_INLINE_VISIBILITY
671
_Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
672
{return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
673
_LIBCPP_INLINE_VISIBILITY
674
_Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
675
{return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
676
_LIBCPP_INLINE_VISIBILITY
677
_Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
678
{return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
679
_LIBCPP_INLINE_VISIBILITY
680
_Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
681
{return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
683
_LIBCPP_INLINE_VISIBILITY
684
_Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
685
_LIBCPP_INLINE_VISIBILITY
686
_Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
687
_LIBCPP_INLINE_VISIBILITY
688
_Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
689
_LIBCPP_INLINE_VISIBILITY
690
_Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
691
_LIBCPP_INLINE_VISIBILITY
692
_Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
693
_LIBCPP_INLINE_VISIBILITY
694
_Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
695
_LIBCPP_INLINE_VISIBILITY
696
_Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
697
_LIBCPP_INLINE_VISIBILITY
698
_Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
699
_LIBCPP_INLINE_VISIBILITY
700
_Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
701
_LIBCPP_INLINE_VISIBILITY
702
_Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
703
_LIBCPP_INLINE_VISIBILITY
704
_Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
705
_LIBCPP_INLINE_VISIBILITY
706
_Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
707
_LIBCPP_INLINE_VISIBILITY
708
_Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
709
_LIBCPP_INLINE_VISIBILITY
710
_Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
711
_LIBCPP_INLINE_VISIBILITY
712
_Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
713
_LIBCPP_INLINE_VISIBILITY
714
_Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
715
_LIBCPP_INLINE_VISIBILITY
716
_Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
717
_LIBCPP_INLINE_VISIBILITY
718
_Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
725
: public __atomic_base<_Tp>
727
typedef __atomic_base<_Tp> __base;
728
_LIBCPP_INLINE_VISIBILITY
729
atomic() _NOEXCEPT {} // = default;
730
_LIBCPP_INLINE_VISIBILITY
731
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
733
_LIBCPP_INLINE_VISIBILITY
734
_Tp operator=(_Tp __d) volatile _NOEXCEPT
735
{__base::store(__d); return __d;}
736
_LIBCPP_INLINE_VISIBILITY
737
_Tp operator=(_Tp __d) _NOEXCEPT
738
{__base::store(__d); return __d;}
745
: public __atomic_base<_Tp*>
747
typedef __atomic_base<_Tp*> __base;
748
_LIBCPP_INLINE_VISIBILITY
749
atomic() _NOEXCEPT {} // = default;
750
_LIBCPP_INLINE_VISIBILITY
751
_LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
753
_LIBCPP_INLINE_VISIBILITY
754
_Tp* operator=(_Tp* __d) volatile _NOEXCEPT
755
{__base::store(__d); return __d;}
756
_LIBCPP_INLINE_VISIBILITY
757
_Tp* operator=(_Tp* __d) _NOEXCEPT
758
{__base::store(__d); return __d;}
760
_LIBCPP_INLINE_VISIBILITY
761
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
763
{return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
764
_LIBCPP_INLINE_VISIBILITY
765
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
766
{return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
767
_LIBCPP_INLINE_VISIBILITY
768
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
770
{return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
771
_LIBCPP_INLINE_VISIBILITY
772
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
773
{return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
775
_LIBCPP_INLINE_VISIBILITY
776
_Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
777
_LIBCPP_INLINE_VISIBILITY
778
_Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
779
_LIBCPP_INLINE_VISIBILITY
780
_Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
781
_LIBCPP_INLINE_VISIBILITY
782
_Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
783
_LIBCPP_INLINE_VISIBILITY
784
_Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
785
_LIBCPP_INLINE_VISIBILITY
786
_Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
787
_LIBCPP_INLINE_VISIBILITY
788
_Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
789
_LIBCPP_INLINE_VISIBILITY
790
_Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
791
_LIBCPP_INLINE_VISIBILITY
792
_Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
793
_LIBCPP_INLINE_VISIBILITY
794
_Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
795
_LIBCPP_INLINE_VISIBILITY
796
_Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
797
_LIBCPP_INLINE_VISIBILITY
798
_Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
801
// atomic_is_lock_free
804
inline _LIBCPP_INLINE_VISIBILITY
806
atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
808
return __o->is_lock_free();
812
inline _LIBCPP_INLINE_VISIBILITY
814
atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
816
return __o->is_lock_free();
822
inline _LIBCPP_INLINE_VISIBILITY
824
atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
826
__c11_atomic_init(&__o->__a_, __d);
830
inline _LIBCPP_INLINE_VISIBILITY
832
atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
834
__c11_atomic_init(&__o->__a_, __d);
840
inline _LIBCPP_INLINE_VISIBILITY
842
atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
848
inline _LIBCPP_INLINE_VISIBILITY
850
atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
855
// atomic_store_explicit
858
inline _LIBCPP_INLINE_VISIBILITY
860
atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
862
__o->store(__d, __m);
866
inline _LIBCPP_INLINE_VISIBILITY
868
atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
870
__o->store(__d, __m);
876
inline _LIBCPP_INLINE_VISIBILITY
878
atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
884
inline _LIBCPP_INLINE_VISIBILITY
886
atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
891
// atomic_load_explicit
894
inline _LIBCPP_INLINE_VISIBILITY
896
atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
898
return __o->load(__m);
902
inline _LIBCPP_INLINE_VISIBILITY
904
atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
906
return __o->load(__m);
912
inline _LIBCPP_INLINE_VISIBILITY
914
atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
916
return __o->exchange(__d);
920
inline _LIBCPP_INLINE_VISIBILITY
922
atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
924
return __o->exchange(__d);
927
// atomic_exchange_explicit
930
inline _LIBCPP_INLINE_VISIBILITY
932
atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
934
return __o->exchange(__d, __m);
938
inline _LIBCPP_INLINE_VISIBILITY
940
atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
942
return __o->exchange(__d, __m);
945
// atomic_compare_exchange_weak
948
inline _LIBCPP_INLINE_VISIBILITY
950
atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
952
return __o->compare_exchange_weak(*__e, __d);
956
inline _LIBCPP_INLINE_VISIBILITY
958
atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
960
return __o->compare_exchange_weak(*__e, __d);
963
// atomic_compare_exchange_strong
966
inline _LIBCPP_INLINE_VISIBILITY
968
atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
970
return __o->compare_exchange_strong(*__e, __d);
974
inline _LIBCPP_INLINE_VISIBILITY
976
atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
978
return __o->compare_exchange_strong(*__e, __d);
981
// atomic_compare_exchange_weak_explicit
984
inline _LIBCPP_INLINE_VISIBILITY
986
atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
988
memory_order __s, memory_order __f) _NOEXCEPT
990
return __o->compare_exchange_weak(*__e, __d, __s, __f);
994
inline _LIBCPP_INLINE_VISIBILITY
996
atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
997
memory_order __s, memory_order __f) _NOEXCEPT
999
return __o->compare_exchange_weak(*__e, __d, __s, __f);
1002
// atomic_compare_exchange_strong_explicit
1004
template <class _Tp>
1005
inline _LIBCPP_INLINE_VISIBILITY
1007
atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
1009
memory_order __s, memory_order __f) _NOEXCEPT
1011
return __o->compare_exchange_strong(*__e, __d, __s, __f);
1014
template <class _Tp>
1015
inline _LIBCPP_INLINE_VISIBILITY
1017
atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
1019
memory_order __s, memory_order __f) _NOEXCEPT
1021
return __o->compare_exchange_strong(*__e, __d, __s, __f);
1026
template <class _Tp>
1027
inline _LIBCPP_INLINE_VISIBILITY
1030
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1033
atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1035
return __o->fetch_add(__op);
1038
template <class _Tp>
1039
inline _LIBCPP_INLINE_VISIBILITY
1042
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1045
atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1047
return __o->fetch_add(__op);
1050
template <class _Tp>
1051
inline _LIBCPP_INLINE_VISIBILITY
1053
atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
1055
return __o->fetch_add(__op);
1058
template <class _Tp>
1059
inline _LIBCPP_INLINE_VISIBILITY
1061
atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
1063
return __o->fetch_add(__op);
1066
// atomic_fetch_add_explicit
1068
template <class _Tp>
1069
inline _LIBCPP_INLINE_VISIBILITY
1072
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1075
atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1077
return __o->fetch_add(__op, __m);
1080
template <class _Tp>
1081
inline _LIBCPP_INLINE_VISIBILITY
1084
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1087
atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1089
return __o->fetch_add(__op, __m);
1092
template <class _Tp>
1093
inline _LIBCPP_INLINE_VISIBILITY
1095
atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
1096
memory_order __m) _NOEXCEPT
1098
return __o->fetch_add(__op, __m);
1101
template <class _Tp>
1102
inline _LIBCPP_INLINE_VISIBILITY
1104
atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
1106
return __o->fetch_add(__op, __m);
1111
template <class _Tp>
1112
inline _LIBCPP_INLINE_VISIBILITY
1115
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1118
atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1120
return __o->fetch_sub(__op);
1123
template <class _Tp>
1124
inline _LIBCPP_INLINE_VISIBILITY
1127
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1130
atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1132
return __o->fetch_sub(__op);
1135
template <class _Tp>
1136
inline _LIBCPP_INLINE_VISIBILITY
1138
atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
1140
return __o->fetch_sub(__op);
1143
template <class _Tp>
1144
inline _LIBCPP_INLINE_VISIBILITY
1146
atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
1148
return __o->fetch_sub(__op);
1151
// atomic_fetch_sub_explicit
1153
template <class _Tp>
1154
inline _LIBCPP_INLINE_VISIBILITY
1157
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1160
atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1162
return __o->fetch_sub(__op, __m);
1165
template <class _Tp>
1166
inline _LIBCPP_INLINE_VISIBILITY
1169
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1172
atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1174
return __o->fetch_sub(__op, __m);
1177
template <class _Tp>
1178
inline _LIBCPP_INLINE_VISIBILITY
1180
atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
1181
memory_order __m) _NOEXCEPT
1183
return __o->fetch_sub(__op, __m);
1186
template <class _Tp>
1187
inline _LIBCPP_INLINE_VISIBILITY
1189
atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
1191
return __o->fetch_sub(__op, __m);
1196
template <class _Tp>
1197
inline _LIBCPP_INLINE_VISIBILITY
1200
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1203
atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1205
return __o->fetch_and(__op);
1208
template <class _Tp>
1209
inline _LIBCPP_INLINE_VISIBILITY
1212
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1215
atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1217
return __o->fetch_and(__op);
1220
// atomic_fetch_and_explicit
1222
template <class _Tp>
1223
inline _LIBCPP_INLINE_VISIBILITY
1226
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1229
atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1231
return __o->fetch_and(__op, __m);
1234
template <class _Tp>
1235
inline _LIBCPP_INLINE_VISIBILITY
1238
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1241
atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1243
return __o->fetch_and(__op, __m);
1248
template <class _Tp>
1249
inline _LIBCPP_INLINE_VISIBILITY
1252
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1255
atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1257
return __o->fetch_or(__op);
1260
template <class _Tp>
1261
inline _LIBCPP_INLINE_VISIBILITY
1264
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1267
atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1269
return __o->fetch_or(__op);
1272
// atomic_fetch_or_explicit
1274
template <class _Tp>
1275
inline _LIBCPP_INLINE_VISIBILITY
1278
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1281
atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1283
return __o->fetch_or(__op, __m);
1286
template <class _Tp>
1287
inline _LIBCPP_INLINE_VISIBILITY
1290
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1293
atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1295
return __o->fetch_or(__op, __m);
1300
template <class _Tp>
1301
inline _LIBCPP_INLINE_VISIBILITY
1304
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1307
atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1309
return __o->fetch_xor(__op);
1312
template <class _Tp>
1313
inline _LIBCPP_INLINE_VISIBILITY
1316
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1319
atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
1321
return __o->fetch_xor(__op);
1324
// atomic_fetch_xor_explicit
1326
template <class _Tp>
1327
inline _LIBCPP_INLINE_VISIBILITY
1330
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1333
atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1335
return __o->fetch_xor(__op, __m);
1338
template <class _Tp>
1339
inline _LIBCPP_INLINE_VISIBILITY
1342
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1345
atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
1347
return __o->fetch_xor(__op, __m);
1350
// flag type and operations
1352
typedef struct atomic_flag
1356
_LIBCPP_INLINE_VISIBILITY
1357
bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1358
{return __c11_atomic_exchange(&__a_, true, __m);}
1359
_LIBCPP_INLINE_VISIBILITY
1360
bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
1361
{return __c11_atomic_exchange(&__a_, true, __m);}
1362
_LIBCPP_INLINE_VISIBILITY
1363
void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1364
{__c11_atomic_store(&__a_, false, __m);}
1365
_LIBCPP_INLINE_VISIBILITY
1366
void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
1367
{__c11_atomic_store(&__a_, false, __m);}
1369
_LIBCPP_INLINE_VISIBILITY
1370
atomic_flag() _NOEXCEPT {} // = default;
1371
_LIBCPP_INLINE_VISIBILITY
1372
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
1374
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1375
atomic_flag(const atomic_flag&) = delete;
1376
atomic_flag& operator=(const atomic_flag&) = delete;
1377
atomic_flag& operator=(const atomic_flag&) volatile = delete;
1378
#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1380
atomic_flag(const atomic_flag&);
1381
atomic_flag& operator=(const atomic_flag&);
1382
atomic_flag& operator=(const atomic_flag&) volatile;
1383
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1386
inline _LIBCPP_INLINE_VISIBILITY
1388
atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
1390
return __o->test_and_set();
1393
inline _LIBCPP_INLINE_VISIBILITY
1395
atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
1397
return __o->test_and_set();
1400
inline _LIBCPP_INLINE_VISIBILITY
1402
atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
1404
return __o->test_and_set(__m);
1407
inline _LIBCPP_INLINE_VISIBILITY
1409
atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
1411
return __o->test_and_set(__m);
1414
inline _LIBCPP_INLINE_VISIBILITY
1416
atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
1421
inline _LIBCPP_INLINE_VISIBILITY
1423
atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
1428
inline _LIBCPP_INLINE_VISIBILITY
1430
atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
1435
inline _LIBCPP_INLINE_VISIBILITY
1437
atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
1444
inline _LIBCPP_INLINE_VISIBILITY
1446
atomic_thread_fence(memory_order __m) _NOEXCEPT
1448
__c11_atomic_thread_fence(__m);
1451
inline _LIBCPP_INLINE_VISIBILITY
1453
atomic_signal_fence(memory_order __m) _NOEXCEPT
1455
__c11_atomic_signal_fence(__m);
1458
// Atomics for standard typedef types
1460
typedef atomic<bool> atomic_bool;
1461
typedef atomic<char> atomic_char;
1462
typedef atomic<signed char> atomic_schar;
1463
typedef atomic<unsigned char> atomic_uchar;
1464
typedef atomic<short> atomic_short;
1465
typedef atomic<unsigned short> atomic_ushort;
1466
typedef atomic<int> atomic_int;
1467
typedef atomic<unsigned int> atomic_uint;
1468
typedef atomic<long> atomic_long;
1469
typedef atomic<unsigned long> atomic_ulong;
1470
typedef atomic<long long> atomic_llong;
1471
typedef atomic<unsigned long long> atomic_ullong;
1472
typedef atomic<char16_t> atomic_char16_t;
1473
typedef atomic<char32_t> atomic_char32_t;
1474
typedef atomic<wchar_t> atomic_wchar_t;
1476
typedef atomic<int_least8_t> atomic_int_least8_t;
1477
typedef atomic<uint_least8_t> atomic_uint_least8_t;
1478
typedef atomic<int_least16_t> atomic_int_least16_t;
1479
typedef atomic<uint_least16_t> atomic_uint_least16_t;
1480
typedef atomic<int_least32_t> atomic_int_least32_t;
1481
typedef atomic<uint_least32_t> atomic_uint_least32_t;
1482
typedef atomic<int_least64_t> atomic_int_least64_t;
1483
typedef atomic<uint_least64_t> atomic_uint_least64_t;
1485
typedef atomic<int_fast8_t> atomic_int_fast8_t;
1486
typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
1487
typedef atomic<int_fast16_t> atomic_int_fast16_t;
1488
typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
1489
typedef atomic<int_fast32_t> atomic_int_fast32_t;
1490
typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
1491
typedef atomic<int_fast64_t> atomic_int_fast64_t;
1492
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
1494
typedef atomic<intptr_t> atomic_intptr_t;
1495
typedef atomic<uintptr_t> atomic_uintptr_t;
1496
typedef atomic<size_t> atomic_size_t;
1497
typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
1498
typedef atomic<intmax_t> atomic_intmax_t;
1499
typedef atomic<uintmax_t> atomic_uintmax_t;
1501
#define ATOMIC_FLAG_INIT {false}
1502
#define ATOMIC_VAR_INIT(__v) {__v}
1504
// lock-free property
1506
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
1507
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
1508
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
1509
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
1510
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
1511
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
1512
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
1513
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
1514
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
1515
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
1517
#endif // !__has_feature(cxx_atomic)
1519
_LIBCPP_END_NAMESPACE_STD
1521
#endif // _LIBCPP_ATOMIC