feat(libkernel): implement the sigset functions #1641
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1641"
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 SleglJan on 2026-10-08T15:25:52Z.
What
Adds the five POSIX signal-set functions to libkernel:
sigemptyset,sigfillset,sigaddset,sigdelsetandsigismember, with the semantics of FreeBSD 11'slib/libc/gen/sigsetops.candsys/sys/_sigset.h:GuestSignalSetlayout asSignals.cpp(defined again in the new file, with astatic_asserton its size); signal n lives in word (n − 1) >> 5 at bit (n − 1) & 31._SIG_MAXSIG).sigaddset,sigdelsetandsigismemberreturn -1 with errno 22 for any other value and leave the set untouched;sigismemberreturns 1 or 0.sigfillsetwrites all ones to every word, as FreeBSD does;sigemptysetwrites zeros. Neither fails.std::invalid_argument); the console would fault.shadPS4 implements the same five the same way (
src/core/libraries/kernel/threads/exception.cpp).The functions go in a new
System/src/SignalSets.cpprather thanSignals.cpp.DispatchinSignals.cpponmaintests the blocked mask at bit n, so a set built with these functions would block the wrong signal; #1652 corrects that to bit n − 1 and this PR lists it under Depends on. #1431 described moving the mask to a per-thread bit n − 1 layout, but its current head does not touchSignals.cpp. The only file shared with #1431 islibkernel/CMakeLists.txt.Overlap: the pr-overlap report lists #1482, #1613, #1616 and #1627 for
__error_nid_postfix. That is the sharedextern "C"declaration of the errno accessor each of them adds to reach the guest errno, not an export; none of them touches the same files or lines.In the Linux audit of the homebrew catalog (#1578),
sigemptyset,sigfillsetandsigdelsetwere each absent for 19 to 20 of the 34 relinked titles,sigaddsetfor 10.Tested
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ONonmain4b005b22:ctest --repeat until-fail:3467/467;tools/check_test_registration.pyandtools/check_conventions.py --base upstream/mainpass.guest_signal_setstest: empty; fill, then membership of all 128 signals; add at the word boundaries 1, 32, 33, 65, 96 and 128 and delete at 1, 32, 33, 96 and 128, with every other word checked; idempotent add; delete of an absent signal; errno 22 and an unchanged set for 0, -1, 129, 1000,INT_MINandINT_MAX, against a nearly empty and a full set; errno untouched by every successful call. Written before the implementation; it failed on the five unresolved exports and passes with them.libkernel.prxexports the five NIDs (+F7C-hdk7+E,VkTAsrZDcJ0,JUimFtKe0Kc,Nd-u09VFSCA,JnNl8Xr-z4Y).tools/import_audit.pyon catalog titles, absent imports before → after: PPSA69420 ScreenTester5 9 → 7, PPSA17641 SymphonyStation5 35 → 33, PPSA99007 Yamagi Quake II 23 → 19, PPSA99420 PS5MC 121 → 116. None of them loads yet; the remaining imports are listed in #1578.main6b56175a), run 37822072979:guest_signal_setspasses its three repeats, full suite 474/474. The first attempt timed out inguest_raise_exception, the hang described in #1488, and passed on the rerun.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
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-08T15:31:33Z.
Review: APPROVED
LGTM. Clean implementation of the five POSIX signal-set functions following FreeBSD semantics. The bit manipulation is correct, validation is thorough (signal range 1-128), and error handling properly sets errno to EINVAL for invalid signals. Test coverage is excellent - covers all operations, word boundaries, idempotent add, and invalid signal cases with errno verification. Good separation into a dedicated SignalSets.cpp file to avoid conflicts with the Signals.cpp rewrite in #1431.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T15:39:18Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfixImported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-08T15:46:02Z.
Amended after the approval; the exports and their semantics are unchanged. What changed:
Dispatchonmaintests the blocked mask at bit n, so a set built with these functions blocked the wrong signal. That is fixed separately in #1652 (one expression plus a test), and this PR now lists it under Depends on. The earlier text said #1431 would move the mask to bit n − 1; its current head does not touchSignals.cpp, so the description no longer relies on it.static_assert(sizeof(GuestSignalSet) == 16); the index arithmetic lives in oneWordIndexhelper; the errno helper isRejectSignal; the null check takes a typed pointer.INT_MINandINT_MAX, signals 65 and 96 (word 2), membership of all 128 signals aftersigfillset, errno untouched by successful calls, the invalid-signal loop against a full set as well.extern "C"declaration of__error_nid_postfix, not an export; see the description.Re-run on this revision: full
ctest --repeat until-fail:3467/467, conventions and test-registration checks pass.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T21:14:14Z.
Progress report (
4b005b2→e6a9b50)📈 System libraries: 84.78% (+0.02%, +5 implemented functions)
✅ 5 implemented
sigaddset_nid_postfixsigdelset_nid_postfixsigemptyset_nid_postfixsigfillset_nid_postfixsigismember_nid_postfixImported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:04:02Z.
First Windows run, since the description says it wasn't tested on Windows.
Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto
mainb7218b3ctogether with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1859, #1685, #1676, #1675, #1656, #1807.guest_signal_setspasses.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T20:58:53Z.
Checked the five exports against shadPS4 (
exception.cpp) and SharpProspero (CompatEmitter.cs): range 1..128, bit n - 1, EINVAL on anything else. Full build and ctest green (guest_signal_setspasses, and the test cannot link withoutSignalSets.cpp); CI green on this head, Windows included. Merging.