Skip to content

feat(libc): implement generic error category messages - #5102

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Dripl1x:codex/generic-error-category
Oct 13, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Dripl1x:codex/generic-error-category

Conversation

@Dripl1x

@Dripl1x Dripl1x commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

What

Calling message() on the generic category stored in a guest std::system_error currently throws std::_Generic_error_category::message not implemented. Return an owned guest string instead, and export the related runtime entry points:

  • std::_Syserror_map(int) — PDX01ziUz+4
  • std::generic_category() — YxwfcCH5Q0I
  • std::_Generic_error_category::message(int) const — KZ++filsCL4

The map covers the 72 distinct Dinkumware errc values present in FreeBSD 11.4's errno header. Unmapped values return null from _Syserror_map and produce unknown error from the category. Lookup follows the first matching entry: FreeBSD aliases EAGAIN/EWOULDBLOCK select operation would block, and ENOTSUP/EOPNOTSUPP select not supported. Use the same lookup for the suffix of _Throw_Cpp_error's message; its EAGAIN case previously assumed both parts were identical.

Messages use the existing GuestLocale::String model and the registered guest allocator. The accessor returns the same category object stored by _Throw_Cpp_error. Enable the existing assembly exception fixture on Linux as well as MinGW.

Semantics are based on VC12 system_error, its syserror.cpp, Microsoft STL's table, and FreeBSD 11.4 errno.h.

Tested

Windows, WinLibs MinGW-w64 GCC 15.2.0 r7, Release; WSL2 Ubuntu 26.04, GCC, Release. A focused CMake harness builds the complete libc, libkernel and libSceAmpr targets from this branch.

On the final commit, all six selected CTests pass on both hosts: guest_generic_category, guest_ampr_cpp_error, guest_errors, guest_collate, guest_new_handler, guest_new_handler_default_heap.

The new test checks direct and virtual message calls, the 15-character inline boundary, allocated strings, independent ownership, surrounding sentinels, errno preservation, unknown/extreme values and null-result rejection. The existing exception fixture checks the category attached to the actual guest exception. With the previous StandardExceptions.cpp restored through a separate baseline build source, the updated Windows fixture fails with std::_Generic_error_category::message not implemented; restoring the change passes.

An independent comparison of the source tables and FreeBSD errno assignments matches all 72 map entries. Patching the built Windows libc succeeds, and the PE export table contains all three NIDs above. Conventions and whitespace checks pass.

No console or title run, full top-level graphics build, or performance claim. The 40-byte string model and virtual return ABI are not validated against a console library; this is recorded in TechnicalDebt. A title's inline category in a bundled libc may still have a different object identity. STREAMS errno assignments absent from the FreeBSD header are not invented.

The locally available public DOOM libc was inspected for these symbols, but they point to a shared zero-return stub; it is not used as a semantic or ABI oracle.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • New third-party code: none
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#4164 docs/dev/debt/libc.md L65
#4546 docs/dev/debt/libc.md L65
#4958 docs/dev/debt/libc.md L64-65
#5087 docs/dev/debt/libc.md L65

@github-actions

Copy link
Copy Markdown

Progress report (2f969f1 → e3cef33)

📈 System libraries: 87.85% (+0.01%, +3 implemented functions)

✅ 3 implemented
Library Name
libc _ZNKSt23_Generic_error_category7messageEi_nid_postfix
libc _ZSt13_Syserror_mapi_nid_postfix
libc _ZSt16generic_categoryv_nid_postfix

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the message table against VC12 syserror.cpp and FreeBSD 11.4 errno.h (72 entries, first-match aliases for EAGAIN and ENOTSUP), built libc/libkernel/libSceAmpr merged onto main, and ran the scoped ctest (97 tests, all pass, including guest_generic_category and guest_ampr_cpp_error); the new tests need the new exports. Merging once the full Build is green.

@adriadam10
adriadam10 merged commit d5835a6 into boykopovar:main Oct 13, 2026
15 checks passed
danielradosa added a commit to danielradosa/AnyPS5 that referenced this pull request Oct 13, 2026
Error map uses Sony SDK errno numbering (KytyPS5/shadPS4): drop 95/96, add 1040/1050/1051/1056/1064/1074 (76 entries); test scans 1..1100 and expects 76 with 95/96/1062 unknown; debt entry merged by hand and cites the SDK numbering.
@jotitadev jotitadev mentioned this pull request Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants