Repository navigation
feat(libc): implement the std::__sce_v2 messages virtuals - #17296
Danigamer05 wants to merge 30 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>
|
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 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 4860ac9cf3:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_facet_ids_tests,guest_sce_v2_makeloc_tests,guest_sce_v2_messages_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsfailed to build.core/libs/prx/libc/src/LocaleSupport.cpp:2977:49: error: no matching function for call to ‘min(const int64_t&, long long int)’ - Minor: please drop the
Generated withfooter from the description; the AI-assisted checkbox can stay.
Requesting changes for the points above.
…61108 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 49b19761b0:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_facet_ids_tests,guest_sce_v2_makeloc_tests,guest_sce_v2_messages_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsfailed to build.core/libs/prx/libc/src/LocaleSupport.cpp:2994:49: error: no matching function for call to ‘min(const int64_t&, long long int)’ - Minor: please drop the
Generated withfooter from the description; the AI-assisted checkbox can stay.
Requesting changes for the points above.
std::int64_t is long on Linux x86-64 and std::llabs returns long long, so std::min could not deduce a single type and LocaleSupport.cpp did not build there. Name std::int64_t explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@PrivacyOnion Thanks for the review. The build error came from 90d09a0 in #16944. It is fixed there in 942b87f ( On Ubuntu 24.04 with GCC 13.3, AI-assisted: yes |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against faf01748c3:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_facet_ids_tests,guest_sce_v2_makeloc_tests,guest_sce_v2_messages_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsbuilt cleanly. - CTest (
guest_sce_v2_makeloc,guest_sce_v2_char_facet_virtuals,guest_sce_v2_num_put_char,guest_sce_v2_num_put_wide,guest_sce_v2_codecvt_wide,guest_sce_v2_collate_moneypunct,guest_sce_v2_messages,guest_sce_v2_num_get_char,guest_sce_v2_num_get_wide,guest_sce_v2_facet_ids):1/10 Test #847: guest_sce_v2_char_facet_virtuals ... Passed 0.02 sec 2/10 Test #846: guest_sce_v2_makeloc ............... Passed 0.03 sec 3/10 Test #848: guest_sce_v2_num_put_char .......... Passed 0.02 sec 4/10 Test #849: guest_sce_v2_num_put_wide .......... Passed 0.03 sec 5/10 Test #850: guest_sce_v2_codecvt_wide .......... Passed 0.02 sec 6/10 Test #851: guest_sce_v2_collate_moneypunct .... Passed 0.02 sec 7/10 Test #852: guest_sce_v2_messages .............. Passed 0.02 sec 8/10 Test #853: guest_sce_v2_num_get_char .......... Passed 0.03 sec 9/10 Test #854: guest_sce_v2_num_get_wide .......... Passed 0.03 sec 10/10 Test #1133: guest_sce_v2_facet_ids ............. Passed 0.02 sec 100% tests passed, 0 tests failed out of 10 - Negative control: with
core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified that the previously reported GCC 13.3 build failure (
std::min(const int64_t&, long long int)) incore/libs/prx/libc/src/LocaleSupport.cpphas been resolved and all 10guest_sce_v2_*test targets build and pass on Linux x86_64. - Checked
std::__sce_v2::messages<char>andmessages<wchar_t>virtual functions (do_open,do_get,do_close) incore/libs/prx/libc/src/LocaleSupport.cppfor SSO threshold logic (15char/ 7wchar_t), dynamic capacity calculation (length | 15/length | 7), and null-terminator copying. - Verified that
guest_sce_v2_messages_testsincore/libs/prx/libc/CMakeLists.txtandGuestSceV2Messages.cppexercisesdo_open,do_get(both SSO and heap-allocated strings), anddo_closefor narrow and widemessagesfacets, and fails when the implementation is reverted. - Confirmed compliance with AGENTS.md rules (
tools/check_conventions.pypassed,git diff --checkclean, and technical debt updated indocs/dev/debt/libc.md). - Verified cross-platform LP64 (Linux) and LLP64 (Windows) compatibility across the stacked
SceV2locale changes and test targets.
- Verified that the previously reported GCC 13.3 build failure (
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed messages facets — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
- Head reviewed:
bf56220c779453962d012f8191192f654831cd01, basemain. The change is the stacked branch as shown indiff.patch; the messages virtuals are the last commit of this PR. - Read the title and body,
commits.md,manifest.json,files.jsonanddiff.patch. Read the messages virtuals and their registration incore/libs/prx/libc/src/LocaleSupport.cpp, the messages testcore/libs/tests/GuestSceV2Messages.cpp, the messages block ofcore/libs/prx/libc/CMakeLists.txt, and the_Makelocentries ofdocs/dev/debt/libc.md. - Repository searches at the head with
repo_read.py:
python3 repo_read.py search AllocateStringStorage
python3 repo_read.py search _Facet_Register
- No build and no test run on my side. The test results in the description are the author's.
Results
| Check | Result | Note |
|---|---|---|
| Messages code and test read | passed | Read in full |
| Rest of the diff read | not run | Read in part; see Not verified |
| Test build and run | not run | Author-reported only |
| No comments in added code | passed | Grep found none |
_Makeloc debt entry |
passed | Lists messages as working |
Findings
Blocking
None.
Non-blocking
core/libs/tests/GuestSceV2Messages.cpp:90—long_comes fromdo_getwith a 40-unit default, so its buffer is allocated throughAllocateStringStorageand never freed.core/libs/tests/GuestSceV2Messages.cpp:95(copiedEnd) leaks the same way. The process exits right after, so this does not affect the result, but the test allocates two heap strings it never releases.
Not verified
- The module-derived behaviour: the
do_getcopy rule, the0x20messages category, the vtable addresses and the SHA-256 oflibc.prx. I have no access to the module binary here. - Build and test results: the Windows 11 / MinGW GCC 15.2 run and the 150-test libc run are the author's report. I did not run them.
- Not read: most of
core/libs/prx/libc/src/LocaleSupport.cpp(num_put, num_get, codecvt, collate, moneypunct, money_get/put and time_get/put implementations and their registration), and the hunks ofcore/libs/prx/libc/include/GuestLocale.hppbeyond theSceV2IosBasechange. - Not read:
core/libs/tests/GuestSceV2CharFacetVirtuals.cpp,GuestSceV2CodecvtWide.cpp,GuestSceV2CollateMoneypunct.cpp,GuestSceV2Makeloc.cpp,GuestSceV2NumGetChar.cpp,GuestSceV2NumGetWide.cpp,GuestSceV2NumPutChar.cpp,GuestSceV2NumPutWide.cpp, andcore/libs/prx/libc/include/Api.hppbeyond its added declarations. - The messages test target in
core/libs/prx/libc/CMakeLists.txt(new line 502) does not listGuestSceV2Exceptions.S, which the_Makeloctest target does. I did not check whether this test needs it. - The
_Facet_Registerchange (LocaleSupport.cpp, around the_Facet_Registerdefinition) now prepends a node, and the matching debt sentence was removed. I saw the change in the diff but did not read the surrounding code.
To get this to a good state
Nothing is required. The non-blocking point above is optional.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a38d4007e8:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_messages_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsbuilt cleanly. - CTest (
guest_sce_v2_char_facet_virtuals,guest_sce_v2_num_put_char,guest_sce_v2_num_put_wide,guest_sce_v2_codecvt_wide,guest_sce_v2_collate_moneypunct,guest_sce_v2_messages,guest_sce_v2_num_get_char,guest_sce_v2_num_get_wide):1/8 Test #1132: guest_sce_v2_char_facet_virtuals ... Passed 0.12 sec 2/8 Test #1133: guest_sce_v2_num_put_char .......... Passed 0.13 sec 3/8 Test #1134: guest_sce_v2_num_put_wide .......... Passed 0.06 sec 4/8 Test #1135: guest_sce_v2_codecvt_wide .......... Passed 0.04 sec 5/8 Test #1136: guest_sce_v2_collate_moneypunct .... Passed 0.03 sec 6/8 Test #1137: guest_sce_v2_messages .............. Passed 0.03 sec 7/8 Test #1138: guest_sce_v2_num_get_char .......... Passed 0.04 sec 8/8 Test #1139: guest_sce_v2_num_get_wide .......... Passed 0.03 sec 100% tests passed, 0 tests failed out of 8 - Negative control: with
core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified do_open, do_get, and do_close implementations for both narrow char and wide char16_t std::__sce_v2::messages facets in core/libs/prx/libc/src/LocaleSupport.cpp against PPSA03671 v01.001.005 libc.prx specifications.
- Checked string copying mechanics in SceV2BasicString, ReserveSceV2String, and AssignSceV2String/AssignSceV2WideString, ensuring correct small string optimization thresholds (InlineCapacity: 15 for char, 7 for char16_t) and null termination.
- Audited memory layout, ABI calling conventions (APS5_VABI), and vtable slot alignment in SceV2MessagesCharVtable and SceV2MessagesWideVtable against GuestLocale::FacetVtable.
- Verified cross-platform 64-bit cleanliness (LP64 Linux vs LLP64 Windows) in size/capacity representation and pointer arithmetic.
- Confirmed AGENTS.md compliance, including lack of unauthorized code comments, proper technical debt accounting in docs/dev/debt/libc.md, and test integration in core/libs/prx/libc/CMakeLists.txt.
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The messages facet implementation appears consistent with the described behavior, but the full change is not verified because several changed files were not reviewed.
What I ran
Reviewed head a38d4007e813743a7cc8a0d221370f7536cc52fa using the pinned repo_read.py reader. I read the prepared description, commit list, diff, manifest, and review-folder README; I did not run tests or other commands.
Results
| Check | Result | Note |
|---|---|---|
| Messages implementation | passed | Inspected implementation and focused test |
| Test execution | not run | No checks run during this review |
| Full change review | not run | Several changed files were not read |
Findings
Blocking
None verified in the inspected messages implementation.
Non-blocking
None.
Not verified
The reviewed material included core/libs/prx/libc/CMakeLists.txt, core/libs/prx/libc/include/GuestLocale.hpp, core/libs/prx/libc/src/LocaleSupport.cpp, core/libs/tests/GuestSceV2Messages.cpp, and docs/dev/debt/libc.md (the relevant implementation and test ranges, plus the prepared diff). The changed files core/libs/tests/GuestSceV2CharFacetVirtuals.cpp, core/libs/tests/GuestSceV2CodecvtWide.cpp, core/libs/tests/GuestSceV2CollateMoneypunct.cpp, core/libs/tests/GuestSceV2NumGetChar.cpp, core/libs/tests/GuestSceV2NumGetWide.cpp, core/libs/tests/GuestSceV2NumPutChar.cpp, and core/libs/tests/GuestSceV2NumPutWide.cpp were not read. Their behavior and tests are not verified. No tests were run in this review; platform and in-title behavior were not confirmed.
To get this to a good state
Nothing is required for the inspected messages implementation. The unreviewed changed files need review before a formal approval is justified.
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>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The messages virtuals match the stated behavior in the inspected source; one test fixture may read beyond its backing string allocation.
What I ran
Inspected the prepared diff and source at head 07fda02256d1f751de8687e835649e9cc3740df6; no build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and messages implementation | passed | Target behavior inspected |
| Build and tests | not run | No commands run |
| Full changed-file review | not run | Several changed files unread |
Findings
Blocking
None.
Non-blocking
core/libs/tests/GuestSceV2Messages.cpp:98-104: the short-on-heap fixture points at astd::basic_stringwith only two characters but claims capacity 31. The implementation copies the full inline buffer for a short default, so this fixture can read beyond the string's allocated storage. Back it with a buffer sized to the claimed capacity before testing this case.
Not verified
Read review/description.md, review/commits.md, review/manifest.json, review/diff.patch, the complete GuestSceV2Messages.cpp, and the messages implementation in LocaleSupport.cpp. Did not read the other changed files, including the broader locale facet additions and tests; those changes are not reviewed here. Did not verify author-reported test results or run a negative control.
To get this to a good state
Nothing is required. The test-fixture point above is optional.
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. The focused GuestSceV2Messages fixture passed.
AI-assisted: yes.
What
Builds on #17277: this branch contains its commits, and through them #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current
main. It needs none of their code, only their place inLocaleSupport.cpp, so it stacks to avoid conflicts. Until they merge, only the last commit is this PR's change.Implement the three virtuals of
std::__sce_v2::messages<char>andmessages<wchar_t>, which_Makelocbuilds anduse_facethands to callers that look up translated strings. Before this PR, each of their six slots threwNotImplemented_nid_no_patch. These slots are not exports, so this PR adds no NID.The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), vtables0x18C8C8and0x18CFD0:do_openreturns -1: the module has no message catalogs.do_getreturns a copy of the default string, built as the module's copy constructor builds it. A default of at most 15charor 7wchar_tunits is copied with the whole 16-byte buffer it is read from; a longer one gets a capacity from its length,length | 15orlength | 7, and its units are copied with the one after them. The source buffer is chosen by the default's capacity, as the module does.do_closedoes nothing.The
_Makelocdebt entry listsmessagesamong the working facets.Tested
Windows 11, MinGW GCC 15.2, Release, head on top of #17277. Not run on Linux or macOS, not run in a title.
guest_sce_v2_messages:do_open,do_close, anddo_getwith short, long and short-on-heap defaults for both character types, checking sizes, capacities, the copied inline buffer and the unit after a long default._Makeloc. Defaults of 0 to 4,400 units, inline or on the heap, with random bytes after the length and capacities that do not match the length. It compares the result, the returned string's size, capacity, inline buffer or heap contents, and the allocations each side makes: 900,000 calls over 3 seeds (about 396,000 heap defaults and 303,000 allocated results), 0 differences.guest_sce_v2_*, locale, string andpublic_headerstest): all pass.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 45 PRs that conflict withmainon shared files, and 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, feat(libc): export the wide time_put facet vtable as data #12704) none adds these virtuals.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)