feat(libc): export the wide time_put facet vtable as data #12704

Merged
mazen320 merged 2 commits from upstream-pr/12704 into main 2026-11-10 18:35:58 +00:00
mazen320 commented 2026-10-29 03:27:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-29T03:27:58Z.


What

Export time_put<wchar_t>'s vtable (NID 5KOPB+1eEfs) as seven zeroed uintptr_t slots so titles that resolve it as data get a 56-byte object matching console title libc.prx (PPSA26344). Facet calls through the slots still fault until methods are wired (debt note). Uses kTimePutWideVtableSlots with a static_assert and a sizeof check like the char time_put / num_put size-gate. #12510 (time_put<char>) has landed. Keep-both with open #12518 and other locale facet PRs if they land first.

Tested

  • Measured NID 5KOPB+1eEfs as STT_OBJECT size 56 on title libc.prx from PPSA26344.
  • guest_locale_tests — passed (Windows MinGW) on tip 4e487bf755164c1673669c7a14ecbeb27aa556ee.
  • python tools/check_conventions.py --base upstream/main — passed on that tip.
  • Hosted product Linux/Windows CI not claimed here.

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 (#12510 landed)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5061592551 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12704). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-29T03:27:58Z. --- ### What Export `time_put<wchar_t>`'s vtable (NID `5KOPB+1eEfs`) as seven zeroed `uintptr_t` slots so titles that resolve it as data get a 56-byte object matching console title `libc.prx` (PPSA26344). Facet calls through the slots still fault until methods are wired (debt note). Uses `kTimePutWideVtableSlots` with a `static_assert` and a `sizeof` check like the char `time_put` / `num_put` size-gate. #12510 (`time_put<char>`) has landed. Keep-both with open #12518 and other locale facet PRs if they land first. ### Tested - Measured NID `5KOPB+1eEfs` as `STT_OBJECT` size 56 on title `libc.prx` from PPSA26344. - `guest_locale_tests` — passed (Windows MinGW) on tip `4e487bf755164c1673669c7a14ecbeb27aa556ee`. - `python tools/check_conventions.py --base upstream/main` — passed on that tip. - Hosted product Linux/Windows CI not claimed here. ### 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 (#12510 landed) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: none - [x] AI-assisted: yes
rooklz commented 2026-10-29 03:45:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T03:45:58Z.

Review: APPROVED


Independent host check of tip 7abed65218 (stacked on #12510 d295b98f23), macOS 26 x86_64, clang ASan+UBSan.

Names / NIDs. tools/nid_names.py --name gives _ZTVSt8time_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE → 5KOPB+1eEfs and the char form → OwfBD-2nhJQ, matching the body and the debt lines. Seven slots = offset-to-top + typeinfo + the four FacetVtable entries + TimePutVtable::put (offset 0x20 in GuestLocale.hpp), which is consistent with the measured st_size 56.

Run. I built a standalone guest_locale_tests from LocaleSupport.cpp and core/libs/tests/GuestLocale.cpp unmodified. The shim covered the heap/syslock/new/delete/__error hooks, plus snprintf/strftime forwarded to the host. The PR tip passes all checks except CheckTimePut/CheckNumPut: those fail identically on main under my host-strftime shim (%E/%O handling), so I left them out of both runs. The other 21 checks pass on head and on main, with no sanitizer reports.

Mutants on the wide vtable, all killed:

mutant result
{} → {1} (non-zero slot) test fails
kTimePutWideVtableSlots = 8 static_assert
definition [6] instead of the constant redeclaration error
definition dropped link error
const definition linkage mismatch

Merge. git merge-tree against main b433c40f2f is clean, and check_conventions --base upstream/main passes. This PR conflicts with #12518, #12511 and #10158 (adjacent appends in GuestLocale.hpp, the test file and debt/libc.md). The body already marks those as keep-both, so that's fine.

LGTM once #12510 lands.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692602199 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12704#pullrequestreview-5692602199). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T03:45:58Z. **Review:** APPROVED --- Independent host check of tip `7abed65218` (stacked on #12510 `d295b98f23`), macOS 26 x86_64, clang ASan+UBSan. **Names / NIDs.** `tools/nid_names.py --name` gives `_ZTVSt8time_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE` → `5KOPB+1eEfs` and the `char` form → `OwfBD-2nhJQ`, matching the body and the debt lines. Seven slots = offset-to-top + typeinfo + the four `FacetVtable` entries + `TimePutVtable::put` (offset 0x20 in `GuestLocale.hpp`), which is consistent with the measured `st_size` 56. **Run.** I built a standalone `guest_locale_tests` from `LocaleSupport.cpp` and `core/libs/tests/GuestLocale.cpp` unmodified. The shim covered the heap/syslock/new/delete/`__error` hooks, plus `snprintf`/`strftime` forwarded to the host. The PR tip passes all checks except `CheckTimePut`/`CheckNumPut`: those fail identically on `main` under my host-`strftime` shim (`%E`/`%O` handling), so I left them out of both runs. The other 21 checks pass on head and on main, with no sanitizer reports. **Mutants** on the wide vtable, all killed: | mutant | result | |---|---| | `{}` → `{1}` (non-zero slot) | test fails | | `kTimePutWideVtableSlots = 8` | `static_assert` | | definition `[6]` instead of the constant | redeclaration error | | definition dropped | link error | | `const` definition | linkage mismatch | **Merge.** `git merge-tree` against `main` b433c40f2f is clean, and `check_conventions --base upstream/main` passes. This PR conflicts with #12518, #12511 and #10158 (adjacent appends in `GuestLocale.hpp`, the test file and `debt/libc.md`). The body already marks those as keep-both, so that's fine. LGTM once #12510 lands. AI-assisted: yes
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!12704
No description provided.