atomic revision 296687
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===--------------------------- atomic -----------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is distributed under the University of Illinois Open Source 7227825Stheraven// License. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_ATOMIC 12227825Stheraven#define _LIBCPP_ATOMIC 13227825Stheraven 14227825Stheraven/* 15227825Stheraven atomic synopsis 16227825Stheraven 17227825Stheravennamespace std 18227825Stheraven{ 19227825Stheraven 20227825Stheraven// order and consistency 21227825Stheraven 22227825Stheraventypedef enum memory_order 23227825Stheraven{ 24227825Stheraven memory_order_relaxed, 25227825Stheraven memory_order_consume, // load-consume 26227825Stheraven memory_order_acquire, // load-acquire 27227825Stheraven memory_order_release, // store-release 28227825Stheraven memory_order_acq_rel, // store-release load-acquire 29227825Stheraven memory_order_seq_cst // store-release load-acquire 30227825Stheraven} memory_order; 31227825Stheraven 32234959Stheraventemplate <class T> T kill_dependency(T y) noexcept; 33227825Stheraven 34227825Stheraven// lock-free property 35227825Stheraven 36246468Stheraven#define ATOMIC_BOOL_LOCK_FREE unspecified 37227825Stheraven#define ATOMIC_CHAR_LOCK_FREE unspecified 38227825Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE unspecified 39227825Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE unspecified 40227825Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE unspecified 41227825Stheraven#define ATOMIC_SHORT_LOCK_FREE unspecified 42227825Stheraven#define ATOMIC_INT_LOCK_FREE unspecified 43227825Stheraven#define ATOMIC_LONG_LOCK_FREE unspecified 44227825Stheraven#define ATOMIC_LLONG_LOCK_FREE unspecified 45246468Stheraven#define ATOMIC_POINTER_LOCK_FREE unspecified 46227825Stheraven 47227825Stheraven// flag type and operations 48227825Stheraven 49227825Stheraventypedef struct atomic_flag 50227825Stheraven{ 51234959Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; 52234959Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; 53234959Stheraven void clear(memory_order m = memory_order_seq_cst) volatile noexcept; 54234959Stheraven void clear(memory_order m = memory_order_seq_cst) noexcept; 55234959Stheraven atomic_flag() noexcept = default; 56227825Stheraven atomic_flag(const atomic_flag&) = delete; 57227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 58227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 59227825Stheraven} atomic_flag; 60227825Stheraven 61227825Stheravenbool 62234959Stheraven atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; 63227825Stheraven 64227825Stheravenbool 65234959Stheraven atomic_flag_test_and_set(atomic_flag* obj) noexcept; 66227825Stheraven 67227825Stheravenbool 68227825Stheraven atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, 69234959Stheraven memory_order m) noexcept; 70227825Stheraven 71227825Stheravenbool 72234959Stheraven atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; 73227825Stheraven 74227825Stheravenvoid 75234959Stheraven atomic_flag_clear(volatile atomic_flag* obj) noexcept; 76227825Stheraven 77227825Stheravenvoid 78234959Stheraven atomic_flag_clear(atomic_flag* obj) noexcept; 79227825Stheraven 80227825Stheravenvoid 81234959Stheraven atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; 82227825Stheraven 83227825Stheravenvoid 84234959Stheraven atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; 85227825Stheraven 86227825Stheraven#define ATOMIC_FLAG_INIT see below 87227825Stheraven#define ATOMIC_VAR_INIT(value) see below 88227825Stheraven 89227825Stheraventemplate <class T> 90227825Stheravenstruct atomic 91227825Stheraven{ 92234959Stheraven bool is_lock_free() const volatile noexcept; 93234959Stheraven bool is_lock_free() const noexcept; 94234959Stheraven void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 95234959Stheraven void store(T desr, memory_order m = memory_order_seq_cst) noexcept; 96234959Stheraven T load(memory_order m = memory_order_seq_cst) const volatile noexcept; 97234959Stheraven T load(memory_order m = memory_order_seq_cst) const noexcept; 98234959Stheraven operator T() const volatile noexcept; 99234959Stheraven operator T() const noexcept; 100234959Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 101234959Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; 102227825Stheraven bool compare_exchange_weak(T& expc, T desr, 103234959Stheraven memory_order s, memory_order f) volatile noexcept; 104234959Stheraven bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; 105227825Stheraven bool compare_exchange_strong(T& expc, T desr, 106234959Stheraven memory_order s, memory_order f) volatile noexcept; 107227825Stheraven bool compare_exchange_strong(T& expc, T desr, 108234959Stheraven memory_order s, memory_order f) noexcept; 109227825Stheraven bool compare_exchange_weak(T& expc, T desr, 110234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 111227825Stheraven bool compare_exchange_weak(T& expc, T desr, 112234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 113227825Stheraven bool compare_exchange_strong(T& expc, T desr, 114234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 115227825Stheraven bool compare_exchange_strong(T& expc, T desr, 116234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 117227825Stheraven 118234959Stheraven atomic() noexcept = default; 119234959Stheraven constexpr atomic(T desr) noexcept; 120227825Stheraven atomic(const atomic&) = delete; 121227825Stheraven atomic& operator=(const atomic&) = delete; 122227825Stheraven atomic& operator=(const atomic&) volatile = delete; 123234959Stheraven T operator=(T) volatile noexcept; 124234959Stheraven T operator=(T) noexcept; 125227825Stheraven}; 126227825Stheraven 127227825Stheraventemplate <> 128227825Stheravenstruct atomic<integral> 129227825Stheraven{ 130234959Stheraven bool is_lock_free() const volatile noexcept; 131234959Stheraven bool is_lock_free() const noexcept; 132234959Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; 133234959Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; 134234959Stheraven integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; 135234959Stheraven integral load(memory_order m = memory_order_seq_cst) const noexcept; 136234959Stheraven operator integral() const volatile noexcept; 137234959Stheraven operator integral() const noexcept; 138227825Stheraven integral exchange(integral desr, 139234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 140234959Stheraven integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; 141227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 142234959Stheraven memory_order s, memory_order f) volatile noexcept; 143227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 144234959Stheraven memory_order s, memory_order f) noexcept; 145227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 146234959Stheraven memory_order s, memory_order f) volatile noexcept; 147227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 148234959Stheraven memory_order s, memory_order f) noexcept; 149227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 150234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 151227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 152234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 153227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 154234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 155227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 156234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 157227825Stheraven 158227825Stheraven integral 159234959Stheraven fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 160234959Stheraven integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; 161227825Stheraven integral 162234959Stheraven fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 163234959Stheraven integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; 164227825Stheraven integral 165234959Stheraven fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 166234959Stheraven integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; 167227825Stheraven integral 168234959Stheraven fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 169234959Stheraven integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; 170227825Stheraven integral 171234959Stheraven fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 172234959Stheraven integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; 173227825Stheraven 174234959Stheraven atomic() noexcept = default; 175234959Stheraven constexpr atomic(integral desr) noexcept; 176227825Stheraven atomic(const atomic&) = delete; 177227825Stheraven atomic& operator=(const atomic&) = delete; 178227825Stheraven atomic& operator=(const atomic&) volatile = delete; 179234959Stheraven integral operator=(integral desr) volatile noexcept; 180234959Stheraven integral operator=(integral desr) noexcept; 181227825Stheraven 182234959Stheraven integral operator++(int) volatile noexcept; 183234959Stheraven integral operator++(int) noexcept; 184234959Stheraven integral operator--(int) volatile noexcept; 185234959Stheraven integral operator--(int) noexcept; 186234959Stheraven integral operator++() volatile noexcept; 187234959Stheraven integral operator++() noexcept; 188234959Stheraven integral operator--() volatile noexcept; 189234959Stheraven integral operator--() noexcept; 190234959Stheraven integral operator+=(integral op) volatile noexcept; 191234959Stheraven integral operator+=(integral op) noexcept; 192234959Stheraven integral operator-=(integral op) volatile noexcept; 193234959Stheraven integral operator-=(integral op) noexcept; 194234959Stheraven integral operator&=(integral op) volatile noexcept; 195234959Stheraven integral operator&=(integral op) noexcept; 196234959Stheraven integral operator|=(integral op) volatile noexcept; 197234959Stheraven integral operator|=(integral op) noexcept; 198234959Stheraven integral operator^=(integral op) volatile noexcept; 199234959Stheraven integral operator^=(integral op) noexcept; 200227825Stheraven}; 201227825Stheraven 202227825Stheraventemplate <class T> 203227825Stheravenstruct atomic<T*> 204227825Stheraven{ 205234959Stheraven bool is_lock_free() const volatile noexcept; 206234959Stheraven bool is_lock_free() const noexcept; 207234959Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 208234959Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; 209234959Stheraven T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; 210234959Stheraven T* load(memory_order m = memory_order_seq_cst) const noexcept; 211234959Stheraven operator T*() const volatile noexcept; 212234959Stheraven operator T*() const noexcept; 213234959Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 214234959Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; 215227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 216234959Stheraven memory_order s, memory_order f) volatile noexcept; 217227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 218234959Stheraven memory_order s, memory_order f) noexcept; 219227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 220234959Stheraven memory_order s, memory_order f) volatile noexcept; 221227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 222234959Stheraven memory_order s, memory_order f) noexcept; 223227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 224234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 225227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 226234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 227227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 228234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 229227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 230234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 231234959Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 232234959Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 233234959Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 234234959Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 235227825Stheraven 236234959Stheraven atomic() noexcept = default; 237234959Stheraven constexpr atomic(T* desr) noexcept; 238227825Stheraven atomic(const atomic&) = delete; 239227825Stheraven atomic& operator=(const atomic&) = delete; 240227825Stheraven atomic& operator=(const atomic&) volatile = delete; 241227825Stheraven 242234959Stheraven T* operator=(T*) volatile noexcept; 243234959Stheraven T* operator=(T*) noexcept; 244234959Stheraven T* operator++(int) volatile noexcept; 245234959Stheraven T* operator++(int) noexcept; 246234959Stheraven T* operator--(int) volatile noexcept; 247234959Stheraven T* operator--(int) noexcept; 248234959Stheraven T* operator++() volatile noexcept; 249234959Stheraven T* operator++() noexcept; 250234959Stheraven T* operator--() volatile noexcept; 251234959Stheraven T* operator--() noexcept; 252234959Stheraven T* operator+=(ptrdiff_t op) volatile noexcept; 253234959Stheraven T* operator+=(ptrdiff_t op) noexcept; 254234959Stheraven T* operator-=(ptrdiff_t op) volatile noexcept; 255234959Stheraven T* operator-=(ptrdiff_t op) noexcept; 256227825Stheraven}; 257227825Stheraven 258227825Stheraven 259227825Stheraventemplate <class T> 260227825Stheraven bool 261234959Stheraven atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; 262227825Stheraven 263227825Stheraventemplate <class T> 264227825Stheraven bool 265234959Stheraven atomic_is_lock_free(const atomic<T>* obj) noexcept; 266227825Stheraven 267227825Stheraventemplate <class T> 268227825Stheraven void 269234959Stheraven atomic_init(volatile atomic<T>* obj, T desr) noexcept; 270227825Stheraven 271227825Stheraventemplate <class T> 272227825Stheraven void 273234959Stheraven atomic_init(atomic<T>* obj, T desr) noexcept; 274227825Stheraven 275227825Stheraventemplate <class T> 276227825Stheraven void 277234959Stheraven atomic_store(volatile atomic<T>* obj, T desr) noexcept; 278227825Stheraven 279227825Stheraventemplate <class T> 280227825Stheraven void 281234959Stheraven atomic_store(atomic<T>* obj, T desr) noexcept; 282227825Stheraven 283227825Stheraventemplate <class T> 284227825Stheraven void 285234959Stheraven atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 286227825Stheraven 287227825Stheraventemplate <class T> 288227825Stheraven void 289234959Stheraven atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 290227825Stheraven 291227825Stheraventemplate <class T> 292227825Stheraven T 293234959Stheraven atomic_load(const volatile atomic<T>* obj) noexcept; 294227825Stheraven 295227825Stheraventemplate <class T> 296227825Stheraven T 297234959Stheraven atomic_load(const atomic<T>* obj) noexcept; 298227825Stheraven 299227825Stheraventemplate <class T> 300227825Stheraven T 301234959Stheraven atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; 302227825Stheraven 303227825Stheraventemplate <class T> 304227825Stheraven T 305234959Stheraven atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; 306227825Stheraven 307227825Stheraventemplate <class T> 308227825Stheraven T 309234959Stheraven atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; 310227825Stheraven 311227825Stheraventemplate <class T> 312227825Stheraven T 313234959Stheraven atomic_exchange(atomic<T>* obj, T desr) noexcept; 314227825Stheraven 315227825Stheraventemplate <class T> 316227825Stheraven T 317234959Stheraven atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 318227825Stheraven 319227825Stheraventemplate <class T> 320227825Stheraven T 321234959Stheraven atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 322227825Stheraven 323227825Stheraventemplate <class T> 324227825Stheraven bool 325234959Stheraven atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; 326227825Stheraven 327227825Stheraventemplate <class T> 328227825Stheraven bool 329234959Stheraven atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; 330227825Stheraven 331227825Stheraventemplate <class T> 332227825Stheraven bool 333234959Stheraven atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; 334227825Stheraven 335227825Stheraventemplate <class T> 336227825Stheraven bool 337234959Stheraven atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; 338227825Stheraven 339227825Stheraventemplate <class T> 340227825Stheraven bool 341227825Stheraven atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, 342227825Stheraven T desr, 343234959Stheraven memory_order s, memory_order f) noexcept; 344227825Stheraven 345227825Stheraventemplate <class T> 346227825Stheraven bool 347227825Stheraven atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, 348234959Stheraven memory_order s, memory_order f) noexcept; 349227825Stheraven 350227825Stheraventemplate <class T> 351227825Stheraven bool 352227825Stheraven atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, 353227825Stheraven T* expc, T desr, 354234959Stheraven memory_order s, memory_order f) noexcept; 355227825Stheraven 356227825Stheraventemplate <class T> 357227825Stheraven bool 358227825Stheraven atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, 359227825Stheraven T desr, 360234959Stheraven memory_order s, memory_order f) noexcept; 361227825Stheraven 362227825Stheraventemplate <class Integral> 363227825Stheraven Integral 364234959Stheraven atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; 365227825Stheraven 366227825Stheraventemplate <class Integral> 367227825Stheraven Integral 368234959Stheraven atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; 369227825Stheraven 370227825Stheraventemplate <class Integral> 371227825Stheraven Integral 372227825Stheraven atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, 373234959Stheraven memory_order m) noexcept; 374227825Stheraventemplate <class Integral> 375227825Stheraven Integral 376227825Stheraven atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, 377234959Stheraven memory_order m) noexcept; 378227825Stheraventemplate <class Integral> 379227825Stheraven Integral 380234959Stheraven atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; 381227825Stheraven 382227825Stheraventemplate <class Integral> 383227825Stheraven Integral 384234959Stheraven atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; 385227825Stheraven 386227825Stheraventemplate <class Integral> 387227825Stheraven Integral 388227825Stheraven atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, 389234959Stheraven memory_order m) noexcept; 390227825Stheraventemplate <class Integral> 391227825Stheraven Integral 392227825Stheraven atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, 393234959Stheraven memory_order m) noexcept; 394227825Stheraventemplate <class Integral> 395227825Stheraven Integral 396234959Stheraven atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; 397227825Stheraven 398227825Stheraventemplate <class Integral> 399227825Stheraven Integral 400234959Stheraven atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; 401227825Stheraven 402227825Stheraventemplate <class Integral> 403227825Stheraven Integral 404227825Stheraven atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, 405234959Stheraven memory_order m) noexcept; 406227825Stheraventemplate <class Integral> 407227825Stheraven Integral 408227825Stheraven atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, 409234959Stheraven memory_order m) noexcept; 410227825Stheraventemplate <class Integral> 411227825Stheraven Integral 412234959Stheraven atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; 413227825Stheraven 414227825Stheraventemplate <class Integral> 415227825Stheraven Integral 416234959Stheraven atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; 417227825Stheraven 418227825Stheraventemplate <class Integral> 419227825Stheraven Integral 420227825Stheraven atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, 421234959Stheraven memory_order m) noexcept; 422227825Stheraventemplate <class Integral> 423227825Stheraven Integral 424227825Stheraven atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, 425234959Stheraven memory_order m) noexcept; 426227825Stheraventemplate <class Integral> 427227825Stheraven Integral 428234959Stheraven atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; 429227825Stheraven 430227825Stheraventemplate <class Integral> 431227825Stheraven Integral 432234959Stheraven atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; 433227825Stheraven 434227825Stheraventemplate <class Integral> 435227825Stheraven Integral 436227825Stheraven atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, 437234959Stheraven memory_order m) noexcept; 438227825Stheraventemplate <class Integral> 439227825Stheraven Integral 440227825Stheraven atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, 441234959Stheraven memory_order m) noexcept; 442227825Stheraven 443227825Stheraventemplate <class T> 444227825Stheraven T* 445234959Stheraven atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 446227825Stheraven 447227825Stheraventemplate <class T> 448227825Stheraven T* 449234959Stheraven atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; 450227825Stheraven 451227825Stheraventemplate <class T> 452227825Stheraven T* 453227825Stheraven atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 454234959Stheraven memory_order m) noexcept; 455227825Stheraventemplate <class T> 456227825Stheraven T* 457234959Stheraven atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 458227825Stheraven 459227825Stheraventemplate <class T> 460227825Stheraven T* 461234959Stheraven atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 462227825Stheraven 463227825Stheraventemplate <class T> 464227825Stheraven T* 465234959Stheraven atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; 466227825Stheraven 467227825Stheraventemplate <class T> 468227825Stheraven T* 469227825Stheraven atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 470234959Stheraven memory_order m) noexcept; 471227825Stheraventemplate <class T> 472227825Stheraven T* 473234959Stheraven atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 474227825Stheraven 475227825Stheraven// Atomics for standard typedef types 476227825Stheraven 477246468Stheraventypedef atomic<bool> atomic_bool; 478227825Stheraventypedef atomic<char> atomic_char; 479227825Stheraventypedef atomic<signed char> atomic_schar; 480227825Stheraventypedef atomic<unsigned char> atomic_uchar; 481227825Stheraventypedef atomic<short> atomic_short; 482227825Stheraventypedef atomic<unsigned short> atomic_ushort; 483227825Stheraventypedef atomic<int> atomic_int; 484227825Stheraventypedef atomic<unsigned int> atomic_uint; 485227825Stheraventypedef atomic<long> atomic_long; 486227825Stheraventypedef atomic<unsigned long> atomic_ulong; 487227825Stheraventypedef atomic<long long> atomic_llong; 488227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 489227825Stheraventypedef atomic<char16_t> atomic_char16_t; 490227825Stheraventypedef atomic<char32_t> atomic_char32_t; 491227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 492227825Stheraven 493227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 494227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 495227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 496227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 497227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 498227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 499227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 500227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 501227825Stheraven 502227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 503227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 504227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 505227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 506227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 507227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 508227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 509227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 510227825Stheraven 511227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 512227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 513227825Stheraventypedef atomic<size_t> atomic_size_t; 514227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 515227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 516227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 517227825Stheraven 518227825Stheraven// fences 519227825Stheraven 520234959Stheravenvoid atomic_thread_fence(memory_order m) noexcept; 521234959Stheravenvoid atomic_signal_fence(memory_order m) noexcept; 522227825Stheraven 523227825Stheraven} // std 524227825Stheraven 525227825Stheraven*/ 526227825Stheraven 527227825Stheraven#include <__config> 528227825Stheraven#include <cstddef> 529227825Stheraven#include <cstdint> 530227825Stheraven#include <type_traits> 531227825Stheraven 532227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 533227825Stheraven#pragma GCC system_header 534227825Stheraven#endif 535227825Stheraven 536276792Sdim#ifdef _LIBCPP_HAS_NO_THREADS 537276792Sdim#error <atomic> is not supported on this single threaded system 538276792Sdim#else // !_LIBCPP_HAS_NO_THREADS 539276792Sdim 540227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 541227825Stheraven 542276792Sdim#if !__has_feature(cxx_atomic) && _GNUC_VER < 407 543227825Stheraven#error <atomic> is not implemented 544227825Stheraven#else 545227825Stheraven 546227825Stheraventypedef enum memory_order 547227825Stheraven{ 548227825Stheraven memory_order_relaxed, memory_order_consume, memory_order_acquire, 549227825Stheraven memory_order_release, memory_order_acq_rel, memory_order_seq_cst 550227825Stheraven} memory_order; 551227825Stheraven 552276792Sdim#if _GNUC_VER >= 407 553276792Sdimnamespace __gcc_atomic { 554288943Sdimtemplate <typename _Tp> 555276792Sdimstruct __gcc_atomic_t { 556296687Sdim 557296687Sdim#if _GNUC_VER >= 501 558296687Sdim static_assert(is_trivially_copyable<_Tp>::value, 559296687Sdim "std::atomic<Tp> requires that 'Tp' be a trivially copyable type"); 560296687Sdim#endif 561296687Sdim 562296687Sdim _LIBCPP_INLINE_VISIBILITY 563296687Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 564296687Sdim __gcc_atomic_t() _NOEXCEPT = default; 565296687Sdim#else 566296687Sdim __gcc_atomic_t() _NOEXCEPT : __a_value() {} 567296687Sdim#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 568288943Sdim _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT 569288943Sdim : __a_value(value) {} 570288943Sdim _Tp __a_value; 571276792Sdim}; 572276792Sdim#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> 573276792Sdim 574288943Sdimtemplate <typename _Tp> _Tp __create(); 575276792Sdim 576288943Sdimtemplate <typename _Tp, typename _Td> 577288943Sdimtypename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type 578276792Sdim __test_atomic_assignable(int); 579288943Sdimtemplate <typename _Tp, typename _Up> 580276792Sdim__two __test_atomic_assignable(...); 581276792Sdim 582288943Sdimtemplate <typename _Tp, typename _Td> 583276792Sdimstruct __can_assign { 584276792Sdim static const bool value = 585288943Sdim sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); 586276792Sdim}; 587276792Sdim 588296687Sdimstatic inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) { 589276792Sdim // Avoid switch statement to make this a constexpr. 590276792Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 591276792Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 592276792Sdim (__order == memory_order_release ? __ATOMIC_RELEASE: 593276792Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 594276792Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: 595276792Sdim __ATOMIC_CONSUME)))); 596276792Sdim} 597276792Sdim 598296687Sdimstatic inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) { 599288943Sdim // Avoid switch statement to make this a constexpr. 600288943Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 601288943Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 602288943Sdim (__order == memory_order_release ? __ATOMIC_RELAXED: 603288943Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 604288943Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE: 605288943Sdim __ATOMIC_CONSUME)))); 606288943Sdim} 607288943Sdim 608276792Sdim} // namespace __gcc_atomic 609276792Sdim 610276792Sdimtemplate <typename _Tp> 611276792Sdimstatic inline 612276792Sdimtypename enable_if< 613276792Sdim __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type 614276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 615276792Sdim __a->__a_value = __val; 616276792Sdim} 617276792Sdim 618276792Sdimtemplate <typename _Tp> 619276792Sdimstatic inline 620276792Sdimtypename enable_if< 621276792Sdim !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && 622276792Sdim __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type 623276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 624276792Sdim // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because 625276792Sdim // the default operator= in an object is not volatile, a byte-by-byte copy 626276792Sdim // is required. 627276792Sdim volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); 628276792Sdim volatile char* end = to + sizeof(_Tp); 629276792Sdim char* from = reinterpret_cast<char*>(&__val); 630276792Sdim while (to != end) { 631276792Sdim *to++ = *from++; 632276792Sdim } 633276792Sdim} 634276792Sdim 635276792Sdimtemplate <typename _Tp> 636276792Sdimstatic inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { 637276792Sdim __a->__a_value = __val; 638276792Sdim} 639276792Sdim 640276792Sdimstatic inline void __c11_atomic_thread_fence(memory_order __order) { 641276792Sdim __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); 642276792Sdim} 643276792Sdim 644276792Sdimstatic inline void __c11_atomic_signal_fence(memory_order __order) { 645276792Sdim __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); 646276792Sdim} 647276792Sdim 648276792Sdimtemplate <typename _Tp> 649276792Sdimstatic inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, 650276792Sdim memory_order __order) { 651276792Sdim return __atomic_store(&__a->__a_value, &__val, 652276792Sdim __gcc_atomic::__to_gcc_order(__order)); 653276792Sdim} 654276792Sdim 655276792Sdimtemplate <typename _Tp> 656276792Sdimstatic inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, 657276792Sdim memory_order __order) { 658288943Sdim __atomic_store(&__a->__a_value, &__val, 659288943Sdim __gcc_atomic::__to_gcc_order(__order)); 660276792Sdim} 661276792Sdim 662276792Sdimtemplate <typename _Tp> 663276792Sdimstatic inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, 664276792Sdim memory_order __order) { 665276792Sdim _Tp __ret; 666276792Sdim __atomic_load(&__a->__a_value, &__ret, 667276792Sdim __gcc_atomic::__to_gcc_order(__order)); 668276792Sdim return __ret; 669276792Sdim} 670276792Sdim 671276792Sdimtemplate <typename _Tp> 672276792Sdimstatic inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { 673276792Sdim _Tp __ret; 674276792Sdim __atomic_load(&__a->__a_value, &__ret, 675276792Sdim __gcc_atomic::__to_gcc_order(__order)); 676276792Sdim return __ret; 677276792Sdim} 678276792Sdim 679276792Sdimtemplate <typename _Tp> 680276792Sdimstatic inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, 681276792Sdim _Tp __value, memory_order __order) { 682276792Sdim _Tp __ret; 683276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 684276792Sdim __gcc_atomic::__to_gcc_order(__order)); 685276792Sdim return __ret; 686276792Sdim} 687276792Sdim 688276792Sdimtemplate <typename _Tp> 689276792Sdimstatic inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, 690276792Sdim memory_order __order) { 691276792Sdim _Tp __ret; 692276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 693276792Sdim __gcc_atomic::__to_gcc_order(__order)); 694276792Sdim return __ret; 695276792Sdim} 696276792Sdim 697276792Sdimtemplate <typename _Tp> 698276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 699276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 700276792Sdim memory_order __success, memory_order __failure) { 701276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 702276792Sdim false, 703276792Sdim __gcc_atomic::__to_gcc_order(__success), 704288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 705276792Sdim} 706276792Sdim 707276792Sdimtemplate <typename _Tp> 708276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 709276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 710276792Sdim memory_order __failure) { 711276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 712276792Sdim false, 713276792Sdim __gcc_atomic::__to_gcc_order(__success), 714288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 715276792Sdim} 716276792Sdim 717276792Sdimtemplate <typename _Tp> 718276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 719276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 720276792Sdim memory_order __success, memory_order __failure) { 721276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 722276792Sdim true, 723276792Sdim __gcc_atomic::__to_gcc_order(__success), 724288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 725276792Sdim} 726276792Sdim 727276792Sdimtemplate <typename _Tp> 728276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 729276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 730276792Sdim memory_order __failure) { 731276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 732276792Sdim true, 733276792Sdim __gcc_atomic::__to_gcc_order(__success), 734288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 735276792Sdim} 736276792Sdim 737276792Sdimtemplate <typename _Tp> 738276792Sdimstruct __skip_amt { enum {value = 1}; }; 739276792Sdim 740276792Sdimtemplate <typename _Tp> 741276792Sdimstruct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; 742276792Sdim 743276792Sdim// FIXME: Haven't figured out what the spec says about using arrays with 744276792Sdim// atomic_fetch_add. Force a failure rather than creating bad behavior. 745276792Sdimtemplate <typename _Tp> 746276792Sdimstruct __skip_amt<_Tp[]> { }; 747276792Sdimtemplate <typename _Tp, int n> 748276792Sdimstruct __skip_amt<_Tp[n]> { }; 749276792Sdim 750276792Sdimtemplate <typename _Tp, typename _Td> 751276792Sdimstatic inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, 752276792Sdim _Td __delta, memory_order __order) { 753276792Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 754276792Sdim __gcc_atomic::__to_gcc_order(__order)); 755276792Sdim} 756276792Sdim 757276792Sdimtemplate <typename _Tp, typename _Td> 758276792Sdimstatic inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, 759276792Sdim memory_order __order) { 760276792Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 761276792Sdim __gcc_atomic::__to_gcc_order(__order)); 762276792Sdim} 763276792Sdim 764276792Sdimtemplate <typename _Tp, typename _Td> 765276792Sdimstatic inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, 766276792Sdim _Td __delta, memory_order __order) { 767276792Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 768276792Sdim __gcc_atomic::__to_gcc_order(__order)); 769276792Sdim} 770276792Sdim 771276792Sdimtemplate <typename _Tp, typename _Td> 772276792Sdimstatic inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, 773276792Sdim memory_order __order) { 774276792Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 775276792Sdim __gcc_atomic::__to_gcc_order(__order)); 776276792Sdim} 777276792Sdim 778276792Sdimtemplate <typename _Tp> 779276792Sdimstatic inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, 780276792Sdim _Tp __pattern, memory_order __order) { 781276792Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 782276792Sdim __gcc_atomic::__to_gcc_order(__order)); 783276792Sdim} 784276792Sdim 785276792Sdimtemplate <typename _Tp> 786276792Sdimstatic inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, 787276792Sdim _Tp __pattern, memory_order __order) { 788276792Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 789276792Sdim __gcc_atomic::__to_gcc_order(__order)); 790276792Sdim} 791276792Sdim 792276792Sdimtemplate <typename _Tp> 793276792Sdimstatic inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, 794276792Sdim _Tp __pattern, memory_order __order) { 795276792Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 796276792Sdim __gcc_atomic::__to_gcc_order(__order)); 797276792Sdim} 798276792Sdim 799276792Sdimtemplate <typename _Tp> 800276792Sdimstatic inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, 801276792Sdim memory_order __order) { 802276792Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 803276792Sdim __gcc_atomic::__to_gcc_order(__order)); 804276792Sdim} 805276792Sdim 806276792Sdimtemplate <typename _Tp> 807276792Sdimstatic inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, 808276792Sdim _Tp __pattern, memory_order __order) { 809276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 810276792Sdim __gcc_atomic::__to_gcc_order(__order)); 811276792Sdim} 812276792Sdim 813276792Sdimtemplate <typename _Tp> 814276792Sdimstatic inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, 815276792Sdim memory_order __order) { 816276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 817276792Sdim __gcc_atomic::__to_gcc_order(__order)); 818276792Sdim} 819276792Sdim#endif // _GNUC_VER >= 407 820276792Sdim 821227825Stheraventemplate <class _Tp> 822227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 823227825Stheraven_Tp 824234959Stheravenkill_dependency(_Tp __y) _NOEXCEPT 825227825Stheraven{ 826227825Stheraven return __y; 827227825Stheraven} 828227825Stheraven 829227825Stheraven// general atomic<T> 830227825Stheraven 831227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> 832227825Stheravenstruct __atomic_base // false 833227825Stheraven{ 834241900Sdim mutable _Atomic(_Tp) __a_; 835227825Stheraven 836227825Stheraven _LIBCPP_INLINE_VISIBILITY 837234959Stheraven bool is_lock_free() const volatile _NOEXCEPT 838288943Sdim { 839288943Sdim#if __has_feature(cxx_atomic) 840288943Sdim return __c11_atomic_is_lock_free(sizeof(_Tp)); 841288943Sdim#else 842288943Sdim return __atomic_is_lock_free(sizeof(_Tp), 0); 843288943Sdim#endif 844288943Sdim } 845227825Stheraven _LIBCPP_INLINE_VISIBILITY 846234959Stheraven bool is_lock_free() const _NOEXCEPT 847288943Sdim {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} 848227825Stheraven _LIBCPP_INLINE_VISIBILITY 849234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 850234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 851227825Stheraven _LIBCPP_INLINE_VISIBILITY 852234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 853234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 854227825Stheraven _LIBCPP_INLINE_VISIBILITY 855234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 856234959Stheraven {return __c11_atomic_load(&__a_, __m);} 857227825Stheraven _LIBCPP_INLINE_VISIBILITY 858234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 859234959Stheraven {return __c11_atomic_load(&__a_, __m);} 860227825Stheraven _LIBCPP_INLINE_VISIBILITY 861234959Stheraven operator _Tp() const volatile _NOEXCEPT {return load();} 862227825Stheraven _LIBCPP_INLINE_VISIBILITY 863234959Stheraven operator _Tp() const _NOEXCEPT {return load();} 864227825Stheraven _LIBCPP_INLINE_VISIBILITY 865234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 866234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 867227825Stheraven _LIBCPP_INLINE_VISIBILITY 868234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 869234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 870227825Stheraven _LIBCPP_INLINE_VISIBILITY 871227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 872234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 873234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 874227825Stheraven _LIBCPP_INLINE_VISIBILITY 875227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 876234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 877234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 878227825Stheraven _LIBCPP_INLINE_VISIBILITY 879227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 880234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 881234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 882227825Stheraven _LIBCPP_INLINE_VISIBILITY 883227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 884234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 885234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 886227825Stheraven _LIBCPP_INLINE_VISIBILITY 887227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 888234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 889234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 890227825Stheraven _LIBCPP_INLINE_VISIBILITY 891227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 892234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 893234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 894227825Stheraven _LIBCPP_INLINE_VISIBILITY 895227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 896234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 897234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 898227825Stheraven _LIBCPP_INLINE_VISIBILITY 899227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 900234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 901234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 902227825Stheraven 903227825Stheraven _LIBCPP_INLINE_VISIBILITY 904253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 905253146Stheraven __atomic_base() _NOEXCEPT = default; 906253146Stheraven#else 907253146Stheraven __atomic_base() _NOEXCEPT : __a_() {} 908253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 909253146Stheraven 910227825Stheraven _LIBCPP_INLINE_VISIBILITY 911234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} 912227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 913227825Stheraven __atomic_base(const __atomic_base&) = delete; 914227825Stheraven __atomic_base& operator=(const __atomic_base&) = delete; 915227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile = delete; 916227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 917227825Stheravenprivate: 918227825Stheraven __atomic_base(const __atomic_base&); 919227825Stheraven __atomic_base& operator=(const __atomic_base&); 920227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile; 921227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 922227825Stheraven}; 923227825Stheraven 924227825Stheraven// atomic<Integral> 925227825Stheraven 926227825Stheraventemplate <class _Tp> 927227825Stheravenstruct __atomic_base<_Tp, true> 928227825Stheraven : public __atomic_base<_Tp, false> 929227825Stheraven{ 930227825Stheraven typedef __atomic_base<_Tp, false> __base; 931227825Stheraven _LIBCPP_INLINE_VISIBILITY 932253146Stheraven __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT 933227825Stheraven _LIBCPP_INLINE_VISIBILITY 934234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 935227825Stheraven 936227825Stheraven _LIBCPP_INLINE_VISIBILITY 937234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 938234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 939227825Stheraven _LIBCPP_INLINE_VISIBILITY 940234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 941234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 942227825Stheraven _LIBCPP_INLINE_VISIBILITY 943234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 944234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 945227825Stheraven _LIBCPP_INLINE_VISIBILITY 946234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 947234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 948227825Stheraven _LIBCPP_INLINE_VISIBILITY 949234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 950234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 951227825Stheraven _LIBCPP_INLINE_VISIBILITY 952234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 953234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 954227825Stheraven _LIBCPP_INLINE_VISIBILITY 955234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 956234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 957227825Stheraven _LIBCPP_INLINE_VISIBILITY 958234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 959234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 960227825Stheraven _LIBCPP_INLINE_VISIBILITY 961234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 962234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 963227825Stheraven _LIBCPP_INLINE_VISIBILITY 964234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 965234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 966227825Stheraven 967227825Stheraven _LIBCPP_INLINE_VISIBILITY 968234959Stheraven _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 969227825Stheraven _LIBCPP_INLINE_VISIBILITY 970234959Stheraven _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 971227825Stheraven _LIBCPP_INLINE_VISIBILITY 972234959Stheraven _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 973227825Stheraven _LIBCPP_INLINE_VISIBILITY 974234959Stheraven _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 975227825Stheraven _LIBCPP_INLINE_VISIBILITY 976234959Stheraven _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 977227825Stheraven _LIBCPP_INLINE_VISIBILITY 978234959Stheraven _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 979227825Stheraven _LIBCPP_INLINE_VISIBILITY 980234959Stheraven _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 981227825Stheraven _LIBCPP_INLINE_VISIBILITY 982234959Stheraven _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 983227825Stheraven _LIBCPP_INLINE_VISIBILITY 984234959Stheraven _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 985227825Stheraven _LIBCPP_INLINE_VISIBILITY 986234959Stheraven _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 987227825Stheraven _LIBCPP_INLINE_VISIBILITY 988234959Stheraven _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 989227825Stheraven _LIBCPP_INLINE_VISIBILITY 990234959Stheraven _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 991227825Stheraven _LIBCPP_INLINE_VISIBILITY 992234959Stheraven _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 993227825Stheraven _LIBCPP_INLINE_VISIBILITY 994234959Stheraven _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 995227825Stheraven _LIBCPP_INLINE_VISIBILITY 996234959Stheraven _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 997227825Stheraven _LIBCPP_INLINE_VISIBILITY 998234959Stheraven _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 999227825Stheraven _LIBCPP_INLINE_VISIBILITY 1000234959Stheraven _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 1001227825Stheraven _LIBCPP_INLINE_VISIBILITY 1002234959Stheraven _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} 1003227825Stheraven}; 1004227825Stheraven 1005227825Stheraven// atomic<T> 1006227825Stheraven 1007227825Stheraventemplate <class _Tp> 1008227825Stheravenstruct atomic 1009227825Stheraven : public __atomic_base<_Tp> 1010227825Stheraven{ 1011227825Stheraven typedef __atomic_base<_Tp> __base; 1012227825Stheraven _LIBCPP_INLINE_VISIBILITY 1013253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1014227825Stheraven _LIBCPP_INLINE_VISIBILITY 1015234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 1016227825Stheraven 1017227825Stheraven _LIBCPP_INLINE_VISIBILITY 1018234959Stheraven _Tp operator=(_Tp __d) volatile _NOEXCEPT 1019227825Stheraven {__base::store(__d); return __d;} 1020227825Stheraven _LIBCPP_INLINE_VISIBILITY 1021234959Stheraven _Tp operator=(_Tp __d) _NOEXCEPT 1022227825Stheraven {__base::store(__d); return __d;} 1023227825Stheraven}; 1024227825Stheraven 1025227825Stheraven// atomic<T*> 1026227825Stheraven 1027227825Stheraventemplate <class _Tp> 1028227825Stheravenstruct atomic<_Tp*> 1029227825Stheraven : public __atomic_base<_Tp*> 1030227825Stheraven{ 1031227825Stheraven typedef __atomic_base<_Tp*> __base; 1032227825Stheraven _LIBCPP_INLINE_VISIBILITY 1033253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1034227825Stheraven _LIBCPP_INLINE_VISIBILITY 1035234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 1036227825Stheraven 1037227825Stheraven _LIBCPP_INLINE_VISIBILITY 1038234959Stheraven _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 1039227825Stheraven {__base::store(__d); return __d;} 1040227825Stheraven _LIBCPP_INLINE_VISIBILITY 1041234959Stheraven _Tp* operator=(_Tp* __d) _NOEXCEPT 1042227825Stheraven {__base::store(__d); return __d;} 1043227825Stheraven 1044227825Stheraven _LIBCPP_INLINE_VISIBILITY 1045227825Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1046234959Stheraven volatile _NOEXCEPT 1047234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1048227825Stheraven _LIBCPP_INLINE_VISIBILITY 1049234959Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1050234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1051227825Stheraven _LIBCPP_INLINE_VISIBILITY 1052227825Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1053234959Stheraven volatile _NOEXCEPT 1054234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1055227825Stheraven _LIBCPP_INLINE_VISIBILITY 1056234959Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1057234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1058227825Stheraven 1059227825Stheraven _LIBCPP_INLINE_VISIBILITY 1060234959Stheraven _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 1061227825Stheraven _LIBCPP_INLINE_VISIBILITY 1062234959Stheraven _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 1063227825Stheraven _LIBCPP_INLINE_VISIBILITY 1064234959Stheraven _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 1065227825Stheraven _LIBCPP_INLINE_VISIBILITY 1066234959Stheraven _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 1067227825Stheraven _LIBCPP_INLINE_VISIBILITY 1068234959Stheraven _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 1069227825Stheraven _LIBCPP_INLINE_VISIBILITY 1070234959Stheraven _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 1071227825Stheraven _LIBCPP_INLINE_VISIBILITY 1072234959Stheraven _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 1073227825Stheraven _LIBCPP_INLINE_VISIBILITY 1074234959Stheraven _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 1075227825Stheraven _LIBCPP_INLINE_VISIBILITY 1076234959Stheraven _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 1077227825Stheraven _LIBCPP_INLINE_VISIBILITY 1078234959Stheraven _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 1079227825Stheraven _LIBCPP_INLINE_VISIBILITY 1080234959Stheraven _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 1081227825Stheraven _LIBCPP_INLINE_VISIBILITY 1082234959Stheraven _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 1083227825Stheraven}; 1084227825Stheraven 1085227825Stheraven// atomic_is_lock_free 1086227825Stheraven 1087227825Stheraventemplate <class _Tp> 1088227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1089227825Stheravenbool 1090234959Stheravenatomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT 1091227825Stheraven{ 1092227825Stheraven return __o->is_lock_free(); 1093227825Stheraven} 1094227825Stheraven 1095227825Stheraventemplate <class _Tp> 1096227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1097227825Stheravenbool 1098234959Stheravenatomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT 1099227825Stheraven{ 1100227825Stheraven return __o->is_lock_free(); 1101227825Stheraven} 1102227825Stheraven 1103227825Stheraven// atomic_init 1104227825Stheraven 1105227825Stheraventemplate <class _Tp> 1106227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1107227825Stheravenvoid 1108234959Stheravenatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1109227825Stheraven{ 1110234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1111227825Stheraven} 1112227825Stheraven 1113227825Stheraventemplate <class _Tp> 1114227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1115227825Stheravenvoid 1116234959Stheravenatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1117227825Stheraven{ 1118234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1119227825Stheraven} 1120227825Stheraven 1121227825Stheraven// atomic_store 1122227825Stheraven 1123227825Stheraventemplate <class _Tp> 1124227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1125227825Stheravenvoid 1126234959Stheravenatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1127227825Stheraven{ 1128227825Stheraven __o->store(__d); 1129227825Stheraven} 1130227825Stheraven 1131227825Stheraventemplate <class _Tp> 1132227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1133227825Stheravenvoid 1134234959Stheravenatomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1135227825Stheraven{ 1136227825Stheraven __o->store(__d); 1137227825Stheraven} 1138227825Stheraven 1139227825Stheraven// atomic_store_explicit 1140227825Stheraven 1141227825Stheraventemplate <class _Tp> 1142227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1143227825Stheravenvoid 1144234959Stheravenatomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1145227825Stheraven{ 1146227825Stheraven __o->store(__d, __m); 1147227825Stheraven} 1148227825Stheraven 1149227825Stheraventemplate <class _Tp> 1150227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1151227825Stheravenvoid 1152234959Stheravenatomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1153227825Stheraven{ 1154227825Stheraven __o->store(__d, __m); 1155227825Stheraven} 1156227825Stheraven 1157227825Stheraven// atomic_load 1158227825Stheraven 1159227825Stheraventemplate <class _Tp> 1160227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1161227825Stheraven_Tp 1162234959Stheravenatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 1163227825Stheraven{ 1164227825Stheraven return __o->load(); 1165227825Stheraven} 1166227825Stheraven 1167227825Stheraventemplate <class _Tp> 1168227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1169227825Stheraven_Tp 1170234959Stheravenatomic_load(const atomic<_Tp>* __o) _NOEXCEPT 1171227825Stheraven{ 1172227825Stheraven return __o->load(); 1173227825Stheraven} 1174227825Stheraven 1175227825Stheraven// atomic_load_explicit 1176227825Stheraven 1177227825Stheraventemplate <class _Tp> 1178227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1179227825Stheraven_Tp 1180234959Stheravenatomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1181227825Stheraven{ 1182227825Stheraven return __o->load(__m); 1183227825Stheraven} 1184227825Stheraven 1185227825Stheraventemplate <class _Tp> 1186227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1187227825Stheraven_Tp 1188234959Stheravenatomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1189227825Stheraven{ 1190227825Stheraven return __o->load(__m); 1191227825Stheraven} 1192227825Stheraven 1193227825Stheraven// atomic_exchange 1194227825Stheraven 1195227825Stheraventemplate <class _Tp> 1196227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1197227825Stheraven_Tp 1198234959Stheravenatomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1199227825Stheraven{ 1200227825Stheraven return __o->exchange(__d); 1201227825Stheraven} 1202227825Stheraven 1203227825Stheraventemplate <class _Tp> 1204227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1205227825Stheraven_Tp 1206234959Stheravenatomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1207227825Stheraven{ 1208227825Stheraven return __o->exchange(__d); 1209227825Stheraven} 1210227825Stheraven 1211227825Stheraven// atomic_exchange_explicit 1212227825Stheraven 1213227825Stheraventemplate <class _Tp> 1214227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1215227825Stheraven_Tp 1216234959Stheravenatomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1217227825Stheraven{ 1218227825Stheraven return __o->exchange(__d, __m); 1219227825Stheraven} 1220227825Stheraven 1221227825Stheraventemplate <class _Tp> 1222227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1223227825Stheraven_Tp 1224234959Stheravenatomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1225227825Stheraven{ 1226227825Stheraven return __o->exchange(__d, __m); 1227227825Stheraven} 1228227825Stheraven 1229227825Stheraven// atomic_compare_exchange_weak 1230227825Stheraven 1231227825Stheraventemplate <class _Tp> 1232227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1233227825Stheravenbool 1234234959Stheravenatomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1235227825Stheraven{ 1236227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1237227825Stheraven} 1238227825Stheraven 1239227825Stheraventemplate <class _Tp> 1240227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1241227825Stheravenbool 1242234959Stheravenatomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1243227825Stheraven{ 1244227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1245227825Stheraven} 1246227825Stheraven 1247227825Stheraven// atomic_compare_exchange_strong 1248227825Stheraven 1249227825Stheraventemplate <class _Tp> 1250227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1251227825Stheravenbool 1252234959Stheravenatomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1253227825Stheraven{ 1254227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1255227825Stheraven} 1256227825Stheraven 1257227825Stheraventemplate <class _Tp> 1258227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1259227825Stheravenbool 1260234959Stheravenatomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1261227825Stheraven{ 1262227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1263227825Stheraven} 1264227825Stheraven 1265227825Stheraven// atomic_compare_exchange_weak_explicit 1266227825Stheraven 1267227825Stheraventemplate <class _Tp> 1268227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1269227825Stheravenbool 1270227825Stheravenatomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, 1271227825Stheraven _Tp __d, 1272234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1273227825Stheraven{ 1274227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1275227825Stheraven} 1276227825Stheraven 1277227825Stheraventemplate <class _Tp> 1278227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1279227825Stheravenbool 1280227825Stheravenatomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, 1281234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1282227825Stheraven{ 1283227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1284227825Stheraven} 1285227825Stheraven 1286227825Stheraven// atomic_compare_exchange_strong_explicit 1287227825Stheraven 1288227825Stheraventemplate <class _Tp> 1289227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1290227825Stheravenbool 1291227825Stheravenatomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, 1292227825Stheraven _Tp* __e, _Tp __d, 1293234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1294227825Stheraven{ 1295227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1296227825Stheraven} 1297227825Stheraven 1298227825Stheraventemplate <class _Tp> 1299227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1300227825Stheravenbool 1301227825Stheravenatomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, 1302227825Stheraven _Tp __d, 1303234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1304227825Stheraven{ 1305227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1306227825Stheraven} 1307227825Stheraven 1308227825Stheraven// atomic_fetch_add 1309227825Stheraven 1310227825Stheraventemplate <class _Tp> 1311227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1312227825Stheraventypename enable_if 1313227825Stheraven< 1314227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1315227825Stheraven _Tp 1316227825Stheraven>::type 1317234959Stheravenatomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1318227825Stheraven{ 1319227825Stheraven return __o->fetch_add(__op); 1320227825Stheraven} 1321227825Stheraven 1322227825Stheraventemplate <class _Tp> 1323227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1324227825Stheraventypename enable_if 1325227825Stheraven< 1326227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1327227825Stheraven _Tp 1328227825Stheraven>::type 1329234959Stheravenatomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1330227825Stheraven{ 1331227825Stheraven return __o->fetch_add(__op); 1332227825Stheraven} 1333227825Stheraven 1334227825Stheraventemplate <class _Tp> 1335227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1336227825Stheraven_Tp* 1337234959Stheravenatomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1338227825Stheraven{ 1339227825Stheraven return __o->fetch_add(__op); 1340227825Stheraven} 1341227825Stheraven 1342227825Stheraventemplate <class _Tp> 1343227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1344227825Stheraven_Tp* 1345234959Stheravenatomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1346227825Stheraven{ 1347227825Stheraven return __o->fetch_add(__op); 1348227825Stheraven} 1349227825Stheraven 1350227825Stheraven// atomic_fetch_add_explicit 1351227825Stheraven 1352227825Stheraventemplate <class _Tp> 1353227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1354227825Stheraventypename enable_if 1355227825Stheraven< 1356227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1357227825Stheraven _Tp 1358227825Stheraven>::type 1359234959Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1360227825Stheraven{ 1361227825Stheraven return __o->fetch_add(__op, __m); 1362227825Stheraven} 1363227825Stheraven 1364227825Stheraventemplate <class _Tp> 1365227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1366227825Stheraventypename enable_if 1367227825Stheraven< 1368227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1369227825Stheraven _Tp 1370227825Stheraven>::type 1371234959Stheravenatomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1372227825Stheraven{ 1373227825Stheraven return __o->fetch_add(__op, __m); 1374227825Stheraven} 1375227825Stheraven 1376227825Stheraventemplate <class _Tp> 1377227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1378227825Stheraven_Tp* 1379227825Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1380234959Stheraven memory_order __m) _NOEXCEPT 1381227825Stheraven{ 1382227825Stheraven return __o->fetch_add(__op, __m); 1383227825Stheraven} 1384227825Stheraven 1385227825Stheraventemplate <class _Tp> 1386227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1387227825Stheraven_Tp* 1388234959Stheravenatomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1389227825Stheraven{ 1390227825Stheraven return __o->fetch_add(__op, __m); 1391227825Stheraven} 1392227825Stheraven 1393227825Stheraven// atomic_fetch_sub 1394227825Stheraven 1395227825Stheraventemplate <class _Tp> 1396227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1397227825Stheraventypename enable_if 1398227825Stheraven< 1399227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1400227825Stheraven _Tp 1401227825Stheraven>::type 1402234959Stheravenatomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1403227825Stheraven{ 1404227825Stheraven return __o->fetch_sub(__op); 1405227825Stheraven} 1406227825Stheraven 1407227825Stheraventemplate <class _Tp> 1408227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1409227825Stheraventypename enable_if 1410227825Stheraven< 1411227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1412227825Stheraven _Tp 1413227825Stheraven>::type 1414234959Stheravenatomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1415227825Stheraven{ 1416227825Stheraven return __o->fetch_sub(__op); 1417227825Stheraven} 1418227825Stheraven 1419227825Stheraventemplate <class _Tp> 1420227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1421227825Stheraven_Tp* 1422234959Stheravenatomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1423227825Stheraven{ 1424227825Stheraven return __o->fetch_sub(__op); 1425227825Stheraven} 1426227825Stheraven 1427227825Stheraventemplate <class _Tp> 1428227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1429227825Stheraven_Tp* 1430234959Stheravenatomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1431227825Stheraven{ 1432227825Stheraven return __o->fetch_sub(__op); 1433227825Stheraven} 1434227825Stheraven 1435227825Stheraven// atomic_fetch_sub_explicit 1436227825Stheraven 1437227825Stheraventemplate <class _Tp> 1438227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1439227825Stheraventypename enable_if 1440227825Stheraven< 1441227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1442227825Stheraven _Tp 1443227825Stheraven>::type 1444234959Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1445227825Stheraven{ 1446227825Stheraven return __o->fetch_sub(__op, __m); 1447227825Stheraven} 1448227825Stheraven 1449227825Stheraventemplate <class _Tp> 1450227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1451227825Stheraventypename enable_if 1452227825Stheraven< 1453227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1454227825Stheraven _Tp 1455227825Stheraven>::type 1456234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1457227825Stheraven{ 1458227825Stheraven return __o->fetch_sub(__op, __m); 1459227825Stheraven} 1460227825Stheraven 1461227825Stheraventemplate <class _Tp> 1462227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1463227825Stheraven_Tp* 1464227825Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1465234959Stheraven memory_order __m) _NOEXCEPT 1466227825Stheraven{ 1467227825Stheraven return __o->fetch_sub(__op, __m); 1468227825Stheraven} 1469227825Stheraven 1470227825Stheraventemplate <class _Tp> 1471227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1472227825Stheraven_Tp* 1473234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1474227825Stheraven{ 1475227825Stheraven return __o->fetch_sub(__op, __m); 1476227825Stheraven} 1477227825Stheraven 1478227825Stheraven// atomic_fetch_and 1479227825Stheraven 1480227825Stheraventemplate <class _Tp> 1481227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1482227825Stheraventypename enable_if 1483227825Stheraven< 1484227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1485227825Stheraven _Tp 1486227825Stheraven>::type 1487234959Stheravenatomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1488227825Stheraven{ 1489227825Stheraven return __o->fetch_and(__op); 1490227825Stheraven} 1491227825Stheraven 1492227825Stheraventemplate <class _Tp> 1493227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1494227825Stheraventypename enable_if 1495227825Stheraven< 1496227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1497227825Stheraven _Tp 1498227825Stheraven>::type 1499234959Stheravenatomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1500227825Stheraven{ 1501227825Stheraven return __o->fetch_and(__op); 1502227825Stheraven} 1503227825Stheraven 1504227825Stheraven// atomic_fetch_and_explicit 1505227825Stheraven 1506227825Stheraventemplate <class _Tp> 1507227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1508227825Stheraventypename enable_if 1509227825Stheraven< 1510227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1511227825Stheraven _Tp 1512227825Stheraven>::type 1513234959Stheravenatomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1514227825Stheraven{ 1515227825Stheraven return __o->fetch_and(__op, __m); 1516227825Stheraven} 1517227825Stheraven 1518227825Stheraventemplate <class _Tp> 1519227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1520227825Stheraventypename enable_if 1521227825Stheraven< 1522227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1523227825Stheraven _Tp 1524227825Stheraven>::type 1525234959Stheravenatomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1526227825Stheraven{ 1527227825Stheraven return __o->fetch_and(__op, __m); 1528227825Stheraven} 1529227825Stheraven 1530227825Stheraven// atomic_fetch_or 1531227825Stheraven 1532227825Stheraventemplate <class _Tp> 1533227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1534227825Stheraventypename enable_if 1535227825Stheraven< 1536227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1537227825Stheraven _Tp 1538227825Stheraven>::type 1539234959Stheravenatomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1540227825Stheraven{ 1541227825Stheraven return __o->fetch_or(__op); 1542227825Stheraven} 1543227825Stheraven 1544227825Stheraventemplate <class _Tp> 1545227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1546227825Stheraventypename enable_if 1547227825Stheraven< 1548227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1549227825Stheraven _Tp 1550227825Stheraven>::type 1551234959Stheravenatomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1552227825Stheraven{ 1553227825Stheraven return __o->fetch_or(__op); 1554227825Stheraven} 1555227825Stheraven 1556227825Stheraven// atomic_fetch_or_explicit 1557227825Stheraven 1558227825Stheraventemplate <class _Tp> 1559227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1560227825Stheraventypename enable_if 1561227825Stheraven< 1562227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1563227825Stheraven _Tp 1564227825Stheraven>::type 1565234959Stheravenatomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1566227825Stheraven{ 1567227825Stheraven return __o->fetch_or(__op, __m); 1568227825Stheraven} 1569227825Stheraven 1570227825Stheraventemplate <class _Tp> 1571227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1572227825Stheraventypename enable_if 1573227825Stheraven< 1574227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1575227825Stheraven _Tp 1576227825Stheraven>::type 1577234959Stheravenatomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1578227825Stheraven{ 1579227825Stheraven return __o->fetch_or(__op, __m); 1580227825Stheraven} 1581227825Stheraven 1582227825Stheraven// atomic_fetch_xor 1583227825Stheraven 1584227825Stheraventemplate <class _Tp> 1585227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1586227825Stheraventypename enable_if 1587227825Stheraven< 1588227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1589227825Stheraven _Tp 1590227825Stheraven>::type 1591234959Stheravenatomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1592227825Stheraven{ 1593227825Stheraven return __o->fetch_xor(__op); 1594227825Stheraven} 1595227825Stheraven 1596227825Stheraventemplate <class _Tp> 1597227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1598227825Stheraventypename enable_if 1599227825Stheraven< 1600227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1601227825Stheraven _Tp 1602227825Stheraven>::type 1603234959Stheravenatomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1604227825Stheraven{ 1605227825Stheraven return __o->fetch_xor(__op); 1606227825Stheraven} 1607227825Stheraven 1608227825Stheraven// atomic_fetch_xor_explicit 1609227825Stheraven 1610227825Stheraventemplate <class _Tp> 1611227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1612227825Stheraventypename enable_if 1613227825Stheraven< 1614227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1615227825Stheraven _Tp 1616227825Stheraven>::type 1617234959Stheravenatomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1618227825Stheraven{ 1619227825Stheraven return __o->fetch_xor(__op, __m); 1620227825Stheraven} 1621227825Stheraven 1622227825Stheraventemplate <class _Tp> 1623227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1624227825Stheraventypename enable_if 1625227825Stheraven< 1626227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1627227825Stheraven _Tp 1628227825Stheraven>::type 1629234959Stheravenatomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1630227825Stheraven{ 1631227825Stheraven return __o->fetch_xor(__op, __m); 1632227825Stheraven} 1633227825Stheraven 1634227825Stheraven// flag type and operations 1635227825Stheraven 1636227825Stheraventypedef struct atomic_flag 1637227825Stheraven{ 1638232924Stheraven _Atomic(bool) __a_; 1639227825Stheraven 1640227825Stheraven _LIBCPP_INLINE_VISIBILITY 1641234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1642234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1643227825Stheraven _LIBCPP_INLINE_VISIBILITY 1644234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1645234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1646227825Stheraven _LIBCPP_INLINE_VISIBILITY 1647234959Stheraven void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1648234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1649227825Stheraven _LIBCPP_INLINE_VISIBILITY 1650234959Stheraven void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1651234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1652227825Stheraven 1653227825Stheraven _LIBCPP_INLINE_VISIBILITY 1654253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1655253146Stheraven atomic_flag() _NOEXCEPT = default; 1656253146Stheraven#else 1657253146Stheraven atomic_flag() _NOEXCEPT : __a_() {} 1658253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1659253146Stheraven 1660227825Stheraven _LIBCPP_INLINE_VISIBILITY 1661234959Stheraven atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} 1662227825Stheraven 1663227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1664227825Stheraven atomic_flag(const atomic_flag&) = delete; 1665227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 1666227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 1667227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1668227825Stheravenprivate: 1669227825Stheraven atomic_flag(const atomic_flag&); 1670227825Stheraven atomic_flag& operator=(const atomic_flag&); 1671227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile; 1672227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1673227825Stheraven} atomic_flag; 1674227825Stheraven 1675227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1676227825Stheravenbool 1677234959Stheravenatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 1678227825Stheraven{ 1679227825Stheraven return __o->test_and_set(); 1680227825Stheraven} 1681227825Stheraven 1682227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1683227825Stheravenbool 1684234959Stheravenatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 1685227825Stheraven{ 1686227825Stheraven return __o->test_and_set(); 1687227825Stheraven} 1688227825Stheraven 1689227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1690227825Stheravenbool 1691234959Stheravenatomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1692227825Stheraven{ 1693227825Stheraven return __o->test_and_set(__m); 1694227825Stheraven} 1695227825Stheraven 1696227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1697227825Stheravenbool 1698234959Stheravenatomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1699227825Stheraven{ 1700227825Stheraven return __o->test_and_set(__m); 1701227825Stheraven} 1702227825Stheraven 1703227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1704227825Stheravenvoid 1705234959Stheravenatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 1706227825Stheraven{ 1707227825Stheraven __o->clear(); 1708227825Stheraven} 1709227825Stheraven 1710227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1711227825Stheravenvoid 1712234959Stheravenatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 1713227825Stheraven{ 1714227825Stheraven __o->clear(); 1715227825Stheraven} 1716227825Stheraven 1717227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1718227825Stheravenvoid 1719234959Stheravenatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1720227825Stheraven{ 1721227825Stheraven __o->clear(__m); 1722227825Stheraven} 1723227825Stheraven 1724227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1725227825Stheravenvoid 1726234959Stheravenatomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1727227825Stheraven{ 1728227825Stheraven __o->clear(__m); 1729227825Stheraven} 1730227825Stheraven 1731227825Stheraven// fences 1732227825Stheraven 1733227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1734227825Stheravenvoid 1735234959Stheravenatomic_thread_fence(memory_order __m) _NOEXCEPT 1736227825Stheraven{ 1737234959Stheraven __c11_atomic_thread_fence(__m); 1738227825Stheraven} 1739227825Stheraven 1740227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1741227825Stheravenvoid 1742234959Stheravenatomic_signal_fence(memory_order __m) _NOEXCEPT 1743227825Stheraven{ 1744234959Stheraven __c11_atomic_signal_fence(__m); 1745227825Stheraven} 1746227825Stheraven 1747227825Stheraven// Atomics for standard typedef types 1748227825Stheraven 1749246468Stheraventypedef atomic<bool> atomic_bool; 1750227825Stheraventypedef atomic<char> atomic_char; 1751227825Stheraventypedef atomic<signed char> atomic_schar; 1752227825Stheraventypedef atomic<unsigned char> atomic_uchar; 1753227825Stheraventypedef atomic<short> atomic_short; 1754227825Stheraventypedef atomic<unsigned short> atomic_ushort; 1755227825Stheraventypedef atomic<int> atomic_int; 1756227825Stheraventypedef atomic<unsigned int> atomic_uint; 1757227825Stheraventypedef atomic<long> atomic_long; 1758227825Stheraventypedef atomic<unsigned long> atomic_ulong; 1759227825Stheraventypedef atomic<long long> atomic_llong; 1760227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 1761227825Stheraventypedef atomic<char16_t> atomic_char16_t; 1762227825Stheraventypedef atomic<char32_t> atomic_char32_t; 1763227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 1764227825Stheraven 1765227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 1766227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 1767227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 1768227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 1769227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 1770227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 1771227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 1772227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 1773227825Stheraven 1774227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 1775227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 1776227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 1777227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 1778227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 1779227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 1780227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 1781227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 1782227825Stheraven 1783227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 1784227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 1785227825Stheraventypedef atomic<size_t> atomic_size_t; 1786227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 1787227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 1788227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 1789227825Stheraven 1790227825Stheraven#define ATOMIC_FLAG_INIT {false} 1791227825Stheraven#define ATOMIC_VAR_INIT(__v) {__v} 1792227825Stheraven 1793227825Stheraven// lock-free property 1794227825Stheraven 1795246468Stheraven#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE 1796246468Stheraven#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE 1797246468Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1798246468Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1799246468Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1800246468Stheraven#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE 1801246468Stheraven#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE 1802246468Stheraven#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE 1803246468Stheraven#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE 1804246468Stheraven#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE 1805227825Stheraven 1806227825Stheraven#endif // !__has_feature(cxx_atomic) 1807227825Stheraven 1808227825Stheraven_LIBCPP_END_NAMESPACE_STD 1809227825Stheraven 1810276792Sdim#endif // !_LIBCPP_HAS_NO_THREADS 1811276792Sdim 1812227825Stheraven#endif // _LIBCPP_ATOMIC 1813