Repository navigation
feat(libkernel): implement the sigset functions - #1641
Conversation
klosixgaming-arch
left a comment
There was a problem hiding this comment.
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.
|
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.
|
Add sigemptyset, sigfillset, sigaddset, sigdelset and sigismember with FreeBSD 11 semantics (lib/libc/gen/sigsetops.c): a 128-bit set of four 32-bit words, signal n at bit n - 1, signals 1 to 128 valid. sigfillset sets every bit. An invalid signal returns -1 with errno EINVAL and leaves the set untouched; sigismember returns 1 or 0. A null set throws. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2c5beb7 to
e6a9b50
Compare
|
Amended after the approval; the exports and their semantics are unchanged. What changed:
Re-run on this revision: full |
|
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
🤖 Addressed by Claude Code |
|
Checked the five exports against shadPS4 ( |
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=ONonmain4b005b2: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 Four open-source homebrew titles stop at start-up on unresolved imports (sysctl, pthread_set_name_np, isatty, mkstemp, signal sets, Opus decoders) #1578.main6b56175), run 37822072979:guest_signal_setspasses its three repeats, full suite 474/474. The first attempt timed out inguest_raise_exception, the hang described in sceKernelRaiseException on Windows can stop a thread inside emulator code that holds a host lock #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