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 32234976Stheraventemplate <class T> T kill_dependency(T y) noexcept; 33227825Stheraven 34227825Stheraven// lock-free property 35227825Stheraven 36246487Stheraven#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 45246487Stheraven#define ATOMIC_POINTER_LOCK_FREE unspecified 46227825Stheraven 47227825Stheraven// flag type and operations 48227825Stheraven 49227825Stheraventypedef struct atomic_flag 50227825Stheraven{ 51234976Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; 52234976Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; 53234976Stheraven void clear(memory_order m = memory_order_seq_cst) volatile noexcept; 54234976Stheraven void clear(memory_order m = memory_order_seq_cst) noexcept; 55234976Stheraven 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 62234976Stheraven atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; 63227825Stheraven 64227825Stheravenbool 65234976Stheraven atomic_flag_test_and_set(atomic_flag* obj) noexcept; 66227825Stheraven 67227825Stheravenbool 68227825Stheraven atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, 69234976Stheraven memory_order m) noexcept; 70227825Stheraven 71227825Stheravenbool 72234976Stheraven atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; 73227825Stheraven 74227825Stheravenvoid 75234976Stheraven atomic_flag_clear(volatile atomic_flag* obj) noexcept; 76227825Stheraven 77227825Stheravenvoid 78234976Stheraven atomic_flag_clear(atomic_flag* obj) noexcept; 79227825Stheraven 80227825Stheravenvoid 81234976Stheraven atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; 82227825Stheraven 83227825Stheravenvoid 84234976Stheraven 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{ 92234976Stheraven bool is_lock_free() const volatile noexcept; 93234976Stheraven bool is_lock_free() const noexcept; 94234976Stheraven void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 95234976Stheraven void store(T desr, memory_order m = memory_order_seq_cst) noexcept; 96234976Stheraven T load(memory_order m = memory_order_seq_cst) const volatile noexcept; 97234976Stheraven T load(memory_order m = memory_order_seq_cst) const noexcept; 98234976Stheraven operator T() const volatile noexcept; 99234976Stheraven operator T() const noexcept; 100234976Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 101234976Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; 102227825Stheraven bool compare_exchange_weak(T& expc, T desr, 103234976Stheraven memory_order s, memory_order f) volatile noexcept; 104234976Stheraven bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; 105227825Stheraven bool compare_exchange_strong(T& expc, T desr, 106234976Stheraven memory_order s, memory_order f) volatile noexcept; 107227825Stheraven bool compare_exchange_strong(T& expc, T desr, 108234976Stheraven memory_order s, memory_order f) noexcept; 109227825Stheraven bool compare_exchange_weak(T& expc, T desr, 110234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 111227825Stheraven bool compare_exchange_weak(T& expc, T desr, 112234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 113227825Stheraven bool compare_exchange_strong(T& expc, T desr, 114234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 115227825Stheraven bool compare_exchange_strong(T& expc, T desr, 116234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 117227825Stheraven 118234976Stheraven atomic() noexcept = default; 119234976Stheraven constexpr atomic(T desr) noexcept; 120227825Stheraven atomic(const atomic&) = delete; 121227825Stheraven atomic& operator=(const atomic&) = delete; 122227825Stheraven atomic& operator=(const atomic&) volatile = delete; 123234976Stheraven T operator=(T) volatile noexcept; 124234976Stheraven T operator=(T) noexcept; 125227825Stheraven}; 126227825Stheraven 127227825Stheraventemplate <> 128227825Stheravenstruct atomic<integral> 129227825Stheraven{ 130234976Stheraven bool is_lock_free() const volatile noexcept; 131234976Stheraven bool is_lock_free() const noexcept; 132234976Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; 133234976Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; 134234976Stheraven integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; 135234976Stheraven integral load(memory_order m = memory_order_seq_cst) const noexcept; 136234976Stheraven operator integral() const volatile noexcept; 137234976Stheraven operator integral() const noexcept; 138227825Stheraven integral exchange(integral desr, 139234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 140234976Stheraven integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; 141227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 142234976Stheraven memory_order s, memory_order f) volatile noexcept; 143227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 144234976Stheraven memory_order s, memory_order f) noexcept; 145227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 146234976Stheraven memory_order s, memory_order f) volatile noexcept; 147227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 148234976Stheraven memory_order s, memory_order f) noexcept; 149227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 150234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 151227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 152234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 153227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 154234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 155227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 156234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 157227825Stheraven 158227825Stheraven integral 159234976Stheraven fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 160234976Stheraven integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; 161227825Stheraven integral 162234976Stheraven fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 163234976Stheraven integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; 164227825Stheraven integral 165234976Stheraven fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 166234976Stheraven integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; 167227825Stheraven integral 168234976Stheraven fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 169234976Stheraven integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; 170227825Stheraven integral 171234976Stheraven fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 172234976Stheraven integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; 173227825Stheraven 174234976Stheraven atomic() noexcept = default; 175234976Stheraven constexpr atomic(integral desr) noexcept; 176227825Stheraven atomic(const atomic&) = delete; 177227825Stheraven atomic& operator=(const atomic&) = delete; 178227825Stheraven atomic& operator=(const atomic&) volatile = delete; 179234976Stheraven integral operator=(integral desr) volatile noexcept; 180234976Stheraven integral operator=(integral desr) noexcept; 181227825Stheraven 182234976Stheraven integral operator++(int) volatile noexcept; 183234976Stheraven integral operator++(int) noexcept; 184234976Stheraven integral operator--(int) volatile noexcept; 185234976Stheraven integral operator--(int) noexcept; 186234976Stheraven integral operator++() volatile noexcept; 187234976Stheraven integral operator++() noexcept; 188234976Stheraven integral operator--() volatile noexcept; 189234976Stheraven integral operator--() noexcept; 190234976Stheraven integral operator+=(integral op) volatile noexcept; 191234976Stheraven integral operator+=(integral op) noexcept; 192234976Stheraven integral operator-=(integral op) volatile noexcept; 193234976Stheraven integral operator-=(integral op) noexcept; 194234976Stheraven integral operator&=(integral op) volatile noexcept; 195234976Stheraven integral operator&=(integral op) noexcept; 196234976Stheraven integral operator|=(integral op) volatile noexcept; 197234976Stheraven integral operator|=(integral op) noexcept; 198234976Stheraven integral operator^=(integral op) volatile noexcept; 199234976Stheraven integral operator^=(integral op) noexcept; 200227825Stheraven}; 201227825Stheraven 202227825Stheraventemplate <class T> 203227825Stheravenstruct atomic<T*> 204227825Stheraven{ 205234976Stheraven bool is_lock_free() const volatile noexcept; 206234976Stheraven bool is_lock_free() const noexcept; 207234976Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 208234976Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; 209234976Stheraven T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; 210234976Stheraven T* load(memory_order m = memory_order_seq_cst) const noexcept; 211234976Stheraven operator T*() const volatile noexcept; 212234976Stheraven operator T*() const noexcept; 213234976Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 214234976Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; 215227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 216234976Stheraven memory_order s, memory_order f) volatile noexcept; 217227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 218234976Stheraven memory_order s, memory_order f) noexcept; 219227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 220234976Stheraven memory_order s, memory_order f) volatile noexcept; 221227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 222234976Stheraven memory_order s, memory_order f) noexcept; 223227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 224234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 225227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 226234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 227227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 228234976Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 229227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 230234976Stheraven memory_order m = memory_order_seq_cst) noexcept; 231234976Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 232234976Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 233234976Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 234234976Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 235227825Stheraven 236234976Stheraven atomic() noexcept = default; 237234976Stheraven constexpr atomic(T* desr) noexcept; 238227825Stheraven atomic(const atomic&) = delete; 239227825Stheraven atomic& operator=(const atomic&) = delete; 240227825Stheraven atomic& operator=(const atomic&) volatile = delete; 241227825Stheraven 242234976Stheraven T* operator=(T*) volatile noexcept; 243234976Stheraven T* operator=(T*) noexcept; 244234976Stheraven T* operator++(int) volatile noexcept; 245234976Stheraven T* operator++(int) noexcept; 246234976Stheraven T* operator--(int) volatile noexcept; 247234976Stheraven T* operator--(int) noexcept; 248234976Stheraven T* operator++() volatile noexcept; 249234976Stheraven T* operator++() noexcept; 250234976Stheraven T* operator--() volatile noexcept; 251234976Stheraven T* operator--() noexcept; 252234976Stheraven T* operator+=(ptrdiff_t op) volatile noexcept; 253234976Stheraven T* operator+=(ptrdiff_t op) noexcept; 254234976Stheraven T* operator-=(ptrdiff_t op) volatile noexcept; 255234976Stheraven T* operator-=(ptrdiff_t op) noexcept; 256227825Stheraven}; 257227825Stheraven 258227825Stheraven 259227825Stheraventemplate <class T> 260227825Stheraven bool 261234976Stheraven atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; 262227825Stheraven 263227825Stheraventemplate <class T> 264227825Stheraven bool 265234976Stheraven atomic_is_lock_free(const atomic<T>* obj) noexcept; 266227825Stheraven 267227825Stheraventemplate <class T> 268227825Stheraven void 269234976Stheraven atomic_init(volatile atomic<T>* obj, T desr) noexcept; 270227825Stheraven 271227825Stheraventemplate <class T> 272227825Stheraven void 273234976Stheraven atomic_init(atomic<T>* obj, T desr) noexcept; 274227825Stheraven 275227825Stheraventemplate <class T> 276227825Stheraven void 277234976Stheraven atomic_store(volatile atomic<T>* obj, T desr) noexcept; 278227825Stheraven 279227825Stheraventemplate <class T> 280227825Stheraven void 281234976Stheraven atomic_store(atomic<T>* obj, T desr) noexcept; 282227825Stheraven 283227825Stheraventemplate <class T> 284227825Stheraven void 285234976Stheraven atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 286227825Stheraven 287227825Stheraventemplate <class T> 288227825Stheraven void 289234976Stheraven atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 290227825Stheraven 291227825Stheraventemplate <class T> 292227825Stheraven T 293234976Stheraven atomic_load(const volatile atomic<T>* obj) noexcept; 294227825Stheraven 295227825Stheraventemplate <class T> 296227825Stheraven T 297234976Stheraven atomic_load(const atomic<T>* obj) noexcept; 298227825Stheraven 299227825Stheraventemplate <class T> 300227825Stheraven T 301234976Stheraven atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; 302227825Stheraven 303227825Stheraventemplate <class T> 304227825Stheraven T 305234976Stheraven atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; 306227825Stheraven 307227825Stheraventemplate <class T> 308227825Stheraven T 309234976Stheraven atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; 310227825Stheraven 311227825Stheraventemplate <class T> 312227825Stheraven T 313234976Stheraven atomic_exchange(atomic<T>* obj, T desr) noexcept; 314227825Stheraven 315227825Stheraventemplate <class T> 316227825Stheraven T 317234976Stheraven atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 318227825Stheraven 319227825Stheraventemplate <class T> 320227825Stheraven T 321234976Stheraven atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 322227825Stheraven 323227825Stheraventemplate <class T> 324227825Stheraven bool 325234976Stheraven atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; 326227825Stheraven 327227825Stheraventemplate <class T> 328227825Stheraven bool 329234976Stheraven atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; 330227825Stheraven 331227825Stheraventemplate <class T> 332227825Stheraven bool 333234976Stheraven atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; 334227825Stheraven 335227825Stheraventemplate <class T> 336227825Stheraven bool 337234976Stheraven 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, 343234976Stheraven 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, 348234976Stheraven 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, 354234976Stheraven 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, 360234976Stheraven memory_order s, memory_order f) noexcept; 361227825Stheraven 362227825Stheraventemplate <class Integral> 363227825Stheraven Integral 364234976Stheraven atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; 365227825Stheraven 366227825Stheraventemplate <class Integral> 367227825Stheraven Integral 368234976Stheraven 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, 373234976Stheraven memory_order m) noexcept; 374227825Stheraventemplate <class Integral> 375227825Stheraven Integral 376227825Stheraven atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, 377234976Stheraven memory_order m) noexcept; 378227825Stheraventemplate <class Integral> 379227825Stheraven Integral 380234976Stheraven atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; 381227825Stheraven 382227825Stheraventemplate <class Integral> 383227825Stheraven Integral 384234976Stheraven 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, 389234976Stheraven memory_order m) noexcept; 390227825Stheraventemplate <class Integral> 391227825Stheraven Integral 392227825Stheraven atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, 393234976Stheraven memory_order m) noexcept; 394227825Stheraventemplate <class Integral> 395227825Stheraven Integral 396234976Stheraven atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; 397227825Stheraven 398227825Stheraventemplate <class Integral> 399227825Stheraven Integral 400234976Stheraven 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, 405234976Stheraven memory_order m) noexcept; 406227825Stheraventemplate <class Integral> 407227825Stheraven Integral 408227825Stheraven atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, 409234976Stheraven memory_order m) noexcept; 410227825Stheraventemplate <class Integral> 411227825Stheraven Integral 412234976Stheraven atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; 413227825Stheraven 414227825Stheraventemplate <class Integral> 415227825Stheraven Integral 416234976Stheraven 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, 421234976Stheraven memory_order m) noexcept; 422227825Stheraventemplate <class Integral> 423227825Stheraven Integral 424227825Stheraven atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, 425234976Stheraven memory_order m) noexcept; 426227825Stheraventemplate <class Integral> 427227825Stheraven Integral 428234976Stheraven atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; 429227825Stheraven 430227825Stheraventemplate <class Integral> 431227825Stheraven Integral 432234976Stheraven 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, 437234976Stheraven memory_order m) noexcept; 438227825Stheraventemplate <class Integral> 439227825Stheraven Integral 440227825Stheraven atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, 441234976Stheraven memory_order m) noexcept; 442227825Stheraven 443227825Stheraventemplate <class T> 444227825Stheraven T* 445234976Stheraven atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 446227825Stheraven 447227825Stheraventemplate <class T> 448227825Stheraven T* 449234976Stheraven 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, 454234976Stheraven memory_order m) noexcept; 455227825Stheraventemplate <class T> 456227825Stheraven T* 457234976Stheraven atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 458227825Stheraven 459227825Stheraventemplate <class T> 460227825Stheraven T* 461234976Stheraven atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 462227825Stheraven 463227825Stheraventemplate <class T> 464227825Stheraven T* 465234976Stheraven 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, 470234976Stheraven memory_order m) noexcept; 471227825Stheraventemplate <class T> 472227825Stheraven T* 473234976Stheraven atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 474227825Stheraven 475227825Stheraven// Atomics for standard typedef types 476227825Stheraven 477246487Stheraventypedef 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 520234976Stheravenvoid atomic_thread_fence(memory_order m) noexcept; 521234976Stheravenvoid 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 536278724Sdim#ifdef _LIBCPP_HAS_NO_THREADS 537278724Sdim#error <atomic> is not supported on this single threaded system 538278724Sdim#else // !_LIBCPP_HAS_NO_THREADS 539278724Sdim 540227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 541227825Stheraven 542278724Sdim#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 552278724Sdim#if _GNUC_VER >= 407 553278724Sdimnamespace __gcc_atomic { 554278724Sdimtemplate <typename T> 555278724Sdimstruct __gcc_atomic_t { 556278724Sdim __gcc_atomic_t() _NOEXCEPT {} 557278724Sdim explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {} 558278724Sdim T __a_value; 559278724Sdim}; 560278724Sdim#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> 561278724Sdim 562278724Sdimtemplate <typename T> T __create(); 563278724Sdim 564278724Sdimtemplate <typename __Tp, typename __Td> 565278724Sdimtypename enable_if<sizeof(__Tp()->__a_value = __create<__Td>()), char>::type 566278724Sdim __test_atomic_assignable(int); 567278724Sdimtemplate <typename T, typename U> 568278724Sdim__two __test_atomic_assignable(...); 569278724Sdim 570278724Sdimtemplate <typename __Tp, typename __Td> 571278724Sdimstruct __can_assign { 572278724Sdim static const bool value = 573278724Sdim sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char); 574278724Sdim}; 575278724Sdim 576278724Sdimstatic inline constexpr int __to_gcc_order(memory_order __order) { 577278724Sdim // Avoid switch statement to make this a constexpr. 578278724Sdim return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 579278724Sdim (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 580278724Sdim (__order == memory_order_release ? __ATOMIC_RELEASE: 581278724Sdim (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 582278724Sdim (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: 583278724Sdim __ATOMIC_CONSUME)))); 584278724Sdim} 585278724Sdim 586278724Sdim} // namespace __gcc_atomic 587278724Sdim 588278724Sdimtemplate <typename _Tp> 589278724Sdimstatic inline 590278724Sdimtypename enable_if< 591278724Sdim __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type 592278724Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 593278724Sdim __a->__a_value = __val; 594278724Sdim} 595278724Sdim 596278724Sdimtemplate <typename _Tp> 597278724Sdimstatic inline 598278724Sdimtypename enable_if< 599278724Sdim !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && 600278724Sdim __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type 601278724Sdim__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 602278724Sdim // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because 603278724Sdim // the default operator= in an object is not volatile, a byte-by-byte copy 604278724Sdim // is required. 605278724Sdim volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); 606278724Sdim volatile char* end = to + sizeof(_Tp); 607278724Sdim char* from = reinterpret_cast<char*>(&__val); 608278724Sdim while (to != end) { 609278724Sdim *to++ = *from++; 610278724Sdim } 611278724Sdim} 612278724Sdim 613278724Sdimtemplate <typename _Tp> 614278724Sdimstatic inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { 615278724Sdim __a->__a_value = __val; 616278724Sdim} 617278724Sdim 618278724Sdimstatic inline void __c11_atomic_thread_fence(memory_order __order) { 619278724Sdim __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); 620278724Sdim} 621278724Sdim 622278724Sdimstatic inline void __c11_atomic_signal_fence(memory_order __order) { 623278724Sdim __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); 624278724Sdim} 625278724Sdim 626278724Sdimstatic inline bool __c11_atomic_is_lock_free(size_t __size) { 627278724Sdim return __atomic_is_lock_free(__size, 0); 628278724Sdim} 629278724Sdim 630278724Sdimtemplate <typename _Tp> 631278724Sdimstatic inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, 632278724Sdim memory_order __order) { 633278724Sdim return __atomic_store(&__a->__a_value, &__val, 634278724Sdim __gcc_atomic::__to_gcc_order(__order)); 635278724Sdim} 636278724Sdim 637278724Sdimtemplate <typename _Tp> 638278724Sdimstatic inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, 639278724Sdim memory_order __order) { 640278724Sdim return __atomic_store(&__a->__a_value, &__val, 641278724Sdim __gcc_atomic::__to_gcc_order(__order)); 642278724Sdim} 643278724Sdim 644278724Sdimtemplate <typename _Tp> 645278724Sdimstatic inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, 646278724Sdim memory_order __order) { 647278724Sdim _Tp __ret; 648278724Sdim __atomic_load(&__a->__a_value, &__ret, 649278724Sdim __gcc_atomic::__to_gcc_order(__order)); 650278724Sdim return __ret; 651278724Sdim} 652278724Sdim 653278724Sdimtemplate <typename _Tp> 654278724Sdimstatic inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { 655278724Sdim _Tp __ret; 656278724Sdim __atomic_load(&__a->__a_value, &__ret, 657278724Sdim __gcc_atomic::__to_gcc_order(__order)); 658278724Sdim return __ret; 659278724Sdim} 660278724Sdim 661278724Sdimtemplate <typename _Tp> 662278724Sdimstatic inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, 663278724Sdim _Tp __value, memory_order __order) { 664278724Sdim _Tp __ret; 665278724Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 666278724Sdim __gcc_atomic::__to_gcc_order(__order)); 667278724Sdim return __ret; 668278724Sdim} 669278724Sdim 670278724Sdimtemplate <typename _Tp> 671278724Sdimstatic inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, 672278724Sdim memory_order __order) { 673278724Sdim _Tp __ret; 674278724Sdim __atomic_exchange(&__a->__a_value, &__value, &__ret, 675278724Sdim __gcc_atomic::__to_gcc_order(__order)); 676278724Sdim return __ret; 677278724Sdim} 678278724Sdim 679278724Sdimtemplate <typename _Tp> 680278724Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 681278724Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 682278724Sdim memory_order __success, memory_order __failure) { 683278724Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 684278724Sdim false, 685278724Sdim __gcc_atomic::__to_gcc_order(__success), 686278724Sdim __gcc_atomic::__to_gcc_order(__failure)); 687278724Sdim} 688278724Sdim 689278724Sdimtemplate <typename _Tp> 690278724Sdimstatic inline bool __c11_atomic_compare_exchange_strong( 691278724Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 692278724Sdim memory_order __failure) { 693278724Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 694278724Sdim false, 695278724Sdim __gcc_atomic::__to_gcc_order(__success), 696278724Sdim __gcc_atomic::__to_gcc_order(__failure)); 697278724Sdim} 698278724Sdim 699278724Sdimtemplate <typename _Tp> 700278724Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 701278724Sdim volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 702278724Sdim memory_order __success, memory_order __failure) { 703278724Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 704278724Sdim true, 705278724Sdim __gcc_atomic::__to_gcc_order(__success), 706278724Sdim __gcc_atomic::__to_gcc_order(__failure)); 707278724Sdim} 708278724Sdim 709278724Sdimtemplate <typename _Tp> 710278724Sdimstatic inline bool __c11_atomic_compare_exchange_weak( 711278724Sdim _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 712278724Sdim memory_order __failure) { 713278724Sdim return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 714278724Sdim true, 715278724Sdim __gcc_atomic::__to_gcc_order(__success), 716278724Sdim __gcc_atomic::__to_gcc_order(__failure)); 717278724Sdim} 718278724Sdim 719278724Sdimtemplate <typename _Tp> 720278724Sdimstruct __skip_amt { enum {value = 1}; }; 721278724Sdim 722278724Sdimtemplate <typename _Tp> 723278724Sdimstruct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; 724278724Sdim 725278724Sdim// FIXME: Haven't figured out what the spec says about using arrays with 726278724Sdim// atomic_fetch_add. Force a failure rather than creating bad behavior. 727278724Sdimtemplate <typename _Tp> 728278724Sdimstruct __skip_amt<_Tp[]> { }; 729278724Sdimtemplate <typename _Tp, int n> 730278724Sdimstruct __skip_amt<_Tp[n]> { }; 731278724Sdim 732278724Sdimtemplate <typename _Tp, typename _Td> 733278724Sdimstatic inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, 734278724Sdim _Td __delta, memory_order __order) { 735278724Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 736278724Sdim __gcc_atomic::__to_gcc_order(__order)); 737278724Sdim} 738278724Sdim 739278724Sdimtemplate <typename _Tp, typename _Td> 740278724Sdimstatic inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, 741278724Sdim memory_order __order) { 742278724Sdim return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 743278724Sdim __gcc_atomic::__to_gcc_order(__order)); 744278724Sdim} 745278724Sdim 746278724Sdimtemplate <typename _Tp, typename _Td> 747278724Sdimstatic inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, 748278724Sdim _Td __delta, memory_order __order) { 749278724Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 750278724Sdim __gcc_atomic::__to_gcc_order(__order)); 751278724Sdim} 752278724Sdim 753278724Sdimtemplate <typename _Tp, typename _Td> 754278724Sdimstatic inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, 755278724Sdim memory_order __order) { 756278724Sdim return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 757278724Sdim __gcc_atomic::__to_gcc_order(__order)); 758278724Sdim} 759278724Sdim 760278724Sdimtemplate <typename _Tp> 761278724Sdimstatic inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, 762278724Sdim _Tp __pattern, memory_order __order) { 763278724Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 764278724Sdim __gcc_atomic::__to_gcc_order(__order)); 765278724Sdim} 766278724Sdim 767278724Sdimtemplate <typename _Tp> 768278724Sdimstatic inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, 769278724Sdim _Tp __pattern, memory_order __order) { 770278724Sdim return __atomic_fetch_and(&__a->__a_value, __pattern, 771278724Sdim __gcc_atomic::__to_gcc_order(__order)); 772278724Sdim} 773278724Sdim 774278724Sdimtemplate <typename _Tp> 775278724Sdimstatic inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, 776278724Sdim _Tp __pattern, memory_order __order) { 777278724Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 778278724Sdim __gcc_atomic::__to_gcc_order(__order)); 779278724Sdim} 780278724Sdim 781278724Sdimtemplate <typename _Tp> 782278724Sdimstatic inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, 783278724Sdim memory_order __order) { 784278724Sdim return __atomic_fetch_or(&__a->__a_value, __pattern, 785278724Sdim __gcc_atomic::__to_gcc_order(__order)); 786278724Sdim} 787278724Sdim 788278724Sdimtemplate <typename _Tp> 789278724Sdimstatic inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, 790278724Sdim _Tp __pattern, memory_order __order) { 791278724Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 792278724Sdim __gcc_atomic::__to_gcc_order(__order)); 793278724Sdim} 794278724Sdim 795278724Sdimtemplate <typename _Tp> 796278724Sdimstatic inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, 797278724Sdim memory_order __order) { 798278724Sdim return __atomic_fetch_xor(&__a->__a_value, __pattern, 799278724Sdim __gcc_atomic::__to_gcc_order(__order)); 800278724Sdim} 801278724Sdim#endif // _GNUC_VER >= 407 802278724Sdim 803227825Stheraventemplate <class _Tp> 804227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 805227825Stheraven_Tp 806234976Stheravenkill_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{ 816241903Sdim mutable _Atomic(_Tp) __a_; 817227825Stheraven 818227825Stheraven _LIBCPP_INLINE_VISIBILITY 819234976Stheraven bool is_lock_free() const volatile _NOEXCEPT 820234976Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 821227825Stheraven _LIBCPP_INLINE_VISIBILITY 822234976Stheraven bool is_lock_free() const _NOEXCEPT 823234976Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 824227825Stheraven _LIBCPP_INLINE_VISIBILITY 825234976Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 826234976Stheraven {__c11_atomic_store(&__a_, __d, __m);} 827227825Stheraven _LIBCPP_INLINE_VISIBILITY 828234976Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 829234976Stheraven {__c11_atomic_store(&__a_, __d, __m);} 830227825Stheraven _LIBCPP_INLINE_VISIBILITY 831234976Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 832234976Stheraven {return __c11_atomic_load(&__a_, __m);} 833227825Stheraven _LIBCPP_INLINE_VISIBILITY 834234976Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 835234976Stheraven {return __c11_atomic_load(&__a_, __m);} 836227825Stheraven _LIBCPP_INLINE_VISIBILITY 837234976Stheraven operator _Tp() const volatile _NOEXCEPT {return load();} 838227825Stheraven _LIBCPP_INLINE_VISIBILITY 839234976Stheraven operator _Tp() const _NOEXCEPT {return load();} 840227825Stheraven _LIBCPP_INLINE_VISIBILITY 841234976Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 842234976Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 843227825Stheraven _LIBCPP_INLINE_VISIBILITY 844234976Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 845234976Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 846227825Stheraven _LIBCPP_INLINE_VISIBILITY 847227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 848234976Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 849234976Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 850227825Stheraven _LIBCPP_INLINE_VISIBILITY 851227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 852234976Stheraven memory_order __s, memory_order __f) _NOEXCEPT 853234976Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 854227825Stheraven _LIBCPP_INLINE_VISIBILITY 855227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 856234976Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 857234976Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 858227825Stheraven _LIBCPP_INLINE_VISIBILITY 859227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 860234976Stheraven memory_order __s, memory_order __f) _NOEXCEPT 861234976Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 862227825Stheraven _LIBCPP_INLINE_VISIBILITY 863227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 864234976Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 865234976Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 866227825Stheraven _LIBCPP_INLINE_VISIBILITY 867227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 868234976Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 869234976Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 870227825Stheraven _LIBCPP_INLINE_VISIBILITY 871227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 872234976Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 873234976Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 874227825Stheraven _LIBCPP_INLINE_VISIBILITY 875227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 876234976Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 877234976Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 878227825Stheraven 879227825Stheraven _LIBCPP_INLINE_VISIBILITY 880253159Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 881253159Stheraven __atomic_base() _NOEXCEPT = default; 882253159Stheraven#else 883253159Stheraven __atomic_base() _NOEXCEPT : __a_() {} 884253159Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 885253159Stheraven 886227825Stheraven _LIBCPP_INLINE_VISIBILITY 887234976Stheraven _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 908253159Stheraven __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT 909227825Stheraven _LIBCPP_INLINE_VISIBILITY 910234976Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 911227825Stheraven 912227825Stheraven _LIBCPP_INLINE_VISIBILITY 913234976Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 914234976Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 915227825Stheraven _LIBCPP_INLINE_VISIBILITY 916234976Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 917234976Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 918227825Stheraven _LIBCPP_INLINE_VISIBILITY 919234976Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 920234976Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 921227825Stheraven _LIBCPP_INLINE_VISIBILITY 922234976Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 923234976Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 924227825Stheraven _LIBCPP_INLINE_VISIBILITY 925234976Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 926234976Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 927227825Stheraven _LIBCPP_INLINE_VISIBILITY 928234976Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 929234976Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 930227825Stheraven _LIBCPP_INLINE_VISIBILITY 931234976Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 932234976Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 933227825Stheraven _LIBCPP_INLINE_VISIBILITY 934234976Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 935234976Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 936227825Stheraven _LIBCPP_INLINE_VISIBILITY 937234976Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 938234976Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 939227825Stheraven _LIBCPP_INLINE_VISIBILITY 940234976Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 941234976Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 942227825Stheraven 943227825Stheraven _LIBCPP_INLINE_VISIBILITY 944234976Stheraven _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 945227825Stheraven _LIBCPP_INLINE_VISIBILITY 946234976Stheraven _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 947227825Stheraven _LIBCPP_INLINE_VISIBILITY 948234976Stheraven _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 949227825Stheraven _LIBCPP_INLINE_VISIBILITY 950234976Stheraven _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 951227825Stheraven _LIBCPP_INLINE_VISIBILITY 952234976Stheraven _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 953227825Stheraven _LIBCPP_INLINE_VISIBILITY 954234976Stheraven _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 955227825Stheraven _LIBCPP_INLINE_VISIBILITY 956234976Stheraven _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 957227825Stheraven _LIBCPP_INLINE_VISIBILITY 958234976Stheraven _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 959227825Stheraven _LIBCPP_INLINE_VISIBILITY 960234976Stheraven _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 961227825Stheraven _LIBCPP_INLINE_VISIBILITY 962234976Stheraven _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 963227825Stheraven _LIBCPP_INLINE_VISIBILITY 964234976Stheraven _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 965227825Stheraven _LIBCPP_INLINE_VISIBILITY 966234976Stheraven _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 967227825Stheraven _LIBCPP_INLINE_VISIBILITY 968234976Stheraven _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 969227825Stheraven _LIBCPP_INLINE_VISIBILITY 970234976Stheraven _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 971227825Stheraven _LIBCPP_INLINE_VISIBILITY 972234976Stheraven _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 973227825Stheraven _LIBCPP_INLINE_VISIBILITY 974234976Stheraven _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 975227825Stheraven _LIBCPP_INLINE_VISIBILITY 976234976Stheraven _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 977227825Stheraven _LIBCPP_INLINE_VISIBILITY 978234976Stheraven _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 989253159Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 990227825Stheraven _LIBCPP_INLINE_VISIBILITY 991234976Stheraven _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 992227825Stheraven 993227825Stheraven _LIBCPP_INLINE_VISIBILITY 994234976Stheraven _Tp operator=(_Tp __d) volatile _NOEXCEPT 995227825Stheraven {__base::store(__d); return __d;} 996227825Stheraven _LIBCPP_INLINE_VISIBILITY 997234976Stheraven _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 1009253159Stheraven atomic() _NOEXCEPT _LIBCPP_DEFAULT 1010227825Stheraven _LIBCPP_INLINE_VISIBILITY 1011234976Stheraven _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 1012227825Stheraven 1013227825Stheraven _LIBCPP_INLINE_VISIBILITY 1014234976Stheraven _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 1015227825Stheraven {__base::store(__d); return __d;} 1016227825Stheraven _LIBCPP_INLINE_VISIBILITY 1017234976Stheraven _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) 1022234976Stheraven volatile _NOEXCEPT 1023234976Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 1024227825Stheraven _LIBCPP_INLINE_VISIBILITY 1025234976Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1026234976Stheraven {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) 1029234976Stheraven volatile _NOEXCEPT 1030234976Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1031227825Stheraven _LIBCPP_INLINE_VISIBILITY 1032234976Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 1033234976Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 1034227825Stheraven 1035227825Stheraven _LIBCPP_INLINE_VISIBILITY 1036234976Stheraven _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 1037227825Stheraven _LIBCPP_INLINE_VISIBILITY 1038234976Stheraven _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 1039227825Stheraven _LIBCPP_INLINE_VISIBILITY 1040234976Stheraven _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 1041227825Stheraven _LIBCPP_INLINE_VISIBILITY 1042234976Stheraven _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 1043227825Stheraven _LIBCPP_INLINE_VISIBILITY 1044234976Stheraven _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 1045227825Stheraven _LIBCPP_INLINE_VISIBILITY 1046234976Stheraven _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 1047227825Stheraven _LIBCPP_INLINE_VISIBILITY 1048234976Stheraven _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 1049227825Stheraven _LIBCPP_INLINE_VISIBILITY 1050234976Stheraven _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 1051227825Stheraven _LIBCPP_INLINE_VISIBILITY 1052234976Stheraven _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 1053227825Stheraven _LIBCPP_INLINE_VISIBILITY 1054234976Stheraven _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 1055227825Stheraven _LIBCPP_INLINE_VISIBILITY 1056234976Stheraven _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 1057227825Stheraven _LIBCPP_INLINE_VISIBILITY 1058234976Stheraven _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 1066234976Stheravenatomic_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 1074234976Stheravenatomic_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 1084234976Stheravenatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1085227825Stheraven{ 1086234976Stheraven __c11_atomic_init(&__o->__a_, __d); 1087227825Stheraven} 1088227825Stheraven 1089227825Stheraventemplate <class _Tp> 1090227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1091227825Stheravenvoid 1092234976Stheravenatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1093227825Stheraven{ 1094234976Stheraven __c11_atomic_init(&__o->__a_, __d); 1095227825Stheraven} 1096227825Stheraven 1097227825Stheraven// atomic_store 1098227825Stheraven 1099227825Stheraventemplate <class _Tp> 1100227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1101227825Stheravenvoid 1102234976Stheravenatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 1103227825Stheraven{ 1104227825Stheraven __o->store(__d); 1105227825Stheraven} 1106227825Stheraven 1107227825Stheraventemplate <class _Tp> 1108227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1109227825Stheravenvoid 1110234976Stheravenatomic_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 1120234976Stheravenatomic_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 1128234976Stheravenatomic_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 1138234976Stheravenatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 1139227825Stheraven{ 1140227825Stheraven return __o->load(); 1141227825Stheraven} 1142227825Stheraven 1143227825Stheraventemplate <class _Tp> 1144227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1145227825Stheraven_Tp 1146234976Stheravenatomic_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 1156234976Stheravenatomic_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 1164234976Stheravenatomic_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 1174234976Stheravenatomic_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 1182234976Stheravenatomic_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 1192234976Stheravenatomic_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 1200234976Stheravenatomic_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 1210234976Stheravenatomic_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 1218234976Stheravenatomic_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 1228234976Stheravenatomic_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 1236234976Stheravenatomic_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, 1248234976Stheraven 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, 1257234976Stheraven 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, 1269234976Stheraven 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, 1279234976Stheraven 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 1293234976Stheravenatomic_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 1305234976Stheravenatomic_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* 1313234976Stheravenatomic_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* 1321234976Stheravenatomic_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 1335234976Stheravenatomic_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 1347234976Stheravenatomic_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, 1356234976Stheraven memory_order __m) _NOEXCEPT 1357227825Stheraven{ 1358227825Stheraven return __o->fetch_add(__op, __m); 1359227825Stheraven} 1360227825Stheraven 1361227825Stheraventemplate <class _Tp> 1362227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1363227825Stheraven_Tp* 1364234976Stheravenatomic_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 1378234976Stheravenatomic_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 1390234976Stheravenatomic_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* 1398234976Stheravenatomic_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* 1406234976Stheravenatomic_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 1420234976Stheravenatomic_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 1432234976Stheravenatomic_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, 1441234976Stheraven memory_order __m) _NOEXCEPT 1442227825Stheraven{ 1443227825Stheraven return __o->fetch_sub(__op, __m); 1444227825Stheraven} 1445227825Stheraven 1446227825Stheraventemplate <class _Tp> 1447227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1448227825Stheraven_Tp* 1449234976Stheravenatomic_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 1463234976Stheravenatomic_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 1475234976Stheravenatomic_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 1489234976Stheravenatomic_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 1501234976Stheravenatomic_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 1515234976Stheravenatomic_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 1527234976Stheravenatomic_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 1541234976Stheravenatomic_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 1553234976Stheravenatomic_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 1567234976Stheravenatomic_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 1579234976Stheravenatomic_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 1593234976Stheravenatomic_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 1605234976Stheravenatomic_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{ 1614232950Stheraven _Atomic(bool) __a_; 1615227825Stheraven 1616227825Stheraven _LIBCPP_INLINE_VISIBILITY 1617234976Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1618234976Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1619227825Stheraven _LIBCPP_INLINE_VISIBILITY 1620234976Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1621234976Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1622227825Stheraven _LIBCPP_INLINE_VISIBILITY 1623234976Stheraven void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1624234976Stheraven {__c11_atomic_store(&__a_, false, __m);} 1625227825Stheraven _LIBCPP_INLINE_VISIBILITY 1626234976Stheraven void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1627234976Stheraven {__c11_atomic_store(&__a_, false, __m);} 1628227825Stheraven 1629227825Stheraven _LIBCPP_INLINE_VISIBILITY 1630253159Stheraven#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1631253159Stheraven atomic_flag() _NOEXCEPT = default; 1632253159Stheraven#else 1633253159Stheraven atomic_flag() _NOEXCEPT : __a_() {} 1634253159Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1635253159Stheraven 1636227825Stheraven _LIBCPP_INLINE_VISIBILITY 1637234976Stheraven 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 1653234976Stheravenatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 1654227825Stheraven{ 1655227825Stheraven return __o->test_and_set(); 1656227825Stheraven} 1657227825Stheraven 1658227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1659227825Stheravenbool 1660234976Stheravenatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 1661227825Stheraven{ 1662227825Stheraven return __o->test_and_set(); 1663227825Stheraven} 1664227825Stheraven 1665227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1666227825Stheravenbool 1667234976Stheravenatomic_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 1674234976Stheravenatomic_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 1681234976Stheravenatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 1682227825Stheraven{ 1683227825Stheraven __o->clear(); 1684227825Stheraven} 1685227825Stheraven 1686227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1687227825Stheravenvoid 1688234976Stheravenatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 1689227825Stheraven{ 1690227825Stheraven __o->clear(); 1691227825Stheraven} 1692227825Stheraven 1693227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1694227825Stheravenvoid 1695234976Stheravenatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1696227825Stheraven{ 1697227825Stheraven __o->clear(__m); 1698227825Stheraven} 1699227825Stheraven 1700227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1701227825Stheravenvoid 1702234976Stheravenatomic_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 1711234976Stheravenatomic_thread_fence(memory_order __m) _NOEXCEPT 1712227825Stheraven{ 1713234976Stheraven __c11_atomic_thread_fence(__m); 1714227825Stheraven} 1715227825Stheraven 1716227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1717227825Stheravenvoid 1718234976Stheravenatomic_signal_fence(memory_order __m) _NOEXCEPT 1719227825Stheraven{ 1720234976Stheraven __c11_atomic_signal_fence(__m); 1721227825Stheraven} 1722227825Stheraven 1723227825Stheraven// Atomics for standard typedef types 1724227825Stheraven 1725246487Stheraventypedef 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 1771246487Stheraven#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE 1772246487Stheraven#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE 1773246487Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1774246487Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1775246487Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1776246487Stheraven#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE 1777246487Stheraven#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE 1778246487Stheraven#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE 1779246487Stheraven#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE 1780246487Stheraven#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE 1781227825Stheraven 1782227825Stheraven#endif // !__has_feature(cxx_atomic) 1783227825Stheraven 1784227825Stheraven_LIBCPP_END_NAMESPACE_STD 1785227825Stheraven 1786278724Sdim#endif // !_LIBCPP_HAS_NO_THREADS 1787278724Sdim 1788227825Stheraven#endif // _LIBCPP_ATOMIC 1789