From 26196750d41700ce88d19a20967a41566a3baa11 Mon Sep 17 00:00:00 2001 From: J Reece Wilson Date: Sat, 23 Nov 2024 04:04:57 +0000 Subject: [PATCH] [*] Nothing to see here. --- Include/auROXTL/auAtomic.hpp | 50 ++++++++++++++++++++++++------------ Include/auROXTLUtils.hpp | 7 +++-- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Include/auROXTL/auAtomic.hpp b/Include/auROXTL/auAtomic.hpp index a9df9d5..2697b62 100644 --- a/Include/auROXTL/auAtomic.hpp +++ b/Include/auROXTL/auAtomic.hpp @@ -427,10 +427,26 @@ inline void AuAtomicUtils::StoreWeak(T *in, T val) *in = val; } +/// noooo whyyyy dont you just use C[++] spec +/// 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 @@ -449,35 +465,35 @@ inline auline T AuAtomicUtils::Load(T *in) #if defined(AURORA_COMPILER_CLANG) if constexpr (AuIsSame_v) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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::Store(T *in, T val) #endif if constexpr (AuIsSame_v) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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::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 } diff --git a/Include/auROXTLUtils.hpp b/Include/auROXTLUtils.hpp index d3d38b8..56e092e 100644 --- a/Include/auROXTLUtils.hpp +++ b/Include/auROXTLUtils.hpp @@ -21,13 +21,12 @@ #if __has_include() #include #endif -#endif -#if defined(AURORA_ARCH_X64) - #include + #if __has_include() + #include + #endif #endif - #include #include #include