[*] Nothing to see here.

This commit is contained in:
Reece Wilson 2024-11-23 04:04:57 +00:00
parent 75fddc41d9
commit 26196750d4
2 changed files with 36 additions and 21 deletions

View File

@ -427,10 +427,26 @@ inline void AuAtomicUtils<T>::StoreWeak(T *in, T val)
*in = val;
}
/// noooo whyyyy dont you just use C[++] spec <current year>
/// its a fucking mystery to me
/// and we havent even gone into why the theory behind these c11 and std atomics are wrong
/// fuck you, and fuck all this
/// some fun bedtime reading: https://google.com/?q=%22address+argument+to+atomic+operation+must+be+a+pointer+to+_Atomic+type%22
#if defined(AURORA_COMPILER_CLANG)
#if defined(CLANG_IS_HOPELESS) || (defined(_LIBCPP_HAS_MUSL_LIBC) && _LIBCPP_HAS_MUSL_LIBC)
#define ATOMIC_PREFIX_HAX(name) name
#define __ATOMIC_ACQUIRE2
#define __ATOMIC_RELEASE2
#else
#define ATOMIC_PREFIX_HAX(name) __c11_ ## name
#define __ATOMIC_ACQUIRE2 ,__ATOMIC_ACQUIRE
#define __ATOMIC_RELEASE2 ,__ATOMIC_RELEASE
#endif
#else
#define ATOMIC_PREFIX_HAX(name) __ ## name ## _explicit
#define __ATOMIC_ACQUIRE2 ,__ATOMIC_ACQUIRE
#define __ATOMIC_RELEASE2 ,__ATOMIC_RELEASE
#endif
template <class T>
@ -449,35 +465,35 @@ inline auline T AuAtomicUtils<T>::Load(T *in)
#if defined(AURORA_COMPILER_CLANG)
if constexpr (AuIsSame_v<AuUInt8, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt8) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt8) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuInt8, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt8) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt8) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuUInt16, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt16) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt16) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuInt16, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt16) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt16) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuUInt32, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt32) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt32) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuInt32, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt32) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt32) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuUInt64, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt64) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuUInt64) *)(in) __ATOMIC_ACQUIRE2);
}
else if constexpr (AuIsSame_v<AuInt64, T>)
{
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt64) *)(in), __ATOMIC_ACQUIRE);
return ATOMIC_PREFIX_HAX(atomic_load)((_Atomic(AuInt64) *)(in) __ATOMIC_ACQUIRE2);
}
else
{
@ -554,35 +570,35 @@ inline auline void AuAtomicUtils<T>::Store(T *in, T val)
#endif
if constexpr (AuIsSame_v<AuUInt8, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt8) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt8) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuInt8, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt8) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt8) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuUInt16, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt16) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt16) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuInt16, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt16) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt16) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuUInt32, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt32) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt32) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuInt32, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt32) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt32) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuUInt64, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt64) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt64) *)(in), val __ATOMIC_RELEASE2);
}
else if constexpr (AuIsSame_v<AuInt64, T>)
{
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt64) *)(in), val, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuInt64) *)(in), val __ATOMIC_RELEASE2);
}
else
{
@ -611,7 +627,7 @@ void AuAtomicUtils<AuUInt8>::ClearU8Lock(AuUInt8 *in)
#endif
// Clear the lock
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt8) *)(in), 0, __ATOMIC_RELEASE);
ATOMIC_PREFIX_HAX(atomic_store)((_Atomic(AuUInt8) *)(in), 0 __ATOMIC_RELEASE2);
#endif
}

View File

@ -21,13 +21,12 @@
#if __has_include(<immintrin.h>)
#include <immintrin.h>
#endif
#endif
#if defined(AURORA_ARCH_X64)
#include <nmmintrin.h>
#if __has_include(<nmmintrin.h>)
#include <nmmintrin.h>
#endif
#endif
#include <auROXTL/auMemoryUtils.hpp>
#include <auROXTL/auCopyMoveUtils.hpp>
#include <auROXTL/auSwapExchangeUtils.hpp>