summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/wall_clock.cpp16
-rw-r--r--src/common/wall_clock.h4
2 files changed, 12 insertions, 8 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
68std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 68std::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
88std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 92std::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
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
index 4d132c531..874448c27 100644
--- a/src/common/wall_clock.h
+++ b/src/common/wall_clock.h
@@ -53,7 +53,7 @@ private:
53 bool is_native; 53 bool is_native;
54}; 54};
55 55
56[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 56[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
57 u32 emulated_clock_frequency); 57 u64 emulated_clock_frequency);
58 58
59} // namespace Common 59} // namespace Common