mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-16 06:31:48 +00:00
sceKernelReadTsc only returns the CPU's RDTSC when the host RDTSC reader is available (currently 64-bit Windows); on Linux and macOS it falls back to the QPC-based Stopwatch. ResolveKernelTscFrequency, however, still consulted the CPUID-reported hardware TSC frequency in that case, so sceKernelGetTscFrequency reported a multi-GHz rate while ReadTsc was ticking at the Stopwatch frequency. A guest computing elapsed = readTscDelta / frequency then gets the wrong time on those platforms. Gate the calibrated/CPUID frequencies on RDTSC actually being available (the calibration path was already self-gated; the CPUID path was not) and otherwise report the Stopwatch frequency, keeping ReadTsc and GetTscFrequency consistent. The selection logic is extracted into a pure, host-independent helper so both branches can be unit tested, including a regression test asserting that a host without RDTSC reports the Stopwatch frequency rather than the hardware TSC.