feat(libSceLibcInternal): construct the moneypunct facet and answer its members #18135
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18135"
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 QW1CKS on 2026-11-10T15:22:46Z.
What
The thirty-seven
moneypunctand_Mpunctexports threw: bothmoneypunct<char, bool>specialisations,_Mpunct<char>and_Mpunct<wchar_t>. Titles that format or parse a monetary value reach them throughmoney_putandmoney_get, so any currency formatting aborted.Each constructor now writes the facet libc models, with the classic C locale's values, and each
do_member reads a field of that facet. The libc side is new:GuestLocale::MoneyPunctFacetandWideMoneyPunctFacetare declared inGuestLocale.hppand answered inLocaleSupport.cppbehind descriptive_nid_postfixnames, and the guest exports forward to them, which is hownumpunctalready works. The classic C locale values come from the C standard:'.'and','separators, an empty grouping string, an empty currency symbol and sign,CHAR_MAXfrac digits, andsymbol sign none value/sign symbol none valuepatterns.This does not implement
money_getormoney_put, which read and write the fields this PR provides, and it does not read the values from an installed locale: a constructor given a name other than"C"throwsstd::invalid_argumentrather than silently reporting classic values for a locale that asks for something else. Those names are recorded in the debt file.37 exports, all bound by their NID.
libSceLibcInternal347/1128 to 384/1128 (30.76% to 34.04%),libc1755/1763 to 1792/1800, overall 37.06% to 37.21%. Stubs inlibSceLibcInternal789 to 752.Tested
Linux, x86-64, GCC 13 (
build-gcc, Release), AMD EPYC 7763.ctest --test-dir build-gcc -R guest_libc_internal_moneypunctpasses.sceLibcInternalMoneyPunctDoDecimalPointChar_nid_no_patchthrowing instead of reading the field aborts it withwhat(): sceLibcInternalMoneyPunctDoDecimalPointChar_nid_no_patch not implemented. Restored, it passes.ctest --test-dir build-gcc -R guest_libc_internalpasses, 37 of 37.python3 tools/check_conventions.py --base upstream/mainreports all checks passed.The new test covers every constructor and every
do_member on both specialisations, the reference count taken from the argument, the_Locinfoconstructors, destruction of a heap facet, the non-classic name throw, and a derived vtable to prove thedo_members are read through the facet rather than from a fixed table.Not tested: a title formatting a monetary value, and a locale other than
"C", which this PR does not support. Not run on Windows or macOS.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 PrivacyOnion on 2026-11-11T17:01:39Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e36012df66:tools/check_conventions.pypassed;git diff --checkclean.windows.guest_libc_internal_moneypunct_testsbuilt cleanly.guest_libc_internal_moneypunct):core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/InventoryExports6.cpp,core/libs/prx/libSceLibcInternal/include/Api.hpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports2.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp,core/libs/prx/libSceLibcInternal/include/PendingExports.hpp,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._ZNKSt7_MpunctIcE14do_frac_digitsEv_nid_postfix(and theMoneyPunctVtable::fracDigitsfunction pointer) is declared and implemented returningcharinstead ofint. In ISO C++ (std::moneypunct<charT>::do_frac_digits() const) and the PS5 Dinkumware runtime ABI (as previously defined inInventoryExports2.hpp),do_frac_digits()returnsint. Returningcharin%alinstead ofintin%eaxleaves the upper 24 bits of%eaxunextended/uninitialized under the System V AMD64 ABI, causing guest callers expectingintto read corrupted frac digit counts._ZNKSt7_MpunctIwE14do_frac_digitsEv_nid_postfix(and theWideMoneyPunctVtable::fracDigitsfunction pointer) is declared and implemented returningcharinstead ofint. In ISO C++ and the PS5 Dinkumware runtime ABI (as previously defined inErrExports.hpp),moneypunct<wchar_t>::do_frac_digits()returnsint. Returningcharviolates the ABI and produces garbage in high register bits on caller side.sceLibcInternalMoneyPunctDoFracDigitsChar_nid_no_patchis declared and implemented returningcharinstead ofint. PS5'slibSceLibcInternalwrapper formoneypunct<char>::do_frac_digitsreturns a 32-bitint.sceLibcInternalMoneyPunctDoFracDigitsWide_nid_no_patchis declared and implemented returningcharinstead ofint. PS5'slibSceLibcInternalwrapper formoneypunct<wchar_t>::do_frac_digitsreturns a 32-bitint.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T03:02:13Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: make the
_Locinfoconstructors reject or correctly handle unsupported non-C locale data instead of silently installing C-locale values.What I ran
Reviewed head
e36012df661dd7268b2d3f93dd5356589a29b5f4from the prepared diff and repository reader. No commands or tests were run.Results
Findings
Blocking
core/libs/prx/libc/src/LocaleSupport.cpp:976-978: The_Locinfoconstructor discardsinfoand always initializes the facet with C-locale values. Unlike the named constructor, it does not reject unsupported locale data, so constructing a facet from a non-C locale silently returns incorrect punctuation and monetary fields. Validate the locale represented byinfoand reject unsupported data, or populate the facet from it.Non-blocking
None.
Sources
Not verified
No tests, build, console behavior, or non-C locale behavior were run. Read the prepared description, commits, manifest, and diff; reviewed the changed money-punctuation implementation, locale facet declarations, export declarations, CMake test registration, and debt entry. The other changed export inventory and declaration files were inspected through their diff hunks. The excluded-file list was not available in the review folder.
To get this to a good state
Reject unsupported locale data in each
_Locinfoconstructor or implement loading those values. Then rerun the focusedguest_libc_internal_moneypuncttest and review the updated head.Pull request closed