#include "prx/libc/include/general/VabiMacros.hpp" #include "prx/libkernel/KernelErrors.hpp" #include #include #include #include #include extern "C" std::int32_t APS5_VABI sceKernelError(std::int32_t); extern "C" int* APS5_VABI __error_nid_postfix(); static void Require(bool value) { if (!value) throw std::runtime_error("Kernel error conversion check failed"); } int main() { *__error_nid_postfix() = 123; const std::array, 6> cases{{ {0, 0}, {1, SCE_KERNEL_ERROR_EPERM}, {2, SCE_KERNEL_ERROR_ENOENT}, {4, SCE_KERNEL_ERROR_EINTR}, {14, SCE_KERNEL_ERROR_EFAULT}, {22, SCE_KERNEL_ERROR_EINVAL} }}; for (const auto [input, expected] : cases) { Require(sceKernelError(input) == expected); Require(*__error_nid_postfix() == 123); } Require(sceKernelError(-1) == static_cast(0x8001ffffu)); Require(sceKernelError(std::numeric_limits::max()) == 0x1ffff); Require(sceKernelError(std::numeric_limits::min()) == 0x20000); Require(*__error_nid_postfix() == 123); }