diff --git a/Utilities/mutex.cpp b/Utilities/mutex.cpp index 6f097f964e..f7e32eaf3a 100644 --- a/Utilities/mutex.cpp +++ b/Utilities/mutex.cpp @@ -1,5 +1,7 @@ #include "mutex.h" +#include "util/asm.hpp" + void shared_mutex::imp_lock_shared(u32 val) { ensure(val < c_err); // "shared_mutex underflow" diff --git a/Utilities/sema.cpp b/Utilities/sema.cpp index 355454141f..2d4f325b19 100644 --- a/Utilities/sema.cpp +++ b/Utilities/sema.cpp @@ -1,5 +1,7 @@ #include "sema.h" +#include "util/asm.hpp" + void semaphore_base::imp_wait() { for (int i = 0; i < 10; i++) diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index 5bf2d3ddd6..54b49bd42b 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -10,7 +10,7 @@ #include "cellGcmSys.h" #include "sysPrxForUser.h" -#include +#include "util/asm.hpp" LOG_CHANNEL(cellGcmSys); diff --git a/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp b/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp index ea6ced0c4a..08b2a44ed3 100644 --- a/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp @@ -6,6 +6,8 @@ #include "Emu/Cell/lv2/sys_mutex.h" #include "sysPrxForUser.h" +#include "util/asm.hpp" + LOG_CHANNEL(sysPrxForUser); error_code sys_lwmutex_create(ppu_thread& ppu, vm::ptr lwmutex, vm::ptr attr) diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 54b0f81cc2..da70bf7865 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -21,6 +21,8 @@ #include "sys_event.h" #include "sys_fs.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_spu); extern u64 get_timebased_time(); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 3477483ba7..7d5565f636 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -9,6 +9,8 @@ #include "Emu/RSX/rsx_methods.h" #include "Emu/Memory/vm_locking.h" +#include "util/asm.hpp" + namespace vk { VkCompareOp get_compare_func(rsx::comparison_function op, bool reverse_direction = false); diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index 818d379e22..c3f47ec57e 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -284,4 +284,14 @@ namespace utils return std::countl_zero(arg) + 64; #endif } + + // Synchronization helper (cache-friendly busy waiting) + inline void busy_wait(std::size_t cycles = 3000) + { + const u64 start = __rdtsc(); + do _mm_pause(); + while (__rdtsc() - start < cycles); + } } // namespace utils + +using utils::busy_wait; diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 9ddd2f265b..3cc9729d7c 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -905,10 +905,3 @@ struct value_hash return static_cast(value) >> Shift; } }; - -// Synchronization helper (cache-friendly busy waiting) -inline void busy_wait(std::size_t cycles = 3000) -{ - const u64 s = __rdtsc(); - do _mm_pause(); while (__rdtsc() - s < cycles); -}