Repository navigation
feat(libc): export narrow libc++ std::__1::cout and std::__1::cerr - #29270
cmsierrave-coder wants to merge 20 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 review inspected the prepared diff and selected implementation files at head 5dfa5404a3273cfd6c85a112e84a2a0b2ea33c82; the remaining reviewed files were not read, so a formal approval is not justified.
What I ran
No tests or builds were run. I inspected the prepared review materials and selected source files using repo_read.py and shell reads.
Results
| Check | Result | Note |
|---|---|---|
| Prepared diff and metadata | passed | Head matches the supplied SHA |
| Selected source inspection | passed | Four implementation files read |
| Tests and build | not run | No execution performed |
Negative control
Not run; no tests were executed.
Findings
Blocking
None identified in the files inspected.
Non-blocking
None.
Sources
Inspected core/libs/prx/libc/src/LibcxxOstream.cpp, core/libs/prx/libc/src/StandardStreams.cpp, core/libs/prx/libc/src/LibcxxIosInit.cpp, and core/libs/prx/libc/src/LibcxxStreambufTransfer.cpp at the pinned head. The prepared description.md, commits.md, manifest.json, files.json, and diff.patch were also inspected.
Not verified
The other files listed under reviewed in files.json were not read. files.json lists no excluded files. Tests, build behavior, and console behavior were not verified. The test result in the PR description is author-reported, not a run performed for this review.
To get this to a good state
Nothing is required. Optional: complete inspection of the remaining changed files before making a formal approval decision.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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
Export the narrow libc++ cout and cerr data symbols as NUk9hfOjti8 and BYhmuhsNRUo. Both have the SDK's 160-byte ostream layout and initialized basic_ios state with the classic locale. The buffers write and flush through the guest C stdout and stderr streams. cerr uses unitbuf and is tied to cout.
Feature commit
Tested
Windows MSYS2 Release on the fork passed
guest_libcxx_standard_outputfore530cbb2461c. GitHub Actions runThe guest test checks initial flags and locale, cout writes and explicit flush, cerr put and write, automatic unitbuf and tied-stream flushes, captured stdout and stderr bytes, and the badbit transition with no buffer.
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 NUk9hfOjti8 and BYhmuhsNRUo.
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)