Repository navigation
fix(libkernel): accept null results in gettimeofday and clock_getres - #2291
Conversation
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37947367784 |
|
This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready. |
FreeBSD's gettimeofday stores the time only when tp is not null, and clock_getres the resolution only when res is not null; both succeed otherwise. Both threw, which aborted a title probing a clock or only asking for the time zone. Write into a local result instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7d04df2 to
70d6382
Compare
|
Rebased onto current On Windows, |
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38021702524 |
…ll-time-results fix(libkernel): accept null results in gettimeofday and clock_getres
What
FreeBSD treats both result pointers as optional:
gettimeofday(tp, tzp)stores the time only whentpis not null (sys_gettimeofday:if (uap->tp) ...), sogettimeofday(NULL, &tz)orgettimeofday(NULL, NULL)succeeds.clock_getres(id, res)stores the resolution only whenresis not null, soclock_getres(id, NULL)succeeds. POSIX says the same, and it is the usual way to check that a clock exists.Both functions threw
std::invalid_argumentfor a null result, which aborts the title. They now write into a local value instead, and every other path is unchanged.Overlap: #1676 adds a branch right after the
clock_getresnull check that this replaces, so whichever lands second needs a two-line rebase. I'll do it here if #1676 goes first.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:guest_freebsd_clocks_tests(at the start ofmain):gettimeofday(NULL, NULL)succeeds;gettimeofday(NULL, &tz)succeeds and fillstz;clock_getres(id, NULL)succeeds for REALTIME, VIRTUAL, MONOTONIC, SECOND and PROCESS_CPUTIME_ID.mainthe test aborts withgettimeofday_nid_postfix: invalid argument. Restoring only the oldclock_getrescheck makes it abort inclock_getres, so both halves are covered.ctest -R "freebsd_clocks|cpu_time_clocks": 2/2 passed.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. It merges cleanly with fix(libkernel): return guest errors for invalid clock IDs #2089, fix(libkernel): initialize the full local-time conversion state #2157, fix(libkernel): preserve large nanosleep durations #2067, test(libkernel): cover cancellation recovery for #1668 #1739 and fix(libkernel): read the process start before the clock in process time #1501, which touch the same files. Apart from feat(libkernel): implement pthread_getcpuclockid and per-thread CPU clocks #1676 above, feat(libkernel): implement thread cancellation #1141 conflicts only inTechnicalDebt.md, where it already conflicts withmain.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code