mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(libkernel): handle clock_second 13 in clock_gettime and clock_getres
This commit is contained in:
@@ -101,7 +101,7 @@ int APS5_VABI clock_gettime_nid_postfix(int clockId, KernelTimespec* tp) {
|
||||
APS5_INVALID_ARG_EX;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (clockId == 0 || clockId == 9 || clockId == 10) {
|
||||
if (clockId == 0 || clockId == 9) {
|
||||
FILETIME ft{};
|
||||
GetSystemTimePreciseAsFileTime(&ft);
|
||||
std::uint64_t t = (static_cast<std::uint64_t>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||
@@ -111,6 +111,16 @@ int APS5_VABI clock_gettime_nid_postfix(int clockId, KernelTimespec* tp) {
|
||||
tp->tv_nsec = static_cast<std::int64_t>(t % 1000000000ULL);
|
||||
return 0;
|
||||
}
|
||||
if (clockId == 10 || clockId == 13) {
|
||||
FILETIME ft{};
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
std::uint64_t t = (static_cast<std::uint64_t>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||
t -= 116444736000000000ULL;
|
||||
t *= 100ULL;
|
||||
tp->tv_sec = static_cast<std::int64_t>(t / 1000000000ULL);
|
||||
tp->tv_nsec = static_cast<std::int64_t>(t % 1000000000ULL);
|
||||
return 0;
|
||||
}
|
||||
if (clockId == 4 || clockId == 1 || clockId == 5 || clockId == 7 || clockId == 8 || clockId == 11 || clockId == 12) {
|
||||
std::uint64_t nanos = GetMonotonicNanos();
|
||||
tp->tv_sec = static_cast<std::int64_t>(nanos / 1000000000ULL);
|
||||
@@ -123,9 +133,16 @@ int APS5_VABI clock_gettime_nid_postfix(int clockId, KernelTimespec* tp) {
|
||||
switch (clockId) {
|
||||
case 0:
|
||||
case 9:
|
||||
case 10:
|
||||
nativeId = CLOCK_REALTIME;
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
#ifdef CLOCK_REALTIME_COARSE
|
||||
nativeId = CLOCK_REALTIME_COARSE;
|
||||
#else
|
||||
nativeId = CLOCK_REALTIME;
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
case 7:
|
||||
case 11:
|
||||
@@ -191,7 +208,7 @@ int APS5_VABI clock_getres_nid_postfix(int clockId, KernelTimespec* res) {
|
||||
res->tv_nsec = 100LL;
|
||||
return 0;
|
||||
}
|
||||
if (clockId == 4 || clockId == 1 || clockId == 5 || clockId == 7 || clockId == 8 || clockId == 10 || clockId == 11 || clockId == 12) {
|
||||
if (clockId == 4 || clockId == 1 || clockId == 5 || clockId == 7 || clockId == 8 || clockId == 10 || clockId == 11 || clockId == 12 || clockId == 13) {
|
||||
static const std::uint64_t freq = [] {
|
||||
LARGE_INTEGER f{};
|
||||
QueryPerformanceFrequency(&f);
|
||||
@@ -208,9 +225,16 @@ int APS5_VABI clock_getres_nid_postfix(int clockId, KernelTimespec* res) {
|
||||
switch (clockId) {
|
||||
case 0:
|
||||
case 9:
|
||||
case 10:
|
||||
nativeId = CLOCK_REALTIME;
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
#ifdef CLOCK_REALTIME_COARSE
|
||||
nativeId = CLOCK_REALTIME_COARSE;
|
||||
#else
|
||||
nativeId = CLOCK_REALTIME;
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
case 7:
|
||||
case 11:
|
||||
|
||||
Reference in New Issue
Block a user