mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 19:53:56 +00:00
refactor(rdtsc): clean up tick logic,
fix intrinsics, and resolve x86 compiler issues - fix `time.hpp` compiler warnings (errors) and use proper intrinsic for gcc - simplify tick calculation logic - fix: exclude intrinsics include for non x86 builds and fix style - fix: get() on clock_ unique ptr
This commit is contained in:
@@ -448,21 +448,15 @@ void windows_emulator::setup_hooks()
|
||||
});
|
||||
|
||||
this->emu().hook_instruction(x64_hookable_instructions::rdtsc, [&] {
|
||||
uint64_t ticks = this->clock_.get()->timestamp_counter();
|
||||
uint64_t ticks = this->clock_->timestamp_counter();
|
||||
static uint64_t fake_ticks = ticks;
|
||||
static uint64_t prev_ticks = 0;
|
||||
|
||||
if (prev_ticks != 0)
|
||||
if (ticks > prev_ticks)
|
||||
{
|
||||
if (ticks > prev_ticks)
|
||||
{
|
||||
fake_ticks += (ticks - prev_ticks);
|
||||
}
|
||||
}
|
||||
if (fake_ticks > ticks)
|
||||
{
|
||||
fake_ticks = ticks;
|
||||
fake_ticks += (ticks - prev_ticks);
|
||||
}
|
||||
fake_ticks = std::min(fake_ticks, ticks);
|
||||
prev_ticks = ticks;
|
||||
|
||||
this->emu().reg(x64_register::rax, fake_ticks & 0xFFFFFFFF);
|
||||
|
||||
Reference in New Issue
Block a user