Files
AnyPS5/core/libs/tests/GuestPthreadHostFaultMask.cpp
T
Ycaro Gabriel f7aa7b9cf4 fix(tests): use canonical pthread declarations in host fault mask test
The public header audit now finds duplicate declarations when this test redeclares the pthread APIs. Include the canonical libkernel header so the test follows the current API and public_headers remains valid.
2026-10-27 19:37:33 -03:00

37 lines
1.2 KiB
C++

#include "prx/libkernel/include/Api.hpp"
#include "SceTypes.hpp"
#include <csignal>
#include <cstdlib>
#include <pthread.h>
static constexpr int FaultSignals[] = {SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP};
static void Require(bool value) { if (!value) std::abort(); }
static void* APS5_VABI CheckMask(void* arg) {
sigset_t mask;
Require(pthread_sigmask(SIG_SETMASK, nullptr, &mask) == 0);
for (const int signal : FaultSignals) Require(sigismember(&mask, signal) == 0);
*static_cast<bool*>(arg) = true;
return nullptr;
}
int main() {
sigset_t oldMask;
sigset_t blocked;
sigemptyset(&blocked);
for (const int signal : FaultSignals) sigaddset(&blocked, signal);
Require(pthread_sigmask(SIG_BLOCK, &blocked, &oldMask) == 0);
bool ran = false;
Pthread thread = nullptr;
Require(scePthreadCreate(&thread, nullptr, CheckMask, &ran, "host-fault-mask") == 0);
sigset_t creatorMask;
Require(pthread_sigmask(SIG_SETMASK, nullptr, &creatorMask) == 0);
for (const int signal : FaultSignals) Require(sigismember(&creatorMask, signal) == 1);
Require(pthread_sigmask(SIG_SETMASK, &oldMask, nullptr) == 0);
Require(scePthreadJoin(thread, nullptr) == 0);
Require(ran);
}