feat(libSceLibcInternal): count std::ios_base::Init and std::_Winit objects #21832
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21832"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-16T20:05:56Z.
What
Implements four
libSceLibcInternalexports that threw: thestd::ios_base::Initandstd::_Winitcomplete-object constructors and destructors (_ZNSt8ios_base4InitC1EvsqWytnhYdEg,_ZNSt8ios_base4InitD1EvkxXCvcat1cM,_ZNSt6_WinitC1Ev-Bl9-SZ2noc,_ZNSt6_WinitD1EvUw3OTZFPNt4).cin/cout/cerr/clog(or the wide ones), and the last destruction flushes them. This library has no such objects and exports none, so construction only counts and the last destruction flushes libc's_Stdoutand_Stderr, the files those streams wrap. The debt fragment records this gap.int ios_base::Init::_Init_cnt = -1;,if (0 <= _Init_cnt) { ++_Init_cnt; } else { _Init_cnt = 1; },if (--_Init_cnt == 0) { // flush standard streams) and wiostrea.cpp L9-L33, the same for_Winit. Thelibc.prxbundled with CUSA00900 exports the same four symbols. Its disassembly (read, not run) has the same count update under one library lock, an initial count of -1, construction of the streams over stdin, stdout and stderr on the first construction, and a flush ofcout,cerrandclog(wide:wcout,wcerr,wclog) outside the lock on the last destruction.int()tovoid(void*), which is the constructor and destructor ABI._ZNSt6_WinitD1Evmoves fromInventoryExports6.cpptoInventoryExports.cppso that it shares its count with the constructor.tools/pr_overlap.py --branchand the diffs of #13778, #14834, #18135 and #19602).Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release,
build-win.guest_libc_internal_standard_stream_init: guest stdout is reopened to a fully buffered file in the test working directory and given text. For each class the test checks that a destruction before any construction flushes nothing, that two constructions and one destruction flush nothing, that the last destruction flushes the text to the file, and that the object is left untouched.--repeat until-fail:3).main'sInventoryExportssources with the same test: fails withterminate called after throwing an instance of 'std::runtime_error'/libSceLibcInternalInventory_145_nid_no_patch not implemented.fcd5d849b6e(after PrivacyOnion's Linux run): the test opened its file by a host absolute temp path, which the guest path resolver does not map on Linux, sofreopenfailed and the test aborted. It now uses a relative name, asGuestAppendStreamsandGuestAtomicAssertdo. WSL Ubuntu, GCC, Release, Ninja: at6a8df00c3d4it aborts withthe guest standard output opens the file; atfcd5d849b6eguest_libc_internal_standard_stream_initandguest_libc_internal_ios_basepass 3/3. Windowsbuild-winatfcd5d849b6e: both pass 3/3. No library code changed.tools/progress.py --module libSceLibcInternal: 518 done / 613 to do onmainand 522 / 609 here (+4).python3 tools/check_conventions.py --base origin/mainpasses.tools/debt_fold.py --checkpasses for this fragment. On currentmainit reportsdocs-nkwebkit-drop-readded-count-lines.md:5, which this PR does not touch.main. Withtools/import_audit.py --moduleson the eboot registry, its bundledlibSceSmart.prximports all four fromlibSceLibcInternal, and they were listed asstub. With this change they are implemented.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)libSceSmart.prximportssqWytnhYdEg,kxXCvcat1cM,-Bl9-SZ2nocandUw3OTZFPNt4, allstubonmain.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T20:11:11Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
6a8df00c3d:tools/check_conventions.pypassed.guest_libc_internal_standard_stream_init_testsbuilt cleanly.guest_libc_internal_standard_stream_init):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T20:37:37Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
fcd5d849b6:tools/check_conventions.pypassed.guest_libc_internal_standard_stream_init_testsbuilt cleanly.guest_libc_internal_standard_stream_init):core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/InventoryExports6.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports6.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me