Skip to content

fix(libc): use precise Windows thread sleep - #8129

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Th3EvilGod:codex/libc-precise-thread-sleep
Oct 20, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Th3EvilGod:codex/libc-precise-thread-sleep

Conversation

@Th3EvilGod

Copy link
Copy Markdown
Contributor

What

_Thrd_sleep uses winpthreads nanosleep on Windows, which truncates sub-millisecond requests and can finish millisecond waits on 15.6 ms clock steps. Use the existing high-resolution waitable-timer helper for the bounded relative wait, rounding up to 100 ns, then recheck the absolute realtime deadline.

The existing xtime normalization, one-day chunk bound, past-deadline behavior and POSIX nanosleep path remain intact. Add guest-API checks for 100 us and 2 ms deadlines and a broad 12 ms median bound over 31 samples. Keep the existing cancellation/console-contract gaps explicit in libc technical debt.

Related to #1471; this addresses only _Thrd_sleep. #7735 changes condition-variable waits in the same source file, independently of this function.

Tested

Windows 11 Pro (26300), AMD Ryzen 7 9800X3D, WinLibs MinGW-w64 GCC 15.2.0 r7, Release build. No title or console verification.

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

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1835 core/libs/prx/libc/src/Threads.cpp
PR 5021 core/libs/prx/libc/src/Threads.cpp
docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/tests/GuestAmprThreads.cpp
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 6819 docs/dev/debt/libc.md
PR 6879 core/libs/prx/libc/src/Threads.cpp
PR 7081 docs/dev/debt/libc.md
PR 7201 core/libs/prx/libc/src/Threads.cpp
PR 7332 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7473 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8037 docs/dev/debt/libc.md

@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@oneandonlydean
oneandonlydean merged commit 8972f8a into boykopovar:main Oct 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants