atomic revision 234959
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 36227825Stheraven#define ATOMIC_CHAR_LOCK_FREE unspecified 37227825Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE unspecified 38227825Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE unspecified 39227825Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE unspecified 40227825Stheraven#define ATOMIC_SHORT_LOCK_FREE unspecified 41227825Stheraven#define ATOMIC_INT_LOCK_FREE unspecified 42227825Stheraven#define ATOMIC_LONG_LOCK_FREE unspecified 43227825Stheraven#define ATOMIC_LLONG_LOCK_FREE unspecified 44227825Stheraven 45227825Stheraven// flag type and operations 46227825Stheraven 47227825Stheraventypedef struct atomic_flag 48227825Stheraven{ 49234959Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; 50234959Stheraven bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; 51234959Stheraven void clear(memory_order m = memory_order_seq_cst) volatile noexcept; 52234959Stheraven void clear(memory_order m = memory_order_seq_cst) noexcept; 53234959Stheraven atomic_flag() noexcept = default; 54227825Stheraven atomic_flag(const atomic_flag&) = delete; 55227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 56227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 57227825Stheraven} atomic_flag; 58227825Stheraven 59227825Stheravenbool 60234959Stheraven atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; 61227825Stheraven 62227825Stheravenbool 63234959Stheraven atomic_flag_test_and_set(atomic_flag* obj) noexcept; 64227825Stheraven 65227825Stheravenbool 66227825Stheraven atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, 67234959Stheraven memory_order m) noexcept; 68227825Stheraven 69227825Stheravenbool 70234959Stheraven atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; 71227825Stheraven 72227825Stheravenvoid 73234959Stheraven atomic_flag_clear(volatile atomic_flag* obj) noexcept; 74227825Stheraven 75227825Stheravenvoid 76234959Stheraven atomic_flag_clear(atomic_flag* obj) noexcept; 77227825Stheraven 78227825Stheravenvoid 79234959Stheraven atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; 80227825Stheraven 81227825Stheravenvoid 82234959Stheraven atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; 83227825Stheraven 84227825Stheraven#define ATOMIC_FLAG_INIT see below 85227825Stheraven#define ATOMIC_VAR_INIT(value) see below 86227825Stheraven 87227825Stheraventemplate <class T> 88227825Stheravenstruct atomic 89227825Stheraven{ 90234959Stheraven bool is_lock_free() const volatile noexcept; 91234959Stheraven bool is_lock_free() const noexcept; 92234959Stheraven void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 93234959Stheraven void store(T desr, memory_order m = memory_order_seq_cst) noexcept; 94234959Stheraven T load(memory_order m = memory_order_seq_cst) const volatile noexcept; 95234959Stheraven T load(memory_order m = memory_order_seq_cst) const noexcept; 96234959Stheraven operator T() const volatile noexcept; 97234959Stheraven operator T() const noexcept; 98234959Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 99234959Stheraven T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; 100227825Stheraven bool compare_exchange_weak(T& expc, T desr, 101234959Stheraven memory_order s, memory_order f) volatile noexcept; 102234959Stheraven bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; 103227825Stheraven bool compare_exchange_strong(T& expc, T desr, 104234959Stheraven memory_order s, memory_order f) volatile noexcept; 105227825Stheraven bool compare_exchange_strong(T& expc, T desr, 106234959Stheraven memory_order s, memory_order f) noexcept; 107227825Stheraven bool compare_exchange_weak(T& expc, T desr, 108234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 109227825Stheraven bool compare_exchange_weak(T& expc, T desr, 110234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 111227825Stheraven bool compare_exchange_strong(T& expc, T desr, 112234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 113227825Stheraven bool compare_exchange_strong(T& expc, T desr, 114234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 115227825Stheraven 116234959Stheraven atomic() noexcept = default; 117234959Stheraven constexpr atomic(T desr) noexcept; 118227825Stheraven atomic(const atomic&) = delete; 119227825Stheraven atomic& operator=(const atomic&) = delete; 120227825Stheraven atomic& operator=(const atomic&) volatile = delete; 121234959Stheraven T operator=(T) volatile noexcept; 122234959Stheraven T operator=(T) noexcept; 123227825Stheraven}; 124227825Stheraven 125227825Stheraventemplate <> 126227825Stheravenstruct atomic<integral> 127227825Stheraven{ 128234959Stheraven bool is_lock_free() const volatile noexcept; 129234959Stheraven bool is_lock_free() const noexcept; 130234959Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; 131234959Stheraven void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; 132234959Stheraven integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; 133234959Stheraven integral load(memory_order m = memory_order_seq_cst) const noexcept; 134234959Stheraven operator integral() const volatile noexcept; 135234959Stheraven operator integral() const noexcept; 136227825Stheraven integral exchange(integral desr, 137234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 138234959Stheraven integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; 139227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 140234959Stheraven memory_order s, memory_order f) volatile noexcept; 141227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 142234959Stheraven memory_order s, memory_order f) noexcept; 143227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 144234959Stheraven memory_order s, memory_order f) volatile noexcept; 145227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 146234959Stheraven memory_order s, memory_order f) noexcept; 147227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 148234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 149227825Stheraven bool compare_exchange_weak(integral& expc, integral desr, 150234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 151227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 152234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 153227825Stheraven bool compare_exchange_strong(integral& expc, integral desr, 154234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 155227825Stheraven 156227825Stheraven integral 157234959Stheraven fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 158234959Stheraven integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; 159227825Stheraven integral 160234959Stheraven fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 161234959Stheraven integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; 162227825Stheraven integral 163234959Stheraven fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 164234959Stheraven integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; 165227825Stheraven integral 166234959Stheraven fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 167234959Stheraven integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; 168227825Stheraven integral 169234959Stheraven fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 170234959Stheraven integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; 171227825Stheraven 172234959Stheraven atomic() noexcept = default; 173234959Stheraven constexpr atomic(integral desr) noexcept; 174227825Stheraven atomic(const atomic&) = delete; 175227825Stheraven atomic& operator=(const atomic&) = delete; 176227825Stheraven atomic& operator=(const atomic&) volatile = delete; 177234959Stheraven integral operator=(integral desr) volatile noexcept; 178234959Stheraven integral operator=(integral desr) noexcept; 179227825Stheraven 180234959Stheraven integral operator++(int) volatile noexcept; 181234959Stheraven integral operator++(int) noexcept; 182234959Stheraven integral operator--(int) volatile noexcept; 183234959Stheraven integral operator--(int) noexcept; 184234959Stheraven integral operator++() volatile noexcept; 185234959Stheraven integral operator++() noexcept; 186234959Stheraven integral operator--() volatile noexcept; 187234959Stheraven integral operator--() noexcept; 188234959Stheraven integral operator+=(integral op) volatile noexcept; 189234959Stheraven integral operator+=(integral op) 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; 198227825Stheraven}; 199227825Stheraven 200227825Stheraventemplate <class T> 201227825Stheravenstruct atomic<T*> 202227825Stheraven{ 203234959Stheraven bool is_lock_free() const volatile noexcept; 204234959Stheraven bool is_lock_free() const noexcept; 205234959Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 206234959Stheraven void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; 207234959Stheraven T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; 208234959Stheraven T* load(memory_order m = memory_order_seq_cst) const noexcept; 209234959Stheraven operator T*() const volatile noexcept; 210234959Stheraven operator T*() const noexcept; 211234959Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 212234959Stheraven T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; 213227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 214234959Stheraven memory_order s, memory_order f) volatile noexcept; 215227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 216234959Stheraven memory_order s, memory_order f) noexcept; 217227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 218234959Stheraven memory_order s, memory_order f) volatile noexcept; 219227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 220234959Stheraven memory_order s, memory_order f) noexcept; 221227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 222234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 223227825Stheraven bool compare_exchange_weak(T*& expc, T* desr, 224234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 225227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 226234959Stheraven memory_order m = memory_order_seq_cst) volatile noexcept; 227227825Stheraven bool compare_exchange_strong(T*& expc, T* desr, 228234959Stheraven memory_order m = memory_order_seq_cst) noexcept; 229234959Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 230234959Stheraven T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 231234959Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 232234959Stheraven T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 233227825Stheraven 234234959Stheraven atomic() noexcept = default; 235234959Stheraven constexpr atomic(T* desr) noexcept; 236227825Stheraven atomic(const atomic&) = delete; 237227825Stheraven atomic& operator=(const atomic&) = delete; 238227825Stheraven atomic& operator=(const atomic&) volatile = delete; 239227825Stheraven 240234959Stheraven T* operator=(T*) volatile noexcept; 241234959Stheraven T* operator=(T*) noexcept; 242234959Stheraven T* operator++(int) volatile noexcept; 243234959Stheraven T* operator++(int) noexcept; 244234959Stheraven T* operator--(int) volatile noexcept; 245234959Stheraven T* operator--(int) noexcept; 246234959Stheraven T* operator++() volatile noexcept; 247234959Stheraven T* operator++() noexcept; 248234959Stheraven T* operator--() volatile noexcept; 249234959Stheraven T* operator--() noexcept; 250234959Stheraven T* operator+=(ptrdiff_t op) volatile noexcept; 251234959Stheraven T* operator+=(ptrdiff_t op) noexcept; 252234959Stheraven T* operator-=(ptrdiff_t op) volatile noexcept; 253234959Stheraven T* operator-=(ptrdiff_t op) noexcept; 254227825Stheraven}; 255227825Stheraven 256227825Stheraven 257227825Stheraventemplate <class T> 258227825Stheraven bool 259234959Stheraven atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; 260227825Stheraven 261227825Stheraventemplate <class T> 262227825Stheraven bool 263234959Stheraven atomic_is_lock_free(const atomic<T>* obj) noexcept; 264227825Stheraven 265227825Stheraventemplate <class T> 266227825Stheraven void 267234959Stheraven atomic_init(volatile atomic<T>* obj, T desr) noexcept; 268227825Stheraven 269227825Stheraventemplate <class T> 270227825Stheraven void 271234959Stheraven atomic_init(atomic<T>* obj, T desr) noexcept; 272227825Stheraven 273227825Stheraventemplate <class T> 274227825Stheraven void 275234959Stheraven atomic_store(volatile atomic<T>* obj, T desr) noexcept; 276227825Stheraven 277227825Stheraventemplate <class T> 278227825Stheraven void 279234959Stheraven atomic_store(atomic<T>* obj, T desr) noexcept; 280227825Stheraven 281227825Stheraventemplate <class T> 282227825Stheraven void 283234959Stheraven atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 284227825Stheraven 285227825Stheraventemplate <class T> 286227825Stheraven void 287234959Stheraven atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 288227825Stheraven 289227825Stheraventemplate <class T> 290227825Stheraven T 291234959Stheraven atomic_load(const volatile atomic<T>* obj) noexcept; 292227825Stheraven 293227825Stheraventemplate <class T> 294227825Stheraven T 295234959Stheraven atomic_load(const atomic<T>* obj) noexcept; 296227825Stheraven 297227825Stheraventemplate <class T> 298227825Stheraven T 299234959Stheraven atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; 300227825Stheraven 301227825Stheraventemplate <class T> 302227825Stheraven T 303234959Stheraven atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; 304227825Stheraven 305227825Stheraventemplate <class T> 306227825Stheraven T 307234959Stheraven atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; 308227825Stheraven 309227825Stheraventemplate <class T> 310227825Stheraven T 311234959Stheraven atomic_exchange(atomic<T>* obj, T desr) noexcept; 312227825Stheraven 313227825Stheraventemplate <class T> 314227825Stheraven T 315234959Stheraven atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 316227825Stheraven 317227825Stheraventemplate <class T> 318227825Stheraven T 319234959Stheraven atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 320227825Stheraven 321227825Stheraventemplate <class T> 322227825Stheraven bool 323234959Stheraven atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; 324227825Stheraven 325227825Stheraventemplate <class T> 326227825Stheraven bool 327234959Stheraven atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; 328227825Stheraven 329227825Stheraventemplate <class T> 330227825Stheraven bool 331234959Stheraven atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; 332227825Stheraven 333227825Stheraventemplate <class T> 334227825Stheraven bool 335234959Stheraven atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; 336227825Stheraven 337227825Stheraventemplate <class T> 338227825Stheraven bool 339227825Stheraven atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, 340227825Stheraven T desr, 341234959Stheraven memory_order s, memory_order f) noexcept; 342227825Stheraven 343227825Stheraventemplate <class T> 344227825Stheraven bool 345227825Stheraven atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, 346234959Stheraven memory_order s, memory_order f) noexcept; 347227825Stheraven 348227825Stheraventemplate <class T> 349227825Stheraven bool 350227825Stheraven atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, 351227825Stheraven T* expc, T desr, 352234959Stheraven memory_order s, memory_order f) noexcept; 353227825Stheraven 354227825Stheraventemplate <class T> 355227825Stheraven bool 356227825Stheraven atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, 357227825Stheraven T desr, 358234959Stheraven memory_order s, memory_order f) noexcept; 359227825Stheraven 360227825Stheraventemplate <class Integral> 361227825Stheraven Integral 362234959Stheraven atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; 363227825Stheraven 364227825Stheraventemplate <class Integral> 365227825Stheraven Integral 366234959Stheraven atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; 367227825Stheraven 368227825Stheraventemplate <class Integral> 369227825Stheraven Integral 370227825Stheraven atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, 371234959Stheraven memory_order m) noexcept; 372227825Stheraventemplate <class Integral> 373227825Stheraven Integral 374227825Stheraven atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, 375234959Stheraven memory_order m) noexcept; 376227825Stheraventemplate <class Integral> 377227825Stheraven Integral 378234959Stheraven atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; 379227825Stheraven 380227825Stheraventemplate <class Integral> 381227825Stheraven Integral 382234959Stheraven atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; 383227825Stheraven 384227825Stheraventemplate <class Integral> 385227825Stheraven Integral 386227825Stheraven atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, 387234959Stheraven memory_order m) noexcept; 388227825Stheraventemplate <class Integral> 389227825Stheraven Integral 390227825Stheraven atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, 391234959Stheraven memory_order m) noexcept; 392227825Stheraventemplate <class Integral> 393227825Stheraven Integral 394234959Stheraven atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; 395227825Stheraven 396227825Stheraventemplate <class Integral> 397227825Stheraven Integral 398234959Stheraven atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; 399227825Stheraven 400227825Stheraventemplate <class Integral> 401227825Stheraven Integral 402227825Stheraven atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, 403234959Stheraven memory_order m) noexcept; 404227825Stheraventemplate <class Integral> 405227825Stheraven Integral 406227825Stheraven atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, 407234959Stheraven memory_order m) noexcept; 408227825Stheraventemplate <class Integral> 409227825Stheraven Integral 410234959Stheraven atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; 411227825Stheraven 412227825Stheraventemplate <class Integral> 413227825Stheraven Integral 414234959Stheraven atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; 415227825Stheraven 416227825Stheraventemplate <class Integral> 417227825Stheraven Integral 418227825Stheraven atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, 419234959Stheraven memory_order m) noexcept; 420227825Stheraventemplate <class Integral> 421227825Stheraven Integral 422227825Stheraven atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, 423234959Stheraven memory_order m) noexcept; 424227825Stheraventemplate <class Integral> 425227825Stheraven Integral 426234959Stheraven atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; 427227825Stheraven 428227825Stheraventemplate <class Integral> 429227825Stheraven Integral 430234959Stheraven atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; 431227825Stheraven 432227825Stheraventemplate <class Integral> 433227825Stheraven Integral 434227825Stheraven atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, 435234959Stheraven memory_order m) noexcept; 436227825Stheraventemplate <class Integral> 437227825Stheraven Integral 438227825Stheraven atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, 439234959Stheraven memory_order m) noexcept; 440227825Stheraven 441227825Stheraventemplate <class T> 442227825Stheraven T* 443234959Stheraven atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 444227825Stheraven 445227825Stheraventemplate <class T> 446227825Stheraven T* 447234959Stheraven atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; 448227825Stheraven 449227825Stheraventemplate <class T> 450227825Stheraven T* 451227825Stheraven atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 452234959Stheraven memory_order m) noexcept; 453227825Stheraventemplate <class T> 454227825Stheraven T* 455234959Stheraven atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 456227825Stheraven 457227825Stheraventemplate <class T> 458227825Stheraven T* 459234959Stheraven atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 460227825Stheraven 461227825Stheraventemplate <class T> 462227825Stheraven T* 463234959Stheraven atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; 464227825Stheraven 465227825Stheraventemplate <class T> 466227825Stheraven T* 467227825Stheraven atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 468234959Stheraven memory_order m) noexcept; 469227825Stheraventemplate <class T> 470227825Stheraven T* 471234959Stheraven atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 472227825Stheraven 473227825Stheraven// Atomics for standard typedef types 474227825Stheraven 475227825Stheraventypedef atomic<char> atomic_char; 476227825Stheraventypedef atomic<signed char> atomic_schar; 477227825Stheraventypedef atomic<unsigned char> atomic_uchar; 478227825Stheraventypedef atomic<short> atomic_short; 479227825Stheraventypedef atomic<unsigned short> atomic_ushort; 480227825Stheraventypedef atomic<int> atomic_int; 481227825Stheraventypedef atomic<unsigned int> atomic_uint; 482227825Stheraventypedef atomic<long> atomic_long; 483227825Stheraventypedef atomic<unsigned long> atomic_ulong; 484227825Stheraventypedef atomic<long long> atomic_llong; 485227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 486227825Stheraventypedef atomic<char16_t> atomic_char16_t; 487227825Stheraventypedef atomic<char32_t> atomic_char32_t; 488227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 489227825Stheraven 490227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 491227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 492227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 493227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 494227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 495227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 496227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 497227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 498227825Stheraven 499227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 500227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 501227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 502227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 503227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 504227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 505227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 506227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 507227825Stheraven 508227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 509227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 510227825Stheraventypedef atomic<size_t> atomic_size_t; 511227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 512227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 513227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 514227825Stheraven 515227825Stheraven// fences 516227825Stheraven 517234959Stheravenvoid atomic_thread_fence(memory_order m) noexcept; 518234959Stheravenvoid atomic_signal_fence(memory_order m) noexcept; 519227825Stheraven 520227825Stheraven} // std 521227825Stheraven 522227825Stheraven*/ 523227825Stheraven 524227825Stheraven#include <__config> 525227825Stheraven#include <cstddef> 526227825Stheraven#include <cstdint> 527227825Stheraven#include <type_traits> 528227825Stheraven 529227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 530227825Stheraven#pragma GCC system_header 531227825Stheraven#endif 532227825Stheraven 533227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 534227825Stheraven 535227825Stheraven#if !__has_feature(cxx_atomic) 536227825Stheraven#error <atomic> is not implemented 537227825Stheraven#else 538227825Stheraven 539227825Stheraventypedef enum memory_order 540227825Stheraven{ 541227825Stheraven memory_order_relaxed, memory_order_consume, memory_order_acquire, 542227825Stheraven memory_order_release, memory_order_acq_rel, memory_order_seq_cst 543227825Stheraven} memory_order; 544227825Stheraven 545227825Stheraventemplate <class _Tp> 546227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 547227825Stheraven_Tp 548234959Stheravenkill_dependency(_Tp __y) _NOEXCEPT 549227825Stheraven{ 550227825Stheraven return __y; 551227825Stheraven} 552227825Stheraven 553227825Stheraven// general atomic<T> 554227825Stheraven 555227825Stheraventemplate <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> 556227825Stheravenstruct __atomic_base // false 557227825Stheraven{ 558232924Stheraven _Atomic(_Tp) __a_; 559227825Stheraven 560227825Stheraven _LIBCPP_INLINE_VISIBILITY 561234959Stheraven bool is_lock_free() const volatile _NOEXCEPT 562234959Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 563227825Stheraven _LIBCPP_INLINE_VISIBILITY 564234959Stheraven bool is_lock_free() const _NOEXCEPT 565234959Stheraven {return __c11_atomic_is_lock_free(sizeof(_Tp));} 566227825Stheraven _LIBCPP_INLINE_VISIBILITY 567234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 568234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 569227825Stheraven _LIBCPP_INLINE_VISIBILITY 570234959Stheraven void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 571234959Stheraven {__c11_atomic_store(&__a_, __d, __m);} 572227825Stheraven _LIBCPP_INLINE_VISIBILITY 573234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 574234959Stheraven {return __c11_atomic_load(&__a_, __m);} 575227825Stheraven _LIBCPP_INLINE_VISIBILITY 576234959Stheraven _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 577234959Stheraven {return __c11_atomic_load(&__a_, __m);} 578227825Stheraven _LIBCPP_INLINE_VISIBILITY 579234959Stheraven operator _Tp() const volatile _NOEXCEPT {return load();} 580227825Stheraven _LIBCPP_INLINE_VISIBILITY 581234959Stheraven operator _Tp() const _NOEXCEPT {return load();} 582227825Stheraven _LIBCPP_INLINE_VISIBILITY 583234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 584234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 585227825Stheraven _LIBCPP_INLINE_VISIBILITY 586234959Stheraven _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 587234959Stheraven {return __c11_atomic_exchange(&__a_, __d, __m);} 588227825Stheraven _LIBCPP_INLINE_VISIBILITY 589227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 590234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 591234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 592227825Stheraven _LIBCPP_INLINE_VISIBILITY 593227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 594234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 595234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 596227825Stheraven _LIBCPP_INLINE_VISIBILITY 597227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 598234959Stheraven memory_order __s, memory_order __f) volatile _NOEXCEPT 599234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 600227825Stheraven _LIBCPP_INLINE_VISIBILITY 601227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 602234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 603234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 604227825Stheraven _LIBCPP_INLINE_VISIBILITY 605227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 606234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 607234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 608227825Stheraven _LIBCPP_INLINE_VISIBILITY 609227825Stheraven bool compare_exchange_weak(_Tp& __e, _Tp __d, 610234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 611234959Stheraven {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 612227825Stheraven _LIBCPP_INLINE_VISIBILITY 613227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 614234959Stheraven memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 615234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 616227825Stheraven _LIBCPP_INLINE_VISIBILITY 617227825Stheraven bool compare_exchange_strong(_Tp& __e, _Tp __d, 618234959Stheraven memory_order __m = memory_order_seq_cst) _NOEXCEPT 619234959Stheraven {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 620227825Stheraven 621227825Stheraven _LIBCPP_INLINE_VISIBILITY 622234959Stheraven __atomic_base() _NOEXCEPT {} // = default; 623227825Stheraven _LIBCPP_INLINE_VISIBILITY 624234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} 625227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 626227825Stheraven __atomic_base(const __atomic_base&) = delete; 627227825Stheraven __atomic_base& operator=(const __atomic_base&) = delete; 628227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile = delete; 629227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 630227825Stheravenprivate: 631227825Stheraven __atomic_base(const __atomic_base&); 632227825Stheraven __atomic_base& operator=(const __atomic_base&); 633227825Stheraven __atomic_base& operator=(const __atomic_base&) volatile; 634227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 635227825Stheraven}; 636227825Stheraven 637227825Stheraven// atomic<Integral> 638227825Stheraven 639227825Stheraventemplate <class _Tp> 640227825Stheravenstruct __atomic_base<_Tp, true> 641227825Stheraven : public __atomic_base<_Tp, false> 642227825Stheraven{ 643227825Stheraven typedef __atomic_base<_Tp, false> __base; 644227825Stheraven _LIBCPP_INLINE_VISIBILITY 645234959Stheraven __atomic_base() _NOEXCEPT {} // = default; 646227825Stheraven _LIBCPP_INLINE_VISIBILITY 647234959Stheraven _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 648227825Stheraven 649227825Stheraven _LIBCPP_INLINE_VISIBILITY 650234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 651234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 652227825Stheraven _LIBCPP_INLINE_VISIBILITY 653234959Stheraven _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 654234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 655227825Stheraven _LIBCPP_INLINE_VISIBILITY 656234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 657234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 658227825Stheraven _LIBCPP_INLINE_VISIBILITY 659234959Stheraven _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 660234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 661227825Stheraven _LIBCPP_INLINE_VISIBILITY 662234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 663234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 664227825Stheraven _LIBCPP_INLINE_VISIBILITY 665234959Stheraven _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 666234959Stheraven {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 667227825Stheraven _LIBCPP_INLINE_VISIBILITY 668234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 669234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 670227825Stheraven _LIBCPP_INLINE_VISIBILITY 671234959Stheraven _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 672234959Stheraven {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 673227825Stheraven _LIBCPP_INLINE_VISIBILITY 674234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 675234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 676227825Stheraven _LIBCPP_INLINE_VISIBILITY 677234959Stheraven _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 678234959Stheraven {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 679227825Stheraven 680227825Stheraven _LIBCPP_INLINE_VISIBILITY 681234959Stheraven _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 682227825Stheraven _LIBCPP_INLINE_VISIBILITY 683234959Stheraven _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 684227825Stheraven _LIBCPP_INLINE_VISIBILITY 685234959Stheraven _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 686227825Stheraven _LIBCPP_INLINE_VISIBILITY 687234959Stheraven _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 688227825Stheraven _LIBCPP_INLINE_VISIBILITY 689234959Stheraven _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 690227825Stheraven _LIBCPP_INLINE_VISIBILITY 691234959Stheraven _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 692227825Stheraven _LIBCPP_INLINE_VISIBILITY 693234959Stheraven _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 694227825Stheraven _LIBCPP_INLINE_VISIBILITY 695234959Stheraven _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 696227825Stheraven _LIBCPP_INLINE_VISIBILITY 697234959Stheraven _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 698227825Stheraven _LIBCPP_INLINE_VISIBILITY 699234959Stheraven _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 700227825Stheraven _LIBCPP_INLINE_VISIBILITY 701234959Stheraven _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 702227825Stheraven _LIBCPP_INLINE_VISIBILITY 703234959Stheraven _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 704227825Stheraven _LIBCPP_INLINE_VISIBILITY 705234959Stheraven _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 706227825Stheraven _LIBCPP_INLINE_VISIBILITY 707234959Stheraven _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 708227825Stheraven _LIBCPP_INLINE_VISIBILITY 709234959Stheraven _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 710227825Stheraven _LIBCPP_INLINE_VISIBILITY 711234959Stheraven _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 712227825Stheraven _LIBCPP_INLINE_VISIBILITY 713234959Stheraven _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 714227825Stheraven _LIBCPP_INLINE_VISIBILITY 715234959Stheraven _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} 716227825Stheraven}; 717227825Stheraven 718227825Stheraven// atomic<T> 719227825Stheraven 720227825Stheraventemplate <class _Tp> 721227825Stheravenstruct atomic 722227825Stheraven : public __atomic_base<_Tp> 723227825Stheraven{ 724227825Stheraven typedef __atomic_base<_Tp> __base; 725227825Stheraven _LIBCPP_INLINE_VISIBILITY 726234959Stheraven atomic() _NOEXCEPT {} // = default; 727227825Stheraven _LIBCPP_INLINE_VISIBILITY 728234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 729227825Stheraven 730227825Stheraven _LIBCPP_INLINE_VISIBILITY 731234959Stheraven _Tp operator=(_Tp __d) volatile _NOEXCEPT 732227825Stheraven {__base::store(__d); return __d;} 733227825Stheraven _LIBCPP_INLINE_VISIBILITY 734234959Stheraven _Tp operator=(_Tp __d) _NOEXCEPT 735227825Stheraven {__base::store(__d); return __d;} 736227825Stheraven}; 737227825Stheraven 738227825Stheraven// atomic<T*> 739227825Stheraven 740227825Stheraventemplate <class _Tp> 741227825Stheravenstruct atomic<_Tp*> 742227825Stheraven : public __atomic_base<_Tp*> 743227825Stheraven{ 744227825Stheraven typedef __atomic_base<_Tp*> __base; 745227825Stheraven _LIBCPP_INLINE_VISIBILITY 746234959Stheraven atomic() _NOEXCEPT {} // = default; 747227825Stheraven _LIBCPP_INLINE_VISIBILITY 748234959Stheraven _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 749227825Stheraven 750227825Stheraven _LIBCPP_INLINE_VISIBILITY 751234959Stheraven _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 752227825Stheraven {__base::store(__d); return __d;} 753227825Stheraven _LIBCPP_INLINE_VISIBILITY 754234959Stheraven _Tp* operator=(_Tp* __d) _NOEXCEPT 755227825Stheraven {__base::store(__d); return __d;} 756227825Stheraven 757227825Stheraven _LIBCPP_INLINE_VISIBILITY 758227825Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 759234959Stheraven volatile _NOEXCEPT 760234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 761227825Stheraven _LIBCPP_INLINE_VISIBILITY 762234959Stheraven _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 763234959Stheraven {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 764227825Stheraven _LIBCPP_INLINE_VISIBILITY 765227825Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 766234959Stheraven volatile _NOEXCEPT 767234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 768227825Stheraven _LIBCPP_INLINE_VISIBILITY 769234959Stheraven _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 770234959Stheraven {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 771227825Stheraven 772227825Stheraven _LIBCPP_INLINE_VISIBILITY 773234959Stheraven _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 774227825Stheraven _LIBCPP_INLINE_VISIBILITY 775234959Stheraven _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 776227825Stheraven _LIBCPP_INLINE_VISIBILITY 777234959Stheraven _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 778227825Stheraven _LIBCPP_INLINE_VISIBILITY 779234959Stheraven _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 780227825Stheraven _LIBCPP_INLINE_VISIBILITY 781234959Stheraven _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 782227825Stheraven _LIBCPP_INLINE_VISIBILITY 783234959Stheraven _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 784227825Stheraven _LIBCPP_INLINE_VISIBILITY 785234959Stheraven _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 786227825Stheraven _LIBCPP_INLINE_VISIBILITY 787234959Stheraven _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 788227825Stheraven _LIBCPP_INLINE_VISIBILITY 789234959Stheraven _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 790227825Stheraven _LIBCPP_INLINE_VISIBILITY 791234959Stheraven _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 792227825Stheraven _LIBCPP_INLINE_VISIBILITY 793234959Stheraven _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 794227825Stheraven _LIBCPP_INLINE_VISIBILITY 795234959Stheraven _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 796227825Stheraven}; 797227825Stheraven 798227825Stheraven// atomic_is_lock_free 799227825Stheraven 800227825Stheraventemplate <class _Tp> 801227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 802227825Stheravenbool 803234959Stheravenatomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT 804227825Stheraven{ 805227825Stheraven return __o->is_lock_free(); 806227825Stheraven} 807227825Stheraven 808227825Stheraventemplate <class _Tp> 809227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 810227825Stheravenbool 811234959Stheravenatomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT 812227825Stheraven{ 813227825Stheraven return __o->is_lock_free(); 814227825Stheraven} 815227825Stheraven 816227825Stheraven// atomic_init 817227825Stheraven 818227825Stheraventemplate <class _Tp> 819227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 820227825Stheravenvoid 821234959Stheravenatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 822227825Stheraven{ 823234959Stheraven __c11_atomic_init(&__o->__a_, __d); 824227825Stheraven} 825227825Stheraven 826227825Stheraventemplate <class _Tp> 827227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 828227825Stheravenvoid 829234959Stheravenatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 830227825Stheraven{ 831234959Stheraven __c11_atomic_init(&__o->__a_, __d); 832227825Stheraven} 833227825Stheraven 834227825Stheraven// atomic_store 835227825Stheraven 836227825Stheraventemplate <class _Tp> 837227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 838227825Stheravenvoid 839234959Stheravenatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 840227825Stheraven{ 841227825Stheraven __o->store(__d); 842227825Stheraven} 843227825Stheraven 844227825Stheraventemplate <class _Tp> 845227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 846227825Stheravenvoid 847234959Stheravenatomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 848227825Stheraven{ 849227825Stheraven __o->store(__d); 850227825Stheraven} 851227825Stheraven 852227825Stheraven// atomic_store_explicit 853227825Stheraven 854227825Stheraventemplate <class _Tp> 855227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 856227825Stheravenvoid 857234959Stheravenatomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 858227825Stheraven{ 859227825Stheraven __o->store(__d, __m); 860227825Stheraven} 861227825Stheraven 862227825Stheraventemplate <class _Tp> 863227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 864227825Stheravenvoid 865234959Stheravenatomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 866227825Stheraven{ 867227825Stheraven __o->store(__d, __m); 868227825Stheraven} 869227825Stheraven 870227825Stheraven// atomic_load 871227825Stheraven 872227825Stheraventemplate <class _Tp> 873227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 874227825Stheraven_Tp 875234959Stheravenatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 876227825Stheraven{ 877227825Stheraven return __o->load(); 878227825Stheraven} 879227825Stheraven 880227825Stheraventemplate <class _Tp> 881227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 882227825Stheraven_Tp 883234959Stheravenatomic_load(const atomic<_Tp>* __o) _NOEXCEPT 884227825Stheraven{ 885227825Stheraven return __o->load(); 886227825Stheraven} 887227825Stheraven 888227825Stheraven// atomic_load_explicit 889227825Stheraven 890227825Stheraventemplate <class _Tp> 891227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 892227825Stheraven_Tp 893234959Stheravenatomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 894227825Stheraven{ 895227825Stheraven return __o->load(__m); 896227825Stheraven} 897227825Stheraven 898227825Stheraventemplate <class _Tp> 899227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 900227825Stheraven_Tp 901234959Stheravenatomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 902227825Stheraven{ 903227825Stheraven return __o->load(__m); 904227825Stheraven} 905227825Stheraven 906227825Stheraven// atomic_exchange 907227825Stheraven 908227825Stheraventemplate <class _Tp> 909227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 910227825Stheraven_Tp 911234959Stheravenatomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 912227825Stheraven{ 913227825Stheraven return __o->exchange(__d); 914227825Stheraven} 915227825Stheraven 916227825Stheraventemplate <class _Tp> 917227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 918227825Stheraven_Tp 919234959Stheravenatomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 920227825Stheraven{ 921227825Stheraven return __o->exchange(__d); 922227825Stheraven} 923227825Stheraven 924227825Stheraven// atomic_exchange_explicit 925227825Stheraven 926227825Stheraventemplate <class _Tp> 927227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 928227825Stheraven_Tp 929234959Stheravenatomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 930227825Stheraven{ 931227825Stheraven return __o->exchange(__d, __m); 932227825Stheraven} 933227825Stheraven 934227825Stheraventemplate <class _Tp> 935227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 936227825Stheraven_Tp 937234959Stheravenatomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 938227825Stheraven{ 939227825Stheraven return __o->exchange(__d, __m); 940227825Stheraven} 941227825Stheraven 942227825Stheraven// atomic_compare_exchange_weak 943227825Stheraven 944227825Stheraventemplate <class _Tp> 945227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 946227825Stheravenbool 947234959Stheravenatomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 948227825Stheraven{ 949227825Stheraven return __o->compare_exchange_weak(*__e, __d); 950227825Stheraven} 951227825Stheraven 952227825Stheraventemplate <class _Tp> 953227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 954227825Stheravenbool 955234959Stheravenatomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 956227825Stheraven{ 957227825Stheraven return __o->compare_exchange_weak(*__e, __d); 958227825Stheraven} 959227825Stheraven 960227825Stheraven// atomic_compare_exchange_strong 961227825Stheraven 962227825Stheraventemplate <class _Tp> 963227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 964227825Stheravenbool 965234959Stheravenatomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 966227825Stheraven{ 967227825Stheraven return __o->compare_exchange_strong(*__e, __d); 968227825Stheraven} 969227825Stheraven 970227825Stheraventemplate <class _Tp> 971227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 972227825Stheravenbool 973234959Stheravenatomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 974227825Stheraven{ 975227825Stheraven return __o->compare_exchange_strong(*__e, __d); 976227825Stheraven} 977227825Stheraven 978227825Stheraven// atomic_compare_exchange_weak_explicit 979227825Stheraven 980227825Stheraventemplate <class _Tp> 981227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 982227825Stheravenbool 983227825Stheravenatomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, 984227825Stheraven _Tp __d, 985234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 986227825Stheraven{ 987227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 988227825Stheraven} 989227825Stheraven 990227825Stheraventemplate <class _Tp> 991227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 992227825Stheravenbool 993227825Stheravenatomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, 994234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 995227825Stheraven{ 996227825Stheraven return __o->compare_exchange_weak(*__e, __d, __s, __f); 997227825Stheraven} 998227825Stheraven 999227825Stheraven// atomic_compare_exchange_strong_explicit 1000227825Stheraven 1001227825Stheraventemplate <class _Tp> 1002227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1003227825Stheravenbool 1004227825Stheravenatomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, 1005227825Stheraven _Tp* __e, _Tp __d, 1006234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1007227825Stheraven{ 1008227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1009227825Stheraven} 1010227825Stheraven 1011227825Stheraventemplate <class _Tp> 1012227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1013227825Stheravenbool 1014227825Stheravenatomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, 1015227825Stheraven _Tp __d, 1016234959Stheraven memory_order __s, memory_order __f) _NOEXCEPT 1017227825Stheraven{ 1018227825Stheraven return __o->compare_exchange_strong(*__e, __d, __s, __f); 1019227825Stheraven} 1020227825Stheraven 1021227825Stheraven// atomic_fetch_add 1022227825Stheraven 1023227825Stheraventemplate <class _Tp> 1024227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1025227825Stheraventypename enable_if 1026227825Stheraven< 1027227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1028227825Stheraven _Tp 1029227825Stheraven>::type 1030234959Stheravenatomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1031227825Stheraven{ 1032227825Stheraven return __o->fetch_add(__op); 1033227825Stheraven} 1034227825Stheraven 1035227825Stheraventemplate <class _Tp> 1036227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1037227825Stheraventypename enable_if 1038227825Stheraven< 1039227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1040227825Stheraven _Tp 1041227825Stheraven>::type 1042234959Stheravenatomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1043227825Stheraven{ 1044227825Stheraven return __o->fetch_add(__op); 1045227825Stheraven} 1046227825Stheraven 1047227825Stheraventemplate <class _Tp> 1048227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1049227825Stheraven_Tp* 1050234959Stheravenatomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1051227825Stheraven{ 1052227825Stheraven return __o->fetch_add(__op); 1053227825Stheraven} 1054227825Stheraven 1055227825Stheraventemplate <class _Tp> 1056227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1057227825Stheraven_Tp* 1058234959Stheravenatomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1059227825Stheraven{ 1060227825Stheraven return __o->fetch_add(__op); 1061227825Stheraven} 1062227825Stheraven 1063227825Stheraven// atomic_fetch_add_explicit 1064227825Stheraven 1065227825Stheraventemplate <class _Tp> 1066227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1067227825Stheraventypename enable_if 1068227825Stheraven< 1069227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1070227825Stheraven _Tp 1071227825Stheraven>::type 1072234959Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1073227825Stheraven{ 1074227825Stheraven return __o->fetch_add(__op, __m); 1075227825Stheraven} 1076227825Stheraven 1077227825Stheraventemplate <class _Tp> 1078227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1079227825Stheraventypename enable_if 1080227825Stheraven< 1081227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1082227825Stheraven _Tp 1083227825Stheraven>::type 1084234959Stheravenatomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1085227825Stheraven{ 1086227825Stheraven return __o->fetch_add(__op, __m); 1087227825Stheraven} 1088227825Stheraven 1089227825Stheraventemplate <class _Tp> 1090227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1091227825Stheraven_Tp* 1092227825Stheravenatomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1093234959Stheraven memory_order __m) _NOEXCEPT 1094227825Stheraven{ 1095227825Stheraven return __o->fetch_add(__op, __m); 1096227825Stheraven} 1097227825Stheraven 1098227825Stheraventemplate <class _Tp> 1099227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1100227825Stheraven_Tp* 1101234959Stheravenatomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1102227825Stheraven{ 1103227825Stheraven return __o->fetch_add(__op, __m); 1104227825Stheraven} 1105227825Stheraven 1106227825Stheraven// atomic_fetch_sub 1107227825Stheraven 1108227825Stheraventemplate <class _Tp> 1109227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1110227825Stheraventypename enable_if 1111227825Stheraven< 1112227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1113227825Stheraven _Tp 1114227825Stheraven>::type 1115234959Stheravenatomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1116227825Stheraven{ 1117227825Stheraven return __o->fetch_sub(__op); 1118227825Stheraven} 1119227825Stheraven 1120227825Stheraventemplate <class _Tp> 1121227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1122227825Stheraventypename enable_if 1123227825Stheraven< 1124227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1125227825Stheraven _Tp 1126227825Stheraven>::type 1127234959Stheravenatomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1128227825Stheraven{ 1129227825Stheraven return __o->fetch_sub(__op); 1130227825Stheraven} 1131227825Stheraven 1132227825Stheraventemplate <class _Tp> 1133227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1134227825Stheraven_Tp* 1135234959Stheravenatomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1136227825Stheraven{ 1137227825Stheraven return __o->fetch_sub(__op); 1138227825Stheraven} 1139227825Stheraven 1140227825Stheraventemplate <class _Tp> 1141227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1142227825Stheraven_Tp* 1143234959Stheravenatomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 1144227825Stheraven{ 1145227825Stheraven return __o->fetch_sub(__op); 1146227825Stheraven} 1147227825Stheraven 1148227825Stheraven// atomic_fetch_sub_explicit 1149227825Stheraven 1150227825Stheraventemplate <class _Tp> 1151227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1152227825Stheraventypename enable_if 1153227825Stheraven< 1154227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1155227825Stheraven _Tp 1156227825Stheraven>::type 1157234959Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1158227825Stheraven{ 1159227825Stheraven return __o->fetch_sub(__op, __m); 1160227825Stheraven} 1161227825Stheraven 1162227825Stheraventemplate <class _Tp> 1163227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1164227825Stheraventypename enable_if 1165227825Stheraven< 1166227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1167227825Stheraven _Tp 1168227825Stheraven>::type 1169234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1170227825Stheraven{ 1171227825Stheraven return __o->fetch_sub(__op, __m); 1172227825Stheraven} 1173227825Stheraven 1174227825Stheraventemplate <class _Tp> 1175227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1176227825Stheraven_Tp* 1177227825Stheravenatomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 1178234959Stheraven memory_order __m) _NOEXCEPT 1179227825Stheraven{ 1180227825Stheraven return __o->fetch_sub(__op, __m); 1181227825Stheraven} 1182227825Stheraven 1183227825Stheraventemplate <class _Tp> 1184227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1185227825Stheraven_Tp* 1186234959Stheravenatomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 1187227825Stheraven{ 1188227825Stheraven return __o->fetch_sub(__op, __m); 1189227825Stheraven} 1190227825Stheraven 1191227825Stheraven// atomic_fetch_and 1192227825Stheraven 1193227825Stheraventemplate <class _Tp> 1194227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1195227825Stheraventypename enable_if 1196227825Stheraven< 1197227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1198227825Stheraven _Tp 1199227825Stheraven>::type 1200234959Stheravenatomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1201227825Stheraven{ 1202227825Stheraven return __o->fetch_and(__op); 1203227825Stheraven} 1204227825Stheraven 1205227825Stheraventemplate <class _Tp> 1206227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1207227825Stheraventypename enable_if 1208227825Stheraven< 1209227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1210227825Stheraven _Tp 1211227825Stheraven>::type 1212234959Stheravenatomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1213227825Stheraven{ 1214227825Stheraven return __o->fetch_and(__op); 1215227825Stheraven} 1216227825Stheraven 1217227825Stheraven// atomic_fetch_and_explicit 1218227825Stheraven 1219227825Stheraventemplate <class _Tp> 1220227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1221227825Stheraventypename enable_if 1222227825Stheraven< 1223227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1224227825Stheraven _Tp 1225227825Stheraven>::type 1226234959Stheravenatomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1227227825Stheraven{ 1228227825Stheraven return __o->fetch_and(__op, __m); 1229227825Stheraven} 1230227825Stheraven 1231227825Stheraventemplate <class _Tp> 1232227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1233227825Stheraventypename enable_if 1234227825Stheraven< 1235227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1236227825Stheraven _Tp 1237227825Stheraven>::type 1238234959Stheravenatomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1239227825Stheraven{ 1240227825Stheraven return __o->fetch_and(__op, __m); 1241227825Stheraven} 1242227825Stheraven 1243227825Stheraven// atomic_fetch_or 1244227825Stheraven 1245227825Stheraventemplate <class _Tp> 1246227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1247227825Stheraventypename enable_if 1248227825Stheraven< 1249227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1250227825Stheraven _Tp 1251227825Stheraven>::type 1252234959Stheravenatomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1253227825Stheraven{ 1254227825Stheraven return __o->fetch_or(__op); 1255227825Stheraven} 1256227825Stheraven 1257227825Stheraventemplate <class _Tp> 1258227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1259227825Stheraventypename enable_if 1260227825Stheraven< 1261227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1262227825Stheraven _Tp 1263227825Stheraven>::type 1264234959Stheravenatomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1265227825Stheraven{ 1266227825Stheraven return __o->fetch_or(__op); 1267227825Stheraven} 1268227825Stheraven 1269227825Stheraven// atomic_fetch_or_explicit 1270227825Stheraven 1271227825Stheraventemplate <class _Tp> 1272227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1273227825Stheraventypename enable_if 1274227825Stheraven< 1275227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1276227825Stheraven _Tp 1277227825Stheraven>::type 1278234959Stheravenatomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1279227825Stheraven{ 1280227825Stheraven return __o->fetch_or(__op, __m); 1281227825Stheraven} 1282227825Stheraven 1283227825Stheraventemplate <class _Tp> 1284227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1285227825Stheraventypename enable_if 1286227825Stheraven< 1287227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1288227825Stheraven _Tp 1289227825Stheraven>::type 1290234959Stheravenatomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1291227825Stheraven{ 1292227825Stheraven return __o->fetch_or(__op, __m); 1293227825Stheraven} 1294227825Stheraven 1295227825Stheraven// atomic_fetch_xor 1296227825Stheraven 1297227825Stheraventemplate <class _Tp> 1298227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1299227825Stheraventypename enable_if 1300227825Stheraven< 1301227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1302227825Stheraven _Tp 1303227825Stheraven>::type 1304234959Stheravenatomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1305227825Stheraven{ 1306227825Stheraven return __o->fetch_xor(__op); 1307227825Stheraven} 1308227825Stheraven 1309227825Stheraventemplate <class _Tp> 1310227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1311227825Stheraventypename enable_if 1312227825Stheraven< 1313227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1314227825Stheraven _Tp 1315227825Stheraven>::type 1316234959Stheravenatomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 1317227825Stheraven{ 1318227825Stheraven return __o->fetch_xor(__op); 1319227825Stheraven} 1320227825Stheraven 1321227825Stheraven// atomic_fetch_xor_explicit 1322227825Stheraven 1323227825Stheraventemplate <class _Tp> 1324227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1325227825Stheraventypename enable_if 1326227825Stheraven< 1327227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1328227825Stheraven _Tp 1329227825Stheraven>::type 1330234959Stheravenatomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1331227825Stheraven{ 1332227825Stheraven return __o->fetch_xor(__op, __m); 1333227825Stheraven} 1334227825Stheraven 1335227825Stheraventemplate <class _Tp> 1336227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1337227825Stheraventypename enable_if 1338227825Stheraven< 1339227825Stheraven is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 1340227825Stheraven _Tp 1341227825Stheraven>::type 1342234959Stheravenatomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 1343227825Stheraven{ 1344227825Stheraven return __o->fetch_xor(__op, __m); 1345227825Stheraven} 1346227825Stheraven 1347227825Stheraven// flag type and operations 1348227825Stheraven 1349227825Stheraventypedef struct atomic_flag 1350227825Stheraven{ 1351232924Stheraven _Atomic(bool) __a_; 1352227825Stheraven 1353227825Stheraven _LIBCPP_INLINE_VISIBILITY 1354234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1355234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1356227825Stheraven _LIBCPP_INLINE_VISIBILITY 1357234959Stheraven bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1358234959Stheraven {return __c11_atomic_exchange(&__a_, true, __m);} 1359227825Stheraven _LIBCPP_INLINE_VISIBILITY 1360234959Stheraven void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 1361234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1362227825Stheraven _LIBCPP_INLINE_VISIBILITY 1363234959Stheraven void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 1364234959Stheraven {__c11_atomic_store(&__a_, false, __m);} 1365227825Stheraven 1366227825Stheraven _LIBCPP_INLINE_VISIBILITY 1367234959Stheraven atomic_flag() _NOEXCEPT {} // = default; 1368227825Stheraven _LIBCPP_INLINE_VISIBILITY 1369234959Stheraven atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} 1370227825Stheraven 1371227825Stheraven#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1372227825Stheraven atomic_flag(const atomic_flag&) = delete; 1373227825Stheraven atomic_flag& operator=(const atomic_flag&) = delete; 1374227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile = delete; 1375227825Stheraven#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1376227825Stheravenprivate: 1377227825Stheraven atomic_flag(const atomic_flag&); 1378227825Stheraven atomic_flag& operator=(const atomic_flag&); 1379227825Stheraven atomic_flag& operator=(const atomic_flag&) volatile; 1380227825Stheraven#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1381227825Stheraven} atomic_flag; 1382227825Stheraven 1383227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1384227825Stheravenbool 1385234959Stheravenatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 1386227825Stheraven{ 1387227825Stheraven return __o->test_and_set(); 1388227825Stheraven} 1389227825Stheraven 1390227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1391227825Stheravenbool 1392234959Stheravenatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 1393227825Stheraven{ 1394227825Stheraven return __o->test_and_set(); 1395227825Stheraven} 1396227825Stheraven 1397227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1398227825Stheravenbool 1399234959Stheravenatomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1400227825Stheraven{ 1401227825Stheraven return __o->test_and_set(__m); 1402227825Stheraven} 1403227825Stheraven 1404227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1405227825Stheravenbool 1406234959Stheravenatomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1407227825Stheraven{ 1408227825Stheraven return __o->test_and_set(__m); 1409227825Stheraven} 1410227825Stheraven 1411227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1412227825Stheravenvoid 1413234959Stheravenatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 1414227825Stheraven{ 1415227825Stheraven __o->clear(); 1416227825Stheraven} 1417227825Stheraven 1418227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1419227825Stheravenvoid 1420234959Stheravenatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 1421227825Stheraven{ 1422227825Stheraven __o->clear(); 1423227825Stheraven} 1424227825Stheraven 1425227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1426227825Stheravenvoid 1427234959Stheravenatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 1428227825Stheraven{ 1429227825Stheraven __o->clear(__m); 1430227825Stheraven} 1431227825Stheraven 1432227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1433227825Stheravenvoid 1434234959Stheravenatomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 1435227825Stheraven{ 1436227825Stheraven __o->clear(__m); 1437227825Stheraven} 1438227825Stheraven 1439227825Stheraven// fences 1440227825Stheraven 1441227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1442227825Stheravenvoid 1443234959Stheravenatomic_thread_fence(memory_order __m) _NOEXCEPT 1444227825Stheraven{ 1445234959Stheraven __c11_atomic_thread_fence(__m); 1446227825Stheraven} 1447227825Stheraven 1448227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1449227825Stheravenvoid 1450234959Stheravenatomic_signal_fence(memory_order __m) _NOEXCEPT 1451227825Stheraven{ 1452234959Stheraven __c11_atomic_signal_fence(__m); 1453227825Stheraven} 1454227825Stheraven 1455227825Stheraven// Atomics for standard typedef types 1456227825Stheraven 1457227825Stheraventypedef atomic<char> atomic_char; 1458227825Stheraventypedef atomic<signed char> atomic_schar; 1459227825Stheraventypedef atomic<unsigned char> atomic_uchar; 1460227825Stheraventypedef atomic<short> atomic_short; 1461227825Stheraventypedef atomic<unsigned short> atomic_ushort; 1462227825Stheraventypedef atomic<int> atomic_int; 1463227825Stheraventypedef atomic<unsigned int> atomic_uint; 1464227825Stheraventypedef atomic<long> atomic_long; 1465227825Stheraventypedef atomic<unsigned long> atomic_ulong; 1466227825Stheraventypedef atomic<long long> atomic_llong; 1467227825Stheraventypedef atomic<unsigned long long> atomic_ullong; 1468227825Stheraventypedef atomic<char16_t> atomic_char16_t; 1469227825Stheraventypedef atomic<char32_t> atomic_char32_t; 1470227825Stheraventypedef atomic<wchar_t> atomic_wchar_t; 1471227825Stheraven 1472227825Stheraventypedef atomic<int_least8_t> atomic_int_least8_t; 1473227825Stheraventypedef atomic<uint_least8_t> atomic_uint_least8_t; 1474227825Stheraventypedef atomic<int_least16_t> atomic_int_least16_t; 1475227825Stheraventypedef atomic<uint_least16_t> atomic_uint_least16_t; 1476227825Stheraventypedef atomic<int_least32_t> atomic_int_least32_t; 1477227825Stheraventypedef atomic<uint_least32_t> atomic_uint_least32_t; 1478227825Stheraventypedef atomic<int_least64_t> atomic_int_least64_t; 1479227825Stheraventypedef atomic<uint_least64_t> atomic_uint_least64_t; 1480227825Stheraven 1481227825Stheraventypedef atomic<int_fast8_t> atomic_int_fast8_t; 1482227825Stheraventypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 1483227825Stheraventypedef atomic<int_fast16_t> atomic_int_fast16_t; 1484227825Stheraventypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 1485227825Stheraventypedef atomic<int_fast32_t> atomic_int_fast32_t; 1486227825Stheraventypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 1487227825Stheraventypedef atomic<int_fast64_t> atomic_int_fast64_t; 1488227825Stheraventypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 1489227825Stheraven 1490227825Stheraventypedef atomic<intptr_t> atomic_intptr_t; 1491227825Stheraventypedef atomic<uintptr_t> atomic_uintptr_t; 1492227825Stheraventypedef atomic<size_t> atomic_size_t; 1493227825Stheraventypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 1494227825Stheraventypedef atomic<intmax_t> atomic_intmax_t; 1495227825Stheraventypedef atomic<uintmax_t> atomic_uintmax_t; 1496227825Stheraven 1497227825Stheraven#define ATOMIC_FLAG_INIT {false} 1498227825Stheraven#define ATOMIC_VAR_INIT(__v) {__v} 1499227825Stheraven 1500227825Stheraven// lock-free property 1501227825Stheraven 1502227825Stheraven#define ATOMIC_CHAR_LOCK_FREE 0 1503227825Stheraven#define ATOMIC_CHAR16_T_LOCK_FREE 0 1504227825Stheraven#define ATOMIC_CHAR32_T_LOCK_FREE 0 1505227825Stheraven#define ATOMIC_WCHAR_T_LOCK_FREE 0 1506227825Stheraven#define ATOMIC_SHORT_LOCK_FREE 0 1507227825Stheraven#define ATOMIC_INT_LOCK_FREE 0 1508227825Stheraven#define ATOMIC_LONG_LOCK_FREE 0 1509227825Stheraven#define ATOMIC_LLONG_LOCK_FREE 0 1510227825Stheraven 1511227825Stheraven#endif // !__has_feature(cxx_atomic) 1512227825Stheraven 1513227825Stheraven_LIBCPP_END_NAMESPACE_STD 1514227825Stheraven 1515227825Stheraven#endif // _LIBCPP_ATOMIC 1516