This repository was archived by the owner on Oct 28, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathCond.cpp
More file actions
67 lines (52 loc) · 2.24 KB
/
Copy pathCond.cpp
File metadata and controls
67 lines (52 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "prx/libkernel/Pthread/include/Pthread.hpp"
#include "prx/libkernel/Pthread/include/Cond.hpp"
#include "Common.hpp"
#include <cstdint>
#include <stdexcept>
namespace {
int toPosix(int result) {
if (result == 0)
return 0;
const auto error = static_cast<std::uint32_t>(result);
if ((error & 0xffff0000u) != 0x80020000u)
throw std::runtime_error("Unexpected SCE condition variable error");
return static_cast<int>(error & 0xffffu);
}
}
extern "C" {
int APS5_VABI pthread_cond_destroy_nid_postfix(PthreadCond* cond) {
if (!cond) return PosixThread::GUEST_EINVAL;
return toPosix(scePthreadCondDestroy(cond));
}
int APS5_VABI pthread_cond_broadcast_nid_postfix(PthreadCond* cond) {
return toPosix(scePthreadCondBroadcast(cond));
}
int APS5_VABI pthread_cond_init_nid_postfix(PthreadCond* cond, const PthreadCondattr* attr) {
return toPosix(scePthreadCondInit(cond, attr, nullptr));
}
int APS5_VABI pthread_cond_signal_nid_postfix(PthreadCond* cond) {
return toPosix(scePthreadCondSignal(cond));
}
int APS5_VABI pthread_cond_timedwait_nid_postfix(PthreadCond* cond, PthreadMutex* mutex, const KernelTimespec* abstime) {
if (!abstime || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) return PosixThread::GUEST_EINVAL;
return toPosix(CondOperations::AbsoluteTimedwait(cond, mutex, abstime));
}
int APS5_VABI pthread_cond_reltimedwait_np_nid_postfix(PthreadCond* cond, PthreadMutex* mutex, KernelUseconds usec) {
return toPosix(scePthreadCondTimedwait(cond, mutex, usec));
}
int APS5_VABI pthread_cond_wait_nid_postfix(PthreadCond* cond, PthreadMutex* mutex) {
return toPosix(scePthreadCondWait(cond, mutex));
}
int APS5_VABI pthread_condattr_destroy_nid_postfix(PthreadCondattr* attr) {
if (!attr || !*attr) return PosixThread::GUEST_EINVAL;
return toPosix(scePthreadCondattrDestroy(attr));
}
int APS5_VABI pthread_condattr_init_nid_postfix(PthreadCondattr* attr) {
if (!attr) return PosixThread::GUEST_EINVAL;
return toPosix(scePthreadCondattrInit(attr));
}
int APS5_VABI pthread_condattr_setclock_nid_postfix(PthreadCondattr* attr, KernelClockid clock_id) {
if (!attr || !*attr) return PosixThread::GUEST_EINVAL;
return toPosix(scePthreadCondattrSetclock(attr, clock_id));
}
}