libraries: kernel: fix `scePthreadMutexattrSettype` error value return

This commit is contained in:
psucien 2024-08-27 22:24:26 +02:00
parent 371d1d009a
commit 3eb47226d9
2 changed files with 12 additions and 6 deletions

View File

@ -510,23 +510,24 @@ int PS4_SYSV_ABI scePthreadMutexattrInit(ScePthreadMutexattr* attr) {
int PS4_SYSV_ABI scePthreadMutexattrSettype(ScePthreadMutexattr* attr, int type) { int PS4_SYSV_ABI scePthreadMutexattrSettype(ScePthreadMutexattr* attr, int type) {
int ptype = PTHREAD_MUTEX_DEFAULT; int ptype = PTHREAD_MUTEX_DEFAULT;
switch (type) { switch (type) {
case 1: case ORBIS_PTHREAD_MUTEX_ERRORCHECK:
ptype = PTHREAD_MUTEX_ERRORCHECK; ptype = PTHREAD_MUTEX_ERRORCHECK;
break; break;
case 2: case ORBIS_PTHREAD_MUTEX_RECURSIVE:
ptype = PTHREAD_MUTEX_RECURSIVE; ptype = PTHREAD_MUTEX_RECURSIVE;
break; break;
case 3: case ORBIS_PTHREAD_MUTEX_NORMAL:
case 4: case ORBIS_PTHREAD_MUTEX_ADAPTIVE:
ptype = PTHREAD_MUTEX_NORMAL; ptype = PTHREAD_MUTEX_NORMAL;
break; break;
default: default:
UNREACHABLE_MSG("Invalid type: {}", type); return SCE_KERNEL_ERROR_EINVAL;
} }
int result = pthread_mutexattr_settype(&(*attr)->pth_mutex_attr, ptype); int result = pthread_mutexattr_settype(&(*attr)->pth_mutex_attr, ptype);
ASSERT(result == 0);
return result == 0 ? SCE_OK : SCE_KERNEL_ERROR_EINVAL; return SCE_OK;
} }
int PS4_SYSV_ABI scePthreadMutexattrSetprotocol(ScePthreadMutexattr* attr, int protocol) { int PS4_SYSV_ABI scePthreadMutexattrSetprotocol(ScePthreadMutexattr* attr, int protocol) {

View File

@ -20,6 +20,11 @@ constexpr int ORBIS_KERNEL_PRIO_FIFO_DEFAULT = 700;
constexpr int ORBIS_KERNEL_PRIO_FIFO_HIGHEST = 256; constexpr int ORBIS_KERNEL_PRIO_FIFO_HIGHEST = 256;
constexpr int ORBIS_KERNEL_PRIO_FIFO_LOWEST = 767; constexpr int ORBIS_KERNEL_PRIO_FIFO_LOWEST = 767;
constexpr int ORBIS_PTHREAD_MUTEX_ERRORCHECK = 1;
constexpr int ORBIS_PTHREAD_MUTEX_RECURSIVE = 2;
constexpr int ORBIS_PTHREAD_MUTEX_NORMAL = 3;
constexpr int ORBIS_PTHREAD_MUTEX_ADAPTIVE = 4;
struct PthreadInternal; struct PthreadInternal;
struct PthreadAttrInternal; struct PthreadAttrInternal;
struct PthreadMutexInternal; struct PthreadMutexInternal;