feat(libSceLibcInternal): implement the collate<wchar_t> members #15712

Merged
B-Howell merged 4 commits from upstream-pr/15712 into main 2026-11-12 20:36:06 +00:00
B-Howell commented 2026-11-04 09:07:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-04T09:07:33Z.


What

Implements the six std::collate<wchar_t> members that libSceLibcInternal exported as NotImplemented stubs (Err.cpp, Pending3_049..054):

NID Symbol Behaviour
roztnFEs5Es collate<wchar_t>::do_compare libc's WideCollateCompare
Zxe-nQMgxHM collate<wchar_t>::do_transform libc's WideCollateTransform
cWaCDW+Dc9U collate<wchar_t>::do_hash libc's WideCollateHash
n-3HFZvDwBw collate<wchar_t>::compare calls the facet's virtual do_compare
81uX7PzrtG8 collate<wchar_t>::transform calls the facet's virtual do_transform
entYnoIu+fc collate<wchar_t>::hash calls the facet's virtual do_hash

References:

  • ISO C++ [locale.collate.members]: compare "Returns: do_compare(low1, high1, low2, high2)", and likewise transform returns do_transform(low, high) and hash returns do_hash(low, high). The public members therefore dispatch through the facet's vtable, as the existing collate<char>::transform in LocaleSupport.cpp already does (reinterpret_cast<const GuestLocale::CollateVtable*>(self->base.vtable)->transform(...)).
  • The do_ members are the base implementations that collate<wchar_t>::_Getcat already installs in the facet (g_wideCollateVtable{..., WideCollateCompare, WideCollateTransform, WideCollateHash}, with GuestWideCharacterSize = 2). They call those functions directly, not through the vtable, so a derived facet that calls collate<wchar_t>::do_compare explicitly cannot recurse into its own override. libc now exposes that vtable to libSceLibcInternal through GuestWideCollateVtable_nid_no_patch(). It has no NID, so libc's export set does not change.

The members are written in a new WideCollate.cpp with their declarations in include/WideCollate.hpp, which keeps them away from the lines of Api.hpp that other open PRs edit. Their six debt entries are removed from docs/dev/debt/libSceLibcInternal.md. Only the C locale gets a collate facet, as before: _Getcat still throws for any other locale.

tools/progress.py collect_libraries(): done goes from 9913 to 9919 (+6) out of 37146 on origin/main 5b1d381d5a. libSceLibcInternal goes from 92 done / 1045 todo to 98 / 1039. No new todo names.

Tested

New guest test guest_libc_internal_wide_collate (core/libs/tests/GuestLibcInternalWideCollate.cpp). It checks:

  • results on the classic facet: ordering by whole 16-bit character, the FNV-1a hash values the libc test pins, inline and allocated transform results, and rejection of reversed or half-null ranges and embedded nulls;
  • virtual dispatch: on a facet whose vtable overrides compare, transform and hash, the public members call the override with the same facet, ranges and result, while the do_ members return the base results and never reach it;
  • that the public members reject a null facet or a null vtable.

