feat(libc): export the std::__sce_v2 _Makeloc family with the standard facet objects #16178
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16178"
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-05T19:58:41Z.
What
Builds on #16165 and #15923: this branch contains their commits, and #16165 contains #16113. Until they merge, only the last commit is this PR's change.
Export the versioned
std::__sce_v2locale::_Locimpfunctions that build the standard facets of a locale, and the facet objects they install._ZNSt8__sce_v26locale7_Locimp8_MakelocERKNS_8_LocinfoEiPS1_PKS0_V-xbiecN6hk0xF19F0_ZNSt8__sce_v26locale7_Locimp9_MakexlocERKNS_8_LocinfoEiPS1_PKS0_vwBEHHisimo0xF2980_ZNSt8__sce_v26locale7_Locimp9_MakewlocERKNS_8_LocinfoEiPS1_PKS0_eluUL39Y-Aw0xF4410_ZNSt8__sce_v26locale7_Locimp11_MakeushlocERKNS_8_LocinfoEiPS1_PKS0_PSGlrerN-7s0xF6600The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6). As in the module:_Makeloc(info, category, self, locale)installsctype<char>,num_get,num_put,numpunctandcodecvt<char>, then calls the other three functions. It ORs the category into the mask, takes the name from the_Locinfoand returnsself._Makexlocinstalls the remainingcharfacets, and_Makewlocand_Makeushlocinstall thewchar_tandunsigned shortsets. The order is the module's, so facet ids are assigned in the same order. Together the four functions install 39 facets: 6 forctype, 9 fornumeric, 3 forcollate, 3 formessages, 12 formonetaryand 6 fortime.localeconvwhere the module reads them.numpunctuses.and,, and itsmoneypunctuses the$+xvpatterns. A bad locale name throwsruntime_error, but only when a default has to be built.unsigned shortnumpunct,moneypunctandtime_getfacets own heap copies of their strings, and their destructors free them. A failed string allocation frees what was built and throwsbad_alloc.Only the retain, release, destroy and delete slots of these facets work. Every other virtual throws
NotImplemented_nid_no_patch, so stream output through a locale built here stops at the first facet call. The classic_Locimpkeeps its one-slot vector, so its users do not reach those virtuals. Implementing the virtuals by family and filling the classic locale are follow-ups.The versioned
_Facet_Registernow prepends a{next, facet}node as the module does, and the versioned locale debt entry drops that sentence. A new debt entry lists what still differs.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, on top of #16165 (b24626696c2) and #15923 (aae14a4ddc6). The branch merges cleanly with mainc4469b60daf. Exact tested commit:67d850c1423.Built libc, libkernel, their NID-patched production libraries and the related tests. The new
guest_sce_v2_makelocpasses, along withguest_sce_v2_locimp_references,guest_sce_v2_locale,guest_sce_v2_locale_basics,guest_sce_v2_facet_ids,guest_locale,guest_sce_v2_exceptionsandpublic_headers.The NID-patched libc contains the four new NIDs.
The new test checks:
ctype,codecvt,numpunct,moneypunct,time_getandtime_putfacets;moneypunctfollowslocaleconvfor digits, separators, patterns and theunsigned shortstrings;ctypefrees a table it owns;bad_allocand frees the strings of the unfinished facet.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. Both sides'
_Xbad_allocand_Xruntime_errorwere redirected to one recorder, which exits bylongjmp. The heap log stops at the failed allocation, because thelongjmpskips the module's landing pads. Allocation failures were injected incallocand in the facet vector, not inoperator new. Both sides use the same fake_Locinfo, and the global locale was set with_Setgloballocaleinstead of the module's_Init.Side by side with the patched production library, over two seeds with 200,000 random steps each: about 116,600 builds per seed (80,600 without a source locale and 36,000 with one), 3,900
bad_allocthrows, 116,600 deleted locales, 16,700 changes tolocaleconv's monetary and numeric fields, 16,600 changes of the global locale, 48,000 facet retains and releases, and 2,200 edits of destructor-owned fields. A default facet is built once per process, so 30 more processes ran with 6,000 steps and different seeds; they hit 56 bad names. Each build compared:_Locimp's references, mask, name and count, and the id counter;malloc,calloc,reallocandfreecalls.The module's
free(NULL)calls are ignored. No comparison differed across about 795,000 comparisons. The side-by-side run found one bug during development: the widectypedestructor frees the table for any nonzero mode. #16165's side-by-side run also still passes with two seeds. The non-lifetime virtuals were not compared, because they throw here.Negative control: seven changes were made one at a time:
_Makelocdid not update the mask;ctypefreed its table only for a positive mode;unsigned shortnumpunctdid not free one string;moneypunctpattern index was wrong;_Makewlocinstallednum_get<wchar_t>wherenum_put<wchar_t>goes.CTest failed on each. The side-by-side run reported differences on five and crashed on the other two (the missing reference and the wrong
num_putstep). The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the tests and side-by-side run passed again.Code conventions and
git diff --checkpass.tools/pr_overlap.pyread 1,898 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 33 branches that already conflict with main. Merging each of the 33 with this branch and with main usinggit merge-treeadds no conflict block in the files this PR touches. For #5021, #9371, #9447 and #9526 the new debt entry lands inside the conflict block they already have indocs/dev/debt/libc.md. #13486 adds the unversioned names of these functions to another debt file, and no open PR adds the versioned names or NIDs. The debt position adds no conflict with the 141 open PRs that touch that file, apart from #16165, which this branch contains. 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, #16083, #16113 and #16165.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T22:29:24Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes blocks merging; the reported test results are author supplied, and this review did not run checks.
What I ran
Reviewed prepared diff for head
f9d7de6cace80e7573b4125c4abf33482a9c92f1and inspected targeted source context throughrepo_read.py. No build or tests were run.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The full source contents of
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/Api.hpp,core/libs/tests/GuestSceV2Makeloc.cpp, anddocs/dev/debt/libc.mdwere not read; relevant diff portions were inspected. The rest ofcore/libs/prx/libc/src/LocaleSupport.cppbeyond inspected ranges was not read. The review manifest lists these five changed files as included; all five were represented in the prepared diff, but onlyLocaleSupport.cppwas read from the repository at head. Build, tests, console behavior, and author-reported experiments were not independently verified.To get this to a good state
Nothing is required.