feat(libc): implement generic error category messages #5102
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5102"
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 Dripl1x on 2026-10-13T11:41:49Z.
What
Calling
message()on the generic category stored in a gueststd::system_errorcurrently throwsstd::_Generic_error_category::message not implemented. Return an owned guest string instead, and export the related runtime entry points:std::_Syserror_map(int)—PDX01ziUz+4std::generic_category()—YxwfcCH5Q0Istd::_Generic_error_category::message(int) const—KZ++filsCL4The map covers the 72 distinct Dinkumware errc values present in FreeBSD 11.4's errno header. Unmapped values return null from
_Syserror_mapand produceunknown errorfrom the category. Lookup follows the first matching entry: FreeBSD aliases EAGAIN/EWOULDBLOCK selectoperation would block, and ENOTSUP/EOPNOTSUPP selectnot 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
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:46:45Z.
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.
main)docs/dev/debt/libc.mdL65docs/dev/debt/libc.mdL65docs/dev/debt/libc.mdL64-65docs/dev/debt/libc.mdL65Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:47:39Z.
Progress report (
2f969f1→e3cef33)📈 System libraries: 87.85% (+0.01%, +3 implemented functions)
✅ 3 implemented
_ZNKSt23_Generic_error_category7messageEi_nid_postfix_ZSt13_Syserror_mapi_nid_postfix_ZSt16generic_categoryv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:03:19Z.
Checked the message table against VC12
syserror.cppand FreeBSD 11.4errno.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, includingguest_generic_categoryandguest_ampr_cpp_error); the new tests need the new exports. Merging once the full Build is green.