feat(libc): implement the std::__sce_v2 time_put virtuals #17578

Open
Danigamer05 wants to merge 41 commits from upstream-pr/17578 into main
Danigamer05 commented 2026-11-08 23:21:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Danigamer05 on 2026-11-08T23:21:22Z.


What

Builds on #17568: this branch contains its commits, and through them #17539, #17331, #17296, #17277, #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current main. It needs none of their code beyond the output helper of #16516 and their place in LocaleSupport.cpp, so it stacks to avoid conflicts. Until they merge, only the last commit is this PR's change.

Implement do_put of std::__sce_v2::time_put<char> and time_put<wchar_t>, which _Makeloc builds and std::put_time calls. Before this PR, their two slots threw NotImplemented_nid_no_patch. These slots are not exports, so this PR adds no NID. With this PR, every char and wchar_t facet of _Makeloc has its virtuals; the unsigned short facets still throw.

The behavior comes from the libc.prx bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), vtables 0x18CCE0 and 0x18D310, read from the disassembly of do_put (0xE0F10, 0xF11B0):

  • The format is !% followed by the modifier and the specifier, or by the specifier alone when the modifier is zero. In the wchar_t facet each byte is sign-extended. The leading ! keeps the result from being empty.
  • The text goes through the exported strftime, or wcsftime for wchar_t, into a buffer that grows by 16, 32, 64 and so on units until the call returns nonzero. errno is restored afterwards. wcsftime fills a buffer that is too small with what fits and returns that count, so a wchar_t field longer than 15 units, %c for one, is written as nothing, as on the console.
  • The characters after the ! go to the output iterator as they are, with no widen and no fill. A missing or failing stream buffer fails the iterator.
  • When wcsftime returns 0 with errno at EINVAL, the wchar_t facet sets badbit on the stream and writes nothing. If the stream's exception mask covers the new state, the module throws ios_base::failure; this library throws NotImplemented there, recorded in the new debt entry.

The _Makeloc debt entry no longer lists time_put.

Tested

Windows 11, MinGW GCC 15.2, Release, head on top of #17568. Not run on Linux or macOS, not run in a title.

  • New test guest_sce_v2_time_put:
    • %Y, %d with a modifier, %%, %n, %A and %c, which grows the char buffer;
    • output through overflow and into a missing buffer, and the kept errno;
    • wchar_t %Y, %B and the empty %c.
  • Differential harness against the module's own code, loaded and relocated, with each side's own locale from its _Makeloc.
    • Each call randomizes the specifier, among every strftime conversion and %%, and the modifier (none, E, O or #). It also randomizes every tm field in and out of range, the stream state, errno, and the output buffer: direct room, overflow, a rejecting overflow, no buffer, and an already failed iterator.
    • It compares the written text, the iterator, the stream state and errno.
    • With the module's strftime and wcsftime redirected to this library's: 900,000 calls over 3 seeds, 0 differences.
    • With the module's own: 200,000 calls, 2,552 differences, all in %Z and %z, where this library prints the guest zone as the strftime debt entry describes.
  • The libc tests built from this head, without the tests that drive the GPU, audio, video or controllers (207): all pass, with guest_fopen_errors skipped.
  • Negative control, 4 single-change mutations: the test and the harness both catch the format order and the written !. Neither catches the other two, and both are equivalent here. One drops the errno restore, which neither function changes on success. The other sizes the buffer 16 and 32 instead of 16 and 48, and no field in the C locale needs more than 31 units.
  • check_conventions, git diff --check: clean. Merges cleanly with main.
  • pr_overlap reports no open PR with the same functions or conflicting code. It could not compare 48 PRs that conflict with main on shared files. Of the 4 that touch LocaleSupport.cpp, #12518 and #12704 export the unversioned std::time_put vtables as zeroed data, different symbols. #9526 and #11172 do not touch time_put.

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: #17568
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5216183119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17578). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-08T23:21:22Z. --- ### What Builds on #17568: this branch contains its commits, and through them #17539, #17331, #17296, #17277, #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current `main`. It needs none of their code beyond the output helper of #16516 and their place in `LocaleSupport.cpp`, so it stacks to avoid conflicts. Until they merge, only the last commit is this PR's change. Implement `do_put` of `std::__sce_v2::time_put<char>` and `time_put<wchar_t>`, which `_Makeloc` builds and `std::put_time` calls. Before this PR, their two slots threw `NotImplemented_nid_no_patch`. These slots are not exports, so this PR adds no NID. With this PR, every `char` and `wchar_t` facet of `_Makeloc` has its virtuals; the `unsigned short` facets still throw. The behavior comes from the `libc.prx` bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 `483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6`), vtables `0x18CCE0` and `0x18D310`, read from the disassembly of `do_put` (`0xE0F10`, `0xF11B0`): - The format is `!%` followed by the modifier and the specifier, or by the specifier alone when the modifier is zero. In the `wchar_t` facet each byte is sign-extended. The leading `!` keeps the result from being empty. - The text goes through the exported `strftime`, or `wcsftime` for `wchar_t`, into a buffer that grows by 16, 32, 64 and so on units until the call returns nonzero. `errno` is restored afterwards. `wcsftime` fills a buffer that is too small with what fits and returns that count, so a `wchar_t` field longer than 15 units, `%c` for one, is written as nothing, as on the console. - The characters after the `!` go to the output iterator as they are, with no `widen` and no fill. A missing or failing stream buffer fails the iterator. - When `wcsftime` returns 0 with `errno` at `EINVAL`, the `wchar_t` facet sets `badbit` on the stream and writes nothing. If the stream's exception mask covers the new state, the module throws `ios_base::failure`; this library throws `NotImplemented` there, recorded in the new debt entry. The `_Makeloc` debt entry no longer lists `time_put`. ### 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. --> Windows 11, MinGW GCC 15.2, Release, head on top of #17568. Not run on Linux or macOS, not run in a title. - New test `guest_sce_v2_time_put`: - `%Y`, `%d` with a modifier, `%%`, `%n`, `%A` and `%c`, which grows the `char` buffer; - output through `overflow` and into a missing buffer, and the kept `errno`; - `wchar_t` `%Y`, `%B` and the empty `%c`. - Differential harness against the module's own code, loaded and relocated, with each side's own locale from its `_Makeloc`. - Each call randomizes the specifier, among every `strftime` conversion and `%%`, and the modifier (none, `E`, `O` or `#`). It also randomizes every `tm` field in and out of range, the stream state, `errno`, and the output buffer: direct room, `overflow`, a rejecting `overflow`, no buffer, and an already failed iterator. - It compares the written text, the iterator, the stream state and `errno`. - With the module's `strftime` and `wcsftime` redirected to this library's: 900,000 calls over 3 seeds, 0 differences. - With the module's own: 200,000 calls, 2,552 differences, all in `%Z` and `%z`, where this library prints the guest zone as the `strftime` debt entry describes. - The libc tests built from this head, without the tests that drive the GPU, audio, video or controllers (207): all pass, with `guest_fopen_errors` skipped. - Negative control, 4 single-change mutations: the test and the harness both catch the format order and the written `!`. Neither catches the other two, and both are equivalent here. One drops the `errno` restore, which neither function changes on success. The other sizes the buffer 16 and 32 instead of 16 and 48, and no field in the C locale needs more than 31 units. - `check_conventions`, `git diff --check`: clean. Merges cleanly with `main`. - `pr_overlap` reports no open PR with the same functions or conflicting code. It could not compare 48 PRs that conflict with `main` on shared files. Of the 4 that touch `LocaleSupport.cpp`, #12518 and #12704 export the unversioned `std::time_put` vtables as zeroed data, different symbols. #9526 and #11172 do not touch `time_put`. ### 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: #17568 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-16 22:47:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T22:47:04Z.

Review: COMMENTED


Reviewed — comments

The time_put implementation and changed-line coverage were inspected at head c330516476; the author-reported Windows tests were not run here, so a formal decision is not justified.

What I ran

  • Read the prepared description, commit list, manifest, diff, review-folder file list, and selected changed code and tests through the repository reader.
  • No build or test commands were run.

Results

Check Result Note
Prepared bundle inspection passed Head and changed-file list checked
Build and tests not run Results in the description are author-reported

Findings

Blocking

None verified in the inspected time_put implementation.

Non-blocking

None.

Not verified

  • The full changed-line coverage required by the review-folder README was not completed. In particular, only selected ranges of LocaleSupport.cpp were read; other changed files, including the additional facet implementations and tests, were not audited.
  • Build, test, and console behavior were not verified independently.
  • Excluded files were not enumerated: files.json is not present in the prepared review folder.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5929242887 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17578#pullrequestreview-5929242887). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T22:47:04Z. **Review:** COMMENTED --- # Reviewed — comments The time_put implementation and changed-line coverage were inspected at head c3305164760d45203708dc30d2c5d42f2106bf79; the author-reported Windows tests were not run here, so a formal decision is not justified. ## What I ran - Read the prepared description, commit list, manifest, diff, review-folder file list, and selected changed code and tests through the repository reader. - No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Prepared bundle inspection | passed | Head and changed-file list checked | | Build and tests | not run | Results in the description are author-reported | ## Findings ### Blocking None verified in the inspected time_put implementation. ### Non-blocking None. ## Not verified - The full changed-line coverage required by the review-folder README was not completed. In particular, only selected ranges of LocaleSupport.cpp were read; other changed files, including the additional facet implementations and tests, were not audited. - Build, test, and console behavior were not verified independently. - Excluded files were not enumerated: `files.json` is not present in the prepared review folder. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-20 11:47:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:47:25Z.

