feat(libSceLibcInternal): implement messages<char> and messages<wchar_t>::_Getcat #24942

Merged
GiannisG1 merged 1 commit from upstream-pr/24942 into main 2026-11-25 04:32:12 +00:00
GiannisG1 commented 2026-11-21 11:54:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GiannisG1 on 2026-11-21T11:54:36Z.


What

With #23867 in, every messages<char> and messages<wchar_t> constructor form is implemented. The two _Getcat exports of the class were still inventory placeholders that threw:

Export Inventory NID
messages<char>::_Getcat(const locale::facet**, const locale*) 150 96Ev+CE1luE
messages<wchar_t>::_Getcat(const locale::facet**, const locale*) 155 XghI4vmw8mU

_Getcat is the factory that use_facet and the locale constructors call for a facet the locale doesn't have yet. microsoft/STL's xlocmes defines it as: if the slot is non-null and empty, store new messages<_Elem>(_Locinfo(_Ploc->_C_str())); always return _X_MESSAGES, which is 6 in xlocinfo. The other _Getcat exports here use the same numbering: num_get returns 4 and time_get 5.

In Messages.cpp, both exports share one helper. For an empty slot, it allocates the facet with operator new and builds it through the same path as the (const char*, size_t) constructor, using the locale's name and no references. A guard frees the allocation if construction throws, so the slot stays empty. A filled slot is left alone, and a null slot only returns the category. An empty slot with a null locale throws std::invalid_argument, because the STL code would dereference it.

The mangled names hash to the inventory NIDs (tools/nid_names.py), so the exports are named and the two placeholders are gone. The debt fragment removes the two table rows and adds a Functional entry: not verified on a console.

Tested

