Repository navigation
feat(libc): fill the std::__sce_v2 classic locale with its facets - #17610
Danigamer05 wants to merge 51 commits into
Conversation
…irtuals for char The facets built by _Makeloc threw NotImplemented from every virtual except the lifecycle slots. The char ctype, numpunct and codecvt facets now answer as the console's libc.prx does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…irtuals for wchar_t Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…get-char-20261107
Main removed GuestStringInlineCapacity, GuestStringCapacityMask and GuestStringLargeAllocation from LocaleSupport.cpp, so the versioned facets' strings use GuestLocale::StringInlineCapacity, GuestLocale::StringCapacityMask and GuestStringStorage::Deallocate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egers, bool and pointers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-facet-virtuals-20261105
Main removed GuestStringInlineCapacity and GuestStringCapacityMask from LocaleSupport.cpp, so AssignSceV2String uses GuestLocale::StringInlineCapacity and GuestLocale::StringCapacityMask. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t/libc-sce-v2-num-put-char-20261106
Main removed GuestStringInlineCapacity and GuestStringLargeAllocation from LocaleSupport.cpp, so TakeSceV2String tests GuestLocale::StringInlineCapacity and frees through GuestStringStorage::Deallocate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sce-v2-num-put-wide-20261107 Brings in current main through boykopovar#16516. The templated TakeSceV2String frees through GuestStringStorage::Deallocate, since main removed GuestStringLargeAllocation from LocaleSupport.cpp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sce-v2-num-get-char-20261107
…integers, bool and pointers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ating point Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sce-v2-num-get-wide-floating-20261108 # Conflicts: # docs/dev/debt/libc.md
…floating point Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_compare, do_transform and do_hash of collate<char> and collate<wchar_t>, and the nine virtuals of moneypunct<char, Intl> and moneypunct<wchar_t, Intl>, following the libc.prx of PPSA03671. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_open, do_get and do_close of messages<char> and messages<wchar_t>, following the libc.prx of PPSA03671: no catalog opens, and do_get returns a copy of the default string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_put of a long double and of a digit string for money_put<char> and money_put<wchar_t>, following the libc.prx of PPSA03671: Dinkumware's field writer with this module's character pattern encoding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_get for long double and for digit strings in money_get<char> and money_get<wchar_t>, following the PPSA03671 libc.prx: _Getmfld reads the negative pattern of the moneypunct facet byte by byte, matches the symbol, sign, grouped value with its fraction and spaces, and do_get converts the digits with _Stod or widens them into the string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement date_order, get_time, get_date, get_weekday, get_monthname, get_year and the single-field do_get of time_get<char> and time_get<wchar_t>, following the PPSA03671 libc.prx: its integer reader counts spaces as digits and converts with the v2 _Stolx, names match without case through the global locale's ctype, %x reads day first and %% never fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_put of time_put<char> and time_put<wchar_t>, following the PPSA03671 libc.prx: it formats "!%<modifier><specifier>" with strftime or wcsftime into a buffer grown by 16, 32, 64 units until the call succeeds, keeps errno, and writes the text after the leading mark. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give the thirteen unsigned short facets that _Makeushloc builds the virtuals of their wchar_t twins, as the PPSA03671 libc.prx instantiates the same code for both, looking up the unsigned short ctype, numpunct and moneypunct. collate<unsigned short>::do_compare walks the ranges unit by unit, as the module's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give std::__sce_v2's classic _Locimp the 25 char and wchar_t facets that the PPSA03671 libc.prx's locale::_Init adds when the library loads, name it C with every category, and make it the global locale, _Locimp::_Clocptr, _sceLibcClassicLocale and classic(), instead of the unversioned classic locale. It is built on the first locale call or facet id. 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. |
MarcZX10
left a comment
There was a problem hiding this comment.
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 7a47c466550322502e069127e765449611048d77 and targeted source context with the PR reader. The description reports Windows 11/MinGW testing and differential harness results; these were not independently run.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Initialization and locale callers inspected |
| Tests in this session | not run | Author-reported results only |
| Console behavior | not verified | Description says no title run |
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 changed core/libs/tests/GuestSceV2*.cpp files, and docs/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.
A review asked whether a field whose first 768 or more digits are zeros could reach the lost-digit rounding with no kept digit, and bump the leading zero or the decimal point. It cannot: leading zeros in the integer part are not counted, and leading fraction zeros only lower the power, so the first nonzero digit is always kept. Pin that down with 800 integer zeros, 769 fraction zeros before a 1 scaled back by e770, and both together. Counting leading zeros as significant fails two of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A review asked for a test of a moneypunct facet whose currency symbol is empty, since the optional-symbol checks compare the next character with symbol[0]. On a std::basic_string that is the terminating null, so the comparison is defined and an empty symbol simply matches nothing. Check it at the front and at the end of the pattern, with and without showbase, including input left after the value. Failing every empty symbol breaks these cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A review asked whether do_in should keep the caller's conversion state and for a test that splits a multibyte sequence across calls. As in the module, do_in starts each call from a clean state and does not consume an incomplete sequence, so the caller passes those bytes again with the rest. Check that the first call returns partial without reading the two bytes or touching the state, and that the second converts the euro sign and the character after it. Consuming the incomplete bytes fails both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
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 dc68baffe91c2c3b85d3317c89b6f8386f283c9b from the prepared bundle. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Bundle and change summary | passed | Description, commits and diff inspected |
| Targeted source review | passed | Locale initialization and facet lookup inspected |
| Full changed-line review | not run | Not every changed line was read |
| Tests | not run | Author-reported results were not independently run |
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, or docs/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.
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
ligmaSec
left a comment
There was a problem hiding this comment.
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.
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(feat(libc): add std::__sce_v2::_Random_device, _Fiopen and setw #9526, feat(libc): wire the codecvt<wchar_t,char> facet vtable #11172, feat(libc): export the money_put facet vtable as data #12518 and feat(libc): export the wide time_put facet vtable as data #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)