mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-08 13:50:20 +00:00
40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
#include "prx/libkernel/include/Api.hpp"
|
|
#include "SceTypes.hpp"
|
|
#include <cstdlib>
|
|
#include <stdexcept>
|
|
|
|
static constexpr int GuestEinval = 22;
|
|
|
|
static void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
template <class TCall>
|
|
static bool ThrowsInvalidArgument(TCall call) {
|
|
try {
|
|
call();
|
|
} catch (const std::invalid_argument&) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int main() {
|
|
PthreadCond cond = nullptr;
|
|
Require(pthread_cond_init_nid_postfix(&cond, nullptr) == 0);
|
|
Require(pthread_cond_setname_np_nid_postfix(&cond, "first") == 0);
|
|
Require(pthread_cond_setname_np_nid_postfix(&cond, "second") == 0);
|
|
Require(pthread_cond_signal_nid_postfix(&cond) == 0);
|
|
Require(ThrowsInvalidArgument([&] { return pthread_cond_setname_np_nid_postfix(&cond, nullptr); }));
|
|
Require(pthread_cond_setname_np_nid_postfix(nullptr, "cond") == GuestEinval);
|
|
Require(pthread_cond_destroy_nid_postfix(&cond) == 0);
|
|
Require(pthread_cond_setname_np_nid_postfix(&cond, "destroyed") == GuestEinval);
|
|
Require(pthread_cond_init_nid_postfix(&cond, nullptr) == 0);
|
|
Require(pthread_cond_setname_np_nid_postfix(&cond, "reinitialized") == 0);
|
|
Require(pthread_cond_destroy_nid_postfix(&cond) == 0);
|
|
|
|
PthreadCond lazy = nullptr;
|
|
Require(pthread_cond_setname_np_nid_postfix(&lazy, "lazy") == 0 && lazy != nullptr);
|
|
Require(pthread_cond_signal_nid_postfix(&lazy) == 0);
|
|
Require(pthread_cond_destroy_nid_postfix(&lazy) == 0);
|
|
Require(pthread_cond_setname_np_nid_postfix(&lazy, "lazy") == GuestEinval);
|
|
}
|