feat(libc): implement libc++ system_error and generic_category #27519
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27519"
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 kiansaeidnia on 2026-11-26T16:04:28Z.
What
The RetroArch Azahar core (PPSA99169, import inventory on #5927) imports 11 libc++
std::__1names forsystem_errorthat libc did not define. This PR adds them:generic_category();system_errorconstructors takingerror_codeplusconst char*orstd::string(C1/C2);system_errordestructors (D1/D2), RTTI and vtable;__throw_system_error(int, const char*);error_categorybase destructor (D2) and RTTI.The layout follows LLVM libc++ 17
system_error.cppand the Azahar relocations:error_codeis 16 bytes, with theintvalue at 0 and the category pointer at 8.system_erroris a libc++runtime_errorwith theerror_codeat 16 (32 bytes in total).__do_message, which derives fromerror_category. They use the libc++ vtable order: D1, D0,name,default_error_condition, the twoequivalentoverloads, thenmessage.message()returns a libc++ short or long string through the hidden result pointer. The text comes from the gueststrerror_r, and values at or aboveELASTgiveunspecified generic_category errororunspecified system_category error.what()iswhat_arg + ": " + message()only when the code is nonzero, as in libc++ 17.#26252 adds the three
error_categorybase members (default_error_conditionand bothequivalentoverloads) as exports. This PR does not export them. The two categories fill those vtable slots with private functions, so either PR can merge first.The new debt fragment says the layout is taken from libc++ 17 and the Azahar relocations, not from a console module. It also says
ELASTis taken as FreeBSD 11's 96, which is unverified for the guest's libc++ build. A nullwhatargument or a null category throws.pr_overlapcould not compareApi.hppwith #11831, #12682, #12688, #12700, #12965, #18135, #25289 and #26224, because they conflict withmain. I checked their diffs by hand: none declares these names. The I/O cancellation PRs only throw the hoststd::system_error.Tested
Windows 11, MinGW-w64 GCC 16.2, Release. These tests pass: the new
guest_libcxx_system_error, plusguest_generic_category,guest_libcxx_regex_error,guest_libcxx_bad_weak_ptr,guest_standard_exception_type_recordsandguest_libc_doraise_system_error.The new test checks:
ELAST, a negative value, and the base slots;messagecomes from its own vtable, with short and long libc++whatstrings, and with a nullwhator a null category, which throw;__throw_system_erroris caught asruntime_errorwith the libc++ RTTI;error_categoryD2 leaves the object unchanged.Exports.cppand the test were syntax-checked with g++ 11 on Linux (WSL Ubuntu).test_public_headers.py --audit-onlyanddebt_fold.py --checkpass. Not tested in the Azahar core itself.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T16:19:25Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed changes add libc++
system_errorsupport and its guest ABI tests; no concrete blocking defect was found in the inspected code.What I ran
Reviewed head
a2f3578789035b76de129313c5e4e437767429e7using the prepared diff andrepo_read.py. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
The PR description reports that the changes were not tested in the Azahar core. Testing there would add confidence that the imported ABI matches the target application.
Not verified
No build or test results were independently verified. Azahar core behavior and console behavior were not tested. The manifest lists five changed files, all included;
diff.patchcontained their complete changes. No excluded changed files were listed in the manifest.To get this to a good state
Nothing is required. Optional: test the new imports in the Azahar core.