[*] Updated atomics
This commit is contained in:
parent
471d04a9c8
commit
01d9b6754f
@ -11,6 +11,41 @@
|
||||
#include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_COMPILER_MSVC)
|
||||
using AuAInt8 = volatile AuInt8;
|
||||
using AuAUInt8 = volatile AuUInt8;
|
||||
|
||||
using AuAInt16 = volatile AuInt16;
|
||||
using AuAUInt16 = volatile AuUInt16;
|
||||
|
||||
using AuAInt32 = volatile AuInt32;
|
||||
using AuAUInt32 = volatile AuUInt32;
|
||||
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
using AuAInt64 = volatile AuInt64;
|
||||
using AuAUInt64 = volatile AuUInt64;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
using AuAInt8 = _Atomic(int8_t);
|
||||
using AuAUInt8 = _Atomic(uint8_t);
|
||||
|
||||
using AuAInt16 = _Atomic(int16_t);
|
||||
using AuAUInt16 = _Atomic(uint16_t);
|
||||
|
||||
|
||||
using AuAInt32 = _Atomic(int32_t);
|
||||
using AuAUInt32 = _Atomic(uint32_t);
|
||||
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
using AuAInt64 = _Atomic(int64_t);
|
||||
using AuAUInt64 = _Atomic(uint64_t);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Defines:
|
||||
// AuAtomicCompareExchange (no weak variants yet)
|
||||
// -
|
||||
@ -380,8 +415,9 @@ template <class T>
|
||||
inline auline T AuAtomicUtils<T>::Load(T *in)
|
||||
{
|
||||
#if defined(AURORA_COMPILER_MSVC) && (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
|
||||
::_ReadWriteBarrier(); // compile-time only! we use this to prevent optimizations. x86/64 does not care so long as we're aligned.
|
||||
return *in;
|
||||
const auto read = *in;
|
||||
::_ReadWriteBarrier();
|
||||
return read;
|
||||
#elif defined(AURORA_COMPILER_MSVC)
|
||||
::MemoryBarrier(); // works on all legacy MSVC targets including AMD64, IA64, and POWER
|
||||
return *in;
|
||||
@ -528,8 +564,7 @@ inline auline
|
||||
void AuAtomicUtils<AuUInt8>::ClearU8Lock(AuUInt8 *in)
|
||||
{
|
||||
#if defined(AURORA_COMPILER_MSVC) && (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
|
||||
*in = 0;
|
||||
::_ReadWriteBarrier();
|
||||
::_InterlockedExchange8((volatile char *)in, 0);
|
||||
#elif defined(AURORA_COMPILER_MSVC)
|
||||
// i think this will work on aarch64 and most risc architectures
|
||||
InterlockedAndRelease((volatile LONG *)in, ~0xFF);
|
||||
|
Loading…
Reference in New Issue
Block a user