feat(libc): implement _Cnd_timedwait #5037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5037"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Feuris on 2026-10-13T09:07:50Z.
What
Implement
_Cnd_timedwaitin libc for Dinkumware condition variables, waiting until the specified xtime deadline and returning_Thrd_timedout(2) on expiration or_Thrd_success(0) on notification.Super Meat Boy 3D (
PPSA31162) importsMcaImWKXongfromlibc.prx. The NID matches aerolib symbol_Cnd_timedwait.Tested
guest_libc_cnd_timed_wait(ctest -R guest_libc_cnd_timed_wait) verifies immediate timeout on past deadline, successful wakeup by signaling thread before deadline, and null deadline argument validation (std::invalid_argument).python tools/check_conventions.py --base origin/mainpassed.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T09:09:04Z.
Progress report (
bb9a4d8→572d330)➖ System libraries: 88.41% (+0.0%, +1 implemented functions)
✅ 1 implemented
_Cnd_timedwait_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:15:40Z.
Review: CHANGES_REQUESTED
Thanks. Built and ran
guest_libc_cnd_timed_waitlocally, and compared with the console's_Cnd_timedwait(disassembled from a title'slibc.prx): the xtime is an absolute deadline converted against the current time,ETIMEDOUTmaps to 2 and success to 0, so the two return values match. A few things to fix:Threads.cpp:239-240:std::chrono::seconds(target->sec) + std::chrono::nanoseconds(target->nsec)overflows (signed UB) for a large guestsec.XtimeDeadlinein the same file already normalizes the nanoseconds and checks overflow; reuse it (or an equivalent check) and throw on overflow like_Thrd_sleepdoes.GuestLibcCndTimedWait.cpp: only an already-past deadline and a signalled wake-up are covered. Add a case with a short future deadline and no signal that returns 2 only after the deadline has passed (loop onsystem_clockas in other timer tests, since Windows can wake early), and annsecoutside[0, 1e9).docs/dev/debt/libc.md:9: say where the behaviour comes from (disassembly of the console'slibc.prx) and that the console returns 4 for other pthread errors while this throws.The
linux/windowsjobs are skipped on this PR, so the full Build will need to run before merge.Imported from boykopovar/AnyPS5. Originally posted by Feuris on 2026-10-13T09:39:46Z.
Updated to address review feedback:
sec values (both negative and > 1s), and std::overflow_error on extreme sec.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:54:33Z.
Review: APPROVED
Rechecked the update:
XtimeDeadlineis reused with overflow checks, the new tests cover a short future deadline (looping onsystem_clock), unnormalizednsecand overflow, and the debt line names the source and the console's return 4.guest_libc_cnd_timed_waitpasses 5/5 here. Merging once the full Build is green.