sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
main.cpp
1#include <cstdio>
2#include <cstring>
3
4extern "C" {
5#include <kernel.h>
6}
7
8#include <cstdio>
9#include <future>
10#include <thread>
11
12extern "C" int kputs(char *s);
13
14/* A program must never return from main on the rig: that reboots the console. */
15static int rig_failed;
16static int rig_kputs(char *s) {
17 if (strstr(s, ": FAIL")) rig_failed = 1;
18 return kputs(s);
19}
20#define kputs rig_kputs
21
22static int test_main() {
23 std::promise<int> prom;
24 std::future<int> fut = prom.get_future();
25
26 std::thread worker([&prom]() { prom.set_value(21 * 2); });
27
28 int result = fut.get();
29 worker.join();
30
31 if (result != 42) {
32 kputs((char *)"cxx-promise: FAIL wrong result\n");
33 return 1;
34 }
35
36 kputs((char *)"cxx-promise: PASS\n");
37 return 0;
38}
39
40int main() {
41 int result = test_main();
42 printf("[ps2rig] exit=%d\n", (result || rig_failed) ? 1 : 0);
43 SleepThread();
44 return 0;
45}