wraping timespec into else so clockgettime only gets call on monotonic clock calls.

This commit is contained in:
Dmugetsu 2025-03-06 11:35:25 -06:00
parent a7c1b897e1
commit 9ba492a778

View File

@ -116,19 +116,18 @@ int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
return ORBIS_KERNEL_ERROR_EINVAL; return ORBIS_KERNEL_ERROR_EINVAL;
} }
struct timespec ts;
if (clock_gettime(pclock_id, &ts) != 0) {
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (pclock_id == CLOCK_REALTIME) { if (pclock_id == CLOCK_REALTIME) {
time_t raw_time = time(nullptr); time_t raw_time = time(nullptr);
if (raw_time == (time_t)(-1)) { if (raw_time == (time_t)(-1)) {
return ORBIS_KERNEL_ERROR_EINVAL; return ORBIS_KERNEL_ERROR_EINVAL;
} }
tp->tv_sec = static_cast<long>(raw_time); tp->tv_sec = static_cast<long>(raw_time);
tp->tv_nsec = ts.tv_nsec; tp->tv_nsec = 0;
} else { } else {
struct timespec ts;
if (clock_gettime(pclock_id, &ts) != 0) {
return ORBIS_KERNEL_ERROR_EINVAL;
}
tp->tv_sec = ts.tv_sec; tp->tv_sec = ts.tv_sec;
tp->tv_nsec = ts.tv_nsec; tp->tv_nsec = ts.tv_nsec;
} }
@ -136,6 +135,7 @@ int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) { int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) {
int result = sceKernelClockGettime(clock_id, time); int result = sceKernelClockGettime(clock_id, time);
if (result < 0) { if (result < 0) {