Review: APPROVED


Reviewed — looks good

The changed time_put implementation and its integration are consistent with the stated behavior; no blocking defect was verified.

What I ran

Reviewed head 15cecb5675d3cacd45bf9eb4e47e1c553b323d8e using the prepared diff and pinned repository reader. No commands or tests were run in this review.

Results

Check Result Note
Diff and changed code passed Reviewed all changed files listed below
Automated checks not run Results in the PR description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported Windows build, test suite, differential harness and negative controls were not run independently. Linux, macOS and console behavior were not verified. Reviewed all changed files reported in review/manifest.json; no files were excluded by rule.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992169166 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17578#pullrequestreview-5992169166). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T11:47:25Z. **Review:** APPROVED --- # Reviewed — looks good The changed time_put implementation and its integration are consistent with the stated behavior; no blocking defect was verified. ## What I ran Reviewed head `15cecb5675d3cacd45bf9eb4e47e1c553b323d8e` using the prepared diff and pinned repository reader. No commands or tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Reviewed all changed files listed below | | Automated checks | not run | Results in the PR description are author reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The reported Windows build, test suite, differential harness and negative controls were not run independently. Linux, macOS and console behavior were not verified. Reviewed all changed files reported in `review/manifest.json`; no files were excluded by rule. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-21 07:14:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:14:11Z.

Review: APPROVED


Reviewed — looks good

The change at 97e64242db2f52c6b972caa49ed23892d962f571 implements the char and wchar_t time output facets; the inspected implementation and available evidence support merging.

What I ran

No build or tests were run during this review. I read the prepared description, commits, manifest, and diff, then inspected the changed implementation and its output helper and time formatting dependencies at the pinned head. The author reports Windows 11 tests and differential harness runs; those results were not independently verified.

Results

Check Result Note
Change and implementation review passed Inspected time output path and dependencies
Build and tests not run Author-reported results only
Changed-file coverage passed All 16 changed files were included in the manifest; inspected the implementation, interface layout, time output test, and debt entry

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build, tests, harness, or negative control. The author reports those runs in the PR description, but they are not review-run evidence. I did not read every changed file in full; the remaining included files were not individually inspected. No files were excluded by files.json rules (no files.json was present in the review folder as exposed to this review).

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003747616 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17578#pullrequestreview-6003747616). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:14:11Z. **Review:** APPROVED --- # Reviewed — looks good The change at `97e64242db2f52c6b972caa49ed23892d962f571` implements the `char` and `wchar_t` time output facets; the inspected implementation and available evidence support merging. ## What I ran No build or tests were run during this review. I read the prepared description, commits, manifest, and diff, then inspected the changed implementation and its output helper and time formatting dependencies at the pinned head. The author reports Windows 11 tests and differential harness runs; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Change and implementation review | passed | Inspected time output path and dependencies | | Build and tests | not run | Author-reported results only | | Changed-file coverage | passed | All 16 changed files were included in the manifest; inspected the implementation, interface layout, time output test, and debt entry | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build, tests, harness, or negative control. The author reports those runs in the PR description, but they are not review-run evidence. I did not read every changed file in full; the remaining included files were not individually inspected. No files were excluded by `files.json` rules (no `files.json` was present in the review folder as exposed to this review). ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 13:12:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:12:26Z.

Review: COMMENTED


Built the branch’s locale implementation and matching headers against the existing Linux runtime. The focused GuestSceV2TimePut fixture passed.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170468638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17578#pullrequestreview-6170468638). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:12:26Z. **Review:** COMMENTED --- Built the branch’s locale implementation and matching headers against the existing Linux runtime. The focused `GuestSceV2TimePut` fixture passed. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/17578:upstream-pr/17578'
git switch 'upstream-pr/17578'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/17578'
git switch 'upstream-pr/17578'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/17578'
git switch 'upstream-pr/17578'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/17578'
git switch 'main'
git merge --squash 'upstream-pr/17578'
git switch 'main'
git merge --ff-only 'upstream-pr/17578'
git switch 'main'
git merge 'upstream-pr/17578'
git push origin 'main'
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!17578
No description provided.