mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 02:26:07 +00:00
Added adaptive mutex initializer handling (#1353)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
This commit is contained in:
parent
1cc4ab7e88
commit
8776eba8c8
|
@ -36,6 +36,10 @@ void init_pthreads() {
|
|||
ScePthreadMutexattr default_mutexattr = nullptr;
|
||||
scePthreadMutexattrInit(&default_mutexattr);
|
||||
g_pthread_cxt->setDefaultMutexattr(default_mutexattr);
|
||||
ScePthreadMutexattr adaptive_mutexattr = nullptr;
|
||||
scePthreadMutexattrInit(&adaptive_mutexattr);
|
||||
scePthreadMutexattrSettype(&adaptive_mutexattr, ORBIS_PTHREAD_MUTEX_ADAPTIVE);
|
||||
g_pthread_cxt->setAdaptiveMutexattr(adaptive_mutexattr);
|
||||
// default cond init
|
||||
ScePthreadCondattr default_condattr = nullptr;
|
||||
scePthreadCondattrInit(&default_condattr);
|
||||
|
@ -412,7 +416,8 @@ int PS4_SYSV_ABI scePthreadGetaffinity(ScePthread thread, /*SceKernelCpumask*/ u
|
|||
}
|
||||
|
||||
ScePthreadMutex* createMutex(ScePthreadMutex* addr) {
|
||||
if (addr == nullptr || *addr != nullptr) {
|
||||
if (addr == nullptr ||
|
||||
(*addr != nullptr && *addr != ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER)) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
@ -429,14 +434,14 @@ int PS4_SYSV_ABI scePthreadMutexInit(ScePthreadMutex* mutex, const ScePthreadMut
|
|||
if (mutex == nullptr) {
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
if (mutex_attr == nullptr) {
|
||||
attr = g_pthread_cxt->getDefaultMutexattr();
|
||||
} else {
|
||||
if (*mutex_attr == nullptr) {
|
||||
attr = g_pthread_cxt->getDefaultMutexattr();
|
||||
if (mutex_attr == nullptr || *mutex_attr == nullptr) {
|
||||
if (*mutex == ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER) {
|
||||
attr = g_pthread_cxt->getAdaptiveMutexattr();
|
||||
} else {
|
||||
attr = mutex_attr;
|
||||
attr = g_pthread_cxt->getDefaultMutexattr();
|
||||
}
|
||||
} else {
|
||||
attr = mutex_attr;
|
||||
}
|
||||
|
||||
*mutex = new PthreadMutexInternal{};
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "common/types.h"
|
||||
|
||||
#define ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER (reinterpret_cast<ScePthreadMutex>(1))
|
||||
|
||||
namespace Core::Loader {
|
||||
class SymbolsResolver;
|
||||
}
|
||||
|
@ -134,6 +136,12 @@ public:
|
|||
void setDefaultMutexattr(ScePthreadMutexattr attr) {
|
||||
m_default_mutexattr = attr;
|
||||
}
|
||||
ScePthreadMutexattr* getAdaptiveMutexattr() {
|
||||
return &m_adaptive_mutexattr;
|
||||
}
|
||||
void setAdaptiveMutexattr(ScePthreadMutexattr attr) {
|
||||
m_adaptive_mutexattr = attr;
|
||||
}
|
||||
ScePthreadCondattr* getDefaultCondattr() {
|
||||
return &m_default_condattr;
|
||||
}
|
||||
|
@ -161,6 +169,7 @@ public:
|
|||
|
||||
private:
|
||||
ScePthreadMutexattr m_default_mutexattr = nullptr;
|
||||
ScePthreadMutexattr m_adaptive_mutexattr = nullptr;
|
||||
ScePthreadCondattr m_default_condattr = nullptr;
|
||||
ScePthreadAttr m_default_attr = nullptr;
|
||||
PThreadPool* m_pthread_pool = nullptr;
|
||||
|
|
Loading…
Reference in a new issue