Index: head/contrib/libc++/include/__config =================================================================== --- head/contrib/libc++/include/__config (revision 296686) +++ head/contrib/libc++/include/__config (revision 296687) @@ -1,777 +1,782 @@ // -*- C++ -*- //===--------------------------- __config ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_CONFIG #define _LIBCPP_CONFIG #if !defined(_MSC_VER) || defined(__clang__) #pragma GCC system_header #endif #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #else #define _GNUC_VER 0 #endif #define _LIBCPP_VERSION 3700 #define _LIBCPP_ABI_VERSION 1 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #ifndef __has_attribute #define __has_attribute(__x) 0 #endif #ifndef __has_builtin #define __has_builtin(__x) 0 #endif #ifndef __has_feature #define __has_feature(__x) 0 #endif // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by // the compiler and '1' otherwise. #ifndef __is_identifier #define __is_identifier(__x) 1 #endif #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 1 #define _LIBCPP_BIG_ENDIAN 0 #endif // __LITTLE_ENDIAN__ #endif // __LITTLE_ENDIAN__ #ifdef __BIG_ENDIAN__ #if __BIG_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 0 #define _LIBCPP_BIG_ENDIAN 1 #endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ #ifdef __FreeBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif // _BYTE_ORDER == _LITTLE_ENDIAN # ifndef __LONG_LONG_SUPPORTED # define _LIBCPP_HAS_NO_LONG_LONG # endif // __LONG_LONG_SUPPORTED #endif // __FreeBSD__ #ifdef __NetBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_HAS_QUICK_EXIT #endif // __NetBSD__ #ifdef _WIN32 # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 // Compiler intrinsics (MSVC) #if defined(_MSC_VER) && _MSC_VER >= 1400 # define _LIBCPP_HAS_IS_BASE_OF # endif # if defined(_MSC_VER) && !defined(__clang__) # define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler # define _LIBCPP_TOSTRING2(x) #x # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) # endif # // If mingw not explicitly detected, assume using MS C runtime only. # ifndef __MINGW32__ # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif #endif // _WIN32 #ifdef __sun__ # include # ifdef _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif #endif // __sun__ #if defined(__CloudABI__) // Certain architectures provide arc4random(). Prefer using // arc4random() over /dev/{u,}random to make it possible to obtain // random data even when using sandboxing mechanisms such as chroots, // Capsicum, etc. # define _LIBCPP_USING_ARC4_RANDOM #elif defined(__native_client__) // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, // including accesses to the special files under /dev. C++11's // std::random_device is instead exposed through a NaCl syscall. # define _LIBCPP_USING_NACL_RANDOM #elif defined(_WIN32) # define _LIBCPP_USING_WIN32_RANDOM #else # define _LIBCPP_USING_DEV_RANDOM #endif #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) # include # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # elif __BYTE_ORDER == __BIG_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # else // __BYTE_ORDER == __BIG_ENDIAN # error unable to determine endian # endif #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) #ifdef _WIN32 // only really useful for a DLL #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally... # ifdef cxx_EXPORTS # define _LIBCPP_HIDDEN # define _LIBCPP_FUNC_VIS __declspec(dllexport) # define _LIBCPP_TYPE_VIS __declspec(dllexport) # else # define _LIBCPP_HIDDEN # define _LIBCPP_FUNC_VIS __declspec(dllimport) # define _LIBCPP_TYPE_VIS __declspec(dllimport) # endif #else # define _LIBCPP_HIDDEN # define _LIBCPP_FUNC_VIS # define _LIBCPP_TYPE_VIS #endif #define _LIBCPP_TYPE_VIS_ONLY #define _LIBCPP_FUNC_VIS_ONLY #ifndef _LIBCPP_INLINE_VISIBILITY # ifdef _LIBCPP_MSVC # define _LIBCPP_INLINE_VISIBILITY __forceinline # else // MinGW GCC and Clang # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) # endif #endif #ifndef _LIBCPP_EXCEPTION_ABI #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS #endif #ifndef _LIBCPP_ALWAYS_INLINE # ifdef _LIBCPP_MSVC # define _LIBCPP_ALWAYS_INLINE __forceinline # endif #endif #endif // _WIN32 #ifndef _LIBCPP_HIDDEN #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) #endif #ifndef _LIBCPP_FUNC_VIS #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) #endif #ifndef _LIBCPP_TYPE_VIS # if __has_attribute(__type_visibility__) # define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) # endif #endif #ifndef _LIBCPP_TYPE_VIS_ONLY # define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS #endif #ifndef _LIBCPP_FUNC_VIS_ONLY # define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS #endif #ifndef _LIBCPP_INLINE_VISIBILITY #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif #ifndef _LIBCPP_EXCEPTION_ABI #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) #endif #ifndef _LIBCPP_ALWAYS_INLINE #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif #if defined(__clang__) #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ !defined(__arm__) #define _LIBCPP_ALTERNATE_STRING_LAYOUT #endif #if __has_feature(cxx_alignas) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) #else # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) # define _ALIGNAS(x) __attribute__((__aligned__(x))) #endif #if !__has_feature(cxx_alias_templates) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif #if __cplusplus < 201103L typedef __char16_t char16_t; typedef __char32_t char32_t; #endif #if !(__has_feature(cxx_exceptions)) #define _LIBCPP_NO_EXCEPTIONS #endif #if !(__has_feature(cxx_rtti)) #define _LIBCPP_NO_RTTI #endif #if !(__has_feature(cxx_strong_enums)) #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if !(__has_feature(cxx_decltype)) #define _LIBCPP_HAS_NO_DECLTYPE #endif #if __has_feature(cxx_attributes) # define _LIBCPP_NORETURN [[noreturn]] #else # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif #define _LIBCPP_UNUSED __attribute__((__unused__)) #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) #if !(__has_feature(cxx_deleted_functions)) #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #endif // !(__has_feature(cxx_deleted_functions)) #if !(__has_feature(cxx_lambdas)) #define _LIBCPP_HAS_NO_LAMBDAS #endif #if !(__has_feature(cxx_nullptr)) #define _LIBCPP_HAS_NO_NULLPTR #endif #if !(__has_feature(cxx_rvalue_references)) #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if !(__has_feature(cxx_static_assert)) #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif #if !(__has_feature(cxx_auto_type)) #define _LIBCPP_HAS_NO_AUTO_TYPE #endif #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return) #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif #if !(__has_feature(cxx_variadic_templates)) #define _LIBCPP_HAS_NO_VARIADICS #endif #if !(__has_feature(cxx_trailing_return)) #define _LIBCPP_HAS_NO_TRAILING_RETURN #endif #if !(__has_feature(cxx_generalized_initializers)) #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif #if __has_feature(is_base_of) # define _LIBCPP_HAS_IS_BASE_OF #endif #if __has_feature(is_final) # define _LIBCPP_HAS_IS_FINAL #endif // Objective-C++ features (opt-in) #if __has_feature(objc_arc) #define _LIBCPP_HAS_OBJC_ARC #endif #if __has_feature(objc_arc_weak) #define _LIBCPP_HAS_OBJC_ARC_WEAK #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if !(__has_feature(cxx_constexpr)) #define _LIBCPP_HAS_NO_CONSTEXPR #endif #if !(__has_feature(cxx_relaxed_constexpr)) #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #endif #if !(__has_feature(cxx_variable_templates)) #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #endif #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L #if defined(__FreeBSD__) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #elif defined(__ANDROID__) #define _LIBCPP_HAS_QUICK_EXIT #elif defined(__linux__) #include #if __GLIBC_PREREQ(2, 15) #define _LIBCPP_HAS_QUICK_EXIT #endif #if __GLIBC_PREREQ(2, 17) #define _LIBCPP_HAS_C11_FEATURES #endif #endif #endif #if (__has_feature(cxx_noexcept)) # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) # define _NOEXCEPT_OR_FALSE(x) noexcept(x) #else # define _NOEXCEPT throw() # define _NOEXCEPT_(x) # define _NOEXCEPT_OR_FALSE(x) false #endif #if __has_feature(underlying_type) # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) #endif #if __has_feature(is_literal) # define _LIBCPP_IS_LITERAL(T) __is_literal(T) #endif // Inline namespaces are available in Clang regardless of C++ dialect. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) #define _LIBCPP_HAS_NO_ASAN #endif #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_UNUSED __attribute__((__unused__)) #if _GNUC_VER >= 407 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) #define _LIBCPP_HAS_IS_FINAL #endif #if defined(__GNUC__) && _GNUC_VER >= 403 # define _LIBCPP_HAS_IS_BASE_OF #endif #if !__EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS #endif #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES // constexpr was added to GCC in 4.6. #if _GNUC_VER < 406 #define _LIBCPP_HAS_NO_CONSTEXPR // Can only use constexpr in c++11 mode. #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L #define _LIBCPP_HAS_NO_CONSTEXPR #endif -// No version of GCC supports relaxed constexpr rules +// Determine if GCC supports relaxed constexpr +#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#endif + // GCC 5 will support variable templates +#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif #define _NOEXCEPT throw() #define _NOEXCEPT_(x) #define _NOEXCEPT_OR_FALSE(x) false #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_STATIC_ASSERT #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_STRONG_ENUMS #else // __GXX_EXPERIMENTAL_CXX0X__ -#define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _GNUC_VER < 404 #if _GNUC_VER < 406 #define _LIBCPP_HAS_NO_NULLPTR #endif #if _GNUC_VER < 407 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif #endif // __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { namespace _LIBCPP_NAMESPACE { } using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); } #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) #define _LIBCPP_HAS_NO_ASAN #endif #elif defined(_LIBCPP_MSVC) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _LIBCPP_UNUSED #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS #define _NOEXCEPT throw () #define _NOEXCEPT_(x) #define _NOEXCEPT_OR_FALSE(x) false #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std # define _LIBCPP_WEAK namespace std { } #define _LIBCPP_HAS_NO_ASAN #elif defined(__IBMCPP__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ATTRIBUTE(x) __attribute__((x)) #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_UNUSED #define _NOEXCEPT throw() #define _NOEXCEPT_(x) #define _NOEXCEPT_OR_FALSE(x) false #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_IS_BASE_OF #define _LIBCPP_HAS_IS_FINAL #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #if defined(_AIX) #define __MULTILOCALE_API #endif #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #define _LIBCPP_HAS_NO_ASAN #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS #ifndef __SIZEOF_INT128__ #define _LIBCPP_HAS_NO_INT128 #endif #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT template struct __static_assert_test; template <> struct __static_assert_test {}; template struct __static_assert_check {}; #define static_assert(__b, __m) \ typedef __static_assert_check)> \ _LIBCPP_CONCAT(__t, __LINE__) #endif // _LIBCPP_HAS_NO_STATIC_ASSERT #ifdef _LIBCPP_HAS_NO_DECLTYPE // GCC 4.6 provides __decltype in all standard modes. #if !__is_identifier(__decltype) || _GNUC_VER >= 406 # define decltype(__x) __decltype(__x) #else # define decltype(__x) __typeof__(__x) #endif #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_CONSTEXPR #else #define _LIBCPP_CONSTEXPR constexpr #endif #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_DEFAULT {} #else #define _LIBCPP_DEFAULT = default; #endif #ifdef __GNUC__ #define _NOALIAS __attribute__((__malloc__)) #else #define _NOALIAS #endif #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) # define _LIBCPP_EXPLICIT explicit #else # define _LIBCPP_EXPLICIT #endif #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) # define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE #endif #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ __lx __v_; \ _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \ _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ }; #else // _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS #ifdef _LIBCPP_DEBUG # if _LIBCPP_DEBUG == 0 # define _LIBCPP_DEBUG_LEVEL 1 # elif _LIBCPP_DEBUG == 1 # define _LIBCPP_DEBUG_LEVEL 2 # else # error Supported values for _LIBCPP_DEBUG are 0 and 1 # endif # define _LIBCPP_EXTERN_TEMPLATE(...) #endif #ifndef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #endif #ifndef _LIBCPP_EXTERN_TEMPLATE2 #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \ defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \ !defined(__CloudABI__) #define _LIBCPP_HAS_CATOPEN 1 #endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) #define _LIBCPP_WCTYPE_IS_MASK #endif #ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR # if defined(__FreeBSD__) // Making the std::pair copy constructor trivial breaks ABI compatibility with // earlier versions of libc++ shipped by FreeBSD, so turn it off by default. // See also http://svnweb.freebsd.org/changeset/base/261801 # define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0 # else # define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 # endif #endif #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 # elif __cplusplus <= 201402L # define _LIBCPP_STD_VER 14 # else # define _LIBCPP_STD_VER 15 // current year, or date of c++17 ratification # endif #endif // _LIBCPP_STD_VER #if _LIBCPP_STD_VER > 11 #define _LIBCPP_DEPRECATED [[deprecated]] #else #define _LIBCPP_DEPRECATED #endif #if _LIBCPP_STD_VER <= 11 #define _LIBCPP_EXPLICIT_AFTER_CXX11 #define _LIBCPP_DEPRECATED_AFTER_CXX11 #else #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] #endif #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr #else #define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif #ifndef _LIBCPP_HAS_NO_ASAN extern "C" void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); #endif // Try to find out if RTTI is disabled. // g++ and cl.exe have RTTI on by default and define a macro when it is. // g++ only defines the macro in 4.3.2 and onwards. #if !defined(_LIBCPP_NO_RTTI) # if defined(__GNUG__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) # define _LIBCPP_NO_RTTI # endif #endif #ifndef _LIBCPP_WEAK # define _LIBCPP_WEAK __attribute__((__weak__)) #endif #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ _LIBCPP_HAS_NO_THREADS is defined. #endif // Systems that use capability-based security (FreeBSD with Capsicum, // Nuxi CloudABI) may only provide local filesystem access (using *at()). // Functions like open(), rename(), unlink() and stat() should not be // used, as they attempt to access the global filesystem namespace. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE #endif // CloudABI is intended for running networked services. Processes do not // have standard input and output channels. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_STDIN #define _LIBCPP_HAS_NO_STDOUT #endif #if defined(__ANDROID__) || defined(__CloudABI__) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif // Thread-unsafe functions such as strtok(), mbtowc() and localtime() // are not available. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #endif #endif // _LIBCPP_CONFIG Index: head/contrib/libc++/include/atomic =================================================================== --- head/contrib/libc++/include/atomic (revision 296686) +++ head/contrib/libc++/include/atomic (revision 296687) @@ -1,1801 +1,1812 @@ // -*- 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 { // 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 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 struct atomic { 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 { 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 struct atomic { 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 bool atomic_is_lock_free(const volatile atomic* obj) noexcept; template bool atomic_is_lock_free(const atomic* obj) noexcept; template void atomic_init(volatile atomic* obj, T desr) noexcept; template void atomic_init(atomic* obj, T desr) noexcept; template void atomic_store(volatile atomic* obj, T desr) noexcept; template void atomic_store(atomic* obj, T desr) noexcept; template void atomic_store_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template void atomic_store_explicit(atomic* obj, T desr, memory_order m) noexcept; template T atomic_load(const volatile atomic* obj) noexcept; template T atomic_load(const atomic* obj) noexcept; template T atomic_load_explicit(const volatile atomic* obj, memory_order m) noexcept; template T atomic_load_explicit(const atomic* obj, memory_order m) noexcept; template T atomic_exchange(volatile atomic* obj, T desr) noexcept; template T atomic_exchange(atomic* obj, T desr) noexcept; template T atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template T atomic_exchange_explicit(atomic* obj, T desr, memory_order m) noexcept; template bool atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_weak(atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_strong(atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_weak_explicit(volatile atomic* obj, T* expc, T desr, memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_weak_explicit(atomic* obj, T* expc, T desr, memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(volatile atomic* obj, T* expc, T desr, memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(atomic* obj, T* expc, T desr, memory_order s, memory_order f) noexcept; template Integral atomic_fetch_add(volatile atomic* obj, Integral op) noexcept; template Integral atomic_fetch_add(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_add_explicit(volatile atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_add_explicit(atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_sub(volatile atomic* obj, Integral op) noexcept; template Integral atomic_fetch_sub(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_sub_explicit(volatile atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_sub_explicit(atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_and(volatile atomic* obj, Integral op) noexcept; template Integral atomic_fetch_and(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_and_explicit(volatile atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_and_explicit(atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_or(volatile atomic* obj, Integral op) noexcept; template Integral atomic_fetch_or(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_or_explicit(volatile atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_or_explicit(atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_xor(volatile atomic* obj, Integral op) noexcept; template Integral atomic_fetch_xor(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_xor_explicit(volatile atomic* obj, Integral op, memory_order m) noexcept; template Integral atomic_fetch_xor_explicit(atomic* obj, Integral op, memory_order m) noexcept; template T* atomic_fetch_add(volatile atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_add(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_sub(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; // Atomics for standard typedef types typedef atomic atomic_bool; typedef atomic atomic_char; typedef atomic atomic_schar; typedef atomic atomic_uchar; typedef atomic atomic_short; typedef atomic atomic_ushort; typedef atomic atomic_int; typedef atomic atomic_uint; typedef atomic atomic_long; typedef atomic atomic_ulong; typedef atomic atomic_llong; typedef atomic atomic_ullong; typedef atomic atomic_char16_t; typedef atomic atomic_char32_t; typedef atomic atomic_wchar_t; typedef atomic atomic_int_least8_t; typedef atomic atomic_uint_least8_t; typedef atomic atomic_int_least16_t; typedef atomic atomic_uint_least16_t; typedef atomic atomic_int_least32_t; typedef atomic atomic_uint_least32_t; typedef atomic atomic_int_least64_t; typedef atomic atomic_uint_least64_t; typedef atomic atomic_int_fast8_t; typedef atomic atomic_uint_fast8_t; typedef atomic atomic_int_fast16_t; typedef atomic atomic_uint_fast16_t; typedef atomic atomic_int_fast32_t; typedef atomic atomic_uint_fast32_t; typedef atomic atomic_int_fast64_t; typedef atomic atomic_uint_fast64_t; typedef atomic atomic_intptr_t; typedef atomic atomic_uintptr_t; typedef atomic atomic_size_t; typedef atomic atomic_ptrdiff_t; typedef atomic atomic_intmax_t; typedef atomic atomic_uintmax_t; // fences void atomic_thread_fence(memory_order m) noexcept; void atomic_signal_fence(memory_order m) noexcept; } // std */ #include <__config> #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #ifdef _LIBCPP_HAS_NO_THREADS #error is not supported on this single threaded system #else // !_LIBCPP_HAS_NO_THREADS _LIBCPP_BEGIN_NAMESPACE_STD #if !__has_feature(cxx_atomic) && _GNUC_VER < 407 #error is not implemented #else 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 _GNUC_VER >= 407 namespace __gcc_atomic { template struct __gcc_atomic_t { - __gcc_atomic_t() _NOEXCEPT {} + +#if _GNUC_VER >= 501 + static_assert(is_trivially_copyable<_Tp>::value, + "std::atomic 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 template _Tp __create(); template typename enable_if__a_value = __create<_Td>()), char>::type __test_atomic_assignable(int); template __two __test_atomic_assignable(...); template struct __can_assign { static const bool value = sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); }; -static inline constexpr int __to_gcc_order(memory_order __order) { +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 constexpr int __to_gcc_failure_order(memory_order __order) { +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 static inline typename enable_if< __gcc_atomic::__can_assign::value>::type __c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { __a->__a_value = __val; } template static inline typename enable_if< !__gcc_atomic::__can_assign::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(&__a->__a_value); volatile char* end = to + sizeof(_Tp); char* from = reinterpret_cast(&__val); while (to != end) { *to++ = *from++; } } template 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 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 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 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 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 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 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 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 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 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 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 struct __skip_amt { enum {value = 1}; }; template 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 struct __skip_amt<_Tp[]> { }; template struct __skip_amt<_Tp[n]> { }; template 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 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 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 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 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 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 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 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 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 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 // _GNUC_VER >= 407 template inline _LIBCPP_INLINE_VISIBILITY _Tp kill_dependency(_Tp __y) _NOEXCEPT { return __y; } // general atomic template ::value && !is_same<_Tp, bool>::value> struct __atomic_base // false { mutable _Atomic(_Tp) __a_; _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const volatile _NOEXCEPT { #if __has_feature(cxx_atomic) return __c11_atomic_is_lock_free(sizeof(_Tp)); #else return __atomic_is_lock_free(sizeof(_Tp), 0); #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 }; // atomic template 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 template 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 template 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 inline _LIBCPP_INLINE_VISIBILITY bool atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT { return __o->is_lock_free(); } template inline _LIBCPP_INLINE_VISIBILITY bool atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT { return __o->is_lock_free(); } // atomic_init template inline _LIBCPP_INLINE_VISIBILITY void atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { __c11_atomic_init(&__o->__a_, __d); } template inline _LIBCPP_INLINE_VISIBILITY void atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { __c11_atomic_init(&__o->__a_, __d); } // atomic_store template inline _LIBCPP_INLINE_VISIBILITY void atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { __o->store(__d); } template inline _LIBCPP_INLINE_VISIBILITY void atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { __o->store(__d); } // atomic_store_explicit template inline _LIBCPP_INLINE_VISIBILITY void atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT { __o->store(__d, __m); } template inline _LIBCPP_INLINE_VISIBILITY void atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT { __o->store(__d, __m); } // atomic_load template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT { return __o->load(); } template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_load(const atomic<_Tp>* __o) _NOEXCEPT { return __o->load(); } // atomic_load_explicit template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT { return __o->load(__m); } template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT { return __o->load(__m); } // atomic_exchange template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { return __o->exchange(__d); } template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT { return __o->exchange(__d); } // atomic_exchange_explicit template inline _LIBCPP_INLINE_VISIBILITY _Tp atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT { return __o->exchange(__d, __m); } template 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 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 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 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 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 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 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 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 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 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 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 inline _LIBCPP_INLINE_VISIBILITY _Tp* atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT { return __o->fetch_add(__op); } template 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 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 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 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 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 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 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 inline _LIBCPP_INLINE_VISIBILITY _Tp* atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT { return __o->fetch_sub(__op); } template 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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) {} #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 atomic_bool; typedef atomic atomic_char; typedef atomic atomic_schar; typedef atomic atomic_uchar; typedef atomic atomic_short; typedef atomic atomic_ushort; typedef atomic atomic_int; typedef atomic atomic_uint; typedef atomic atomic_long; typedef atomic atomic_ulong; typedef atomic atomic_llong; typedef atomic atomic_ullong; typedef atomic atomic_char16_t; typedef atomic atomic_char32_t; typedef atomic atomic_wchar_t; typedef atomic atomic_int_least8_t; typedef atomic atomic_uint_least8_t; typedef atomic atomic_int_least16_t; typedef atomic atomic_uint_least16_t; typedef atomic atomic_int_least32_t; typedef atomic atomic_uint_least32_t; typedef atomic atomic_int_least64_t; typedef atomic atomic_uint_least64_t; typedef atomic atomic_int_fast8_t; typedef atomic atomic_uint_fast8_t; typedef atomic atomic_int_fast16_t; typedef atomic atomic_uint_fast16_t; typedef atomic atomic_int_fast32_t; typedef atomic atomic_uint_fast32_t; typedef atomic atomic_int_fast64_t; typedef atomic atomic_uint_fast64_t; typedef atomic atomic_intptr_t; typedef atomic atomic_uintptr_t; typedef atomic atomic_size_t; typedef atomic atomic_ptrdiff_t; typedef atomic atomic_intmax_t; typedef atomic atomic_uintmax_t; #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(__v) {__v} // lock-free property #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 // !__has_feature(cxx_atomic) _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS #endif // _LIBCPP_ATOMIC