1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Move busy_wait() to asm.hpp

This commit is contained in:
Nekotekina 2020-12-18 09:47:08 +03:00
parent 908465b274
commit 4cfa9b11f3
8 changed files with 21 additions and 8 deletions

View File

@ -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"

View File

@ -1,5 +1,7 @@
#include "sema.h"
#include "util/asm.hpp"
void semaphore_base::imp_wait()
{
for (int i = 0; i < 10; i++)

View File

@ -10,7 +10,7 @@
#include "cellGcmSys.h"
#include "sysPrxForUser.h"
#include <thread>
#include "util/asm.hpp"
LOG_CHANNEL(cellGcmSys);

View File

@ -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<sys_lwmutex_t> lwmutex, vm::ptr<sys_lwmutex_attribute_t> attr)

View File

@ -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();

View File

@ -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);

View File

@ -284,4 +284,14 @@ namespace utils
return std::countl_zero<u64>(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;

View File

@ -905,10 +905,3 @@ struct value_hash
return static_cast<std::size_t>(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);
}