Repository navigation
feat(libc): expose narrow libc++ basic_stringstream<char> vtable and VTT - #29269
cmsierrave-coder wants to merge 23 commits into
Conversation
# Conflicts: # core/libs/prx/libc/CMakeLists.txt
# Conflicts: # core/libs/prx/libc/libc.hpp
# Conflicts: # core/libs/prx/libc/CMakeLists.txt # core/libs/prx/libc/libc.hpp
Add the std::__1 iostream_category and the ios_base::failure const char* and string constructors, D1, D2, RTTI and vtable. failure is a system_error with its own vtable and typeinfo, so what() is msg + ": " + message() for a nonzero code. iostream_category is named "iostream" and reports "unspecified iostream_category error" for io_errc::stream (1) and from the ELAST cutoff on, strerror text otherwise, as LLVM libc++ 17 ios.cpp does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the libc++ 17 ios_base object layout and its offset asserts from LibcxxIosInit.cpp to GuestLocale.hpp as LibcxxIosBase, next to LibcxxLocale, so the basic_ostream exports can read the stream state, exception mask, buffer and format flags through the same checked layout instead of a second copy. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add ios_base::clear and the basic_ostream<char> sentry constructor and destructor, put, write, flush and the complete and base destructors, imported by RetroArch's Azahar core (PPSA99169). They follow LLVM libc++ 17.0.6 <ostream>, <ios>, <streambuf> and ios.cpp. The basic_ios virtual base is found through the virtual-base offset at vtable slot -24, and the stream buffer's sync, xsputn and overflow are called through the guest object's vtable; put writes into the put area as the inline sputc does. clear throws ios_base::failure with io_errc::stream as a guest exception. Exceptions from the stream buffer are caught like libc++ does, since guest and host share libc's exception runtime: badbit is set and the exception is rethrown when the mask has badbit. The sentry destructor skips pubsync while libc's uncaught exception count is nonzero. The base destructor does nothing and ignores the VTT, matching clang's code for the empty destructor body; the complete destructor runs the basic_ios<char> base destructor on the virtual base. Unreadable objects and missing virtual functions throw invalid_argument and are not turned into badbit. The gaps are recorded in the libc debt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eam buffers per export MakeStream and MakeBuffer returned objects that point into themselves, so the test relied on copy elision. The fixtures are now set up in the caller's objects. The debt entry now says what each export does with no stream buffer, instead of listing them all as throwing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The targeted source inspection found no confirmed blocker in the paths read; this review is incomplete because several changed files were not read.
What I ran
Reviewed head 042bc11adec64be1315911de260a297d390bbd70 using the prepared diff and head snapshots. The pinned repo_read.py returned one source file, then could not append its read log in the read-only run directory; I used the supplied snapshots for subsequent targeted inspection. No tests or builds were run.
Results
| Check | Result | Note |
|---|---|---|
| Prepared change metadata | passed | Description, commits, manifest and exclusion list inspected |
| Targeted source inspection | passed | Stream lifecycle, transfers, ostream and stringstream paths |
| Tests and build | not run | No commands that compile were run |
| Full change-set review | not run | Several changed files were not read |
Findings
Blocking
None confirmed in the inspected files. This is not a determination about files that were not read.
Non-blocking
No code feedback from the inspected paths.
Not verified
Full or targeted contents inspected: core/libs/prx/libc/src/LibcxxIosInit.cpp, LibcxxIstreamDestructors.cpp, LibcxxLocaleFacet.cpp, LibcxxOstream.cpp, LibcxxStreambufLifecycle.cpp, LibcxxStreambufTransfer.cpp, LibcxxStringstream.cpp, portions of core/libs/prx/libc/src/exception/StandardExceptions.cpp and TypeInfo.cpp, portions of core/libs/prx/libc/include/GuestLocale.hpp, LibcxxStreamVtables.hpp, LibcxxStringstream.hpp, core/libs/tests/GuestLibcxxIstreamDestructors.cpp, GuestLibcxxStreambufLifecycle.cpp, GuestLibcxxStreambufTransfer.cpp, GuestLibcxxStringstreamVtables.cpp, and a portion of GuestLibcxxSystemError.cpp.
Other manifest-reviewed files were not read in full: core/libs/prx/libc/CMakeLists.txt; core/libs/prx/libc/include/Api.hpp, LibcxxIosInit.hpp, LibcxxIstreamDestructors.hpp, and LibcxxStreambufTransfer.hpp; core/libs/prx/libc/libc.hpp; core/libs/prx/libc/tests/cmake/guest_libcxx_istream_destructors.cmake, guest_libcxx_ostream.cmake, guest_libcxx_streambuf_lifecycle.cmake, guest_libcxx_streambuf_transfer.cmake, and guest_libcxx_stringstream_vtables.cmake; core/libs/tests/GuardedBuffer.hpp, GuestDynamicCast.cpp, GuestLibcStaticImports.cpp, and GuestLibcxxOstream.cpp; the remainder of GuestLibcxxSystemError.cpp; and the nine changed debt documents under docs/dev/debt/changes/. files.json lists no excluded files. The author reports a Windows MSYS2 guest test and SDK layout comparison; those were not run or independently verified here. Retail console behavior is also unverified, as the description states.
To get this to a good state
Nothing is required by the inspected paths. Optional: read the remaining manifest-reviewed files before treating this as a complete review.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
Expose the narrow libc++ basic_stringstream vtable and VTT as 2wX7xq90Ra0 and q_7I-bZ0544. The 120-byte vtable describes the istream, ostream and virtual basic_ios address points. The ten-entry VTT includes the basic_iostream, basic_istream and basic_ostream construction tables. Teardown releases long string storage and the embedded streambuf locale before destroying the virtual basic_ios base.
Feature commit
Tested
Windows MSYS2 Release on the fork passed
guest_libcxx_stringstream_vtablesfora9b81b770596. GitHub Actions runThe guest test checks every VTT entry, the diamond RTTI, cross-casts and virtual-base adjustment, and complete and deleting dispatch through all three address points. Heap and erase-callback checks cover teardown.
Compared the guest object sizes and layout to the PS5 Payload SDK v0.42
libc++.aarchive. SDK releaseRetroArch/Azahar startup and retail console behavior remain unverified.
The branch merges into upstream snapshot efbc232. An exact scan of 1,697 open libc source trees found no owner for 2wX7xq90Ra0 and q_7I-bZ0544.
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)