12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865 |
- // -*- C++ -*-
- //===--------------------------- atomic -----------------------------------===//
- //
- // The LLVM Compiler Infrastructure
- //
- // This file is distributed under the University of Illinois Open Source
- // License. See LICENSE.TXT for details.
- //
- //===----------------------------------------------------------------------===//
- #ifndef _LIBCPP_ATOMIC
- #define _LIBCPP_ATOMIC
- /*
- atomic synopsis
- namespace std
- {
- // feature test macro
- #define __cpp_lib_atomic_is_always_lock_free // as specified by SG10
- // order and consistency
- typedef enum memory_order
- {
- memory_order_relaxed,
- memory_order_consume, // load-consume
- memory_order_acquire, // load-acquire
- memory_order_release, // store-release
- memory_order_acq_rel, // store-release load-acquire
- memory_order_seq_cst // store-release load-acquire
- } memory_order;
- template <class T> T kill_dependency(T y) noexcept;
- // lock-free property
- #define ATOMIC_BOOL_LOCK_FREE unspecified
- #define ATOMIC_CHAR_LOCK_FREE unspecified
- #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
- #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
- #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
- #define ATOMIC_SHORT_LOCK_FREE unspecified
- #define ATOMIC_INT_LOCK_FREE unspecified
- #define ATOMIC_LONG_LOCK_FREE unspecified
- #define ATOMIC_LLONG_LOCK_FREE unspecified
- #define ATOMIC_POINTER_LOCK_FREE unspecified
- // flag type and operations
- typedef struct atomic_flag
- {
- bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
- bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
- void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
- void clear(memory_order m = memory_order_seq_cst) noexcept;
- atomic_flag() noexcept = default;
- atomic_flag(const atomic_flag&) = delete;
- atomic_flag& operator=(const atomic_flag&) = delete;
- atomic_flag& operator=(const atomic_flag&) volatile = delete;
- } atomic_flag;
- bool
- atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
- bool
- atomic_flag_test_and_set(atomic_flag* obj) noexcept;
- bool
- atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
- memory_order m) noexcept;
- bool
- atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
- void
- atomic_flag_clear(volatile atomic_flag* obj) noexcept;
- void
- atomic_flag_clear(atomic_flag* obj) noexcept;
- void
- atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
- void
- atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
- #define ATOMIC_FLAG_INIT see below
- #define ATOMIC_VAR_INIT(value) see below
- template <class T>
- struct atomic
- {
- static constexpr bool is_always_lock_free;
- bool is_lock_free() const volatile noexcept;
- bool is_lock_free() const noexcept;
- void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
- void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
- T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
- T load(memory_order m = memory_order_seq_cst) const noexcept;
- operator T() const volatile noexcept;
- operator T() const noexcept;
- T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
- T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_weak(T& expc, T desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
- bool compare_exchange_strong(T& expc, T desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_strong(T& expc, T desr,
- memory_order s, memory_order f) noexcept;
- bool compare_exchange_weak(T& expc, T desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_weak(T& expc, T desr,
- memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_strong(T& expc, T desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_strong(T& expc, T desr,
- memory_order m = memory_order_seq_cst) noexcept;
- atomic() noexcept = default;
- constexpr atomic(T desr) noexcept;
- atomic(const atomic&) = delete;
- atomic& operator=(const atomic&) = delete;
- atomic& operator=(const atomic&) volatile = delete;
- T operator=(T) volatile noexcept;
- T operator=(T) noexcept;
- };
- template <>
- struct atomic<integral>
- {
- static constexpr bool is_always_lock_free;
- bool is_lock_free() const volatile noexcept;
- bool is_lock_free() const noexcept;
- void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
- void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
- integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
- integral load(memory_order m = memory_order_seq_cst) const noexcept;
- operator integral() const volatile noexcept;
- operator integral() const noexcept;
- integral exchange(integral desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_weak(integral& expc, integral desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_weak(integral& expc, integral desr,
- memory_order s, memory_order f) noexcept;
- bool compare_exchange_strong(integral& expc, integral desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_strong(integral& expc, integral desr,
- memory_order s, memory_order f) noexcept;
- bool compare_exchange_weak(integral& expc, integral desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_weak(integral& expc, integral desr,
- memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_strong(integral& expc, integral desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_strong(integral& expc, integral desr,
- memory_order m = memory_order_seq_cst) noexcept;
- integral
- fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
- integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
- integral
- fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
- integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
- integral
- fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
- integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
- integral
- fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
- integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
- integral
- fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
- integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
- atomic() noexcept = default;
- constexpr atomic(integral desr) noexcept;
- atomic(const atomic&) = delete;
- atomic& operator=(const atomic&) = delete;
- atomic& operator=(const atomic&) volatile = delete;
- integral operator=(integral desr) volatile noexcept;
- integral operator=(integral desr) noexcept;
- integral operator++(int) volatile noexcept;
- integral operator++(int) noexcept;
- integral operator--(int) volatile noexcept;
- integral operator--(int) noexcept;
- integral operator++() volatile noexcept;
- integral operator++() noexcept;
- integral operator--() volatile noexcept;
- integral operator--() noexcept;
- integral operator+=(integral op) volatile noexcept;
- integral operator+=(integral op) noexcept;
- integral operator-=(integral op) volatile noexcept;
- integral operator-=(integral op) noexcept;
- integral operator&=(integral op) volatile noexcept;
- integral operator&=(integral op) noexcept;
- integral operator|=(integral op) volatile noexcept;
- integral operator|=(integral op) noexcept;
- integral operator^=(integral op) volatile noexcept;
- integral operator^=(integral op) noexcept;
- };
- template <class T>
- struct atomic<T*>
- {
- static constexpr bool is_always_lock_free;
- bool is_lock_free() const volatile noexcept;
- bool is_lock_free() const noexcept;
- void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
- void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
- T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
- T* load(memory_order m = memory_order_seq_cst) const noexcept;
- operator T*() const volatile noexcept;
- operator T*() const noexcept;
- T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
- T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_weak(T*& expc, T* desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_weak(T*& expc, T* desr,
- memory_order s, memory_order f) noexcept;
- bool compare_exchange_strong(T*& expc, T* desr,
- memory_order s, memory_order f) volatile noexcept;
- bool compare_exchange_strong(T*& expc, T* desr,
- memory_order s, memory_order f) noexcept;
- bool compare_exchange_weak(T*& expc, T* desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_weak(T*& expc, T* desr,
- memory_order m = memory_order_seq_cst) noexcept;
- bool compare_exchange_strong(T*& expc, T* desr,
- memory_order m = memory_order_seq_cst) volatile noexcept;
- bool compare_exchange_strong(T*& expc, T* desr,
- memory_order m = memory_order_seq_cst) noexcept;
- T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
- T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
- T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
- T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
- atomic() noexcept = default;
- constexpr atomic(T* desr) noexcept;
- atomic(const atomic&) = delete;
- atomic& operator=(const atomic&) = delete;
- atomic& operator=(const atomic&) volatile = delete;
- T* operator=(T*) volatile noexcept;
- T* operator=(T*) noexcept;
- T* operator++(int) volatile noexcept;
- T* operator++(int) noexcept;
- T* operator--(int) volatile noexcept;
- T* operator--(int) noexcept;
- T* operator++() volatile noexcept;
- T* operator++() noexcept;
- T* operator--() volatile noexcept;
- T* operator--() noexcept;
- T* operator+=(ptrdiff_t op) volatile noexcept;
- T* operator+=(ptrdiff_t op) noexcept;
- T* operator-=(ptrdiff_t op) volatile noexcept;
- T* operator-=(ptrdiff_t op) noexcept;
- };
- template <class T>
- bool
- atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
- template <class T>
- bool
- atomic_is_lock_free(const atomic<T>* obj) noexcept;
- template <class T>
- void
- atomic_init(volatile atomic<T>* obj, T desr) noexcept;
- template <class T>
- void
- atomic_init(atomic<T>* obj, T desr) noexcept;
- template <class T>
- void
- atomic_store(volatile atomic<T>* obj, T desr) noexcept;
- template <class T>
- void
- atomic_store(atomic<T>* obj, T desr) noexcept;
- template <class T>
- void
- atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
- template <class T>
- void
- atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
- template <class T>
- T
- atomic_load(const volatile atomic<T>* obj) noexcept;
- template <class T>
- T
- atomic_load(const atomic<T>* obj) noexcept;
- template <class T>
- T
- atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
- template <class T>
- T
- atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
- template <class T>
- T
- atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
- template <class T>
- T
- atomic_exchange(atomic<T>* obj, T desr) noexcept;
- template <class T>
- T
- atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
- template <class T>
- T
- atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
- T desr,
- memory_order s, memory_order f) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
- memory_order s, memory_order f) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
- T* expc, T desr,
- memory_order s, memory_order f) noexcept;
- template <class T>
- bool
- atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
- T desr,
- memory_order s, memory_order f) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class Integral>
- Integral
- atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
- memory_order m) noexcept;
- template <class T>
- T*
- atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
- template <class T>
- T*
- atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
- template <class T>
- T*
- atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
- memory_order m) noexcept;
- template <class T>
- T*
- atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
- template <class T>
- T*
- atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
- template <class T>
- T*
- atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
- template <class T>
- T*
- atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
- memory_order m) noexcept;
- template <class T>
- T*
- atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
- // Atomics for standard typedef types
- typedef atomic<bool> atomic_bool;
- typedef atomic<char> atomic_char;
- typedef atomic<signed char> atomic_schar;
- typedef atomic<unsigned char> atomic_uchar;
- typedef atomic<short> atomic_short;
- typedef atomic<unsigned short> atomic_ushort;
- typedef atomic<int> atomic_int;
- typedef atomic<unsigned int> atomic_uint;
- typedef atomic<long> atomic_long;
- typedef atomic<unsigned long> atomic_ulong;
- typedef atomic<long long> atomic_llong;
- typedef atomic<unsigned long long> atomic_ullong;
- typedef atomic<char16_t> atomic_char16_t;
- typedef atomic<char32_t> atomic_char32_t;
- typedef atomic<wchar_t> atomic_wchar_t;
- typedef atomic<int_least8_t> atomic_int_least8_t;
- typedef atomic<uint_least8_t> atomic_uint_least8_t;
- typedef atomic<int_least16_t> atomic_int_least16_t;
- typedef atomic<uint_least16_t> atomic_uint_least16_t;
- typedef atomic<int_least32_t> atomic_int_least32_t;
- typedef atomic<uint_least32_t> atomic_uint_least32_t;
- typedef atomic<int_least64_t> atomic_int_least64_t;
- typedef atomic<uint_least64_t> atomic_uint_least64_t;
- typedef atomic<int_fast8_t> atomic_int_fast8_t;
- typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
- typedef atomic<int_fast16_t> atomic_int_fast16_t;
- typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
- typedef atomic<int_fast32_t> atomic_int_fast32_t;
- typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
- typedef atomic<int_fast64_t> atomic_int_fast64_t;
- typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
- typedef atomic<int8_t> atomic_int8_t;
- typedef atomic<uint8_t> atomic_uint8_t;
- typedef atomic<int16_t> atomic_int16_t;
- typedef atomic<uint16_t> atomic_uint16_t;
- typedef atomic<int32_t> atomic_int32_t;
- typedef atomic<uint32_t> atomic_uint32_t;
- typedef atomic<int64_t> atomic_int64_t;
- typedef atomic<uint64_t> atomic_uint64_t;
- typedef atomic<intptr_t> atomic_intptr_t;
- typedef atomic<uintptr_t> atomic_uintptr_t;
- typedef atomic<size_t> atomic_size_t;
- typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
- typedef atomic<intmax_t> atomic_intmax_t;
- typedef atomic<uintmax_t> atomic_uintmax_t;
- // fences
- void atomic_thread_fence(memory_order m) noexcept;
- void atomic_signal_fence(memory_order m) noexcept;
- } // std
- */
- #include <__config>
- #include <cstddef>
- #include <cstdint>
- #include <type_traits>
- #if defined(_LIBCPP_SGX_CONFIG)
- #include <sgx_spinlock.h>
- #include <cstring>
- #include <cstdlib>
- #endif // defined(_LIBCPP_SGX_CONFIG)
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
- #endif
- #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_SGX_HAS_NO_ATOMIC)
- #error <atomic> is not supported on this single threaded system
- #endif
- #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
- #error <atomic> is not implemented
- #endif
- #if _LIBCPP_STD_VER > 14
- // FIXME: use the right feature test macro value as chose by SG10.
- # define __cpp_lib_atomic_is_always_lock_free 201603L
- #endif
- _LIBCPP_BEGIN_NAMESPACE_STD
- typedef enum memory_order
- {
- memory_order_relaxed, memory_order_consume, memory_order_acquire,
- memory_order_release, memory_order_acq_rel, memory_order_seq_cst
- } memory_order;
- #if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
- namespace __gcc_atomic {
- template <typename _Tp>
- struct __gcc_atomic_t {
- #if _GNUC_VER >= 501
- static_assert(is_trivially_copyable<_Tp>::value,
- "std::atomic<Tp> requires that 'Tp' be a trivially copyable type");
- #endif
- _LIBCPP_INLINE_VISIBILITY
- #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- __gcc_atomic_t() _NOEXCEPT = default;
- #else
- __gcc_atomic_t() _NOEXCEPT : __a_value() {}
- #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
- : __a_value(value) {}
- _Tp __a_value;
- };
- #define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
- template <typename _Tp> _Tp __create();
- template <typename _Tp, typename _Td>
- typename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type
- __test_atomic_assignable(int);
- template <typename _Tp, typename _Up>
- __two __test_atomic_assignable(...);
- template <typename _Tp, typename _Td>
- struct __can_assign {
- static const bool value =
- sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char);
- };
- static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
- // Avoid switch statement to make this a constexpr.
- return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
- (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
- (__order == memory_order_release ? __ATOMIC_RELEASE:
- (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
- (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL:
- __ATOMIC_CONSUME))));
- }
- static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
- // Avoid switch statement to make this a constexpr.
- return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
- (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
- (__order == memory_order_release ? __ATOMIC_RELAXED:
- (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
- (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE:
- __ATOMIC_CONSUME))));
- }
- } // namespace __gcc_atomic
- template <typename _Tp>
- static inline
- typename enable_if<
- __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type
- __c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
- __a->__a_value = __val;
- }
- template <typename _Tp>
- static inline
- typename enable_if<
- !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value &&
- __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type
- __c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
- // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
- // the default operator= in an object is not volatile, a byte-by-byte copy
- // is required.
- volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value);
- volatile char* end = to + sizeof(_Tp);
- char* from = reinterpret_cast<char*>(&__val);
- while (to != end) {
- *to++ = *from++;
- }
- }
- template <typename _Tp>
- static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) {
- __a->__a_value = __val;
- }
- static inline void __c11_atomic_thread_fence(memory_order __order) {
- __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order));
- }
- static inline void __c11_atomic_signal_fence(memory_order __order) {
- __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val,
- memory_order __order) {
- return __atomic_store(&__a->__a_value, &__val,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val,
- memory_order __order) {
- __atomic_store(&__a->__a_value, &__val,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
- memory_order __order) {
- _Tp __ret;
- __atomic_load(&__a->__a_value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
- return __ret;
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
- _Tp __ret;
- __atomic_load(&__a->__a_value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
- return __ret;
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a,
- _Tp __value, memory_order __order) {
- _Tp __ret;
- __atomic_exchange(&__a->__a_value, &__value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
- return __ret;
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value,
- memory_order __order) {
- _Tp __ret;
- __atomic_exchange(&__a->__a_value, &__value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
- return __ret;
- }
- template <typename _Tp>
- static inline bool __c11_atomic_compare_exchange_strong(
- volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
- memory_order __success, memory_order __failure) {
- return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
- false,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
- }
- template <typename _Tp>
- static inline bool __c11_atomic_compare_exchange_strong(
- _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
- memory_order __failure) {
- return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
- false,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
- }
- template <typename _Tp>
- static inline bool __c11_atomic_compare_exchange_weak(
- volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
- memory_order __success, memory_order __failure) {
- return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
- true,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
- }
- template <typename _Tp>
- static inline bool __c11_atomic_compare_exchange_weak(
- _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
- memory_order __failure) {
- return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
- true,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
- }
- template <typename _Tp>
- struct __skip_amt { enum {value = 1}; };
- template <typename _Tp>
- struct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; };
- // FIXME: Haven't figured out what the spec says about using arrays with
- // atomic_fetch_add. Force a failure rather than creating bad behavior.
- template <typename _Tp>
- struct __skip_amt<_Tp[]> { };
- template <typename _Tp, int n>
- struct __skip_amt<_Tp[n]> { };
- template <typename _Tp, typename _Td>
- static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a,
- _Td __delta, memory_order __order) {
- return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp, typename _Td>
- static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta,
- memory_order __order) {
- return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp, typename _Td>
- static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a,
- _Td __delta, memory_order __order) {
- return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp, typename _Td>
- static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta,
- memory_order __order) {
- return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
- return __atomic_fetch_and(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
- return __atomic_fetch_and(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
- return __atomic_fetch_or(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern,
- memory_order __order) {
- return __atomic_fetch_or(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
- return __atomic_fetch_xor(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- template <typename _Tp>
- static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern,
- memory_order __order) {
- return __atomic_fetch_xor(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
- }
- #endif // _LIBCPP_HAS_GCC_ATOMIC_IMP
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- kill_dependency(_Tp __y) _NOEXCEPT
- {
- return __y;
- }
- #if defined(_LIBCPP_SGX_CONFIG)
- #define ATOMIC_XXX_LOCK_FREE 0
- #define ATOMIC_BOOL_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_CHAR_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_CHAR32_T_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_SHORT_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_INT_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_LONG_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_LLONG_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #define ATOMIC_POINTER_LOCK_FREE ATOMIC_XXX_LOCK_FREE
- #else // defined(_LIBCPP_SGX_CONFIG)
- #define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
- #define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
- #define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
- #define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
- #define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
- #define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
- #define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
- #define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
- #define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
- #define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
- #endif // defined(_LIBCPP_SGX_CONFIG)
- template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
- struct __atomic_base // false
- {
- mutable _Atomic(_Tp) __a_;
- #if defined(__cpp_lib_atomic_is_always_lock_free)
- static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
- #endif
- _LIBCPP_INLINE_VISIBILITY
- bool is_lock_free() const volatile _NOEXCEPT
- {
- #if defined(_LIBCPP_SGX_CONFIG)
- return false;
- #else
- #if defined(_LIBCPP_HAS_C_ATOMIC_IMP)
- return __c11_atomic_is_lock_free(sizeof(_Tp));
- #else
- return __atomic_is_lock_free(sizeof(_Tp), 0);
- #endif
- #endif
- }
- _LIBCPP_INLINE_VISIBILITY
- bool is_lock_free() const _NOEXCEPT
- {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
- _LIBCPP_INLINE_VISIBILITY
- void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {__c11_atomic_store(&__a_, __d, __m);}
- _LIBCPP_INLINE_VISIBILITY
- void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {__c11_atomic_store(&__a_, __d, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
- {return __c11_atomic_load(&__a_, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
- {return __c11_atomic_load(&__a_, __m);}
- _LIBCPP_INLINE_VISIBILITY
- operator _Tp() const volatile _NOEXCEPT {return load();}
- _LIBCPP_INLINE_VISIBILITY
- operator _Tp() const _NOEXCEPT {return load();}
- _LIBCPP_INLINE_VISIBILITY
- _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, __d, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, __d, __m);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_weak(_Tp& __e, _Tp __d,
- memory_order __s, memory_order __f) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_weak(_Tp& __e, _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_strong(_Tp& __e, _Tp __d,
- memory_order __s, memory_order __f) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_strong(_Tp& __e, _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_weak(_Tp& __e, _Tp __d,
- memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_weak(_Tp& __e, _Tp __d,
- memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_strong(_Tp& __e, _Tp __d,
- memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
- _LIBCPP_INLINE_VISIBILITY
- bool compare_exchange_strong(_Tp& __e, _Tp __d,
- memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
- _LIBCPP_INLINE_VISIBILITY
- #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- __atomic_base() _NOEXCEPT = default;
- #else
- __atomic_base() _NOEXCEPT : __a_() {}
- #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
- #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- __atomic_base(const __atomic_base&) = delete;
- __atomic_base& operator=(const __atomic_base&) = delete;
- __atomic_base& operator=(const __atomic_base&) volatile = delete;
- #else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- private:
- __atomic_base(const __atomic_base&);
- __atomic_base& operator=(const __atomic_base&);
- __atomic_base& operator=(const __atomic_base&) volatile;
- #endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- };
- #if defined(__cpp_lib_atomic_is_always_lock_free)
- template <class _Tp, bool __b>
- _LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free;
- #endif
- // atomic<Integral>
- template <class _Tp>
- struct __atomic_base<_Tp, true>
- : public __atomic_base<_Tp, false>
- {
- typedef __atomic_base<_Tp, false> __base;
- _LIBCPP_INLINE_VISIBILITY
- __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
- };
- // atomic<T>
- template <class _Tp>
- struct atomic
- : public __atomic_base<_Tp>
- {
- typedef __atomic_base<_Tp> __base;
- _LIBCPP_INLINE_VISIBILITY
- atomic() _NOEXCEPT _LIBCPP_DEFAULT
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator=(_Tp __d) volatile _NOEXCEPT
- {__base::store(__d); return __d;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp operator=(_Tp __d) _NOEXCEPT
- {__base::store(__d); return __d;}
- };
- // atomic<T*>
- template <class _Tp>
- struct atomic<_Tp*>
- : public __atomic_base<_Tp*>
- {
- typedef __atomic_base<_Tp*> __base;
- _LIBCPP_INLINE_VISIBILITY
- atomic() _NOEXCEPT _LIBCPP_DEFAULT
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
- {__base::store(__d); return __d;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator=(_Tp* __d) _NOEXCEPT
- {__base::store(__d); return __d;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
- volatile _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
- volatile _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
- _LIBCPP_INLINE_VISIBILITY
- _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
- };
- // atomic_is_lock_free
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
- {
- return __o->is_lock_free();
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
- {
- return __o->is_lock_free();
- }
- // atomic_init
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- __c11_atomic_init(&__o->__a_, __d);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- __c11_atomic_init(&__o->__a_, __d);
- }
- // atomic_store
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- __o->store(__d);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- __o->store(__d);
- }
- // atomic_store_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
- {
- __o->store(__d, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
- {
- __o->store(__d, __m);
- }
- // atomic_load
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
- {
- return __o->load();
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
- {
- return __o->load();
- }
- // atomic_load_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
- {
- return __o->load(__m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
- {
- return __o->load(__m);
- }
- // atomic_exchange
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- return __o->exchange(__d);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
- {
- return __o->exchange(__d);
- }
- // atomic_exchange_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
- {
- return __o->exchange(__d, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp
- atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
- {
- return __o->exchange(__d, __m);
- }
- // atomic_compare_exchange_weak
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
- {
- return __o->compare_exchange_weak(*__e, __d);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
- {
- return __o->compare_exchange_weak(*__e, __d);
- }
- // atomic_compare_exchange_strong
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
- {
- return __o->compare_exchange_strong(*__e, __d);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
- {
- return __o->compare_exchange_strong(*__e, __d);
- }
- // atomic_compare_exchange_weak_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
- _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {
- return __o->compare_exchange_weak(*__e, __d, __s, __f);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {
- return __o->compare_exchange_weak(*__e, __d, __s, __f);
- }
- // atomic_compare_exchange_strong_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
- _Tp* __e, _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {
- return __o->compare_exchange_strong(*__e, __d, __s, __f);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
- _Tp __d,
- memory_order __s, memory_order __f) _NOEXCEPT
- {
- return __o->compare_exchange_strong(*__e, __d, __s, __f);
- }
- // atomic_fetch_add
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_add(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_add(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
- {
- return __o->fetch_add(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
- {
- return __o->fetch_add(__op);
- }
- // atomic_fetch_add_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_add(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_add(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
- memory_order __m) _NOEXCEPT
- {
- return __o->fetch_add(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_add(__op, __m);
- }
- // atomic_fetch_sub
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_sub(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_sub(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
- {
- return __o->fetch_sub(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
- {
- return __o->fetch_sub(__op);
- }
- // atomic_fetch_sub_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_sub(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_sub(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
- memory_order __m) _NOEXCEPT
- {
- return __o->fetch_sub(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- _Tp*
- atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_sub(__op, __m);
- }
- // atomic_fetch_and
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_and(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_and(__op);
- }
- // atomic_fetch_and_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_and(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_and(__op, __m);
- }
- // atomic_fetch_or
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_or(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_or(__op);
- }
- // atomic_fetch_or_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_or(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_or(__op, __m);
- }
- // atomic_fetch_xor
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_xor(__op);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
- {
- return __o->fetch_xor(__op);
- }
- // atomic_fetch_xor_explicit
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_xor(__op, __m);
- }
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
- _Tp
- >::type
- atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
- {
- return __o->fetch_xor(__op, __m);
- }
- // flag type and operations
- typedef struct atomic_flag
- {
- _Atomic(bool) __a_;
- _LIBCPP_INLINE_VISIBILITY
- bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, true, __m);}
- _LIBCPP_INLINE_VISIBILITY
- bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, true, __m);}
- _LIBCPP_INLINE_VISIBILITY
- void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {__c11_atomic_store(&__a_, false, __m);}
- _LIBCPP_INLINE_VISIBILITY
- void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {__c11_atomic_store(&__a_, false, __m);}
- _LIBCPP_INLINE_VISIBILITY
- #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- atomic_flag() _NOEXCEPT = default;
- #else
- atomic_flag() _NOEXCEPT : __a_() {}
- #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- _LIBCPP_INLINE_VISIBILITY
- atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
- #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- atomic_flag(const atomic_flag&) = delete;
- atomic_flag& operator=(const atomic_flag&) = delete;
- atomic_flag& operator=(const atomic_flag&) volatile = delete;
- #else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- private:
- atomic_flag(const atomic_flag&);
- atomic_flag& operator=(const atomic_flag&);
- atomic_flag& operator=(const atomic_flag&) volatile;
- #endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
- } atomic_flag;
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
- {
- return __o->test_and_set();
- }
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
- {
- return __o->test_and_set();
- }
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
- {
- return __o->test_and_set(__m);
- }
- inline _LIBCPP_INLINE_VISIBILITY
- bool
- atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
- {
- return __o->test_and_set(__m);
- }
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
- {
- __o->clear();
- }
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
- {
- __o->clear();
- }
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
- {
- __o->clear(__m);
- }
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
- {
- __o->clear(__m);
- }
- // fences
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_thread_fence(memory_order __m) _NOEXCEPT
- {
- __c11_atomic_thread_fence(__m);
- }
- inline _LIBCPP_INLINE_VISIBILITY
- void
- atomic_signal_fence(memory_order __m) _NOEXCEPT
- {
- __c11_atomic_signal_fence(__m);
- }
- // Atomics for standard typedef types
- typedef atomic<bool> atomic_bool;
- typedef atomic<char> atomic_char;
- typedef atomic<signed char> atomic_schar;
- typedef atomic<unsigned char> atomic_uchar;
- typedef atomic<short> atomic_short;
- typedef atomic<unsigned short> atomic_ushort;
- typedef atomic<int> atomic_int;
- typedef atomic<unsigned int> atomic_uint;
- typedef atomic<long> atomic_long;
- typedef atomic<unsigned long> atomic_ulong;
- typedef atomic<long long> atomic_llong;
- typedef atomic<unsigned long long> atomic_ullong;
- typedef atomic<char16_t> atomic_char16_t;
- typedef atomic<char32_t> atomic_char32_t;
- typedef atomic<wchar_t> atomic_wchar_t;
- typedef atomic<int_least8_t> atomic_int_least8_t;
- typedef atomic<uint_least8_t> atomic_uint_least8_t;
- typedef atomic<int_least16_t> atomic_int_least16_t;
- typedef atomic<uint_least16_t> atomic_uint_least16_t;
- typedef atomic<int_least32_t> atomic_int_least32_t;
- typedef atomic<uint_least32_t> atomic_uint_least32_t;
- typedef atomic<int_least64_t> atomic_int_least64_t;
- typedef atomic<uint_least64_t> atomic_uint_least64_t;
- typedef atomic<int_fast8_t> atomic_int_fast8_t;
- typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
- typedef atomic<int_fast16_t> atomic_int_fast16_t;
- typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
- typedef atomic<int_fast32_t> atomic_int_fast32_t;
- typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
- typedef atomic<int_fast64_t> atomic_int_fast64_t;
- typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
- typedef atomic< int8_t> atomic_int8_t;
- typedef atomic<uint8_t> atomic_uint8_t;
- typedef atomic< int16_t> atomic_int16_t;
- typedef atomic<uint16_t> atomic_uint16_t;
- typedef atomic< int32_t> atomic_int32_t;
- typedef atomic<uint32_t> atomic_uint32_t;
- typedef atomic< int64_t> atomic_int64_t;
- typedef atomic<uint64_t> atomic_uint64_t;
- typedef atomic<intptr_t> atomic_intptr_t;
- typedef atomic<uintptr_t> atomic_uintptr_t;
- typedef atomic<size_t> atomic_size_t;
- typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
- typedef atomic<intmax_t> atomic_intmax_t;
- typedef atomic<uintmax_t> atomic_uintmax_t;
- #define ATOMIC_FLAG_INIT {false}
- #define ATOMIC_VAR_INIT(__v) {__v}
- _LIBCPP_END_NAMESPACE_STD
- #endif // _LIBCPP_ATOMIC
|