feat(libkernel_sys): implement __sys_nanosleep export #13256

Merged
iAbdulrrahman merged 4 commits from upstream-pr/13256 into main 2026-11-05 15:39:19 +00:00
iAbdulrrahman commented 2026-10-30 08:22:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iAbdulrrahman on 2026-10-30T08:22:57Z.


What

Implement __sys_nanosleep (msfSXXy-8H8) in libkernel_sys by forwarding to libkernel's nanosleep_nid_postfix as defined in FreeBSD 11.4 libc lib/libc/sys/nanosleep.c. Add unit tests in GuestKernelSysNanosleep.cpp testing invalid requests, negative and zero seconds, and valid sleep requests.

Tested

Windows 11, ctest --test-dir build -R guest_kernel_sys_nanosleep --repeat until-fail:3 -V (passed 3/3 iterations).

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: #13129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5081532725 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13256). Originally posted by [iAbdulrrahman](https://github.com/iAbdulrrahman) on 2026-10-30T08:22:57Z. --- ### What Implement `__sys_nanosleep` (`msfSXXy-8H8`) in `libkernel_sys` by forwarding to `libkernel`'s `nanosleep_nid_postfix` as defined in FreeBSD 11.4 libc `lib/libc/sys/nanosleep.c`. Add unit tests in `GuestKernelSysNanosleep.cpp` testing invalid requests, negative and zero seconds, and valid sleep requests. ### 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. --> Windows 11, `ctest --test-dir build -R guest_kernel_sys_nanosleep --repeat until-fail:3 -V` (passed 3/3 iterations). ### 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: #13129 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:50:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:50:15Z.

Review: COMMENTED


On the code: the wrapper calls scePthreadSetcancelstate(1, ...) around sceKernelNanosleep, i.e. it makes the raw syscall non-cancellable by hand and restores the state afterwards. If sceKernelNanosleep throws or longjmps out (guest signal jump), the cancel state is left disabled for the thread. Is the restore protected, and does the test cover an interrupted sleep with a non-null rmtp?

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729924880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13256#pullrequestreview-5729924880). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:50:15Z. **Review:** COMMENTED --- On the code: the wrapper calls `scePthreadSetcancelstate(1, ...)` around `sceKernelNanosleep`, i.e. it makes the raw syscall non-cancellable by hand and restores the state afterwards. If `sceKernelNanosleep` throws or longjmps out (guest signal jump), the cancel state is left disabled for the thread. Is the restore protected, and does the test cover an interrupted sleep with a non-null `rmtp`?
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!13256
No description provided.