Repository navigation
feat(libSceLibcInternal): implement basic_streambuf xsgetn and xsputn - #23837
Merged
oneandonlydean merged 1 commit intoNov 20, 2026
Merged
oneandonlydean merged 1 commit into
oneandonlydean merged 1 commit into
Conversation
PrivacyOnion
approved these changes
Nov 19, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against e85e771696:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libc_internal_streambuf_transfer_testsbuilt cleanly. - CTest (
guest_libc_internal_streambuf_transfer):1/1 Test #4432: guest_libc_internal_streambuf_transfer ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
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. - Code reading:
- Validated StreambufTransfer.cpp GetElements and PutElements for negative and zero count handling (returns 0 immediately without dereferencing pointers or mutating state)
- Verified Available calculation in StreambufTransfer.cpp: properly handles nullptr next/end, end <= next, pointer difference, and element byte scaling
- Audited StreambufTransfer.cpp pointer arithmetic and std::memcpy bounds for both char and uint16_t (wchar_t) specializations
- Audited virtual slot lookups and calling conventions (uflow slot 8, overflow slot 4 with APS5_VABI) matching Microsoft STL and AnyPS5 vtable conventions
- Verified docs/dev/debt/changes/ fragment formatting and removal of placeholder InventoryExports 045, 046, 048, 049 from InventoryExports.cpp and InventoryExports.hpp
- Checked CMakeLists.txt and GuestLibcInternalStreambufTransfer.cpp unit tests across edge cases (full buffer, partial buffer, EOF on uflow/overflow, zero/negative count, null stream/buffer exceptions)
Looks Good To Me
12 tasks done
basic_streambuf<char> and <wchar_t>::xsgetn and xsputn were parameterless inventory placeholders that threw, so a guest stream buffer that inherits them failed on its first bulk read or write (istream::read, ostream::write). They now follow Microsoft STL's basic_streambuf (stl/inc/streambuf): copy what the get or put area holds, then move one element at a time through the virtual uflow or overflow until it returns end-of-file, and return the count moved. The areas are the indirect next and end pointers time_get and time_put already use. Their mangled names hash to the inventory NIDs, so the exports are named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Progress report (aa698cd → c511705)📈 System libraries: 44.52% (+0.01%, +4 implemented, -4 removed functions) ✅ 4 implemented
🗑️ 4 removed
Changed libraries (implemented exports)
|
GiannisG1
force-pushed
the
feat/libcinternal-streambuf-xsgetn-xsputn
branch
from
November 19, 2026 19:22
e85e771 to
c511705
Compare
ycbuzi
added a commit
to ycbuzi/AnyPS5
that referenced
this pull request
Nov 19, 2026
PrivacyOnion
approved these changes
Nov 19, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against c511705d5d:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libc_internal_streambuf_transfer_testsbuilt cleanly. - CTest (
guest_libc_internal_streambuf_transfer):1/1 Test #4435: guest_libc_internal_streambuf_transfer ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
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. - Code reading:
- StreambufTransfer.cpp: verified Available() safely handles nullptr, *end <= *next, and computes integer division by element size without overflow or signed pointer subtraction issues
- StreambufTransfer.cpp: verified GetElements and PutElements for count <= 0 immediately returning 0 without dereferencing pointers or modifying stream state
- StreambufTransfer.cpp: checked vtable dispatch for CallUflow (slot 8) and CallOverflow (slot 4) matching Microsoft STL streambuf layout and APS5_VABI calling convention
- StreambufTransfer.cpp: verified argument checking and throwing std::invalid_argument when self, self->vtable, or (count > 0 && destination/source == nullptr) are null
- StreambufTransfer.cpp: verified wchar_t / std::uint16_t signed/unsigned promotion in CallOverflow and unsigned conversions in GetElements/PutElements
- InventoryExports.cpp & include/InventoryExports.hpp: verified removal of old placeholders 045, 046, 048, 049 and correct replacement with exported mangled symbols
- GuestLibcInternalStreambufTransfer.cpp: verified test coverage across bulk transfers, partial buffer reads/writes, uflow/overflow fallbacks, EOF termination, and null argument exceptions
Looks Good To Me
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 feat(libSceLibcInternal): implement istreambuf_iterator equal #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: refactor(prx): name the libSceLibcInternal export aliases the NID databases resolve #17300 (rename-only) names the same four aliases. feat(libSceLibcInternal): implement the msun trigonometric kernels #13778, feat(libSceLibcInternal): run the deleting destructors of future_error, overflow_error and underflow_error #14834, refactor(prx): name the libSceLibcInternal export aliases the NID databases resolve #17300, feat(libSceLibcInternal): construct the moneypunct facet and answer its members #18135 and feat(libSceLibcInternal): implement _Hypot, _FHypot and _LHypot #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 feat(libSceLibcInternal): implement istreambuf_iterator equal #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