mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-06 01:12:33 +00:00
fix build
This commit is contained in:
parent
454079e438
commit
c3ce2674c3
@ -172,8 +172,8 @@ static s32 clock_gettime(u32 clock_id, struct timespec* ts) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, struct timespec* ts) {
|
||||||
if (tp == nullptr) {
|
if (ts == nullptr) {
|
||||||
return ORBIS_KERNEL_ERROR_EFAULT;
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,11 @@ int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
break;
|
break;
|
||||||
case ORBIS_CLOCK_SECOND:
|
case ORBIS_CLOCK_SECOND:
|
||||||
case ORBIS_CLOCK_REALTIME_FAST:
|
case ORBIS_CLOCK_REALTIME_FAST:
|
||||||
|
#ifndef __APPLE__
|
||||||
pclock_id = CLOCK_REALTIME_COARSE;
|
pclock_id = CLOCK_REALTIME_COARSE;
|
||||||
|
#else
|
||||||
|
pclock_id = CLOCK_REALTIME;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case ORBIS_CLOCK_UPTIME:
|
case ORBIS_CLOCK_UPTIME:
|
||||||
case ORBIS_CLOCK_UPTIME_PRECISE:
|
case ORBIS_CLOCK_UPTIME_PRECISE:
|
||||||
@ -195,15 +199,19 @@ int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
break;
|
break;
|
||||||
case ORBIS_CLOCK_UPTIME_FAST:
|
case ORBIS_CLOCK_UPTIME_FAST:
|
||||||
case ORBIS_CLOCK_MONOTONIC_FAST:
|
case ORBIS_CLOCK_MONOTONIC_FAST:
|
||||||
|
#ifndef __APPLE__
|
||||||
pclock_id = CLOCK_MONOTONIC_COARSE;
|
pclock_id = CLOCK_MONOTONIC_COARSE;
|
||||||
|
#else
|
||||||
|
pclock_id = CLOCK_MONOTONIC;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case ORBIS_CLOCK_THREAD_CPUTIME_ID:
|
case ORBIS_CLOCK_THREAD_CPUTIME_ID:
|
||||||
pclock_id = CLOCK_THREAD_CPUTIME_ID;
|
pclock_id = CLOCK_THREAD_CPUTIME_ID;
|
||||||
break;
|
break;
|
||||||
case ORBIS_CLOCK_PROCTIME: {
|
case ORBIS_CLOCK_PROCTIME: {
|
||||||
const auto us = sceKernelGetProcessTime();
|
const auto us = sceKernelGetProcessTime();
|
||||||
tp->tv_sec = us / 1'000'000;
|
ts->tv_sec = us / 1'000'000;
|
||||||
tp->tv_nsec = (us % 1'000'000) * 1000;
|
ts->tv_nsec = (us % 1'000'000) * 1000;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case ORBIS_CLOCK_VIRTUAL: {
|
case ORBIS_CLOCK_VIRTUAL: {
|
||||||
@ -213,15 +221,16 @@ int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
const u64 ns = FileTimeTo100Ns(ut);
|
const u64 ns = FileTimeTo100Ns(ut);
|
||||||
tp->tv_sec = ns / 10'000'000;
|
ts->tv_sec = ns / 10'000'000;
|
||||||
tp->tv_nsec = (ns % 10'000'000) * 100;
|
ts->tv_nsec = (ns % 10'000'000) * 100;
|
||||||
#else
|
#else
|
||||||
struct rusage ru;
|
struct rusage ru;
|
||||||
const auto res = getrusage(RUSAGE_SELF, &ru);
|
const auto res = getrusage(RUSAGE_SELF, &ru);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
*tp = ru.ru_utime;
|
ts->tv_sec = ru.ru_utime.tv_sec;
|
||||||
|
ts->tv_nsec = ru.ru_utime.tv_usec * 1000;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -232,15 +241,16 @@ int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
const u64 ns = FileTimeTo100Ns(kt);
|
const u64 ns = FileTimeTo100Ns(kt);
|
||||||
tp->tv_sec = ns / 10'000'000;
|
ts->tv_sec = ns / 10'000'000;
|
||||||
tp->tv_nsec = (ns % 10'000'000) * 100;
|
ts->tv_nsec = (ns % 10'000'000) * 100;
|
||||||
#else
|
#else
|
||||||
struct rusage ru;
|
struct rusage ru;
|
||||||
const auto res = getrusage(RUSAGE_SELF, &ru);
|
const auto res = getrusage(RUSAGE_SELF, &ru);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
*tp = ru.ru_stime;
|
ts->tv_sec = ru.ru_stime.tv_sec;
|
||||||
|
ts->tv_nsec = ru.ru_stime.tv_usec * 1000;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -255,23 +265,17 @@ int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec ts;
|
return clock_gettime(pclock_id, ts);
|
||||||
const auto res = clock_gettime(pclock_id, &ts);
|
|
||||||
if (res < 0) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
tp->tv_sec = ts.tv_sec;
|
|
||||||
tp->tv_nsec = ts.tv_nsec;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
||||||
const auto res = orbis_clock_gettime(clock_id, tp);
|
struct timespec ts;
|
||||||
|
const auto res = orbis_clock_gettime(clock_id, &ts);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return ErrnoToSceKernelError(res);
|
return ErrnoToSceKernelError(res);
|
||||||
}
|
}
|
||||||
|
tp->tv_sec = ts.tv_sec;
|
||||||
|
tp->tv_nsec = ts.tv_nsec;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user