diff options
Diffstat (limited to 'src/common/wall_clock.cpp')
| -rw-r--r-- | src/common/wall_clock.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 081e0562f..9acf7551e 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp | |||
| @@ -65,16 +65,20 @@ private: | |||
| 65 | 65 | ||
| 66 | #ifdef ARCHITECTURE_x86_64 | 66 | #ifdef ARCHITECTURE_x86_64 |
| 67 | 67 | ||
| 68 | std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | 68 | std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, |
| 69 | u32 emulated_clock_frequency) { | 69 | u64 emulated_clock_frequency) { |
| 70 | const auto& caps = GetCPUCaps(); | 70 | const auto& caps = GetCPUCaps(); |
| 71 | u64 rtsc_frequency = 0; | 71 | u64 rtsc_frequency = 0; |
| 72 | if (caps.invariant_tsc) { | 72 | if (caps.invariant_tsc) { |
| 73 | rtsc_frequency = EstimateRDTSCFrequency(); | 73 | rtsc_frequency = EstimateRDTSCFrequency(); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | // Fallback to StandardWallClock if the hardware TSC does not have nanosecond precision. | 76 | // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than: |
| 77 | if (rtsc_frequency <= WallClock::NS_RATIO) { | 77 | // - A nanosecond |
| 78 | // - The emulated CPU frequency | ||
| 79 | // - The emulated clock counter frequency (CNTFRQ) | ||
| 80 | if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency || | ||
| 81 | rtsc_frequency <= emulated_clock_frequency) { | ||
| 78 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, | 82 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, |
| 79 | emulated_clock_frequency); | 83 | emulated_clock_frequency); |
| 80 | } else { | 84 | } else { |
| @@ -85,8 +89,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | |||
| 85 | 89 | ||
| 86 | #else | 90 | #else |
| 87 | 91 | ||
| 88 | std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | 92 | std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, |
| 89 | u32 emulated_clock_frequency) { | 93 | u64 emulated_clock_frequency) { |
| 90 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); | 94 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); |
| 91 | } | 95 | } |
| 92 | 96 | ||