feat(libc): implement legacy signal masks #10392

Merged
GabrielKLBr merged 3 commits from upstream-pr/10392 into main 2026-11-04 17:35:07 +00:00
GabrielKLBr commented 2026-10-23 20:55:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GabrielKLBr on 2026-10-23T20:55:52Z.


What

Adds sigblock (Bm3k7JQMN5w) and sigsetmask (cJvOg1KV8uc) to libSceLibcInternal. Missing imports can resolve to implementations that block or replace the guest signal mask through libkernel's existing sigprocmask.

Both take a signed 32-bit mask, zero-fill the upper words of the 128-bit guest signal set, and return the signed low word of the previous mask. Backend failures and errno pass through unchanged. The semantics follow FreeBSD 11.4 lib/libc/compat-43/sigcompat.c; console verification and inherited libkernel limitations are recorded in the existing debt file.

The two new behavioral tests cover every combination of seven input and previous masks, signed bit 31, zero-extension, backend errors, errno preservation, unmaskable signals, upper-word preservation or clearing, and pending-signal delivery. The workflow used for validation lives only on a separate fork branch and is excluded from this PR.

tools/pr_overlap.py --branch feat/libc-legacy-signal-masks reports no line or export overlaps. It cannot compare the base-conflicted shared files of #5021, #6044, #9133 and #9669. Those patches were reviewed manually: they change Darwin statvfs/TLS tests, reorganize test paths, or change spawn linkage and debt; none implements these exports or edits this implementation.

Tested

Draft: complete build validation is still in progress. Source commit 1cc37db1af3f671132ad6927cc629e7f6ffda01c, based on main 1915df0dd430e678b4a2348e3454c0f306f5c7df: https://github.com/GabrielKLBr/AnyPS5/actions/runs/40021748777

Edit: The build was successfully validated.

At PR creation, the focused target build, the four signal behavior/regression tests, conventions and test registration have passed on the Windows runner. The complete project build is running. The subsequent explicit libs build and patched_libraries test have not run yet. This is not a claim of complete build or test-suite success. Only sigblock and sigsetmask are added; the nine todo entries reported for the separate libc module are not resolved by this PR.

Windows x86-64 (windows-2025), WinLibs GCC 15.2.0 UCRT POSIX SEH r7, Ninja, CMake Release, BUILD_TESTING=ON. The validation workflow runs the following commands, with the pending stages identified above:

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON
cmake --build build --target guest_legacy_signal_mask_tests guest_legacy_signal_mask_forwarding_tests guest_signal_tests guest_signal_set_tests --parallel 3
ctest --test-dir build -R '^guest_(legacy_signal_mask(_forwarding)?|signals|signal_sets)$' --output-on-failure --no-tests=error
cmake --build build --parallel 3
cmake --build build --target libs --parallel 3
ctest --test-dir build -R '^patched_libraries$' --output-on-failure --no-tests=error
python tools/check_conventions.py --base 1915df0dd430e678b4a2348e3454c0f306f5c7df
python tools/check_test_registration.py --scripts
python tools/check_test_registration.py build

The local Windows 10 Education 22H2 machine builds the focused targets and passes the standalone forwarding test, but its Core i3-2120 lacks the CPU features required by libkernel's startup guard. The new integration test and unchanged main's existing guest_signals both stop at that guard before main. The Windows runner is used for runtime validation without bypassing that check. No PS5, game, homebrew or Linux runtime testing was performed. The complete CTest suite was not run.

