feat(libc): add std::system_category and keep error_code values at offset 4 #9014
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9014"
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 hypermoist on 2026-10-21T09:48:46Z.
What
Adds
std::system_category()(aotaAaQK6yc) and moves theerror_code/error_conditionvalue to byte offset 4, where the console keeps it.PPSA29340's eboot imports
system_category. So do the SDK modules shipped with PPSA08427. In PPSA29340 the call comes from itsstd::filesystemcode: it builds anerror_codeby writing 0 to +0 and the category to +8, readsvalue()at +4, and compares the category pointer withsystem_category()(around eboot0xaa7a5a–0xaa7b2f).Behaviour from the decrypted PS5 13.60
libSceLibcInternal:error_codelayouterror_category::equivalent(const error_code&, int)(0x1b760) compares the value at +4 and the category at +8. Bothdefault_error_conditionoverrides (0x1b710, 0x1bba0) return the value shifted into the high half of the first qword.system_errorstores the code as those two qwordsErrorCodeis{reserved, value, category}; the condition overrides return{0, value, category}system_category()(0x1b6e0)_System_error_categoryname(0x1bb00)"system"message(0x1bb10)"unknown error"fallback as the genericmessage(0x1b900)default_error_condition(0x1bba0)_Syserror_map's tableequivalent(int, const error_condition&)(0x1b730)default_error_conditionand compares the resultSt22_System_error_category, deriving fromSt14error_categoryThe deleting destructor throws, as the generic one already does on
main. The code is written from the observed behaviour; nothing from the module is copied.Not changed here:
mainuses 95 and 96. It also has 1040, 1050, 1051 and 1074, whichmainlacks. I'll send that as a separate PR.__sce_v2::system_errorwas not assessed. It is built differently (libc++-style). My #8901 still writes the old two-fieldErrorCode, so whichever of the two lands second gets adjusted.iostream_categorystill returns the host library's object.Tested
Linux (CachyOS, GCC, Release).
guest_generic_categorynow also checks:name;value << 32;equivalentoverloads go through the system mapping;The generic condition is also checked for the reserved dword and for
equivalent.GuestAmprCppError.cppandGuestAmprThreads.cppreadsystem_error::codethrough their own copies of the layout, and both copies now match it.The 552 tests matching
guest_|libc|ampr|exceptionall pass. Each negative control fails the test:equivalentcomparing against the object itself instead of its condition ("line 71").tools/check_conventions.pyis clean. No open PR exportssystem_categoryunder its name or NID. Three-way merges with the open PRs touching these files: #6044, #7201, #8658 and #8901 each gain one or two conflicting hunks inStandardExceptions.cpp; the others merge cleanly.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)system_category; neither was run with this change🤖 Generated with Claude Code
https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T09:49:29Z.
Progress report (
1381826→1860f90)📈 System libraries: 50.98% (+0.01%, +1 implemented functions)
✅ 1 implemented
_ZSt15system_categoryv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-22T12:52:22Z.
Overlap notes for the reports above:
_ZSt15system_categoryvand rewrites the sameErrorCodelines, but it keeps the value at both +0 and +4. I've proposed on #9416 that this PR goes first (it was opened earlier and its layout comes from the 12.00 firmware) and that #9416 then drops its system category and depends on this one.const_casts to thevtablereads at lines 56-59 ofGuestGenericCategory.cpp, which this PR also edits. Whichever is merged second keeps both: the new checks from here and the casts from there.🤖 Generated with Claude Code