Merge pull request #171 from asimplestray/feat/kernel-time-signal
feat(kernel): implement Sleep, sigprocmask and pthread finalize
This commit is contained in:
commit
95f34bed3d
|
|
@ -444,8 +444,7 @@ int APS5_VABI scePthreadOnce(int32_t* once, void (APS5_VABI* init)(void)) {
|
|||
extern "C" {
|
||||
|
||||
void APS5_VABI __pthread_cxa_finalize_nid_postfix(void* argument) {
|
||||
(void)argument;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
CxaFinalize_nid_no_patch(argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,12 +74,4 @@ int APS5_VABI select_nid_postfix(int nfds, void* readfds, void* writefds, void*
|
|||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sigprocmask_nid_postfix(int how, const void* set, void* oset) {
|
||||
(void)how;
|
||||
(void)set;
|
||||
(void)oset;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ int APS5_VABI _sigprocmask_nid_postfix(int how, const GuestSignalSet* set, Guest
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sigprocmask_nid_postfix(int how, const void* set, void* previousSet) {
|
||||
return _sigprocmask_nid_postfix(how, static_cast<const GuestSignalSet*>(set),
|
||||
static_cast<GuestSignalSet*>(previousSet));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -481,9 +481,8 @@ uint64_t APS5_VABI sceKernelGetTscFrequency(void) {
|
|||
}
|
||||
|
||||
unsigned int APS5_VABI sceKernelSleep(unsigned int seconds) {
|
||||
(void)seconds;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
TimedWait::SleepNanos(static_cast<std::uint64_t>(seconds) * 1000000000ULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,14 @@ int APS5_VABI scePthreadMutexUnlock(PthreadMutex* mutex);
|
|||
int APS5_VABI scePthreadCondInit(PthreadCond* cond, const PthreadCondattr* attr, const char* name);
|
||||
int APS5_VABI scePthreadCondDestroy(PthreadCond* cond);
|
||||
int APS5_VABI scePthreadCondTimedwait(PthreadCond* cond, PthreadMutex* mutex, unsigned int usec);
|
||||
int APS5_VABI __cxa_atexit_nid_postfix(void (APS5_VABI *)(void*), void*, void*);
|
||||
void APS5_VABI __pthread_cxa_finalize_nid_postfix(void*);
|
||||
unsigned int APS5_VABI sceKernelSleep(unsigned int seconds);
|
||||
}
|
||||
|
||||
static int cleanupAt = -1;
|
||||
static void APS5_VABI Cleanup(void*) { cleanupAt = 0; }
|
||||
|
||||
static constexpr int SCE_OK = 0;
|
||||
static constexpr int SCE_KERNEL_ERROR_ETIMEDOUT = static_cast<int>(0x8002003C);
|
||||
|
||||
|
|
@ -49,4 +55,10 @@ int main() {
|
|||
|
||||
Require(scePthreadCondDestroy(&cond) == SCE_OK);
|
||||
Require(scePthreadMutexDestroy(&context.mutex) == SCE_OK);
|
||||
|
||||
Require(sceKernelSleep(0) == SCE_OK);
|
||||
void* finalizeHandle = reinterpret_cast<void*>(7);
|
||||
Require(__cxa_atexit_nid_postfix(Cleanup, nullptr, finalizeHandle) == SCE_OK);
|
||||
__pthread_cxa_finalize_nid_postfix(finalizeHandle);
|
||||
Require(cleanupAt == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,12 @@ using Handler = void (APS5_VABI *)(int);
|
|||
extern "C" {
|
||||
Handler APS5_VABI signal_nid_postfix(int, Handler);
|
||||
int APS5_VABI raise_nid_postfix(int);
|
||||
int APS5_VABI sigprocmask_nid_postfix(int, const void*, void*);
|
||||
int* APS5_VABI __error_nid_postfix();
|
||||
}
|
||||
struct GuestSignalSet {
|
||||
std::uint32_t bits[4];
|
||||
};
|
||||
volatile std::sig_atomic_t received = 0;
|
||||
void APS5_VABI Callback(int value) { received = value; }
|
||||
static void Require(bool value) { if (!value) std::abort(); }
|
||||
|
|
@ -25,4 +29,13 @@ int main() {
|
|||
Require(raise_nid_postfix(15) == 0 && received == 0);
|
||||
Require(signal_nid_postfix(15, nullptr) == ignore);
|
||||
Require(raise_nid_postfix(100) == -1 && *__error_nid_postfix() == 22);
|
||||
GuestSignalSet blocked{{0x20, 0, 0, 0}};
|
||||
GuestSignalSet previous{{}};
|
||||
Require(sigprocmask_nid_postfix(3, &blocked, &previous) == 0);
|
||||
Require(previous.bits[0] == 0);
|
||||
Require(sigprocmask_nid_postfix(1, nullptr, &previous) == 0);
|
||||
Require(previous.bits[0] == 0x20);
|
||||
Require(sigprocmask_nid_postfix(2, &blocked, nullptr) == 0);
|
||||
Require(sigprocmask_nid_postfix(1, nullptr, &previous) == 0);
|
||||
Require(previous.bits[0] == 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue