diff --git a/Utilities/lockless.h b/Utilities/lockless.h index 7bd0133346..87e726ee3c 100644 --- a/Utilities/lockless.h +++ b/Utilities/lockless.h @@ -2,7 +2,7 @@ #include "util/types.hpp" #include "util/atomic.hpp" -#include "util/asm.hpp" +#include "util/bless.hpp" //! Simple unshrinkable array base for concurrent access. Only growths automatically. //! There is no way to know the current size. The smaller index is, the faster it's accessed. diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 17051eb305..4aaaf7ef2d 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -611,6 +611,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 0adf76dedf..fb5bda5d41 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -2371,6 +2371,9 @@ Emu\GPU\RSX\Common + + Utilities + diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index 6afc032390..da0be9f1f6 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -410,23 +410,6 @@ namespace utils return factor1 > 0 && T{umax} / factor1 < factor2 ? T{umax} : static_cast(factor1 * factor2); } - // Hack. Pointer cast util to workaround UB. Use with extreme care. - template - [[nodiscard]] T* bless(U* ptr) - { -#ifdef _MSC_VER - return (T*)ptr; -#elif defined(ARCH_X64) - T* result; - __asm__("movq %1, %0;" : "=r" (result) : "r" (ptr) : "memory"); - return result; -#elif defined(ARCH_ARM64) - T* result; - __asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory"); - return result; -#endif - } - inline void trap() { #ifdef _M_X64 diff --git a/rpcs3/util/bless.hpp b/rpcs3/util/bless.hpp new file mode 100644 index 0000000000..49ffa8facb --- /dev/null +++ b/rpcs3/util/bless.hpp @@ -0,0 +1,21 @@ +#pragma once + +namespace utils +{ + // Hack. Pointer cast util to workaround UB. Use with extreme care. + template + [[nodiscard]] T* bless(U* ptr) + { +#ifdef _MSC_VER + return (T*)ptr; +#elif defined(ARCH_X64) + T* result; + __asm__("movq %1, %0;" : "=r" (result) : "r" (ptr) : "memory"); + return result; +#elif defined(ARCH_ARM64) + T* result; + __asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory"); + return result; +#endif + } +} diff --git a/rpcs3/util/shared_ptr.hpp b/rpcs3/util/shared_ptr.hpp index 23d4bfd974..109e28216a 100644 --- a/rpcs3/util/shared_ptr.hpp +++ b/rpcs3/util/shared_ptr.hpp @@ -3,7 +3,7 @@ #include #include #include "atomic.hpp" -#include "asm.hpp" +#include "bless.hpp" namespace stx {