refactor(kernel): share SCE kernel error codes through KernelErrors.hpp #27

Merged
QDarkRex merged 5 commits from upstream-pr/27 into main 2026-09-28 19:07:33 +00:00
QDarkRex commented 2026-09-27 06:32:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-09-27T06:32:32Z.


Stacked on #25 and #26. Only the last commit (refactor(kernel): share SCE kernel error codes through KernelErrors.hpp) is new here; please merge after #25 and #26. The diff shrinks to that commit once they land.

Summary

SCE kernel error codes were declared locally in each file under three different prefixes (SCE_KERNEL_ERROR_* in Pthread/File/DirectMemory, EQUEUE_ERROR_*, KERNEL_SEMA_ERROR_*). That duplication is how the wrong values fixed in #25/#26 went unnoticed (0x8001xxxx range, EDEADLK holding the EAGAIN value, ETIMEDOUT = 0x80020062).

This PR adds core/libs/prx/libkernel/KernelErrors.hpp, which contains:

  • a SceKernelError(errno) helper that builds 0x80020000 | errno;
  • SCE_KERNEL_ERROR_* constants for FreeBSD errno 1..94 (EPERM … ECAPMODE).

Every constant was cross-checked against shadPS4's orbis_error.h. Slots 95/96 are left out because Sony uses them for its own codes (ENOBLK, EICV) instead of FreeBSD's ENOTRECOVERABLE/EOWNERDEAD.

Code changes:

  • The local definitions in Attr.cpp, Cond.cpp, Mutex.cpp, Thread.cpp, Open.cpp, DirectMemory.hpp, Equeue.hpp and Semaphore.hpp are removed.
  • EQUEUE_ERROR_* / KERNEL_SEMA_ERROR_* are renamed to SCE_KERNEL_ERROR_*, including their uses in libSceVideoOut.
  • EQUEUE_OK / KERNEL_SEMA_OK are unchanged.

No behaviour change: every constant keeps its numeric value. After normalising the prefixes, each + line in the diff is identical to its - line.

Tests

  • core/libs/tests/*.cpp are intentionally left untouched. They hard-code the expected guest-visible values, so they check the header independently.
  • Windows, MinGW-w64 GCC 15.2.0: 35/35 passed.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4652122652 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27). Originally posted by [QDarkRex](https://github.com/QDarkRex) on 2026-09-27T06:32:32Z. --- > **Stacked on #25 and #26.** Only the last commit (`refactor(kernel): share SCE kernel error codes through KernelErrors.hpp`) is new here; please merge after #25 and #26. The diff shrinks to that commit once they land. ## Summary SCE kernel error codes were declared locally in each file under three different prefixes (`SCE_KERNEL_ERROR_*` in Pthread/File/DirectMemory, `EQUEUE_ERROR_*`, `KERNEL_SEMA_ERROR_*`). That duplication is how the wrong values fixed in #25/#26 went unnoticed (`0x8001xxxx` range, `EDEADLK` holding the `EAGAIN` value, `ETIMEDOUT` = `0x80020062`). This PR adds `core/libs/prx/libkernel/KernelErrors.hpp`, which contains: - a `SceKernelError(errno)` helper that builds `0x80020000 | errno`; - `SCE_KERNEL_ERROR_*` constants for FreeBSD errno 1..94 (`EPERM` … `ECAPMODE`). Every constant was cross-checked against shadPS4's `orbis_error.h`. Slots 95/96 are left out because Sony uses them for its own codes (`ENOBLK`, `EICV`) instead of FreeBSD's `ENOTRECOVERABLE`/`EOWNERDEAD`. Code changes: - The local definitions in `Attr.cpp`, `Cond.cpp`, `Mutex.cpp`, `Thread.cpp`, `Open.cpp`, `DirectMemory.hpp`, `Equeue.hpp` and `Semaphore.hpp` are removed. - `EQUEUE_ERROR_*` / `KERNEL_SEMA_ERROR_*` are renamed to `SCE_KERNEL_ERROR_*`, including their uses in `libSceVideoOut`. - `EQUEUE_OK` / `KERNEL_SEMA_OK` are unchanged. **No behaviour change:** every constant keeps its numeric value. After normalising the prefixes, each `+` line in the diff is identical to its `-` line. ## Tests - `core/libs/tests/*.cpp` are intentionally left untouched. They hard-code the expected guest-visible values, so they check the header independently. - Windows, MinGW-w64 GCC 15.2.0: **35/35** passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
boykopovar commented 2026-09-28 08:20:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-28T08:20:49Z.


There are two conflicts

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5866197830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27#issuecomment-5866197830). Originally posted by [boykopovar](https://github.com/boykopovar) on 2026-09-28T08:20:49Z. --- There are two conflicts
QDarkRex commented 2026-09-28 08:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-09-28T08:40:09Z.


Done.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5866467801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27#issuecomment-5866467801). Originally posted by [QDarkRex](https://github.com/QDarkRex) on 2026-09-28T08:40:09Z. --- Done.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27
No description provided.