feat(libc): format time_put<char>::do_put as the console's libc does #11044
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11044"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by verusferro on 2026-10-25T14:58:44Z.
What
time_put<char>::do_putthrew (TimePutMethodUnsupported), so a title that formats astd::tmthrough a stream (std::put_time,time_put::put) stopped there. It now does what the SDKlibc.prxthat PPSA06416 ships insce_module/(title SDK 7.00) does, read from its disassembly (REVERSE_ENGINEERING, source 2). The module exports it as+i81FtUCarA(0x9aa00):!%followed by the modifier and the conversion, or the conversion alone when the modifier is 0, and runs_Strftimeon it, the same functionstrftimecalls. It starts with a 16-byte buffer and doubles it until the result fits; the leading!tells an empty result from one that did not fit, and is dropped.sputcdoes. When the stream buffer's put pointer (*(buffer + 0x40)) is set and(int)(*(buffer + 0x60) - next) > 0, it stores the character and advances the pointer. Otherwise it callsoverflow, vtable slot 4, and marks the iterator failed when that returnseof. A null buffer marks the iterator failed. A failed iterator still offers the rest of the characters, and the stream and fill arguments are not read.The facet gets a vtable with its single
do_putslot instead of eight throwing slots. The formatting goes through this library'sstrftime, so its gaps carry over.GuestLocale.hppdescribes the three guest types this touches: the stream buffer's put pointers, itsoverflowslot and the 16-byte iterator, which arrives in two registers and is returned in RAX:RDX.The debt entry for these facets now says
time_putformats throughstrftime. To keep it under 1000 characters, thestd::clog,std::wclogand facet id sizes that shared it move to an entry of their own, unchanged.Tested
Ubuntu 24.04 (WSL2) x86-64, GCC 13.3, Release, full build with
BUILD_TESTING=ON:libc.prx, converted by the relinker and loaded in a host process, compared against this library's facet with the same fake stream buffer. That covers every conversion byte 0-255 with no modifier and withE,O,#,x,Y, 0x80 and%, each with room in the buffer, 2 bytes of room withoverflowrefusing every character or every other one, a null put pointer and a null buffer: 8,176 calls. Stored bytes, the order ofoverflowcalls, the failed flag and the returned iterator match in all of them except the 12%Zcalls. There the module prints the empty zone name of a process withoutTZand this library prints the host's, as the existingtznamedebt entry records. A format that ends afterEorOis left out: the console crashes there andstrftimethrows.guest_localegainsCheckTimePut: a conversion that fits, one that runs intooverflowpart way (and needs a 32-byte buffer),EandO, a 0 conversion, an unknown conversion,overflowrefusing (all 8 characters are still offered), a null put pointer and a null buffer. Emitting the!as well fails it.ctest -R '^(guest_locale|guest_strftime|patched_libraries|conventions_unknown_nids)$': 4/4 pass.tools/progress.py: libc +1 implemented (TimePutDoPut),TimePutMethodUnsupportedremoved.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py: no conflicting lines or same exports; none of the 39 pull requests it could not compare touchestime_put, the stream buffer types or this debt entry.Windows: not run by me.
guest_localepassed in @ycbuzi's run of186fbf3b8fand in @wachi35676's run of this head3338ffefff, as the parent of #11054.Not tested: macOS, a title that calls
put_time.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:16:45Z.
Review: APPROVED
Reviewed exact head 186fbf3b8f92f8c649bd869180af12887b4a8922. The guest streambuf offsets and vtable slot are statically asserted, the formatter follows the observed leading-sentinel and overflow behavior, and failed iterators still receive every output character. The focused test covers formatting, overflow rejection, null put-next, and null iterator buffer. The author also reports 8,176 comparisons against the title SDK implementation with only the documented timezone difference. Hosted conventions, intake, eligibility, relinker, sanitizer, and register-context checks pass; product jobs are skipped by path policy. I reviewed the implementation and test but did not run the full local build here.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:51:16Z.
Review: CHANGES_REQUESTED
I manually checked the exact heads of #9456 (
159a6f44078e56a677b354da7e0d88688583a7f7) and #9468 (ef2f603255e817198618bd38a1fddd803b115ce5) against this PR (186fbf3b8f92f8c649bd869180af12887b4a8922).git merge-treereports a content conflict only incore/libs/tests/GuestLocale.cpp; all three branches closeCheckFacetGetcatand add a separate check at that insertion point. The implementation additions appear independent, and a combined result should retain one closing brace plus all three checks. PerCONTRIBUTING.md, please coordinate merge order with the other authors and declare the agreed dependency on the checklist (Depends on: #N) before this PR is considered ready. This is a merge-order issue, not a finding that thetime_putimplementation overlaps semantically withtime_getornum_get.