feat(libSceLibcInternal): implement the time_get<char> and time_get<wchar_t> members #15789

Closed
B-Howell wants to merge 0 commits from upstream-pr/15789 into main
B-Howell commented 2026-11-04 14:51:44 +00:00 (Migrated from github.com)

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


What

The seven public members of time_get<char, istreambuf_iterator<char>> and the seven of time_get<wchar_t, istreambuf_iterator<wchar_t>> in libSceLibcInternal threw from the Pending4 placeholders in Export.cpp. They now return their do_ member through the facet's own vtable.

Member Slot char NID (was) wchar_t NID (was)
date_order() 0x20 ShlQcYrzRF8 (Pending4_035) nc6OsiDx630 (Pending4_051)
get_time 0x28 rrqNi95bhMs (Pending4_049) 9TfGnN6xq-U (Pending4_066)
get_date 0x30 OY5mqEBxP+8 (Pending4_048) kwp-0uidHpw (Pending4_065)
get_weekday 0x38 KwJ5V3D0v3A (Pending4_039) A0PftWMfrhk (Pending4_055)
get_monthname 0x40 vvA7HtdtWnY (Pending4_041) xy0MR+OOZI8 (Pending4_057)
get_year 0x48 5L5Aft+9nZU (Pending4_050) Krt-A7EnHHs (Pending4_067)
get(first, last, ios, err, tm*, char format, char modifier) 0x50 +RuThw5axA4 (Pending4_044) 64pqofAwJEg (Pending4_061)

Each NID matches tools/nid_names.py compute_nid of its mangled name, for example _ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10date_orderEv gives ShlQcYrzRF8 and _ZNKSt8time_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE3getES3_S3_RSt8ios_baseRNSt5_IosbIiE8_IostateEP2tmcc gives 64pqofAwJEg. All 14 were checked.

Where the behaviour comes from:

  • [locale.time.get.members]: each member returns its do_ member with the same arguments. The first microsoft/STL commit does the same (xloctime L53-L85), for example return do_get(_First, _Last, _Iosbase, _State, _Pt, _Specifier, _Modifier);.
  • The slots are the declaration order of the seven virtuals in xloctime L201-L367 (do_date_order, do_get_time, do_get_date, do_get_weekday, do_get_monthname, do_get_year, do_get), after the four FacetVtable slots. time_base derives from locale::facet and adds no virtual (xloctime L23-L35). Here the standard synopsis and microsoft/STL agree. With offset-to-top and RTTI this gives the 13 entries libc already declares for _ZTVSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE and _ZTVSt8time_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE. 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. istreambuf_iterator<char> and istreambuf_iterator<wchar_t> are both 16 bytes (_Strbuf, _Got, _Val in streambuf L519-L521) with no user-declared copy constructor or destructor, so they are passed and returned in two integer registers like this struct.
  • GuestLocale.hpp: new GuestLocale::TimeGetVtable with static_asserts on all seven slot offsets (0x20 to 0x50) and the size (0x58). ios_base::iostate& is _Iosb<int>::_Iostate& in the mangled names and is passed as std::int32_t*; dateorder is returned as std::int32_t; format and modifier are char for both character types, as the mangled cc says.
  • New TimeGet.cpp with the 14 forwarders, and the 14 placeholders removed from Export.cpp.
  • docs/dev/debt/libSceLibcInternal.md: the 14 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 money_get/money_put 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 time_get facet or implements its do_ members, so today these calls reach only a facet the title provides. The do_ members, _Getfmt, _Getint, the pattern overload get(..., const char_type* first, const char_type* last) (it reads the stream buffer itself) and the rest of the facet still throw.
  • No title was seen calling these exports.

Tested

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

  • each of the 14 exports calls its own do_ slot exactly once (every slot records a different index, so a wrong slot order fails);
  • the facet, both 16-byte iterators word for word, the stream, the state pointer and the tm pointer arrive unchanged, and get passes format and modifier (checked with 'Y'/'E' and 'x'/'');
  • the member returns the iterator its do_ member returns and leaves the state it wrote; date_order returns the do_date_order result;
  • with a second vtable standing in for a derived facet, every export reaches the derived slot.
    The header static_asserts pin every slot offset (0x20 to 0x50) and the size.

