8#ifndef INCLUDED_BSLS_ATOMICOPERATIONS_ARM64_WIN_MSVC
9#define INCLUDED_BSLS_ATOMICOPERATIONS_ARM64_WIN_MSVC
54#include <bsls_atomicoperations_default.h>
58#if defined(BSLS_PLATFORM_CPU_ARM) && defined(BSLS_PLATFORM_CPU_64_BIT) && \
59 defined(BSLS_PLATFORM_CMP_MSVC)
66struct AtomicOperations_ARM64_WIN_MSVC;
67typedef AtomicOperations_ARM64_WIN_MSVC AtomicOperations_Imp;
74struct Atomic_TypeTraits<AtomicOperations_ARM64_WIN_MSVC>
85 volatile Types::Int64 d_value;
91 volatile
unsigned int d_value;
97 volatile Types::Uint64 d_value;
103 void * volatile d_value;
111struct AtomicOperations_ARM64_WIN_MSVC
112 : AtomicOperations_Default64<AtomicOperations_ARM64_WIN_MSVC>
114 typedef Atomic_TypeTraits<AtomicOperations_ARM64_WIN_MSVC> AtomicTypes;
118 static int getInt(
const AtomicTypes::Int *atomicInt);
120 static int getIntAcquire(
const AtomicTypes::Int *atomicInt);
122 static void setInt(AtomicTypes::Int *atomicInt,
int value);
124 static void setIntRelease(AtomicTypes::Int *atomicInt,
int value);
126 static int swapInt(AtomicTypes::Int *atomicInt,
int swapValue);
128 static int testAndSwapInt(AtomicTypes::Int *atomicInt,
132 static int addIntNv(AtomicTypes::Int *atomicInt,
int value);
136 static Types::Int64 getInt64(
const AtomicTypes::Int64 *atomicInt);
138 static void setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value);
140 static Types::Int64 swapInt64(AtomicTypes::Int64 *atomicInt,
141 Types::Int64 swapValue);
143 static Types::Int64 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
144 Types::Int64 compareValue,
145 Types::Int64 swapValue);
147 static Types::Int64 addInt64Nv(AtomicTypes::Int64 *atomicInt,
160#define BSLS_ATOMIC_FENCE() \
161 __dmb(_ARM64_BARRIER_ISH)
164int AtomicOperations_ARM64_WIN_MSVC::getInt(
const AtomicTypes::Int *atomicInt)
166 unsigned int result = __ldar32(
167 reinterpret_cast<const volatile unsigned int *
>(&atomicInt->d_value));
169 return static_cast<int>(result);
173int AtomicOperations_ARM64_WIN_MSVC::getIntAcquire(
174 const AtomicTypes::Int *atomicInt)
176 unsigned int result = __ldar32(
177 reinterpret_cast<const volatile unsigned int *
>(&atomicInt->d_value));
179 return static_cast<int>(result);
183void AtomicOperations_ARM64_WIN_MSVC::setInt(AtomicTypes::Int *atomicInt,
187 __stlr32(
reinterpret_cast<volatile unsigned int *
>(&atomicInt->d_value),
188 static_cast<unsigned int>(value));
193void AtomicOperations_ARM64_WIN_MSVC::setIntRelease(
194 AtomicTypes::Int *atomicInt,
198 __stlr32(
reinterpret_cast<volatile unsigned int *
>(&atomicInt->d_value),
199 static_cast<unsigned int>(value));
203int AtomicOperations_ARM64_WIN_MSVC::
204 swapInt(AtomicTypes::Int *atomicInt,
int swapValue)
206 return _InterlockedExchange(
207 reinterpret_cast<long volatile *
>(&atomicInt->d_value),
212int AtomicOperations_ARM64_WIN_MSVC::
213 testAndSwapInt(AtomicTypes::Int *atomicInt,
217 return _InterlockedCompareExchange(
218 reinterpret_cast<long volatile *
>(&atomicInt->d_value),
224int AtomicOperations_ARM64_WIN_MSVC::
225 addIntNv(AtomicTypes::Int *atomicInt,
int value)
227 return static_cast<int>(
228 static_cast<unsigned int>(_InterlockedExchangeAdd(
229 reinterpret_cast<long volatile *
>(&atomicInt->d_value),
237Types::Int64 AtomicOperations_ARM64_WIN_MSVC::getInt64(
238 const AtomicTypes::Int64 *atomicInt)
240 unsigned long long result =
241 __ldar64(
reinterpret_cast<const volatile unsigned long long *
>(
242 &atomicInt->d_value));
244 return static_cast<Types::Int64
>(result);
248void AtomicOperations_ARM64_WIN_MSVC::setInt64(AtomicTypes::Int64 *atomicInt,
253 reinterpret_cast<volatile unsigned long long *
>(&atomicInt->d_value),
254 static_cast<unsigned long long>(value));
260Types::Int64 AtomicOperations_ARM64_WIN_MSVC::
261 swapInt64(AtomicTypes::Int64 *atomicInt,
262 Types::Int64 swapValue)
264 return _InterlockedExchange64(
270Types::Int64 AtomicOperations_ARM64_WIN_MSVC::
271 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
272 Types::Int64 compareValue,
273 Types::Int64 swapValue)
275 return _InterlockedCompareExchange64(
282Types::Int64 AtomicOperations_ARM64_WIN_MSVC::
283 addInt64Nv(AtomicTypes::Int64 *atomicInt,
286 return static_cast<Types::Int64
>(
287 static_cast<Types::Uint64
>(
288 _InterlockedExchangeAdd64(&atomicInt->d_value, value)) +
293#undef BSLS_ATOMIC_FENCE
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691