Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 1 | // -*- 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 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 20 | // feature test macro |
| 21 | |
| 22 | #define __cpp_lib_atomic_is_always_lock_free // as specified by SG10 |
| 23 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 24 | // order and consistency |
| 25 | |
| 26 | typedef enum memory_order |
| 27 | { |
Howard Hinnant | dca6e71 | 2010-09-28 17:13:38 +0000 | [diff] [blame] | 28 | memory_order_relaxed, |
| 29 | memory_order_consume, // load-consume |
| 30 | memory_order_acquire, // load-acquire |
| 31 | memory_order_release, // store-release |
| 32 | memory_order_acq_rel, // store-release load-acquire |
| 33 | memory_order_seq_cst // store-release load-acquire |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 34 | } memory_order; |
| 35 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 36 | template <class T> T kill_dependency(T y) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 37 | |
| 38 | // lock-free property |
| 39 | |
Howard Hinnant | 931e340 | 2013-01-21 20:39:41 +0000 | [diff] [blame] | 40 | #define ATOMIC_BOOL_LOCK_FREE unspecified |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 41 | #define ATOMIC_CHAR_LOCK_FREE unspecified |
| 42 | #define ATOMIC_CHAR16_T_LOCK_FREE unspecified |
| 43 | #define ATOMIC_CHAR32_T_LOCK_FREE unspecified |
| 44 | #define ATOMIC_WCHAR_T_LOCK_FREE unspecified |
| 45 | #define ATOMIC_SHORT_LOCK_FREE unspecified |
| 46 | #define ATOMIC_INT_LOCK_FREE unspecified |
| 47 | #define ATOMIC_LONG_LOCK_FREE unspecified |
| 48 | #define ATOMIC_LLONG_LOCK_FREE unspecified |
Howard Hinnant | 931e340 | 2013-01-21 20:39:41 +0000 | [diff] [blame] | 49 | #define ATOMIC_POINTER_LOCK_FREE unspecified |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 50 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 51 | // flag type and operations |
| 52 | |
| 53 | typedef struct atomic_flag |
| 54 | { |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 55 | bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; |
| 56 | bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; |
| 57 | void clear(memory_order m = memory_order_seq_cst) volatile noexcept; |
| 58 | void clear(memory_order m = memory_order_seq_cst) noexcept; |
| 59 | atomic_flag() noexcept = default; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 60 | atomic_flag(const atomic_flag&) = delete; |
| 61 | atomic_flag& operator=(const atomic_flag&) = delete; |
| 62 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 63 | } atomic_flag; |
| 64 | |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 65 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 66 | atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 67 | |
| 68 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 69 | atomic_flag_test_and_set(atomic_flag* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 70 | |
| 71 | bool |
| 72 | atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 73 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 74 | |
| 75 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 76 | atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 77 | |
| 78 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 79 | atomic_flag_clear(volatile atomic_flag* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 80 | |
| 81 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 82 | atomic_flag_clear(atomic_flag* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 83 | |
| 84 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 85 | atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 86 | |
| 87 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 88 | atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 89 | |
| 90 | #define ATOMIC_FLAG_INIT see below |
Howard Hinnant | 493d1d9 | 2010-10-19 16:51:18 +0000 | [diff] [blame] | 91 | #define ATOMIC_VAR_INIT(value) see below |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 92 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 93 | template <class T> |
| 94 | struct atomic |
| 95 | { |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 96 | static constexpr bool is_always_lock_free; |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 97 | bool is_lock_free() const volatile noexcept; |
| 98 | bool is_lock_free() const noexcept; |
| 99 | void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 100 | void store(T desr, memory_order m = memory_order_seq_cst) noexcept; |
| 101 | T load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 102 | T load(memory_order m = memory_order_seq_cst) const noexcept; |
| 103 | operator T() const volatile noexcept; |
| 104 | operator T() const noexcept; |
| 105 | T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 106 | T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 107 | bool compare_exchange_weak(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 108 | memory_order s, memory_order f) volatile noexcept; |
| 109 | bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 110 | bool compare_exchange_strong(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 111 | memory_order s, memory_order f) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 112 | bool compare_exchange_strong(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 113 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 114 | bool compare_exchange_weak(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 115 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 116 | bool compare_exchange_weak(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 117 | memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 118 | bool compare_exchange_strong(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 119 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 120 | bool compare_exchange_strong(T& expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 121 | memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 122 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 123 | atomic() noexcept = default; |
| 124 | constexpr atomic(T desr) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 125 | atomic(const atomic&) = delete; |
| 126 | atomic& operator=(const atomic&) = delete; |
| 127 | atomic& operator=(const atomic&) volatile = delete; |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 128 | T operator=(T) volatile noexcept; |
| 129 | T operator=(T) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | template <> |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 133 | struct atomic<integral> |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 134 | { |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 135 | static constexpr bool is_always_lock_free; |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 136 | bool is_lock_free() const volatile noexcept; |
| 137 | bool is_lock_free() const noexcept; |
| 138 | void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 139 | void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; |
| 140 | integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 141 | integral load(memory_order m = memory_order_seq_cst) const noexcept; |
| 142 | operator integral() const volatile noexcept; |
| 143 | operator integral() const noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 144 | integral exchange(integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 145 | memory_order m = memory_order_seq_cst) volatile noexcept; |
| 146 | integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 147 | bool compare_exchange_weak(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 148 | memory_order s, memory_order f) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 149 | bool compare_exchange_weak(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 150 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 151 | bool compare_exchange_strong(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 152 | memory_order s, memory_order f) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 153 | bool compare_exchange_strong(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 154 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 155 | bool compare_exchange_weak(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 156 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 157 | bool compare_exchange_weak(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 158 | memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 159 | bool compare_exchange_strong(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 160 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 161 | bool compare_exchange_strong(integral& expc, integral desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 162 | memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 163 | |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 164 | integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 165 | fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 166 | integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 167 | integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 168 | fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 169 | integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 170 | integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 171 | fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 172 | integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 173 | integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 174 | fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 175 | integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 176 | integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 177 | fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 178 | integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 179 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 180 | atomic() noexcept = default; |
| 181 | constexpr atomic(integral desr) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 182 | atomic(const atomic&) = delete; |
| 183 | atomic& operator=(const atomic&) = delete; |
| 184 | atomic& operator=(const atomic&) volatile = delete; |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 185 | integral operator=(integral desr) volatile noexcept; |
| 186 | integral operator=(integral desr) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 187 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 188 | integral operator++(int) volatile noexcept; |
| 189 | integral operator++(int) noexcept; |
| 190 | integral operator--(int) volatile noexcept; |
| 191 | integral operator--(int) noexcept; |
| 192 | integral operator++() volatile noexcept; |
| 193 | integral operator++() noexcept; |
| 194 | integral operator--() volatile noexcept; |
| 195 | integral operator--() 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; |
| 200 | integral operator&=(integral op) volatile noexcept; |
| 201 | integral operator&=(integral op) noexcept; |
| 202 | integral operator|=(integral op) volatile noexcept; |
| 203 | integral operator|=(integral op) noexcept; |
| 204 | integral operator^=(integral op) volatile noexcept; |
| 205 | integral operator^=(integral op) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | template <class T> |
| 209 | struct atomic<T*> |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 210 | { |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 211 | static constexpr bool is_always_lock_free; |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 212 | bool is_lock_free() const volatile noexcept; |
| 213 | bool is_lock_free() const noexcept; |
| 214 | void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 215 | void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; |
| 216 | T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; |
| 217 | T* load(memory_order m = memory_order_seq_cst) const noexcept; |
| 218 | operator T*() const volatile noexcept; |
| 219 | operator T*() const noexcept; |
| 220 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 221 | T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 222 | bool compare_exchange_weak(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 223 | memory_order s, memory_order f) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 224 | bool compare_exchange_weak(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 225 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 226 | bool compare_exchange_strong(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 227 | memory_order s, memory_order f) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 228 | bool compare_exchange_strong(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 229 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 230 | bool compare_exchange_weak(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 231 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 232 | bool compare_exchange_weak(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 233 | memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 234 | bool compare_exchange_strong(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 235 | memory_order m = memory_order_seq_cst) volatile noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 236 | bool compare_exchange_strong(T*& expc, T* desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 237 | memory_order m = memory_order_seq_cst) noexcept; |
| 238 | T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 239 | T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; |
| 240 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; |
| 241 | T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 242 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 243 | atomic() noexcept = default; |
| 244 | constexpr atomic(T* desr) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 245 | atomic(const atomic&) = delete; |
| 246 | atomic& operator=(const atomic&) = delete; |
| 247 | atomic& operator=(const atomic&) volatile = delete; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 248 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 249 | T* operator=(T*) volatile noexcept; |
| 250 | T* operator=(T*) noexcept; |
| 251 | T* operator++(int) volatile noexcept; |
| 252 | T* operator++(int) noexcept; |
| 253 | T* operator--(int) volatile noexcept; |
| 254 | T* operator--(int) noexcept; |
| 255 | T* operator++() volatile noexcept; |
| 256 | T* operator++() noexcept; |
| 257 | T* operator--() volatile noexcept; |
| 258 | T* operator--() noexcept; |
| 259 | T* operator+=(ptrdiff_t op) volatile noexcept; |
| 260 | T* operator+=(ptrdiff_t op) noexcept; |
| 261 | T* operator-=(ptrdiff_t op) volatile noexcept; |
| 262 | T* operator-=(ptrdiff_t op) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 263 | }; |
| 264 | |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 265 | |
| 266 | template <class T> |
| 267 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 268 | atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 269 | |
| 270 | template <class T> |
| 271 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 272 | atomic_is_lock_free(const atomic<T>* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 273 | |
| 274 | template <class T> |
| 275 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 276 | atomic_init(volatile atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 277 | |
| 278 | template <class T> |
| 279 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 280 | atomic_init(atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 281 | |
| 282 | template <class T> |
| 283 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 284 | atomic_store(volatile atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 285 | |
| 286 | template <class T> |
| 287 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 288 | atomic_store(atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 289 | |
| 290 | template <class T> |
| 291 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 292 | atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 293 | |
| 294 | template <class T> |
| 295 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 296 | atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 297 | |
| 298 | template <class T> |
| 299 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 300 | atomic_load(const volatile atomic<T>* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 301 | |
| 302 | template <class T> |
| 303 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 304 | atomic_load(const atomic<T>* obj) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 305 | |
| 306 | template <class T> |
| 307 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 308 | atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 309 | |
| 310 | template <class T> |
| 311 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 312 | atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 313 | |
| 314 | template <class T> |
| 315 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 316 | atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 317 | |
| 318 | template <class T> |
| 319 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 320 | atomic_exchange(atomic<T>* obj, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 321 | |
| 322 | template <class T> |
| 323 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 324 | atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 325 | |
| 326 | template <class T> |
| 327 | T |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 328 | atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 329 | |
| 330 | template <class T> |
| 331 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 332 | atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 333 | |
| 334 | template <class T> |
| 335 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 336 | atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 337 | |
| 338 | template <class T> |
| 339 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 340 | atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 341 | |
| 342 | template <class T> |
| 343 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 344 | atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 345 | |
| 346 | template <class T> |
| 347 | bool |
| 348 | atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, |
| 349 | T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 350 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 351 | |
| 352 | template <class T> |
| 353 | bool |
| 354 | atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 355 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 356 | |
| 357 | template <class T> |
| 358 | bool |
| 359 | atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, |
| 360 | T* expc, T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 361 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 362 | |
| 363 | template <class T> |
| 364 | bool |
| 365 | atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, |
| 366 | T desr, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 367 | memory_order s, memory_order f) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 368 | |
| 369 | template <class Integral> |
| 370 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 371 | atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 372 | |
| 373 | template <class Integral> |
| 374 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 375 | atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 376 | |
| 377 | template <class Integral> |
| 378 | Integral |
| 379 | atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 380 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 381 | template <class Integral> |
| 382 | Integral |
| 383 | atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 384 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 385 | template <class Integral> |
| 386 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 387 | atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 388 | |
| 389 | template <class Integral> |
| 390 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 391 | atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 392 | |
| 393 | template <class Integral> |
| 394 | Integral |
| 395 | atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 396 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 397 | template <class Integral> |
| 398 | Integral |
| 399 | atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 400 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 401 | template <class Integral> |
| 402 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 403 | atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 404 | |
| 405 | template <class Integral> |
| 406 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 407 | atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 408 | |
| 409 | template <class Integral> |
| 410 | Integral |
| 411 | atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 412 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 413 | template <class Integral> |
| 414 | Integral |
| 415 | atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 416 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 417 | template <class Integral> |
| 418 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 419 | atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 420 | |
| 421 | template <class Integral> |
| 422 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 423 | atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 424 | |
| 425 | template <class Integral> |
| 426 | Integral |
| 427 | atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 428 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 429 | template <class Integral> |
| 430 | Integral |
| 431 | atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 432 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 433 | template <class Integral> |
| 434 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 435 | atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 436 | |
| 437 | template <class Integral> |
| 438 | Integral |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 439 | atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 440 | |
| 441 | template <class Integral> |
| 442 | Integral |
| 443 | atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 444 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 445 | template <class Integral> |
| 446 | Integral |
| 447 | atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 448 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 449 | |
| 450 | template <class T> |
| 451 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 452 | atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 453 | |
| 454 | template <class T> |
| 455 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 456 | atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 457 | |
| 458 | template <class T> |
| 459 | T* |
| 460 | atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 461 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 462 | template <class T> |
| 463 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 464 | atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 465 | |
| 466 | template <class T> |
| 467 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 468 | atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 469 | |
| 470 | template <class T> |
| 471 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 472 | atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 473 | |
| 474 | template <class T> |
| 475 | T* |
| 476 | atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 477 | memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 478 | template <class T> |
| 479 | T* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 480 | atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 481 | |
| 482 | // Atomics for standard typedef types |
| 483 | |
Howard Hinnant | f0af8d9 | 2013-01-04 18:58:50 +0000 | [diff] [blame] | 484 | typedef atomic<bool> atomic_bool; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 485 | typedef atomic<char> atomic_char; |
| 486 | typedef atomic<signed char> atomic_schar; |
| 487 | typedef atomic<unsigned char> atomic_uchar; |
| 488 | typedef atomic<short> atomic_short; |
| 489 | typedef atomic<unsigned short> atomic_ushort; |
| 490 | typedef atomic<int> atomic_int; |
| 491 | typedef atomic<unsigned int> atomic_uint; |
| 492 | typedef atomic<long> atomic_long; |
| 493 | typedef atomic<unsigned long> atomic_ulong; |
| 494 | typedef atomic<long long> atomic_llong; |
| 495 | typedef atomic<unsigned long long> atomic_ullong; |
| 496 | typedef atomic<char16_t> atomic_char16_t; |
| 497 | typedef atomic<char32_t> atomic_char32_t; |
| 498 | typedef atomic<wchar_t> atomic_wchar_t; |
| 499 | |
| 500 | typedef atomic<int_least8_t> atomic_int_least8_t; |
| 501 | typedef atomic<uint_least8_t> atomic_uint_least8_t; |
| 502 | typedef atomic<int_least16_t> atomic_int_least16_t; |
| 503 | typedef atomic<uint_least16_t> atomic_uint_least16_t; |
| 504 | typedef atomic<int_least32_t> atomic_int_least32_t; |
| 505 | typedef atomic<uint_least32_t> atomic_uint_least32_t; |
| 506 | typedef atomic<int_least64_t> atomic_int_least64_t; |
| 507 | typedef atomic<uint_least64_t> atomic_uint_least64_t; |
| 508 | |
| 509 | typedef atomic<int_fast8_t> atomic_int_fast8_t; |
| 510 | typedef atomic<uint_fast8_t> atomic_uint_fast8_t; |
| 511 | typedef atomic<int_fast16_t> atomic_int_fast16_t; |
| 512 | typedef atomic<uint_fast16_t> atomic_uint_fast16_t; |
| 513 | typedef atomic<int_fast32_t> atomic_int_fast32_t; |
| 514 | typedef atomic<uint_fast32_t> atomic_uint_fast32_t; |
| 515 | typedef atomic<int_fast64_t> atomic_int_fast64_t; |
| 516 | typedef atomic<uint_fast64_t> atomic_uint_fast64_t; |
| 517 | |
Marshall Clow | f710afc | 2016-06-30 15:28:38 +0000 | [diff] [blame^] | 518 | typedef atomic<int8_t> atomic_int8_t; |
| 519 | typedef atomic<uint8_t> atomic_uint8_t; |
| 520 | typedef atomic<int16_t> atomic_int16_t; |
| 521 | typedef atomic<uint16_t> atomic_uint16_t; |
| 522 | typedef atomic<int32_t> atomic_int32_t; |
| 523 | typedef atomic<uint32_t> atomic_uint32_t; |
| 524 | typedef atomic<int64_t> atomic_int64_t; |
| 525 | typedef atomic<uint64_t> atomic_uint64_t; |
| 526 | |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 527 | typedef atomic<intptr_t> atomic_intptr_t; |
| 528 | typedef atomic<uintptr_t> atomic_uintptr_t; |
| 529 | typedef atomic<size_t> atomic_size_t; |
| 530 | typedef atomic<ptrdiff_t> atomic_ptrdiff_t; |
| 531 | typedef atomic<intmax_t> atomic_intmax_t; |
| 532 | typedef atomic<uintmax_t> atomic_uintmax_t; |
| 533 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 534 | // fences |
| 535 | |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 536 | void atomic_thread_fence(memory_order m) noexcept; |
| 537 | void atomic_signal_fence(memory_order m) noexcept; |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 538 | |
| 539 | } // std |
| 540 | |
| 541 | */ |
| 542 | |
| 543 | #include <__config> |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 544 | #include <cstddef> |
| 545 | #include <cstdint> |
| 546 | #include <type_traits> |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 547 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 548 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 549 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 550 | #endif |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 551 | |
Jonathan Roelofs | 39cb6bf | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 552 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 553 | #error <atomic> is not supported on this single threaded system |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 554 | #endif |
| 555 | #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) |
| 556 | #error <atomic> is not implemented |
| 557 | #endif |
Jonathan Roelofs | 39cb6bf | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 558 | |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 559 | #if _LIBCPP_STD_VER > 14 |
| 560 | // FIXME: use the right feature test macro value as chose by SG10. |
| 561 | # define __cpp_lib_atomic_is_always_lock_free 201603L |
| 562 | #endif |
| 563 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 564 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 565 | |
Howard Hinnant | dca6e71 | 2010-09-28 17:13:38 +0000 | [diff] [blame] | 566 | typedef enum memory_order |
| 567 | { |
| 568 | memory_order_relaxed, memory_order_consume, memory_order_acquire, |
| 569 | memory_order_release, memory_order_acq_rel, memory_order_seq_cst |
| 570 | } memory_order; |
| 571 | |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 572 | #if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 573 | namespace __gcc_atomic { |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 574 | template <typename _Tp> |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 575 | struct __gcc_atomic_t { |
Eric Fiselier | 88f0712 | 2015-12-15 00:32:21 +0000 | [diff] [blame] | 576 | |
| 577 | #if _GNUC_VER >= 501 |
| 578 | static_assert(is_trivially_copyable<_Tp>::value, |
| 579 | "std::atomic<Tp> requires that 'Tp' be a trivially copyable type"); |
| 580 | #endif |
| 581 | |
Eric Fiselier | 684aaca | 2015-10-14 08:36:22 +0000 | [diff] [blame] | 582 | _LIBCPP_INLINE_VISIBILITY |
| 583 | #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
| 584 | __gcc_atomic_t() _NOEXCEPT = default; |
| 585 | #else |
| 586 | __gcc_atomic_t() _NOEXCEPT : __a_value() {} |
| 587 | #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
Eric Fiselier | 719e044 | 2015-07-14 17:50:27 +0000 | [diff] [blame] | 588 | _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT |
| 589 | : __a_value(value) {} |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 590 | _Tp __a_value; |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 591 | }; |
| 592 | #define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> |
| 593 | |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 594 | template <typename _Tp> _Tp __create(); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 595 | |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 596 | template <typename _Tp, typename _Td> |
| 597 | typename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 598 | __test_atomic_assignable(int); |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 599 | template <typename _Tp, typename _Up> |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 600 | __two __test_atomic_assignable(...); |
| 601 | |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 602 | template <typename _Tp, typename _Td> |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 603 | struct __can_assign { |
| 604 | static const bool value = |
Marshall Clow | 290eb3f | 2015-01-11 06:15:59 +0000 | [diff] [blame] | 605 | sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 606 | }; |
| 607 | |
Eric Fiselier | 684aaca | 2015-10-14 08:36:22 +0000 | [diff] [blame] | 608 | static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) { |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 609 | // Avoid switch statement to make this a constexpr. |
| 610 | return __order == memory_order_relaxed ? __ATOMIC_RELAXED: |
| 611 | (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: |
| 612 | (__order == memory_order_release ? __ATOMIC_RELEASE: |
| 613 | (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: |
| 614 | (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: |
| 615 | __ATOMIC_CONSUME)))); |
| 616 | } |
| 617 | |
Eric Fiselier | 684aaca | 2015-10-14 08:36:22 +0000 | [diff] [blame] | 618 | static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) { |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 619 | // Avoid switch statement to make this a constexpr. |
| 620 | return __order == memory_order_relaxed ? __ATOMIC_RELAXED: |
| 621 | (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: |
| 622 | (__order == memory_order_release ? __ATOMIC_RELAXED: |
| 623 | (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: |
| 624 | (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE: |
| 625 | __ATOMIC_CONSUME)))); |
| 626 | } |
| 627 | |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 628 | } // namespace __gcc_atomic |
| 629 | |
| 630 | template <typename _Tp> |
| 631 | static inline |
| 632 | typename enable_if< |
| 633 | __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type |
| 634 | __c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { |
| 635 | __a->__a_value = __val; |
| 636 | } |
| 637 | |
| 638 | template <typename _Tp> |
| 639 | static inline |
| 640 | typename enable_if< |
| 641 | !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && |
| 642 | __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type |
| 643 | __c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { |
| 644 | // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because |
| 645 | // the default operator= in an object is not volatile, a byte-by-byte copy |
| 646 | // is required. |
| 647 | volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); |
| 648 | volatile char* end = to + sizeof(_Tp); |
| 649 | char* from = reinterpret_cast<char*>(&__val); |
| 650 | while (to != end) { |
| 651 | *to++ = *from++; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | template <typename _Tp> |
| 656 | static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { |
| 657 | __a->__a_value = __val; |
| 658 | } |
| 659 | |
| 660 | static inline void __c11_atomic_thread_fence(memory_order __order) { |
| 661 | __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); |
| 662 | } |
| 663 | |
| 664 | static inline void __c11_atomic_signal_fence(memory_order __order) { |
| 665 | __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); |
| 666 | } |
| 667 | |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 668 | template <typename _Tp> |
| 669 | static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, |
| 670 | memory_order __order) { |
| 671 | return __atomic_store(&__a->__a_value, &__val, |
| 672 | __gcc_atomic::__to_gcc_order(__order)); |
| 673 | } |
| 674 | |
| 675 | template <typename _Tp> |
| 676 | static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, |
| 677 | memory_order __order) { |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 678 | __atomic_store(&__a->__a_value, &__val, |
| 679 | __gcc_atomic::__to_gcc_order(__order)); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | template <typename _Tp> |
| 683 | static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, |
| 684 | memory_order __order) { |
| 685 | _Tp __ret; |
| 686 | __atomic_load(&__a->__a_value, &__ret, |
| 687 | __gcc_atomic::__to_gcc_order(__order)); |
| 688 | return __ret; |
| 689 | } |
| 690 | |
| 691 | template <typename _Tp> |
| 692 | static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { |
| 693 | _Tp __ret; |
| 694 | __atomic_load(&__a->__a_value, &__ret, |
| 695 | __gcc_atomic::__to_gcc_order(__order)); |
| 696 | return __ret; |
| 697 | } |
| 698 | |
| 699 | template <typename _Tp> |
| 700 | static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, |
| 701 | _Tp __value, memory_order __order) { |
| 702 | _Tp __ret; |
| 703 | __atomic_exchange(&__a->__a_value, &__value, &__ret, |
| 704 | __gcc_atomic::__to_gcc_order(__order)); |
| 705 | return __ret; |
| 706 | } |
| 707 | |
| 708 | template <typename _Tp> |
| 709 | static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, |
| 710 | memory_order __order) { |
| 711 | _Tp __ret; |
| 712 | __atomic_exchange(&__a->__a_value, &__value, &__ret, |
| 713 | __gcc_atomic::__to_gcc_order(__order)); |
| 714 | return __ret; |
| 715 | } |
| 716 | |
| 717 | template <typename _Tp> |
| 718 | static inline bool __c11_atomic_compare_exchange_strong( |
| 719 | volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, |
| 720 | memory_order __success, memory_order __failure) { |
| 721 | return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, |
| 722 | false, |
| 723 | __gcc_atomic::__to_gcc_order(__success), |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 724 | __gcc_atomic::__to_gcc_failure_order(__failure)); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | template <typename _Tp> |
| 728 | static inline bool __c11_atomic_compare_exchange_strong( |
| 729 | _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, |
| 730 | memory_order __failure) { |
| 731 | return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, |
| 732 | false, |
| 733 | __gcc_atomic::__to_gcc_order(__success), |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 734 | __gcc_atomic::__to_gcc_failure_order(__failure)); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | template <typename _Tp> |
| 738 | static inline bool __c11_atomic_compare_exchange_weak( |
| 739 | volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, |
| 740 | memory_order __success, memory_order __failure) { |
| 741 | return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, |
| 742 | true, |
| 743 | __gcc_atomic::__to_gcc_order(__success), |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 744 | __gcc_atomic::__to_gcc_failure_order(__failure)); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | template <typename _Tp> |
| 748 | static inline bool __c11_atomic_compare_exchange_weak( |
| 749 | _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, |
| 750 | memory_order __failure) { |
| 751 | return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, |
| 752 | true, |
| 753 | __gcc_atomic::__to_gcc_order(__success), |
Dan Albert | 48815f2 | 2015-01-06 18:39:37 +0000 | [diff] [blame] | 754 | __gcc_atomic::__to_gcc_failure_order(__failure)); |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | template <typename _Tp> |
| 758 | struct __skip_amt { enum {value = 1}; }; |
| 759 | |
| 760 | template <typename _Tp> |
| 761 | struct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; |
| 762 | |
| 763 | // FIXME: Haven't figured out what the spec says about using arrays with |
| 764 | // atomic_fetch_add. Force a failure rather than creating bad behavior. |
| 765 | template <typename _Tp> |
| 766 | struct __skip_amt<_Tp[]> { }; |
| 767 | template <typename _Tp, int n> |
| 768 | struct __skip_amt<_Tp[n]> { }; |
| 769 | |
| 770 | template <typename _Tp, typename _Td> |
| 771 | static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, |
| 772 | _Td __delta, memory_order __order) { |
| 773 | return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, |
| 774 | __gcc_atomic::__to_gcc_order(__order)); |
| 775 | } |
| 776 | |
| 777 | template <typename _Tp, typename _Td> |
| 778 | static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, |
| 779 | memory_order __order) { |
| 780 | return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, |
| 781 | __gcc_atomic::__to_gcc_order(__order)); |
| 782 | } |
| 783 | |
| 784 | template <typename _Tp, typename _Td> |
| 785 | static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, |
| 786 | _Td __delta, memory_order __order) { |
| 787 | return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, |
| 788 | __gcc_atomic::__to_gcc_order(__order)); |
| 789 | } |
| 790 | |
| 791 | template <typename _Tp, typename _Td> |
| 792 | static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, |
| 793 | memory_order __order) { |
| 794 | return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, |
| 795 | __gcc_atomic::__to_gcc_order(__order)); |
| 796 | } |
| 797 | |
| 798 | template <typename _Tp> |
| 799 | static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, |
| 800 | _Tp __pattern, memory_order __order) { |
| 801 | return __atomic_fetch_and(&__a->__a_value, __pattern, |
| 802 | __gcc_atomic::__to_gcc_order(__order)); |
| 803 | } |
| 804 | |
| 805 | template <typename _Tp> |
| 806 | static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, |
| 807 | _Tp __pattern, memory_order __order) { |
| 808 | return __atomic_fetch_and(&__a->__a_value, __pattern, |
| 809 | __gcc_atomic::__to_gcc_order(__order)); |
| 810 | } |
| 811 | |
| 812 | template <typename _Tp> |
| 813 | static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, |
| 814 | _Tp __pattern, memory_order __order) { |
| 815 | return __atomic_fetch_or(&__a->__a_value, __pattern, |
| 816 | __gcc_atomic::__to_gcc_order(__order)); |
| 817 | } |
| 818 | |
| 819 | template <typename _Tp> |
| 820 | static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, |
| 821 | memory_order __order) { |
| 822 | return __atomic_fetch_or(&__a->__a_value, __pattern, |
| 823 | __gcc_atomic::__to_gcc_order(__order)); |
| 824 | } |
| 825 | |
| 826 | template <typename _Tp> |
| 827 | static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, |
| 828 | _Tp __pattern, memory_order __order) { |
| 829 | return __atomic_fetch_xor(&__a->__a_value, __pattern, |
| 830 | __gcc_atomic::__to_gcc_order(__order)); |
| 831 | } |
| 832 | |
| 833 | template <typename _Tp> |
| 834 | static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, |
| 835 | memory_order __order) { |
| 836 | return __atomic_fetch_xor(&__a->__a_value, __pattern, |
| 837 | __gcc_atomic::__to_gcc_order(__order)); |
| 838 | } |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 839 | #endif // _LIBCPP_HAS_GCC_ATOMIC_IMP |
Dan Albert | 7b65ace | 2014-08-09 23:51:51 +0000 | [diff] [blame] | 840 | |
Howard Hinnant | dca6e71 | 2010-09-28 17:13:38 +0000 | [diff] [blame] | 841 | template <class _Tp> |
| 842 | inline _LIBCPP_INLINE_VISIBILITY |
| 843 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 844 | kill_dependency(_Tp __y) _NOEXCEPT |
Howard Hinnant | dca6e71 | 2010-09-28 17:13:38 +0000 | [diff] [blame] | 845 | { |
| 846 | return __y; |
| 847 | } |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 848 | |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 849 | #define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE |
| 850 | #define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE |
| 851 | #define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE |
| 852 | #define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE |
| 853 | #define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE |
| 854 | #define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE |
| 855 | #define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE |
| 856 | #define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE |
| 857 | #define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE |
| 858 | #define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE |
| 859 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 860 | // general atomic<T> |
| 861 | |
| 862 | template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> |
| 863 | struct __atomic_base // false |
| 864 | { |
Howard Hinnant | d5eebd6 | 2012-09-16 20:33:09 +0000 | [diff] [blame] | 865 | mutable _Atomic(_Tp) __a_; |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 866 | |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 867 | #if defined(__cpp_lib_atomic_is_always_lock_free) |
| 868 | static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0); |
| 869 | #endif |
| 870 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 871 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 872 | bool is_lock_free() const volatile _NOEXCEPT |
Eric Fiselier | 3fd22c2 | 2015-06-13 00:23:07 +0000 | [diff] [blame] | 873 | { |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 874 | #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) |
Eric Fiselier | 3fd22c2 | 2015-06-13 00:23:07 +0000 | [diff] [blame] | 875 | return __c11_atomic_is_lock_free(sizeof(_Tp)); |
| 876 | #else |
| 877 | return __atomic_is_lock_free(sizeof(_Tp), 0); |
| 878 | #endif |
| 879 | } |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 880 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 881 | bool is_lock_free() const _NOEXCEPT |
Eric Fiselier | 3fd22c2 | 2015-06-13 00:23:07 +0000 | [diff] [blame] | 882 | {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 883 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 884 | void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 885 | {__c11_atomic_store(&__a_, __d, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 886 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 887 | void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 888 | {__c11_atomic_store(&__a_, __d, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 889 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 890 | _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 891 | {return __c11_atomic_load(&__a_, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 892 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 893 | _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 894 | {return __c11_atomic_load(&__a_, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 895 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 896 | operator _Tp() const volatile _NOEXCEPT {return load();} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 897 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 898 | operator _Tp() const _NOEXCEPT {return load();} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 899 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 900 | _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 901 | {return __c11_atomic_exchange(&__a_, __d, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 902 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 903 | _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 904 | {return __c11_atomic_exchange(&__a_, __d, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 905 | _LIBCPP_INLINE_VISIBILITY |
| 906 | bool compare_exchange_weak(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 907 | memory_order __s, memory_order __f) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 908 | {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 909 | _LIBCPP_INLINE_VISIBILITY |
| 910 | bool compare_exchange_weak(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 911 | memory_order __s, memory_order __f) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 912 | {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 913 | _LIBCPP_INLINE_VISIBILITY |
| 914 | bool compare_exchange_strong(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 915 | memory_order __s, memory_order __f) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 916 | {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 917 | _LIBCPP_INLINE_VISIBILITY |
| 918 | bool compare_exchange_strong(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 919 | memory_order __s, memory_order __f) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 920 | {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 921 | _LIBCPP_INLINE_VISIBILITY |
| 922 | bool compare_exchange_weak(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 923 | memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 924 | {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 925 | _LIBCPP_INLINE_VISIBILITY |
| 926 | bool compare_exchange_weak(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 927 | memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 928 | {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 929 | _LIBCPP_INLINE_VISIBILITY |
| 930 | bool compare_exchange_strong(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 931 | memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 932 | {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 933 | _LIBCPP_INLINE_VISIBILITY |
| 934 | bool compare_exchange_strong(_Tp& __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 935 | memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 936 | {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 937 | |
| 938 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3d28422 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 939 | #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
| 940 | __atomic_base() _NOEXCEPT = default; |
| 941 | #else |
| 942 | __atomic_base() _NOEXCEPT : __a_() {} |
| 943 | #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
| 944 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 945 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 946 | _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 947 | #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 948 | __atomic_base(const __atomic_base&) = delete; |
| 949 | __atomic_base& operator=(const __atomic_base&) = delete; |
| 950 | __atomic_base& operator=(const __atomic_base&) volatile = delete; |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 951 | #else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
| 952 | private: |
| 953 | __atomic_base(const __atomic_base&); |
| 954 | __atomic_base& operator=(const __atomic_base&); |
| 955 | __atomic_base& operator=(const __atomic_base&) volatile; |
| 956 | #endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 957 | }; |
| 958 | |
JF Bastien | fdb42c2 | 2016-03-25 15:48:21 +0000 | [diff] [blame] | 959 | #if defined(__cpp_lib_atomic_is_always_lock_free) |
| 960 | template <class _Tp, bool __b> |
| 961 | _LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free; |
| 962 | #endif |
| 963 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 964 | // atomic<Integral> |
| 965 | |
| 966 | template <class _Tp> |
| 967 | struct __atomic_base<_Tp, true> |
| 968 | : public __atomic_base<_Tp, false> |
| 969 | { |
| 970 | typedef __atomic_base<_Tp, false> __base; |
| 971 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3d28422 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 972 | __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 973 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 974 | _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 975 | |
| 976 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 977 | _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 978 | {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 979 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 980 | _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 981 | {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 982 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 983 | _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 984 | {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 985 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 986 | _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 987 | {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 988 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 989 | _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 990 | {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 991 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 992 | _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 993 | {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 994 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 995 | _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 996 | {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 997 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 998 | _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 999 | {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1000 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1001 | _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1002 | {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1003 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1004 | _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1005 | {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1006 | |
| 1007 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1008 | _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1009 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1010 | _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1011 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1012 | _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1013 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1014 | _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1015 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1016 | _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1017 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1018 | _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1019 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1020 | _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1021 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1022 | _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1023 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1024 | _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1025 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1026 | _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1027 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1028 | _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1029 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1030 | _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1031 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1032 | _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1033 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1034 | _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1035 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1036 | _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1037 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1038 | _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1039 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1040 | _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1041 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1042 | _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1043 | }; |
| 1044 | |
| 1045 | // atomic<T> |
| 1046 | |
| 1047 | template <class _Tp> |
| 1048 | struct atomic |
| 1049 | : public __atomic_base<_Tp> |
| 1050 | { |
| 1051 | typedef __atomic_base<_Tp> __base; |
| 1052 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3d28422 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 1053 | atomic() _NOEXCEPT _LIBCPP_DEFAULT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1054 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1055 | _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1056 | |
| 1057 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1058 | _Tp operator=(_Tp __d) volatile _NOEXCEPT |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1059 | {__base::store(__d); return __d;} |
| 1060 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1061 | _Tp operator=(_Tp __d) _NOEXCEPT |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1062 | {__base::store(__d); return __d;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1063 | }; |
| 1064 | |
| 1065 | // atomic<T*> |
| 1066 | |
| 1067 | template <class _Tp> |
| 1068 | struct atomic<_Tp*> |
| 1069 | : public __atomic_base<_Tp*> |
| 1070 | { |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1071 | typedef __atomic_base<_Tp*> __base; |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1072 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3d28422 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 1073 | atomic() _NOEXCEPT _LIBCPP_DEFAULT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1074 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1075 | _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1076 | |
| 1077 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1078 | _Tp* operator=(_Tp* __d) volatile _NOEXCEPT |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1079 | {__base::store(__d); return __d;} |
| 1080 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1081 | _Tp* operator=(_Tp* __d) _NOEXCEPT |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1082 | {__base::store(__d); return __d;} |
| 1083 | |
| 1084 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1085 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1086 | volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1087 | {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1088 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1089 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1090 | {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1091 | _LIBCPP_INLINE_VISIBILITY |
| 1092 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1093 | volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1094 | {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1095 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1096 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1097 | {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1098 | |
| 1099 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1100 | _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1101 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1102 | _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1103 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1104 | _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1105 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1106 | _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1107 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1108 | _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1109 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1110 | _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1111 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1112 | _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1113 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1114 | _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1115 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1116 | _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1117 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1118 | _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1119 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1120 | _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1121 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1122 | _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1123 | }; |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1124 | |
| 1125 | // atomic_is_lock_free |
| 1126 | |
| 1127 | template <class _Tp> |
| 1128 | inline _LIBCPP_INLINE_VISIBILITY |
| 1129 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1130 | atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1131 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1132 | return __o->is_lock_free(); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | template <class _Tp> |
| 1136 | inline _LIBCPP_INLINE_VISIBILITY |
| 1137 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1138 | atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1139 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1140 | return __o->is_lock_free(); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | // atomic_init |
| 1144 | |
| 1145 | template <class _Tp> |
| 1146 | inline _LIBCPP_INLINE_VISIBILITY |
| 1147 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1148 | atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1149 | { |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1150 | __c11_atomic_init(&__o->__a_, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | template <class _Tp> |
| 1154 | inline _LIBCPP_INLINE_VISIBILITY |
| 1155 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1156 | atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1157 | { |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1158 | __c11_atomic_init(&__o->__a_, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | // atomic_store |
| 1162 | |
| 1163 | template <class _Tp> |
| 1164 | inline _LIBCPP_INLINE_VISIBILITY |
| 1165 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1166 | atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1167 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1168 | __o->store(__d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | template <class _Tp> |
| 1172 | inline _LIBCPP_INLINE_VISIBILITY |
| 1173 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1174 | atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1175 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1176 | __o->store(__d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | // atomic_store_explicit |
| 1180 | |
| 1181 | template <class _Tp> |
| 1182 | inline _LIBCPP_INLINE_VISIBILITY |
| 1183 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1184 | atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1185 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1186 | __o->store(__d, __m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | template <class _Tp> |
| 1190 | inline _LIBCPP_INLINE_VISIBILITY |
| 1191 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1192 | atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1193 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1194 | __o->store(__d, __m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | // atomic_load |
| 1198 | |
| 1199 | template <class _Tp> |
| 1200 | inline _LIBCPP_INLINE_VISIBILITY |
| 1201 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1202 | atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1203 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1204 | return __o->load(); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1205 | } |
| 1206 | |
| 1207 | template <class _Tp> |
| 1208 | inline _LIBCPP_INLINE_VISIBILITY |
| 1209 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1210 | atomic_load(const atomic<_Tp>* __o) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1211 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1212 | return __o->load(); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | // atomic_load_explicit |
| 1216 | |
| 1217 | template <class _Tp> |
| 1218 | inline _LIBCPP_INLINE_VISIBILITY |
| 1219 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1220 | atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1221 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1222 | return __o->load(__m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | template <class _Tp> |
| 1226 | inline _LIBCPP_INLINE_VISIBILITY |
| 1227 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1228 | atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1229 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1230 | return __o->load(__m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1231 | } |
| 1232 | |
| 1233 | // atomic_exchange |
| 1234 | |
| 1235 | template <class _Tp> |
| 1236 | inline _LIBCPP_INLINE_VISIBILITY |
| 1237 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1238 | atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1239 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1240 | return __o->exchange(__d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | template <class _Tp> |
| 1244 | inline _LIBCPP_INLINE_VISIBILITY |
| 1245 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1246 | atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1247 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1248 | return __o->exchange(__d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | // atomic_exchange_explicit |
| 1252 | |
| 1253 | template <class _Tp> |
| 1254 | inline _LIBCPP_INLINE_VISIBILITY |
| 1255 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1256 | atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1257 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1258 | return __o->exchange(__d, __m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | template <class _Tp> |
| 1262 | inline _LIBCPP_INLINE_VISIBILITY |
| 1263 | _Tp |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1264 | atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1265 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1266 | return __o->exchange(__d, __m); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
| 1269 | // atomic_compare_exchange_weak |
| 1270 | |
| 1271 | template <class _Tp> |
| 1272 | inline _LIBCPP_INLINE_VISIBILITY |
| 1273 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1274 | atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1275 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1276 | return __o->compare_exchange_weak(*__e, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1277 | } |
| 1278 | |
| 1279 | template <class _Tp> |
| 1280 | inline _LIBCPP_INLINE_VISIBILITY |
| 1281 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1282 | atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1283 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1284 | return __o->compare_exchange_weak(*__e, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | // atomic_compare_exchange_strong |
| 1288 | |
| 1289 | template <class _Tp> |
| 1290 | inline _LIBCPP_INLINE_VISIBILITY |
| 1291 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1292 | atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1293 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1294 | return __o->compare_exchange_strong(*__e, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | template <class _Tp> |
| 1298 | inline _LIBCPP_INLINE_VISIBILITY |
| 1299 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1300 | atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1301 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1302 | return __o->compare_exchange_strong(*__e, __d); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | // atomic_compare_exchange_weak_explicit |
| 1306 | |
| 1307 | template <class _Tp> |
| 1308 | inline _LIBCPP_INLINE_VISIBILITY |
| 1309 | bool |
| 1310 | atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, |
| 1311 | _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1312 | memory_order __s, memory_order __f) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1313 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1314 | return __o->compare_exchange_weak(*__e, __d, __s, __f); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | template <class _Tp> |
| 1318 | inline _LIBCPP_INLINE_VISIBILITY |
| 1319 | bool |
| 1320 | atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1321 | memory_order __s, memory_order __f) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1322 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1323 | return __o->compare_exchange_weak(*__e, __d, __s, __f); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | // atomic_compare_exchange_strong_explicit |
| 1327 | |
| 1328 | template <class _Tp> |
| 1329 | inline _LIBCPP_INLINE_VISIBILITY |
| 1330 | bool |
| 1331 | atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, |
| 1332 | _Tp* __e, _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1333 | memory_order __s, memory_order __f) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1334 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1335 | return __o->compare_exchange_strong(*__e, __d, __s, __f); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1336 | } |
| 1337 | |
| 1338 | template <class _Tp> |
| 1339 | inline _LIBCPP_INLINE_VISIBILITY |
| 1340 | bool |
| 1341 | atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, |
| 1342 | _Tp __d, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1343 | memory_order __s, memory_order __f) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1344 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1345 | return __o->compare_exchange_strong(*__e, __d, __s, __f); |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1348 | // atomic_fetch_add |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1349 | |
| 1350 | template <class _Tp> |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1351 | inline _LIBCPP_INLINE_VISIBILITY |
| 1352 | typename enable_if |
| 1353 | < |
| 1354 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1355 | _Tp |
| 1356 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1357 | atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1358 | { |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1359 | return __o->fetch_add(__op); |
| 1360 | } |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1361 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1362 | template <class _Tp> |
| 1363 | inline _LIBCPP_INLINE_VISIBILITY |
| 1364 | typename enable_if |
| 1365 | < |
| 1366 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1367 | _Tp |
| 1368 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1369 | atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1370 | { |
| 1371 | return __o->fetch_add(__op); |
| 1372 | } |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1373 | |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1374 | template <class _Tp> |
| 1375 | inline _LIBCPP_INLINE_VISIBILITY |
| 1376 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1377 | atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1378 | { |
| 1379 | return __o->fetch_add(__op); |
| 1380 | } |
| 1381 | |
| 1382 | template <class _Tp> |
| 1383 | inline _LIBCPP_INLINE_VISIBILITY |
| 1384 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1385 | atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1386 | { |
| 1387 | return __o->fetch_add(__op); |
| 1388 | } |
| 1389 | |
| 1390 | // atomic_fetch_add_explicit |
| 1391 | |
| 1392 | template <class _Tp> |
| 1393 | inline _LIBCPP_INLINE_VISIBILITY |
| 1394 | typename enable_if |
| 1395 | < |
| 1396 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1397 | _Tp |
| 1398 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1399 | atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1400 | { |
| 1401 | return __o->fetch_add(__op, __m); |
| 1402 | } |
| 1403 | |
| 1404 | template <class _Tp> |
| 1405 | inline _LIBCPP_INLINE_VISIBILITY |
| 1406 | typename enable_if |
| 1407 | < |
| 1408 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1409 | _Tp |
| 1410 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1411 | atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1412 | { |
| 1413 | return __o->fetch_add(__op, __m); |
| 1414 | } |
| 1415 | |
| 1416 | template <class _Tp> |
| 1417 | inline _LIBCPP_INLINE_VISIBILITY |
| 1418 | _Tp* |
| 1419 | atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1420 | memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1421 | { |
| 1422 | return __o->fetch_add(__op, __m); |
| 1423 | } |
| 1424 | |
| 1425 | template <class _Tp> |
| 1426 | inline _LIBCPP_INLINE_VISIBILITY |
| 1427 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1428 | atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1429 | { |
| 1430 | return __o->fetch_add(__op, __m); |
| 1431 | } |
| 1432 | |
| 1433 | // atomic_fetch_sub |
| 1434 | |
| 1435 | template <class _Tp> |
| 1436 | inline _LIBCPP_INLINE_VISIBILITY |
| 1437 | typename enable_if |
| 1438 | < |
| 1439 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1440 | _Tp |
| 1441 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1442 | atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1443 | { |
| 1444 | return __o->fetch_sub(__op); |
| 1445 | } |
| 1446 | |
| 1447 | template <class _Tp> |
| 1448 | inline _LIBCPP_INLINE_VISIBILITY |
| 1449 | typename enable_if |
| 1450 | < |
| 1451 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1452 | _Tp |
| 1453 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1454 | atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1455 | { |
| 1456 | return __o->fetch_sub(__op); |
| 1457 | } |
| 1458 | |
| 1459 | template <class _Tp> |
| 1460 | inline _LIBCPP_INLINE_VISIBILITY |
| 1461 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1462 | atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1463 | { |
| 1464 | return __o->fetch_sub(__op); |
| 1465 | } |
| 1466 | |
| 1467 | template <class _Tp> |
| 1468 | inline _LIBCPP_INLINE_VISIBILITY |
| 1469 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1470 | atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1471 | { |
| 1472 | return __o->fetch_sub(__op); |
| 1473 | } |
| 1474 | |
| 1475 | // atomic_fetch_sub_explicit |
| 1476 | |
| 1477 | template <class _Tp> |
| 1478 | inline _LIBCPP_INLINE_VISIBILITY |
| 1479 | typename enable_if |
| 1480 | < |
| 1481 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1482 | _Tp |
| 1483 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1484 | atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1485 | { |
| 1486 | return __o->fetch_sub(__op, __m); |
| 1487 | } |
| 1488 | |
| 1489 | template <class _Tp> |
| 1490 | inline _LIBCPP_INLINE_VISIBILITY |
| 1491 | typename enable_if |
| 1492 | < |
| 1493 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1494 | _Tp |
| 1495 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1496 | atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1497 | { |
| 1498 | return __o->fetch_sub(__op, __m); |
| 1499 | } |
| 1500 | |
| 1501 | template <class _Tp> |
| 1502 | inline _LIBCPP_INLINE_VISIBILITY |
| 1503 | _Tp* |
| 1504 | atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1505 | memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1506 | { |
| 1507 | return __o->fetch_sub(__op, __m); |
| 1508 | } |
| 1509 | |
| 1510 | template <class _Tp> |
| 1511 | inline _LIBCPP_INLINE_VISIBILITY |
| 1512 | _Tp* |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1513 | atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1514 | { |
| 1515 | return __o->fetch_sub(__op, __m); |
| 1516 | } |
| 1517 | |
| 1518 | // atomic_fetch_and |
| 1519 | |
| 1520 | template <class _Tp> |
| 1521 | inline _LIBCPP_INLINE_VISIBILITY |
| 1522 | typename enable_if |
| 1523 | < |
| 1524 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1525 | _Tp |
| 1526 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1527 | atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1528 | { |
| 1529 | return __o->fetch_and(__op); |
| 1530 | } |
| 1531 | |
| 1532 | template <class _Tp> |
| 1533 | inline _LIBCPP_INLINE_VISIBILITY |
| 1534 | typename enable_if |
| 1535 | < |
| 1536 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1537 | _Tp |
| 1538 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1539 | atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1540 | { |
| 1541 | return __o->fetch_and(__op); |
| 1542 | } |
| 1543 | |
| 1544 | // atomic_fetch_and_explicit |
| 1545 | |
| 1546 | template <class _Tp> |
| 1547 | inline _LIBCPP_INLINE_VISIBILITY |
| 1548 | typename enable_if |
| 1549 | < |
| 1550 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1551 | _Tp |
| 1552 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1553 | atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1554 | { |
| 1555 | return __o->fetch_and(__op, __m); |
| 1556 | } |
| 1557 | |
| 1558 | template <class _Tp> |
| 1559 | inline _LIBCPP_INLINE_VISIBILITY |
| 1560 | typename enable_if |
| 1561 | < |
| 1562 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1563 | _Tp |
| 1564 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1565 | atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1566 | { |
| 1567 | return __o->fetch_and(__op, __m); |
| 1568 | } |
| 1569 | |
| 1570 | // atomic_fetch_or |
| 1571 | |
| 1572 | template <class _Tp> |
| 1573 | inline _LIBCPP_INLINE_VISIBILITY |
| 1574 | typename enable_if |
| 1575 | < |
| 1576 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1577 | _Tp |
| 1578 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1579 | atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1580 | { |
| 1581 | return __o->fetch_or(__op); |
| 1582 | } |
| 1583 | |
| 1584 | template <class _Tp> |
| 1585 | inline _LIBCPP_INLINE_VISIBILITY |
| 1586 | typename enable_if |
| 1587 | < |
| 1588 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1589 | _Tp |
| 1590 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1591 | atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1592 | { |
| 1593 | return __o->fetch_or(__op); |
| 1594 | } |
| 1595 | |
| 1596 | // atomic_fetch_or_explicit |
| 1597 | |
| 1598 | template <class _Tp> |
| 1599 | inline _LIBCPP_INLINE_VISIBILITY |
| 1600 | typename enable_if |
| 1601 | < |
| 1602 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1603 | _Tp |
| 1604 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1605 | atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1606 | { |
| 1607 | return __o->fetch_or(__op, __m); |
| 1608 | } |
| 1609 | |
| 1610 | template <class _Tp> |
| 1611 | inline _LIBCPP_INLINE_VISIBILITY |
| 1612 | typename enable_if |
| 1613 | < |
| 1614 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1615 | _Tp |
| 1616 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1617 | atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1618 | { |
| 1619 | return __o->fetch_or(__op, __m); |
| 1620 | } |
| 1621 | |
| 1622 | // atomic_fetch_xor |
| 1623 | |
| 1624 | template <class _Tp> |
| 1625 | inline _LIBCPP_INLINE_VISIBILITY |
| 1626 | typename enable_if |
| 1627 | < |
| 1628 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1629 | _Tp |
| 1630 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1631 | atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1632 | { |
| 1633 | return __o->fetch_xor(__op); |
| 1634 | } |
| 1635 | |
| 1636 | template <class _Tp> |
| 1637 | inline _LIBCPP_INLINE_VISIBILITY |
| 1638 | typename enable_if |
| 1639 | < |
| 1640 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1641 | _Tp |
| 1642 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1643 | atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1644 | { |
| 1645 | return __o->fetch_xor(__op); |
| 1646 | } |
| 1647 | |
| 1648 | // atomic_fetch_xor_explicit |
| 1649 | |
| 1650 | template <class _Tp> |
| 1651 | inline _LIBCPP_INLINE_VISIBILITY |
| 1652 | typename enable_if |
| 1653 | < |
| 1654 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1655 | _Tp |
| 1656 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1657 | atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1658 | { |
| 1659 | return __o->fetch_xor(__op, __m); |
| 1660 | } |
| 1661 | |
| 1662 | template <class _Tp> |
| 1663 | inline _LIBCPP_INLINE_VISIBILITY |
| 1664 | typename enable_if |
| 1665 | < |
| 1666 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value, |
| 1667 | _Tp |
| 1668 | >::type |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1669 | atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT |
Howard Hinnant | 138f592 | 2010-12-07 20:46:14 +0000 | [diff] [blame] | 1670 | { |
| 1671 | return __o->fetch_xor(__op, __m); |
| 1672 | } |
Howard Hinnant | 7bfaeb8 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1673 | |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1674 | // flag type and operations |
| 1675 | |
| 1676 | typedef struct atomic_flag |
| 1677 | { |
David Chisnall | 26ed3f4 | 2011-12-19 11:44:20 +0000 | [diff] [blame] | 1678 | _Atomic(bool) __a_; |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1679 | |
| 1680 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1681 | bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1682 | {return __c11_atomic_exchange(&__a_, true, __m);} |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1683 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1684 | bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1685 | {return __c11_atomic_exchange(&__a_, true, __m);} |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1686 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1687 | void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1688 | {__c11_atomic_store(&__a_, false, __m);} |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1689 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1690 | void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1691 | {__c11_atomic_store(&__a_, false, __m);} |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1692 | |
| 1693 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3d28422 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 1694 | #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
| 1695 | atomic_flag() _NOEXCEPT = default; |
| 1696 | #else |
| 1697 | atomic_flag() _NOEXCEPT : __a_() {} |
| 1698 | #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS |
| 1699 | |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1700 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | fec26a9 | 2016-05-03 02:12:26 +0000 | [diff] [blame] | 1701 | atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1702 | |
| 1703 | #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
| 1704 | atomic_flag(const atomic_flag&) = delete; |
| 1705 | atomic_flag& operator=(const atomic_flag&) = delete; |
| 1706 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 1707 | #else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
| 1708 | private: |
| 1709 | atomic_flag(const atomic_flag&); |
| 1710 | atomic_flag& operator=(const atomic_flag&); |
| 1711 | atomic_flag& operator=(const atomic_flag&) volatile; |
| 1712 | #endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
| 1713 | } atomic_flag; |
| 1714 | |
| 1715 | inline _LIBCPP_INLINE_VISIBILITY |
| 1716 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1717 | atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1718 | { |
| 1719 | return __o->test_and_set(); |
| 1720 | } |
| 1721 | |
| 1722 | inline _LIBCPP_INLINE_VISIBILITY |
| 1723 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1724 | atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1725 | { |
| 1726 | return __o->test_and_set(); |
| 1727 | } |
| 1728 | |
| 1729 | inline _LIBCPP_INLINE_VISIBILITY |
| 1730 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1731 | atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1732 | { |
| 1733 | return __o->test_and_set(__m); |
| 1734 | } |
| 1735 | |
| 1736 | inline _LIBCPP_INLINE_VISIBILITY |
| 1737 | bool |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1738 | atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1739 | { |
| 1740 | return __o->test_and_set(__m); |
| 1741 | } |
| 1742 | |
| 1743 | inline _LIBCPP_INLINE_VISIBILITY |
| 1744 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1745 | atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1746 | { |
| 1747 | __o->clear(); |
| 1748 | } |
| 1749 | |
| 1750 | inline _LIBCPP_INLINE_VISIBILITY |
| 1751 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1752 | atomic_flag_clear(atomic_flag* __o) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1753 | { |
| 1754 | __o->clear(); |
| 1755 | } |
| 1756 | |
| 1757 | inline _LIBCPP_INLINE_VISIBILITY |
| 1758 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1759 | atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1760 | { |
| 1761 | __o->clear(__m); |
| 1762 | } |
| 1763 | |
| 1764 | inline _LIBCPP_INLINE_VISIBILITY |
| 1765 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1766 | atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1767 | { |
| 1768 | __o->clear(__m); |
| 1769 | } |
| 1770 | |
| 1771 | // fences |
| 1772 | |
| 1773 | inline _LIBCPP_INLINE_VISIBILITY |
| 1774 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1775 | atomic_thread_fence(memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1776 | { |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1777 | __c11_atomic_thread_fence(__m); |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | inline _LIBCPP_INLINE_VISIBILITY |
| 1781 | void |
Howard Hinnant | eee2c14 | 2012-04-11 20:14:21 +0000 | [diff] [blame] | 1782 | atomic_signal_fence(memory_order __m) _NOEXCEPT |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1783 | { |
Richard Smith | 27a4a97 | 2012-04-11 18:55:46 +0000 | [diff] [blame] | 1784 | __c11_atomic_signal_fence(__m); |
Howard Hinnant | 6ac60f8 | 2010-12-08 17:20:28 +0000 | [diff] [blame] | 1785 | } |
| 1786 | |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1787 | // Atomics for standard typedef types |
| 1788 | |
Howard Hinnant | f0af8d9 | 2013-01-04 18:58:50 +0000 | [diff] [blame] | 1789 | typedef atomic<bool> atomic_bool; |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1790 | typedef atomic<char> atomic_char; |
| 1791 | typedef atomic<signed char> atomic_schar; |
| 1792 | typedef atomic<unsigned char> atomic_uchar; |
| 1793 | typedef atomic<short> atomic_short; |
| 1794 | typedef atomic<unsigned short> atomic_ushort; |
| 1795 | typedef atomic<int> atomic_int; |
| 1796 | typedef atomic<unsigned int> atomic_uint; |
| 1797 | typedef atomic<long> atomic_long; |
| 1798 | typedef atomic<unsigned long> atomic_ulong; |
| 1799 | typedef atomic<long long> atomic_llong; |
| 1800 | typedef atomic<unsigned long long> atomic_ullong; |
| 1801 | typedef atomic<char16_t> atomic_char16_t; |
| 1802 | typedef atomic<char32_t> atomic_char32_t; |
| 1803 | typedef atomic<wchar_t> atomic_wchar_t; |
| 1804 | |
| 1805 | typedef atomic<int_least8_t> atomic_int_least8_t; |
| 1806 | typedef atomic<uint_least8_t> atomic_uint_least8_t; |
| 1807 | typedef atomic<int_least16_t> atomic_int_least16_t; |
| 1808 | typedef atomic<uint_least16_t> atomic_uint_least16_t; |
| 1809 | typedef atomic<int_least32_t> atomic_int_least32_t; |
| 1810 | typedef atomic<uint_least32_t> atomic_uint_least32_t; |
| 1811 | typedef atomic<int_least64_t> atomic_int_least64_t; |
| 1812 | typedef atomic<uint_least64_t> atomic_uint_least64_t; |
| 1813 | |
| 1814 | typedef atomic<int_fast8_t> atomic_int_fast8_t; |
| 1815 | typedef atomic<uint_fast8_t> atomic_uint_fast8_t; |
| 1816 | typedef atomic<int_fast16_t> atomic_int_fast16_t; |
| 1817 | typedef atomic<uint_fast16_t> atomic_uint_fast16_t; |
| 1818 | typedef atomic<int_fast32_t> atomic_int_fast32_t; |
| 1819 | typedef atomic<uint_fast32_t> atomic_uint_fast32_t; |
| 1820 | typedef atomic<int_fast64_t> atomic_int_fast64_t; |
| 1821 | typedef atomic<uint_fast64_t> atomic_uint_fast64_t; |
| 1822 | |
Marshall Clow | f710afc | 2016-06-30 15:28:38 +0000 | [diff] [blame^] | 1823 | typedef atomic< int8_t> atomic_int8_t; |
| 1824 | typedef atomic<uint8_t> atomic_uint8_t; |
| 1825 | typedef atomic< int16_t> atomic_int16_t; |
| 1826 | typedef atomic<uint16_t> atomic_uint16_t; |
| 1827 | typedef atomic< int32_t> atomic_int32_t; |
| 1828 | typedef atomic<uint32_t> atomic_uint32_t; |
| 1829 | typedef atomic< int64_t> atomic_int64_t; |
| 1830 | typedef atomic<uint64_t> atomic_uint64_t; |
| 1831 | |
Howard Hinnant | 96e4cd6 | 2010-12-07 23:24:41 +0000 | [diff] [blame] | 1832 | typedef atomic<intptr_t> atomic_intptr_t; |
| 1833 | typedef atomic<uintptr_t> atomic_uintptr_t; |
| 1834 | typedef atomic<size_t> atomic_size_t; |
| 1835 | typedef atomic<ptrdiff_t> atomic_ptrdiff_t; |
| 1836 | typedef atomic<intmax_t> atomic_intmax_t; |
| 1837 | typedef atomic<uintmax_t> atomic_uintmax_t; |
| 1838 | |
Howard Hinnant | f1f066a | 2010-09-29 21:20:03 +0000 | [diff] [blame] | 1839 | #define ATOMIC_FLAG_INIT {false} |
Howard Hinnant | 953c31d | 2010-10-04 18:52:54 +0000 | [diff] [blame] | 1840 | #define ATOMIC_VAR_INIT(__v) {__v} |
| 1841 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 1842 | _LIBCPP_END_NAMESPACE_STD |
| 1843 | |
Howard Hinnant | 71be729 | 2010-09-27 21:17:38 +0000 | [diff] [blame] | 1844 | #endif // _LIBCPP_ATOMIC |