refactor(libSceLibcInternal): serve siginterrupt from libSceLibcInternal #10749

Merged
ycbuzi merged 14 commits from upstream-pr/10749 into main 2026-11-04 17:35:30 +00:00
ycbuzi commented 2026-10-24 20:45:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-24T20:45:37Z.


What

Follow-up to #8872, as suggested by @harisibrar1 in its review: siginterrupt (TsrS8nGDQok) moves from libc to libSceLibcInternal/SignalList.cpp. On the console it is a libSceLibcInternal.sprx function (STT_FUNC, 128 bytes, absent from the kernel modules) that imports _sigintr and UDCI-WazohQ, which hashes from _sigaction (@mazen320's dynsym parse and Ghidra decompile on #8872, and the NID check there).

libSceLibcInternal links libkernel and already calls libkernel exports directly (utimes in FileTime.cpp, fcntl and close in Directory.cpp). So siginterrupt now calls _sigaction_nid_postfix (UDCI-WazohQ, the import the console function uses; on main it forwards to sigaction_nid_postfix, Signals.cpp:513-514) and sets or clears its bit in _sigintr_nid_postfix itself. The sequence is unchanged: FreeBSD 11.4 lib/libc/gen/siginterrupt.c. Read the disposition, set or clear the bit with SA_RESTART cleared or set, then install it again. EINVAL for a signal outside 1 to 128 comes from the first _sigaction, before the set is touched.

This removes what #8872 needed while siginterrupt lived in libc:

  • SigactionFn_nid_no_patch and RegisterSigaction_nid_no_patch in libc's General.hpp;
  • the registration block and its copy of the sigaction struct in libc's Process.cpp, including the throw for a call before registration;
  • the static initializer at the end of libkernel's Signals.cpp that registered sigaction.

On main the relinker gives a module that imports libSceLibcInternal both libSceLibcInternal.prx and libc.prx (GuestModuleBuilder.cpp:368-371), so a title's siginterrupt import now resolves in libSceLibcInternal.prx. With #10706's export headers, SignalList.cpp takes GuestSigaction and _sigaction_nid_postfix from libkernel/include/Api.hpp, and the siginterrupt_nid_postfix declaration moves from libc/include/Api.hpp to libSceLibcInternal/include/Api.hpp, so public_headers still finds one declaration per export. guest_signal_tests links libSceLibcInternal and GuestSignals.cpp includes its header for the existing siginterrupt checks. The debt entry moves from libc.md to libSceLibcInternal.md.

#9001 (@Queuse, test only) merged first, as @oneandonlydean asked on this PR. Its guest_signal_interrupt_tests linked libkernel libc and took siginterrupt_nid_postfix from libc's Api.hpp. With this PR it links libSceLibcInternal too (target_link_libraries(guest_signal_interrupt_tests PRIVATE libkernel libSceLibcInternal libc)), and GuestSignalInterrupt.cpp includes prx/libSceLibcInternal/include/Api.hpp next to its libc include. Those two lines are in 29c52418f2, after merging main.

Overlap: #9499 (@EagleBearerYS) touches the same spots without changing what it does. In Signals.cpp its RegisteredForJumps registration goes in the anonymous namespace whose RegisterSignalsOnLoad this PR removes, and in libkernel.md its sigaction entry sits next to the signal entry changed here. #9499 merged first after all; merging main here keeps its RegisteredForJumps registration in that namespace and drops RegisterSignalsOnLoad, and keeps its sigaction entry next to this PR's signal entry. #10706 and #9001 landed first; main is merged in with the header moves and the two lines above. #10615 and #10648 only touch the neighbouring lines of libc.md.

Tested

Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0, Release, head 68a0d205c0 (main 809c7fa2df merged in): 24 focused tests (the libSceLibcInternal tests, the signal tests, guest_user_context and guest_user_context_exit) and public_headers (65 tests) pass 2 of 2; tools/check_conventions.py passes.

