Skip to content

feat(libc): export the std::__sce_v2 _Makeloc family with the standard facet objects - #16178

Merged
oneandonlydean merged 5 commits into
boykopovar:mainfrom
Danigamer05:feat/libc-sce-v2-makeloc-20261105
Nov 17, 2026
Merged

oneandonlydean merged 5 commits into
boykopovar:mainfrom
Danigamer05:feat/libc-sce-v2-makeloc-20261105

Conversation

@Danigamer05

@Danigamer05 Danigamer05 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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_v2 locale::_Locimp functions that build the standard facets of a locale, and the facet objects they install.

Export NID Original address Original size
_ZNSt8__sce_v26locale7_Locimp8_MakelocERKNS_8_LocinfoEiPS1_PKS0_ V-xbiecN6hk 0xF19F0 1268
_ZNSt8__sce_v26locale7_Locimp9_MakexlocERKNS_8_LocinfoEiPS1_PKS0_ vwBEHHisimo 0xF2980 1832
_ZNSt8__sce_v26locale7_Locimp9_MakewlocERKNS_8_LocinfoEiPS1_PKS0_ eluUL39Y-Aw 0xF4410 2956
_ZNSt8__sce_v26locale7_Locimp11_MakeushlocERKNS_8_LocinfoEiPS1_PKS0_ PSGlrerN-7s 0xF6600 3020

The behavior comes from the libc.prx bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6). As in the module:

  • _Makeloc(info, category, self, locale) installs ctype<char>, num_get, num_put, numpunct and codecvt<char>, then calls the other three functions. It ORs the category into the mask, takes the name from the _Locinfo and returns self.
  • _Makexloc installs the remaining char facets, and _Makewloc and _Makeushloc install the wchar_t and unsigned short sets. The order is the module's, so facet ids are assigned in the same order. Together the four functions install 39 facets: 6 for ctype, 9 for numeric, 3 for collate, 3 for messages, 12 for monetary and 6 for time.
  • Without a source locale, each facet is allocated with the module's size and starts with no references. Its fields come from localeconv where the module reads them.
  • With a source locale, a facet comes from that locale, then from the global locale if the source is transparent, then from a default built once per facet type. A default keeps a reference of its own. Its numpunct uses . and ,, and its moneypunct uses the $+xv patterns. A bad locale name throws runtime_error, but only when a default has to be built.
  • The unsigned short numpunct, moneypunct and time_get facets own heap copies of their strings, and their destructors free them. A failed string allocation frees what was built and throws bad_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 _Locimp keeps 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_Register now 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 main c4469b60daf. Exact tested commit: 67d850c1423.

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

Danigamer05 and others added 2 commits November 5, 2026 20:46
…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>
@JJenkx

JJenkx commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 67d850c142, merged onto main 151a2cb6e2 (1793116f79, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_sce_v2_facet_ids and guest_sce_v2_locale pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Progress report (2a8a0d1 → f9d7de6)

📈 System libraries: 41.84% (+0.0059%, +4 implemented functions)

✅ 4 implemented
Library Name
libc _ZNSt8__sce_v26locale7_Locimp11_MakeushlocERKNS_8_LocinfoEiPS1_PKS0__nid_postfix
libc _ZNSt8__sce_v26locale7_Locimp8_MakelocERKNS_8_LocinfoEiPS1_PKS0__nid_postfix
libc _ZNSt8__sce_v26locale7_Locimp9_MakewlocERKNS_8_LocinfoEiPS1_PKS0__nid_postfix
libc _ZNSt8__sce_v26locale7_Locimp9_MakexlocERKNS_8_LocinfoEiPS1_PKS0__nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1795/1802 (99.61%) 1799/1806 (99.61%) +0.0009%

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 7447 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7715 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8150 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8965 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9466 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9526 core/libs/prx/libc/src/LocaleSupport.cpp
docs/dev/debt/libc.md
PR 10409 docs/dev/debt/libc.md
PR 11172 core/libs/prx/libc/src/LocaleSupport.cpp
docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 12184 core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 12682 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 12688 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 12700 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 12717 core/libs/prx/libc/CMakeLists.txt
PR 12849 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12965 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 15973 docs/dev/debt/libc.md
PR 16791 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 17026 docs/dev/debt/libc.md
PR 17259 docs/dev/debt/libc.md
PR 17557 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 17558 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 18135 core/libs/prx/libc/include/Api.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 19181 core/libs/prx/libc/CMakeLists.txt
PR 19767 core/libs/prx/libc/include/Api.hpp

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head 5a8306b705, merged onto main e37e9fa3f9 (clean merge, built together with other open PRs that touch different files).

Setup: Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (r7), Ninja, Release, BUILD_TESTING=ON, Python 3.15.

  • Tests chosen with tools/select_tests.py explain from this PR's test files: guest_sce_v2_facet_ids, guest_sce_v2_makeloc.
  • All of them pass in 3 of 3 runs.
  • No negative control was run in this pass, so this does not show that the tests fail without the change.

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@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>
@Danigamer05

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Done in 6cb1b63. The table is gone. MakeSceV2MoneyPattern builds the four characters from cs_precedes, sep_by_space and sign_posn:

  • cs_precedes orders the symbol and the value.
  • sign_posn places the sign: in front for 0 and 1, at the end for 2, just before the symbol for 3, just after it for 4.
  • sep_by_space places the gap: 1 puts it between the value and the symbol side, 2 next to the sign on the symbol side. With 0 the pattern ends in x. With 2 and sign_posn 0 the gap is x.

A standalone check compared all 30 indices against the previous patterns: same result for each. guest_sce_v2_makeloc and guest_sce_v2_facet_ids pass (Windows 11, MinGW-w64 GCC 15.2, Release), and check_conventions is clean.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@oneandonlydean
oneandonlydean merged commit ddecf89 into boykopovar:main Nov 17, 2026
22 checks passed
This was referenced Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants