feat(libc): export the std::__sce_v2 locale::global, empty, classic and _Locinfo category calls #16113
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16113"
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 Danigamer05 on 2026-11-05T17:41:28Z.
What
Export the versioned
std::__sce_v2locale::classic,locale::empty,locale::global,locale::_Setgloballocale,_Locimp::_New_Locimp(bool),_Locimp::_Clocptr,_sceLibcLocinfo, and the_Locinfoconstructor and_Addcatsthat take a category, from libc._ZNSt8__sce_v26locale16_SetgloballocaleEPvkyDNldAZhv40xCFD50_ZNSt8__sce_v26locale7classicEvf0KW1y+Ea0Q0xCFE30_ZNSt8__sce_v26locale5emptyEvKA0vt-WXdqQ0xD0D90_ZNSt8__sce_v26locale7_Locimp11_New_LocimpEbVUJZ+pCrRn40xD0DF0_ZNSt8__sce_v26locale6globalERKS0_v+WMV7IIp7w0xF18A0_ZNSt8__sce_v28_Locinfo13_Locinfo_ctorEPS0_iPKc6cl-GjyMBbU0xF27F0_ZNSt8__sce_v28_Locinfo16_Locinfo_AddcatsEPS0_iPKcTM74yWf91xI0xF2860_ZNSt8__sce_v215_sceLibcLocinfoEPKcdJM+bL2BU9E0xF28B0_ZNSt8__sce_v26locale7_Locimp8_ClocptrEHWch8-MtqmQ0x197900The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).They build on main's versioned locale, which shares the unversioned
0x30-byte_Locimpand has the classic locale ready from the start. As in the module:classic()returns a staticlocalethat holds the classic_Locimp, and_Clocptrpoints at that_Locimp;empty()and_New_Locimp(bool)build a_Locimpwith one reference, no facets, category 0 and the name*;empty()makes it transparent and_New_Locimptakes the flag;_Setgloballocalestores the global_Locimp, and_Getgloballocaleand_Init(bool)now return that global instead of the classic one, so they follow it once it changes;_Initstill takes a reference when its flag is set;global()returns the previous global through_Init(true). When the new locale differs, it releases the old global's reference, installs and retains the new one, and callssetlocalewith its name for each category in its mask, or once for all six;_sceLibcLocinfothrowsruntime_error("bad locale name")unless the name is""or"C". The two_Locinfocalls ignore the category, check the name the same way, and storesetlocale(LC_ALL, nullptr); the constructor first stores the current name, and both store the classic name only after the check._Locimp_ctorand_Locimp_dtorare left for a follow-up, since they need reference counting in_Locimp_Addfacand_New_Locimp(const _Locimp&), which main does not do yet. A new debt entry records what differs here. The existing versioned locale entry now says_Initand_Getgloballocalereturn the global locale.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, maind893997f1a6. Exact tested commit:d18e1c71325.Built libc, libkernel, their NID-patched production libraries and the related tests. The new
guest_sce_v2_locale_basicspasses, along withguest_sce_v2_locale,guest_localeandguest_sce_v2_exceptions.The NID-patched libc exports all 9 NIDs above.
The new test checks:
classic(),_Clocptr,_Getgloballocaleand_Initagree on the classic_Locimp;_Locimpthatempty()and both_New_Locimp(bool)build;global()takes and releases when it installs a locale, keeps the same one and restores the classic one;_Setgloballocaletakes no reference, and that a null locale throws and keeps the global;_Locinfocalls write, for accepted names and four categories, and thebad locale nameexception and the fields left for six rejected names.The original functions were loaded from the bundled module with their relocations applied. Their imports were bound by NID to this branch's libc and libkernel. The module's heap is not set up outside a console process, so its allocation calls were redirected to the host's. Its
_Xruntime_errorand this branch's were both redirected to one recorder, so each side's rejections were compared by message.Side by side with the patched production library, over two seeds with 20,000 trials each:
_Locimpthatempty()and_New_Locimpbuild, compared field by field;classic(),_Clocptr,_Getgloballocaleand_Initagree after the module's_Initbuilt its classic locale;global,_Setgloballocale,_Initand_Getgloballocalecalls over the classic locale and six other_Locimps, with about 8,000 switches, of which about 3,300global()calls changed the global. Each step compared the returned locale, the global and every reference count except the classic one's, which differs by design.No comparison differed.
Negative control: five lines were altered one at a time:
global()kept the old global's reference;empty()built an opaque_Locimp;_Init(true)took no reference;_Locinfoconstructor stored the classic name before checking the name.The new CTest failed on each, and the side-by-side run reported differences each time. 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,863 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 38 branches that already conflict with main. Merging each of the 38 with this branch and with main usinggit merge-treegives the same conflict blocks, except indocs/dev/debt/libc.mdfor #5021, #9371, #9447 and #9526: their conflict block there already spans the end of the functional section, which holds the versioned locale entry this PR corrects, so the corrected line and the new entry next to it land inside it. The new entry adds no conflict with any of the 141 open PRs that touch that file. #13486 names the unversionedstd::locale::_SetgloballocaleinlibSceLibcInternal, not these exports. No open PR adds these names or NIDs. The branch also merges cleanly with #14595, #15336, #15471, #15484, #15490, #15501, #15519, #15552, #15561, #15602, #15614, #15667, #15683, #15791, #15796, #15809, #15834, #15879, #15923 and #16083.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