Path: blob/main/contrib/llvm-project/libcxx/include/__atomic/cxx_atomic_impl.h
35262 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H9#define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H1011#include <__atomic/memory_order.h>12#include <__atomic/to_gcc_order.h>13#include <__config>14#include <__memory/addressof.h>15#include <__type_traits/is_assignable.h>16#include <__type_traits/is_trivially_copyable.h>17#include <__type_traits/remove_const.h>18#include <cstddef>1920#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21# pragma GCC system_header22#endif2324_LIBCPP_BEGIN_NAMESPACE_STD2526#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)2728// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because29// the default operator= in an object is not volatile, a byte-by-byte copy30// is required.31template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>32_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) {33__a_value = __val;34}35template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>36_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) {37volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value));38volatile char* __end = __to + sizeof(_Tp);39volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val));40while (__to != __end)41*__to++ = *__from++;42}4344template <typename _Tp>45struct __cxx_atomic_base_impl {46_LIBCPP_HIDE_FROM_ABI47# ifndef _LIBCPP_CXX03_LANG48__cxx_atomic_base_impl() _NOEXCEPT = default;49# else50__cxx_atomic_base_impl() _NOEXCEPT : __a_value() {51}52# endif // _LIBCPP_CXX03_LANG53_LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {}54_Tp __a_value;55};5657template <typename _Tp>58_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {59__cxx_atomic_assign_volatile(__a->__a_value, __val);60}6162template <typename _Tp>63_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {64__a->__a_value = __val;65}6667_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) {68__atomic_thread_fence(__to_gcc_order(__order));69}7071_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) {72__atomic_signal_fence(__to_gcc_order(__order));73}7475template <typename _Tp>76_LIBCPP_HIDE_FROM_ABI void77__cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {78__atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));79}8081template <typename _Tp>82_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {83__atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));84}8586template <typename _Tp>87_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {88_Tp __ret;89__atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));90return __ret;91}9293template <typename _Tp>94_LIBCPP_HIDE_FROM_ABI void95__cxx_atomic_load_inplace(const volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {96__atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));97}9899template <typename _Tp>100_LIBCPP_HIDE_FROM_ABI void101__cxx_atomic_load_inplace(const __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {102__atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));103}104105template <typename _Tp>106_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {107_Tp __ret;108__atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));109return __ret;110}111112template <typename _Tp>113_LIBCPP_HIDE_FROM_ABI _Tp114__cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {115_Tp __ret;116__atomic_exchange(117std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));118return __ret;119}120121template <typename _Tp>122_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {123_Tp __ret;124__atomic_exchange(125std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));126return __ret;127}128129template <typename _Tp>130_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(131volatile __cxx_atomic_base_impl<_Tp>* __a,132_Tp* __expected,133_Tp __value,134memory_order __success,135memory_order __failure) {136return __atomic_compare_exchange(137std::addressof(__a->__a_value),138__expected,139std::addressof(__value),140false,141__to_gcc_order(__success),142__to_gcc_failure_order(__failure));143}144145template <typename _Tp>146_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(147__cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {148return __atomic_compare_exchange(149std::addressof(__a->__a_value),150__expected,151std::addressof(__value),152false,153__to_gcc_order(__success),154__to_gcc_failure_order(__failure));155}156157template <typename _Tp>158_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(159volatile __cxx_atomic_base_impl<_Tp>* __a,160_Tp* __expected,161_Tp __value,162memory_order __success,163memory_order __failure) {164return __atomic_compare_exchange(165std::addressof(__a->__a_value),166__expected,167std::addressof(__value),168true,169__to_gcc_order(__success),170__to_gcc_failure_order(__failure));171}172173template <typename _Tp>174_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(175__cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {176return __atomic_compare_exchange(177std::addressof(__a->__a_value),178__expected,179std::addressof(__value),180true,181__to_gcc_order(__success),182__to_gcc_failure_order(__failure));183}184185template <typename _Tp>186struct __skip_amt {187enum { value = 1 };188};189190template <typename _Tp>191struct __skip_amt<_Tp*> {192enum { value = sizeof(_Tp) };193};194195// FIXME: Haven't figured out what the spec says about using arrays with196// atomic_fetch_add. Force a failure rather than creating bad behavior.197template <typename _Tp>198struct __skip_amt<_Tp[]> {};199template <typename _Tp, int n>200struct __skip_amt<_Tp[n]> {};201202template <typename _Tp, typename _Td>203_LIBCPP_HIDE_FROM_ABI _Tp204__cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {205return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));206}207208template <typename _Tp, typename _Td>209_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {210return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));211}212213template <typename _Tp, typename _Td>214_LIBCPP_HIDE_FROM_ABI _Tp215__cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {216return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));217}218219template <typename _Tp, typename _Td>220_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {221return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));222}223224template <typename _Tp>225_LIBCPP_HIDE_FROM_ABI _Tp226__cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {227return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));228}229230template <typename _Tp>231_LIBCPP_HIDE_FROM_ABI _Tp232__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {233return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));234}235236template <typename _Tp>237_LIBCPP_HIDE_FROM_ABI _Tp238__cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {239return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));240}241242template <typename _Tp>243_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {244return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));245}246247template <typename _Tp>248_LIBCPP_HIDE_FROM_ABI _Tp249__cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {250return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));251}252253template <typename _Tp>254_LIBCPP_HIDE_FROM_ABI _Tp255__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {256return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));257}258259# define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0)260261#elif defined(_LIBCPP_HAS_C_ATOMIC_IMP)262263template <typename _Tp>264struct __cxx_atomic_base_impl {265_LIBCPP_HIDE_FROM_ABI266# ifndef _LIBCPP_CXX03_LANG267__cxx_atomic_base_impl() _NOEXCEPT = default;268# else269__cxx_atomic_base_impl() _NOEXCEPT : __a_value() {270}271# endif // _LIBCPP_CXX03_LANG272_LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}273_LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;274};275276# define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)277278_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT {279__c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order));280}281282_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {283__c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order));284}285286template <class _Tp>287_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {288__c11_atomic_init(std::addressof(__a->__a_value), __val);289}290template <class _Tp>291_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) _NOEXCEPT {292__c11_atomic_init(std::addressof(__a->__a_value), __val);293}294295template <class _Tp>296_LIBCPP_HIDE_FROM_ABI void297__cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT {298__c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));299}300template <class _Tp>301_LIBCPP_HIDE_FROM_ABI void302__cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT {303__c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));304}305306template <class _Tp>307_LIBCPP_HIDE_FROM_ABI _Tp308__cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {309using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;310return __c11_atomic_load(311const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));312}313template <class _Tp>314_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {315using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;316return __c11_atomic_load(317const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));318}319320template <class _Tp>321_LIBCPP_HIDE_FROM_ABI void322__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {323using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;324*__dst = __c11_atomic_load(325const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));326}327template <class _Tp>328_LIBCPP_HIDE_FROM_ABI void329__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {330using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;331*__dst = __c11_atomic_load(332const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));333}334335template <class _Tp>336_LIBCPP_HIDE_FROM_ABI _Tp337__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT {338return __c11_atomic_exchange(339std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));340}341template <class _Tp>342_LIBCPP_HIDE_FROM_ABI _Tp343__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) _NOEXCEPT {344return __c11_atomic_exchange(345std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));346}347348_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) {349// Avoid switch statement to make this a constexpr.350return __order == memory_order_release351? memory_order_relaxed352: (__order == memory_order_acq_rel ? memory_order_acquire : __order);353}354355template <class _Tp>356_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(357__cxx_atomic_base_impl<_Tp> volatile* __a,358_Tp* __expected,359_Tp __value,360memory_order __success,361memory_order __failure) _NOEXCEPT {362return __c11_atomic_compare_exchange_strong(363std::addressof(__a->__a_value),364__expected,365__value,366static_cast<__memory_order_underlying_t>(__success),367static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));368}369template <class _Tp>370_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(371__cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)372_NOEXCEPT {373return __c11_atomic_compare_exchange_strong(374std::addressof(__a->__a_value),375__expected,376__value,377static_cast<__memory_order_underlying_t>(__success),378static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));379}380381template <class _Tp>382_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(383__cxx_atomic_base_impl<_Tp> volatile* __a,384_Tp* __expected,385_Tp __value,386memory_order __success,387memory_order __failure) _NOEXCEPT {388return __c11_atomic_compare_exchange_weak(389std::addressof(__a->__a_value),390__expected,391__value,392static_cast<__memory_order_underlying_t>(__success),393static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));394}395template <class _Tp>396_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(397__cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)398_NOEXCEPT {399return __c11_atomic_compare_exchange_weak(400std::addressof(__a->__a_value),401__expected,402__value,403static_cast<__memory_order_underlying_t>(__success),404static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));405}406407template <class _Tp>408_LIBCPP_HIDE_FROM_ABI _Tp409__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {410return __c11_atomic_fetch_add(411std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));412}413template <class _Tp>414_LIBCPP_HIDE_FROM_ABI _Tp415__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {416return __c11_atomic_fetch_add(417std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));418}419420template <class _Tp>421_LIBCPP_HIDE_FROM_ABI _Tp*422__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {423return __c11_atomic_fetch_add(424std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));425}426template <class _Tp>427_LIBCPP_HIDE_FROM_ABI _Tp*428__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {429return __c11_atomic_fetch_add(430std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));431}432433template <class _Tp>434_LIBCPP_HIDE_FROM_ABI _Tp435__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {436return __c11_atomic_fetch_sub(437std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));438}439template <class _Tp>440_LIBCPP_HIDE_FROM_ABI _Tp441__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {442return __c11_atomic_fetch_sub(443std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));444}445template <class _Tp>446_LIBCPP_HIDE_FROM_ABI _Tp*447__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {448return __c11_atomic_fetch_sub(449std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));450}451template <class _Tp>452_LIBCPP_HIDE_FROM_ABI _Tp*453__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {454return __c11_atomic_fetch_sub(455std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));456}457458template <class _Tp>459_LIBCPP_HIDE_FROM_ABI _Tp460__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {461return __c11_atomic_fetch_and(462std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));463}464template <class _Tp>465_LIBCPP_HIDE_FROM_ABI _Tp466__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {467return __c11_atomic_fetch_and(468std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));469}470471template <class _Tp>472_LIBCPP_HIDE_FROM_ABI _Tp473__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {474return __c11_atomic_fetch_or(475std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));476}477template <class _Tp>478_LIBCPP_HIDE_FROM_ABI _Tp479__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {480return __c11_atomic_fetch_or(481std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));482}483484template <class _Tp>485_LIBCPP_HIDE_FROM_ABI _Tp486__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {487return __c11_atomic_fetch_xor(488std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));489}490template <class _Tp>491_LIBCPP_HIDE_FROM_ABI _Tp492__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {493return __c11_atomic_fetch_xor(494std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));495}496497#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP498499template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >500struct __cxx_atomic_impl : public _Base {501static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");502503_LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;504_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}505};506507_LIBCPP_END_NAMESPACE_STD508509#endif // _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H510511512