feat(libSceLibcInternal): implement the money_get and money_put get and put members #15790

Closed
B-Howell wants to merge 1 commit from upstream-pr/15790 into main
B-Howell commented 2026-11-04 14:52:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-04T14:52:10Z.


What

The public get members of money_get<char> and money_get<wchar_t> and the public put members of money_put<char> and money_put<wchar_t> in libSceLibcInternal threw from the Pending4 placeholders in Export.cpp. They now return do_get or do_put of the same value type through the facet's own vtable.

Member Slot NID (was)
money_get<char>::get(..., long double&) 0x20 G84okRnyJJg (Pending4_076)
money_get<char>::get(..., string&) 0x28 2fxdcyt5tGs (Pending4_075)
money_get<wchar_t>::get(..., long double&) 0x20 cx-1THpef1A (Pending4_081)
money_get<wchar_t>::get(..., wstring&) 0x28 wWIsjOqfcSc (Pending4_080)
money_put<char>::put(..., long double) 0x20 65cvm2NDLmU (Pending4_086)
money_put<char>::put(..., const string&) 0x28 DR029KeWsHw (Pending4_085)
money_put<wchar_t>::put(..., long double) 0x20 fsF-tGtGsD4 (Pending4_091)
money_put<wchar_t>::put(..., const wstring&) 0x28 JruBeQgsAaU (Pending4_090)

Each NID matches tools/nid_names.py compute_nid of its mangled name, for example _ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE3getES3_S3_bRSt8ios_baseRNSt5_IosbIiE8_IostateERe gives G84okRnyJJg and _ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE3putES3_bRSt8ios_basewRKSbIwS2_SaIwEE gives JruBeQgsAaU. All 8 were checked.

Where the behaviour comes from:

  • [locale.money.get.members] and [locale.money.put.members]: get returns do_get(s, end, intl, f, err, quant) (or digits), and put returns do_put(s, intl, f, fill, quant) (or digits). The first microsoft/STL commit does the same: xlocmon L326-L334 for get (return do_get(_First, _Last, _Intl, _Iosbase, _State, _Val);) and L629-L637 for put (return do_put(_Dest, _Intl, _Iosbase, _Fill, _Val);).
  • The slots: the long double virtual is declared before the string one, do_get at L363 and L390, do_put at L666 and L697, as in the standard synopsis. After the four FacetVtable slots that puts long double at 0x20 and the string at 0x28. With offset-to-top and RTTI this gives 8 entries, the size open #12511 and #12518 give the money_get<char> and money_put<char> _ZTV objects as zeroed data, from their st_size of 64 in the libc.prx of PPSA26344; this PR does not depend on them. The console's libSceLibcInternal.sprx was not read, so the slots are not confirmed on the console.
  • The forwarder calls the slot in the vtable of the facet it is given, so a derived facet's override is reached.

Changes:

  • GuestLocale.hpp: new GuestLocale::InputIterator, an opaque, trivially copyable 16-byte value for istreambuf_iterator, with static_asserts on its size and triviality. Nothing reads its fields. The istreambuf_iterator members are _Strbuf, _Got and _Val: streambuf L519-L521 in the first commit, moved to iterator L480-L482 at e1ed302683. For char and for the 2-byte wchar_t the iterator is 16 bytes with no user-declared copy constructor or destructor, so it is passed and returned in two integer registers like this struct. money_put takes and returns the existing 16-byte GuestLocale::OutputIterator.
  • GuestLocale.hpp: new GuestLocale::MoneyGetVtable<TString> and GuestLocale::MoneyPutVtable<TCharacter, TString>, used as CharMoneyGetVtable, WideMoneyGetVtable, CharMoneyPutVtable and WideMoneyPutVtable, with static_asserts on both slots and the size of each. The narrow string is the existing 0x28-byte GuestLocale::String; the wide string has no layout in AnyPS5 and is forwarded as an opaque pointer. The wchar_t fill is std::uint16_t. ios_base::iostate& is _Iosb<int>::_Iostate& in the mangled names and is passed as std::int32_t*.
  • New MoneyGetPut.cpp with the 8 forwarders, and the 8 placeholders removed from Export.cpp.
  • docs/dev/debt/libSceLibcInternal.md: the 8 per-NID "prototype and behavior are unverified" entries are removed and one entry records what is still open.

