libraries: kernel: fix for inaccurate `sceKernelGetProcessTime`
This commit is contained in:
parent
6fd4264b5d
commit
78e24852f8
|
@ -18,16 +18,16 @@ NativeClock::NativeClock()
|
||||||
us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)},
|
us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)},
|
||||||
ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {}
|
ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeNS() const {
|
u64 NativeClock::GetTimeNS(u64 base_ptc /*= 0*/) const {
|
||||||
return MultiplyHigh(GetUptime(), ns_rdtsc_factor);
|
return MultiplyHigh(GetUptime() - base_ptc, ns_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeUS() const {
|
u64 NativeClock::GetTimeUS(u64 base_ptc /*= 0*/) const {
|
||||||
return MultiplyHigh(GetUptime(), us_rdtsc_factor);
|
return MultiplyHigh(GetUptime() - base_ptc, us_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeMS() const {
|
u64 NativeClock::GetTimeMS(u64 base_ptc /*= 0*/) const {
|
||||||
return MultiplyHigh(GetUptime(), ms_rdtsc_factor);
|
return MultiplyHigh(GetUptime() - base_ptc, ms_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetUptime() const {
|
u64 NativeClock::GetUptime() const {
|
||||||
|
|
|
@ -16,9 +16,9 @@ public:
|
||||||
return rdtsc_frequency;
|
return rdtsc_frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetTimeNS() const;
|
u64 GetTimeNS(u64 base_ptc = 0) const;
|
||||||
u64 GetTimeUS() const;
|
u64 GetTimeUS(u64 base_ptc = 0) const;
|
||||||
u64 GetTimeMS() const;
|
u64 GetTimeMS(u64 base_ptc = 0) const;
|
||||||
u64 GetUptime() const;
|
u64 GetUptime() const;
|
||||||
u64 GetProcessTimeUS() const;
|
u64 GetProcessTimeUS() const;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "common/debug.h"
|
||||||
#include "common/native_clock.h"
|
#include "common/native_clock.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/kernel/time_management.h"
|
#include "core/libraries/kernel/time_management.h"
|
||||||
|
@ -30,7 +31,8 @@ u64 PS4_SYSV_ABI sceKernelGetTscFrequency() {
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetProcessTime() {
|
u64 PS4_SYSV_ABI sceKernelGetProcessTime() {
|
||||||
return clock->GetProcessTimeUS();
|
// TODO: this timer should support suspends, so initial ptc needs to be updated on wake up
|
||||||
|
return clock->GetTimeUS(initial_ptc);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter() {
|
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter() {
|
||||||
|
|
Loading…
Reference in New Issue