feat(libSceLibcInternal): implement the num_get<char> and num_get<wchar_t> get members #15788
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15788"
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-04T14:51:18Z.
What
The 22 public
getoverloads ofnum_get<char, istreambuf_iterator<char>>andnum_get<wchar_t, istreambuf_iterator<wchar_t>>in libSceLibcInternal threw from thePending3placeholders inErr.cpp. They now returndo_getthrough the facet's own vtable. These are the callsstd::istreamandstd::wistreamoperator>>make throughuse_facet<num_get<...>>forbool, the integer types, the floating types andvoid*.charNID (was)wchar_tNID (was)boolOWO5cpNw3NA(Pending3_056)vW-nnV62ea4(Pending3_081)unsigned shortgozsp4urvq8(Pending3_063)bZ+lKHGvOr8(Pending3_088)unsigned intN1VqUWz2OEI(Pending3_060)Y3hBU5FYmhM(Pending3_085)longI2UzwkwwEPs(Pending3_061)-m2YPwVCwJQ(Pending3_086)unsigned long2bfL3yIBi5k(Pending3_062)94ZLp2+AOq0(Pending3_087)long long4hiQK82QuLc(Pending3_064)cG5hQhjFGog(Pending3_089)unsigned long longeZfFLyWCkvg(Pending3_065)banNSumaAZ0(Pending3_090)float6RGkooTERsE(Pending3_059)2mb8FYgER+E(Pending3_084)doublemAwXCpkWaYc(Pending3_057)+hjXHfvy1Mg(Pending3_082)long doublewUCRGap1j0U(Pending3_058)xLZr4GJRMLo(Pending3_083)void*my9ujasm6-0(Pending3_055)zomvAQ5RFdA(Pending3_080)Each NID matches
tools/nid_names.pycompute_nidof its mangled name, for example_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE3getES3_S3_RSt8ios_baseRNSt5_IosbIiE8_IostateERbgivesOWO5cpNw3NA. The others differ in the character type (Ic/Iw) and the last letters (t,j,l,m,x,y,f,d,e,Pv). All 22 were checked.What each
getdoes:getreturnsdo_get(in, end, str, err, val). The first microsoft/STL commit does the same for all eleven overloads (xlocnum L308-L361):return do_get(_First, _Last, _Iosbase, _State, _Val);.The slot order is an inference. The console's
libSceLibcInternal.sprxwas not read. The standard synopsis ([locale.num.get]) declaresdo_getfor bool, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double and void*. This PR uses the microsoft/STL (Dinkumware) order instead, the order of thedo_getdeclarations in xlocnum L365-L636: bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, void*, starting after the fourFacetVtableslots at 0x20. The evidence for that choice is indirect:GuestLocale::NumPutVtable, which libc hands to guests asg_numPutVtable(LocaleSupport.cpp), already lays outnum_putin the microsoft/STL order (putLong,putUnsignedLong,putLongLong), not the standard's (long, long long, unsigned long);_ZTVSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEEand_ZTVSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEEwith 17 entries: offset-to-top and RTTI, 4 facet slots and 11do_getslots. That fixes the count, not the order.If the console's order differs, the forwarders call the wrong
do_get. The debt entry says so, and the test pins every slot, so a later change to the order fails it.Changes:
GuestLocale.hpp: newGuestLocale::InputIterator, an opaque, trivially copyable 16-byte value foristreambuf_iterator, withstatic_asserts on its size and triviality. Nothing reads its fields.istreambuf_iterator<char>andistreambuf_iterator<wchar_t>are both 16 bytes (pointer,bool, element padded; the members are_Strbuf,_Gotand_Valin streambuf L519-L521) with no user-declared copy constructor or destructor, so both are passed and returned in two integer registers like this struct.GuestLocale.hpp: newGuestLocale::NumGetVtablewith all eleven slots, astatic_asserton every slot offset (0x20 to 0x70) and on the size (0x78). Theios_base::iostate&argument is_Iosb<int>::_Iostate&in the mangled names and is passed asstd::int32_t*.NumGet.cppwith the 22 forwarders, and the 22 placeholders removed fromErr.cpp.docs/dev/debt/libSceLibcInternal.md: the 22 per-NID "prototype and behavior are unverified" entries are removed and one entry records what is still open.The
InputIteratorblock inGuestLocale.hpp(and its<type_traits>include) is byte-for-byte the block of thetime_getandmoney_get/money_putPRs from the same batch, at the same place, so the three merge in any order.git merge-tree --write-treeof each pair, of all three, and of each againstmainis clean, and the merged header has oneInputIterator.Still not done:
num_getfacet or implementsdo_get, so today these calls reach only a facet the title provides. The facet constructors,_Init,_Getcat,_Getifld,_Getffldand thedo_getmembers still throw.Tested
No title was run. I added the guest test
guest_libc_internal_num_get(core/libs/tests/GuestLibcInternalNumGet.cpp). It loadslibSceLibcInternal, calls each of the 22 exports with a facet whose vtable records every call, and checks:do_getslot of its own value type exactly once (every slot of the vtable records a different index, so a forwarder bound to a wrong slot, or a wrong slot order, fails);do_getreturns and leaves the statedo_getwrote;The header
static_asserts pin every slot offset (0x20 to 0x70) and the size.Results:
ctest -R '^guest_libc_internal_num_get$'passed 3 of 3 runs (1/1 each), and once more after the negative-control restore.public_headerspassed.b11c7bf84fwith this commit applied (git write-treeequal to the commit's tree) passedctest -R '^(guest_libc_internal_num_get|public_headers)$'3 of 3 runs (2/2 each), and 1 of 1 after the restore.Err.cppput back andNumGet.cppemptied, keeping the new test, the test fails on both hosts withsceLibcInternalPending3_056_nid_no_patch not implemented(Windows exit code 0xc0000409, Linux subprocess aborted).python3 tools/check_conventions.py --base origin/mainwith this title and body: "All conventions checks passed."tools/progress.pycollect_libraries()for libSceLibcInternal: done 92 to 114 (+22), todo 1045 to 1023. Overall done 9921 to 9943 of 37146; the total does not change, so no new todo.python3 tools/pr_overlap.py --branch feat/r4-num-get-membersfailed closed. It reported one PR with conflicting lines: our own #15712 (collate<wchar_t> members), whosePending3_049-054removals inErr.cppand debt lines sit right next to this PR's. It implements different functions; whichever lands second rebases. No PR has the same exports or new files. It could not compare 8 PRs that conflict with main: #5021, #13486, #13778, #13782, #14212, #14401, #14837 and #14936. I grepped the added and removed lines of every file patch of each one (from the REST files API; for #14212'sdocs/dev/debt/libSceLibcInternal.md, whose patch the API omits,git diffof the fetched PR head against its merge base) for the 44 NIDs of this batch, thePending3_055-065,Pending3_080-090andPending4stub names it removes, thenum_get/time_get/money_get/money_putmember mangled names,InputIterator,NumGetVtable,TimeGetVtable,MoneyGetVtable,MoneyPutVtableand the new file names. None has a match. #15712's lines have no match either.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
Pull request closed