feat(libSceLibcInternal): implement locale and facet leftovers #28568
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28568"
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 GODOSTROYER on 2026-12-01T20:40:29Z.
What
Implements 14 libSceLibcInternal locale, facet and filesystem exports, mostly in new files, and deletes their stubs.
numpunct<char>duplicates (8):_Init, the(const _Locinfo&, size_t, bool),(size_t)×2 and(const char*, size_t, bool)constructors and the D0, D1 and D2 destructors forward to libc'snumpunct<char>implementation of the same names, so they share its gaps._Initallocates the grouping, false and true names and the destructors free them, so a facet built here can be destroyed here. This library's_Tidystays the bareretfirmware 13.42 has (the existing "Empty facet and exception members" entry), so a direct_Tidycall leaves those three buffers allocated; the debt records that, and that theretsuggests the module's facet may own no buffers.num_put<wchar_t>(size_t)C1/C2 (2): set the vtable and reference count as the existing_Locinfoconstructor does. Dinkumware's_Initis empty fornum_put.filesystem::_Equivalent(1): Dinkumware's -1/0/1 contract (crt.vc12filesys.h): -1 when neither name resolves, 0 when one does not or they differ, 1 for the same file. A name resolves whenstatsucceeds on it, following symbolic links, so unlike the cited Windows code two names of one directory give 1. Identity is the host's, read by a new libkernel helperGuestPathIdentity_nid_no_patchthat resolves the guest path asstatdoes: device and inode on Unix; the volume serial number and 64-bit file index on Windows, which the cited code compares; the archive entry for a file read from app0.zar. The gueststatinode is only 32 bits (the low 32 bits of the host inode on Unix; on Windows the 64-bit file index folded byGuestFileNumber.hpp), so comparing it made distinct files compare equal. The debt records that ReFS's 128-bit file IDs are not compared.std::locale::_Setgloballocale(1): stores the pointer as given, null included, as Dinkumware'slocale0.cppdoes, through a new libc helper beside_Getgloballocale. As that version'slocale::_Initrebuilds the C locale when the global is null, libc'slocale::_Init,locale::globaland facet lookups now reinstall libc's classic locale as the global, so a laterstd::locale()orstd::locale::globalworks. The debt records two gaps:_Locimpand makes it the classic locale too, while herelocale::classic()keeps its object.num_put<char>/<wchar_t>::_Fput(2): insert the before-point, after-point and trailing zeros where Dinkumware V6.00's four-size_Fputin crt.vc12xlocnumdoes, then run microsoft/STL's one-size_Fputfor grouping, fill and adjustment. microsoft/STL never had the four-size form, so crt.vc12 is cited only as evidence for where the zeros go. The Apache-2.0 WITH LLVM-exception notice and pinned link of the microsoft/STL source headNumFacetExtensions.cpp, as inNumGet.cpp. libc gains two helpers that write narrow characters to a guest output iterator.inf, is grouped too.do_widen, not the single-character one.count + 1bytes, or an unreadable one, throwsstd::invalid_argument; an insert offset beyond the text throwsstd::out_of_range.ctypewidens as the classic one; one withoutnumpunctuses no grouping and..Left throwing, with reasons:
codecvt<wchar_t, char>do_in/do_out/do_unshift/do_length: no reading of Sony's facet. libc's_Mbrtowc/_Wcrtombtake no_Cvtvec, unlike MS STL's, so implementing them would mean guessing the facet layout and conversion state._Locimp::_Makeloc/_Makewloc/_Makexloc: they must build every standard old-ABI facet, and several of those constructors are still stubs.num_get_Getffldx: the two Dinkumware versions disagree (the older one reads every field as hex), and nothing settles which one the module has.The
_Printf/_Scanf/_Putfldformatted-I/O engine is not in this PR. Neither accepted Dinkumware source containsxstdio.h,xprintf.corxscanf.c: xtosCrt/stlis C++ support code only, and crt.vc12 has the math and conversion files only. Those exports stay as they are, and the existing debt already records them as unverified and throwing.Debt: the new fragment
feat-libcinternal-locale-leftovers.mdremoves the entries of the 14 stubs and adds the Functional entries above. It also edits the pending fragmentfix-libc-current-set.mdin place. Its_Stat…_Current_set2entry ended with "_Equivalentand the three-argument_Xfilesystem_errorstill throw". This PR implements_Equivalent. The_Xfilesystem_errorclause was already stale onmain:Wut42WAe7Rwforwards to libc's two-path filesystem error, which throwsfilesystem_errorby design. The edit is in place becausetools/debt_fold.pyrefuses two fragments that change the same entry. Ifmainfoldsfix-libc-current-set.mdbefore this lands, the rebase hits a modify/delete conflict; it is resolved by moving the shortened entry into this PR's fragment as a## change.Overlap, run by the owner's
tools/pr_overlap.pyon headc9741fb873withmainat1891347284: no shared exports; line conflicts with #17746, #19434, #24905, #24911 and #27697; 6 PRs could not be compared. This head adds commits that also touch libkernel'sOpen.cppandNativeStat.cpp/.hpp, so the check needs a rerun on this head.Tested
The full build was not rerun after the final rebase. The focused targets below were built and run on this head,
fad1cb11b2.Linux x86-64 (Ubuntu 24.04, GCC), Release:
guest_libc_internal_locale_leftovers,guest_libc_internal_num_facet_extensions,guest_libc_internal_locale_stateandguest_libc_internal_unversioned_filesystempass.guest_locale,guest_sce_v2_locale,guest_sce_v2_locale_basics,guest_c_locale_helpers,guest_multibyte_locale,guest_numpunct_facet,guest_libc_numpunct_char,guest_libc_filesystem,guest_sce_v2_filesystemandguest_sce_v2_filesystem_callspass, as does libkernel'sguest_kernel_fstat.test_public_headers.py --audit-onlyanddebt_fold.py --checkpass.numpunctforwarders are compared field by field against libc. Through a counting test heap, D1 and D2 free the three names, and D0 frees them and the facet._Setgloballocalestores a pointer, stores null and restores the original. After a null global,_Initand a facet lookup return the classic locale and make it global again, andlocale::globalinstalls its argument and returns the classic locale._Equivalentis checked with the same path, the same file by another path, a hard link, different files and missing files. The identity helper gives the full host device and inode on Linux, different identities for different files and none for a missing file. Inodes that differ only above bit 31, Windows and app0.zar entries are not exercised._Fputwith zero counts is compared against libc's one-size formatting. With non-zero counts it is compared against hand-derived outputs: zeros before and after the point and trailing, zeros before the exponent, hexfloat, grouping across inserted zeros and ofinf, and a wide locale. A grouping string too long for a host string throws and its guest storage is released; that check fails on the previous head.progress.py --module libSceLibcInternal: 724/1127 onmain→ 738/1127 on this head (735 at the earlier headc9741fb873).Overlap was checked on the previous head by a merge test against the open upstream PRs that touch these files: no functional overlap (#28312, #27697 and #25573 implement other
numpunct/_Locimpmembers). New adjacency conflicts are 1–2 hunks each with #24905, #24907, #24911 and #27697, plus a few more with #17746, #25573, #27697 and #24907, which already conflict withmain.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)Written with Claude Opus 5.5 (Claude Code).
Signed-off-by: Arnav Bule [email protected]
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-02T01:37:53Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T01:49:53Z.
Review: COMMENTED
Actionable comments
4e069d75-80b7-4239-9edb-539cfbe8dcc0Reviewing files that changed from the base of the PR and between
6a1b7a1920andfad1cb11b2.core/libs/prx/libSceLibcInternal/CMakeLists.txtcore/libs/prx/libSceLibcInternal/Err.cppcore/libs/prx/libSceLibcInternal/Export.cppcore/libs/prx/libSceLibcInternal/FilesystemEquivalent.cppcore/libs/prx/libSceLibcInternal/InventoryExports.cppcore/libs/prx/libSceLibcInternal/InventoryExports6.cppcore/libs/prx/libSceLibcInternal/LocaleGlobal.cppcore/libs/prx/libSceLibcInternal/NumFacetExtensions.cppcore/libs/prx/libSceLibcInternal/NumPutField.cppcore/libs/prx/libSceLibcInternal/NumpunctConstruction.cppcore/libs/prx/libSceLibcInternal/include/ErrExports.hppcore/libs/prx/libSceLibcInternal/include/InventoryExports.hppcore/libs/prx/libSceLibcInternal/include/InventoryExports6.hppcore/libs/prx/libSceLibcInternal/include/LocaleLeftovers.hppcore/libs/prx/libSceLibcInternal/include/NumFacetExtensions.hppcore/libs/prx/libSceLibcInternal/libSceLibcInternal.hppcore/libs/prx/libc/include/GuestLocale.hppcore/libs/prx/libc/src/LocaleSupport.cppcore/libs/prx/libkernel/File/include/NativeStat.hppcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/tests/GuestLibcInternalLocaleLeftovers.cppcore/libs/tests/GuestLibcInternalNumFacetExtensions.cppdocs/dev/debt/changes/feat-libcinternal-locale-leftovers.mddocs/dev/debt/changes/fix-libc-current-set.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T02:29:17Z.
Review: APPROVED
Reviewed — looks good
No verified blocking defects were found in the changes reviewed at
fad1cb11b273dff2bcf6b23cfcad8458a7566aac.What I ran
Reviewed the prepared diff and targeted source context at the exact head above. I did not run builds or tests; the focused Linux tests listed in the PR description are author-reported.
Results
Negative control
A negative control could not be run because no tests were run locally.
Findings
Blocking
None.
Non-blocking
None.
Sources
NumFacetExtensions.cppat the reviewed head — four-size formatting, locale facets, grouping, and padding.LocaleSupport.cppat the reviewed head — restoring the classic locale when the global locale is null.Open.cppat the reviewed head — guest path resolution and file identity lookup.Not verified
The full build, console behavior, Windows behavior, archive identity cases, and ReFS identity handling were not run or confirmed. I reviewed all 25 paths listed under
reviewedinfiles.json;files.jsonlists no excluded paths.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T03:06:57Z.
Review: COMMENTED
Actionable comments
5c06ce12-65bd-42af-be75-9c828936331aReviewing files that changed from the base of the PR and between
fad1cb11b2and2b5940cd7e.core/libs/prx/libSceLibcInternal/NumFacetExtensions.cppcore/libs/tests/GuestLibcInternalLocaleLeftovers.cppcore/libs/tests/GuestLibcInternalNumFacetExtensions.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T04:00:01Z.
Review: COMMENTED
Reviewed — comments
The inspected implementation paths show no verified defect, but the review is incomplete because several changed files were not read in full.
What I ran
Reviewed head
2b5940cd7e8440f38ba790e0e9ab6b1dd172141cusing the prepared diff, snapshots, and pinnedrepo_read.pysource ranges. No tests or builds were run. The test results in the PR description are author-reported.Results
Negative control
Not run; no tests were executed in this review.
Findings
Blocking
None verified in the inspected paths.
Non-blocking
None.
Sources
The four-size formatting implementation and its grouping, padding, and insertion logic are in NumFacetExtensions.cpp at the reviewed head. The filesystem identity comparison is in FilesystemEquivalent.cpp at the reviewed head.
Not verified
The manifest lists 25 changed paths. I read full snapshots or targeted source ranges for 15 paths:
FilesystemEquivalent.cpp,LocaleGlobal.cpp,NumFacetExtensions.cpp,NumPutField.cpp,NumpunctConstruction.cpp,ErrExports.hpp,InventoryExports.hpp,InventoryExports6.hpp,LocaleLeftovers.hpp,NumFacetExtensions.hpp,GuestLocale.hpp,LocaleSupport.cpp,NativeStat.hpp,NativeStat.cpp, andOpen.cpp. The newGuestLibcInternalNumFacetExtensions.cpptest snapshot was also read. Other changes were not fully reviewed, includingCMakeLists.txt,Err.cpp,Export.cpp,InventoryExports.cpp,libSceLibcInternal.hpp,GuestLibcInternalLocaleLeftovers.cpp, and both debt fragments. Some related changes were visible only as diff hunks. Windows behavior, app0.zar identity behavior, and runtime behavior were not independently checked.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T08:08:58Z.
Review: COMMENTED
Actionable comments
3a30a76d-ae53-47e2-afd1-895fd0303016Reviewing files that changed from the base of the PR and between
2b5940cd7eand79daa5776c.core/libs/prx/libSceLibcInternal/InventoryExports.cppcore/libs/prx/libSceLibcInternal/NumpunctConstruction.cppcore/libs/prx/libSceLibcInternal/include/InventoryExports.hppcore/libs/prx/libSceLibcInternal/include/LocaleLeftovers.hppcore/libs/tests/GuestLibcInternalLocaleLeftovers.cppdocs/dev/debt/changes/feat-libcinternal-locale-leftovers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T08:09:13Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
79daa5776c739b3b6296e0eaf979a090b9d91af7. I inspected the prepared diff and selected changed-file excerpts. I did not run tests, builds, or other checks. The pinned reader could not return further context because its attempt to write a read log was blocked by the read-only filesystem.Results
Negative control
Not run; no tests were run.
Findings
Blocking
None identified in the inspected excerpts.
Non-blocking
Nothing is required. Optional: complete the review of the remaining changed files once the pinned reader can return source context.
Sources
The prepared diff and included files were the sources for the inspected changes. No behavior claims beyond those excerpts are made.
Not verified
The pinned reader did not provide additional repository context, and no tests or builds were run. Focused source excerpts were read from
FilesystemEquivalent.cpp,LocaleGlobal.cpp,NumFacetExtensions.cpp,NumPutField.cpp,NumpunctConstruction.cpp,LocaleLeftovers.hpp,NumFacetExtensions.hpp,LocaleSupport.cpp,NativeStat.hpp,NativeStat.cpp,Open.cpp, andGuestLibcInternalLocaleLeftovers.cpp.files.jsonlists 23 reviewed files and 0 preparation-excluded files; the remaining changed files were not fully inspected.To get this to a good state
Nothing is required. Optional: complete the remaining source review and run relevant non-build checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T04:01:04Z.
Review: COMMENTED
Both
GuestLibcInternalLocaleLeftoversandGuestLibcInternalNumFacetExtensionspassed on Linux with the exact locale sources and native file-stat implementation. The numeric checks covered narrow and wide formatting, the guarded digit read, and releasing the guest grouping allocation if the host copy throws.I also exercised
_Equivalentagainst a realapp0.zar. Two spellings of the same archived file compared equal, two distinct entries with identical contents compared unequal, and a native file placed over one archived entry received a distinct native identity and still compared equal to itself through the alternate spelling. This verifies the archived and native overlay paths on Linux. Windows file identities and retail locale behavior were outside the run.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.