feat(libkernel): implement pthread_condattr_getclock #8010

Merged
Piyush-Sagar merged 4 commits from upstream-pr/8010 into main 2026-10-26 18:02:46 +00:00
Piyush-Sagar commented 2026-10-19 17:34:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Piyush-Sagar on 2026-10-19T17:34:32Z.


What

Add the missing libkernel pthread_condattr_getclock export (NID cTDYxTUNPhM). A live initialized attribute reports its stored signed 32-bit clock ID without changing the attribute or guest errno. Declare the getter in the shared libkernel API header and use the shared libc declarations in its regression test.

The signature and opaque handle follow the public PS5 payload SDK's pthread.h and _pthreadtypes.h; sys/_types.h supplies the 32-bit clock type. Valid-input behavior follows FreeBSD 11.4 libthr. This is public SDK/reference evidence; no PS5 hardware verification is claimed.

Null attribute pointers, null handles and null outputs call NotImplemented_nid_no_patch; their console error/fault behavior remains unverified. Inaccessible non-null pointers and copied dangling handles are not validated, and concurrent mutation/destruction is not synchronized. These gaps remain in docs/dev/debt/libkernel.md.

Getter regression coverage checks initialized defaults, both setters using clocks {0, 1, 2, Monotonic}, independent attributes, output canaries, unchanged handles/errno, and refusal of null arguments and original handles cleared by both destroy functions. Main's rejected-clock cases and SCE/POSIX pshared checks are preserved. After each rejected SCE and POSIX setter, the getter must report the previously stored Monotonic clock.

Dependency #9500 is merged. This branch is rebased onto main with its {0, 1, 2, 4} setter allowlist and rejection tests; the setter implementation is unchanged by this PR. Depends on: #9500 records the completed landing order.

Related prior work: closed, unmerged #3930 proposed this getter alongside additional SCE/pshared exports. This PR is limited to the POSIX getter.

Tested

Verified on 2026-10-26: Windows 11 Pro 10.0.26300, supported WinLibs MinGW-w64 GCC 15.2.0 r7 (x86_64-ucrt-posix-seh), Ninja, Release, BUILD_TESTING=ON, ANYPS5_RELINKER_ONLY=OFF. Head fd54e493dd4873e5d63bddbb614b6613637027eb is rebased onto main 518d36eaec0ac37870a17b465bedb5551be91b42, which includes #9500.

  • All patched system libraries and the five focused test targets rebuilt successfully.
  • Focused runtime tests: 5/5 passed, 0 failures, 2.86 seconds total: patched_libraries, guest_cond_timedwait, guest_pthread_condattr, guest_cond_recursive_mutex, guest_cond_unowned_mutex.
  • Registration audit: 1396 test executables, 0 built but unregistered, none new.
  • Public-header audit: 368 libraries, 12235 exports; unique declarations and umbrella coverage verified.
  • Conventions checks, including the PR title and description, and working-tree/committed-diff whitespace checks passed.
  • Overlap scan completed against main 427dd36164bbc1e7960c85c8e84dca75017c88f8. Its duplicate getter finding is this PR's previous head. Comparisons involving 35 other PRs' shared debt/header files could not complete because those PRs conflict with main; no clean-overlap claim is made.
  • Merge-tree checks against both the tested main base and the newer scan base were clean. The three changed source/header/test files are unchanged between those bases; the shared debt file has advanced.
cmake --build build-condattr --target libs guest_pthread_condattr_tests guest_cond_timedwait_tests guest_cond_recursive_mutex_tests guest_cond_unowned_mutex_tests patched_libraries_tests --parallel 6
ctest --test-dir build-condattr -R '^(guest_pthread_condattr|guest_cond_timedwait|guest_cond_recursive_mutex|guest_cond_unowned_mutex|patched_libraries)$' --output-on-failure
python3 tools/check_test_registration.py build-condattr
python3 core/libs/tests/test_public_headers.py --audit-only
python3 tools/check_conventions.py --base origin/main
python3 tools/check_conventions.py --base origin/main --title 'feat(libkernel): implement pthread_condattr_getclock' --body <PR-description-file>
git diff origin/main...HEAD --check
git diff --check
python3 tools/pr_overlap.py --branch codex/implement-condattr-getclock --repo boykopovar/AnyPS5 --jobs 8

