feat(libc): fill the std::__sce_v2 classic locale with its facets #17610
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17610"
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-09T02:12:25Z.
What
Builds on #17607: this branch contains its commits, and through them #17578, #17568, #17539, #17331, #17296, #17277, #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current
main. It needs the facets those PRs implement, so it cannot stand alone. Until they merge, only the last commit is this PR's change.Give
std::__sce_v2's classic locale its facets, as thelibc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6) does. Until now the versioned classic locale, global locale,_Locimp::_Clocptrand_sceLibcClassicLocalewere all the unversioned classic_Locimp, which holds nostd::__sce_v2facet.use_facetbuilt each facet the first time a stream asked for it, so formatting worked. Buthas_facetand the facet vector oflocale::classic()found nothing, and the facet ids depended on the order in which a title first used each facet.What the module does, read from the disassembly of
locale::_Init(0xCFE60),classic(0xCFE30),_Getgloballocale(0xCFD40),_Setgloballocale(0xCFD50) and the library's static initializer (0xF2940):When the library loads, its static initializer calls
_Init(true)and keeps the result in_sceLibcClassicLocale.The first
_Initfills a static classic_Locimp, made with the name*, with 25 facets in this order:char:ctype,num_get,num_put,numpunct,codecvt,collate,messages,money_get,money_put, bothmoneypunct,time_getandtime_put;wchar_t: the same, withoutcodecvt.So these facets take ids 1 to 25. Each facet holds two references and the vector has 40 slots.
It then names the locale
C, gives it every category, and retains it twice. It makes it the global locale and stores it as_Clocptrand as the objectclassic()returns.This PR builds the same locale on the first locale call or facet id assignment, which every facet use goes through. It then reaches the state the module has after loading: the 25 facets with two references each in ids 1 to 25,
codecvt<wchar_t>and theunsigned shortfacets left to_Makeloc, nameC, categories0x3F, and four references, counting the one_sceLibcClassicLocalekeeps._Clocptr,_sceLibcClassicLocaleandclassic()point to that object from the start._Getgloballocale,_Setgloballocale,globaland the transparent-locale fallback ofuse_facetbuild it before they use the global locale. The unversioned classic locale is unchanged.The
_Makelocdebt entry records that the facets arrive on first use instead of at load.Tested
Windows 11, MinGW GCC 15.2, Release, head on top of #17607. Not run on Linux or macOS. Not run in a title: PPSA03671 ships its own
libc.prx, which AnyPS5 converts and looks up before this library, so itsstd::__sce_v2calls never reach this code.guest_sce_v2_locale_basicsnow checks the classic locale's facets, references, name, categories and ids.guest_sce_v2_locimp_referencesnow takes the classic locale's own vtable for copies, and keeps its borrowed-vector case on the unversioned classic locale, the only one that still has that static vector._Init(true), it compares the classic locale's references, slot count, category, name, the facets present with their references, and the ids ofctype<char>,ctype<wchar_t>,codecvt<wchar_t>,num_put<char>andtime_put<wchar_t>. It also checks_Init,_Getgloballocale,classic(),_Clocptrand_sceLibcClassicLocale, which all give the same object.numpunct<char>'s decimal point and prints adoublethrough a stream on the classic locale and on a transparentempty()locale. It then moves the global locale to a copy and back withglobal, compares the references of the classic locale, the copy and the facet, and prints again after the switch.charandwchar_tand again forunsigned short: 0 differences.guest_fopen_errorsskipped.check_conventions,git diff --check: clean. Merges cleanly withmain.pr_overlapreports no open PR with the same functions or conflicting code. It could not compare 48 PRs that conflict withmainon shared files. None of the 4 that touchLocaleSupport.cpp(#9526, #11172, #12518 and #12704) touches the versioned classic or global locale.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 MarcZX10 on 2026-11-20T11:50:49Z.
Review: APPROVED
Reviewed — looks good
The changed locale initialization and facet registration are consistent with the described classic-locale state; no blocking defect was verified in the source and tests reviewed.
What I ran
No commands or tests were run. Inspected the prepared diff at head
7a47c466550322502e069127e765449611048d77and targeted source context with the PR reader. The description reports Windows 11/MinGW testing and differential harness results; these were not independently run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read the complete diff and all 18 changed files listed as included in the manifest:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp, the 14 changedcore/libs/tests/GuestSceV2*.cppfiles, anddocs/dev/debt/libc.md. The manifest marked all changed files included; no changed file was excluded. Targeted source ranges were additionally read for locale initialization, facet ID assignment, installation, global switching, and the modified locale tests. No build, test suite, Linux/macOS run, or console run was performed here.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:13:25Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because only selected changed lines and source ranges were read; the remaining changed behavior was not verified.
What I ran
Reviewed head
dc68baffe91c2c3b85d3317c89b6f8386f283c9bfrom the prepared bundle. No commands or tests were run.Results
Findings
Blocking
None identified in the inspected lines.
Non-blocking
None.
Not verified
The bundle lists 19 changed files; I read the description, commits, review README, manifest, selected diff ranges, and targeted ranges in
core/libs/prx/libc/src/LocaleSupport.cpp. I did not read every changed line or the full contents of the changed test files,core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/GuestLocale.hpp, ordocs/dev/debt/libc.md. Their behavior is not verified. No tests or build checks were run.To get this to a good state
Complete the changed-line review and run the applicable checks before making a formal review decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:12:38Z.
Review: COMMENTED
Built the branch’s locale implementation and matching headers against the existing Linux runtime, with the branch’s SceV2 exception assembly linked into the fixture. The focused locale-basics test passed.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.