The InputIterator block in GuestLocale.hpp (and its <type_traits> include) is byte-for-byte the block of the num_get and time_get PRs from the same batch, at the same place, so the three merge in any order. git merge-tree --write-tree of each pair, of all three, and of each against main is clean, and the merged header has one InputIterator.

Still not done:

  • Neither libc nor libSceLibcInternal builds a money_get or money_put facet or implements their do_ members, so today these calls reach only a facet the title provides. do_get, do_put, _Getmfld, _Putmfld and moneypunct still throw.
  • No title was seen calling these exports.

Tested

No title was run. I added the guest test guest_libc_internal_money_get_put (core/libs/tests/GuestLibcInternalMoneyGetPut.cpp). It loads libSceLibcInternal, calls each of the 8 exports with a facet whose vtable records every call, and checks:

  • each of the 8 exports calls the do_get or do_put slot of its own value type exactly once, with intl false and true (each slot records a different index, so a wrong slot order fails);
  • get passes the facet, both 16-byte iterators word for word, intl, the stream, the state pointer and the value pointer, and returns the iterator do_get returns;
  • put passes the facet, the output iterator, intl, the stream, the fill ('*', 0xa4, 0x20ac, 0xffe5) and the units or digits pointer; the long double units are -(1 + 2^-60) * 2^40, which needs the full 64-bit x87 mantissa; it returns the iterator do_put returns;
  • with a second vtable standing in for a derived facet, every export reaches the derived slot.
    The header static_asserts pin both slot offsets and the size of all four vtable types.

Results:

  • Windows 11, WinLibs GCC 15.2.0 (MinGW), Release: ctest -R '^guest_libc_internal_money_get_put$' passed 3 of 3 runs (1/1 each), and once more after the negative-control restore. public_headers passed.
  • Linux, WSL Ubuntu 22.04, GCC 11.4.0, Release: a fresh clone of b11c7bf84f with this commit applied (git write-tree equal to the commit's tree) passed ctest -R '^(guest_libc_internal_money_get_put|public_headers)$' 3 of 3 runs (2/2 each), and 1 of 1 after the restore.
  • Negative control: with main's Export.cpp put back and MoneyGetPut.cpp emptied, keeping the new test, the test fails on both hosts with sceLibcInternalPending4_076_nid_no_patch not implemented (Windows exit code 0xc0000409, Linux subprocess aborted).
  • Conventions: python3 tools/check_conventions.py --base origin/main with this title and body: "All conventions checks passed."
  • Progress: tools/progress.py collect_libraries() for libSceLibcInternal: done 92 to 100 (+8), todo 1045 to 1037. Overall done 9921 to 9929 of 37146; the total does not change, so no new todo.
  • Overlap: python3 tools/pr_overlap.py --branch feat/r4-money-get-put-members failed closed. It reported no PR with the same exports or new files. Line conflicts are neighbours only: #13881 at debt line 346, and #14664 and #14836 at CMakeLists.txt line 78. Whichever lands second rebases. It could not compare 8 PRs that conflict with main: #5021, #13486, #13778, #13782, #14212, #14401, #14837 and #14936. I grepped the added and removed lines of every file patch of each one (from the REST files API; for #14212's docs/dev/debt/libSceLibcInternal.md, whose patch the API omits, git diff of the fetched PR head against its merge base) for the 44 NIDs of this batch, the Pending3_055-065, Pending3_080-090 and Pending4 stub names it removes, the num_get/time_get/money_get/money_put member mangled names, InputIterator, NumGetVtable, TimeGetVtable, MoneyGetVtable, MoneyPutVtable and the new file names. None has a match. The added and removed lines of #13881, #14664 and #14836 have no match either.

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:5156329217 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15790). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T14:52:10Z. --- ### What The public `get` members of `money_get<char>` and `money_get<wchar_t>` and the public `put` members of `money_put<char>` and `money_put<wchar_t>` in libSceLibcInternal threw from the `Pending4` placeholders in `Export.cpp`. They now return `do_get` or `do_put` of the same value type through the facet's own vtable. | Member | Slot | NID (was) | |---|---|---| | `money_get<char>::get(..., long double&)` | 0x20 | `G84okRnyJJg` (`Pending4_076`) | | `money_get<char>::get(..., string&)` | 0x28 | `2fxdcyt5tGs` (`Pending4_075`) | | `money_get<wchar_t>::get(..., long double&)` | 0x20 | `cx-1THpef1A` (`Pending4_081`) | | `money_get<wchar_t>::get(..., wstring&)` | 0x28 | `wWIsjOqfcSc` (`Pending4_080`) | | `money_put<char>::put(..., long double)` | 0x20 | `65cvm2NDLmU` (`Pending4_086`) | | `money_put<char>::put(..., const string&)` | 0x28 | `DR029KeWsHw` (`Pending4_085`) | | `money_put<wchar_t>::put(..., long double)` | 0x20 | `fsF-tGtGsD4` (`Pending4_091`) | | `money_put<wchar_t>::put(..., const wstring&)` | 0x28 | `JruBeQgsAaU` (`Pending4_090`) | Each NID matches `tools/nid_names.py` `compute_nid` of its mangled name, for example `_ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE3getES3_S3_bRSt8ios_baseRNSt5_IosbIiE8_IostateERe` gives `G84okRnyJJg` and `_ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE3putES3_bRSt8ios_basewRKSbIwS2_SaIwEE` gives `JruBeQgsAaU`. All 8 were checked. Where the behaviour comes from: - [locale.money.get.members] and [locale.money.put.members]: `get` returns `do_get(s, end, intl, f, err, quant)` (or `digits`), and `put` returns `do_put(s, intl, f, fill, quant)` (or `digits`). The first microsoft/STL commit does the same: [xlocmon L326-L334](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L326-L334) for `get` (`return do_get(_First, _Last, _Intl, _Iosbase, _State, _Val);`) and [L629-L637](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L629-L637) for `put` (`return do_put(_Dest, _Intl, _Iosbase, _Fill, _Val);`). - The slots: the `long double` virtual is declared before the string one, `do_get` at [L363](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L363) and [L390](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L390), `do_put` at [L666](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L666) and [L697](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocmon#L697), as in the standard synopsis. After the four `FacetVtable` slots that puts `long double` at 0x20 and the string at 0x28. With offset-to-top and RTTI this gives 8 entries, the size open #12511 and #12518 give the `money_get<char>` and `money_put<char>` `_ZTV` objects as zeroed data, from their `st_size` of 64 in the `libc.prx` of PPSA26344; this PR does not depend on them. The console's `libSceLibcInternal.sprx` was not read, so the slots are not confirmed on the console. - The forwarder calls the slot in the vtable of the facet it is given, so a derived facet's override is reached. Changes: - `GuestLocale.hpp`: new `GuestLocale::InputIterator`, an opaque, trivially copyable 16-byte value for `istreambuf_iterator`, with `static_assert`s on its size and triviality. Nothing reads its fields. The `istreambuf_iterator` members are `_Strbuf`, `_Got` and `_Val`: [streambuf L519-L521](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/streambuf#L519-L521) in the first commit, moved to [iterator L480-L482](https://github.com/microsoft/STL/blob/e1ed302683e5e822f663fbb0f44cee7e9ddc6af0/stl/inc/iterator#L480-L482) at `e1ed302683`. For `char` and for the 2-byte `wchar_t` the iterator is 16 bytes with no user-declared copy constructor or destructor, so it is passed and returned in two integer registers like this struct. `money_put` takes and returns the existing 16-byte `GuestLocale::OutputIterator`. - `GuestLocale.hpp`: new `GuestLocale::MoneyGetVtable<TString>` and `GuestLocale::MoneyPutVtable<TCharacter, TString>`, used as `CharMoneyGetVtable`, `WideMoneyGetVtable`, `CharMoneyPutVtable` and `WideMoneyPutVtable`, with `static_assert`s on both slots and the size of each. The narrow string is the existing 0x28-byte `GuestLocale::String`; the wide string has no layout in AnyPS5 and is forwarded as an opaque pointer. The `wchar_t` fill is `std::uint16_t`. `ios_base::iostate&` is `_Iosb<int>::_Iostate&` in the mangled names and is passed as `std::int32_t*`. - New `MoneyGetPut.cpp` with the 8 forwarders, and the 8 placeholders removed from `Export.cpp`. - `docs/dev/debt/libSceLibcInternal.md`: the 8 per-NID "prototype and behavior are unverified" entries are removed and one entry records what is still open. The `InputIterator` block in `GuestLocale.hpp` (and its `<type_traits>` include) is byte-for-byte the block of the `num_get` and `time_get` PRs from the same batch, at the same place, so the three merge in any order. `git merge-tree --write-tree` of each pair, of all three, and of each against `main` is clean, and the merged header has one `InputIterator`. Still not done: - Neither libc nor libSceLibcInternal builds a `money_get` or `money_put` facet or implements their `do_` members, so today these calls reach only a facet the title provides. `do_get`, `do_put`, `_Getmfld`, `_Putmfld` and `moneypunct` still throw. - No title was seen calling these exports. ### 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. --> No title was run. I added the guest test `guest_libc_internal_money_get_put` (`core/libs/tests/GuestLibcInternalMoneyGetPut.cpp`). It loads `libSceLibcInternal`, calls each of the 8 exports with a facet whose vtable records every call, and checks: - each of the 8 exports calls the `do_get` or `do_put` slot of its own value type exactly once, with `intl` false and true (each slot records a different index, so a wrong slot order fails); - `get` passes the facet, both 16-byte iterators word for word, `intl`, the stream, the state pointer and the value pointer, and returns the iterator `do_get` returns; - `put` passes the facet, the output iterator, `intl`, the stream, the fill (`'*'`, `0xa4`, `0x20ac`, `0xffe5`) and the units or digits pointer; the `long double` units are `-(1 + 2^-60) * 2^40`, which needs the full 64-bit x87 mantissa; it returns the iterator `do_put` returns; - with a second vtable standing in for a derived facet, every export reaches the derived slot. The header `static_assert`s pin both slot offsets and the size of all four vtable types. Results: - **Windows 11, WinLibs GCC 15.2.0 (MinGW), Release:** `ctest -R '^guest_libc_internal_money_get_put$'` passed 3 of 3 runs (1/1 each), and once more after the negative-control restore. `public_headers` passed. - **Linux, WSL Ubuntu 22.04, GCC 11.4.0, Release:** a fresh clone of `b11c7bf84f` with this commit applied (`git write-tree` equal to the commit's tree) passed `ctest -R '^(guest_libc_internal_money_get_put|public_headers)$'` 3 of 3 runs (2/2 each), and 1 of 1 after the restore. - **Negative control:** with main's `Export.cpp` put back and `MoneyGetPut.cpp` emptied, keeping the new test, the test fails on both hosts with `sceLibcInternalPending4_076_nid_no_patch not implemented` (Windows exit code 0xc0000409, Linux subprocess aborted). - **Conventions:** `python3 tools/check_conventions.py --base origin/main` with this title and body: "All conventions checks passed." - **Progress:** `tools/progress.py` `collect_libraries()` for libSceLibcInternal: done 92 to 100 (+8), todo 1045 to 1037. Overall done 9921 to 9929 of 37146; the total does not change, so no new todo. - **Overlap:** `python3 tools/pr_overlap.py --branch feat/r4-money-get-put-members` failed closed. It reported no PR with the same exports or new files. Line conflicts are neighbours only: #13881 at debt line 346, and #14664 and #14836 at `CMakeLists.txt` line 78. Whichever lands second rebases. It could not compare 8 PRs that conflict with main: #5021, #13486, #13778, #13782, #14212, #14401, #14837 and #14936. I grepped the added and removed lines of every file patch of each one (from the REST files API; for #14212's `docs/dev/debt/libSceLibcInternal.md`, whose patch the API omits, `git diff` of the fetched PR head against its merge base) for the 44 NIDs of this batch, the `Pending3_055`-`065`, `Pending3_080`-`090` and `Pending4` stub names it removes, the `num_get`/`time_get`/`money_get`/`money_put` member mangled names, `InputIterator`, `NumGetVtable`, `TimeGetVtable`, `MoneyGetVtable`, `MoneyPutVtable` and the new file names. None has a match. The added and removed lines of #13881, #14664 and #14836 have no match either. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

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!15790
No description provided.