Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-cpu-clock-resolution.md
KianandClaude Opus 5.5 6bc0fdc790 fix(libkernel): read CLOCK_VIRTUAL and CLOCK_PROF from getrusage on POSIX hosts, as FreeBSD 11.4 does
On Linux and macOS clock_gettime ids 1 and 2, and id 21 built on id 2,
came from times(), which counts in _SC_CLK_TCK ticks (usually 10 ms),
and threw when times() failed. They now read getrusage(RUSAGE_SELF)
ru_utime and ru_stime in microseconds and set the guest errno on
failure, as FreeBSD 11.4 kern_clock_gettime does through calcru and
TIMEVAL_TO_TIMESPEC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 06:26:11 +10:00

1.0 KiB

libkernel

change clock_getres

  • clock_getres (libkernel) answers as libc's clock_getres did on a PS5 (firmware 11.60, a payload process, #17958) and the raw system call on firmware 12.00 (#15725); the libkernel export itself, a title process and other firmware are unmeasured. Ids 3, 6, 15 to 20 and 22 to 31 fail with EINVAL, the result untouched; id 15 fails though its clock_gettime succeeds. Ids 32 and above fail with EINVAL too, as #14557 added and the console did for 1000 and INT_MAX. Values keep the host's granularity, not the reported resolution; on Windows ids 1, 2 and 21 step per scheduler tick. Encoded CPU clocks (bit 31) answer as id 14 and a null result returns 0 before the id is checked, as FreeBSD 11.4 does; the console agrees for -1 and a null result.