Repository navigation
feat(libc): export the std::__sce_v2 at-thread-exit registry calls - #15879
Open
Danigamer05 wants to merge 1 commit into
Open
Danigamer05 wants to merge 1 commit into
Danigamer05 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run this test on pull requests.
AI-assisted: yes. |
Progress report (b611e63 → 5880453)📈 System libraries: 26.7% (+0.01%, +5 implemented functions) ✅ 5 implemented
Changed libraries (implemented exports)
|
This was referenced Nov 5, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Export the versioned
std::__sce_v2at-thread-exit calls from libc._ZNSt8__sce_v228_Cnd_register_at_thread_exitEPP12pthread_condPP13pthread_mutexPi+fAmL52-yfQ0x10AE00_ZNSt8__sce_v230_Cnd_unregister_at_thread_exitEPP13pthread_mutexSwcNvp-Af6c0x10B110_ZNSt8__sce_v232_Cnd_do_broadcast_at_thread_exitEv2s6aLdPIA4I0x10B1C0_ZNSt8__sce_v226_Lock_at_thread_exit_mutexEv2qvjaae0N-M0x10ADB0_ZNSt8__sce_v228_Unlock_at_thread_exit_mutexEvhx11Xia3FSY0x10ADE0The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).These back
std::notify_all_at_thread_exitand thepromise..._at_thread_exitcalls. They take the versioned handles (pthread_cond**,pthread_mutex**) and use main's versioned_Mtx_*,_Cnd_broadcast,_Thrd_idand_Throw_Cpp_error. As in the module:calloc, and an allocation failure drops the entry;SceLibc_V2AtThreadExit(type0x102), which_Lock_at_thread_exit_mutexand_Unlock_at_thread_exit_mutextake and release. A failed lock throws through_Throw_Cpp_error(5);notify_all_at_thread_exitleft held.Nothing in the module calls the broadcast when a thread ends: as in Dinkumware's
std::thread, the title's own thread code calls_Cnd_do_broadcast_at_thread_exitafter the thread function returns, so nothing here adds a thread-exit hook. The module creates its mutex when it loads; here it is created on first use. The debt entry records both.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, mainb611e634f7f. Exact tested commit:5880453e377.Built libc, libkernel, their NID-patched production libraries and the related tests. The new
guest_sce_v2_at_thread_exitpasses 20 times in a row, along withguest_libc_threads,guest_libc_shared_mutexandpublic_headers.The new test uses real guest mutexes and conditions. It checks:
The original functions were loaded from the bundled module with their relocations applied and its static constructor for the mutex run. Their imports were bound by NID to this branch's libc and libkernel, so both sides used the same guest mutexes and conditions. The module's heap is not set up outside a console process, so its
callocwas redirected to the host's; without that, the module drops every entry past the twentieth.Side by side with the patched production library, the same random operation sequences ran on each side over 1,400 sequences and two seeds, with 25,041 registrations. The sequences registered from the main thread and from three long-lived helper threads, with and without flags and held locks, and unregistered, broadcast and nested the global mutex. Each run then compared the 48 flags and whether each mutex was still held, and no run differed. Long-lived helpers were needed because a thread id is the address of the thread's object, which a new thread can reuse.
Negative control: four lines were altered one at a time:
The new CTest failed on each, and the side-by-side run reported differences or, for the first, deadlocked. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again.
Code conventions and
git diff --checkpass.tools/pr_overlap.pyread 1,859 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 42 branches that already conflict with main. Merging each of the 42 with this branch and with main usinggit merge-treegives the same conflict blocks except indocs/dev/debt/libc.mdfor docs(debt): separate entries with blank lines and drop derived export totals #14212, which reflows the whole file, so the new debt entry lands inside one of its conflict blocks wherever it goes. feat(libc): add the std::__sce_v2 thread start, timed wait, clock and processor count calls #9447 names_Cnd_do_broadcast_at_thread_exitand_Cnd_register_at_thread_exitonly in a debt entry that says they are not implemented; it adds no code for them. The branch also merges cleanly with feat(libc): export the std::__sce_v2 extended-precision helpers #15336, feat(libc): export the std::__sce_v2 multiprecision helpers #15471, feat(libc): export the std::__sce_v2 _Poly and _XLgamma helpers #15484, feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper #15490, feat(libc): export the std::__sce_v2 _Exp and _FExp helpers #15501, feat(libc): export the std::__sce_v2 _Pmsw, _FPmsw and _LPmsw helpers #15519, feat(libc): throw std::bad_cast and the std::__sce_v2 bad_any_cast, format_error and future_error #15552, feat(libc): forward the std::atomic wait and notify helpers to libkernel #15561, feat(libc): count the std::__sce_v2 _Winit and ios_base::Init initializations #15602, feat(libc): export the std::__sce_v2 floating-point constants #15614, fix(libc): store the std::__sce_v2 _Throw_Cpp_error value in the first code word #15667, feat(libc): export the std::__sce_v2 _Stollx, _Stoullx, _Stolx and _Stoulx parsers #15683, feat(libc): export std::_Throw_bad_any_cast and std::_Throw_bad_node_access #15791, feat(libc): export the std::error_category complete and deleting destructors #15796, feat(libc): export the std::__sce_v2 resetiosflags, setiosflags, setbase and setprecision manipulators #15809 and feat(libc): export the std::__sce_v2 _Timespec64_get_sys and _Timespec64_diff_to_ts clock helpers #15834.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code