From ef3341c78c7ce59478d2e780856f9cd7ffbb94ce Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Thu, 24 Oct 2024 00:39:36 +0300 Subject: [PATCH] kernel: Add missing funcs --- src/core/libraries/kernel/threads.cpp | 1 + src/core/libraries/kernel/threads/pthread.cpp | 1 + src/core/libraries/kernel/threads/pthread.h | 1 + .../libraries/kernel/threads/pthread_clean.cpp | 16 +++++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/kernel/threads.cpp b/src/core/libraries/kernel/threads.cpp index 3c617d2f..082a52b6 100644 --- a/src/core/libraries/kernel/threads.cpp +++ b/src/core/libraries/kernel/threads.cpp @@ -16,6 +16,7 @@ void RegisterThreads(Core::Loader::SymbolsResolver* sym) { RegisterThreadAttr(sym); RegisterThread(sym); RegisterRtld(sym); + RegisterPthreadClean(sym); } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/threads/pthread.cpp b/src/core/libraries/kernel/threads/pthread.cpp index 7791d86c..a97502ea 100644 --- a/src/core/libraries/kernel/threads/pthread.cpp +++ b/src/core/libraries/kernel/threads/pthread.cpp @@ -432,6 +432,7 @@ void RegisterThread(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("EotR8a3ASf4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_self); LIB_FUNCTION("B5GmVDKwpn0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_yield); LIB_FUNCTION("+U1R4WtXvoc", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_detach); + LIB_FUNCTION("FJrT5LuUBAU", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_exit); LIB_FUNCTION("h9CcP3J0oVM", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_join); LIB_FUNCTION("OxhIB8LB-PQ", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create); LIB_FUNCTION("Jmi+9w9u0E4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_create_name_np); diff --git a/src/core/libraries/kernel/threads/pthread.h b/src/core/libraries/kernel/threads/pthread.h index 9cb89dfe..323c288b 100644 --- a/src/core/libraries/kernel/threads/pthread.h +++ b/src/core/libraries/kernel/threads/pthread.h @@ -327,5 +327,6 @@ void RegisterThreadAttr(Core::Loader::SymbolsResolver* sym); void RegisterThread(Core::Loader::SymbolsResolver* sym); void RegisterRtld(Core::Loader::SymbolsResolver* sym); void RegisterKernelEventFlag(Core::Loader::SymbolsResolver* sym); +void RegisterPthreadClean(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/threads/pthread_clean.cpp b/src/core/libraries/kernel/threads/pthread_clean.cpp index 86d73c80..da5df0dc 100644 --- a/src/core/libraries/kernel/threads/pthread_clean.cpp +++ b/src/core/libraries/kernel/threads/pthread_clean.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/libraries/kernel/threads/pthread.h" +#include "core/libraries/libs.h" namespace Libraries::Kernel { -void __pthread_cleanup_push_imp(PthreadCleanupFunc routine, void* arg, PthreadCleanup* newbuf) { - Pthread* curthread = g_curthread; +void PS4_SYSV_ABI __pthread_cleanup_push_imp(PthreadCleanupFunc routine, void* arg, PthreadCleanup* newbuf) { newbuf->routine = routine; newbuf->routine_arg = arg; newbuf->onheap = 0; - curthread->cleanup.push_front(newbuf); + g_curthread->cleanup.push_front(newbuf); } void PS4_SYSV_ABI posix_pthread_cleanup_push(PthreadCleanupFunc routine, void* arg) { @@ -40,4 +40,14 @@ void PS4_SYSV_ABI posix_pthread_cleanup_pop(int execute) { } } +void RegisterPthreadClean(Core::Loader::SymbolsResolver* sym) { + // Posix + LIB_FUNCTION("4ZeZWcMsAV0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cleanup_push); + LIB_FUNCTION("RVxb0Ssa5t0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cleanup_pop); + + // Posix-Kernel + LIB_FUNCTION("1xvtUVx1-Sg", "libkernel", 1, "libkernel", 1, 1, __pthread_cleanup_push_imp); + LIB_FUNCTION("iWsFlYMf3Kw", "libkernel", 1, "libkernel", 1, 1, posix_pthread_cleanup_pop); +} + } // namespace Libraries::Kernel