feat(libkernel): implement sceKernelSyncOnAddressWait32 and sceKernelSyncOnAddressWait64 #633

Merged
Celegans12 merged 1 commit from upstream-pr/633 into main 2026-10-05 19:02:29 +00:00
Celegans12 commented 2026-10-05 10:14:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T10:14:45Z.


What

This completes #349, which implemented Wait and Wake and left sceKernelSyncOnAddressWait32 and sceKernelSyncOnAddressWait64 out; a libc.prx with the C++20 atomic wait wrappers does not load without them.

  • Wait32 (B2n8aDorSH4) and Wait64 (PZQhiiLXRFs) return 0 at once when the 4- or 8-byte value at the address differs from the comparand, else wait for sceKernelSyncOnAddressWake (0) or the timeout (SCE_KERNEL_ERROR_ETIMEDOUT). A null address, or one not aligned to the value size, throws, as in #349.
  • They share the waiter queue of sceKernelSyncOnAddressWait (unchanged), so one Wake releases waiters of every size, oldest first.
  • Comparand, timeout, return values and alignment match KytyPS5, which marks both experimental and returns EINVAL where this throws.
  • In the PPSA26344 v1.008 libc.prx, __std_atomic_wait_direct_32/64 (0x112060, 0x1120f0) pass the address, the comparand, their millisecond timeout converted to a pointer to 32-bit microseconds (null for none) and a name string, and ignore the result; __std_atomic_notify_one/all_direct call Wake.
  • Assumed (TechnicalDebt, Unknown function info): the by-value comparand, the return values and Wait64's 8-byte alignment.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0: configure -DBUILD_TESTING=ON, full build, --target libs.
  • 284/284 tests pass (ctest --output-on-failure)
  • guest_sync_on_address gains cases for the Wait32/Wait64 timeout and early return, the Wait64 high-half compare, Wake across all three sizes (count 1, then INT_MAX) and their invalid addresses; they do not link on main. ctest -R guest_sync_on_address --repeat until-fail:20 passes, also with APS5_COARSE_TIMED_WAITS=1.
  • PPSA26344 v1.008: the libc.prx imports B2n8aDorSH4 and PZQhiiLXRFs now resolve; before, loading stopped on them.
  • Not tested: Linux (CI), console behaviour.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4743367948 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/633). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-05T10:14:45Z. --- ### What This completes #349, which implemented Wait and Wake and left `sceKernelSyncOnAddressWait32` and `sceKernelSyncOnAddressWait64` out; a `libc.prx` with the C++20 atomic wait wrappers does not load without them. - Wait32 (`B2n8aDorSH4`) and Wait64 (`PZQhiiLXRFs`) return 0 at once when the 4- or 8-byte value at the address differs from the comparand, else wait for `sceKernelSyncOnAddressWake` (0) or the timeout (`SCE_KERNEL_ERROR_ETIMEDOUT`). A null address, or one not aligned to the value size, throws, as in #349. - They share the waiter queue of `sceKernelSyncOnAddressWait` (unchanged), so one Wake releases waiters of every size, oldest first. - Comparand, timeout, return values and alignment match [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/72e4989b1e1643c9237ba68ae4e3fe77fa489c63/src/libs/libKernel.cpp#L2103-L2117), which marks both experimental and returns `EINVAL` where this throws. - In the PPSA26344 v1.008 `libc.prx`, `__std_atomic_wait_direct_32/64` (0x112060, 0x1120f0) pass the address, the comparand, their millisecond timeout converted to a pointer to 32-bit microseconds (null for none) and a name string, and ignore the result; `__std_atomic_notify_one/all_direct` call Wake. - Assumed (TechnicalDebt, Unknown function info): the by-value comparand, the return values and Wait64's 8-byte alignment. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0: configure `-DBUILD_TESTING=ON`, full build, `--target libs`. - 284/284 tests pass (`ctest --output-on-failure`) - `guest_sync_on_address` gains cases for the Wait32/Wait64 timeout and early return, the Wait64 high-half compare, Wake across all three sizes (count 1, then `INT_MAX`) and their invalid addresses; they do not link on main. `ctest -R guest_sync_on_address --repeat until-fail:20` passes, also with `APS5_COARSE_TIMED_WAITS=1`. - PPSA26344 v1.008: the `libc.prx` imports `B2n8aDorSH4` and `PZQhiiLXRFs` now resolve; before, loading stopped on them. - Not tested: Linux (CI), console behaviour. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-05 15:47:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T15:47:09Z.


Progress report (e248f40 → 28b2a08)

📈 System libraries: 79.21% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel sceKernelSyncOnAddressWait32
libkernel sceKernelSyncOnAddressWait64
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5997938690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/633#issuecomment-5997938690). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T15:47:09Z. --- <!-- progress-report --> ### Progress report (e248f40 → 28b2a08) 📈 **System libraries**: 79.21% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelSyncOnAddressWait32` | | libkernel | `sceKernelSyncOnAddressWait64` | </details>
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!633
No description provided.