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