Repository navigation
feat(libc): export the std::__sce_v2 _Makeloc family with the standard facet objects - #16178
Conversation
…d facet objects _Makeloc, _Makexloc, _Makewloc and _Makeushloc build the 39 standard facets of the requested categories and install them with _Locimp_Addfac, as the console's libc.prx does. Without a source locale each facet takes its fields from localeconv. With one, a facet comes from that locale, from the global locale if it is transparent, or from a default built once per facet type with the module's default punctuation and kept with a reference of its own. The facets have the module's sizes, fields and destructors. Their retain, release, destroy and delete slots work. Every other virtual throws NotImplemented, so the classic locale stays without facets. The versioned _Facet_Register now prepends a node as the module does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Progress report (2a8a0d1 → f9d7de6)📈 System libraries: 41.84% (+0.0059%, +4 implemented functions) ✅ 4 implemented
Changed libraries (implemented exports)
|
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows check of head Setup: Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (r7), Ninja, Release,
AI-assisted: yes. |
|
@Danigamer05 I reviewed 5a8306b. The facets, the category mask and the refcounting read right to me against Dinkumware _Makeloc. One change: g_sceV2MoneyPatterns at LocaleSupport.cpp:813 (used at :1406 and :1409) is byte for byte the Dinkumware _Makpat table, which is also what the module ships. Copied tables are not accepted here, whether they come from the module or from a library without its licence notice. Could you build the four-character pattern in code from cs_precedes, sep_by_space and sign_posn instead, keeping the same result for every index? |
Derive each four-character moneypunct pattern from cs_precedes, sep_by_space and sign_posn instead of reading it from a 120-byte table. Every one of the 30 indices gives the same pattern as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean Done in 6cb1b63. The table is gone.
A standalone check compared all 30 indices against the previous patterns: same result for each. |
MarcZX10
left a comment
There was a problem hiding this comment.
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 f9d7de6cace80e7573b4125c4abf33482a9c92f1 and inspected targeted source context through repo_read.py. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted code review | passed | Inspected implementation and ownership paths |
| Build and tests | not run | Results in the description are author reported |
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, and docs/dev/debt/libc.md were not read; relevant diff portions were inspected. The rest of core/libs/prx/libc/src/LocaleSupport.cpp beyond inspected ranges was not read. The review manifest lists these five changed files as included; all five were represented in the prepared diff, but only LocaleSupport.cpp was 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.
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. feat(libc): export the std::__sce_v2 _Locimp_ctor and _Locimp_dtor with facet reference counting #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 feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, fix(libc): follow a Windows symbolic link before .. in a guest path #9371, feat(libc): add the std::__sce_v2 thread start, timed wait, clock and processor count calls #9447 and feat(libc): add std::__sce_v2::_Random_device, _Fiopen and setw #9526 the new debt entry lands inside the conflict block they already have indocs/dev/debt/libc.md. fix(relinker): match AppContent utility import to provider #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 feat(libc): export the std::__sce_v2 _Locimp_ctor and _Locimp_dtor with facet reference counting #16165, which this branch contains. The branch also merges cleanly with fix(libc): preserve Dinkumware zero signs when no conversion occurs #14595, feat(libc): export the std::__sce_v2 extended-precision helpers #15336, feat(libc): export the std::__sce_v2 multiprecision helpers #15471, feat(libc): export the std::__sce_v2 _Poly and _XLgamma helpers #15484, feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper #15490, feat(libc): export the std::__sce_v2 _Exp and _FExp helpers #15501, feat(libc): export the std::__sce_v2 _Pmsw, _FPmsw and _LPmsw helpers #15519, feat(libc): throw std::bad_cast and the std::__sce_v2 bad_any_cast, format_error and future_error #15552, feat(libc): forward the std::atomic wait and notify helpers to libkernel #15561, feat(libc): count the std::__sce_v2 _Winit and ios_base::Init initializations #15602, feat(libc): export the std::__sce_v2 floating-point constants #15614, fix(libc): store the std::__sce_v2 _Throw_Cpp_error value in the first code word #15667, feat(libc): export the std::__sce_v2 _Stollx, _Stoullx, _Stolx and _Stoulx parsers #15683, feat(libc): export std::_Throw_bad_any_cast and std::_Throw_bad_node_access #15791, feat(libc): export the std::error_category complete and deleting destructors #15796, feat(libc): export the std::__sce_v2 resetiosflags, setiosflags, setbase and setprecision manipulators #15809, feat(libc): export the std::__sce_v2 _Timespec64_get_sys and _Timespec64_diff_to_ts clock helpers #15834, feat(libc): export the std::__sce_v2 at-thread-exit registry calls #15879, feat(libc): export the remaining std::__sce_v2 facet ids and ios_base _Sync and _Index #15923, feat(libc): export the std::__sce_v2 clog, wclog and standard stream pointers #16083, feat(libc): export the std::__sce_v2 locale::global, empty, classic and _Locinfo category calls #16113 and feat(libc): export the std::__sce_v2 _Locimp_ctor and _Locimp_dtor with facet reference counting #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)