The current refresh was not tested on Linux, on a PS5, or with a title; the full test suite was not run. No performance or game-unblocking claim is made. Full upstream Linux/Windows CI requires a maintainer-triggered Build workflow for PR 8010. The post-#9500 rebase and rejected-setter preservation checks are complete.

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: #9500
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4924876957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8010). Originally posted by [Piyush-Sagar](https://github.com/Piyush-Sagar) on 2026-10-19T17:34:32Z. --- ### What Add the missing libkernel `pthread_condattr_getclock` export (NID `cTDYxTUNPhM`). A live initialized attribute reports its stored signed 32-bit clock ID without changing the attribute or guest errno. Declare the getter in the shared libkernel API header and use the shared libc declarations in its regression test. The signature and opaque handle follow the public PS5 payload SDK's [pthread.h](https://github.com/ps5-payload-dev/sdk/blob/f5d40f02770e9b0001dd9e18056eca70b3da8b40/include/freebsd/pthread.h) and [_pthreadtypes.h](https://github.com/ps5-payload-dev/sdk/blob/f5d40f02770e9b0001dd9e18056eca70b3da8b40/include/freebsd/sys/_pthreadtypes.h); [sys/_types.h](https://github.com/ps5-payload-dev/sdk/blob/f5d40f02770e9b0001dd9e18056eca70b3da8b40/include/freebsd/sys/_types.h) supplies the 32-bit clock type. Valid-input behavior follows [FreeBSD 11.4 libthr](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libthr/thread/thr_condattr.c). This is public SDK/reference evidence; no PS5 hardware verification is claimed. Null attribute pointers, null handles and null outputs call `NotImplemented_nid_no_patch`; their console error/fault behavior remains unverified. Inaccessible non-null pointers and copied dangling handles are not validated, and concurrent mutation/destruction is not synchronized. These gaps remain in `docs/dev/debt/libkernel.md`. Getter regression coverage checks initialized defaults, both setters using clocks `{0, 1, 2, Monotonic}`, independent attributes, output canaries, unchanged handles/errno, and refusal of null arguments and original handles cleared by both destroy functions. Main's rejected-clock cases and SCE/POSIX pshared checks are preserved. After each rejected SCE and POSIX setter, the getter must report the previously stored `Monotonic` clock. Dependency #9500 is merged. This branch is rebased onto main with its `{0, 1, 2, 4}` setter allowlist and rejection tests; the setter implementation is unchanged by this PR. `Depends on: #9500` records the completed landing order. Related prior work: closed, unmerged [#3930](https://github.com/boykopovar/AnyPS5/pull/3930) proposed this getter alongside additional SCE/pshared exports. This PR is limited to the POSIX getter. ### Tested Verified on 2026-10-26: Windows 11 Pro 10.0.26300, supported WinLibs MinGW-w64 GCC 15.2.0 r7 (`x86_64-ucrt-posix-seh`), Ninja, Release, `BUILD_TESTING=ON`, `ANYPS5_RELINKER_ONLY=OFF`. Head `fd54e493dd4873e5d63bddbb614b6613637027eb` is rebased onto main `518d36eaec0ac37870a17b465bedb5551be91b42`, which includes #9500. - All patched system libraries and the five focused test targets rebuilt successfully. - Focused runtime tests: **5/5 passed, 0 failures**, 2.86 seconds total: `patched_libraries`, `guest_cond_timedwait`, `guest_pthread_condattr`, `guest_cond_recursive_mutex`, `guest_cond_unowned_mutex`. - Registration audit: 1396 test executables, 0 built but unregistered, none new. - Public-header audit: 368 libraries, 12235 exports; unique declarations and umbrella coverage verified. - Conventions checks, including the PR title and description, and working-tree/committed-diff whitespace checks passed. - Overlap scan completed against main `427dd36164bbc1e7960c85c8e84dca75017c88f8`. Its duplicate getter finding is this PR's previous head. Comparisons involving 35 other PRs' shared debt/header files could not complete because those PRs conflict with main; no clean-overlap claim is made. - Merge-tree checks against both the tested main base and the newer scan base were clean. The three changed source/header/test files are unchanged between those bases; the shared debt file has advanced. ```text cmake --build build-condattr --target libs guest_pthread_condattr_tests guest_cond_timedwait_tests guest_cond_recursive_mutex_tests guest_cond_unowned_mutex_tests patched_libraries_tests --parallel 6 ctest --test-dir build-condattr -R '^(guest_pthread_condattr|guest_cond_timedwait|guest_cond_recursive_mutex|guest_cond_unowned_mutex|patched_libraries)$' --output-on-failure python3 tools/check_test_registration.py build-condattr python3 core/libs/tests/test_public_headers.py --audit-only python3 tools/check_conventions.py --base origin/main python3 tools/check_conventions.py --base origin/main --title 'feat(libkernel): implement pthread_condattr_getclock' --body <PR-description-file> git diff origin/main...HEAD --check git diff --check python3 tools/pr_overlap.py --branch codex/implement-condattr-getclock --repo boykopovar/AnyPS5 --jobs 8 ``` The current refresh was not tested on Linux, on a PS5, or with a title; the full test suite was not run. No performance or game-unblocking claim is made. Full upstream Linux/Windows CI requires a maintainer-triggered Build workflow for PR 8010. The post-#9500 rebase and rejected-setter preservation checks are complete. <!-- 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. --> ### 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: #9500 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-22 01:32:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:32:28Z.


The overlap scan flags the GuestPthreadCondattr.cpp cases shared with #9500. Your getter regression currently stores clock IDs 5 and 12 and expects the getter to return them, while #9500 changes the setter to reject those IDs per FreeBSD libthr. Please coordinate with #9500’s author on which lands first and update the second PR’s test/checklist so both changes compose.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330506092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8010#issuecomment-6330506092). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:32:28Z. --- The overlap scan flags the `GuestPthreadCondattr.cpp` cases shared with #9500. Your getter regression currently stores clock IDs 5 and 12 and expects the getter to return them, while #9500 changes the setter to reject those IDs per FreeBSD libthr. Please coordinate with #9500’s author on which lands first and update the second PR’s test/checklist so both changes compose.
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!8010
No description provided.