mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
refactor(rdtsc): clean up code overall
Change type of chrono return to be auto Co-authored-by: Maurice Heumann <MauriceHeumann@gmail.com> simplify conditional compile and add #else to prevent clang-tidy breaking CI Co-authored-by: Maurice Heumann <MauriceHeumann@gmail.com>
This commit is contained in:
@@ -449,18 +449,8 @@ void windows_emulator::setup_hooks()
|
||||
|
||||
this->emu().hook_instruction(x64_hookable_instructions::rdtsc, [&] {
|
||||
uint64_t ticks = this->clock_->timestamp_counter();
|
||||
static uint64_t fake_ticks = ticks;
|
||||
static uint64_t prev_ticks = 0;
|
||||
|
||||
if (ticks > prev_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);
|
||||
this->emu().reg(x64_register::rdx, (fake_ticks >> 32) & 0xFFFFFFFF);
|
||||
this->emu().reg(x64_register::rax, ticks & 0xFFFFFFFF);
|
||||
this->emu().reg(x64_register::rdx, (ticks >> 32) & 0xFFFFFFFF);
|
||||
return instruction_hook_continuation::skip_instruction;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user