feat(libSceLibcInternal): construct the messages<char> and messages<wchar_t> facets #21904
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21904"
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 LeandroLP23 on 2026-11-16T20:48:57Z.
What
Implements the seven
std::messagesconstructors that still threw:messages<char>C1(const char*, size_t),C1(const _Locinfo&, size_t),C2(const _Locinfo&, size_t)andC2(size_t), andmessages<wchar_t>C1(const char*, size_t),C1(const _Locinfo&, size_t)andC2(size_t).Each one writes the vtable pointer and the reference count into the 0x10-byte facet and nothing else. Both
messages::_Initmembers are already a singleretfrom firmware 13.42 (the empty facet members debt entry), and Microsoft STL'sxlocmesmessageshas no other members.messages<char>gets the exported libc vtable_ZTVSt8messagesIcE(at slot 2), whosedo_open,do_getanddo_closeare already wired.messages<wchar_t>vtable exists in the tree. The wide facet gets a vtable in libSceLibcInternal with the D1, D0,_Increfand_Decrefslots and ado_open,do_getanddo_closethat behave as the exportedmessages<wchar_t>members do:-1, a copy of the default, nothing._Locinfofrom it, so they accept the names_Locinfo(const char*)accepts.The other messages constructors (
C1(size_t),C2(const char*, size_t)and wideC1(size_t),C2(const char*, size_t),C2(const _Locinfo&, size_t)) are NID-only declarations, which #17300 names, so this PR leaves them alone. The debt fragment removes the seven stub entries and adds one that states what is not measured.tools/progress.py --module libSceLibcInternal: 522 done / 609 to do onmain9b60c84343, 529 / 602 on this branch.Tested
Windows 11, MinGW-w64 GCC 15.2, Release,
BUILD_TESTING=ON, onmain9b60c84343.guest_libc_internal_messages(extended) passes. For every constructor it checks that the vptr is the exportedmessages<char>vtable or the wide one, that the 64-bit reference count lands at offset 8 (with0x100000007to catch a truncated count), and that the bytes after the 0x10-byte facet stay as they were. It then calls the existingopen,getandcloseexports on the constructed facets:openreturns -1 in both widths, andgetthrough the wide vtable copies a 20-unit wide default onto the heap. A wide facet allocated withoperator newis retained, released and deleted through its own vtable, and the test's allocation counter comes back to where it started.guest_libc_internal_facet_queries,guest_libc_internal_facet_put,guest_localeandpublic_headersstill pass.do_getcopying narrow units, it fails at "get through the wide vtable copies the wide default". Both reverted.python tools/check_conventions.py --base origin/mainpasses.tools/debt_fold.py --checkpasses oncedocs-nkwebkit-drop-readded-count-lines.md, which fails onmainas well, is set aside.tools/pr_overlap.py --namesfor the seven constructors: no open PR.--branch: no PR with the same exports. It reports neighbouring-line conflicts with #19767 and #21894 inInventoryExports6and could not merge 13 conflicting PRs; I read the diffs of all of them, and none touches these constructors or amessages<wchar_t>vtable (#17300 only names the other, NID-only messages constructors).Not tested: a console or a title.
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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T20:55:40Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
1a2653604a:tools/check_conventions.pypassed.guest_libc_internal_messages_testsbuilt cleanly.guest_libc_internal_messages):core/libs/prx/libSceLibcInternal/InventoryExports6.cpp,core/libs/prx/libSceLibcInternal/include/Api.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp,core/libs/prx/libc/include/Api.hpp,core/libs/prx/libSceLibcInternal/Messages.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me