Full Linux and Windows checks in the official repository require a collaborator with write access to start the Build workflow, as CONTRIBUTING.md describes. The fork validation above does not substitute for those official checks.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4989152242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10392). Originally posted by [GabrielKLBr](https://github.com/GabrielKLBr) on 2026-10-23T20:55:52Z. --- ### What Adds `sigblock` (`Bm3k7JQMN5w`) and `sigsetmask` (`cJvOg1KV8uc`) to libSceLibcInternal. Missing imports can resolve to implementations that block or replace the guest signal mask through libkernel's existing `sigprocmask`. Both take a signed 32-bit mask, zero-fill the upper words of the 128-bit guest signal set, and return the signed low word of the previous mask. Backend failures and errno pass through unchanged. The semantics follow FreeBSD 11.4 `lib/libc/compat-43/sigcompat.c`; console verification and inherited libkernel limitations are recorded in the existing debt file. The two new behavioral tests cover every combination of seven input and previous masks, signed bit 31, zero-extension, backend errors, errno preservation, unmaskable signals, upper-word preservation or clearing, and pending-signal delivery. The workflow used for validation lives only on a separate fork branch and is excluded from this PR. `tools/pr_overlap.py --branch feat/libc-legacy-signal-masks` reports no line or export overlaps. It cannot compare the base-conflicted shared files of #5021, #6044, #9133 and #9669. Those patches were reviewed manually: they change Darwin statvfs/TLS tests, reorganize test paths, or change spawn linkage and debt; none implements these exports or edits this implementation. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> **Draft: complete build validation is still in progress.** Source commit `1cc37db1af3f671132ad6927cc629e7f6ffda01c`, based on main `1915df0dd430e678b4a2348e3454c0f306f5c7df`: https://github.com/GabrielKLBr/AnyPS5/actions/runs/40021748777 **Edit:** The build was successfully validated. At PR creation, the focused target build, the four signal behavior/regression tests, conventions and test registration have passed on the Windows runner. The complete project build is running. The subsequent explicit `libs` build and `patched_libraries` test have not run yet. This is not a claim of complete build or test-suite success. Only `sigblock` and `sigsetmask` are added; the nine todo entries reported for the separate libc module are not resolved by this PR. Windows x86-64 (`windows-2025`), WinLibs GCC 15.2.0 UCRT POSIX SEH r7, Ninja, CMake Release, `BUILD_TESTING=ON`. The validation workflow runs the following commands, with the pending stages identified above: ```text cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON cmake --build build --target guest_legacy_signal_mask_tests guest_legacy_signal_mask_forwarding_tests guest_signal_tests guest_signal_set_tests --parallel 3 ctest --test-dir build -R '^guest_(legacy_signal_mask(_forwarding)?|signals|signal_sets)$' --output-on-failure --no-tests=error cmake --build build --parallel 3 cmake --build build --target libs --parallel 3 ctest --test-dir build -R '^patched_libraries$' --output-on-failure --no-tests=error python tools/check_conventions.py --base 1915df0dd430e678b4a2348e3454c0f306f5c7df python tools/check_test_registration.py --scripts python tools/check_test_registration.py build ``` The local Windows 10 Education 22H2 machine builds the focused targets and passes the standalone forwarding test, but its Core i3-2120 lacks the CPU features required by libkernel's startup guard. The new integration test and unchanged main's existing `guest_signals` both stop at that guard before main. The Windows runner is used for runtime validation without bypassing that check. No PS5, game, homebrew or Linux runtime testing was performed. The complete CTest suite was not run. Full Linux and Windows checks in the official repository require a collaborator with write access to start the Build workflow, as CONTRIBUTING.md describes. The fork validation above does not substitute for those official checks. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 21:19:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T21:19:10Z.

Review: APPROVED


Reviewed the implementation, tests, CMake registration, and debt update. The wrappers translate the legacy operations to SIG_BLOCK/SIG_SETMASK, zero-extend the signed 32-bit mask to the 128-bit guest set, and return the signed previous low word. The tests cover forwarding/error propagation and guest integration, including unmaskable signals and pending delivery. Hosted conventions, intake and labels pass; the linked Windows validation run has passed the focused build/tests and is still compiling the full project, so I am not treating that full build or the later libs/patched_libraries checks as complete.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5634554675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10392#pullrequestreview-5634554675). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T21:19:10Z. **Review:** APPROVED --- Reviewed the implementation, tests, CMake registration, and debt update. The wrappers translate the legacy operations to `SIG_BLOCK`/`SIG_SETMASK`, zero-extend the signed 32-bit mask to the 128-bit guest set, and return the signed previous low word. The tests cover forwarding/error propagation and guest integration, including unmaskable signals and pending delivery. Hosted conventions, intake and labels pass; the linked Windows validation run has passed the focused build/tests and is still compiling the full project, so I am not treating that full build or the later `libs`/`patched_libraries` checks as complete.
MarcZX10 commented 2026-10-24 00:34:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:34:12Z.

Review: APPROVED


Re-reviewed head 1cc37db1af3f671132ad6927cc629e7f6ffda01c with the completed validation run 40021748777. The Windows job now passes the focused signal behavior/regression tests, full project build, production libs build, patched-library load test, conventions and test registration. This resolves the validation caveat in my earlier review. The implementation and test diff remain unchanged; I found no additional issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635846057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10392#pullrequestreview-5635846057). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T00:34:12Z. **Review:** APPROVED --- Re-reviewed head `1cc37db1af3f671132ad6927cc629e7f6ffda01c` with the completed validation run `40021748777`. The Windows job now passes the focused signal behavior/regression tests, full project build, production `libs` build, patched-library load test, conventions and test registration. This resolves the validation caveat in my earlier review. The implementation and test diff remain unchanged; I found no additional issue.
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!10392
No description provided.