atomic revision 276792
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 { 554276792Sdimtemplate <typename T> 555276792Sdimstruct __gcc_atomic_t { 556276792Sdim __gcc_atomic_t() _NOEXCEPT {} 557276792Sdim explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {} 558276792Sdim T __a_value; 559276792Sdim}; 560276792Sdim#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> 561276792Sdim 562276792Sdimtemplate <typename T> T __create(); 563276792Sdim 564276792Sdimtemplate <typename __Tp, typename __Td> 565276792Sdimtypename enable_if<sizeof(__Tp()->__a_value = __create<__Td>()), char>::type 566276792Sdim __test_atomic_assignable(int); 567276792Sdimtemplate <typename T, typename U> 568276792Sdim__two __test_atomic_assignable(...); 569276792Sdim 570276792Sdimtemplate <typename __Tp, typename __Td> 571276792Sdimstruct __can_assign { 572276792Sdim static const bool value = 573276792Sdim sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char); 574276792Sdim}; 575276792Sdim 576276792Sdimstatic inline constexpr int __to_gcc_order(memory_order __order) { 577276792Sdim // Avoid switch statement to make this a constexpr. 578276792Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 579276792Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 580276792Sdim (__order == memory_order_release ? __ATOMIC_RELEASE: 581276792Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 582276792Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: 583276792Sdim __ATOMIC_CONSUME)))); 584276792Sdim} 585276792Sdim 586276792Sdim} // namespace __gcc_atomic 587276792Sdim 588276792Sdimtemplate <typename _Tp> 589276792Sdimstatic inline 590276792Sdimtypename enable_if< 591276792Sdim __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type 592276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 593276792Sdim __a->__a_value = __val; 594276792Sdim} 595276792Sdim 596276792Sdimtemplate <typename _Tp> 597276792Sdimstatic inline 598276792Sdimtypename enable_if< 599276792Sdim !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && 600276792Sdim __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type 601276792Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 602276792Sdim // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because 603276792Sdim // the default operator= in an object is not volatile, a byte-by-byte copy 604276792Sdim // is required. 605276792Sdim volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); 606276792Sdim volatile char* end = to + sizeof(_Tp); 607276792Sdim char* from = reinterpret_cast<char*>(&__val); 608276792Sdim while (to != end) { 609276792Sdim *to++ = *from++; 610276792Sdim } 611276792Sdim} 612276792Sdim 613276792Sdimtemplate <typename _Tp> 614276792Sdimstatic inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { 615276792Sdim __a->__a_value = __val; 616276792Sdim} 617276792Sdim 618276792Sdimstatic inline void __c11_atomic_thread_fence(memory_order __order) { 619276792Sdim __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); 620276792Sdim} 621276792Sdim 622276792Sdimstatic inline void __c11_atomic_signal_fence(memory_order __order) { 623276792Sdim __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); 624276792Sdim} 625276792Sdim 626276792Sdimstatic inline bool __c11_atomic_is_lock_free(size_t __size) { 627276792Sdim return __atomic_is_lock_free(__size, 0); 628276792Sdim} 629276792Sdim 630276792Sdimtemplate <typename _Tp> 631276792Sdimstatic inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, 632276792Sdim memory_order __order) { 633276792Sdim return __atomic_store(&__a->__a_value, &__val, 634276792Sdim __gcc_atomic::__to_gcc_order(__order)); 635276792Sdim} 636276792Sdim 637276792Sdimtemplate <typename _Tp> 638276792Sdimstatic inline void __c11_atomic_store(_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 _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, 646276792Sdim memory_order __order) { 647276792Sdim _Tp __ret; 648276792Sdim __atomic_load(&__a->__a_value, &__ret, 649276792Sdim __gcc_atomic::__to_gcc_order(__order)); 650276792Sdim return __ret; 651276792Sdim} 652276792Sdim 653276792Sdimtemplate <typename _Tp> 654276792Sdimstatic inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { 655276792Sdim _Tp __ret; 656276792Sdim __atomic_load(&__a->__a_value, &__ret, 657276792Sdim __gcc_atomic::__to_gcc_order(__order)); 658276792Sdim return __ret; 659276792Sdim} 660276792Sdim 661276792Sdimtemplate <typename _Tp> 662276792Sdimstatic inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, 663276792Sdim _Tp __value, memory_order __order) { 664276792Sdim _Tp __ret; 665276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 666276792Sdim __gcc_atomic::__to_gcc_order(__order)); 667276792Sdim return __ret; 668276792Sdim} 669276792Sdim 670276792Sdimtemplate <typename _Tp> 671276792Sdimstatic inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, 672276792Sdim memory_order __order) { 673276792Sdim _Tp __ret; 674276792Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 675276792Sdim __gcc_atomic::__to_gcc_order(__order)); 676276792Sdim return __ret; 677276792Sdim} 678276792Sdim 679276792Sdimtemplate <typename _Tp> 680276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 681276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 682276792Sdim memory_order __success, memory_order __failure) { 683276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 684276792Sdim false, 685276792Sdim __gcc_atomic::__to_gcc_order(__success), 686276792Sdim __gcc_atomic::__to_gcc_order(__failure)); 687276792Sdim} 688276792Sdim 689276792Sdimtemplate <typename _Tp> 690276792Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 691276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 692276792Sdim memory_order __failure) { 693276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 694276792Sdim false, 695276792Sdim __gcc_atomic::__to_gcc_order(__success), 696276792Sdim __gcc_atomic::__to_gcc_order(__failure)); 697276792Sdim} 698276792Sdim 699276792Sdimtemplate <typename _Tp> 700276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 701276792Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 702276792Sdim memory_order __success, memory_order __failure) { 703276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 704276792Sdim true, 705276792Sdim __gcc_atomic::__to_gcc_order(__success), 706276792Sdim __gcc_atomic::__to_gcc_order(__failure)); 707276792Sdim} 708276792Sdim 709276792Sdimtemplate <typename _Tp> 710276792Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 711276792Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 712276792Sdim memory_order __failure) { 713276792Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 714276792Sdim true, 715276792Sdim __gcc_atomic::__to_gcc_order(__success), 716276792Sdim __gcc_atomic::__to_gcc_order(__failure)); 717276792Sdim} 718276792Sdim 719276792Sdimtemplate <typename _Tp> 720276792Sdimstruct __skip_amt { enum {value = 1}; }; 721276792Sdim 722276792Sdimtemplate <typename _Tp> 723276792Sdimstruct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; 724276792Sdim 725276792Sdim// FIXME: Haven't figured out what the spec says about using arrays with 726276792Sdim// atomic_fetch_add. Force a failure rather than creating bad behavior. 727276792Sdimtemplate <typename _Tp> 728276792Sdimstruct __skip_amt<_Tp[]> { }; 729276792Sdimtemplate <typename _Tp, int n> 730276792Sdimstruct __skip_amt<_Tp[n]> { }; 731276792Sdim 732276792Sdimtemplate <typename _Tp, typename _Td> 733276792Sdimstatic inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, 734276792Sdim _Td __delta, memory_order __order) { 735276792Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 736276792Sdim __gcc_atomic::__to_gcc_order(__order)); 737276792Sdim} 738276792Sdim 739276792Sdimtemplate <typename _Tp, typename _Td> 740276792Sdimstatic inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, 741276792Sdim 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_sub(volatile _Atomic(_Tp)* __a, 748276792Sdim _Td __delta, memory_order __order) { 749276792Sdim return __atomic_fetch_sub(&__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(_Atomic(_Tp)* __a, _Td __delta, 755276792Sdim 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> 761276792Sdimstatic inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, 762276792Sdim _Tp __pattern, memory_order __order) { 763276792Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 764276792Sdim __gcc_atomic::__to_gcc_order(__order)); 765276792Sdim} 766276792Sdim 767276792Sdimtemplate <typename _Tp> 768276792Sdimstatic inline _Tp __c11_atomic_fetch_and(_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_or(volatile _Atomic(_Tp)* __a, 776276792Sdim _Tp __pattern, memory_order __order) { 777276792Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 778276792Sdim __gcc_atomic::__to_gcc_order(__order)); 779276792Sdim} 780276792Sdim 781276792Sdimtemplate <typename _Tp> 782276792Sdimstatic inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, 783276792Sdim 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_xor(volatile _Atomic(_Tp)* __a, 790276792Sdim _Tp __pattern, memory_order __order) { 791276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 792276792Sdim __gcc_atomic::__to_gcc_order(__order)); 793276792Sdim} 794276792Sdim 795276792Sdimtemplate <typename _Tp> 796276792Sdimstatic inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, 797276792Sdim memory_order __order) { 798276792Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 799276792Sdim __gcc_atomic::__to_gcc_order(__order)); 800276792Sdim} 801276792Sdim#endif // _GNUC_VER >= 407 802276792Sdim 803227825Stheraventemplate <class _Tp> 804227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 805227825Stheraven_Tp 806234959Stheravenkill_dependency(_Tp __y) _NOEXCEPT 807227825Stheraven{ 808227825Stheraven return __y; 809227825Stheraven} 810227825Stheraven 811227825Stheraven// general atomic<T> 812227825Stheraven 813227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> 814227825Stheravenstruct __atomic_base // false 815227825Stheraven{ 816241900Sdim mutable _Atomic(_Tp) __a_; 817227825Stheraven 818227825Stheraven _LIBCPP_INLINE_VISIBILITY 819234959Stheraven bool is_lock_free() const volatile _NOEXCEPT 820234959Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 821227825Stheraven _LIBCPP_INLINE_VISIBILITY 822234959Stheraven bool is_lock_free() const _NOEXCEPT 823234959Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 824227825Stheraven _LIBCPP_INLINE_VISIBILITY 825234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 826234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 827227825Stheraven _LIBCPP_INLINE_VISIBILITY 828234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 829234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 830227825Stheraven _LIBCPP_INLINE_VISIBILITY 831234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 832234959Stheraven {return __c11_atomic_load(&__a_, __m);} 833227825Stheraven _LIBCPP_INLINE_VISIBILITY 834234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 835234959Stheraven {return __c11_atomic_load(&__a_, __m);} 836227825Stheraven _LIBCPP_INLINE_VISIBILITY 837234959Stheraven operator _Tp() const volatile _NOEXCEPT {return load();} 838227825Stheraven _LIBCPP_INLINE_VISIBILITY 839234959Stheraven operator _Tp() const _NOEXCEPT {return load();} 840227825Stheraven _LIBCPP_INLINE_VISIBILITY 841234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 842234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 843227825Stheraven _LIBCPP_INLINE_VISIBILITY 844234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 845234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 846227825Stheraven _LIBCPP_INLINE_VISIBILITY 847227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 848234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 849234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 850227825Stheraven _LIBCPP_INLINE_VISIBILITY 851227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 852234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 853234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 854227825Stheraven _LIBCPP_INLINE_VISIBILITY 855227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 856234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 857234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 858227825Stheraven _LIBCPP_INLINE_VISIBILITY 859227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 860234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 861234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 862227825Stheraven _LIBCPP_INLINE_VISIBILITY 863227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 864234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 865234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 866227825Stheraven _LIBCPP_INLINE_VISIBILITY 867227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 868234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 869234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 870227825Stheraven _LIBCPP_INLINE_VISIBILITY 871227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 872234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 873234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 874227825Stheraven _LIBCPP_INLINE_VISIBILITY 875227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 876234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 877234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 878227825Stheraven 879227825Stheraven _LIBCPP_INLINE_VISIBILITY 880253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 881253146Stheraven __atomic_base() _NOEXCEPT = default; 882253146Stheraven#else 883253146Stheraven __atomic_base() _NOEXCEPT : __a_() {} 884253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 885253146Stheraven 886227825Stheraven _LIBCPP_INLINE_VISIBILITY 887234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} 888227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 889227825Stheraven __atomic_base(const __atomic_base&) = delete; 890227825Stheraven __atomic_base& operator=(const __atomic_base&) = delete; 891227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile = delete; 892227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 893227825Stheravenprivate: 894227825Stheraven __atomic_base(const __atomic_base&); 895227825Stheraven __atomic_base& operator=(const __atomic_base&); 896227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile; 897227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 898227825Stheraven}; 899227825Stheraven 900227825Stheraven// atomic<Integral> 901227825Stheraven 902227825Stheraventemplate <class _Tp> 903227825Stheravenstruct __atomic_base<_Tp, true> 904227825Stheraven : public __atomic_base<_Tp, false> 905227825Stheraven{ 906227825Stheraven typedef __atomic_base<_Tp, false> __base; 907227825Stheraven _LIBCPP_INLINE_VISIBILITY 908253146Stheraven __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT 909227825Stheraven _LIBCPP_INLINE_VISIBILITY 910234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 911227825Stheraven 912227825Stheraven _LIBCPP_INLINE_VISIBILITY 913234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 914234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 915227825Stheraven _LIBCPP_INLINE_VISIBILITY 916234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 917234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 918227825Stheraven _LIBCPP_INLINE_VISIBILITY 919234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 920234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 921227825Stheraven _LIBCPP_INLINE_VISIBILITY 922234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 923234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 924227825Stheraven _LIBCPP_INLINE_VISIBILITY 925234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 926234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 927227825Stheraven _LIBCPP_INLINE_VISIBILITY 928234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 929234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 930227825Stheraven _LIBCPP_INLINE_VISIBILITY 931234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 932234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 933227825Stheraven _LIBCPP_INLINE_VISIBILITY 934234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 935234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 936227825Stheraven _LIBCPP_INLINE_VISIBILITY 937234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 938234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 939227825Stheraven _LIBCPP_INLINE_VISIBILITY 940234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 941234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 942227825Stheraven 943227825Stheraven _LIBCPP_INLINE_VISIBILITY 944234959Stheraven _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 945227825Stheraven _LIBCPP_INLINE_VISIBILITY 946234959Stheraven _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 947227825Stheraven _LIBCPP_INLINE_VISIBILITY 948234959Stheraven _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 949227825Stheraven _LIBCPP_INLINE_VISIBILITY 950234959Stheraven _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 951227825Stheraven _LIBCPP_INLINE_VISIBILITY 952234959Stheraven _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 953227825Stheraven _LIBCPP_INLINE_VISIBILITY 954234959Stheraven _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 955227825Stheraven _LIBCPP_INLINE_VISIBILITY 956234959Stheraven _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 957227825Stheraven _LIBCPP_INLINE_VISIBILITY 958234959Stheraven _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 959227825Stheraven _LIBCPP_INLINE_VISIBILITY 960234959Stheraven _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 961227825Stheraven _LIBCPP_INLINE_VISIBILITY 962234959Stheraven _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 963227825Stheraven _LIBCPP_INLINE_VISIBILITY 964234959Stheraven _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 965227825Stheraven _LIBCPP_INLINE_VISIBILITY 966234959Stheraven _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 967227825Stheraven _LIBCPP_INLINE_VISIBILITY 968234959Stheraven _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 969227825Stheraven _LIBCPP_INLINE_VISIBILITY 970234959Stheraven _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 971227825Stheraven _LIBCPP_INLINE_VISIBILITY 972234959Stheraven _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 973227825Stheraven _LIBCPP_INLINE_VISIBILITY 974234959Stheraven _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 975227825Stheraven _LIBCPP_INLINE_VISIBILITY 976234959Stheraven _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 977227825Stheraven _LIBCPP_INLINE_VISIBILITY 978234959Stheraven _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} 979227825Stheraven}; 980227825Stheraven 981227825Stheraven// atomic<T> 982227825Stheraven 983227825Stheraventemplate <class _Tp> 984227825Stheravenstruct atomic 985227825Stheraven : public __atomic_base<_Tp> 986227825Stheraven{ 987227825Stheraven typedef __atomic_base<_Tp> __base; 988227825Stheraven _LIBCPP_INLINE_VISIBILITY 989253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 990227825Stheraven _LIBCPP_INLINE_VISIBILITY 991234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 992227825Stheraven 993227825Stheraven _LIBCPP_INLINE_VISIBILITY 994234959Stheraven _Tp operator=(_Tp __d) volatile _NOEXCEPT 995227825Stheraven {__base::store(__d); return __d;} 996227825Stheraven _LIBCPP_INLINE_VISIBILITY 997234959Stheraven _Tp operator=(_Tp __d) _NOEXCEPT 998227825Stheraven {__base::store(__d); return __d;} 999227825Stheraven}; 1000227825Stheraven 1001227825Stheraven// atomic<T*> 1002227825Stheraven 1003227825Stheraventemplate <class _Tp> 1004227825Stheravenstruct atomic<_Tp*> 1005227825Stheraven : public __atomic_base<_Tp*> 1006227825Stheraven{ 1007227825Stheraven typedef __atomic_base<_Tp*> __base; 1008227825Stheraven _LIBCPP_INLINE_VISIBILITY 1009253146Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1010227825Stheraven _LIBCPP_INLINE_VISIBILITY 1011234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 1012227825Stheraven 1013227825Stheraven _LIBCPP_INLINE_VISIBILITY 1014234959Stheraven _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 1015227825Stheraven {__base::store(__d); return __d;} 1016227825Stheraven _LIBCPP_INLINE_VISIBILITY 1017234959Stheraven _Tp* operator=(_Tp* __d) _NOEXCEPT 1018227825Stheraven {__base::store(__d); return __d;} 1019227825Stheraven 1020227825Stheraven _LIBCPP_INLINE_VISIBILITY 1021227825Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1022234959Stheraven volatile _NOEXCEPT 1023234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1024227825Stheraven _LIBCPP_INLINE_VISIBILITY 1025234959Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1026234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1027227825Stheraven _LIBCPP_INLINE_VISIBILITY 1028227825Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 1029234959Stheraven volatile _NOEXCEPT 1030234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1031227825Stheraven _LIBCPP_INLINE_VISIBILITY 1032234959Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1033234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1034227825Stheraven 1035227825Stheraven _LIBCPP_INLINE_VISIBILITY 1036234959Stheraven _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 1037227825Stheraven _LIBCPP_INLINE_VISIBILITY 1038234959Stheraven _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 1039227825Stheraven _LIBCPP_INLINE_VISIBILITY 1040234959Stheraven _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 1041227825Stheraven _LIBCPP_INLINE_VISIBILITY 1042234959Stheraven _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 1043227825Stheraven _LIBCPP_INLINE_VISIBILITY 1044234959Stheraven _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 1045227825Stheraven _LIBCPP_INLINE_VISIBILITY 1046234959Stheraven _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 1047227825Stheraven _LIBCPP_INLINE_VISIBILITY 1048234959Stheraven _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 1049227825Stheraven _LIBCPP_INLINE_VISIBILITY 1050234959Stheraven _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 1051227825Stheraven _LIBCPP_INLINE_VISIBILITY 1052234959Stheraven _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 1053227825Stheraven _LIBCPP_INLINE_VISIBILITY 1054234959Stheraven _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 1055227825Stheraven _LIBCPP_INLINE_VISIBILITY 1056234959Stheraven _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 1057227825Stheraven _LIBCPP_INLINE_VISIBILITY 1058234959Stheraven _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 1059227825Stheraven}; 1060227825Stheraven 1061227825Stheraven// atomic_is_lock_free 1062227825Stheraven 1063227825Stheraventemplate <class _Tp> 1064227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1065227825Stheravenbool 1066234959Stheravenatomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT 1067227825Stheraven{ 1068227825Stheraven return __o->is_lock_free(); 1069227825Stheraven} 1070227825Stheraven 1071227825Stheraventemplate <class _Tp> 1072227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1073227825Stheravenbool 1074234959Stheravenatomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT 1075227825Stheraven{ 1076227825Stheraven return __o->is_lock_free(); 1077227825Stheraven} 1078227825Stheraven 1079227825Stheraven// atomic_init 1080227825Stheraven 1081227825Stheraventemplate <class _Tp> 1082227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1083227825Stheravenvoid 1084234959Stheravenatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1085227825Stheraven{ 1086234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1087227825Stheraven} 1088227825Stheraven 1089227825Stheraventemplate <class _Tp> 1090227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1091227825Stheravenvoid 1092234959Stheravenatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1093227825Stheraven{ 1094234959Stheraven __c11_atomic_init(&__o->__a_, __d); 1095227825Stheraven} 1096227825Stheraven 1097227825Stheraven// atomic_store 1098227825Stheraven 1099227825Stheraventemplate <class _Tp> 1100227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1101227825Stheravenvoid 1102234959Stheravenatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1103227825Stheraven{ 1104227825Stheraven __o->store(__d); 1105227825Stheraven} 1106227825Stheraven 1107227825Stheraventemplate <class _Tp> 1108227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1109227825Stheravenvoid 1110234959Stheravenatomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1111227825Stheraven{ 1112227825Stheraven __o->store(__d); 1113227825Stheraven} 1114227825Stheraven 1115227825Stheraven// atomic_store_explicit 1116227825Stheraven 1117227825Stheraventemplate <class _Tp> 1118227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1119227825Stheravenvoid 1120234959Stheravenatomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1121227825Stheraven{ 1122227825Stheraven __o->store(__d, __m); 1123227825Stheraven} 1124227825Stheraven 1125227825Stheraventemplate <class _Tp> 1126227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1127227825Stheravenvoid 1128234959Stheravenatomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1129227825Stheraven{ 1130227825Stheraven __o->store(__d, __m); 1131227825Stheraven} 1132227825Stheraven 1133227825Stheraven// atomic_load 1134227825Stheraven 1135227825Stheraventemplate <class _Tp> 1136227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1137227825Stheraven_Tp 1138234959Stheravenatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 1139227825Stheraven{ 1140227825Stheraven return __o->load(); 1141227825Stheraven} 1142227825Stheraven 1143227825Stheraventemplate <class _Tp> 1144227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1145227825Stheraven_Tp 1146234959Stheravenatomic_load(const atomic<_Tp>* __o) _NOEXCEPT 1147227825Stheraven{ 1148227825Stheraven return __o->load(); 1149227825Stheraven} 1150227825Stheraven 1151227825Stheraven// atomic_load_explicit 1152227825Stheraven 1153227825Stheraventemplate <class _Tp> 1154227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1155227825Stheraven_Tp 1156234959Stheravenatomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1157227825Stheraven{ 1158227825Stheraven return __o->load(__m); 1159227825Stheraven} 1160227825Stheraven 1161227825Stheraventemplate <class _Tp> 1162227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1163227825Stheraven_Tp 1164234959Stheravenatomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 1165227825Stheraven{ 1166227825Stheraven return __o->load(__m); 1167227825Stheraven} 1168227825Stheraven 1169227825Stheraven// atomic_exchange 1170227825Stheraven 1171227825Stheraventemplate <class _Tp> 1172227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1173227825Stheraven_Tp 1174234959Stheravenatomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1175227825Stheraven{ 1176227825Stheraven return __o->exchange(__d); 1177227825Stheraven} 1178227825Stheraven 1179227825Stheraventemplate <class _Tp> 1180227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1181227825Stheraven_Tp 1182234959Stheravenatomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1183227825Stheraven{ 1184227825Stheraven return __o->exchange(__d); 1185227825Stheraven} 1186227825Stheraven 1187227825Stheraven// atomic_exchange_explicit 1188227825Stheraven 1189227825Stheraventemplate <class _Tp> 1190227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1191227825Stheraven_Tp 1192234959Stheravenatomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1193227825Stheraven{ 1194227825Stheraven return __o->exchange(__d, __m); 1195227825Stheraven} 1196227825Stheraven 1197227825Stheraventemplate <class _Tp> 1198227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1199227825Stheraven_Tp 1200234959Stheravenatomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 1201227825Stheraven{ 1202227825Stheraven return __o->exchange(__d, __m); 1203227825Stheraven} 1204227825Stheraven 1205227825Stheraven// atomic_compare_exchange_weak 1206227825Stheraven 1207227825Stheraventemplate <class _Tp> 1208227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1209227825Stheravenbool 1210234959Stheravenatomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1211227825Stheraven{ 1212227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1213227825Stheraven} 1214227825Stheraven 1215227825Stheraventemplate <class _Tp> 1216227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1217227825Stheravenbool 1218234959Stheravenatomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1219227825Stheraven{ 1220227825Stheraven return __o->compare_exchange_weak(*__e, __d); 1221227825Stheraven} 1222227825Stheraven 1223227825Stheraven// atomic_compare_exchange_strong 1224227825Stheraven 1225227825Stheraventemplate <class _Tp> 1226227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1227227825Stheravenbool 1228234959Stheravenatomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1229227825Stheraven{ 1230227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1231227825Stheraven} 1232227825Stheraven 1233227825Stheraventemplate <class _Tp> 1234227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1235227825Stheravenbool 1236234959Stheravenatomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 1237227825Stheraven{ 1238227825Stheraven return __o->compare_exchange_strong(*__e, __d); 1239227825Stheraven} 1240227825Stheraven 1241227825Stheraven// atomic_compare_exchange_weak_explicit 1242227825Stheraven 1243227825Stheraventemplate <class _Tp> 1244227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1245227825Stheravenbool 1246227825Stheravenatomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, 1247227825Stheraven _Tp __d, 1248234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1249227825Stheraven{ 1250227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1251227825Stheraven} 1252227825Stheraven 1253227825Stheraventemplate <class _Tp> 1254227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1255227825Stheravenbool 1256227825Stheravenatomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, 1257234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1258227825Stheraven{ 1259227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 1260227825Stheraven} 1261227825Stheraven 1262227825Stheraven// atomic_compare_exchange_strong_explicit 1263227825Stheraven 1264227825Stheraventemplate <class _Tp> 1265227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1266227825Stheravenbool 1267227825Stheravenatomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, 1268227825Stheraven _Tp* __e, _Tp __d, 1269234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1270227825Stheraven{ 1271227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1272227825Stheraven} 1273227825Stheraven 1274227825Stheraventemplate <class _Tp> 1275227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1276227825Stheravenbool 1277227825Stheravenatomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, 1278227825Stheraven _Tp __d, 1279234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1280227825Stheraven{ 1281227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1282227825Stheraven} 1283227825Stheraven 1284227825Stheraven// atomic_fetch_add 1285227825Stheraven 1286227825Stheraventemplate <class _Tp> 1287227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1288227825Stheraventypename enable_if 1289227825Stheraven< 1290227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1291227825Stheraven _Tp 1292227825Stheraven>::type 1293234959Stheravenatomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1294227825Stheraven{ 1295227825Stheraven return __o->fetch_add(__op); 1296227825Stheraven} 1297227825Stheraven 1298227825Stheraventemplate <class _Tp> 1299227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1300227825Stheraventypename enable_if 1301227825Stheraven< 1302227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1303227825Stheraven _Tp 1304227825Stheraven>::type 1305234959Stheravenatomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1306227825Stheraven{ 1307227825Stheraven return __o->fetch_add(__op); 1308227825Stheraven} 1309227825Stheraven 1310227825Stheraventemplate <class _Tp> 1311227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1312227825Stheraven_Tp* 1313234959Stheravenatomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1314227825Stheraven{ 1315227825Stheraven return __o->fetch_add(__op); 1316227825Stheraven} 1317227825Stheraven 1318227825Stheraventemplate <class _Tp> 1319227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1320227825Stheraven_Tp* 1321234959Stheravenatomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1322227825Stheraven{ 1323227825Stheraven return __o->fetch_add(__op); 1324227825Stheraven} 1325227825Stheraven 1326227825Stheraven// atomic_fetch_add_explicit 1327227825Stheraven 1328227825Stheraventemplate <class _Tp> 1329227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1330227825Stheraventypename enable_if 1331227825Stheraven< 1332227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1333227825Stheraven _Tp 1334227825Stheraven>::type 1335234959Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1336227825Stheraven{ 1337227825Stheraven return __o->fetch_add(__op, __m); 1338227825Stheraven} 1339227825Stheraven 1340227825Stheraventemplate <class _Tp> 1341227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1342227825Stheraventypename enable_if 1343227825Stheraven< 1344227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1345227825Stheraven _Tp 1346227825Stheraven>::type 1347234959Stheravenatomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1348227825Stheraven{ 1349227825Stheraven return __o->fetch_add(__op, __m); 1350227825Stheraven} 1351227825Stheraven 1352227825Stheraventemplate <class _Tp> 1353227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1354227825Stheraven_Tp* 1355227825Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1356234959Stheraven memory_order __m) _NOEXCEPT 1357227825Stheraven{ 1358227825Stheraven return __o->fetch_add(__op, __m); 1359227825Stheraven} 1360227825Stheraven 1361227825Stheraventemplate <class _Tp> 1362227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1363227825Stheraven_Tp* 1364234959Stheravenatomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1365227825Stheraven{ 1366227825Stheraven return __o->fetch_add(__op, __m); 1367227825Stheraven} 1368227825Stheraven 1369227825Stheraven// atomic_fetch_sub 1370227825Stheraven 1371227825Stheraventemplate <class _Tp> 1372227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1373227825Stheraventypename enable_if 1374227825Stheraven< 1375227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1376227825Stheraven _Tp 1377227825Stheraven>::type 1378234959Stheravenatomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1379227825Stheraven{ 1380227825Stheraven return __o->fetch_sub(__op); 1381227825Stheraven} 1382227825Stheraven 1383227825Stheraventemplate <class _Tp> 1384227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1385227825Stheraventypename enable_if 1386227825Stheraven< 1387227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1388227825Stheraven _Tp 1389227825Stheraven>::type 1390234959Stheravenatomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1391227825Stheraven{ 1392227825Stheraven return __o->fetch_sub(__op); 1393227825Stheraven} 1394227825Stheraven 1395227825Stheraventemplate <class _Tp> 1396227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1397227825Stheraven_Tp* 1398234959Stheravenatomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1399227825Stheraven{ 1400227825Stheraven return __o->fetch_sub(__op); 1401227825Stheraven} 1402227825Stheraven 1403227825Stheraventemplate <class _Tp> 1404227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1405227825Stheraven_Tp* 1406234959Stheravenatomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1407227825Stheraven{ 1408227825Stheraven return __o->fetch_sub(__op); 1409227825Stheraven} 1410227825Stheraven 1411227825Stheraven// atomic_fetch_sub_explicit 1412227825Stheraven 1413227825Stheraventemplate <class _Tp> 1414227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1415227825Stheraventypename enable_if 1416227825Stheraven< 1417227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1418227825Stheraven _Tp 1419227825Stheraven>::type 1420234959Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1421227825Stheraven{ 1422227825Stheraven return __o->fetch_sub(__op, __m); 1423227825Stheraven} 1424227825Stheraven 1425227825Stheraventemplate <class _Tp> 1426227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1427227825Stheraventypename enable_if 1428227825Stheraven< 1429227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1430227825Stheraven _Tp 1431227825Stheraven>::type 1432234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1433227825Stheraven{ 1434227825Stheraven return __o->fetch_sub(__op, __m); 1435227825Stheraven} 1436227825Stheraven 1437227825Stheraventemplate <class _Tp> 1438227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1439227825Stheraven_Tp* 1440227825Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1441234959Stheraven memory_order __m) _NOEXCEPT 1442227825Stheraven{ 1443227825Stheraven return __o->fetch_sub(__op, __m); 1444227825Stheraven} 1445227825Stheraven 1446227825Stheraventemplate <class _Tp> 1447227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1448227825Stheraven_Tp* 1449234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1450227825Stheraven{ 1451227825Stheraven return __o->fetch_sub(__op, __m); 1452227825Stheraven} 1453227825Stheraven 1454227825Stheraven// atomic_fetch_and 1455227825Stheraven 1456227825Stheraventemplate <class _Tp> 1457227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1458227825Stheraventypename enable_if 1459227825Stheraven< 1460227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1461227825Stheraven _Tp 1462227825Stheraven>::type 1463234959Stheravenatomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1464227825Stheraven{ 1465227825Stheraven return __o->fetch_and(__op); 1466227825Stheraven} 1467227825Stheraven 1468227825Stheraventemplate <class _Tp> 1469227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1470227825Stheraventypename enable_if 1471227825Stheraven< 1472227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1473227825Stheraven _Tp 1474227825Stheraven>::type 1475234959Stheravenatomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1476227825Stheraven{ 1477227825Stheraven return __o->fetch_and(__op); 1478227825Stheraven} 1479227825Stheraven 1480227825Stheraven// atomic_fetch_and_explicit 1481227825Stheraven 1482227825Stheraventemplate <class _Tp> 1483227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1484227825Stheraventypename enable_if 1485227825Stheraven< 1486227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1487227825Stheraven _Tp 1488227825Stheraven>::type 1489234959Stheravenatomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1490227825Stheraven{ 1491227825Stheraven return __o->fetch_and(__op, __m); 1492227825Stheraven} 1493227825Stheraven 1494227825Stheraventemplate <class _Tp> 1495227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1496227825Stheraventypename enable_if 1497227825Stheraven< 1498227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1499227825Stheraven _Tp 1500227825Stheraven>::type 1501234959Stheravenatomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1502227825Stheraven{ 1503227825Stheraven return __o->fetch_and(__op, __m); 1504227825Stheraven} 1505227825Stheraven 1506227825Stheraven// atomic_fetch_or 1507227825Stheraven 1508227825Stheraventemplate <class _Tp> 1509227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1510227825Stheraventypename enable_if 1511227825Stheraven< 1512227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1513227825Stheraven _Tp 1514227825Stheraven>::type 1515234959Stheravenatomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1516227825Stheraven{ 1517227825Stheraven return __o->fetch_or(__op); 1518227825Stheraven} 1519227825Stheraven 1520227825Stheraventemplate <class _Tp> 1521227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1522227825Stheraventypename enable_if 1523227825Stheraven< 1524227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1525227825Stheraven _Tp 1526227825Stheraven>::type 1527234959Stheravenatomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1528227825Stheraven{ 1529227825Stheraven return __o->fetch_or(__op); 1530227825Stheraven} 1531227825Stheraven 1532227825Stheraven// atomic_fetch_or_explicit 1533227825Stheraven 1534227825Stheraventemplate <class _Tp> 1535227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1536227825Stheraventypename enable_if 1537227825Stheraven< 1538227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1539227825Stheraven _Tp 1540227825Stheraven>::type 1541234959Stheravenatomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1542227825Stheraven{ 1543227825Stheraven return __o->fetch_or(__op, __m); 1544227825Stheraven} 1545227825Stheraven 1546227825Stheraventemplate <class _Tp> 1547227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1548227825Stheraventypename enable_if 1549227825Stheraven< 1550227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1551227825Stheraven _Tp 1552227825Stheraven>::type 1553234959Stheravenatomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1554227825Stheraven{ 1555227825Stheraven return __o->fetch_or(__op, __m); 1556227825Stheraven} 1557227825Stheraven 1558227825Stheraven// atomic_fetch_xor 1559227825Stheraven 1560227825Stheraventemplate <class _Tp> 1561227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1562227825Stheraventypename enable_if 1563227825Stheraven< 1564227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1565227825Stheraven _Tp 1566227825Stheraven>::type 1567234959Stheravenatomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1568227825Stheraven{ 1569227825Stheraven return __o->fetch_xor(__op); 1570227825Stheraven} 1571227825Stheraven 1572227825Stheraventemplate <class _Tp> 1573227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1574227825Stheraventypename enable_if 1575227825Stheraven< 1576227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1577227825Stheraven _Tp 1578227825Stheraven>::type 1579234959Stheravenatomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1580227825Stheraven{ 1581227825Stheraven return __o->fetch_xor(__op); 1582227825Stheraven} 1583227825Stheraven 1584227825Stheraven// atomic_fetch_xor_explicit 1585227825Stheraven 1586227825Stheraventemplate <class _Tp> 1587227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1588227825Stheraventypename enable_if 1589227825Stheraven< 1590227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1591227825Stheraven _Tp 1592227825Stheraven>::type 1593234959Stheravenatomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1594227825Stheraven{ 1595227825Stheraven return __o->fetch_xor(__op, __m); 1596227825Stheraven} 1597227825Stheraven 1598227825Stheraventemplate <class _Tp> 1599227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1600227825Stheraventypename enable_if 1601227825Stheraven< 1602227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1603227825Stheraven _Tp 1604227825Stheraven>::type 1605234959Stheravenatomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1606227825Stheraven{ 1607227825Stheraven return __o->fetch_xor(__op, __m); 1608227825Stheraven} 1609227825Stheraven 1610227825Stheraven// flag type and operations 1611227825Stheraven 1612227825Stheraventypedef struct atomic_flag 1613227825Stheraven{ 1614232924Stheraven _Atomic(bool) __a_; 1615227825Stheraven 1616227825Stheraven _LIBCPP_INLINE_VISIBILITY 1617234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1618234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1619227825Stheraven _LIBCPP_INLINE_VISIBILITY 1620234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1621234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1622227825Stheraven _LIBCPP_INLINE_VISIBILITY 1623234959Stheraven void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1624234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1625227825Stheraven _LIBCPP_INLINE_VISIBILITY 1626234959Stheraven void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1627234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1628227825Stheraven 1629227825Stheraven _LIBCPP_INLINE_VISIBILITY 1630253146Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1631253146Stheraven atomic_flag() _NOEXCEPT = default; 1632253146Stheraven#else 1633253146Stheraven atomic_flag() _NOEXCEPT : __a_() {} 1634253146Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1635253146Stheraven 1636227825Stheraven _LIBCPP_INLINE_VISIBILITY 1637234959Stheraven atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} 1638227825Stheraven 1639227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1640227825Stheraven atomic_flag(const atomic_flag&) = delete; 1641227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 1642227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 1643227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1644227825Stheravenprivate: 1645227825Stheraven atomic_flag(const atomic_flag&); 1646227825Stheraven atomic_flag& operator=(const atomic_flag&); 1647227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile; 1648227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1649227825Stheraven} atomic_flag; 1650227825Stheraven 1651227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1652227825Stheravenbool 1653234959Stheravenatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 1654227825Stheraven{ 1655227825Stheraven return __o->test_and_set(); 1656227825Stheraven} 1657227825Stheraven 1658227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1659227825Stheravenbool 1660234959Stheravenatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 1661227825Stheraven{ 1662227825Stheraven return __o->test_and_set(); 1663227825Stheraven} 1664227825Stheraven 1665227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1666227825Stheravenbool 1667234959Stheravenatomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1668227825Stheraven{ 1669227825Stheraven return __o->test_and_set(__m); 1670227825Stheraven} 1671227825Stheraven 1672227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1673227825Stheravenbool 1674234959Stheravenatomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1675227825Stheraven{ 1676227825Stheraven return __o->test_and_set(__m); 1677227825Stheraven} 1678227825Stheraven 1679227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1680227825Stheravenvoid 1681234959Stheravenatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 1682227825Stheraven{ 1683227825Stheraven __o->clear(); 1684227825Stheraven} 1685227825Stheraven 1686227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1687227825Stheravenvoid 1688234959Stheravenatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 1689227825Stheraven{ 1690227825Stheraven __o->clear(); 1691227825Stheraven} 1692227825Stheraven 1693227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1694227825Stheravenvoid 1695234959Stheravenatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1696227825Stheraven{ 1697227825Stheraven __o->clear(__m); 1698227825Stheraven} 1699227825Stheraven 1700227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1701227825Stheravenvoid 1702234959Stheravenatomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1703227825Stheraven{ 1704227825Stheraven __o->clear(__m); 1705227825Stheraven} 1706227825Stheraven 1707227825Stheraven// fences 1708227825Stheraven 1709227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1710227825Stheravenvoid 1711234959Stheravenatomic_thread_fence(memory_order __m) _NOEXCEPT 1712227825Stheraven{ 1713234959Stheraven __c11_atomic_thread_fence(__m); 1714227825Stheraven} 1715227825Stheraven 1716227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1717227825Stheravenvoid 1718234959Stheravenatomic_signal_fence(memory_order __m) _NOEXCEPT 1719227825Stheraven{ 1720234959Stheraven __c11_atomic_signal_fence(__m); 1721227825Stheraven} 1722227825Stheraven 1723227825Stheraven// Atomics for standard typedef types 1724227825Stheraven 1725246468Stheraventypedef atomic<bool> atomic_bool; 1726227825Stheraventypedef atomic<char> atomic_char; 1727227825Stheraventypedef atomic<signed char> atomic_schar; 1728227825Stheraventypedef atomic<unsigned char> atomic_uchar; 1729227825Stheraventypedef atomic<short> atomic_short; 1730227825Stheraventypedef atomic<unsigned short> atomic_ushort; 1731227825Stheraventypedef atomic<int> atomic_int; 1732227825Stheraventypedef atomic<unsigned int> atomic_uint; 1733227825Stheraventypedef atomic<long> atomic_long; 1734227825Stheraventypedef atomic<unsigned long> atomic_ulong; 1735227825Stheraventypedef atomic<long long> atomic_llong; 1736227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 1737227825Stheraventypedef atomic<char16_t> atomic_char16_t; 1738227825Stheraventypedef atomic<char32_t> atomic_char32_t; 1739227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 1740227825Stheraven 1741227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 1742227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 1743227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 1744227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 1745227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 1746227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 1747227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 1748227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 1749227825Stheraven 1750227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 1751227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 1752227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 1753227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 1754227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 1755227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 1756227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 1757227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 1758227825Stheraven 1759227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 1760227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 1761227825Stheraventypedef atomic<size_t> atomic_size_t; 1762227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 1763227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 1764227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 1765227825Stheraven 1766227825Stheraven#define ATOMIC_FLAG_INIT {false} 1767227825Stheraven#define ATOMIC_VAR_INIT(__v) {__v} 1768227825Stheraven 1769227825Stheraven// lock-free property 1770227825Stheraven 1771246468Stheraven#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE 1772246468Stheraven#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE 1773246468Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1774246468Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1775246468Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1776246468Stheraven#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE 1777246468Stheraven#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE 1778246468Stheraven#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE 1779246468Stheraven#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE 1780246468Stheraven#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE 1781227825Stheraven 1782227825Stheraven#endif // !__has_feature(cxx_atomic) 1783227825Stheraven 1784227825Stheraven_LIBCPP_END_NAMESPACE_STD 1785227825Stheraven 1786276792Sdim#endif // !_LIBCPP_HAS_NO_THREADS 1787276792Sdim 1788227825Stheraven#endif // _LIBCPP_ATOMIC 1789