From b82993c56805245fc75742a3e0a72db770cdf054 Mon Sep 17 00:00:00 2001 From: "Daniel R." <47796739+polybiusproxy@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:12:35 +0100 Subject: [PATCH] core/kernel: implement condvar signalto --- src/core/libraries/kernel/threads/condvar.cpp | 15 ++++++++++++--- src/core/libraries/kernel/threads/pthread.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/libraries/kernel/threads/condvar.cpp b/src/core/libraries/kernel/threads/condvar.cpp index 2927899d9..853526559 100644 --- a/src/core/libraries/kernel/threads/condvar.cpp +++ b/src/core/libraries/kernel/threads/condvar.cpp @@ -177,7 +177,7 @@ int PS4_SYSV_ABI posix_pthread_cond_reltimedwait_np(PthreadCondT* cond, PthreadM return cvp->Wait(mutex, THR_RELTIME, usec); } -int PthreadCond::Signal() { +int PthreadCond::Signal(Pthread* thread) { Pthread* curthread = g_curthread; SleepqLock(this); @@ -187,7 +187,8 @@ int PthreadCond::Signal() { return 0; } - Pthread* td = sq->sq_blocked.front(); + Pthread* td = thread ? thread : sq->sq_blocked.front(); + PthreadMutex* mp = td->mutex_obj; has_user_waiters = SleepqRemove(sq, td); @@ -262,7 +263,13 @@ int PthreadCond::Broadcast() { int PS4_SYSV_ABI posix_pthread_cond_signal(PthreadCondT* cond) { PthreadCond* cvp{}; CHECK_AND_INIT_COND - return cvp->Signal(); + return cvp->Signal(nullptr); +} + +int PS4_SYSV_ABI posix_pthread_cond_signalto_np(PthreadCondT* cond, Pthread* thread) { + PthreadCond* cvp{}; + CHECK_AND_INIT_COND + return cvp->Signal(thread); } int PS4_SYSV_ABI posix_pthread_cond_broadcast(PthreadCondT* cond) { @@ -358,6 +365,8 @@ void RegisterCond(Core::Loader::SymbolsResolver* sym) { ORBIS(posix_pthread_cond_reltimedwait_np)); LIB_FUNCTION("g+PZd2hiacg", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_cond_destroy)); + LIB_FUNCTION("o69RpYO-Mu0", "libkernel", 1, "libkernel", 1, 1, + ORBIS(posix_pthread_cond_signalto_np)); } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/threads/pthread.h b/src/core/libraries/kernel/threads/pthread.h index 456c2ef37..089156776 100644 --- a/src/core/libraries/kernel/threads/pthread.h +++ b/src/core/libraries/kernel/threads/pthread.h @@ -123,7 +123,7 @@ struct PthreadCond { int Wait(PthreadMutexT* mutex, const OrbisKernelTimespec* abstime, u64 usec = 0); - int Signal(); + int Signal(Pthread* thread); int Broadcast(); }; using PthreadCondT = PthreadCond*;