mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 03:24:49 +00:00
some thread function calls
This commit is contained in:
parent
b7c7934e2a
commit
f4afe2490a
2 changed files with 49 additions and 7 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Core::Libraries::LibKernel {
|
||||
|
||||
thread_local PthreadInternal g_pthread_self{};
|
||||
thread_local ScePthread g_pthread_self{};
|
||||
PThreadCxt* g_pthread_cxt = nullptr;
|
||||
|
||||
constexpr bool log_pthread_file = true; // disable it to disable logging
|
||||
|
@ -21,9 +21,10 @@ void init_pthreads() {
|
|||
}
|
||||
|
||||
void pthreadInitSelfMainThread() {
|
||||
scePthreadAttrInit(&g_pthread_self.attr);
|
||||
g_pthread_self.pth = pthread_self();
|
||||
g_pthread_self.name = "Main_Thread";
|
||||
g_pthread_self = new PthreadInternal{};
|
||||
scePthreadAttrInit(&g_pthread_self->attr);
|
||||
g_pthread_self->pth = pthread_self();
|
||||
g_pthread_self->name = "Main_Thread";
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePthreadAttrInit(ScePthreadAttr* attr) {
|
||||
|
@ -119,7 +120,35 @@ int PS4_SYSV_ABI scePthreadAttrSetschedpolicy(ScePthreadAttr* attr, int policy)
|
|||
|
||||
return result == 0 ? SCE_OK : SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
ScePthread PS4_SYSV_ABI scePthreadSelf() { return g_pthread_self; }
|
||||
|
||||
int PS4_SYSV_ABI scePthreadAttrSetaffinity(ScePthreadAttr* pattr, const /*SceKernelCpumask*/ u64 mask) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
|
||||
if (pattr == nullptr || *pattr == nullptr) {
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
|
||||
(*pattr)->affinity = mask;
|
||||
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePthreadSetaffinity(ScePthread thread, const /*SceKernelCpumask*/ u64 mask) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
|
||||
if (thread == nullptr) {
|
||||
return SCE_KERNEL_ERROR_ESRCH;
|
||||
}
|
||||
|
||||
auto result = scePthreadAttrSetaffinity(&thread->attr, mask);
|
||||
|
||||
return result;
|
||||
}
|
||||
int PS4_SYSV_ABI scePthreadCreate(ScePthread* thread, const ScePthreadAttr* attr, pthreadEntryFunc start_routine, void* arg, const char* name) {
|
||||
PRINT_DUMMY_FUNCTION_NAME();
|
||||
return 0;
|
||||
}
|
||||
/****
|
||||
* Mutex calls
|
||||
*/
|
||||
|
@ -287,6 +316,11 @@ void pthreadSymbolsRegister(Loader::SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("nsYoNRywwNg", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrInit);
|
||||
LIB_FUNCTION("9UK1vLZQft4", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexLock);
|
||||
LIB_FUNCTION("tn3VlD0hG60", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexUnlock);
|
||||
LIB_FUNCTION("aI+OeCz8xrQ", "libkernel", 1, "libkernel", 1, 1, scePthreadSelf);
|
||||
LIB_FUNCTION("3qxgM4ezETA", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetaffinity);
|
||||
LIB_FUNCTION("bt3CTBKmGyI", "libkernel", 1, "libkernel", 1, 1, scePthreadSetaffinity);
|
||||
LIB_FUNCTION("6UgtwV+0zb4", "libkernel", 1, "libkernel", 1, 1, scePthreadCreate);
|
||||
|
||||
// posix calls
|
||||
LIB_FUNCTION("ttHNfU+qDBU", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_init);
|
||||
LIB_FUNCTION("7H0iTOciTLo", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutex_lock);
|
||||
|
|
|
@ -17,12 +17,16 @@ namespace Core::Libraries::LibKernel {
|
|||
struct PthreadAttrInternal;
|
||||
struct PthreadMutexInternal;
|
||||
struct PthreadMutexattrInternal;
|
||||
struct PthreadInternal;
|
||||
|
||||
using SceKernelSchedParam = ::sched_param;
|
||||
using ScePthread = PthreadInternal*;
|
||||
using ScePthreadAttr = PthreadAttrInternal*;
|
||||
using ScePthreadMutex = PthreadMutexInternal*;
|
||||
using ScePthreadMutexattr = PthreadMutexattrInternal*;
|
||||
|
||||
using pthreadEntryFunc = PS4_SYSV_ABI void* (*)(void*);
|
||||
|
||||
struct PthreadInternal {
|
||||
u08 reserved[4096];
|
||||
std::string name;
|
||||
|
@ -68,10 +72,14 @@ int PS4_SYSV_ABI scePthreadAttrSetdetachstate(ScePthreadAttr* attr, int detachst
|
|||
int PS4_SYSV_ABI scePthreadAttrSetinheritsched(ScePthreadAttr* attr, int inheritSched);
|
||||
int PS4_SYSV_ABI scePthreadAttrSetschedparam(ScePthreadAttr* attr, const SceKernelSchedParam* param);
|
||||
int PS4_SYSV_ABI scePthreadAttrSetschedpolicy(ScePthreadAttr* attr, int policy);
|
||||
|
||||
ScePthread PS4_SYSV_ABI scePthreadSelf();
|
||||
int PS4_SYSV_ABI scePthreadAttrSetaffinity(ScePthreadAttr* pattr, const /*SceKernelCpumask*/ u64 mask);
|
||||
int PS4_SYSV_ABI scePthreadSetaffinity(ScePthread thread, const /*SceKernelCpumask*/ u64 mask);
|
||||
int PS4_SYSV_ABI scePthreadCreate(ScePthread* thread, const ScePthreadAttr* attr, pthreadEntryFunc start_routine, void* arg, const char* name);
|
||||
|
||||
/***
|
||||
* Mutex calls
|
||||
*/
|
||||
* Mutex calls
|
||||
*/
|
||||
int PS4_SYSV_ABI scePthreadMutexInit(ScePthreadMutex* mutex, const ScePthreadMutexattr* attr, const char* name);
|
||||
int PS4_SYSV_ABI scePthreadMutexattrInit(ScePthreadMutexattr* attr);
|
||||
int PS4_SYSV_ABI scePthreadMutexattrSettype(ScePthreadMutexattr* attr, int type);
|
||||
|
|
Loading…
Add table
Reference in a new issue