Skip to content

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

Open
Danigamer05 wants to merge 41 commits into
boykopovar:mainfrom
Danigamer05:feat/libc-sce-v2-time-put-20261109
Open

Danigamer05 wants to merge 41 commits into
boykopovar:mainfrom
Danigamer05:feat/libc-sce-v2-time-put-20261109

Conversation

@Danigamer05

@Danigamer05 Danigamer05 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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, feat(libc): export the money_put facet vtable as data #12518 and feat(libc): export the wide time_put facet vtable as data #12704 export the unversioned std::time_put vtables as zeroed data, different symbols. feat(libc): add std::__sce_v2::_Random_device, _Fiopen and setw #9526 and feat(libc): wire the codecvt<wchar_t,char> facet vtable #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: feat(libc): implement the std::__sce_v2 time_get virtuals #17568
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Danigamer05 and others added 24 commits November 5, 2026 21:33
…irtuals for char

The facets built by _Makeloc threw NotImplemented from every virtual
except the lifecycle slots. The char ctype, numpunct and codecvt facets
now answer as the console's libc.prx does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…irtuals for wchar_t

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main removed GuestStringInlineCapacity, GuestStringCapacityMask and
GuestStringLargeAllocation from LocaleSupport.cpp, so the versioned
facets' strings use GuestLocale::StringInlineCapacity,
GuestLocale::StringCapacityMask and GuestStringStorage::Deallocate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egers, bool and pointers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main removed GuestStringInlineCapacity and GuestStringCapacityMask from
LocaleSupport.cpp, so AssignSceV2String uses
GuestLocale::StringInlineCapacity and GuestLocale::StringCapacityMask.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main removed GuestStringInlineCapacity and GuestStringLargeAllocation
from LocaleSupport.cpp, so TakeSceV2String tests
GuestLocale::StringInlineCapacity and frees through
GuestStringStorage::Deallocate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sce-v2-num-put-wide-20261107

Brings in current main through boykopovar#16516. The templated TakeSceV2String
frees through GuestStringStorage::Deallocate, since main removed
GuestStringLargeAllocation from LocaleSupport.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…integers, bool and pointers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ating point

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sce-v2-num-get-wide-floating-20261108

# Conflicts:
#	docs/dev/debt/libc.md
…floating point

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_compare, do_transform and do_hash of collate<char> and
collate<wchar_t>, and the nine virtuals of moneypunct<char, Intl> and
moneypunct<wchar_t, Intl>, following the libc.prx of PPSA03671.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_open, do_get and do_close of messages<char> and
messages<wchar_t>, following the libc.prx of PPSA03671: no catalog
opens, and do_get returns a copy of the default string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_put of a long double and of a digit string for
money_put<char> and money_put<wchar_t>, following the libc.prx of
PPSA03671: Dinkumware's field writer with this module's character
pattern encoding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_get for long double and for digit strings in
money_get<char> and money_get<wchar_t>, following the PPSA03671
libc.prx: _Getmfld reads the negative pattern of the moneypunct facet
byte by byte, matches the symbol, sign, grouped value with its fraction
and spaces, and do_get converts the digits with _Stod or widens them
into the string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement date_order, get_time, get_date, get_weekday, get_monthname,
get_year and the single-field do_get of time_get<char> and
time_get<wchar_t>, following the PPSA03671 libc.prx: its integer reader
counts spaces as digits and converts with the v2 _Stolx, names match
without case through the global locale's ctype, %x reads day first and
%% never fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement do_put of time_put<char> and time_put<wchar_t>, following the
PPSA03671 libc.prx: it formats "!%<modifier><specifier>" with strftime
or wcsftime into a buffer grown by 16, 32, 64 units until the call
succeeds, keeps errno, and writes the text after the leading mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head e2ba8b1b29, merged onto main b5a9a4781c (eec6f44a91, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_sce_v2_char_facet_virtuals, guest_sce_v2_codecvt_wide, guest_sce_v2_collate_moneypunct, guest_sce_v2_facet_ids, guest_sce_v2_makeloc, guest_sce_v2_messages, guest_sce_v2_money_get, guest_sce_v2_money_put, guest_sce_v2_num_get_char, guest_sce_v2_num_get_wide, guest_sce_v2_num_put_char, guest_sce_v2_num_put_wide, guest_sce_v2_time_get, guest_sce_v2_time_put pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7715 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8965 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 12682 core/libs/prx/libc/CMakeLists.txt
PR 12688 core/libs/prx/libc/CMakeLists.txt
PR 12700 core/libs/prx/libc/CMakeLists.txt
PR 12717 core/libs/prx/libc/CMakeLists.txt
PR 12849 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12965 core/libs/prx/libc/CMakeLists.txt
PR 15973 docs/dev/debt/libc.md
PR 17746 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 23395 core/libs/prx/libc/CMakeLists.txt
PR 24907 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 25573 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 28051 core/libs/prx/libc/CMakeLists.txt
PR 28565 core/libs/prx/libc/CMakeLists.txt
PR 28568 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 28709 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/GuestLocale.hpp
PR 28808 core/libs/prx/libc/CMakeLists.txt

Danigamer05 and others added 4 commits November 12, 2026 22:56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
std::int64_t is long on Linux x86-64 and std::llabs returns long long,
so std::min could not deduce a single type and LocaleSupport.cpp did not
build there. Name std::int64_t explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

The time_put implementation and changed-line coverage were inspected at head c330516; 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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 17, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 20, 2026
Danigamer05 and others added 5 commits November 20, 2026 18:00
A review asked whether a field whose first 768 or more digits are zeros
could reach the lost-digit rounding with no kept digit, and bump the
leading zero or the decimal point. It cannot: leading zeros in the
integer part are not counted, and leading fraction zeros only lower the
power, so the first nonzero digit is always kept. Pin that down with 800
integer zeros, 769 fraction zeros before a 1 scaled back by e770, and
both together. Counting leading zeros as significant fails two of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A review asked for a test of a moneypunct facet whose currency symbol is
empty, since the optional-symbol checks compare the next character with
symbol[0]. On a std::basic_string that is the terminating null, so the
comparison is defined and an empty symbol simply matches nothing. Check
it at the front and at the end of the pattern, with and without
showbase, including input left after the value. Failing every empty
symbol breaks these cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ycbuzi

ycbuzi commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tested 97e64242db merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 2 tests failed out of 7494; 99% tests passed, 2 tests failed out of 7494. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7494; 99% tests passed, 1 tests failed out of 7494. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants