scePthreadSetprio Changes

FindThread uses posix error codes, so the function export should apply the ORBIS wrapper to convert these. Since it uses posix codes, I've also renamed the function to align with other posix functions. Lastly, this fixes a compile warning about ret sometimes not getting initialized.
This commit is contained in:
Stephen Miller 2024-11-26 22:28:21 -06:00
parent 18a36c5daa
commit 2deab1590e

View File

@ -421,29 +421,27 @@ int PS4_SYSV_ABI scePthreadGetprio(PthreadT thread, int* priority) {
return 0; return 0;
} }
int PS4_SYSV_ABI scePthreadSetprio(PthreadT thread, int prio) { int PS4_SYSV_ABI posix_pthread_setprio(PthreadT thread, int prio) {
SchedParam param; SchedParam param;
int ret;
param.sched_priority = prio; param.sched_priority = prio;
auto* thread_state = ThrState::Instance(); auto* thread_state = ThrState::Instance();
if (thread == g_curthread) { if (thread == g_curthread) {
g_curthread->lock.lock(); g_curthread->lock.lock();
} else if (int ret = thread_state->FindThread(thread, /*include dead*/ 0)) { } else if (int ret = thread_state->FindThread(thread, /*include dead*/ 0); ret != 0) {
return ret; return ret;
} }
if (thread->attr.sched_policy == SchedPolicy::Other || thread->attr.prio == prio) { if (thread->attr.sched_policy == SchedPolicy::Other || thread->attr.prio == prio) {
thread->attr.prio = prio; thread->attr.prio = prio;
ret = 0;
} else { } else {
// TODO: _thr_setscheduler // TODO: _thr_setscheduler
thread->attr.prio = prio; thread->attr.prio = prio;
} }
thread->lock.unlock(); thread->lock.unlock();
return ret; return 0;
} }
enum class PthreadCancelState : u32 { enum class PthreadCancelState : u32 {
@ -517,7 +515,7 @@ void RegisterThread(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, posix_pthread_yield); LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, posix_pthread_yield);
LIB_FUNCTION("EI-5-jlq2dE", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getthreadid_np); LIB_FUNCTION("EI-5-jlq2dE", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getthreadid_np);
LIB_FUNCTION("1tKyG7RlMJo", "libkernel", 1, "libkernel", 1, 1, scePthreadGetprio); LIB_FUNCTION("1tKyG7RlMJo", "libkernel", 1, "libkernel", 1, 1, scePthreadGetprio);
LIB_FUNCTION("W0Hpm2X0uPE", "libkernel", 1, "libkernel", 1, 1, scePthreadSetprio); LIB_FUNCTION("W0Hpm2X0uPE", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_setprio));
LIB_FUNCTION("rNhWz+lvOMU", "libkernel", 1, "libkernel", 1, 1, _sceKernelSetThreadDtors); LIB_FUNCTION("rNhWz+lvOMU", "libkernel", 1, "libkernel", 1, 1, _sceKernelSetThreadDtors);
LIB_FUNCTION("6XG4B33N09g", "libkernel", 1, "libkernel", 1, 1, sched_yield); LIB_FUNCTION("6XG4B33N09g", "libkernel", 1, "libkernel", 1, 1, sched_yield);
} }