236 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CXX03_STDATOMIC_H11#define _LIBCPP___CXX03_STDATOMIC_H12 13/*14 stdatomic.h synopsis15 16template<class T>17 using std-atomic = std::atomic<T>; // exposition only18 19#define _Atomic(T) std-atomic<T>20 21#define ATOMIC_BOOL_LOCK_FREE see below22#define ATOMIC_CHAR_LOCK_FREE see below23#define ATOMIC_CHAR16_T_LOCK_FREE see below24#define ATOMIC_CHAR32_T_LOCK_FREE see below25#define ATOMIC_WCHAR_T_LOCK_FREE see below26#define ATOMIC_SHORT_LOCK_FREE see below27#define ATOMIC_INT_LOCK_FREE see below28#define ATOMIC_LONG_LOCK_FREE see below29#define ATOMIC_LLONG_LOCK_FREE see below30#define ATOMIC_POINTER_LOCK_FREE see below31 32using std::memory_order // see below33using std::memory_order_relaxed // see below34using std::memory_order_consume // see below35using std::memory_order_acquire // see below36using std::memory_order_release // see below37using std::memory_order_acq_rel // see below38using std::memory_order_seq_cst // see below39 40using std::atomic_flag // see below41 42using std::atomic_bool // see below43using std::atomic_char // see below44using std::atomic_schar // see below45using std::atomic_uchar // see below46using std::atomic_short // see below47using std::atomic_ushort // see below48using std::atomic_int // see below49using std::atomic_uint // see below50using std::atomic_long // see below51using std::atomic_ulong // see below52using std::atomic_llong // see below53using std::atomic_ullong // see below54using std::atomic_char8_t // see below55using std::atomic_char16_t // see below56using std::atomic_char32_t // see below57using std::atomic_wchar_t // see below58using std::atomic_int8_t // see below59using std::atomic_uint8_t // see below60using std::atomic_int16_t // see below61using std::atomic_uint16_t // see below62using std::atomic_int32_t // see below63using std::atomic_uint32_t // see below64using std::atomic_int64_t // see below65using std::atomic_uint64_t // see below66using std::atomic_int_least8_t // see below67using std::atomic_uint_least8_t // see below68using std::atomic_int_least16_t // see below69using std::atomic_uint_least16_t // see below70using std::atomic_int_least32_t // see below71using std::atomic_uint_least32_t // see below72using std::atomic_int_least64_t // see below73using std::atomic_uint_least64_t // see below74using std::atomic_int_fast8_t // see below75using std::atomic_uint_fast8_t // see below76using std::atomic_int_fast16_t // see below77using std::atomic_uint_fast16_t // see below78using std::atomic_int_fast32_t // see below79using std::atomic_uint_fast32_t // see below80using std::atomic_int_fast64_t // see below81using std::atomic_uint_fast64_t // see below82using std::atomic_intptr_t // see below83using std::atomic_uintptr_t // see below84using std::atomic_size_t // see below85using std::atomic_ptrdiff_t // see below86using std::atomic_intmax_t // see below87using std::atomic_uintmax_t // see below88 89using std::atomic_is_lock_free // see below90using std::atomic_load // see below91using std::atomic_load_explicit // see below92using std::atomic_store // see below93using std::atomic_store_explicit // see below94using std::atomic_exchange // see below95using std::atomic_exchange_explicit // see below96using std::atomic_compare_exchange_strong // see below97using std::atomic_compare_exchange_strong_explicit // see below98using std::atomic_compare_exchange_weak // see below99using std::atomic_compare_exchange_weak_explicit // see below100using std::atomic_fetch_add // see below101using std::atomic_fetch_add_explicit // see below102using std::atomic_fetch_sub // see below103using std::atomic_fetch_sub_explicit // see below104using std::atomic_fetch_or // see below105using std::atomic_fetch_or_explicit // see below106using std::atomic_fetch_and // see below107using std::atomic_fetch_and_explicit // see below108using std::atomic_flag_test_and_set // see below109using std::atomic_flag_test_and_set_explicit // see below110using std::atomic_flag_clear // see below111using std::atomic_flag_clear_explicit // see below112 113using std::atomic_thread_fence // see below114using std::atomic_signal_fence // see below115 116*/117 118#include <__cxx03/__config>119 120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)121# pragma GCC system_header122#endif123 124#if defined(__cplusplus) && false125 126# include <__cxx03/atomic>127# include <__cxx03/version>128 129# ifdef _Atomic130# undef _Atomic131# endif132 133# define _Atomic(_Tp) ::std::atomic<_Tp>134 135using std::memory_order _LIBCPP_USING_IF_EXISTS;136using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;137using std::memory_order_consume _LIBCPP_USING_IF_EXISTS;138using std::memory_order_acquire _LIBCPP_USING_IF_EXISTS;139using std::memory_order_release _LIBCPP_USING_IF_EXISTS;140using std::memory_order_acq_rel _LIBCPP_USING_IF_EXISTS;141using std::memory_order_seq_cst _LIBCPP_USING_IF_EXISTS;142 143using std::atomic_flag _LIBCPP_USING_IF_EXISTS;144 145using std::atomic_bool _LIBCPP_USING_IF_EXISTS;146using std::atomic_char _LIBCPP_USING_IF_EXISTS;147using std::atomic_schar _LIBCPP_USING_IF_EXISTS;148using std::atomic_uchar _LIBCPP_USING_IF_EXISTS;149using std::atomic_short _LIBCPP_USING_IF_EXISTS;150using std::atomic_ushort _LIBCPP_USING_IF_EXISTS;151using std::atomic_int _LIBCPP_USING_IF_EXISTS;152using std::atomic_uint _LIBCPP_USING_IF_EXISTS;153using std::atomic_long _LIBCPP_USING_IF_EXISTS;154using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;155using std::atomic_llong _LIBCPP_USING_IF_EXISTS;156using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;157using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;158using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;159using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;160using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;161 162using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;163using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;164using std::atomic_int16_t _LIBCPP_USING_IF_EXISTS;165using std::atomic_uint16_t _LIBCPP_USING_IF_EXISTS;166using std::atomic_int32_t _LIBCPP_USING_IF_EXISTS;167using std::atomic_uint32_t _LIBCPP_USING_IF_EXISTS;168using std::atomic_int64_t _LIBCPP_USING_IF_EXISTS;169using std::atomic_uint64_t _LIBCPP_USING_IF_EXISTS;170 171using std::atomic_int_least8_t _LIBCPP_USING_IF_EXISTS;172using std::atomic_uint_least8_t _LIBCPP_USING_IF_EXISTS;173using std::atomic_int_least16_t _LIBCPP_USING_IF_EXISTS;174using std::atomic_uint_least16_t _LIBCPP_USING_IF_EXISTS;175using std::atomic_int_least32_t _LIBCPP_USING_IF_EXISTS;176using std::atomic_uint_least32_t _LIBCPP_USING_IF_EXISTS;177using std::atomic_int_least64_t _LIBCPP_USING_IF_EXISTS;178using std::atomic_uint_least64_t _LIBCPP_USING_IF_EXISTS;179 180using std::atomic_int_fast8_t _LIBCPP_USING_IF_EXISTS;181using std::atomic_uint_fast8_t _LIBCPP_USING_IF_EXISTS;182using std::atomic_int_fast16_t _LIBCPP_USING_IF_EXISTS;183using std::atomic_uint_fast16_t _LIBCPP_USING_IF_EXISTS;184using std::atomic_int_fast32_t _LIBCPP_USING_IF_EXISTS;185using std::atomic_uint_fast32_t _LIBCPP_USING_IF_EXISTS;186using std::atomic_int_fast64_t _LIBCPP_USING_IF_EXISTS;187using std::atomic_uint_fast64_t _LIBCPP_USING_IF_EXISTS;188 189using std::atomic_intptr_t _LIBCPP_USING_IF_EXISTS;190using std::atomic_uintptr_t _LIBCPP_USING_IF_EXISTS;191using std::atomic_size_t _LIBCPP_USING_IF_EXISTS;192using std::atomic_ptrdiff_t _LIBCPP_USING_IF_EXISTS;193using std::atomic_intmax_t _LIBCPP_USING_IF_EXISTS;194using std::atomic_uintmax_t _LIBCPP_USING_IF_EXISTS;195 196using std::atomic_compare_exchange_strong _LIBCPP_USING_IF_EXISTS;197using std::atomic_compare_exchange_strong_explicit _LIBCPP_USING_IF_EXISTS;198using std::atomic_compare_exchange_weak _LIBCPP_USING_IF_EXISTS;199using std::atomic_compare_exchange_weak_explicit _LIBCPP_USING_IF_EXISTS;200using std::atomic_exchange _LIBCPP_USING_IF_EXISTS;201using std::atomic_exchange_explicit _LIBCPP_USING_IF_EXISTS;202using std::atomic_fetch_add _LIBCPP_USING_IF_EXISTS;203using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;204using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;205using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;206using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;207using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;208using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;209using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;210using std::atomic_flag_clear _LIBCPP_USING_IF_EXISTS;211using std::atomic_flag_clear_explicit _LIBCPP_USING_IF_EXISTS;212using std::atomic_flag_test_and_set _LIBCPP_USING_IF_EXISTS;213using std::atomic_flag_test_and_set_explicit _LIBCPP_USING_IF_EXISTS;214using std::atomic_is_lock_free _LIBCPP_USING_IF_EXISTS;215using std::atomic_load _LIBCPP_USING_IF_EXISTS;216using std::atomic_load_explicit _LIBCPP_USING_IF_EXISTS;217using std::atomic_store _LIBCPP_USING_IF_EXISTS;218using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;219 220using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;221using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;222 223#elif defined(_LIBCPP_COMPILER_CLANG_BASED)224 225// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking226// the header. We do this because Clang has historically shipped a <stdatomic.h>227// header that would be available in all Standard modes, and we don't want to228// break that use case.229# if __has_include_next(<stdatomic.h>)230# include_next <stdatomic.h>231# endif232 233#endif // defined(__cplusplus) && false234 235#endif // _LIBCPP___CXX03_STDATOMIC_H236