Linux Mint 22.3, GCC 13.3.0, Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON as in main's Linux job, head on main 0ac196e295.

  • guest_libc_internal_messages gets CheckGetcat, which checks both exports:
    • an empty slot gets a new facet with the class's vtable (the exported messages<char> vtable, or the wide one) and no references, and the call returns 6;
    • a filled slot is kept, with no new allocation;
    • a null slot returns 6;
    • the facet opens no catalog, and its vtable's deleting destructor frees it (the test heap counts live allocations);
    • an empty slot with a null locale, or with a null locale pointer, throws and allocates nothing.
  • RED: with _Getcat returning 5 instead of 6, the test aborts at messages<char>::_Getcat builds a facet for an empty slot and returns the messages category. With the change it passes 3/3.
  • progress.py --module libSceLibcInternal: 641 → 643 implemented. The two placeholders leave the pending list, and nothing joins it.
  • Split suite (tools/suite.py -j2) on this branch: GPU tests on a GTX 1050 Ti (NVIDIA 580.178.04), an HD 630 (Mesa 25.2.8 ANV) and llvmpipe 25.2.8, everything else once. The failures and skips are the same as our main 0ac196e295 run with the same configuration: GTX 0, HD 630 the same 8 (#20831, #16953, our #22078, and the two real-display presents plus window_margins_bounds under Xvfb), and llvmpipe the same 3 (Mesa 25.2.8, #24834). guest_libc_internal_messages and the 152 source-scanning tests (conventions, public_headers, tools_*) pass.
  • check_conventions.py, check_test_registration.py, check_compile.py, check_main_sync.py (merges cleanly with 26194f0fcf) and debt_fold.py --check are clean.
  • pr_overlap.py --branch: no overlap among the pull requests it could compare. #13778, #17300, #18135 and #19602 could not be compared, because they conflict with main. In their diffs, #17300 removes the neighbouring placeholders 149 and 153/154, next to the 150 and 155 removed here, so whichever lands second keeps both removals. #13778 and #19602 remove other placeholders, and #18135 only adds declarations elsewhere in Api.hpp.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5427537818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24942). Originally posted by [GiannisG1](https://github.com/GiannisG1) on 2026-11-21T11:54:36Z. --- ### What With #23867 in, every `messages<char>` and `messages<wchar_t>` constructor form is implemented. The two `_Getcat` exports of the class were still inventory placeholders that threw: | Export | Inventory | NID | |---|---|---| | `messages<char>::_Getcat(const locale::facet**, const locale*)` | 150 | `96Ev+CE1luE` | | `messages<wchar_t>::_Getcat(const locale::facet**, const locale*)` | 155 | `XghI4vmw8mU` | `_Getcat` is the factory that `use_facet` and the locale constructors call for a facet the locale doesn't have yet. microsoft/STL's [`xlocmes`](https://github.com/microsoft/STL/blob/main/stl/inc/xlocmes) defines it as: if the slot is non-null and empty, store `new messages<_Elem>(_Locinfo(_Ploc->_C_str()))`; always return `_X_MESSAGES`, which is 6 in [`xlocinfo`](https://github.com/microsoft/STL/blob/main/stl/inc/xlocinfo). The other `_Getcat` exports here use the same numbering: `num_get` returns 4 and `time_get` 5. In `Messages.cpp`, both exports share one helper. For an empty slot, it allocates the facet with `operator new` and builds it through the same path as the `(const char*, size_t)` constructor, using the locale's name and no references. A guard frees the allocation if construction throws, so the slot stays empty. A filled slot is left alone, and a null slot only returns the category. An empty slot with a null locale throws `std::invalid_argument`, because the STL code would dereference it. The mangled names hash to the inventory NIDs (`tools/nid_names.py`), so the exports are named and the two placeholders are gone. The debt fragment removes the two table rows and adds a Functional entry: not verified on a console. ### Tested Linux Mint 22.3, GCC 13.3.0, Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON` as in `main`'s Linux job, head on `main` `0ac196e295`. - `guest_libc_internal_messages` gets `CheckGetcat`, which checks both exports: - an empty slot gets a new facet with the class's vtable (the exported `messages<char>` vtable, or the wide one) and no references, and the call returns 6; - a filled slot is kept, with no new allocation; - a null slot returns 6; - the facet opens no catalog, and its vtable's deleting destructor frees it (the test heap counts live allocations); - an empty slot with a null locale, or with a null locale pointer, throws and allocates nothing. - RED: with `_Getcat` returning 5 instead of 6, the test aborts at `messages<char>::_Getcat builds a facet for an empty slot and returns the messages category`. With the change it passes 3/3. - `progress.py --module libSceLibcInternal`: 641 → 643 implemented. The two placeholders leave the pending list, and nothing joins it. - Split suite (`tools/suite.py -j2`) on this branch: GPU tests on a GTX 1050 Ti (NVIDIA 580.178.04), an HD 630 (Mesa 25.2.8 ANV) and llvmpipe 25.2.8, everything else once. The failures and skips are the same as our `main` `0ac196e295` run with the same configuration: GTX 0, HD 630 the same 8 (#20831, #16953, our #22078, and the two real-display presents plus `window_margins_bounds` under Xvfb), and llvmpipe the same 3 (Mesa 25.2.8, #24834). `guest_libc_internal_messages` and the 152 source-scanning tests (`conventions`, `public_headers`, `tools_*`) pass. - `check_conventions.py`, `check_test_registration.py`, `check_compile.py`, `check_main_sync.py` (merges cleanly with `26194f0fcf`) and `debt_fold.py --check` are clean. - `pr_overlap.py --branch`: no overlap among the pull requests it could compare. #13778, #17300, #18135 and #19602 could not be compared, because they conflict with `main`. In their diffs, #17300 removes the neighbouring placeholders 149 and 153/154, next to the 150 and 155 removed here, so whichever lands second keeps both removals. #13778 and #19602 remove other placeholders, and #18135 only adds declarations elsewhere in `Api.hpp`. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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)
MarcZX10 commented 2026-11-21 12:16:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:16:09Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reviewed implementation and focused test support merging.

What I ran

Reviewed head 0a94a32d495da9035e17bbc67b5935e2cfbf148b using the prepared diff and pinned repository reader. No commands or tests were run by me; reported test results are author supplied.

Results

Check Result Note
Diff and changed source review passed Reviewed all six changed files
Focused tests not run Author reports guest_libc_internal_messages passed
Console behavior not run Author reports not verified on console

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full source of core/libs/prx/libSceLibcInternal/InventoryExports.cpp was not read; its changed hunk only removes the two inventory placeholders. review/files.json was unavailable through the reader, so there were no additional excluded-file details to inspect. The author-reported test suite, build and console behavior were not independently run or confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005120575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24942#pullrequestreview-6005120575). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T12:16:09Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reviewed implementation and focused test support merging. ## What I ran Reviewed head `0a94a32d495da9035e17bbc67b5935e2cfbf148b` using the prepared diff and pinned repository reader. No commands or tests were run by me; reported test results are author supplied. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source review | passed | Reviewed all six changed files | | Focused tests | not run | Author reports `guest_libc_internal_messages` passed | | Console behavior | not run | Author reports not verified on console | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full source of `core/libs/prx/libSceLibcInternal/InventoryExports.cpp` was not read; its changed hunk only removes the two inventory placeholders. `review/files.json` was unavailable through the reader, so there were no additional excluded-file details to inspect. The author-reported test suite, build and console behavior were not independently run or confirmed. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-21 12:31:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T12:31:25Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0a94a32d49:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_messages_tests built cleanly.
  • CTest (guest_libc_internal_messages):
    1/1 Test #4522: guest_libc_internal_messages .....   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/Messages.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified Getcat implementation in Messages.cpp handles null facet pointer and already populated *facet properly, returning category 6
    • Verified Getcat validates null locale and null *locale throwing std::invalid_argument before dereference and allocation
    • Verified FacetGuard RAII memory management ensures no leak if ConstructNamed throws during allocation or locinfo construction
    • Verified replacement of inventory placeholders 150 and 155 in InventoryExports.cpp and InventoryExports.hpp matches NIDs 96Ev+CE1luE and XghI4vmw8mU
    • Verified technical debt fragment docs/dev/debt/changes/feat-libcinternal-messages-getcat.md correctly removes previous inventory entries and documents Functional status
    • Verified unit test coverage in GuestLibcInternalMessages.cpp exercises char and wchar_t versions, empty/existing slots, null locale error branches, and proper refcounting/vtable setup

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005195198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24942#pullrequestreview-6005195198). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T12:31:25Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0a94a32d49`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_messages_tests` built cleanly. - **CTest** (`guest_libc_internal_messages`): ``` 1/1 Test #4522: guest_libc_internal_messages ..... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibcInternal/InventoryExports.cpp`, `core/libs/prx/libSceLibcInternal/Messages.cpp`, `core/libs/prx/libSceLibcInternal/include/Api.hpp`, `core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified Getcat implementation in Messages.cpp handles null facet pointer and already populated *facet properly, returning category 6 - Verified Getcat validates null locale and null *locale throwing std::invalid_argument before dereference and allocation - Verified FacetGuard RAII memory management ensures no leak if ConstructNamed throws during allocation or locinfo construction - Verified replacement of inventory placeholders 150 and 155 in InventoryExports.cpp and InventoryExports.hpp matches NIDs 96Ev+CE1luE and XghI4vmw8mU - Verified technical debt fragment docs/dev/debt/changes/feat-libcinternal-messages-getcat.md correctly removes previous inventory entries and documents Functional status - Verified unit test coverage in GuestLibcInternalMessages.cpp exercises char and wchar_t versions, empty/existing slots, null locale error branches, and proper refcounting/vtable setup Looks Good To Me
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!24942
No description provided.