feat(libcinternal): implement relative thread sleep #15931

Merged
KomedyKid merged 1 commit from upstream-pr/15931 into main 2026-11-10 22:31:50 +00:00
KomedyKid commented 2026-11-05 01:17:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KomedyKid on 2026-11-05T01:17:27Z.


What

Replaces the throwing std::__sce_v2::_Thrd_sleep_for stub with relative thread sleep. Zero milliseconds yields; positive waits preserve the full 64-bit duration and use bounded chunks to avoid host duration overflow.

The behavior follows Microsoft STL sharedmutex.cpp. Sony-specific behavior remains unverified and is recorded in technical debt.

Manual comparison of the reported overlapping PRs found no duplicate sleep implementation. The overlaps concern inventory documentation, build registration and adjacent declarations.

Merge-order coordination:

  • Authors of #15577, #15657 and #15697 agree that this PR may land first.
  • #15460 merged into main and is included in this branch.
  • Discussions with #15581 and #15822 remain pending.
  • No functional dependency on those changes.

Tested

Windows x86-64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, BUILD_TESTING=ON, commit effa625451.

  • Built guest_relative_sleep_tests and its library dependencies through the full project configuration.
  • guest_relative_sleep and guest_relative_sleep_large: 2/2 passed. Covers zero delay, 1/20/80 ms waits, and durations of 2^32, 2^63 and UINT64_MAX milliseconds.
  • Restoring the original throwing behavior made both tests fail; reinstating the implementation made both pass.
  • Public-header, test-script registration and convention checks passed.
  • Additional Windows validation reported by @JJenkx: guest_relative_sleep passed 3/3 runs after a clean merge onto main.
  • No PS5/module, game, Linux or macOS execution was performed.

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:5164389715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15931). Originally posted by [KomedyKid](https://github.com/KomedyKid) on 2026-11-05T01:17:27Z. --- ### What Replaces the throwing `std::__sce_v2::_Thrd_sleep_for` stub with relative thread sleep. Zero milliseconds yields; positive waits preserve the full 64-bit duration and use bounded chunks to avoid host duration overflow. The behavior follows [Microsoft STL sharedmutex.cpp](https://github.com/microsoft/STL/blob/ca6b46463662934a2379d2e1c1a57c9103e820a6/stl/src/sharedmutex.cpp). Sony-specific behavior remains unverified and is recorded in technical debt. Manual comparison of the reported overlapping PRs found no duplicate sleep implementation. The overlaps concern inventory documentation, build registration and adjacent declarations. Merge-order coordination: - Authors of #15577, #15657 and #15697 agree that this PR may land first. - #15460 merged into `main` and is included in this branch. - Discussions with #15581 and #15822 remain pending. - No functional dependency on those changes. ### Tested Windows x86-64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, BUILD_TESTING=ON, commit `effa625451`. - Built `guest_relative_sleep_tests` and its library dependencies through the full project configuration. - `guest_relative_sleep` and `guest_relative_sleep_large`: 2/2 passed. Covers zero delay, 1/20/80 ms waits, and durations of 2^32, 2^63 and UINT64_MAX milliseconds. - Restoring the original throwing behavior made both tests fail; reinstating the implementation made both pass. - Public-header, test-script registration and convention checks passed. - Additional Windows validation reported by @JJenkx: `guest_relative_sleep` passed 3/3 runs after a clean merge onto main. - No PS5/module, game, Linux or macOS execution was performed. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of the change, 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
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!15931
No description provided.