Windows 11 Home 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release. Head 1c060e99b9 (main efd368fec6, with #9001, #10706 and #9499, merged in):

  • Built libkernel, libc, libSceLibcInternal and the test executables with no errors. The one warning is main's existing _sigintr_nid_postfix "initialized and declared 'extern'" at Signals.cpp:24.
  • ctest --repeat until-fail:2: guest_signal_interrupt (#9001's test), guest_signal_handler_mask (#9499's), guest_signal_sets, guest_signals, the 17 libSceLibcInternal tests and guest_user_context (22 tests) pass both runs.
  • public_headers and its 64 compile batches (65 tests) pass.
  • tools/check_conventions.py --base origin/main passes.
  • Export tables (objdump -p): only libSceLibcInternal.prx exports siginterrupt_nid_postfix; libkernel.prx exports _sigaction_nid_postfix and _sigintr_nid_postfix; libc.prx has none of them.
  • After merging main 88795ed448 (head 432aed7b7b, 0 behind): the same 22 tests pass 2 of 2, public_headers (65 tests) passes, tools/check_conventions.py --base origin/main passes and the export tables are the same. The only warning is still main's _sigintr_nid_postfix one, now at Signals.cpp:26.
  • After merging main e0cd1259a9 (head 32c682c803, 0 behind; the one conflict was the neighbouring collate<char> vtable entry in docs/dev/debt/libc.md, kept as main has it): the same 22 tests pass 2 of 2, the 64 public_headers_compile_* batches pass, tools/check_conventions.py --base origin/main passes and the export tables are the same. The public_headers audit passes (368 libraries, 12811 exports) run directly, but took 120 s on this machine against the test's 90 s timeout while another build ran, so under ctest it timed out.
  • After merging main 420b6a064e (head f430c9ec4e, 0 behind; the one conflict was #11504's removal of the _Xfilesystem_error entry next to this one in docs/dev/debt/libSceLibcInternal.md, kept as main has it): the same 22 tests pass 2 of 2, public_headers (65 tests) passes, tools/check_conventions.py --base origin/main passes and the export tables are the same. The only warning is still main's _sigintr_nid_postfix one, now at Signals.cpp:30.

Before #9001 merged, on main 2dc85609fc: its GuestSignalInterrupt.cpp at b5e40d1d3e (all four set words, extreme flags, errno, neighbouring bits, the signal interplay, invalid signals) passed both runs on this branch with libSceLibcInternal added to its link line, and linked as libkernel libc it failed with undefined references. libSceLibcInternal.prx imports _sigaction_nid_postfix and _sigintr_nid_postfix from libkernel.prx.

Not tested: Linux, macOS, a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (#9001 has merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4999007858 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10749). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-24T20:45:37Z. --- ### What Follow-up to #8872, as suggested by @harisibrar1 in its review: `siginterrupt` (`TsrS8nGDQok`) moves from libc to `libSceLibcInternal/SignalList.cpp`. On the console it is a `libSceLibcInternal.sprx` function (`STT_FUNC`, 128 bytes, absent from the kernel modules) that imports `_sigintr` and `UDCI-WazohQ`, which hashes from `_sigaction` (@mazen320's dynsym parse and Ghidra decompile on #8872, and the NID check there). `libSceLibcInternal` links libkernel and already calls libkernel exports directly (`utimes` in `FileTime.cpp`, `fcntl` and `close` in `Directory.cpp`). So `siginterrupt` now calls `_sigaction_nid_postfix` (`UDCI-WazohQ`, the import the console function uses; on `main` it forwards to `sigaction_nid_postfix`, `Signals.cpp:513-514`) and sets or clears its bit in `_sigintr_nid_postfix` itself. The sequence is unchanged: FreeBSD 11.4 `lib/libc/gen/siginterrupt.c`. Read the disposition, set or clear the bit with `SA_RESTART` cleared or set, then install it again. `EINVAL` for a signal outside 1 to 128 comes from the first `_sigaction`, before the set is touched. This removes what #8872 needed while `siginterrupt` lived in libc: - `SigactionFn_nid_no_patch` and `RegisterSigaction_nid_no_patch` in libc's `General.hpp`; - the registration block and its copy of the sigaction struct in libc's `Process.cpp`, including the throw for a call before registration; - the static initializer at the end of libkernel's `Signals.cpp` that registered `sigaction`. On `main` the relinker gives a module that imports `libSceLibcInternal` both `libSceLibcInternal.prx` and `libc.prx` (`GuestModuleBuilder.cpp:368-371`), so a title's `siginterrupt` import now resolves in `libSceLibcInternal.prx`. With #10706's export headers, `SignalList.cpp` takes `GuestSigaction` and `_sigaction_nid_postfix` from `libkernel/include/Api.hpp`, and the `siginterrupt_nid_postfix` declaration moves from `libc/include/Api.hpp` to `libSceLibcInternal/include/Api.hpp`, so `public_headers` still finds one declaration per export. `guest_signal_tests` links `libSceLibcInternal` and `GuestSignals.cpp` includes its header for the existing `siginterrupt` checks. The debt entry moves from `libc.md` to `libSceLibcInternal.md`. #9001 (@Queuse, test only) merged first, as @oneandonlydean asked on this PR. Its `guest_signal_interrupt_tests` linked `libkernel libc` and took `siginterrupt_nid_postfix` from libc's `Api.hpp`. With this PR it links `libSceLibcInternal` too (`target_link_libraries(guest_signal_interrupt_tests PRIVATE libkernel libSceLibcInternal libc)`), and `GuestSignalInterrupt.cpp` includes `prx/libSceLibcInternal/include/Api.hpp` next to its libc include. Those two lines are in `29c52418f2`, after merging `main`. Overlap: #9499 (@EagleBearerYS) touches the same spots without changing what it does. In `Signals.cpp` its `RegisteredForJumps` registration goes in the anonymous namespace whose `RegisterSignalsOnLoad` this PR removes, and in `libkernel.md` its `sigaction` entry sits next to the `signal` entry changed here. #9499 merged first after all; merging `main` here keeps its `RegisteredForJumps` registration in that namespace and drops `RegisterSignalsOnLoad`, and keeps its `sigaction` entry next to this PR's `signal` entry. #10706 and #9001 landed first; `main` is merged in with the header moves and the two lines above. #10615 and #10648 only touch the neighbouring lines of `libc.md`. ### Tested Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0, Release, head `68a0d205c0` (`main` `809c7fa2df` merged in): 24 focused tests (the `libSceLibcInternal` tests, the signal tests, `guest_user_context` and `guest_user_context_exit`) and `public_headers` (65 tests) pass 2 of 2; `tools/check_conventions.py` passes. Windows 11 Home 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release. Head `1c060e99b9` (`main` `efd368fec6`, with #9001, #10706 and #9499, merged in): - Built `libkernel`, `libc`, `libSceLibcInternal` and the test executables with no errors. The one warning is `main`'s existing `_sigintr_nid_postfix` "initialized and declared 'extern'" at `Signals.cpp:24`. - `ctest --repeat until-fail:2`: `guest_signal_interrupt` (#9001's test), `guest_signal_handler_mask` (#9499's), `guest_signal_sets`, `guest_signals`, the 17 libSceLibcInternal tests and `guest_user_context` (22 tests) pass both runs. - `public_headers` and its 64 compile batches (65 tests) pass. - `tools/check_conventions.py --base origin/main` passes. - Export tables (`objdump -p`): only `libSceLibcInternal.prx` exports `siginterrupt_nid_postfix`; `libkernel.prx` exports `_sigaction_nid_postfix` and `_sigintr_nid_postfix`; `libc.prx` has none of them. - After merging `main` `88795ed448` (head `432aed7b7b`, 0 behind): the same 22 tests pass 2 of 2, `public_headers` (65 tests) passes, `tools/check_conventions.py --base origin/main` passes and the export tables are the same. The only warning is still `main`'s `_sigintr_nid_postfix` one, now at `Signals.cpp:26`. - After merging `main` `e0cd1259a9` (head `32c682c803`, 0 behind; the one conflict was the neighbouring `collate<char> vtable` entry in `docs/dev/debt/libc.md`, kept as `main` has it): the same 22 tests pass 2 of 2, the 64 `public_headers_compile_*` batches pass, `tools/check_conventions.py --base origin/main` passes and the export tables are the same. The `public_headers` audit passes (368 libraries, 12811 exports) run directly, but took 120 s on this machine against the test's 90 s timeout while another build ran, so under ctest it timed out. - After merging `main` `420b6a064e` (head `f430c9ec4e`, 0 behind; the one conflict was #11504's removal of the `_Xfilesystem_error` entry next to this one in `docs/dev/debt/libSceLibcInternal.md`, kept as `main` has it): the same 22 tests pass 2 of 2, `public_headers` (65 tests) passes, `tools/check_conventions.py --base origin/main` passes and the export tables are the same. The only warning is still `main`'s `_sigintr_nid_postfix` one, now at `Signals.cpp:30`. Before #9001 merged, on `main` `2dc85609fc`: its `GuestSignalInterrupt.cpp` at `b5e40d1d3e` (all four set words, extreme flags, errno, neighbouring bits, the `signal` interplay, invalid signals) passed both runs on this branch with `libSceLibcInternal` added to its link line, and linked as `libkernel libc` it failed with undefined references. `libSceLibcInternal.prx` imports `_sigaction_nid_postfix` and `_sigintr_nid_postfix` from `libkernel.prx`. Not tested: Linux, macOS, a title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#9001 has merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-24 20:48:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:48:26Z.

Review: CHANGES_REQUESTED


I reviewed the relocation and the reported Windows coverage. The console evidence and the sequence match the stated FreeBSD implementation; the layout assertions and use of _sigaction before indexing the signal set are useful safeguards. I have not run the PR's Windows tests locally; the focused Windows results in Tested are author-reported, and hosted product jobs are currently skipped.

There are two unresolved integration points that affect the build/test result:

  1. The open #9001 test currently links only libkernel and libc. Once this PR removes siginterrupt from libc, that test cannot link until its target also links libSceLibcInternal. The PR description notes this, but there is no confirmed order with #9001's author, and the checklist still says Depends on: none. Please coordinate the target-link change with that author and record the agreed order/dependency in both PR descriptions.
  2. I ran git merge-tree on the current heads of this PR and #9499. The combined result has content conflicts in core/libs/prx/libkernel/System/src/Signals.cpp and docs/dev/debt/libkernel.md. The described resolution appears possible (retain RegisteredForJumps, omit the obsolete sigaction-registration initializer, and retain both debt updates), but the heads do not merge as-is. Please confirm the order/resolution with #9499's author and record it in the checklist before this can be approved.

The implementation may be correct independently, but the known open test and code conflicts need an agreed integration path. The relinker/product matrix is still running, so I will recheck it after these coordination points are resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639947800 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10749#pullrequestreview-5639947800). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T20:48:26Z. **Review:** CHANGES_REQUESTED --- I reviewed the relocation and the reported Windows coverage. The console evidence and the sequence match the stated FreeBSD implementation; the layout assertions and use of `_sigaction` before indexing the signal set are useful safeguards. I have not run the PR's Windows tests locally; the focused Windows results in `Tested` are author-reported, and hosted product jobs are currently skipped. There are two unresolved integration points that affect the build/test result: 1. The open #9001 test currently links only `libkernel` and `libc`. Once this PR removes `siginterrupt` from `libc`, that test cannot link until its target also links `libSceLibcInternal`. The PR description notes this, but there is no confirmed order with #9001's author, and the checklist still says `Depends on: none`. Please coordinate the target-link change with that author and record the agreed order/dependency in both PR descriptions. 2. I ran `git merge-tree` on the current heads of this PR and #9499. The combined result has content conflicts in `core/libs/prx/libkernel/System/src/Signals.cpp` and `docs/dev/debt/libkernel.md`. The described resolution appears possible (retain `RegisteredForJumps`, omit the obsolete sigaction-registration initializer, and retain both debt updates), but the heads do not merge as-is. Please confirm the order/resolution with #9499's author and record it in the checklist before this can be approved. The implementation may be correct independently, but the known open test and code conflicts need an agreed integration path. The relinker/product matrix is still running, so I will recheck it after these coordination points are resolved.
MarcZX10 commented 2026-10-29 10:19:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:19:35Z.

Review: CHANGES_REQUESTED


Re-reviewed exact head 32c682c803c4a11bd4d137c95f77e2e723f9911b against current main f99d7fece316e31878f0195f8bbc2ad2fbe635e4.

The earlier overlap items are resolved: #9001 and #9499 are merged, and #11504 now declares Depends on: #10749. The current-main merge preview is clean; git diff --check and tools/check_conventions.py pass against current main. I found no new issue in the relocation itself.

I cannot clear the review yet because the tested tree is still based on e0cd1259a9, while current main has moved substantially and changed the related libkernel/System/src/Signals.cpp initialization and signal-debt entries. Please sync this branch to current main and rerun the focused signal tests, public-header/export checks, and conventions on that integrated head. The current hosted Windows relinker matrix also has one red shader_cache_native_paths timeout (368/369 passed); it is unrelated by path, but remains a failed check. Please obtain a green rerun on the updated head.

The author-reported Windows/macOS results on the prior integrated heads are useful, but I did not run a local product build or tests. Product Linux CI is skipped. My existing changes-requested review remains for current-main validation and the failed hosted check.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5696122398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10749#pullrequestreview-5696122398). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T10:19:35Z. **Review:** CHANGES_REQUESTED --- Re-reviewed exact head `32c682c803c4a11bd4d137c95f77e2e723f9911b` against current `main` `f99d7fece316e31878f0195f8bbc2ad2fbe635e4`. The earlier overlap items are resolved: #9001 and #9499 are merged, and #11504 now declares `Depends on: #10749`. The current-main merge preview is clean; `git diff --check` and `tools/check_conventions.py` pass against current main. I found no new issue in the relocation itself. I cannot clear the review yet because the tested tree is still based on `e0cd1259a9`, while current `main` has moved substantially and changed the related `libkernel/System/src/Signals.cpp` initialization and signal-debt entries. Please sync this branch to current `main` and rerun the focused signal tests, public-header/export checks, and conventions on that integrated head. The current hosted Windows relinker matrix also has one red `shader_cache_native_paths` timeout (368/369 passed); it is unrelated by path, but remains a failed check. Please obtain a green rerun on the updated head. The author-reported Windows/macOS results on the prior integrated heads are useful, but I did not run a local product build or tests. Product Linux CI is skipped. My existing changes-requested review remains for current-main validation and the failed hosted check.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10749
No description provided.