Runs, same tests on both platforms (guest_libc_internal_wide_collate, plus the existing guest_collate and guest_locale as regressions):

  • Windows 11, WinLibs GCC 15.2.0 (MinGW-w64): 3/3 tests passed in each of 3 runs.
  • Linux, WSL Ubuntu 22.04, GCC 11.4.0: 3/3 tests passed in each of 3 runs.
  • The unpatched libSceLibcInternal.prx on Windows exports all six <NID>_nid_no_patch_cut symbols and imports GuestWideCollateVtable_nid_no_patch from libc.
  • Negative control on both platforms: with main's Err.cpp and without WideCollate.cpp built in, the new test fails to link (undefined reference to sceLibcInternalWideCollateDoCompare_nid_no_patch, and the other five).
  • python3 tools/check_conventions.py --base origin/main: all checks passed. The conventions_* and debt_split CTest entries are self-tests of the checker scripts, not of this change, and were not run here.
  • python3 tools/pr_overlap.py --branch feat/r2-collate-wchar: no open PR implements these exports or adds these files, and git merge-tree against PR 15695 and PR 15696, the two that edit nearby lines of the libSceLibcInternal CMakeLists.txt, merges cleanly. It fails closed only because some older PRs that touch LocaleSupport.cpp, GuestLocale.hpp, the libSceLibcInternal CMakeLists.txt or its debt file conflict with main, so those files could not be compared automatically.
  • No title was run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5151796899 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15712). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T09:07:33Z. --- ### What Implements the six `std::collate<wchar_t>` members that `libSceLibcInternal` exported as `NotImplemented` stubs (`Err.cpp`, `Pending3_049`..`054`): | NID | Symbol | Behaviour | |---|---|---| | `roztnFEs5Es` | `collate<wchar_t>::do_compare` | libc's `WideCollateCompare` | | `Zxe-nQMgxHM` | `collate<wchar_t>::do_transform` | libc's `WideCollateTransform` | | `cWaCDW+Dc9U` | `collate<wchar_t>::do_hash` | libc's `WideCollateHash` | | `n-3HFZvDwBw` | `collate<wchar_t>::compare` | calls the facet's virtual `do_compare` | | `81uX7PzrtG8` | `collate<wchar_t>::transform` | calls the facet's virtual `do_transform` | | `entYnoIu+fc` | `collate<wchar_t>::hash` | calls the facet's virtual `do_hash` | References: - ISO C++ [locale.collate.members]: `compare` "Returns: `do_compare(low1, high1, low2, high2)`", and likewise `transform` returns `do_transform(low, high)` and `hash` returns `do_hash(low, high)`. The public members therefore dispatch through the facet's vtable, as the existing `collate<char>::transform` in `LocaleSupport.cpp` already does (`reinterpret_cast<const GuestLocale::CollateVtable*>(self->base.vtable)->transform(...)`). - The `do_` members are the base implementations that `collate<wchar_t>::_Getcat` already installs in the facet (`g_wideCollateVtable{..., WideCollateCompare, WideCollateTransform, WideCollateHash}`, with `GuestWideCharacterSize = 2`). They call those functions directly, not through the vtable, so a derived facet that calls `collate<wchar_t>::do_compare` explicitly cannot recurse into its own override. libc now exposes that vtable to `libSceLibcInternal` through `GuestWideCollateVtable_nid_no_patch()`. It has no NID, so libc's export set does not change. The members are written in a new `WideCollate.cpp` with their declarations in `include/WideCollate.hpp`, which keeps them away from the lines of `Api.hpp` that other open PRs edit. Their six debt entries are removed from `docs/dev/debt/libSceLibcInternal.md`. Only the C locale gets a collate facet, as before: `_Getcat` still throws for any other locale. `tools/progress.py` `collect_libraries()`: done goes from 9913 to 9919 (+6) out of 37146 on origin/main `5b1d381d5a`. libSceLibcInternal goes from 92 done / 1045 todo to 98 / 1039. No new todo names. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> New guest test `guest_libc_internal_wide_collate` (`core/libs/tests/GuestLibcInternalWideCollate.cpp`). It checks: - results on the classic facet: ordering by whole 16-bit character, the FNV-1a hash values the libc test pins, inline and allocated transform results, and rejection of reversed or half-null ranges and embedded nulls; - virtual dispatch: on a facet whose vtable overrides compare, transform and hash, the public members call the override with the same facet, ranges and result, while the `do_` members return the base results and never reach it; - that the public members reject a null facet or a null vtable. Runs, same tests on both platforms (`guest_libc_internal_wide_collate`, plus the existing `guest_collate` and `guest_locale` as regressions): - Windows 11, WinLibs GCC 15.2.0 (MinGW-w64): 3/3 tests passed in each of 3 runs. - Linux, WSL Ubuntu 22.04, GCC 11.4.0: 3/3 tests passed in each of 3 runs. - The unpatched `libSceLibcInternal.prx` on Windows exports all six `<NID>_nid_no_patch_cut` symbols and imports `GuestWideCollateVtable_nid_no_patch` from libc. - Negative control on both platforms: with main's `Err.cpp` and without `WideCollate.cpp` built in, the new test fails to link (`undefined reference to sceLibcInternalWideCollateDoCompare_nid_no_patch`, and the other five). - `python3 tools/check_conventions.py --base origin/main`: all checks passed. The `conventions_*` and `debt_split` CTest entries are self-tests of the checker scripts, not of this change, and were not run here. - `python3 tools/pr_overlap.py --branch feat/r2-collate-wchar`: no open PR implements these exports or adds these files, and `git merge-tree` against PR 15695 and PR 15696, the two that edit nearby lines of the libSceLibcInternal `CMakeLists.txt`, merges cleanly. It fails closed only because some older PRs that touch `LocaleSupport.cpp`, `GuestLocale.hpp`, the libSceLibcInternal `CMakeLists.txt` or its debt file conflict with main, so those files could not be compared automatically. - No title was run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15712
No description provided.