feat(libSceLibcInternal): implement basic_streambuf xsgetn and xsputn #23837
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23837"
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 GiannisG1 on 2026-11-19T18:35:50Z.
What
basic_streambuf<char>andbasic_streambuf<wchar_t>xsgetnandxsputn(inventory 045, 046, 048 and 049, NIDsVpwymQiS4ck,sXaxl1QGorg,lZVehk7yFok,041c37QfoUc) were parameterless placeholders that threw. A guest stream buffer that does not override them inherits these exports through its vtable (slots 9 and 10), so its first bulk transfer failed:istream::read,ostream::write,sgetn,sputn.They now follow Microsoft STL's
basic_streambuf(stl/inc/streambuf) and C++ [streambuf.virt.get]/[streambuf.virt.put]:uflow(slot 8) oroverflow(slot 4) until it returns end-of-file;overflowgets the element as a non-negativeint_type(0xff and 0xffff are not end-of-file), asto_int_typegives.Each mangled name hashes to its inventory NID (
tools/nid_names.py), so the exports are named and the four placeholders are gone. The count is anint, as the mangled names give.The get and put areas are the indirect next and end pointers that
time_get(TimeGetFields.cpp) andtime_put(LocaleSupport.cpp, read from the SDKlibc.prx) already use: 0x38 and 0x58, 0x40 and 0x60. Microsoft STL keeps remaining counts there instead, so only the next pointer advances, as in those functions. End-of-file is -1 for the 16-bit wide form too, as in the library's other wide stream code. The new header is included by the library umbrella. The debt fragment removes the four table rows and adds a Functional entry: not verified on a console.Tested
Linux Mint 22.3, GCC 13.3.0, Release, head on
maine4cee4952b.guest_libc_internal_streambuf_transfer, with a fake guest stream buffer, forcharandwchar_t:xsgetnof 10 with a 4-element get area and 3 more fromuflowreturns 7 in order, writes nothing after them, empties the get area and callsuflow4 times;uflowalone;uflow;xsputnof 8 with room for 4 and anoverflowthat takes 2 returns 6, fills the put area first and stops at the thirdoverflow. 0xff (0xffff wide) reachesoverflowas 255 (65535);std::invalid_argument.main: the test does not link, because none of the four exports exists there (their NIDs reach the throwing placeholders). This PR: passes 3/3.tools/suite.py): GPU tests on a GTX 1050 Ti (NVIDIA 580.178.04), an HD 630 (Mesa 25.2.8 ANV) and llvmpipe 25.2.8, everything else once.guest_libc_internal_streambuf_transferandguest_libc_internal_time_get_fieldspass.mainbaseline (HD 630 10, llvmpipe 3) plus two more:agc_driver_pm4_order_signalon the GTX and llvmpipe. It checks for a median below 0.1 ms and does not load libSceLibcInternal. Interleaved with amaine4cee4952bbuild, 5 runs per GPU, both builds failed 7 of 15 (measured for #23809).public_headers: the new header was missing from the library umbrella. The include was added, andpublic_headers, its 64 compile tests, everyguest_libc_internal_*test and the conventions and checker tests (344) then passed on the rebuilt tree.NotImplemented_nid_no_patchtostd::invalid_argument(headc511705d5d). They are invalid arguments, not unimplemented paths, andtools/progress.pycounts a reachableNotImplementedas a stub. On that tree,public_headersand its compile tests, everyguest_libc_internal_*test and the conventions and checker tests (344) pass.progress.py --module libSceLibcInternallists none of the four exports as pending.check_conventions.py,check_test_registration.py,check_main_sync.py(merges cleanly),check_compile.pyanddebt_fold.py --checkare clean.pr_overlap.py --branch: #17300 (rename-only) names the same four aliases. #13778, #14834, #17300, #18135 and #21704 could not be compared because they conflict withmain. A trial merge with each adds no conflicting file beyond those it already has. It merges cleanly with #23809.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
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T18:47:36Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e85e771696:tools/check_conventions.pypassed.guest_libc_internal_streambuf_transfer_testsbuilt cleanly.guest_libc_internal_streambuf_transfer):core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/libSceLibcInternal.hpp,core/libs/prx/libSceLibcInternal/StreambufTransfer.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T19:48:16Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c511705d5d:tools/check_conventions.pypassed.guest_libc_internal_streambuf_transfer_testsbuilt cleanly.guest_libc_internal_streambuf_transfer):core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/libSceLibcInternal.hpp,core/libs/prx/libSceLibcInternal/StreambufTransfer.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me