mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 00:35:47 +00:00
38 lines
1.6 KiB
C++
38 lines
1.6 KiB
C++
#include "prx/libkernel/include/Api.hpp"
|
|
#include "prx/libc/include/Api.hpp"
|
|
#include "prx/libc/include/general/VabiMacros.hpp"
|
|
#include <cstdlib>
|
|
#include <initializer_list>
|
|
|
|
constexpr int noChild = 10;
|
|
constexpr int invalidArgument = 22;
|
|
constexpr int untouched = 0x5a5a5a5a;
|
|
static void Require(bool value) { if (!value) std::abort(); }
|
|
static void RequireFailure(int pid, int options, int error) {
|
|
int status = untouched;
|
|
*__error_nid_postfix() = 0;
|
|
Require(waitpid_nid_postfix(pid, &status, options) == -1);
|
|
Require(*__error_nid_postfix() == error);
|
|
Require(status == untouched);
|
|
*__error_nid_postfix() = 0;
|
|
Require(waitpid_nid_postfix(pid, nullptr, options) == -1);
|
|
Require(*__error_nid_postfix() == error);
|
|
}
|
|
int main() {
|
|
const int self = getpid_nid_postfix();
|
|
for (int pid : {-1, 0, 1, self, self + 1, -self}) {
|
|
for (int options : {0, 1, 2, 3, 4, 8, 16, 32, 0x2c, 0x3f, static_cast<int>(0x80000000u), static_cast<int>(0x80000001u), static_cast<int>(0x8000003fu)})
|
|
RequireFailure(pid, options, noChild);
|
|
for (int options : {0x40, 0x41, 0x80, 0x100, 0x40000000, static_cast<int>(0x80000040u), static_cast<int>(0xffffffffu)})
|
|
RequireFailure(pid, options, invalidArgument);
|
|
}
|
|
int status = untouched;
|
|
*__error_nid_postfix() = invalidArgument;
|
|
Require(wait_nid_postfix(&status) == -1);
|
|
Require(*__error_nid_postfix() == noChild);
|
|
Require(status == untouched);
|
|
*__error_nid_postfix() = invalidArgument;
|
|
Require(wait_nid_postfix(nullptr) == -1);
|
|
Require(*__error_nid_postfix() == noChild);
|
|
}
|