Skip to content

feat(libc): implement threading, ABI and string helpers - #4403

Closed
Feuris wants to merge 1 commit into
boykopovar:mainfrom
Feuris:feat/libc-mtx-cnd-cxa-strings
Closed

Feuris wants to merge 1 commit into
boykopovar:mainfrom
Feuris:feat/libc-mtx-cnd-cxa-strings

Conversation

@Feuris

@Feuris Feuris commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

This pull request implements several missing standard library runtime functions in libc.prx required by titles importing C++ ABI, Dinkumware threading primitives and wide string functions:

  • _Mtx_init_with_name (tgioGpKtmbE): forwards to _Mtx_init, ignoring the name parameter.
  • _Cnd_timedwait (McaImWKXong): converts the target Xtime deadline to a system clock time point and waits on the condition variable until expiration or notification, returning _Thrd_timedout (2) on expiration and _Thrd_success (0) on notification.
  • __cxa_thread_atexit (BKSCW2bCACA): forwards to __cxa_thread_atexit_impl. In __cxa_thread_atexit_impl, resets dso to nullptr on Windows to prevent MinGW CRT runtime assertions when guest callers pass non-null DSO handles.
  • wcscat (KZm8HUIX2Rw): wide string concatenation for 16-bit char16_t units.
  • wcsnlen_s (K+v+cnmGoH4): bounded wide string length per C11 Annex K for 16-bit char16_t units.
  • Added unit tests in GuestLibcTimedWait.cpp and GuestWideStrings.cpp, and registered __cxa_thread_atexit_nid_postfix in ThreadLocalDestructors.cmake.
  • Documented in docs/dev/TechnicalDebt.md.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, Ninja:
    • guest_libc_timed_wait unit test passes.
    • guest_wide_strings unit test passes.
    • guest_thread_callback_abi unit test passes.
    • guest_strings unit test passes.
    • prx_thread_local_destructors test passes.
    • python tools/check_conventions.py --base origin/main passes with 0 errors.
    • git diff --check origin/main clean.

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
  • Unblocks: none
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Progress report (90c6839 → 14a6e1e)

📈 System libraries: 87.88% (+0.01%, +5 implemented functions)

✅ 5 implemented
Library Name
libc _Cnd_timedwait_nid_postfix
libc _Mtx_init_with_name_nid_postfix
libc __cxa_thread_atexit_nid_postfix
libc wcscat_nid_postfix
libc wcsnlen_s_nid_postfix

@Feuris
Feuris force-pushed the feat/libc-mtx-cnd-cxa-strings branch from fa78758 to 14a6e1e Compare October 12, 2026 23:18
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: no title is shown to reach _Mtx_init_with_name, _Cnd_timedwait, __cxa_thread_atexit, wcscat or wcsnlen_s on main (Unblocks: none), and clearing dso in the existing __cxa_thread_atexit_impl on Windows is a separate fix. Reopen one function per PR, with the title ID and the log line where it stops.

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