feat(libSceLibcInternal): implement num_put<char>::put and time_put<char>::put #15715
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15715"
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 B-Howell on 2026-11-04T09:07:48Z.
What
Implements ten
libSceLibcInternalexports that threw throughNotImplemented_nid_no_patchonmain: the publicputmembers ofstd::num_put<char>andstd::time_put<char>(theostreambuf_iterator<char>instantiations), whichoperator<<on numbers andstd::put_timereach through the stream's facets.mainnum_put<char>::put(..., bool)(...3putES3_RSt8ios_basecb)nftirmo6hBgsceLibcInternalPending3_106(Err.cpp)do_put(bool)num_put<char>::put(..., long)(...basecl)ffnhh0HcxJ4sceLibcInternalPending3_109do_put(long)num_put<char>::put(..., unsigned long)(...basecm)uODuM76vS4UsceLibcInternalPending3_110do_put(unsigned long)num_put<char>::put(..., long long)(...basecx)NJtKruu9qOssceLibcInternalPending3_111do_put(long long)num_put<char>::put(..., unsigned long long)(...basecy)dep6W2Ix35ssceLibcInternalPending3_112do_put(unsigned long long)num_put<char>::put(..., double)(...basecd)w9NzCYAjEpQsceLibcInternalPending3_107do_put(double)num_put<char>::put(..., long double)(...basece)VPcTGA-LwSosceLibcInternalPending3_108do_put(long double)num_put<char>::put(..., const void*)(...basecPKv)8NVUcufbklMsceLibcInternalPending3_105do_put(const void*)time_put<char>::put(..., const tm*, char, char)(...basecPK2tmcc)qkuA-unH7PUsceLibcInternalPending4_069(Export.cpp)do_put(spec, mod)time_put<char>::put(..., const tm*, const char*, const char*)(...basecPK2tmPKcSB_)j9LU8GsuEGwsceLibcInternalPending4_068Where the behaviour comes from:
num_put::putasReturns: do_put(out, str, fill, val)., and [locale.time.put.members] the(spec, mod)overload asReturns: do_put(s, str, fill, t, format, modifier).The Dinkumware code in the first microsoft/STL commit219514876ea8writes them the same way:return do_put(_Dest, _Iosbase, _Fill, _Val);(stl/inc/xlocnumL1189-L1227) andreturn do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier);(stl/inc/xloctimeL680-L683).do_putis virtual, so each export calls the slot of the facet's own vtable (GuestLocale::NumPutVtableputBool0x20 toputPointer0x58,TimePutVtable::put0x20, all already static_asserted). A guest facet that overridesdo_putis honoured; libc's ownnum_put/time_putfacets run libc's existingNumPut*andTimePutDoPut.stl/inc/xloctimeL646-L678): it takesuse_facet<ctype<char>>(_Iosbase.getloc()), and for each characterif (_Ctype_fac.narrow(*_Fmtfirst) != '%')copies it; a trailing%is copied;E,O,Qand#after%are modifiers, and a modifier at the end is copied with its%; every other specifier goes todo_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier), whose returned iterator is used for the rest of the pattern. It isLibcTimePutPattern_nid_no_patchinlibc'sLocaleSupport.cpp, next toTimePutDoPut, because it useslibc's existingFindFacet(the stream'slocale::idlookup thatWidenalready uses forctype<char>) andPutCharacter(theostreambuf_iteratorwrite: a full or null buffer setsfailed, and later characters are still offered, as Dinkumware'soperator=does:if (!_Strbuf || traits_type::eq_int_type(_Traits::eof(), _Strbuf->sputc(_Right))) { _Failed = true; },stl/inc/streambufL555-L561). The export inlibSceLibcInternalcalls it._Is_valid_strftime_specifierchecks that write?for some specifiers. That is a later MSVC change, not Dinkumware's, so it is left out: every specifier goes todo_put, as in219514876ea8and the standard ("For each valid format sequence identified, callsdo_put").ctype<char>vtable'sdo_narrowslot with a null default, asctype<char>::narrow(c, '\0')does.GuestLocale::CtypeVtablegetsnarrow(0x50) andnarrowRange(0x58) afterwidenRangewith static_asserts, in the declaration order ofctype<char>'s virtuals. These lines are character-for-character the ones thefeat/r2-ctype-char-widenbranch adds, so the two merge cleanly in either order (checked withgit merge-tree).ctype<char>facet, the pattern is narrowed by identity. Dinkumware'suse_facetwould then create the classicctype<char>through_Getcat, whosedo_narrowreturns the character;libchas noctype<char>::_Getcat, andlibc'sWidenalready treats a missingctype<char>the same way.The ten stubs are removed from
Err.cppandExport.cpp; the new exports are incore/libs/prx/libSceLibcInternal/FacetPut.cpp. The debt file drops their ten "prototype and behavior are unverified" lines and gets one entry for what stays unverified: the console'slibSceLibcInternal.sprxwas not read and no title was seen calling them.tools/progress.pycollect_libraries()onorigin/main5b1d381d5aand on this branch:libSceLibcInternaldone 92 -> 102 (+10), todo 1045 -> 1035 (-10);libcunchanged at 1628 done, 19 todo. The repository total goes from 9913 to 9923 done of 37146, so +10 done and no new todo. The branch merges cleanly into the currentorigin/mainb11c7bf84f.Tested
guest_libc_internal_facet_put(core/libs/tests/GuestLibcInternalFacetPut.cpp). It resolves the ten exports by their NID export names (<NID>_nid_no_patch_cut) from the builtlibSceLibcInternal.prx, so the same test runs againstmain's stubs:num_put::putcalls thedo_putslot of its own value type on a recording vtable, passes the facet, stream, fill, iterator and value (INT64_MIN,UINT64_MAX,0x8000000000000001,-2.5,1.0L / 3.0L, a pointer), and returns whatdo_putreturned.libc's ownnum_put<char>facet from_Getcat:put(long)gives***-42and0X****FF(hex, showbase, uppercase, internal),put(double)andput(bool)give0.125and1.time_put::put(spec, mod)callsdo_putonce with its arguments and returns its iterator.do_put: empty and plain patterns,a%Yb%Ec%Od%%e(four calls, in order,%%going todo_put),Qand#modifiers, unknown and null specifiers, trailing%and%E,%EE, and a failed iterator returned bydo_putcarried through the rest of the pattern.ctype<char>: the pattern is narrowed through it (!to%,qtoE,ztod), once per examined character with a null default, literal characters keep their unnarrowed value, and a trailing!qis copied as!E.libc's owntime_put<char>facet:%Y-%m-%d %H:%M:%S %% %Ey %Oy %gives2026-10-02 13:05:09 % 26 26 %,put('a')givesFri, and a streambuf that takes 3 characters marks the iterator failed while all 10 characters of%Y-%m-%dare still offered.87228bb9f8:guest_libc_internal_facet_put,guest_locale(thelibclocale code changed here),debt_splitand 39conventions_*tests (the last 40 are checker self-tests oftools/check_conventions.pyand the debt-file splitter, not tests of this change) were run 3 times withctest -j2; 42/42 passed each time (126/126). The other two checker self-tests,conventions_wrapped_declarationsandconventions_wrapped_declarations_AbiAliasTests, hit ctest's 30 s timeout on this loaded machine; run directly withpython tools/tests/test_check_conventions_wrapped_declarations.py <class>3 times each, they passed every time (6/6, 19-26 s each).conventions_wrapped_declarationsself-tests) were run 3 times withctest -j2; 44/44 passed each time (132/132).f7d95ac7bc, whose test file is identical to the final one):main'sErr.cpp,Export.cpp,LocaleSupport.cppandGuestLocale.hpp, withFacetPut.cppremoved and this PR's test, build and the test fails:terminate called after throwing an instance of 'std::runtime_error',what(): sceLibcInternalPending3_106_nid_no_patch not implemented(the first export it calls,put(bool)).python3 tools/check_conventions.py --base origin/main --title ... --body ...with this title and body printed "All conventions checks passed."python3 tools/pr_overlap.py --branch feat/r2-numput-char-puton the final commit probed 1804 open PRs againstmainb11c7bf84fand failed closed. Its table lists only neighbouring lines, no same exports and no same new files: #14158 and #15692 (libSceLibcInternal/CMakeLists.txtL79, where this PR addsFacetPut.cppand its test afterFilesystem.cpp), and #14373, #14834, #15695 and #15697 (debt file L534, the entry this PR's entry follows). It could not compare #5021, #7081, #9526, #10158, #10165, #10200, #12510, #12511, #12518, #12704, #13486, #13778, #13782, #13881, #14212, #14401, #14837 and #14936. I took the diff of all 24 (gh pr diff; for #5021, which is too large for that, thelibSceLibcInternal,LocaleSupportandGuestLocalefile patches from the pull request files API), together with #14085 and #15696 from an earlier run, and searched every added and removed line for the ten NIDs, the3putES3_RSt8ios_basemangled names, the ten stub names,LibcTimePutPattern,CtypeVtableandFacetPut. None has a hit, so none implements these functions or edits the stub lines this PR removes. Whichever of the neighbouring PRs merges second needs a rebase.5b1d381d5a; none of the 87 commits from there tob11c7bf84ftouches a file this PR changes, andgit merge-treemerges it intob11c7bf84fwithout conflicts.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)🤖 Generated with Claude Code