Results:

  • Windows 11, WinLibs GCC 15.2.0 (MinGW), Release: ctest -R '^guest_libc_internal_time_get$' 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_time_get|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 TimeGet.cpp emptied, keeping the new test, the test fails on both hosts with sceLibcInternalPending4_035_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 106 (+14), todo 1045 to 1031. Overall done 9921 to 9935 of 37146; the total does not change, so no new todo.
  • Overlap: python3 tools/pr_overlap.py --branch feat/r4-time-get-members failed closed. It reported no PR with the same exports or new files. Line conflicts are neighbours only: #10392, #14664 and #14836 at debt line 342, #15577 and #15657 at CMakeLists.txt line 61, and our own #15715 at Export.cpp L402-431 (its Pending4_068 and later removals sit right after this PR's Pending4_065-067). 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 #10392, #14664, #14836, #15577, #15657 and #15715 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:5156322891 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15789). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T14:51:44Z. --- ### What The seven public members of `time_get<char, istreambuf_iterator<char>>` and the seven of `time_get<wchar_t, istreambuf_iterator<wchar_t>>` in libSceLibcInternal threw from the `Pending4` placeholders in `Export.cpp`. They now return their `do_` member through the facet's own vtable. | Member | Slot | `char` NID (was) | `wchar_t` NID (was) | |---|---|---|---| | `date_order()` | 0x20 | `ShlQcYrzRF8` (`Pending4_035`) | `nc6OsiDx630` (`Pending4_051`) | | `get_time` | 0x28 | `rrqNi95bhMs` (`Pending4_049`) | `9TfGnN6xq-U` (`Pending4_066`) | | `get_date` | 0x30 | `OY5mqEBxP+8` (`Pending4_048`) | `kwp-0uidHpw` (`Pending4_065`) | | `get_weekday` | 0x38 | `KwJ5V3D0v3A` (`Pending4_039`) | `A0PftWMfrhk` (`Pending4_055`) | | `get_monthname` | 0x40 | `vvA7HtdtWnY` (`Pending4_041`) | `xy0MR+OOZI8` (`Pending4_057`) | | `get_year` | 0x48 | `5L5Aft+9nZU` (`Pending4_050`) | `Krt-A7EnHHs` (`Pending4_067`) | | `get(first, last, ios, err, tm*, char format, char modifier)` | 0x50 | `+RuThw5axA4` (`Pending4_044`) | `64pqofAwJEg` (`Pending4_061`) | Each NID matches `tools/nid_names.py` `compute_nid` of its mangled name, for example `_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10date_orderEv` gives `ShlQcYrzRF8` and `_ZNKSt8time_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE3getES3_S3_RSt8ios_baseRNSt5_IosbIiE8_IostateEP2tmcc` gives `64pqofAwJEg`. All 14 were checked. Where the behaviour comes from: - [locale.time.get.members]: each member returns its `do_` member with the same arguments. The first microsoft/STL commit does the same ([xloctime L53-L85](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xloctime#L53-L85)), for example `return do_get(_First, _Last, _Iosbase, _State, _Pt, _Specifier, _Modifier);`. - The slots are the declaration order of the seven virtuals in [xloctime L201-L367](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xloctime#L201-L367) (`do_date_order`, `do_get_time`, `do_get_date`, `do_get_weekday`, `do_get_monthname`, `do_get_year`, `do_get`), after the four `FacetVtable` slots. `time_base` derives from `locale::facet` and adds no virtual ([xloctime L23-L35](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xloctime#L23-L35)). Here the standard synopsis and microsoft/STL agree. With offset-to-top and RTTI this gives the 13 entries libc already declares for `_ZTVSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE` and `_ZTVSt8time_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE`. 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. `istreambuf_iterator<char>` and `istreambuf_iterator<wchar_t>` are both 16 bytes (`_Strbuf`, `_Got`, `_Val` in [streambuf L519-L521](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/streambuf#L519-L521)) with no user-declared copy constructor or destructor, so they are passed and returned in two integer registers like this struct. - `GuestLocale.hpp`: new `GuestLocale::TimeGetVtable` with `static_assert`s on all seven slot offsets (0x20 to 0x50) and the size (0x58). `ios_base::iostate&` is `_Iosb<int>::_Iostate&` in the mangled names and is passed as `std::int32_t*`; `dateorder` is returned as `std::int32_t`; `format` and `modifier` are `char` for both character types, as the mangled `cc` says. - New `TimeGet.cpp` with the 14 forwarders, and the 14 placeholders removed from `Export.cpp`. - `docs/dev/debt/libSceLibcInternal.md`: the 14 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 `money_get`/`money_put` 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 `time_get` facet or implements its `do_` members, so today these calls reach only a facet the title provides. The `do_` members, `_Getfmt`, `_Getint`, the pattern overload `get(..., const char_type* first, const char_type* last)` (it reads the stream buffer itself) and the rest of the facet 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_time_get` (`core/libs/tests/GuestLibcInternalTimeGet.cpp`). It loads `libSceLibcInternal`, calls each of the 14 exports with a facet whose vtable records every call, and checks: - each of the 14 exports calls its own `do_` slot exactly once (every slot records a different index, so a wrong slot order fails); - the facet, both 16-byte iterators word for word, the stream, the state pointer and the `tm` pointer arrive unchanged, and `get` passes `format` and `modifier` (checked with `'Y'`/`'E'` and `'x'`/`''`); - the member returns the iterator its `do_` member returns and leaves the state it wrote; `date_order` returns the `do_date_order` result; - with a second vtable standing in for a derived facet, every export reaches the derived slot. The header `static_assert`s pin every slot offset (0x20 to 0x50) and the size. Results: - **Windows 11, WinLibs GCC 15.2.0 (MinGW), Release:** `ctest -R '^guest_libc_internal_time_get$'` 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_time_get|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 `TimeGet.cpp` emptied, keeping the new test, the test fails on both hosts with `sceLibcInternalPending4_035_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 106 (+14), todo 1045 to 1031. Overall done 9921 to 9935 of 37146; the total does not change, so no new todo. - **Overlap:** `python3 tools/pr_overlap.py --branch feat/r4-time-get-members` failed closed. It reported no PR with the same exports or new files. Line conflicts are neighbours only: #10392, #14664 and #14836 at debt line 342, #15577 and #15657 at `CMakeLists.txt` line 61, and our own #15715 at `Export.cpp` L402-431 (its `Pending4_068` and later removals sit right after this PR's `Pending4_065`-`067`). 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 #10392, #14664, #14836, #15577, #15657 and #15715 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!15789
No description provided.