mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06: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;
|
ScePthreadMutexattr default_mutexattr = nullptr;
|
||||||
scePthreadMutexattrInit(&default_mutexattr);
|
scePthreadMutexattrInit(&default_mutexattr);
|
||||||
g_pthread_cxt->setDefaultMutexattr(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
|
// default cond init
|
||||||
ScePthreadCondattr default_condattr = nullptr;
|
ScePthreadCondattr default_condattr = nullptr;
|
||||||
scePthreadCondattrInit(&default_condattr);
|
scePthreadCondattrInit(&default_condattr);
|
||||||
|
@ -412,7 +416,8 @@ int PS4_SYSV_ABI scePthreadGetaffinity(ScePthread thread, /*SceKernelCpumask*/ u
|
||||||
}
|
}
|
||||||
|
|
||||||
ScePthreadMutex* createMutex(ScePthreadMutex* addr) {
|
ScePthreadMutex* createMutex(ScePthreadMutex* addr) {
|
||||||
if (addr == nullptr || *addr != nullptr) {
|
if (addr == nullptr ||
|
||||||
|
(*addr != nullptr && *addr != ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER)) {
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,15 +434,15 @@ int PS4_SYSV_ABI scePthreadMutexInit(ScePthreadMutex* mutex, const ScePthreadMut
|
||||||
if (mutex == nullptr) {
|
if (mutex == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return SCE_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (mutex_attr == nullptr) {
|
if (mutex_attr == nullptr || *mutex_attr == nullptr) {
|
||||||
attr = g_pthread_cxt->getDefaultMutexattr();
|
if (*mutex == ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER) {
|
||||||
|
attr = g_pthread_cxt->getAdaptiveMutexattr();
|
||||||
} else {
|
} else {
|
||||||
if (*mutex_attr == nullptr) {
|
|
||||||
attr = g_pthread_cxt->getDefaultMutexattr();
|
attr = g_pthread_cxt->getDefaultMutexattr();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
attr = mutex_attr;
|
attr = mutex_attr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*mutex = new PthreadMutexInternal{};
|
*mutex = new PthreadMutexInternal{};
|
||||||
if (name != nullptr) {
|
if (name != nullptr) {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
|
#define ORBIS_PTHREAD_MUTEX_ADAPTIVE_INITIALIZER (reinterpret_cast<ScePthreadMutex>(1))
|
||||||
|
|
||||||
namespace Core::Loader {
|
namespace Core::Loader {
|
||||||
class SymbolsResolver;
|
class SymbolsResolver;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,12 @@ public:
|
||||||
void setDefaultMutexattr(ScePthreadMutexattr attr) {
|
void setDefaultMutexattr(ScePthreadMutexattr attr) {
|
||||||
m_default_mutexattr = attr;
|
m_default_mutexattr = attr;
|
||||||
}
|
}
|
||||||
|
ScePthreadMutexattr* getAdaptiveMutexattr() {
|
||||||
|
return &m_adaptive_mutexattr;
|
||||||
|
}
|
||||||
|
void setAdaptiveMutexattr(ScePthreadMutexattr attr) {
|
||||||
|
m_adaptive_mutexattr = attr;
|
||||||
|
}
|
||||||
ScePthreadCondattr* getDefaultCondattr() {
|
ScePthreadCondattr* getDefaultCondattr() {
|
||||||
return &m_default_condattr;
|
return &m_default_condattr;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +169,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScePthreadMutexattr m_default_mutexattr = nullptr;
|
ScePthreadMutexattr m_default_mutexattr = nullptr;
|
||||||
|
ScePthreadMutexattr m_adaptive_mutexattr = nullptr;
|
||||||
ScePthreadCondattr m_default_condattr = nullptr;
|
ScePthreadCondattr m_default_condattr = nullptr;
|
||||||
ScePthreadAttr m_default_attr = nullptr;
|
ScePthreadAttr m_default_attr = nullptr;
|
||||||
PThreadPool* m_pthread_pool = nullptr;
|
PThreadPool* m_pthread_pool = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue