atomic revision 288943
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 { 556276792Sdim __gcc_atomic_t() _NOEXCEPT {} 557288943Sdim _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT 558288943Sdim : __a_value(value) {} 559288943Sdim _Tp __a_value; 560276792Sdim}; 561276792Sdim#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> 562276792Sdim 563288943Sdimtemplate <typename _Tp> _Tp __create(); 564276792Sdim 565288943Sdimtemplate <typename _Tp, typename _Td> 566288943Sdimtypename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type 567276792Sdim __test_atomic_assignable(int); 568288943Sdimtemplate <typename _Tp, typename _Up> 569276792Sdim__two __test_atomic_assignable(...); 570276792Sdim 571288943Sdimtemplate <typename _Tp, typename _Td> 572276792Sdimstruct __can_assign { 573276792Sdim static const bool value = 574288943Sdim sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); 575276792Sdim}; 576276792Sdim 577276792Sdimstatic inline constexpr int __to_gcc_order(memory_order __order) { 578276792Sdim // Avoid switch statement to make this a constexpr. 579276792Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 580276792Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 581276792Sdim (__order == memory_order_release ? __ATOMIC_RELEASE: 582276792Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 583276792Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: 584276792Sdim __ATOMIC_CONSUME)))); 585276792Sdim} 586276792Sdim 587288943Sdimstatic inline constexpr int __to_gcc_failure_order(memory_order __order) { 588288943Sdim // Avoid switch statement to make this a constexpr. 589288943Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 590288943Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 591288943Sdim (__order == memory_order_release ? __ATOMIC_RELAXED: 592288943Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 593288943Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE: 594288943Sdim __ATOMIC_CONSUME)))); 595288943Sdim} 596288943Sdim 597276792Sdim} // namespace __gcc_atomic 598276792Sdim 599276792Sdimtemplate <typename _Tp> 600276792Sdimstatic inline 601276792Sdimtypename enable_if< 602276792Sdim __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type 603276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 604276792Sdim __a->__a_value = __val; 605276792Sdim} 606276792Sdim 607276792Sdimtemplate <typename _Tp> 608276792Sdimstatic inline 609276792Sdimtypename enable_if< 610276792Sdim !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && 611276792Sdim __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type 612276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 613276792Sdim // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because 614276792Sdim // the default operator= in an object is not volatile, a byte-by-byte copy 615276792Sdim // is required. 616276792Sdim volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); 617276792Sdim volatile char* end = to + sizeof(_Tp); 618276792Sdim char* from = reinterpret_cast<char*>(&__val); 619276792Sdim while (to != end) { 620276792Sdim *to++ = *from++; 621276792Sdim } 622276792Sdim} 623276792Sdim 624276792Sdimtemplate <typename _Tp> 625276792Sdimstatic inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { 626276792Sdim __a->__a_value = __val; 627276792Sdim} 628276792Sdim 629276792Sdimstatic inline void __c11_atomic_thread_fence(memory_order __order) { 630276792Sdim __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); 631276792Sdim} 632276792Sdim 633276792Sdimstatic inline void __c11_atomic_signal_fence(memory_order __order) { 634276792Sdim __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); 635276792Sdim} 636276792Sdim 637276792Sdimtemplate <typename _Tp> 638276792Sdimstatic inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, 639276792Sdim memory_order __order) { 640276792Sdim return __atomic_store(&__a->__a_value, &__val, 641276792Sdim __gcc_atomic::__to_gcc_order(__order)); 642276792Sdim} 643276792Sdim 644276792Sdimtemplate <typename _Tp> 645276792Sdimstatic inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, 646276792Sdim memory_order __order) { 647288943Sdim __atomic_store(&__a->__a_value, &__val, 648288943Sdim __gcc_atomic::__to_gcc_order(__order)); 649276792Sdim} 650276792Sdim 651276792Sdimtemplate <typename _Tp> 652276792Sdimstatic inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, 653276792Sdim memory_order __order) { 654276792Sdim _Tp __ret; 655276792Sdim __atomic_load(&__a->__a_value, &__ret, 656276792Sdim __gcc_atomic::__to_gcc_order(__order)); 657276792Sdim return __ret; 658276792Sdim} 659276792Sdim 660276792Sdimtemplate <typename _Tp> 661276792Sdimstatic inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { 662276792Sdim _Tp __ret; 663276792Sdim __atomic_load(&__a->__a_value, &__ret, 664276792Sdim __gcc_atomic::__to_gcc_order(__order)); 665276792Sdim return __ret; 666276792Sdim} 667276792Sdim 668276792Sdimtemplate <typename _Tp> 669276792Sdimstatic inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, 670276792Sdim _Tp __value, memory_order __order) { 671276792Sdim _Tp __ret; 672276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 673276792Sdim __gcc_atomic::__to_gcc_order(__order)); 674276792Sdim return __ret; 675276792Sdim} 676276792Sdim 677276792Sdimtemplate <typename _Tp> 678276792Sdimstatic inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, 679276792Sdim memory_order __order) { 680276792Sdim _Tp __ret; 681276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 682276792Sdim __gcc_atomic::__to_gcc_order(__order)); 683276792Sdim return __ret; 684276792Sdim} 685276792Sdim 686276792Sdimtemplate <typename _Tp> 687276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 688276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 689276792Sdim memory_order __success, memory_order __failure) { 690276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 691276792Sdim false, 692276792Sdim __gcc_atomic::__to_gcc_order(__success), 693288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 694276792Sdim} 695276792Sdim 696276792Sdimtemplate <typename _Tp> 697276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 698276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 699276792Sdim memory_order __failure) { 700276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 701276792Sdim false, 702276792Sdim __gcc_atomic::__to_gcc_order(__success), 703288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 704276792Sdim} 705276792Sdim 706276792Sdimtemplate <typename _Tp> 707276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 708276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 709276792Sdim memory_order __success, memory_order __failure) { 710276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 711276792Sdim true, 712276792Sdim __gcc_atomic::__to_gcc_order(__success), 713288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 714276792Sdim} 715276792Sdim 716276792Sdimtemplate <typename _Tp> 717276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 718276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 719276792Sdim memory_order __failure) { 720276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 721276792Sdim true, 722276792Sdim __gcc_atomic::__to_gcc_order(__success), 723288943Sdim __gcc_atomic::__to_gcc_failure_order(__failure)); 724276792Sdim} 725276792Sdim 726276792Sdimtemplate <typename _Tp> 727276792Sdimstruct __skip_amt { enum {value = 1}; }; 728276792Sdim 729276792Sdimtemplate <typename _Tp> 730276792Sdimstruct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; 731276792Sdim 732276792Sdim// FIXME: Haven't figured out what the spec says about using arrays with 733276792Sdim// atomic_fetch_add. Force a failure rather than creating bad behavior. 734276792Sdimtemplate <typename _Tp> 735276792Sdimstruct __skip_amt<_Tp[]> { }; 736276792Sdimtemplate <typename _Tp, int n> 737276792Sdimstruct __skip_amt<_Tp[n]> { }; 738276792Sdim 739276792Sdimtemplate <typename _Tp, typename _Td> 740276792Sdimstatic inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, 741276792Sdim _Td __delta, memory_order __order) { 742276792Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 743276792Sdim __gcc_atomic::__to_gcc_order(__order)); 744276792Sdim} 745276792Sdim 746276792Sdimtemplate <typename _Tp, typename _Td> 747276792Sdimstatic inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, 748276792Sdim memory_order __order) { 749276792Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 750276792Sdim __gcc_atomic::__to_gcc_order(__order)); 751276792Sdim} 752276792Sdim 753276792Sdimtemplate <typename _Tp, typename _Td> 754276792Sdimstatic inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, 755276792Sdim _Td __delta, memory_order __order) { 756276792Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 757276792Sdim __gcc_atomic::__to_gcc_order(__order)); 758276792Sdim} 759276792Sdim 760276792Sdimtemplate <typename _Tp, typename _Td> 761276792Sdimstatic inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, 762276792Sdim memory_order __order) { 763276792Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 764276792Sdim __gcc_atomic::__to_gcc_order(__order)); 765276792Sdim} 766276792Sdim 767276792Sdimtemplate <typename _Tp> 768276792Sdimstatic inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, 769276792Sdim _Tp __pattern, memory_order __order) { 770276792Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 771276792Sdim __gcc_atomic::__to_gcc_order(__order)); 772276792Sdim} 773276792Sdim 774276792Sdimtemplate <typename _Tp> 775276792Sdimstatic inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, 776276792Sdim _Tp __pattern, memory_order __order) { 777276792Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 778276792Sdim __gcc_atomic::__to_gcc_order(__order)); 779276792Sdim} 780276792Sdim 781276792Sdimtemplate <typename _Tp> 782276792Sdimstatic inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, 783276792Sdim _Tp __pattern, memory_order __order) { 784276792Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 785276792Sdim __gcc_atomic::__to_gcc_order(__order)); 786276792Sdim} 787276792Sdim 788276792Sdimtemplate <typename _Tp> 789276792Sdimstatic inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, 790276792Sdim memory_order __order) { 791276792Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 792276792Sdim __gcc_atomic::__to_gcc_order(__order)); 793276792Sdim} 794276792Sdim 795276792Sdimtemplate <typename _Tp> 796276792Sdimstatic inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, 797276792Sdim _Tp __pattern, memory_order __order) { 798276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 799276792Sdim __gcc_atomic::__to_gcc_order(__order)); 800276792Sdim} 801276792Sdim 802276792Sdimtemplate <typename _Tp> 803276792Sdimstatic inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, 804276792Sdim memory_order __order) { 805276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 806276792Sdim __gcc_atomic::__to_gcc_order(__order)); 807276792Sdim} 808276792Sdim#endif // _GNUC_VER >= 407 809276792Sdim 810227825Stheraventemplate <class _Tp> 811227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 812227825Stheraven_Tp 813234959Stheravenkill_dependency(_Tp __y) _NOEXCEPT 814227825Stheraven{ 815227825Stheraven return __y; 816227825Stheraven} 817227825Stheraven 818227825Stheraven// general atomic<T> 819227825Stheraven 820227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> 821227825Stheravenstruct __atomic_base // false 822227825Stheraven{ 823241900Sdim mutable _Atomic(_Tp) __a_; 824227825Stheraven 825227825Stheraven _LIBCPP_INLINE_VISIBILITY 826234959Stheraven bool is_lock_free() const volatile _NOEXCEPT 827288943Sdim { 828288943Sdim#if __has_feature(cxx_atomic) 829288943Sdim return __c11_atomic_is_lock_free(sizeof(_Tp)); 830288943Sdim#else 831288943Sdim return __atomic_is_lock_free(sizeof(_Tp), 0); 832288943Sdim#endif 833288943Sdim } 834227825Stheraven _LIBCPP_INLINE_VISIBILITY 835234959Stheraven bool is_lock_free() const _NOEXCEPT 836288943Sdim {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} 837227825Stheraven _LIBCPP_INLINE_VISIBILITY 838234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 839234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 840227825Stheraven _LIBCPP_INLINE_VISIBILITY 841234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 842234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 843227825Stheraven _LIBCPP_INLINE_VISIBILITY 844234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 845234959Stheraven {return __c11_atomic_load(&__a_, __m);} 846227825Stheraven _LIBCPP_INLINE_VISIBILITY 847234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 848234959Stheraven {return __c11_atomic_load(&__a_, __m);} 849227825Stheraven _LIBCPP_INLINE_VISIBILITY 850234959Stheraven operator _Tp() const volatile _NOEXCEPT {return load();} 851227825Stheraven _LIBCPP_INLINE_VISIBILITY 852234959Stheraven operator _Tp() const _NOEXCEPT {return load();} 853227825Stheraven _LIBCPP_INLINE_VISIBILITY 854234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 855234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 856227825Stheraven _LIBCPP_INLINE_VISIBILITY 857234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 858234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 859227825Stheraven _LIBCPP_INLINE_VISIBILITY 860227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 861234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 862234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 863227825Stheraven _LIBCPP_INLINE_VISIBILITY 864227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 865234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 866234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 867227825Stheraven _LIBCPP_INLINE_VISIBILITY 868227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 869234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 870234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 871227825Stheraven _LIBCPP_INLINE_VISIBILITY 872227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 873234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 874234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 875227825Stheraven _LIBCPP_INLINE_VISIBILITY 876227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 877234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 878234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 879227825Stheraven _LIBCPP_INLINE_VISIBILITY 880227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 881234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 882234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 883227825Stheraven _LIBCPP_INLINE_VISIBILITY 884227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 885234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 886234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 887227825Stheraven _LIBCPP_INLINE_VISIBILITY 888227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 889234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 890234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 891227825Stheraven 892227825Stheraven _LIBCPP_INLINE_VISIBILITY 893253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 894253146Stheraven __atomic_base() _NOEXCEPT = default; 895253146Stheraven#else 896253146Stheraven __atomic_base() _NOEXCEPT : __a_() {} 897253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 898253146Stheraven 899227825Stheraven _LIBCPP_INLINE_VISIBILITY 900234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} 901227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 902227825Stheraven __atomic_base(const __atomic_base&) = delete; 903227825Stheraven __atomic_base& operator=(const __atomic_base&) = delete; 904227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile = delete; 905227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 906227825Stheravenprivate: 907227825Stheraven __atomic_base(const __atomic_base&); 908227825Stheraven __atomic_base& operator=(const __atomic_base&); 909227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile; 910227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 911227825Stheraven}; 912227825Stheraven 913227825Stheraven// atomic<Integral> 914227825Stheraven 915227825Stheraventemplate <class _Tp> 916227825Stheravenstruct __atomic_base<_Tp, true> 917227825Stheraven : public __atomic_base<_Tp, false> 918227825Stheraven{ 919227825Stheraven typedef __atomic_base<_Tp, false> __base; 920227825Stheraven _LIBCPP_INLINE_VISIBILITY 921253146Stheraven __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT 922227825Stheraven _LIBCPP_INLINE_VISIBILITY 923234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 924227825Stheraven 925227825Stheraven _LIBCPP_INLINE_VISIBILITY 926234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 927234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 928227825Stheraven _LIBCPP_INLINE_VISIBILITY 929234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 930234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 931227825Stheraven _LIBCPP_INLINE_VISIBILITY 932234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 933234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 934227825Stheraven _LIBCPP_INLINE_VISIBILITY 935234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 936234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 937227825Stheraven _LIBCPP_INLINE_VISIBILITY 938234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 939234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 940227825Stheraven _LIBCPP_INLINE_VISIBILITY 941234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 942234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 943227825Stheraven _LIBCPP_INLINE_VISIBILITY 944234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 945234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 946227825Stheraven _LIBCPP_INLINE_VISIBILITY 947234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 948234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 949227825Stheraven _LIBCPP_INLINE_VISIBILITY 950234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 951234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 952227825Stheraven _LIBCPP_INLINE_VISIBILITY 953234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 954234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 955227825Stheraven 956227825Stheraven _LIBCPP_INLINE_VISIBILITY 957234959Stheraven _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 958227825Stheraven _LIBCPP_INLINE_VISIBILITY 959234959Stheraven _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 960227825Stheraven _LIBCPP_INLINE_VISIBILITY 961234959Stheraven _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 962227825Stheraven _LIBCPP_INLINE_VISIBILITY 963234959Stheraven _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 964227825Stheraven _LIBCPP_INLINE_VISIBILITY 965234959Stheraven _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 966227825Stheraven _LIBCPP_INLINE_VISIBILITY 967234959Stheraven _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 968227825Stheraven _LIBCPP_INLINE_VISIBILITY 969234959Stheraven _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 970227825Stheraven _LIBCPP_INLINE_VISIBILITY 971234959Stheraven _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 972227825Stheraven _LIBCPP_INLINE_VISIBILITY 973234959Stheraven _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 974227825Stheraven _LIBCPP_INLINE_VISIBILITY 975234959Stheraven _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 976227825Stheraven _LIBCPP_INLINE_VISIBILITY 977234959Stheraven _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 978227825Stheraven _LIBCPP_INLINE_VISIBILITY 979234959Stheraven _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 980227825Stheraven _LIBCPP_INLINE_VISIBILITY 981234959Stheraven _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 982227825Stheraven _LIBCPP_INLINE_VISIBILITY 983234959Stheraven _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 984227825Stheraven _LIBCPP_INLINE_VISIBILITY 985234959Stheraven _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 986227825Stheraven _LIBCPP_INLINE_VISIBILITY 987234959Stheraven _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 988227825Stheraven _LIBCPP_INLINE_VISIBILITY 989234959Stheraven _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 990227825Stheraven _LIBCPP_INLINE_VISIBILITY 991234959Stheraven _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} 992227825Stheraven}; 993227825Stheraven 994227825Stheraven// atomic<T> 995227825Stheraven 996227825Stheraventemplate <class _Tp> 997227825Stheravenstruct atomic 998227825Stheraven : public __atomic_base<_Tp> 999227825Stheraven{ 1000227825Stheraven typedef __atomic_base<_Tp> __base; 1001227825Stheraven _LIBCPP_INLINE_VISIBILITY 1002253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1003227825Stheraven _LIBCPP_INLINE_VISIBILITY 1004234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 1005227825Stheraven 1006227825Stheraven _LIBCPP_INLINE_VISIBILITY 1007234959Stheraven _Tp operator=(_Tp __d) volatile _NOEXCEPT 1008227825Stheraven {__base::store(__d); return __d;} 1009227825Stheraven _LIBCPP_INLINE_VISIBILITY 1010234959Stheraven _Tp operator=(_Tp __d) _NOEXCEPT 1011227825Stheraven {__base::store(__d); return __d;} 1012227825Stheraven}; 1013227825Stheraven 1014227825Stheraven// atomic<T*> 1015227825Stheraven 1016227825Stheraventemplate <class _Tp> 1017227825Stheravenstruct atomic<_Tp*> 1018227825Stheraven : public __atomic_base<_Tp*> 1019227825Stheraven{ 1020227825Stheraven typedef __atomic_base<_Tp*> __base; 1021227825Stheraven _LIBCPP_INLINE_VISIBILITY 1022253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1023227825Stheraven _LIBCPP_INLINE_VISIBILITY 1024234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 1025227825Stheraven 1026227825Stheraven _LIBCPP_INLINE_VISIBILITY 1027234959Stheraven _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 1028227825Stheraven {__base::store(__d); return __d;} 1029227825Stheraven _LIBCPP_INLINE_VISIBILITY 1030234959Stheraven _Tp* operator=(_Tp* __d) _NOEXCEPT 1031227825Stheraven {__base::store(__d); return __d;} 1032227825Stheraven 1033227825Stheraven _LIBCPP_INLINE_VISIBILITY 1034227825Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1035234959Stheraven volatile _NOEXCEPT 1036234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1037227825Stheraven _LIBCPP_INLINE_VISIBILITY 1038234959Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1039234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1040227825Stheraven _LIBCPP_INLINE_VISIBILITY 1041227825Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1042234959Stheraven volatile _NOEXCEPT 1043234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1044227825Stheraven _LIBCPP_INLINE_VISIBILITY 1045234959Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1046234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1047227825Stheraven 1048227825Stheraven _LIBCPP_INLINE_VISIBILITY 1049234959Stheraven _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 1050227825Stheraven _LIBCPP_INLINE_VISIBILITY 1051234959Stheraven _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 1052227825Stheraven _LIBCPP_INLINE_VISIBILITY 1053234959Stheraven _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 1054227825Stheraven _LIBCPP_INLINE_VISIBILITY 1055234959Stheraven _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 1056227825Stheraven _LIBCPP_INLINE_VISIBILITY 1057234959Stheraven _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 1058227825Stheraven _LIBCPP_INLINE_VISIBILITY 1059234959Stheraven _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 1060227825Stheraven _LIBCPP_INLINE_VISIBILITY 1061234959Stheraven _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 1062227825Stheraven _LIBCPP_INLINE_VISIBILITY 1063234959Stheraven _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 1064227825Stheraven _LIBCPP_INLINE_VISIBILITY 1065234959Stheraven _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 1066227825Stheraven _LIBCPP_INLINE_VISIBILITY 1067234959Stheraven _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 1068227825Stheraven _LIBCPP_INLINE_VISIBILITY 1069234959Stheraven _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 1070227825Stheraven _LIBCPP_INLINE_VISIBILITY 1071234959Stheraven _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 1072227825Stheraven}; 1073227825Stheraven 1074227825Stheraven// atomic_is_lock_free 1075227825Stheraven 1076227825Stheraventemplate <class _Tp> 1077227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1078227825Stheravenbool 1079234959Stheravenatomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT 1080227825Stheraven{ 1081227825Stheraven return __o->is_lock_free(); 1082227825Stheraven} 1083227825Stheraven 1084227825Stheraventemplate <class _Tp> 1085227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1086227825Stheravenbool 1087234959Stheravenatomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT 1088227825Stheraven{ 1089227825Stheraven return __o->is_lock_free(); 1090227825Stheraven} 1091227825Stheraven 1092227825Stheraven// atomic_init 1093227825Stheraven 1094227825Stheraventemplate <class _Tp> 1095227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1096227825Stheravenvoid 1097234959Stheravenatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1098227825Stheraven{ 1099234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1100227825Stheraven} 1101227825Stheraven 1102227825Stheraventemplate <class _Tp> 1103227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1104227825Stheravenvoid 1105234959Stheravenatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1106227825Stheraven{ 1107234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1108227825Stheraven} 1109227825Stheraven 1110227825Stheraven// atomic_store 1111227825Stheraven 1112227825Stheraventemplate <class _Tp> 1113227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1114227825Stheravenvoid 1115234959Stheravenatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1116227825Stheraven{ 1117227825Stheraven __o->store(__d); 1118227825Stheraven} 1119227825Stheraven 1120227825Stheraventemplate <class _Tp> 1121227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1122227825Stheravenvoid 1123234959Stheravenatomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1124227825Stheraven{ 1125227825Stheraven __o->store(__d); 1126227825Stheraven} 1127227825Stheraven 1128227825Stheraven// atomic_store_explicit 1129227825Stheraven 1130227825Stheraventemplate <class _Tp> 1131227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1132227825Stheravenvoid 1133234959Stheravenatomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1134227825Stheraven{ 1135227825Stheraven __o->store(__d, __m); 1136227825Stheraven} 1137227825Stheraven 1138227825Stheraventemplate <class _Tp> 1139227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1140227825Stheravenvoid 1141234959Stheravenatomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1142227825Stheraven{ 1143227825Stheraven __o->store(__d, __m); 1144227825Stheraven} 1145227825Stheraven 1146227825Stheraven// atomic_load 1147227825Stheraven 1148227825Stheraventemplate <class _Tp> 1149227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1150227825Stheraven_Tp 1151234959Stheravenatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 1152227825Stheraven{ 1153227825Stheraven return __o->load(); 1154227825Stheraven} 1155227825Stheraven 1156227825Stheraventemplate <class _Tp> 1157227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1158227825Stheraven_Tp 1159234959Stheravenatomic_load(const atomic<_Tp>* __o) _NOEXCEPT 1160227825Stheraven{ 1161227825Stheraven return __o->load(); 1162227825Stheraven} 1163227825Stheraven 1164227825Stheraven// atomic_load_explicit 1165227825Stheraven 1166227825Stheraventemplate <class _Tp> 1167227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1168227825Stheraven_Tp 1169234959Stheravenatomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1170227825Stheraven{ 1171227825Stheraven return __o->load(__m); 1172227825Stheraven} 1173227825Stheraven 1174227825Stheraventemplate <class _Tp> 1175227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1176227825Stheraven_Tp 1177234959Stheravenatomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1178227825Stheraven{ 1179227825Stheraven return __o->load(__m); 1180227825Stheraven} 1181227825Stheraven 1182227825Stheraven// atomic_exchange 1183227825Stheraven 1184227825Stheraventemplate <class _Tp> 1185227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1186227825Stheraven_Tp 1187234959Stheravenatomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1188227825Stheraven{ 1189227825Stheraven return __o->exchange(__d); 1190227825Stheraven} 1191227825Stheraven 1192227825Stheraventemplate <class _Tp> 1193227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1194227825Stheraven_Tp 1195234959Stheravenatomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1196227825Stheraven{ 1197227825Stheraven return __o->exchange(__d); 1198227825Stheraven} 1199227825Stheraven 1200227825Stheraven// atomic_exchange_explicit 1201227825Stheraven 1202227825Stheraventemplate <class _Tp> 1203227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1204227825Stheraven_Tp 1205234959Stheravenatomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1206227825Stheraven{ 1207227825Stheraven return __o->exchange(__d, __m); 1208227825Stheraven} 1209227825Stheraven 1210227825Stheraventemplate <class _Tp> 1211227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1212227825Stheraven_Tp 1213234959Stheravenatomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1214227825Stheraven{ 1215227825Stheraven return __o->exchange(__d, __m); 1216227825Stheraven} 1217227825Stheraven 1218227825Stheraven// atomic_compare_exchange_weak 1219227825Stheraven 1220227825Stheraventemplate <class _Tp> 1221227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1222227825Stheravenbool 1223234959Stheravenatomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1224227825Stheraven{ 1225227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1226227825Stheraven} 1227227825Stheraven 1228227825Stheraventemplate <class _Tp> 1229227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1230227825Stheravenbool 1231234959Stheravenatomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1232227825Stheraven{ 1233227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1234227825Stheraven} 1235227825Stheraven 1236227825Stheraven// atomic_compare_exchange_strong 1237227825Stheraven 1238227825Stheraventemplate <class _Tp> 1239227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1240227825Stheravenbool 1241234959Stheravenatomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1242227825Stheraven{ 1243227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1244227825Stheraven} 1245227825Stheraven 1246227825Stheraventemplate <class _Tp> 1247227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1248227825Stheravenbool 1249234959Stheravenatomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1250227825Stheraven{ 1251227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1252227825Stheraven} 1253227825Stheraven 1254227825Stheraven// atomic_compare_exchange_weak_explicit 1255227825Stheraven 1256227825Stheraventemplate <class _Tp> 1257227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1258227825Stheravenbool 1259227825Stheravenatomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, 1260227825Stheraven _Tp __d, 1261234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1262227825Stheraven{ 1263227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1264227825Stheraven} 1265227825Stheraven 1266227825Stheraventemplate <class _Tp> 1267227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1268227825Stheravenbool 1269227825Stheravenatomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, 1270234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1271227825Stheraven{ 1272227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1273227825Stheraven} 1274227825Stheraven 1275227825Stheraven// atomic_compare_exchange_strong_explicit 1276227825Stheraven 1277227825Stheraventemplate <class _Tp> 1278227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1279227825Stheravenbool 1280227825Stheravenatomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, 1281227825Stheraven _Tp* __e, _Tp __d, 1282234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1283227825Stheraven{ 1284227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1285227825Stheraven} 1286227825Stheraven 1287227825Stheraventemplate <class _Tp> 1288227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1289227825Stheravenbool 1290227825Stheravenatomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, 1291227825Stheraven _Tp __d, 1292234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1293227825Stheraven{ 1294227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1295227825Stheraven} 1296227825Stheraven 1297227825Stheraven// atomic_fetch_add 1298227825Stheraven 1299227825Stheraventemplate <class _Tp> 1300227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1301227825Stheraventypename enable_if 1302227825Stheraven< 1303227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1304227825Stheraven _Tp 1305227825Stheraven>::type 1306234959Stheravenatomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1307227825Stheraven{ 1308227825Stheraven return __o->fetch_add(__op); 1309227825Stheraven} 1310227825Stheraven 1311227825Stheraventemplate <class _Tp> 1312227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1313227825Stheraventypename enable_if 1314227825Stheraven< 1315227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1316227825Stheraven _Tp 1317227825Stheraven>::type 1318234959Stheravenatomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1319227825Stheraven{ 1320227825Stheraven return __o->fetch_add(__op); 1321227825Stheraven} 1322227825Stheraven 1323227825Stheraventemplate <class _Tp> 1324227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1325227825Stheraven_Tp* 1326234959Stheravenatomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1327227825Stheraven{ 1328227825Stheraven return __o->fetch_add(__op); 1329227825Stheraven} 1330227825Stheraven 1331227825Stheraventemplate <class _Tp> 1332227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1333227825Stheraven_Tp* 1334234959Stheravenatomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1335227825Stheraven{ 1336227825Stheraven return __o->fetch_add(__op); 1337227825Stheraven} 1338227825Stheraven 1339227825Stheraven// atomic_fetch_add_explicit 1340227825Stheraven 1341227825Stheraventemplate <class _Tp> 1342227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1343227825Stheraventypename enable_if 1344227825Stheraven< 1345227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1346227825Stheraven _Tp 1347227825Stheraven>::type 1348234959Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1349227825Stheraven{ 1350227825Stheraven return __o->fetch_add(__op, __m); 1351227825Stheraven} 1352227825Stheraven 1353227825Stheraventemplate <class _Tp> 1354227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1355227825Stheraventypename enable_if 1356227825Stheraven< 1357227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1358227825Stheraven _Tp 1359227825Stheraven>::type 1360234959Stheravenatomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1361227825Stheraven{ 1362227825Stheraven return __o->fetch_add(__op, __m); 1363227825Stheraven} 1364227825Stheraven 1365227825Stheraventemplate <class _Tp> 1366227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1367227825Stheraven_Tp* 1368227825Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1369234959Stheraven memory_order __m) _NOEXCEPT 1370227825Stheraven{ 1371227825Stheraven return __o->fetch_add(__op, __m); 1372227825Stheraven} 1373227825Stheraven 1374227825Stheraventemplate <class _Tp> 1375227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1376227825Stheraven_Tp* 1377234959Stheravenatomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1378227825Stheraven{ 1379227825Stheraven return __o->fetch_add(__op, __m); 1380227825Stheraven} 1381227825Stheraven 1382227825Stheraven// atomic_fetch_sub 1383227825Stheraven 1384227825Stheraventemplate <class _Tp> 1385227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1386227825Stheraventypename enable_if 1387227825Stheraven< 1388227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1389227825Stheraven _Tp 1390227825Stheraven>::type 1391234959Stheravenatomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1392227825Stheraven{ 1393227825Stheraven return __o->fetch_sub(__op); 1394227825Stheraven} 1395227825Stheraven 1396227825Stheraventemplate <class _Tp> 1397227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1398227825Stheraventypename enable_if 1399227825Stheraven< 1400227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1401227825Stheraven _Tp 1402227825Stheraven>::type 1403234959Stheravenatomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1404227825Stheraven{ 1405227825Stheraven return __o->fetch_sub(__op); 1406227825Stheraven} 1407227825Stheraven 1408227825Stheraventemplate <class _Tp> 1409227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1410227825Stheraven_Tp* 1411234959Stheravenatomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1412227825Stheraven{ 1413227825Stheraven return __o->fetch_sub(__op); 1414227825Stheraven} 1415227825Stheraven 1416227825Stheraventemplate <class _Tp> 1417227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1418227825Stheraven_Tp* 1419234959Stheravenatomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1420227825Stheraven{ 1421227825Stheraven return __o->fetch_sub(__op); 1422227825Stheraven} 1423227825Stheraven 1424227825Stheraven// atomic_fetch_sub_explicit 1425227825Stheraven 1426227825Stheraventemplate <class _Tp> 1427227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1428227825Stheraventypename enable_if 1429227825Stheraven< 1430227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1431227825Stheraven _Tp 1432227825Stheraven>::type 1433234959Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1434227825Stheraven{ 1435227825Stheraven return __o->fetch_sub(__op, __m); 1436227825Stheraven} 1437227825Stheraven 1438227825Stheraventemplate <class _Tp> 1439227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1440227825Stheraventypename enable_if 1441227825Stheraven< 1442227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1443227825Stheraven _Tp 1444227825Stheraven>::type 1445234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1446227825Stheraven{ 1447227825Stheraven return __o->fetch_sub(__op, __m); 1448227825Stheraven} 1449227825Stheraven 1450227825Stheraventemplate <class _Tp> 1451227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1452227825Stheraven_Tp* 1453227825Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1454234959Stheraven memory_order __m) _NOEXCEPT 1455227825Stheraven{ 1456227825Stheraven return __o->fetch_sub(__op, __m); 1457227825Stheraven} 1458227825Stheraven 1459227825Stheraventemplate <class _Tp> 1460227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1461227825Stheraven_Tp* 1462234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1463227825Stheraven{ 1464227825Stheraven return __o->fetch_sub(__op, __m); 1465227825Stheraven} 1466227825Stheraven 1467227825Stheraven// atomic_fetch_and 1468227825Stheraven 1469227825Stheraventemplate <class _Tp> 1470227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1471227825Stheraventypename enable_if 1472227825Stheraven< 1473227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1474227825Stheraven _Tp 1475227825Stheraven>::type 1476234959Stheravenatomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1477227825Stheraven{ 1478227825Stheraven return __o->fetch_and(__op); 1479227825Stheraven} 1480227825Stheraven 1481227825Stheraventemplate <class _Tp> 1482227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1483227825Stheraventypename enable_if 1484227825Stheraven< 1485227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1486227825Stheraven _Tp 1487227825Stheraven>::type 1488234959Stheravenatomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1489227825Stheraven{ 1490227825Stheraven return __o->fetch_and(__op); 1491227825Stheraven} 1492227825Stheraven 1493227825Stheraven// atomic_fetch_and_explicit 1494227825Stheraven 1495227825Stheraventemplate <class _Tp> 1496227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1497227825Stheraventypename enable_if 1498227825Stheraven< 1499227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1500227825Stheraven _Tp 1501227825Stheraven>::type 1502234959Stheravenatomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1503227825Stheraven{ 1504227825Stheraven return __o->fetch_and(__op, __m); 1505227825Stheraven} 1506227825Stheraven 1507227825Stheraventemplate <class _Tp> 1508227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1509227825Stheraventypename enable_if 1510227825Stheraven< 1511227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1512227825Stheraven _Tp 1513227825Stheraven>::type 1514234959Stheravenatomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1515227825Stheraven{ 1516227825Stheraven return __o->fetch_and(__op, __m); 1517227825Stheraven} 1518227825Stheraven 1519227825Stheraven// atomic_fetch_or 1520227825Stheraven 1521227825Stheraventemplate <class _Tp> 1522227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1523227825Stheraventypename enable_if 1524227825Stheraven< 1525227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1526227825Stheraven _Tp 1527227825Stheraven>::type 1528234959Stheravenatomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1529227825Stheraven{ 1530227825Stheraven return __o->fetch_or(__op); 1531227825Stheraven} 1532227825Stheraven 1533227825Stheraventemplate <class _Tp> 1534227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1535227825Stheraventypename enable_if 1536227825Stheraven< 1537227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1538227825Stheraven _Tp 1539227825Stheraven>::type 1540234959Stheravenatomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1541227825Stheraven{ 1542227825Stheraven return __o->fetch_or(__op); 1543227825Stheraven} 1544227825Stheraven 1545227825Stheraven// atomic_fetch_or_explicit 1546227825Stheraven 1547227825Stheraventemplate <class _Tp> 1548227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1549227825Stheraventypename enable_if 1550227825Stheraven< 1551227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1552227825Stheraven _Tp 1553227825Stheraven>::type 1554234959Stheravenatomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1555227825Stheraven{ 1556227825Stheraven return __o->fetch_or(__op, __m); 1557227825Stheraven} 1558227825Stheraven 1559227825Stheraventemplate <class _Tp> 1560227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1561227825Stheraventypename enable_if 1562227825Stheraven< 1563227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1564227825Stheraven _Tp 1565227825Stheraven>::type 1566234959Stheravenatomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1567227825Stheraven{ 1568227825Stheraven return __o->fetch_or(__op, __m); 1569227825Stheraven} 1570227825Stheraven 1571227825Stheraven// atomic_fetch_xor 1572227825Stheraven 1573227825Stheraventemplate <class _Tp> 1574227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1575227825Stheraventypename enable_if 1576227825Stheraven< 1577227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1578227825Stheraven _Tp 1579227825Stheraven>::type 1580234959Stheravenatomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1581227825Stheraven{ 1582227825Stheraven return __o->fetch_xor(__op); 1583227825Stheraven} 1584227825Stheraven 1585227825Stheraventemplate <class _Tp> 1586227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1587227825Stheraventypename enable_if 1588227825Stheraven< 1589227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1590227825Stheraven _Tp 1591227825Stheraven>::type 1592234959Stheravenatomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1593227825Stheraven{ 1594227825Stheraven return __o->fetch_xor(__op); 1595227825Stheraven} 1596227825Stheraven 1597227825Stheraven// atomic_fetch_xor_explicit 1598227825Stheraven 1599227825Stheraventemplate <class _Tp> 1600227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1601227825Stheraventypename enable_if 1602227825Stheraven< 1603227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1604227825Stheraven _Tp 1605227825Stheraven>::type 1606234959Stheravenatomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1607227825Stheraven{ 1608227825Stheraven return __o->fetch_xor(__op, __m); 1609227825Stheraven} 1610227825Stheraven 1611227825Stheraventemplate <class _Tp> 1612227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1613227825Stheraventypename enable_if 1614227825Stheraven< 1615227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1616227825Stheraven _Tp 1617227825Stheraven>::type 1618234959Stheravenatomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1619227825Stheraven{ 1620227825Stheraven return __o->fetch_xor(__op, __m); 1621227825Stheraven} 1622227825Stheraven 1623227825Stheraven// flag type and operations 1624227825Stheraven 1625227825Stheraventypedef struct atomic_flag 1626227825Stheraven{ 1627232924Stheraven _Atomic(bool) __a_; 1628227825Stheraven 1629227825Stheraven _LIBCPP_INLINE_VISIBILITY 1630234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1631234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1632227825Stheraven _LIBCPP_INLINE_VISIBILITY 1633234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1634234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1635227825Stheraven _LIBCPP_INLINE_VISIBILITY 1636234959Stheraven void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1637234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1638227825Stheraven _LIBCPP_INLINE_VISIBILITY 1639234959Stheraven void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1640234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1641227825Stheraven 1642227825Stheraven _LIBCPP_INLINE_VISIBILITY 1643253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1644253146Stheraven atomic_flag() _NOEXCEPT = default; 1645253146Stheraven#else 1646253146Stheraven atomic_flag() _NOEXCEPT : __a_() {} 1647253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1648253146Stheraven 1649227825Stheraven _LIBCPP_INLINE_VISIBILITY 1650234959Stheraven atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} 1651227825Stheraven 1652227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1653227825Stheraven atomic_flag(const atomic_flag&) = delete; 1654227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 1655227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 1656227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1657227825Stheravenprivate: 1658227825Stheraven atomic_flag(const atomic_flag&); 1659227825Stheraven atomic_flag& operator=(const atomic_flag&); 1660227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile; 1661227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1662227825Stheraven} atomic_flag; 1663227825Stheraven 1664227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1665227825Stheravenbool 1666234959Stheravenatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 1667227825Stheraven{ 1668227825Stheraven return __o->test_and_set(); 1669227825Stheraven} 1670227825Stheraven 1671227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1672227825Stheravenbool 1673234959Stheravenatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 1674227825Stheraven{ 1675227825Stheraven return __o->test_and_set(); 1676227825Stheraven} 1677227825Stheraven 1678227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1679227825Stheravenbool 1680234959Stheravenatomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1681227825Stheraven{ 1682227825Stheraven return __o->test_and_set(__m); 1683227825Stheraven} 1684227825Stheraven 1685227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1686227825Stheravenbool 1687234959Stheravenatomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1688227825Stheraven{ 1689227825Stheraven return __o->test_and_set(__m); 1690227825Stheraven} 1691227825Stheraven 1692227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1693227825Stheravenvoid 1694234959Stheravenatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 1695227825Stheraven{ 1696227825Stheraven __o->clear(); 1697227825Stheraven} 1698227825Stheraven 1699227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1700227825Stheravenvoid 1701234959Stheravenatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 1702227825Stheraven{ 1703227825Stheraven __o->clear(); 1704227825Stheraven} 1705227825Stheraven 1706227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1707227825Stheravenvoid 1708234959Stheravenatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1709227825Stheraven{ 1710227825Stheraven __o->clear(__m); 1711227825Stheraven} 1712227825Stheraven 1713227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1714227825Stheravenvoid 1715234959Stheravenatomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1716227825Stheraven{ 1717227825Stheraven __o->clear(__m); 1718227825Stheraven} 1719227825Stheraven 1720227825Stheraven// fences 1721227825Stheraven 1722227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1723227825Stheravenvoid 1724234959Stheravenatomic_thread_fence(memory_order __m) _NOEXCEPT 1725227825Stheraven{ 1726234959Stheraven __c11_atomic_thread_fence(__m); 1727227825Stheraven} 1728227825Stheraven 1729227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1730227825Stheravenvoid 1731234959Stheravenatomic_signal_fence(memory_order __m) _NOEXCEPT 1732227825Stheraven{ 1733234959Stheraven __c11_atomic_signal_fence(__m); 1734227825Stheraven} 1735227825Stheraven 1736227825Stheraven// Atomics for standard typedef types 1737227825Stheraven 1738246468Stheraventypedef atomic<bool> atomic_bool; 1739227825Stheraventypedef atomic<char> atomic_char; 1740227825Stheraventypedef atomic<signed char> atomic_schar; 1741227825Stheraventypedef atomic<unsigned char> atomic_uchar; 1742227825Stheraventypedef atomic<short> atomic_short; 1743227825Stheraventypedef atomic<unsigned short> atomic_ushort; 1744227825Stheraventypedef atomic<int> atomic_int; 1745227825Stheraventypedef atomic<unsigned int> atomic_uint; 1746227825Stheraventypedef atomic<long> atomic_long; 1747227825Stheraventypedef atomic<unsigned long> atomic_ulong; 1748227825Stheraventypedef atomic<long long> atomic_llong; 1749227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 1750227825Stheraventypedef atomic<char16_t> atomic_char16_t; 1751227825Stheraventypedef atomic<char32_t> atomic_char32_t; 1752227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 1753227825Stheraven 1754227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 1755227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 1756227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 1757227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 1758227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 1759227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 1760227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 1761227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 1762227825Stheraven 1763227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 1764227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 1765227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 1766227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 1767227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 1768227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 1769227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 1770227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 1771227825Stheraven 1772227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 1773227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 1774227825Stheraventypedef atomic<size_t> atomic_size_t; 1775227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 1776227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 1777227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 1778227825Stheraven 1779227825Stheraven#define ATOMIC_FLAG_INIT {false} 1780227825Stheraven#define ATOMIC_VAR_INIT(__v) {__v} 1781227825Stheraven 1782227825Stheraven// lock-free property 1783227825Stheraven 1784246468Stheraven#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE 1785246468Stheraven#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE 1786246468Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1787246468Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1788246468Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1789246468Stheraven#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE 1790246468Stheraven#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE 1791246468Stheraven#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE 1792246468Stheraven#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE 1793246468Stheraven#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE 1794227825Stheraven 1795227825Stheraven#endif // !__has_feature(cxx_atomic) 1796227825Stheraven 1797227825Stheraven_LIBCPP_END_NAMESPACE_STD 1798227825Stheraven 1799276792Sdim#endif // !_LIBCPP_HAS_NO_THREADS 1800276792Sdim 1801227825Stheraven#endif // _LIBCPP_ATOMIC 1802