14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===--------------------------- atomic -----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is distributed under the University of Illinois Open Source 74684ddb6SLionel Sambuc// License. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_ATOMIC 124684ddb6SLionel Sambuc#define _LIBCPP_ATOMIC 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc atomic synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std 184684ddb6SLionel Sambuc{ 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambuc// order and consistency 214684ddb6SLionel Sambuc 224684ddb6SLionel Sambuctypedef enum memory_order 234684ddb6SLionel Sambuc{ 244684ddb6SLionel Sambuc memory_order_relaxed, 254684ddb6SLionel Sambuc memory_order_consume, // load-consume 264684ddb6SLionel Sambuc memory_order_acquire, // load-acquire 274684ddb6SLionel Sambuc memory_order_release, // store-release 284684ddb6SLionel Sambuc memory_order_acq_rel, // store-release load-acquire 294684ddb6SLionel Sambuc memory_order_seq_cst // store-release load-acquire 304684ddb6SLionel Sambuc} memory_order; 314684ddb6SLionel Sambuc 324684ddb6SLionel Sambuctemplate <class T> T kill_dependency(T y) noexcept; 334684ddb6SLionel Sambuc 344684ddb6SLionel Sambuc// lock-free property 354684ddb6SLionel Sambuc 364684ddb6SLionel Sambuc#define ATOMIC_BOOL_LOCK_FREE unspecified 374684ddb6SLionel Sambuc#define ATOMIC_CHAR_LOCK_FREE unspecified 384684ddb6SLionel Sambuc#define ATOMIC_CHAR16_T_LOCK_FREE unspecified 394684ddb6SLionel Sambuc#define ATOMIC_CHAR32_T_LOCK_FREE unspecified 404684ddb6SLionel Sambuc#define ATOMIC_WCHAR_T_LOCK_FREE unspecified 414684ddb6SLionel Sambuc#define ATOMIC_SHORT_LOCK_FREE unspecified 424684ddb6SLionel Sambuc#define ATOMIC_INT_LOCK_FREE unspecified 434684ddb6SLionel Sambuc#define ATOMIC_LONG_LOCK_FREE unspecified 444684ddb6SLionel Sambuc#define ATOMIC_LLONG_LOCK_FREE unspecified 454684ddb6SLionel Sambuc#define ATOMIC_POINTER_LOCK_FREE unspecified 464684ddb6SLionel Sambuc 474684ddb6SLionel Sambuc// flag type and operations 484684ddb6SLionel Sambuc 494684ddb6SLionel Sambuctypedef struct atomic_flag 504684ddb6SLionel Sambuc{ 514684ddb6SLionel Sambuc bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; 524684ddb6SLionel Sambuc bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; 534684ddb6SLionel Sambuc void clear(memory_order m = memory_order_seq_cst) volatile noexcept; 544684ddb6SLionel Sambuc void clear(memory_order m = memory_order_seq_cst) noexcept; 554684ddb6SLionel Sambuc atomic_flag() noexcept = default; 564684ddb6SLionel Sambuc atomic_flag(const atomic_flag&) = delete; 574684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&) = delete; 584684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&) volatile = delete; 594684ddb6SLionel Sambuc} atomic_flag; 604684ddb6SLionel Sambuc 614684ddb6SLionel Sambucbool 624684ddb6SLionel Sambuc atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; 634684ddb6SLionel Sambuc 644684ddb6SLionel Sambucbool 654684ddb6SLionel Sambuc atomic_flag_test_and_set(atomic_flag* obj) noexcept; 664684ddb6SLionel Sambuc 674684ddb6SLionel Sambucbool 684684ddb6SLionel Sambuc atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, 694684ddb6SLionel Sambuc memory_order m) noexcept; 704684ddb6SLionel Sambuc 714684ddb6SLionel Sambucbool 724684ddb6SLionel Sambuc atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; 734684ddb6SLionel Sambuc 744684ddb6SLionel Sambucvoid 754684ddb6SLionel Sambuc atomic_flag_clear(volatile atomic_flag* obj) noexcept; 764684ddb6SLionel Sambuc 774684ddb6SLionel Sambucvoid 784684ddb6SLionel Sambuc atomic_flag_clear(atomic_flag* obj) noexcept; 794684ddb6SLionel Sambuc 804684ddb6SLionel Sambucvoid 814684ddb6SLionel Sambuc atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; 824684ddb6SLionel Sambuc 834684ddb6SLionel Sambucvoid 844684ddb6SLionel Sambuc atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; 854684ddb6SLionel Sambuc 864684ddb6SLionel Sambuc#define ATOMIC_FLAG_INIT see below 874684ddb6SLionel Sambuc#define ATOMIC_VAR_INIT(value) see below 884684ddb6SLionel Sambuc 894684ddb6SLionel Sambuctemplate <class T> 904684ddb6SLionel Sambucstruct atomic 914684ddb6SLionel Sambuc{ 924684ddb6SLionel Sambuc bool is_lock_free() const volatile noexcept; 934684ddb6SLionel Sambuc bool is_lock_free() const noexcept; 944684ddb6SLionel Sambuc void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 954684ddb6SLionel Sambuc void store(T desr, memory_order m = memory_order_seq_cst) noexcept; 964684ddb6SLionel Sambuc T load(memory_order m = memory_order_seq_cst) const volatile noexcept; 974684ddb6SLionel Sambuc T load(memory_order m = memory_order_seq_cst) const noexcept; 984684ddb6SLionel Sambuc operator T() const volatile noexcept; 994684ddb6SLionel Sambuc operator T() const noexcept; 1004684ddb6SLionel Sambuc T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; 1014684ddb6SLionel Sambuc T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; 1024684ddb6SLionel Sambuc bool compare_exchange_weak(T& expc, T desr, 1034684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 1044684ddb6SLionel Sambuc bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; 1054684ddb6SLionel Sambuc bool compare_exchange_strong(T& expc, T desr, 1064684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 1074684ddb6SLionel Sambuc bool compare_exchange_strong(T& expc, T desr, 1084684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 1094684ddb6SLionel Sambuc bool compare_exchange_weak(T& expc, T desr, 1104684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 1114684ddb6SLionel Sambuc bool compare_exchange_weak(T& expc, T desr, 1124684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 1134684ddb6SLionel Sambuc bool compare_exchange_strong(T& expc, T desr, 1144684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 1154684ddb6SLionel Sambuc bool compare_exchange_strong(T& expc, T desr, 1164684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 1174684ddb6SLionel Sambuc 1184684ddb6SLionel Sambuc atomic() noexcept = default; 1194684ddb6SLionel Sambuc constexpr atomic(T desr) noexcept; 1204684ddb6SLionel Sambuc atomic(const atomic&) = delete; 1214684ddb6SLionel Sambuc atomic& operator=(const atomic&) = delete; 1224684ddb6SLionel Sambuc atomic& operator=(const atomic&) volatile = delete; 1234684ddb6SLionel Sambuc T operator=(T) volatile noexcept; 1244684ddb6SLionel Sambuc T operator=(T) noexcept; 1254684ddb6SLionel Sambuc}; 1264684ddb6SLionel Sambuc 1274684ddb6SLionel Sambuctemplate <> 1284684ddb6SLionel Sambucstruct atomic<integral> 1294684ddb6SLionel Sambuc{ 1304684ddb6SLionel Sambuc bool is_lock_free() const volatile noexcept; 1314684ddb6SLionel Sambuc bool is_lock_free() const noexcept; 1324684ddb6SLionel Sambuc void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; 1334684ddb6SLionel Sambuc void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; 1344684ddb6SLionel Sambuc integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; 1354684ddb6SLionel Sambuc integral load(memory_order m = memory_order_seq_cst) const noexcept; 1364684ddb6SLionel Sambuc operator integral() const volatile noexcept; 1374684ddb6SLionel Sambuc operator integral() const noexcept; 1384684ddb6SLionel Sambuc integral exchange(integral desr, 1394684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 1404684ddb6SLionel Sambuc integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; 1414684ddb6SLionel Sambuc bool compare_exchange_weak(integral& expc, integral desr, 1424684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 1434684ddb6SLionel Sambuc bool compare_exchange_weak(integral& expc, integral desr, 1444684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 1454684ddb6SLionel Sambuc bool compare_exchange_strong(integral& expc, integral desr, 1464684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 1474684ddb6SLionel Sambuc bool compare_exchange_strong(integral& expc, integral desr, 1484684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 1494684ddb6SLionel Sambuc bool compare_exchange_weak(integral& expc, integral desr, 1504684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 1514684ddb6SLionel Sambuc bool compare_exchange_weak(integral& expc, integral desr, 1524684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 1534684ddb6SLionel Sambuc bool compare_exchange_strong(integral& expc, integral desr, 1544684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 1554684ddb6SLionel Sambuc bool compare_exchange_strong(integral& expc, integral desr, 1564684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 1574684ddb6SLionel Sambuc 1584684ddb6SLionel Sambuc integral 1594684ddb6SLionel Sambuc fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 1604684ddb6SLionel Sambuc integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; 1614684ddb6SLionel Sambuc integral 1624684ddb6SLionel Sambuc fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 1634684ddb6SLionel Sambuc integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; 1644684ddb6SLionel Sambuc integral 1654684ddb6SLionel Sambuc fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 1664684ddb6SLionel Sambuc integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; 1674684ddb6SLionel Sambuc integral 1684684ddb6SLionel Sambuc fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 1694684ddb6SLionel Sambuc integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; 1704684ddb6SLionel Sambuc integral 1714684ddb6SLionel Sambuc fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; 1724684ddb6SLionel Sambuc integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; 1734684ddb6SLionel Sambuc 1744684ddb6SLionel Sambuc atomic() noexcept = default; 1754684ddb6SLionel Sambuc constexpr atomic(integral desr) noexcept; 1764684ddb6SLionel Sambuc atomic(const atomic&) = delete; 1774684ddb6SLionel Sambuc atomic& operator=(const atomic&) = delete; 1784684ddb6SLionel Sambuc atomic& operator=(const atomic&) volatile = delete; 1794684ddb6SLionel Sambuc integral operator=(integral desr) volatile noexcept; 1804684ddb6SLionel Sambuc integral operator=(integral desr) noexcept; 1814684ddb6SLionel Sambuc 1824684ddb6SLionel Sambuc integral operator++(int) volatile noexcept; 1834684ddb6SLionel Sambuc integral operator++(int) noexcept; 1844684ddb6SLionel Sambuc integral operator--(int) volatile noexcept; 1854684ddb6SLionel Sambuc integral operator--(int) noexcept; 1864684ddb6SLionel Sambuc integral operator++() volatile noexcept; 1874684ddb6SLionel Sambuc integral operator++() noexcept; 1884684ddb6SLionel Sambuc integral operator--() volatile noexcept; 1894684ddb6SLionel Sambuc integral operator--() noexcept; 1904684ddb6SLionel Sambuc integral operator+=(integral op) volatile noexcept; 1914684ddb6SLionel Sambuc integral operator+=(integral op) noexcept; 1924684ddb6SLionel Sambuc integral operator-=(integral op) volatile noexcept; 1934684ddb6SLionel Sambuc integral operator-=(integral op) noexcept; 1944684ddb6SLionel Sambuc integral operator&=(integral op) volatile noexcept; 1954684ddb6SLionel Sambuc integral operator&=(integral op) noexcept; 1964684ddb6SLionel Sambuc integral operator|=(integral op) volatile noexcept; 1974684ddb6SLionel Sambuc integral operator|=(integral op) noexcept; 1984684ddb6SLionel Sambuc integral operator^=(integral op) volatile noexcept; 1994684ddb6SLionel Sambuc integral operator^=(integral op) noexcept; 2004684ddb6SLionel Sambuc}; 2014684ddb6SLionel Sambuc 2024684ddb6SLionel Sambuctemplate <class T> 2034684ddb6SLionel Sambucstruct atomic<T*> 2044684ddb6SLionel Sambuc{ 2054684ddb6SLionel Sambuc bool is_lock_free() const volatile noexcept; 2064684ddb6SLionel Sambuc bool is_lock_free() const noexcept; 2074684ddb6SLionel Sambuc void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 2084684ddb6SLionel Sambuc void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; 2094684ddb6SLionel Sambuc T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; 2104684ddb6SLionel Sambuc T* load(memory_order m = memory_order_seq_cst) const noexcept; 2114684ddb6SLionel Sambuc operator T*() const volatile noexcept; 2124684ddb6SLionel Sambuc operator T*() const noexcept; 2134684ddb6SLionel Sambuc T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; 2144684ddb6SLionel Sambuc T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; 2154684ddb6SLionel Sambuc bool compare_exchange_weak(T*& expc, T* desr, 2164684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 2174684ddb6SLionel Sambuc bool compare_exchange_weak(T*& expc, T* desr, 2184684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 2194684ddb6SLionel Sambuc bool compare_exchange_strong(T*& expc, T* desr, 2204684ddb6SLionel Sambuc memory_order s, memory_order f) volatile noexcept; 2214684ddb6SLionel Sambuc bool compare_exchange_strong(T*& expc, T* desr, 2224684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 2234684ddb6SLionel Sambuc bool compare_exchange_weak(T*& expc, T* desr, 2244684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 2254684ddb6SLionel Sambuc bool compare_exchange_weak(T*& expc, T* desr, 2264684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 2274684ddb6SLionel Sambuc bool compare_exchange_strong(T*& expc, T* desr, 2284684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) volatile noexcept; 2294684ddb6SLionel Sambuc bool compare_exchange_strong(T*& expc, T* desr, 2304684ddb6SLionel Sambuc memory_order m = memory_order_seq_cst) noexcept; 2314684ddb6SLionel Sambuc T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 2324684ddb6SLionel Sambuc T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 2334684ddb6SLionel Sambuc T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; 2344684ddb6SLionel Sambuc T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; 2354684ddb6SLionel Sambuc 2364684ddb6SLionel Sambuc atomic() noexcept = default; 2374684ddb6SLionel Sambuc constexpr atomic(T* desr) noexcept; 2384684ddb6SLionel Sambuc atomic(const atomic&) = delete; 2394684ddb6SLionel Sambuc atomic& operator=(const atomic&) = delete; 2404684ddb6SLionel Sambuc atomic& operator=(const atomic&) volatile = delete; 2414684ddb6SLionel Sambuc 2424684ddb6SLionel Sambuc T* operator=(T*) volatile noexcept; 2434684ddb6SLionel Sambuc T* operator=(T*) noexcept; 2444684ddb6SLionel Sambuc T* operator++(int) volatile noexcept; 2454684ddb6SLionel Sambuc T* operator++(int) noexcept; 2464684ddb6SLionel Sambuc T* operator--(int) volatile noexcept; 2474684ddb6SLionel Sambuc T* operator--(int) noexcept; 2484684ddb6SLionel Sambuc T* operator++() volatile noexcept; 2494684ddb6SLionel Sambuc T* operator++() noexcept; 2504684ddb6SLionel Sambuc T* operator--() volatile noexcept; 2514684ddb6SLionel Sambuc T* operator--() noexcept; 2524684ddb6SLionel Sambuc T* operator+=(ptrdiff_t op) volatile noexcept; 2534684ddb6SLionel Sambuc T* operator+=(ptrdiff_t op) noexcept; 2544684ddb6SLionel Sambuc T* operator-=(ptrdiff_t op) volatile noexcept; 2554684ddb6SLionel Sambuc T* operator-=(ptrdiff_t op) noexcept; 2564684ddb6SLionel Sambuc}; 2574684ddb6SLionel Sambuc 2584684ddb6SLionel Sambuc 2594684ddb6SLionel Sambuctemplate <class T> 2604684ddb6SLionel Sambuc bool 2614684ddb6SLionel Sambuc atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; 2624684ddb6SLionel Sambuc 2634684ddb6SLionel Sambuctemplate <class T> 2644684ddb6SLionel Sambuc bool 2654684ddb6SLionel Sambuc atomic_is_lock_free(const atomic<T>* obj) noexcept; 2664684ddb6SLionel Sambuc 2674684ddb6SLionel Sambuctemplate <class T> 2684684ddb6SLionel Sambuc void 2694684ddb6SLionel Sambuc atomic_init(volatile atomic<T>* obj, T desr) noexcept; 2704684ddb6SLionel Sambuc 2714684ddb6SLionel Sambuctemplate <class T> 2724684ddb6SLionel Sambuc void 2734684ddb6SLionel Sambuc atomic_init(atomic<T>* obj, T desr) noexcept; 2744684ddb6SLionel Sambuc 2754684ddb6SLionel Sambuctemplate <class T> 2764684ddb6SLionel Sambuc void 2774684ddb6SLionel Sambuc atomic_store(volatile atomic<T>* obj, T desr) noexcept; 2784684ddb6SLionel Sambuc 2794684ddb6SLionel Sambuctemplate <class T> 2804684ddb6SLionel Sambuc void 2814684ddb6SLionel Sambuc atomic_store(atomic<T>* obj, T desr) noexcept; 2824684ddb6SLionel Sambuc 2834684ddb6SLionel Sambuctemplate <class T> 2844684ddb6SLionel Sambuc void 2854684ddb6SLionel Sambuc atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 2864684ddb6SLionel Sambuc 2874684ddb6SLionel Sambuctemplate <class T> 2884684ddb6SLionel Sambuc void 2894684ddb6SLionel Sambuc atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 2904684ddb6SLionel Sambuc 2914684ddb6SLionel Sambuctemplate <class T> 2924684ddb6SLionel Sambuc T 2934684ddb6SLionel Sambuc atomic_load(const volatile atomic<T>* obj) noexcept; 2944684ddb6SLionel Sambuc 2954684ddb6SLionel Sambuctemplate <class T> 2964684ddb6SLionel Sambuc T 2974684ddb6SLionel Sambuc atomic_load(const atomic<T>* obj) noexcept; 2984684ddb6SLionel Sambuc 2994684ddb6SLionel Sambuctemplate <class T> 3004684ddb6SLionel Sambuc T 3014684ddb6SLionel Sambuc atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; 3024684ddb6SLionel Sambuc 3034684ddb6SLionel Sambuctemplate <class T> 3044684ddb6SLionel Sambuc T 3054684ddb6SLionel Sambuc atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; 3064684ddb6SLionel Sambuc 3074684ddb6SLionel Sambuctemplate <class T> 3084684ddb6SLionel Sambuc T 3094684ddb6SLionel Sambuc atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; 3104684ddb6SLionel Sambuc 3114684ddb6SLionel Sambuctemplate <class T> 3124684ddb6SLionel Sambuc T 3134684ddb6SLionel Sambuc atomic_exchange(atomic<T>* obj, T desr) noexcept; 3144684ddb6SLionel Sambuc 3154684ddb6SLionel Sambuctemplate <class T> 3164684ddb6SLionel Sambuc T 3174684ddb6SLionel Sambuc atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; 3184684ddb6SLionel Sambuc 3194684ddb6SLionel Sambuctemplate <class T> 3204684ddb6SLionel Sambuc T 3214684ddb6SLionel Sambuc atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; 3224684ddb6SLionel Sambuc 3234684ddb6SLionel Sambuctemplate <class T> 3244684ddb6SLionel Sambuc bool 3254684ddb6SLionel Sambuc atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; 3264684ddb6SLionel Sambuc 3274684ddb6SLionel Sambuctemplate <class T> 3284684ddb6SLionel Sambuc bool 3294684ddb6SLionel Sambuc atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; 3304684ddb6SLionel Sambuc 3314684ddb6SLionel Sambuctemplate <class T> 3324684ddb6SLionel Sambuc bool 3334684ddb6SLionel Sambuc atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; 3344684ddb6SLionel Sambuc 3354684ddb6SLionel Sambuctemplate <class T> 3364684ddb6SLionel Sambuc bool 3374684ddb6SLionel Sambuc atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; 3384684ddb6SLionel Sambuc 3394684ddb6SLionel Sambuctemplate <class T> 3404684ddb6SLionel Sambuc bool 3414684ddb6SLionel Sambuc atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, 3424684ddb6SLionel Sambuc T desr, 3434684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 3444684ddb6SLionel Sambuc 3454684ddb6SLionel Sambuctemplate <class T> 3464684ddb6SLionel Sambuc bool 3474684ddb6SLionel Sambuc atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, 3484684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 3494684ddb6SLionel Sambuc 3504684ddb6SLionel Sambuctemplate <class T> 3514684ddb6SLionel Sambuc bool 3524684ddb6SLionel Sambuc atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, 3534684ddb6SLionel Sambuc T* expc, T desr, 3544684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 3554684ddb6SLionel Sambuc 3564684ddb6SLionel Sambuctemplate <class T> 3574684ddb6SLionel Sambuc bool 3584684ddb6SLionel Sambuc atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, 3594684ddb6SLionel Sambuc T desr, 3604684ddb6SLionel Sambuc memory_order s, memory_order f) noexcept; 3614684ddb6SLionel Sambuc 3624684ddb6SLionel Sambuctemplate <class Integral> 3634684ddb6SLionel Sambuc Integral 3644684ddb6SLionel Sambuc atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; 3654684ddb6SLionel Sambuc 3664684ddb6SLionel Sambuctemplate <class Integral> 3674684ddb6SLionel Sambuc Integral 3684684ddb6SLionel Sambuc atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; 3694684ddb6SLionel Sambuc 3704684ddb6SLionel Sambuctemplate <class Integral> 3714684ddb6SLionel Sambuc Integral 3724684ddb6SLionel Sambuc atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, 3734684ddb6SLionel Sambuc memory_order m) noexcept; 3744684ddb6SLionel Sambuctemplate <class Integral> 3754684ddb6SLionel Sambuc Integral 3764684ddb6SLionel Sambuc atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, 3774684ddb6SLionel Sambuc memory_order m) noexcept; 3784684ddb6SLionel Sambuctemplate <class Integral> 3794684ddb6SLionel Sambuc Integral 3804684ddb6SLionel Sambuc atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; 3814684ddb6SLionel Sambuc 3824684ddb6SLionel Sambuctemplate <class Integral> 3834684ddb6SLionel Sambuc Integral 3844684ddb6SLionel Sambuc atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; 3854684ddb6SLionel Sambuc 3864684ddb6SLionel Sambuctemplate <class Integral> 3874684ddb6SLionel Sambuc Integral 3884684ddb6SLionel Sambuc atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, 3894684ddb6SLionel Sambuc memory_order m) noexcept; 3904684ddb6SLionel Sambuctemplate <class Integral> 3914684ddb6SLionel Sambuc Integral 3924684ddb6SLionel Sambuc atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, 3934684ddb6SLionel Sambuc memory_order m) noexcept; 3944684ddb6SLionel Sambuctemplate <class Integral> 3954684ddb6SLionel Sambuc Integral 3964684ddb6SLionel Sambuc atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; 3974684ddb6SLionel Sambuc 3984684ddb6SLionel Sambuctemplate <class Integral> 3994684ddb6SLionel Sambuc Integral 4004684ddb6SLionel Sambuc atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; 4014684ddb6SLionel Sambuc 4024684ddb6SLionel Sambuctemplate <class Integral> 4034684ddb6SLionel Sambuc Integral 4044684ddb6SLionel Sambuc atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, 4054684ddb6SLionel Sambuc memory_order m) noexcept; 4064684ddb6SLionel Sambuctemplate <class Integral> 4074684ddb6SLionel Sambuc Integral 4084684ddb6SLionel Sambuc atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, 4094684ddb6SLionel Sambuc memory_order m) noexcept; 4104684ddb6SLionel Sambuctemplate <class Integral> 4114684ddb6SLionel Sambuc Integral 4124684ddb6SLionel Sambuc atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; 4134684ddb6SLionel Sambuc 4144684ddb6SLionel Sambuctemplate <class Integral> 4154684ddb6SLionel Sambuc Integral 4164684ddb6SLionel Sambuc atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; 4174684ddb6SLionel Sambuc 4184684ddb6SLionel Sambuctemplate <class Integral> 4194684ddb6SLionel Sambuc Integral 4204684ddb6SLionel Sambuc atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, 4214684ddb6SLionel Sambuc memory_order m) noexcept; 4224684ddb6SLionel Sambuctemplate <class Integral> 4234684ddb6SLionel Sambuc Integral 4244684ddb6SLionel Sambuc atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, 4254684ddb6SLionel Sambuc memory_order m) noexcept; 4264684ddb6SLionel Sambuctemplate <class Integral> 4274684ddb6SLionel Sambuc Integral 4284684ddb6SLionel Sambuc atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; 4294684ddb6SLionel Sambuc 4304684ddb6SLionel Sambuctemplate <class Integral> 4314684ddb6SLionel Sambuc Integral 4324684ddb6SLionel Sambuc atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; 4334684ddb6SLionel Sambuc 4344684ddb6SLionel Sambuctemplate <class Integral> 4354684ddb6SLionel Sambuc Integral 4364684ddb6SLionel Sambuc atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, 4374684ddb6SLionel Sambuc memory_order m) noexcept; 4384684ddb6SLionel Sambuctemplate <class Integral> 4394684ddb6SLionel Sambuc Integral 4404684ddb6SLionel Sambuc atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, 4414684ddb6SLionel Sambuc memory_order m) noexcept; 4424684ddb6SLionel Sambuc 4434684ddb6SLionel Sambuctemplate <class T> 4444684ddb6SLionel Sambuc T* 4454684ddb6SLionel Sambuc atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 4464684ddb6SLionel Sambuc 4474684ddb6SLionel Sambuctemplate <class T> 4484684ddb6SLionel Sambuc T* 4494684ddb6SLionel Sambuc atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; 4504684ddb6SLionel Sambuc 4514684ddb6SLionel Sambuctemplate <class T> 4524684ddb6SLionel Sambuc T* 4534684ddb6SLionel Sambuc atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 4544684ddb6SLionel Sambuc memory_order m) noexcept; 4554684ddb6SLionel Sambuctemplate <class T> 4564684ddb6SLionel Sambuc T* 4574684ddb6SLionel Sambuc atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 4584684ddb6SLionel Sambuc 4594684ddb6SLionel Sambuctemplate <class T> 4604684ddb6SLionel Sambuc T* 4614684ddb6SLionel Sambuc atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; 4624684ddb6SLionel Sambuc 4634684ddb6SLionel Sambuctemplate <class T> 4644684ddb6SLionel Sambuc T* 4654684ddb6SLionel Sambuc atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; 4664684ddb6SLionel Sambuc 4674684ddb6SLionel Sambuctemplate <class T> 4684684ddb6SLionel Sambuc T* 4694684ddb6SLionel Sambuc atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, 4704684ddb6SLionel Sambuc memory_order m) noexcept; 4714684ddb6SLionel Sambuctemplate <class T> 4724684ddb6SLionel Sambuc T* 4734684ddb6SLionel Sambuc atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; 4744684ddb6SLionel Sambuc 4754684ddb6SLionel Sambuc// Atomics for standard typedef types 4764684ddb6SLionel Sambuc 4774684ddb6SLionel Sambuctypedef atomic<bool> atomic_bool; 4784684ddb6SLionel Sambuctypedef atomic<char> atomic_char; 4794684ddb6SLionel Sambuctypedef atomic<signed char> atomic_schar; 4804684ddb6SLionel Sambuctypedef atomic<unsigned char> atomic_uchar; 4814684ddb6SLionel Sambuctypedef atomic<short> atomic_short; 4824684ddb6SLionel Sambuctypedef atomic<unsigned short> atomic_ushort; 4834684ddb6SLionel Sambuctypedef atomic<int> atomic_int; 4844684ddb6SLionel Sambuctypedef atomic<unsigned int> atomic_uint; 4854684ddb6SLionel Sambuctypedef atomic<long> atomic_long; 4864684ddb6SLionel Sambuctypedef atomic<unsigned long> atomic_ulong; 4874684ddb6SLionel Sambuctypedef atomic<long long> atomic_llong; 4884684ddb6SLionel Sambuctypedef atomic<unsigned long long> atomic_ullong; 4894684ddb6SLionel Sambuctypedef atomic<char16_t> atomic_char16_t; 4904684ddb6SLionel Sambuctypedef atomic<char32_t> atomic_char32_t; 4914684ddb6SLionel Sambuctypedef atomic<wchar_t> atomic_wchar_t; 4924684ddb6SLionel Sambuc 4934684ddb6SLionel Sambuctypedef atomic<int_least8_t> atomic_int_least8_t; 4944684ddb6SLionel Sambuctypedef atomic<uint_least8_t> atomic_uint_least8_t; 4954684ddb6SLionel Sambuctypedef atomic<int_least16_t> atomic_int_least16_t; 4964684ddb6SLionel Sambuctypedef atomic<uint_least16_t> atomic_uint_least16_t; 4974684ddb6SLionel Sambuctypedef atomic<int_least32_t> atomic_int_least32_t; 4984684ddb6SLionel Sambuctypedef atomic<uint_least32_t> atomic_uint_least32_t; 4994684ddb6SLionel Sambuctypedef atomic<int_least64_t> atomic_int_least64_t; 5004684ddb6SLionel Sambuctypedef atomic<uint_least64_t> atomic_uint_least64_t; 5014684ddb6SLionel Sambuc 5024684ddb6SLionel Sambuctypedef atomic<int_fast8_t> atomic_int_fast8_t; 5034684ddb6SLionel Sambuctypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 5044684ddb6SLionel Sambuctypedef atomic<int_fast16_t> atomic_int_fast16_t; 5054684ddb6SLionel Sambuctypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 5064684ddb6SLionel Sambuctypedef atomic<int_fast32_t> atomic_int_fast32_t; 5074684ddb6SLionel Sambuctypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 5084684ddb6SLionel Sambuctypedef atomic<int_fast64_t> atomic_int_fast64_t; 5094684ddb6SLionel Sambuctypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 5104684ddb6SLionel Sambuc 5114684ddb6SLionel Sambuctypedef atomic<intptr_t> atomic_intptr_t; 5124684ddb6SLionel Sambuctypedef atomic<uintptr_t> atomic_uintptr_t; 5134684ddb6SLionel Sambuctypedef atomic<size_t> atomic_size_t; 5144684ddb6SLionel Sambuctypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 5154684ddb6SLionel Sambuctypedef atomic<intmax_t> atomic_intmax_t; 5164684ddb6SLionel Sambuctypedef atomic<uintmax_t> atomic_uintmax_t; 5174684ddb6SLionel Sambuc 5184684ddb6SLionel Sambuc// fences 5194684ddb6SLionel Sambuc 5204684ddb6SLionel Sambucvoid atomic_thread_fence(memory_order m) noexcept; 5214684ddb6SLionel Sambucvoid atomic_signal_fence(memory_order m) noexcept; 5224684ddb6SLionel Sambuc 5234684ddb6SLionel Sambuc} // std 5244684ddb6SLionel Sambuc 5254684ddb6SLionel Sambuc*/ 5264684ddb6SLionel Sambuc 5274684ddb6SLionel Sambuc#include <__config> 5284684ddb6SLionel Sambuc#include <cstddef> 5294684ddb6SLionel Sambuc#include <cstdint> 5304684ddb6SLionel Sambuc#include <type_traits> 5314684ddb6SLionel Sambuc 5324684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5334684ddb6SLionel Sambuc#pragma GCC system_header 5344684ddb6SLionel Sambuc#endif 5354684ddb6SLionel Sambuc 536*0a6a1f1dSLionel Sambuc#ifdef _LIBCPP_HAS_NO_THREADS 537*0a6a1f1dSLionel Sambuc#error <atomic> is not supported on this single threaded system 538*0a6a1f1dSLionel Sambuc#endif 539*0a6a1f1dSLionel Sambuc#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) 5404684ddb6SLionel Sambuc#error <atomic> is not implemented 541*0a6a1f1dSLionel Sambuc#endif 542*0a6a1f1dSLionel Sambuc 543*0a6a1f1dSLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 5444684ddb6SLionel Sambuc 5454684ddb6SLionel Sambuctypedef enum memory_order 5464684ddb6SLionel Sambuc{ 5474684ddb6SLionel Sambuc memory_order_relaxed, memory_order_consume, memory_order_acquire, 5484684ddb6SLionel Sambuc memory_order_release, memory_order_acq_rel, memory_order_seq_cst 5494684ddb6SLionel Sambuc} memory_order; 5504684ddb6SLionel Sambuc 551*0a6a1f1dSLionel Sambuc#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) 552*0a6a1f1dSLionel Sambucnamespace __gcc_atomic { 553*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 554*0a6a1f1dSLionel Sambucstruct __gcc_atomic_t { 555*0a6a1f1dSLionel Sambuc __gcc_atomic_t() _NOEXCEPT {} 556*0a6a1f1dSLionel Sambuc _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT 557*0a6a1f1dSLionel Sambuc : __a_value(value) {} 558*0a6a1f1dSLionel Sambuc _Tp __a_value; 559*0a6a1f1dSLionel Sambuc}; 560*0a6a1f1dSLionel Sambuc#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> 561*0a6a1f1dSLionel Sambuc 562*0a6a1f1dSLionel Sambuctemplate <typename _Tp> _Tp __create(); 563*0a6a1f1dSLionel Sambuc 564*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 565*0a6a1f1dSLionel Sambuctypename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type 566*0a6a1f1dSLionel Sambuc __test_atomic_assignable(int); 567*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Up> 568*0a6a1f1dSLionel Sambuc__two __test_atomic_assignable(...); 569*0a6a1f1dSLionel Sambuc 570*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 571*0a6a1f1dSLionel Sambucstruct __can_assign { 572*0a6a1f1dSLionel Sambuc static const bool value = 573*0a6a1f1dSLionel Sambuc sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); 574*0a6a1f1dSLionel Sambuc}; 575*0a6a1f1dSLionel Sambuc 576*0a6a1f1dSLionel Sambucstatic inline constexpr int __to_gcc_order(memory_order __order) { 577*0a6a1f1dSLionel Sambuc // Avoid switch statement to make this a constexpr. 578*0a6a1f1dSLionel Sambuc return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 579*0a6a1f1dSLionel Sambuc (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 580*0a6a1f1dSLionel Sambuc (__order == memory_order_release ? __ATOMIC_RELEASE: 581*0a6a1f1dSLionel Sambuc (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 582*0a6a1f1dSLionel Sambuc (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: 583*0a6a1f1dSLionel Sambuc __ATOMIC_CONSUME)))); 584*0a6a1f1dSLionel Sambuc} 585*0a6a1f1dSLionel Sambuc 586*0a6a1f1dSLionel Sambucstatic inline constexpr int __to_gcc_failure_order(memory_order __order) { 587*0a6a1f1dSLionel Sambuc // Avoid switch statement to make this a constexpr. 588*0a6a1f1dSLionel Sambuc return __order == memory_order_relaxed ? __ATOMIC_RELAXED: 589*0a6a1f1dSLionel Sambuc (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: 590*0a6a1f1dSLionel Sambuc (__order == memory_order_release ? __ATOMIC_RELAXED: 591*0a6a1f1dSLionel Sambuc (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: 592*0a6a1f1dSLionel Sambuc (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE: 593*0a6a1f1dSLionel Sambuc __ATOMIC_CONSUME)))); 594*0a6a1f1dSLionel Sambuc} 595*0a6a1f1dSLionel Sambuc 596*0a6a1f1dSLionel Sambuc} // namespace __gcc_atomic 597*0a6a1f1dSLionel Sambuc 598*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 599*0a6a1f1dSLionel Sambucstatic inline 600*0a6a1f1dSLionel Sambuctypename enable_if< 601*0a6a1f1dSLionel Sambuc __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type 602*0a6a1f1dSLionel Sambuc__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 603*0a6a1f1dSLionel Sambuc __a->__a_value = __val; 604*0a6a1f1dSLionel Sambuc} 605*0a6a1f1dSLionel Sambuc 606*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 607*0a6a1f1dSLionel Sambucstatic inline 608*0a6a1f1dSLionel Sambuctypename enable_if< 609*0a6a1f1dSLionel Sambuc !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value && 610*0a6a1f1dSLionel Sambuc __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type 611*0a6a1f1dSLionel Sambuc__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { 612*0a6a1f1dSLionel Sambuc // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because 613*0a6a1f1dSLionel Sambuc // the default operator= in an object is not volatile, a byte-by-byte copy 614*0a6a1f1dSLionel Sambuc // is required. 615*0a6a1f1dSLionel Sambuc volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value); 616*0a6a1f1dSLionel Sambuc volatile char* end = to + sizeof(_Tp); 617*0a6a1f1dSLionel Sambuc char* from = reinterpret_cast<char*>(&__val); 618*0a6a1f1dSLionel Sambuc while (to != end) { 619*0a6a1f1dSLionel Sambuc *to++ = *from++; 620*0a6a1f1dSLionel Sambuc } 621*0a6a1f1dSLionel Sambuc} 622*0a6a1f1dSLionel Sambuc 623*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 624*0a6a1f1dSLionel Sambucstatic inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { 625*0a6a1f1dSLionel Sambuc __a->__a_value = __val; 626*0a6a1f1dSLionel Sambuc} 627*0a6a1f1dSLionel Sambuc 628*0a6a1f1dSLionel Sambucstatic inline void __c11_atomic_thread_fence(memory_order __order) { 629*0a6a1f1dSLionel Sambuc __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); 630*0a6a1f1dSLionel Sambuc} 631*0a6a1f1dSLionel Sambuc 632*0a6a1f1dSLionel Sambucstatic inline void __c11_atomic_signal_fence(memory_order __order) { 633*0a6a1f1dSLionel Sambuc __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); 634*0a6a1f1dSLionel Sambuc} 635*0a6a1f1dSLionel Sambuc 636*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 637*0a6a1f1dSLionel Sambucstatic inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, 638*0a6a1f1dSLionel Sambuc memory_order __order) { 639*0a6a1f1dSLionel Sambuc return __atomic_store(&__a->__a_value, &__val, 640*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 641*0a6a1f1dSLionel Sambuc} 642*0a6a1f1dSLionel Sambuc 643*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 644*0a6a1f1dSLionel Sambucstatic inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, 645*0a6a1f1dSLionel Sambuc memory_order __order) { 646*0a6a1f1dSLionel Sambuc __atomic_store(&__a->__a_value, &__val, 647*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 648*0a6a1f1dSLionel Sambuc} 649*0a6a1f1dSLionel Sambuc 650*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 651*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, 652*0a6a1f1dSLionel Sambuc memory_order __order) { 653*0a6a1f1dSLionel Sambuc _Tp __ret; 654*0a6a1f1dSLionel Sambuc __atomic_load(&__a->__a_value, &__ret, 655*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 656*0a6a1f1dSLionel Sambuc return __ret; 657*0a6a1f1dSLionel Sambuc} 658*0a6a1f1dSLionel Sambuc 659*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 660*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { 661*0a6a1f1dSLionel Sambuc _Tp __ret; 662*0a6a1f1dSLionel Sambuc __atomic_load(&__a->__a_value, &__ret, 663*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 664*0a6a1f1dSLionel Sambuc return __ret; 665*0a6a1f1dSLionel Sambuc} 666*0a6a1f1dSLionel Sambuc 667*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 668*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, 669*0a6a1f1dSLionel Sambuc _Tp __value, memory_order __order) { 670*0a6a1f1dSLionel Sambuc _Tp __ret; 671*0a6a1f1dSLionel Sambuc __atomic_exchange(&__a->__a_value, &__value, &__ret, 672*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 673*0a6a1f1dSLionel Sambuc return __ret; 674*0a6a1f1dSLionel Sambuc} 675*0a6a1f1dSLionel Sambuc 676*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 677*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, 678*0a6a1f1dSLionel Sambuc memory_order __order) { 679*0a6a1f1dSLionel Sambuc _Tp __ret; 680*0a6a1f1dSLionel Sambuc __atomic_exchange(&__a->__a_value, &__value, &__ret, 681*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 682*0a6a1f1dSLionel Sambuc return __ret; 683*0a6a1f1dSLionel Sambuc} 684*0a6a1f1dSLionel Sambuc 685*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 686*0a6a1f1dSLionel Sambucstatic inline bool __c11_atomic_compare_exchange_strong( 687*0a6a1f1dSLionel Sambuc volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 688*0a6a1f1dSLionel Sambuc memory_order __success, memory_order __failure) { 689*0a6a1f1dSLionel Sambuc return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 690*0a6a1f1dSLionel Sambuc false, 691*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__success), 692*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_failure_order(__failure)); 693*0a6a1f1dSLionel Sambuc} 694*0a6a1f1dSLionel Sambuc 695*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 696*0a6a1f1dSLionel Sambucstatic inline bool __c11_atomic_compare_exchange_strong( 697*0a6a1f1dSLionel Sambuc _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 698*0a6a1f1dSLionel Sambuc memory_order __failure) { 699*0a6a1f1dSLionel Sambuc return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 700*0a6a1f1dSLionel Sambuc false, 701*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__success), 702*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_failure_order(__failure)); 703*0a6a1f1dSLionel Sambuc} 704*0a6a1f1dSLionel Sambuc 705*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 706*0a6a1f1dSLionel Sambucstatic inline bool __c11_atomic_compare_exchange_weak( 707*0a6a1f1dSLionel Sambuc volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, 708*0a6a1f1dSLionel Sambuc memory_order __success, memory_order __failure) { 709*0a6a1f1dSLionel Sambuc return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 710*0a6a1f1dSLionel Sambuc true, 711*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__success), 712*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_failure_order(__failure)); 713*0a6a1f1dSLionel Sambuc} 714*0a6a1f1dSLionel Sambuc 715*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 716*0a6a1f1dSLionel Sambucstatic inline bool __c11_atomic_compare_exchange_weak( 717*0a6a1f1dSLionel Sambuc _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, 718*0a6a1f1dSLionel Sambuc memory_order __failure) { 719*0a6a1f1dSLionel Sambuc return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, 720*0a6a1f1dSLionel Sambuc true, 721*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__success), 722*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_failure_order(__failure)); 723*0a6a1f1dSLionel Sambuc} 724*0a6a1f1dSLionel Sambuc 725*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 726*0a6a1f1dSLionel Sambucstruct __skip_amt { enum {value = 1}; }; 727*0a6a1f1dSLionel Sambuc 728*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 729*0a6a1f1dSLionel Sambucstruct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; 730*0a6a1f1dSLionel Sambuc 731*0a6a1f1dSLionel Sambuc// FIXME: Haven't figured out what the spec says about using arrays with 732*0a6a1f1dSLionel Sambuc// atomic_fetch_add. Force a failure rather than creating bad behavior. 733*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 734*0a6a1f1dSLionel Sambucstruct __skip_amt<_Tp[]> { }; 735*0a6a1f1dSLionel Sambuctemplate <typename _Tp, int n> 736*0a6a1f1dSLionel Sambucstruct __skip_amt<_Tp[n]> { }; 737*0a6a1f1dSLionel Sambuc 738*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 739*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, 740*0a6a1f1dSLionel Sambuc _Td __delta, memory_order __order) { 741*0a6a1f1dSLionel Sambuc return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 742*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 743*0a6a1f1dSLionel Sambuc} 744*0a6a1f1dSLionel Sambuc 745*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 746*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, 747*0a6a1f1dSLionel Sambuc memory_order __order) { 748*0a6a1f1dSLionel Sambuc return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 749*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 750*0a6a1f1dSLionel Sambuc} 751*0a6a1f1dSLionel Sambuc 752*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 753*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, 754*0a6a1f1dSLionel Sambuc _Td __delta, memory_order __order) { 755*0a6a1f1dSLionel Sambuc return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 756*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 757*0a6a1f1dSLionel Sambuc} 758*0a6a1f1dSLionel Sambuc 759*0a6a1f1dSLionel Sambuctemplate <typename _Tp, typename _Td> 760*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, 761*0a6a1f1dSLionel Sambuc memory_order __order) { 762*0a6a1f1dSLionel Sambuc return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, 763*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 764*0a6a1f1dSLionel Sambuc} 765*0a6a1f1dSLionel Sambuc 766*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 767*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, 768*0a6a1f1dSLionel Sambuc _Tp __pattern, memory_order __order) { 769*0a6a1f1dSLionel Sambuc return __atomic_fetch_and(&__a->__a_value, __pattern, 770*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 771*0a6a1f1dSLionel Sambuc} 772*0a6a1f1dSLionel Sambuc 773*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 774*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, 775*0a6a1f1dSLionel Sambuc _Tp __pattern, memory_order __order) { 776*0a6a1f1dSLionel Sambuc return __atomic_fetch_and(&__a->__a_value, __pattern, 777*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 778*0a6a1f1dSLionel Sambuc} 779*0a6a1f1dSLionel Sambuc 780*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 781*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, 782*0a6a1f1dSLionel Sambuc _Tp __pattern, memory_order __order) { 783*0a6a1f1dSLionel Sambuc return __atomic_fetch_or(&__a->__a_value, __pattern, 784*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 785*0a6a1f1dSLionel Sambuc} 786*0a6a1f1dSLionel Sambuc 787*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 788*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, 789*0a6a1f1dSLionel Sambuc memory_order __order) { 790*0a6a1f1dSLionel Sambuc return __atomic_fetch_or(&__a->__a_value, __pattern, 791*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 792*0a6a1f1dSLionel Sambuc} 793*0a6a1f1dSLionel Sambuc 794*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 795*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, 796*0a6a1f1dSLionel Sambuc _Tp __pattern, memory_order __order) { 797*0a6a1f1dSLionel Sambuc return __atomic_fetch_xor(&__a->__a_value, __pattern, 798*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 799*0a6a1f1dSLionel Sambuc} 800*0a6a1f1dSLionel Sambuc 801*0a6a1f1dSLionel Sambuctemplate <typename _Tp> 802*0a6a1f1dSLionel Sambucstatic inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, 803*0a6a1f1dSLionel Sambuc memory_order __order) { 804*0a6a1f1dSLionel Sambuc return __atomic_fetch_xor(&__a->__a_value, __pattern, 805*0a6a1f1dSLionel Sambuc __gcc_atomic::__to_gcc_order(__order)); 806*0a6a1f1dSLionel Sambuc} 807*0a6a1f1dSLionel Sambuc#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP 808*0a6a1f1dSLionel Sambuc 8094684ddb6SLionel Sambuctemplate <class _Tp> 8104684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8114684ddb6SLionel Sambuc_Tp 8124684ddb6SLionel Sambuckill_dependency(_Tp __y) _NOEXCEPT 8134684ddb6SLionel Sambuc{ 8144684ddb6SLionel Sambuc return __y; 8154684ddb6SLionel Sambuc} 8164684ddb6SLionel Sambuc 8174684ddb6SLionel Sambuc// general atomic<T> 8184684ddb6SLionel Sambuc 8194684ddb6SLionel Sambuctemplate <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> 8204684ddb6SLionel Sambucstruct __atomic_base // false 8214684ddb6SLionel Sambuc{ 8224684ddb6SLionel Sambuc mutable _Atomic(_Tp) __a_; 8234684ddb6SLionel Sambuc 8244684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8254684ddb6SLionel Sambuc bool is_lock_free() const volatile _NOEXCEPT 826*0a6a1f1dSLionel Sambuc { 827*0a6a1f1dSLionel Sambuc#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) 828*0a6a1f1dSLionel Sambuc return __c11_atomic_is_lock_free(sizeof(_Tp)); 829*0a6a1f1dSLionel Sambuc#else 830*0a6a1f1dSLionel Sambuc return __atomic_is_lock_free(sizeof(_Tp), 0); 831*0a6a1f1dSLionel Sambuc#endif 832*0a6a1f1dSLionel Sambuc } 8334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8344684ddb6SLionel Sambuc bool is_lock_free() const _NOEXCEPT 835*0a6a1f1dSLionel Sambuc {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} 8364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8374684ddb6SLionel Sambuc void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 8384684ddb6SLionel Sambuc {__c11_atomic_store(&__a_, __d, __m);} 8394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8404684ddb6SLionel Sambuc void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 8414684ddb6SLionel Sambuc {__c11_atomic_store(&__a_, __d, __m);} 8424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8434684ddb6SLionel Sambuc _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT 8444684ddb6SLionel Sambuc {return __c11_atomic_load(&__a_, __m);} 8454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8464684ddb6SLionel Sambuc _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT 8474684ddb6SLionel Sambuc {return __c11_atomic_load(&__a_, __m);} 8484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8494684ddb6SLionel Sambuc operator _Tp() const volatile _NOEXCEPT {return load();} 8504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8514684ddb6SLionel Sambuc operator _Tp() const _NOEXCEPT {return load();} 8524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8534684ddb6SLionel Sambuc _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 8544684ddb6SLionel Sambuc {return __c11_atomic_exchange(&__a_, __d, __m);} 8554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8564684ddb6SLionel Sambuc _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT 8574684ddb6SLionel Sambuc {return __c11_atomic_exchange(&__a_, __d, __m);} 8584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8594684ddb6SLionel Sambuc bool compare_exchange_weak(_Tp& __e, _Tp __d, 8604684ddb6SLionel Sambuc memory_order __s, memory_order __f) volatile _NOEXCEPT 8614684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 8624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8634684ddb6SLionel Sambuc bool compare_exchange_weak(_Tp& __e, _Tp __d, 8644684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 8654684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} 8664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8674684ddb6SLionel Sambuc bool compare_exchange_strong(_Tp& __e, _Tp __d, 8684684ddb6SLionel Sambuc memory_order __s, memory_order __f) volatile _NOEXCEPT 8694684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 8704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8714684ddb6SLionel Sambuc bool compare_exchange_strong(_Tp& __e, _Tp __d, 8724684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 8734684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} 8744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8754684ddb6SLionel Sambuc bool compare_exchange_weak(_Tp& __e, _Tp __d, 8764684ddb6SLionel Sambuc memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 8774684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 8784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8794684ddb6SLionel Sambuc bool compare_exchange_weak(_Tp& __e, _Tp __d, 8804684ddb6SLionel Sambuc memory_order __m = memory_order_seq_cst) _NOEXCEPT 8814684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} 8824684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8834684ddb6SLionel Sambuc bool compare_exchange_strong(_Tp& __e, _Tp __d, 8844684ddb6SLionel Sambuc memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 8854684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 8864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8874684ddb6SLionel Sambuc bool compare_exchange_strong(_Tp& __e, _Tp __d, 8884684ddb6SLionel Sambuc memory_order __m = memory_order_seq_cst) _NOEXCEPT 8894684ddb6SLionel Sambuc {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} 8904684ddb6SLionel Sambuc 8914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8924684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 8934684ddb6SLionel Sambuc __atomic_base() _NOEXCEPT = default; 8944684ddb6SLionel Sambuc#else 8954684ddb6SLionel Sambuc __atomic_base() _NOEXCEPT : __a_() {} 8964684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 8974684ddb6SLionel Sambuc 8984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8994684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} 9004684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 9014684ddb6SLionel Sambuc __atomic_base(const __atomic_base&) = delete; 9024684ddb6SLionel Sambuc __atomic_base& operator=(const __atomic_base&) = delete; 9034684ddb6SLionel Sambuc __atomic_base& operator=(const __atomic_base&) volatile = delete; 9044684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 9054684ddb6SLionel Sambucprivate: 9064684ddb6SLionel Sambuc __atomic_base(const __atomic_base&); 9074684ddb6SLionel Sambuc __atomic_base& operator=(const __atomic_base&); 9084684ddb6SLionel Sambuc __atomic_base& operator=(const __atomic_base&) volatile; 9094684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 9104684ddb6SLionel Sambuc}; 9114684ddb6SLionel Sambuc 9124684ddb6SLionel Sambuc// atomic<Integral> 9134684ddb6SLionel Sambuc 9144684ddb6SLionel Sambuctemplate <class _Tp> 9154684ddb6SLionel Sambucstruct __atomic_base<_Tp, true> 9164684ddb6SLionel Sambuc : public __atomic_base<_Tp, false> 9174684ddb6SLionel Sambuc{ 9184684ddb6SLionel Sambuc typedef __atomic_base<_Tp, false> __base; 9194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9204684ddb6SLionel Sambuc __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT 9214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9224684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} 9234684ddb6SLionel Sambuc 9244684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9254684ddb6SLionel Sambuc _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 9264684ddb6SLionel Sambuc {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 9274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9284684ddb6SLionel Sambuc _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 9294684ddb6SLionel Sambuc {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 9304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9314684ddb6SLionel Sambuc _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 9324684ddb6SLionel Sambuc {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 9334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9344684ddb6SLionel Sambuc _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 9354684ddb6SLionel Sambuc {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 9364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9374684ddb6SLionel Sambuc _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 9384684ddb6SLionel Sambuc {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 9394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9404684ddb6SLionel Sambuc _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 9414684ddb6SLionel Sambuc {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} 9424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9434684ddb6SLionel Sambuc _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 9444684ddb6SLionel Sambuc {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 9454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9464684ddb6SLionel Sambuc _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 9474684ddb6SLionel Sambuc {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} 9484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9494684ddb6SLionel Sambuc _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 9504684ddb6SLionel Sambuc {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 9514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9524684ddb6SLionel Sambuc _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 9534684ddb6SLionel Sambuc {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} 9544684ddb6SLionel Sambuc 9554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9564684ddb6SLionel Sambuc _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} 9574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9584684ddb6SLionel Sambuc _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} 9594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9604684ddb6SLionel Sambuc _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} 9614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9624684ddb6SLionel Sambuc _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} 9634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9644684ddb6SLionel Sambuc _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 9654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9664684ddb6SLionel Sambuc _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} 9674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9684684ddb6SLionel Sambuc _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 9694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9704684ddb6SLionel Sambuc _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} 9714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9724684ddb6SLionel Sambuc _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 9734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9744684ddb6SLionel Sambuc _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} 9754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9764684ddb6SLionel Sambuc _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 9774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9784684ddb6SLionel Sambuc _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 9794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9804684ddb6SLionel Sambuc _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} 9814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9824684ddb6SLionel Sambuc _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} 9834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9844684ddb6SLionel Sambuc _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} 9854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9864684ddb6SLionel Sambuc _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} 9874684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9884684ddb6SLionel Sambuc _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} 9894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9904684ddb6SLionel Sambuc _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} 9914684ddb6SLionel Sambuc}; 9924684ddb6SLionel Sambuc 9934684ddb6SLionel Sambuc// atomic<T> 9944684ddb6SLionel Sambuc 9954684ddb6SLionel Sambuctemplate <class _Tp> 9964684ddb6SLionel Sambucstruct atomic 9974684ddb6SLionel Sambuc : public __atomic_base<_Tp> 9984684ddb6SLionel Sambuc{ 9994684ddb6SLionel Sambuc typedef __atomic_base<_Tp> __base; 10004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10014684ddb6SLionel Sambuc atomic() _NOEXCEPT _LIBCPP_DEFAULT 10024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10034684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} 10044684ddb6SLionel Sambuc 10054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10064684ddb6SLionel Sambuc _Tp operator=(_Tp __d) volatile _NOEXCEPT 10074684ddb6SLionel Sambuc {__base::store(__d); return __d;} 10084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10094684ddb6SLionel Sambuc _Tp operator=(_Tp __d) _NOEXCEPT 10104684ddb6SLionel Sambuc {__base::store(__d); return __d;} 10114684ddb6SLionel Sambuc}; 10124684ddb6SLionel Sambuc 10134684ddb6SLionel Sambuc// atomic<T*> 10144684ddb6SLionel Sambuc 10154684ddb6SLionel Sambuctemplate <class _Tp> 10164684ddb6SLionel Sambucstruct atomic<_Tp*> 10174684ddb6SLionel Sambuc : public __atomic_base<_Tp*> 10184684ddb6SLionel Sambuc{ 10194684ddb6SLionel Sambuc typedef __atomic_base<_Tp*> __base; 10204684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10214684ddb6SLionel Sambuc atomic() _NOEXCEPT _LIBCPP_DEFAULT 10224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10234684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} 10244684ddb6SLionel Sambuc 10254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10264684ddb6SLionel Sambuc _Tp* operator=(_Tp* __d) volatile _NOEXCEPT 10274684ddb6SLionel Sambuc {__base::store(__d); return __d;} 10284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10294684ddb6SLionel Sambuc _Tp* operator=(_Tp* __d) _NOEXCEPT 10304684ddb6SLionel Sambuc {__base::store(__d); return __d;} 10314684ddb6SLionel Sambuc 10324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10334684ddb6SLionel Sambuc _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 10344684ddb6SLionel Sambuc volatile _NOEXCEPT 10354684ddb6SLionel Sambuc {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 10364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10374684ddb6SLionel Sambuc _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 10384684ddb6SLionel Sambuc {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} 10394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10404684ddb6SLionel Sambuc _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) 10414684ddb6SLionel Sambuc volatile _NOEXCEPT 10424684ddb6SLionel Sambuc {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 10434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10444684ddb6SLionel Sambuc _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT 10454684ddb6SLionel Sambuc {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} 10464684ddb6SLionel Sambuc 10474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10484684ddb6SLionel Sambuc _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} 10494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10504684ddb6SLionel Sambuc _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);} 10514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10524684ddb6SLionel Sambuc _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);} 10534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10544684ddb6SLionel Sambuc _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);} 10554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10564684ddb6SLionel Sambuc _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;} 10574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10584684ddb6SLionel Sambuc _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;} 10594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10604684ddb6SLionel Sambuc _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;} 10614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10624684ddb6SLionel Sambuc _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;} 10634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10644684ddb6SLionel Sambuc _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} 10654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10664684ddb6SLionel Sambuc _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;} 10674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10684684ddb6SLionel Sambuc _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} 10694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10704684ddb6SLionel Sambuc _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} 10714684ddb6SLionel Sambuc}; 10724684ddb6SLionel Sambuc 10734684ddb6SLionel Sambuc// atomic_is_lock_free 10744684ddb6SLionel Sambuc 10754684ddb6SLionel Sambuctemplate <class _Tp> 10764684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10774684ddb6SLionel Sambucbool 10784684ddb6SLionel Sambucatomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT 10794684ddb6SLionel Sambuc{ 10804684ddb6SLionel Sambuc return __o->is_lock_free(); 10814684ddb6SLionel Sambuc} 10824684ddb6SLionel Sambuc 10834684ddb6SLionel Sambuctemplate <class _Tp> 10844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10854684ddb6SLionel Sambucbool 10864684ddb6SLionel Sambucatomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT 10874684ddb6SLionel Sambuc{ 10884684ddb6SLionel Sambuc return __o->is_lock_free(); 10894684ddb6SLionel Sambuc} 10904684ddb6SLionel Sambuc 10914684ddb6SLionel Sambuc// atomic_init 10924684ddb6SLionel Sambuc 10934684ddb6SLionel Sambuctemplate <class _Tp> 10944684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10954684ddb6SLionel Sambucvoid 10964684ddb6SLionel Sambucatomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 10974684ddb6SLionel Sambuc{ 10984684ddb6SLionel Sambuc __c11_atomic_init(&__o->__a_, __d); 10994684ddb6SLionel Sambuc} 11004684ddb6SLionel Sambuc 11014684ddb6SLionel Sambuctemplate <class _Tp> 11024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11034684ddb6SLionel Sambucvoid 11044684ddb6SLionel Sambucatomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 11054684ddb6SLionel Sambuc{ 11064684ddb6SLionel Sambuc __c11_atomic_init(&__o->__a_, __d); 11074684ddb6SLionel Sambuc} 11084684ddb6SLionel Sambuc 11094684ddb6SLionel Sambuc// atomic_store 11104684ddb6SLionel Sambuc 11114684ddb6SLionel Sambuctemplate <class _Tp> 11124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11134684ddb6SLionel Sambucvoid 11144684ddb6SLionel Sambucatomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 11154684ddb6SLionel Sambuc{ 11164684ddb6SLionel Sambuc __o->store(__d); 11174684ddb6SLionel Sambuc} 11184684ddb6SLionel Sambuc 11194684ddb6SLionel Sambuctemplate <class _Tp> 11204684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11214684ddb6SLionel Sambucvoid 11224684ddb6SLionel Sambucatomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 11234684ddb6SLionel Sambuc{ 11244684ddb6SLionel Sambuc __o->store(__d); 11254684ddb6SLionel Sambuc} 11264684ddb6SLionel Sambuc 11274684ddb6SLionel Sambuc// atomic_store_explicit 11284684ddb6SLionel Sambuc 11294684ddb6SLionel Sambuctemplate <class _Tp> 11304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11314684ddb6SLionel Sambucvoid 11324684ddb6SLionel Sambucatomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 11334684ddb6SLionel Sambuc{ 11344684ddb6SLionel Sambuc __o->store(__d, __m); 11354684ddb6SLionel Sambuc} 11364684ddb6SLionel Sambuc 11374684ddb6SLionel Sambuctemplate <class _Tp> 11384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11394684ddb6SLionel Sambucvoid 11404684ddb6SLionel Sambucatomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 11414684ddb6SLionel Sambuc{ 11424684ddb6SLionel Sambuc __o->store(__d, __m); 11434684ddb6SLionel Sambuc} 11444684ddb6SLionel Sambuc 11454684ddb6SLionel Sambuc// atomic_load 11464684ddb6SLionel Sambuc 11474684ddb6SLionel Sambuctemplate <class _Tp> 11484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11494684ddb6SLionel Sambuc_Tp 11504684ddb6SLionel Sambucatomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT 11514684ddb6SLionel Sambuc{ 11524684ddb6SLionel Sambuc return __o->load(); 11534684ddb6SLionel Sambuc} 11544684ddb6SLionel Sambuc 11554684ddb6SLionel Sambuctemplate <class _Tp> 11564684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11574684ddb6SLionel Sambuc_Tp 11584684ddb6SLionel Sambucatomic_load(const atomic<_Tp>* __o) _NOEXCEPT 11594684ddb6SLionel Sambuc{ 11604684ddb6SLionel Sambuc return __o->load(); 11614684ddb6SLionel Sambuc} 11624684ddb6SLionel Sambuc 11634684ddb6SLionel Sambuc// atomic_load_explicit 11644684ddb6SLionel Sambuc 11654684ddb6SLionel Sambuctemplate <class _Tp> 11664684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11674684ddb6SLionel Sambuc_Tp 11684684ddb6SLionel Sambucatomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 11694684ddb6SLionel Sambuc{ 11704684ddb6SLionel Sambuc return __o->load(__m); 11714684ddb6SLionel Sambuc} 11724684ddb6SLionel Sambuc 11734684ddb6SLionel Sambuctemplate <class _Tp> 11744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11754684ddb6SLionel Sambuc_Tp 11764684ddb6SLionel Sambucatomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT 11774684ddb6SLionel Sambuc{ 11784684ddb6SLionel Sambuc return __o->load(__m); 11794684ddb6SLionel Sambuc} 11804684ddb6SLionel Sambuc 11814684ddb6SLionel Sambuc// atomic_exchange 11824684ddb6SLionel Sambuc 11834684ddb6SLionel Sambuctemplate <class _Tp> 11844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11854684ddb6SLionel Sambuc_Tp 11864684ddb6SLionel Sambucatomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 11874684ddb6SLionel Sambuc{ 11884684ddb6SLionel Sambuc return __o->exchange(__d); 11894684ddb6SLionel Sambuc} 11904684ddb6SLionel Sambuc 11914684ddb6SLionel Sambuctemplate <class _Tp> 11924684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11934684ddb6SLionel Sambuc_Tp 11944684ddb6SLionel Sambucatomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT 11954684ddb6SLionel Sambuc{ 11964684ddb6SLionel Sambuc return __o->exchange(__d); 11974684ddb6SLionel Sambuc} 11984684ddb6SLionel Sambuc 11994684ddb6SLionel Sambuc// atomic_exchange_explicit 12004684ddb6SLionel Sambuc 12014684ddb6SLionel Sambuctemplate <class _Tp> 12024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12034684ddb6SLionel Sambuc_Tp 12044684ddb6SLionel Sambucatomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 12054684ddb6SLionel Sambuc{ 12064684ddb6SLionel Sambuc return __o->exchange(__d, __m); 12074684ddb6SLionel Sambuc} 12084684ddb6SLionel Sambuc 12094684ddb6SLionel Sambuctemplate <class _Tp> 12104684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12114684ddb6SLionel Sambuc_Tp 12124684ddb6SLionel Sambucatomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT 12134684ddb6SLionel Sambuc{ 12144684ddb6SLionel Sambuc return __o->exchange(__d, __m); 12154684ddb6SLionel Sambuc} 12164684ddb6SLionel Sambuc 12174684ddb6SLionel Sambuc// atomic_compare_exchange_weak 12184684ddb6SLionel Sambuc 12194684ddb6SLionel Sambuctemplate <class _Tp> 12204684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12214684ddb6SLionel Sambucbool 12224684ddb6SLionel Sambucatomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 12234684ddb6SLionel Sambuc{ 12244684ddb6SLionel Sambuc return __o->compare_exchange_weak(*__e, __d); 12254684ddb6SLionel Sambuc} 12264684ddb6SLionel Sambuc 12274684ddb6SLionel Sambuctemplate <class _Tp> 12284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12294684ddb6SLionel Sambucbool 12304684ddb6SLionel Sambucatomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 12314684ddb6SLionel Sambuc{ 12324684ddb6SLionel Sambuc return __o->compare_exchange_weak(*__e, __d); 12334684ddb6SLionel Sambuc} 12344684ddb6SLionel Sambuc 12354684ddb6SLionel Sambuc// atomic_compare_exchange_strong 12364684ddb6SLionel Sambuc 12374684ddb6SLionel Sambuctemplate <class _Tp> 12384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12394684ddb6SLionel Sambucbool 12404684ddb6SLionel Sambucatomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 12414684ddb6SLionel Sambuc{ 12424684ddb6SLionel Sambuc return __o->compare_exchange_strong(*__e, __d); 12434684ddb6SLionel Sambuc} 12444684ddb6SLionel Sambuc 12454684ddb6SLionel Sambuctemplate <class _Tp> 12464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12474684ddb6SLionel Sambucbool 12484684ddb6SLionel Sambucatomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT 12494684ddb6SLionel Sambuc{ 12504684ddb6SLionel Sambuc return __o->compare_exchange_strong(*__e, __d); 12514684ddb6SLionel Sambuc} 12524684ddb6SLionel Sambuc 12534684ddb6SLionel Sambuc// atomic_compare_exchange_weak_explicit 12544684ddb6SLionel Sambuc 12554684ddb6SLionel Sambuctemplate <class _Tp> 12564684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12574684ddb6SLionel Sambucbool 12584684ddb6SLionel Sambucatomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, 12594684ddb6SLionel Sambuc _Tp __d, 12604684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 12614684ddb6SLionel Sambuc{ 12624684ddb6SLionel Sambuc return __o->compare_exchange_weak(*__e, __d, __s, __f); 12634684ddb6SLionel Sambuc} 12644684ddb6SLionel Sambuc 12654684ddb6SLionel Sambuctemplate <class _Tp> 12664684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12674684ddb6SLionel Sambucbool 12684684ddb6SLionel Sambucatomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, 12694684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 12704684ddb6SLionel Sambuc{ 12714684ddb6SLionel Sambuc return __o->compare_exchange_weak(*__e, __d, __s, __f); 12724684ddb6SLionel Sambuc} 12734684ddb6SLionel Sambuc 12744684ddb6SLionel Sambuc// atomic_compare_exchange_strong_explicit 12754684ddb6SLionel Sambuc 12764684ddb6SLionel Sambuctemplate <class _Tp> 12774684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12784684ddb6SLionel Sambucbool 12794684ddb6SLionel Sambucatomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, 12804684ddb6SLionel Sambuc _Tp* __e, _Tp __d, 12814684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 12824684ddb6SLionel Sambuc{ 12834684ddb6SLionel Sambuc return __o->compare_exchange_strong(*__e, __d, __s, __f); 12844684ddb6SLionel Sambuc} 12854684ddb6SLionel Sambuc 12864684ddb6SLionel Sambuctemplate <class _Tp> 12874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 12884684ddb6SLionel Sambucbool 12894684ddb6SLionel Sambucatomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, 12904684ddb6SLionel Sambuc _Tp __d, 12914684ddb6SLionel Sambuc memory_order __s, memory_order __f) _NOEXCEPT 12924684ddb6SLionel Sambuc{ 12934684ddb6SLionel Sambuc return __o->compare_exchange_strong(*__e, __d, __s, __f); 12944684ddb6SLionel Sambuc} 12954684ddb6SLionel Sambuc 12964684ddb6SLionel Sambuc// atomic_fetch_add 12974684ddb6SLionel Sambuc 12984684ddb6SLionel Sambuctemplate <class _Tp> 12994684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13004684ddb6SLionel Sambuctypename enable_if 13014684ddb6SLionel Sambuc< 13024684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 13034684ddb6SLionel Sambuc _Tp 13044684ddb6SLionel Sambuc>::type 13054684ddb6SLionel Sambucatomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 13064684ddb6SLionel Sambuc{ 13074684ddb6SLionel Sambuc return __o->fetch_add(__op); 13084684ddb6SLionel Sambuc} 13094684ddb6SLionel Sambuc 13104684ddb6SLionel Sambuctemplate <class _Tp> 13114684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13124684ddb6SLionel Sambuctypename enable_if 13134684ddb6SLionel Sambuc< 13144684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 13154684ddb6SLionel Sambuc _Tp 13164684ddb6SLionel Sambuc>::type 13174684ddb6SLionel Sambucatomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 13184684ddb6SLionel Sambuc{ 13194684ddb6SLionel Sambuc return __o->fetch_add(__op); 13204684ddb6SLionel Sambuc} 13214684ddb6SLionel Sambuc 13224684ddb6SLionel Sambuctemplate <class _Tp> 13234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13244684ddb6SLionel Sambuc_Tp* 13254684ddb6SLionel Sambucatomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 13264684ddb6SLionel Sambuc{ 13274684ddb6SLionel Sambuc return __o->fetch_add(__op); 13284684ddb6SLionel Sambuc} 13294684ddb6SLionel Sambuc 13304684ddb6SLionel Sambuctemplate <class _Tp> 13314684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13324684ddb6SLionel Sambuc_Tp* 13334684ddb6SLionel Sambucatomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 13344684ddb6SLionel Sambuc{ 13354684ddb6SLionel Sambuc return __o->fetch_add(__op); 13364684ddb6SLionel Sambuc} 13374684ddb6SLionel Sambuc 13384684ddb6SLionel Sambuc// atomic_fetch_add_explicit 13394684ddb6SLionel Sambuc 13404684ddb6SLionel Sambuctemplate <class _Tp> 13414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13424684ddb6SLionel Sambuctypename enable_if 13434684ddb6SLionel Sambuc< 13444684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 13454684ddb6SLionel Sambuc _Tp 13464684ddb6SLionel Sambuc>::type 13474684ddb6SLionel Sambucatomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 13484684ddb6SLionel Sambuc{ 13494684ddb6SLionel Sambuc return __o->fetch_add(__op, __m); 13504684ddb6SLionel Sambuc} 13514684ddb6SLionel Sambuc 13524684ddb6SLionel Sambuctemplate <class _Tp> 13534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13544684ddb6SLionel Sambuctypename enable_if 13554684ddb6SLionel Sambuc< 13564684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 13574684ddb6SLionel Sambuc _Tp 13584684ddb6SLionel Sambuc>::type 13594684ddb6SLionel Sambucatomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 13604684ddb6SLionel Sambuc{ 13614684ddb6SLionel Sambuc return __o->fetch_add(__op, __m); 13624684ddb6SLionel Sambuc} 13634684ddb6SLionel Sambuc 13644684ddb6SLionel Sambuctemplate <class _Tp> 13654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13664684ddb6SLionel Sambuc_Tp* 13674684ddb6SLionel Sambucatomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 13684684ddb6SLionel Sambuc memory_order __m) _NOEXCEPT 13694684ddb6SLionel Sambuc{ 13704684ddb6SLionel Sambuc return __o->fetch_add(__op, __m); 13714684ddb6SLionel Sambuc} 13724684ddb6SLionel Sambuc 13734684ddb6SLionel Sambuctemplate <class _Tp> 13744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13754684ddb6SLionel Sambuc_Tp* 13764684ddb6SLionel Sambucatomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 13774684ddb6SLionel Sambuc{ 13784684ddb6SLionel Sambuc return __o->fetch_add(__op, __m); 13794684ddb6SLionel Sambuc} 13804684ddb6SLionel Sambuc 13814684ddb6SLionel Sambuc// atomic_fetch_sub 13824684ddb6SLionel Sambuc 13834684ddb6SLionel Sambuctemplate <class _Tp> 13844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13854684ddb6SLionel Sambuctypename enable_if 13864684ddb6SLionel Sambuc< 13874684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 13884684ddb6SLionel Sambuc _Tp 13894684ddb6SLionel Sambuc>::type 13904684ddb6SLionel Sambucatomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 13914684ddb6SLionel Sambuc{ 13924684ddb6SLionel Sambuc return __o->fetch_sub(__op); 13934684ddb6SLionel Sambuc} 13944684ddb6SLionel Sambuc 13954684ddb6SLionel Sambuctemplate <class _Tp> 13964684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 13974684ddb6SLionel Sambuctypename enable_if 13984684ddb6SLionel Sambuc< 13994684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14004684ddb6SLionel Sambuc _Tp 14014684ddb6SLionel Sambuc>::type 14024684ddb6SLionel Sambucatomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 14034684ddb6SLionel Sambuc{ 14044684ddb6SLionel Sambuc return __o->fetch_sub(__op); 14054684ddb6SLionel Sambuc} 14064684ddb6SLionel Sambuc 14074684ddb6SLionel Sambuctemplate <class _Tp> 14084684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14094684ddb6SLionel Sambuc_Tp* 14104684ddb6SLionel Sambucatomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 14114684ddb6SLionel Sambuc{ 14124684ddb6SLionel Sambuc return __o->fetch_sub(__op); 14134684ddb6SLionel Sambuc} 14144684ddb6SLionel Sambuc 14154684ddb6SLionel Sambuctemplate <class _Tp> 14164684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14174684ddb6SLionel Sambuc_Tp* 14184684ddb6SLionel Sambucatomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT 14194684ddb6SLionel Sambuc{ 14204684ddb6SLionel Sambuc return __o->fetch_sub(__op); 14214684ddb6SLionel Sambuc} 14224684ddb6SLionel Sambuc 14234684ddb6SLionel Sambuc// atomic_fetch_sub_explicit 14244684ddb6SLionel Sambuc 14254684ddb6SLionel Sambuctemplate <class _Tp> 14264684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14274684ddb6SLionel Sambuctypename enable_if 14284684ddb6SLionel Sambuc< 14294684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14304684ddb6SLionel Sambuc _Tp 14314684ddb6SLionel Sambuc>::type 14324684ddb6SLionel Sambucatomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 14334684ddb6SLionel Sambuc{ 14344684ddb6SLionel Sambuc return __o->fetch_sub(__op, __m); 14354684ddb6SLionel Sambuc} 14364684ddb6SLionel Sambuc 14374684ddb6SLionel Sambuctemplate <class _Tp> 14384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14394684ddb6SLionel Sambuctypename enable_if 14404684ddb6SLionel Sambuc< 14414684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14424684ddb6SLionel Sambuc _Tp 14434684ddb6SLionel Sambuc>::type 14444684ddb6SLionel Sambucatomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 14454684ddb6SLionel Sambuc{ 14464684ddb6SLionel Sambuc return __o->fetch_sub(__op, __m); 14474684ddb6SLionel Sambuc} 14484684ddb6SLionel Sambuc 14494684ddb6SLionel Sambuctemplate <class _Tp> 14504684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14514684ddb6SLionel Sambuc_Tp* 14524684ddb6SLionel Sambucatomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op, 14534684ddb6SLionel Sambuc memory_order __m) _NOEXCEPT 14544684ddb6SLionel Sambuc{ 14554684ddb6SLionel Sambuc return __o->fetch_sub(__op, __m); 14564684ddb6SLionel Sambuc} 14574684ddb6SLionel Sambuc 14584684ddb6SLionel Sambuctemplate <class _Tp> 14594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14604684ddb6SLionel Sambuc_Tp* 14614684ddb6SLionel Sambucatomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT 14624684ddb6SLionel Sambuc{ 14634684ddb6SLionel Sambuc return __o->fetch_sub(__op, __m); 14644684ddb6SLionel Sambuc} 14654684ddb6SLionel Sambuc 14664684ddb6SLionel Sambuc// atomic_fetch_and 14674684ddb6SLionel Sambuc 14684684ddb6SLionel Sambuctemplate <class _Tp> 14694684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14704684ddb6SLionel Sambuctypename enable_if 14714684ddb6SLionel Sambuc< 14724684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14734684ddb6SLionel Sambuc _Tp 14744684ddb6SLionel Sambuc>::type 14754684ddb6SLionel Sambucatomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 14764684ddb6SLionel Sambuc{ 14774684ddb6SLionel Sambuc return __o->fetch_and(__op); 14784684ddb6SLionel Sambuc} 14794684ddb6SLionel Sambuc 14804684ddb6SLionel Sambuctemplate <class _Tp> 14814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14824684ddb6SLionel Sambuctypename enable_if 14834684ddb6SLionel Sambuc< 14844684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14854684ddb6SLionel Sambuc _Tp 14864684ddb6SLionel Sambuc>::type 14874684ddb6SLionel Sambucatomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 14884684ddb6SLionel Sambuc{ 14894684ddb6SLionel Sambuc return __o->fetch_and(__op); 14904684ddb6SLionel Sambuc} 14914684ddb6SLionel Sambuc 14924684ddb6SLionel Sambuc// atomic_fetch_and_explicit 14934684ddb6SLionel Sambuc 14944684ddb6SLionel Sambuctemplate <class _Tp> 14954684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14964684ddb6SLionel Sambuctypename enable_if 14974684ddb6SLionel Sambuc< 14984684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 14994684ddb6SLionel Sambuc _Tp 15004684ddb6SLionel Sambuc>::type 15014684ddb6SLionel Sambucatomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 15024684ddb6SLionel Sambuc{ 15034684ddb6SLionel Sambuc return __o->fetch_and(__op, __m); 15044684ddb6SLionel Sambuc} 15054684ddb6SLionel Sambuc 15064684ddb6SLionel Sambuctemplate <class _Tp> 15074684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15084684ddb6SLionel Sambuctypename enable_if 15094684ddb6SLionel Sambuc< 15104684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15114684ddb6SLionel Sambuc _Tp 15124684ddb6SLionel Sambuc>::type 15134684ddb6SLionel Sambucatomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 15144684ddb6SLionel Sambuc{ 15154684ddb6SLionel Sambuc return __o->fetch_and(__op, __m); 15164684ddb6SLionel Sambuc} 15174684ddb6SLionel Sambuc 15184684ddb6SLionel Sambuc// atomic_fetch_or 15194684ddb6SLionel Sambuc 15204684ddb6SLionel Sambuctemplate <class _Tp> 15214684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15224684ddb6SLionel Sambuctypename enable_if 15234684ddb6SLionel Sambuc< 15244684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15254684ddb6SLionel Sambuc _Tp 15264684ddb6SLionel Sambuc>::type 15274684ddb6SLionel Sambucatomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 15284684ddb6SLionel Sambuc{ 15294684ddb6SLionel Sambuc return __o->fetch_or(__op); 15304684ddb6SLionel Sambuc} 15314684ddb6SLionel Sambuc 15324684ddb6SLionel Sambuctemplate <class _Tp> 15334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15344684ddb6SLionel Sambuctypename enable_if 15354684ddb6SLionel Sambuc< 15364684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15374684ddb6SLionel Sambuc _Tp 15384684ddb6SLionel Sambuc>::type 15394684ddb6SLionel Sambucatomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 15404684ddb6SLionel Sambuc{ 15414684ddb6SLionel Sambuc return __o->fetch_or(__op); 15424684ddb6SLionel Sambuc} 15434684ddb6SLionel Sambuc 15444684ddb6SLionel Sambuc// atomic_fetch_or_explicit 15454684ddb6SLionel Sambuc 15464684ddb6SLionel Sambuctemplate <class _Tp> 15474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15484684ddb6SLionel Sambuctypename enable_if 15494684ddb6SLionel Sambuc< 15504684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15514684ddb6SLionel Sambuc _Tp 15524684ddb6SLionel Sambuc>::type 15534684ddb6SLionel Sambucatomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 15544684ddb6SLionel Sambuc{ 15554684ddb6SLionel Sambuc return __o->fetch_or(__op, __m); 15564684ddb6SLionel Sambuc} 15574684ddb6SLionel Sambuc 15584684ddb6SLionel Sambuctemplate <class _Tp> 15594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15604684ddb6SLionel Sambuctypename enable_if 15614684ddb6SLionel Sambuc< 15624684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15634684ddb6SLionel Sambuc _Tp 15644684ddb6SLionel Sambuc>::type 15654684ddb6SLionel Sambucatomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 15664684ddb6SLionel Sambuc{ 15674684ddb6SLionel Sambuc return __o->fetch_or(__op, __m); 15684684ddb6SLionel Sambuc} 15694684ddb6SLionel Sambuc 15704684ddb6SLionel Sambuc// atomic_fetch_xor 15714684ddb6SLionel Sambuc 15724684ddb6SLionel Sambuctemplate <class _Tp> 15734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15744684ddb6SLionel Sambuctypename enable_if 15754684ddb6SLionel Sambuc< 15764684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15774684ddb6SLionel Sambuc _Tp 15784684ddb6SLionel Sambuc>::type 15794684ddb6SLionel Sambucatomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 15804684ddb6SLionel Sambuc{ 15814684ddb6SLionel Sambuc return __o->fetch_xor(__op); 15824684ddb6SLionel Sambuc} 15834684ddb6SLionel Sambuc 15844684ddb6SLionel Sambuctemplate <class _Tp> 15854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15864684ddb6SLionel Sambuctypename enable_if 15874684ddb6SLionel Sambuc< 15884684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 15894684ddb6SLionel Sambuc _Tp 15904684ddb6SLionel Sambuc>::type 15914684ddb6SLionel Sambucatomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT 15924684ddb6SLionel Sambuc{ 15934684ddb6SLionel Sambuc return __o->fetch_xor(__op); 15944684ddb6SLionel Sambuc} 15954684ddb6SLionel Sambuc 15964684ddb6SLionel Sambuc// atomic_fetch_xor_explicit 15974684ddb6SLionel Sambuc 15984684ddb6SLionel Sambuctemplate <class _Tp> 15994684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16004684ddb6SLionel Sambuctypename enable_if 16014684ddb6SLionel Sambuc< 16024684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 16034684ddb6SLionel Sambuc _Tp 16044684ddb6SLionel Sambuc>::type 16054684ddb6SLionel Sambucatomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 16064684ddb6SLionel Sambuc{ 16074684ddb6SLionel Sambuc return __o->fetch_xor(__op, __m); 16084684ddb6SLionel Sambuc} 16094684ddb6SLionel Sambuc 16104684ddb6SLionel Sambuctemplate <class _Tp> 16114684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16124684ddb6SLionel Sambuctypename enable_if 16134684ddb6SLionel Sambuc< 16144684ddb6SLionel Sambuc is_integral<_Tp>::value && !is_same<_Tp, bool>::value, 16154684ddb6SLionel Sambuc _Tp 16164684ddb6SLionel Sambuc>::type 16174684ddb6SLionel Sambucatomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT 16184684ddb6SLionel Sambuc{ 16194684ddb6SLionel Sambuc return __o->fetch_xor(__op, __m); 16204684ddb6SLionel Sambuc} 16214684ddb6SLionel Sambuc 16224684ddb6SLionel Sambuc// flag type and operations 16234684ddb6SLionel Sambuc 16244684ddb6SLionel Sambuctypedef struct atomic_flag 16254684ddb6SLionel Sambuc{ 16264684ddb6SLionel Sambuc _Atomic(bool) __a_; 16274684ddb6SLionel Sambuc 16284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16294684ddb6SLionel Sambuc bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 16304684ddb6SLionel Sambuc {return __c11_atomic_exchange(&__a_, true, __m);} 16314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16324684ddb6SLionel Sambuc bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT 16334684ddb6SLionel Sambuc {return __c11_atomic_exchange(&__a_, true, __m);} 16344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16354684ddb6SLionel Sambuc void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT 16364684ddb6SLionel Sambuc {__c11_atomic_store(&__a_, false, __m);} 16374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16384684ddb6SLionel Sambuc void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT 16394684ddb6SLionel Sambuc {__c11_atomic_store(&__a_, false, __m);} 16404684ddb6SLionel Sambuc 16414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16424684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 16434684ddb6SLionel Sambuc atomic_flag() _NOEXCEPT = default; 16444684ddb6SLionel Sambuc#else 16454684ddb6SLionel Sambuc atomic_flag() _NOEXCEPT : __a_() {} 16464684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 16474684ddb6SLionel Sambuc 16484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16494684ddb6SLionel Sambuc atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} 16504684ddb6SLionel Sambuc 16514684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 16524684ddb6SLionel Sambuc atomic_flag(const atomic_flag&) = delete; 16534684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&) = delete; 16544684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&) volatile = delete; 16554684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 16564684ddb6SLionel Sambucprivate: 16574684ddb6SLionel Sambuc atomic_flag(const atomic_flag&); 16584684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&); 16594684ddb6SLionel Sambuc atomic_flag& operator=(const atomic_flag&) volatile; 16604684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS 16614684ddb6SLionel Sambuc} atomic_flag; 16624684ddb6SLionel Sambuc 16634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16644684ddb6SLionel Sambucbool 16654684ddb6SLionel Sambucatomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT 16664684ddb6SLionel Sambuc{ 16674684ddb6SLionel Sambuc return __o->test_and_set(); 16684684ddb6SLionel Sambuc} 16694684ddb6SLionel Sambuc 16704684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16714684ddb6SLionel Sambucbool 16724684ddb6SLionel Sambucatomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT 16734684ddb6SLionel Sambuc{ 16744684ddb6SLionel Sambuc return __o->test_and_set(); 16754684ddb6SLionel Sambuc} 16764684ddb6SLionel Sambuc 16774684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16784684ddb6SLionel Sambucbool 16794684ddb6SLionel Sambucatomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 16804684ddb6SLionel Sambuc{ 16814684ddb6SLionel Sambuc return __o->test_and_set(__m); 16824684ddb6SLionel Sambuc} 16834684ddb6SLionel Sambuc 16844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16854684ddb6SLionel Sambucbool 16864684ddb6SLionel Sambucatomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 16874684ddb6SLionel Sambuc{ 16884684ddb6SLionel Sambuc return __o->test_and_set(__m); 16894684ddb6SLionel Sambuc} 16904684ddb6SLionel Sambuc 16914684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16924684ddb6SLionel Sambucvoid 16934684ddb6SLionel Sambucatomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT 16944684ddb6SLionel Sambuc{ 16954684ddb6SLionel Sambuc __o->clear(); 16964684ddb6SLionel Sambuc} 16974684ddb6SLionel Sambuc 16984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16994684ddb6SLionel Sambucvoid 17004684ddb6SLionel Sambucatomic_flag_clear(atomic_flag* __o) _NOEXCEPT 17014684ddb6SLionel Sambuc{ 17024684ddb6SLionel Sambuc __o->clear(); 17034684ddb6SLionel Sambuc} 17044684ddb6SLionel Sambuc 17054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 17064684ddb6SLionel Sambucvoid 17074684ddb6SLionel Sambucatomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT 17084684ddb6SLionel Sambuc{ 17094684ddb6SLionel Sambuc __o->clear(__m); 17104684ddb6SLionel Sambuc} 17114684ddb6SLionel Sambuc 17124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 17134684ddb6SLionel Sambucvoid 17144684ddb6SLionel Sambucatomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT 17154684ddb6SLionel Sambuc{ 17164684ddb6SLionel Sambuc __o->clear(__m); 17174684ddb6SLionel Sambuc} 17184684ddb6SLionel Sambuc 17194684ddb6SLionel Sambuc// fences 17204684ddb6SLionel Sambuc 17214684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 17224684ddb6SLionel Sambucvoid 17234684ddb6SLionel Sambucatomic_thread_fence(memory_order __m) _NOEXCEPT 17244684ddb6SLionel Sambuc{ 17254684ddb6SLionel Sambuc __c11_atomic_thread_fence(__m); 17264684ddb6SLionel Sambuc} 17274684ddb6SLionel Sambuc 17284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 17294684ddb6SLionel Sambucvoid 17304684ddb6SLionel Sambucatomic_signal_fence(memory_order __m) _NOEXCEPT 17314684ddb6SLionel Sambuc{ 17324684ddb6SLionel Sambuc __c11_atomic_signal_fence(__m); 17334684ddb6SLionel Sambuc} 17344684ddb6SLionel Sambuc 17354684ddb6SLionel Sambuc// Atomics for standard typedef types 17364684ddb6SLionel Sambuc 17374684ddb6SLionel Sambuctypedef atomic<bool> atomic_bool; 17384684ddb6SLionel Sambuctypedef atomic<char> atomic_char; 17394684ddb6SLionel Sambuctypedef atomic<signed char> atomic_schar; 17404684ddb6SLionel Sambuctypedef atomic<unsigned char> atomic_uchar; 17414684ddb6SLionel Sambuctypedef atomic<short> atomic_short; 17424684ddb6SLionel Sambuctypedef atomic<unsigned short> atomic_ushort; 17434684ddb6SLionel Sambuctypedef atomic<int> atomic_int; 17444684ddb6SLionel Sambuctypedef atomic<unsigned int> atomic_uint; 17454684ddb6SLionel Sambuctypedef atomic<long> atomic_long; 17464684ddb6SLionel Sambuctypedef atomic<unsigned long> atomic_ulong; 17474684ddb6SLionel Sambuctypedef atomic<long long> atomic_llong; 17484684ddb6SLionel Sambuctypedef atomic<unsigned long long> atomic_ullong; 17494684ddb6SLionel Sambuctypedef atomic<char16_t> atomic_char16_t; 17504684ddb6SLionel Sambuctypedef atomic<char32_t> atomic_char32_t; 17514684ddb6SLionel Sambuctypedef atomic<wchar_t> atomic_wchar_t; 17524684ddb6SLionel Sambuc 17534684ddb6SLionel Sambuctypedef atomic<int_least8_t> atomic_int_least8_t; 17544684ddb6SLionel Sambuctypedef atomic<uint_least8_t> atomic_uint_least8_t; 17554684ddb6SLionel Sambuctypedef atomic<int_least16_t> atomic_int_least16_t; 17564684ddb6SLionel Sambuctypedef atomic<uint_least16_t> atomic_uint_least16_t; 17574684ddb6SLionel Sambuctypedef atomic<int_least32_t> atomic_int_least32_t; 17584684ddb6SLionel Sambuctypedef atomic<uint_least32_t> atomic_uint_least32_t; 17594684ddb6SLionel Sambuctypedef atomic<int_least64_t> atomic_int_least64_t; 17604684ddb6SLionel Sambuctypedef atomic<uint_least64_t> atomic_uint_least64_t; 17614684ddb6SLionel Sambuc 17624684ddb6SLionel Sambuctypedef atomic<int_fast8_t> atomic_int_fast8_t; 17634684ddb6SLionel Sambuctypedef atomic<uint_fast8_t> atomic_uint_fast8_t; 17644684ddb6SLionel Sambuctypedef atomic<int_fast16_t> atomic_int_fast16_t; 17654684ddb6SLionel Sambuctypedef atomic<uint_fast16_t> atomic_uint_fast16_t; 17664684ddb6SLionel Sambuctypedef atomic<int_fast32_t> atomic_int_fast32_t; 17674684ddb6SLionel Sambuctypedef atomic<uint_fast32_t> atomic_uint_fast32_t; 17684684ddb6SLionel Sambuctypedef atomic<int_fast64_t> atomic_int_fast64_t; 17694684ddb6SLionel Sambuctypedef atomic<uint_fast64_t> atomic_uint_fast64_t; 17704684ddb6SLionel Sambuc 17714684ddb6SLionel Sambuctypedef atomic<intptr_t> atomic_intptr_t; 17724684ddb6SLionel Sambuctypedef atomic<uintptr_t> atomic_uintptr_t; 17734684ddb6SLionel Sambuctypedef atomic<size_t> atomic_size_t; 17744684ddb6SLionel Sambuctypedef atomic<ptrdiff_t> atomic_ptrdiff_t; 17754684ddb6SLionel Sambuctypedef atomic<intmax_t> atomic_intmax_t; 17764684ddb6SLionel Sambuctypedef atomic<uintmax_t> atomic_uintmax_t; 17774684ddb6SLionel Sambuc 17784684ddb6SLionel Sambuc#define ATOMIC_FLAG_INIT {false} 17794684ddb6SLionel Sambuc#define ATOMIC_VAR_INIT(__v) {__v} 17804684ddb6SLionel Sambuc 17814684ddb6SLionel Sambuc#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE 17824684ddb6SLionel Sambuc#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE 17834684ddb6SLionel Sambuc#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE 17844684ddb6SLionel Sambuc#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE 17854684ddb6SLionel Sambuc#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE 17864684ddb6SLionel Sambuc#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE 17874684ddb6SLionel Sambuc#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE 17884684ddb6SLionel Sambuc#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE 17894684ddb6SLionel Sambuc#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE 17904684ddb6SLionel Sambuc#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE 17914684ddb6SLionel Sambuc 17924684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 17934684ddb6SLionel Sambuc 17944684ddb6SLionel Sambuc#endif // _LIBCPP_ATOMIC 1795