mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(libkernel): return EINVAL for unknown mutex attribute types
UFC 6 (PPSA23566) passes type 0 to pthread_mutexattr_settype during startup. libkernel rejects it with EINVAL and leaves the attribute unchanged, as fpPS4's decompiled body does, instead of aborting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "../include/Pthread.hpp"
|
||||
#include "../include/Mutex.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "prx/libkernel/Time/include/TimedWait.hpp"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
@@ -114,7 +115,7 @@ int APS5_VABI scePthreadMutexattrSettype(PthreadMutexattr* attr, int type) {
|
||||
case 2: (*attr)->type = MutexType::Recursive; break;
|
||||
case 3: (*attr)->type = MutexType::Normal; break;
|
||||
case 4: (*attr)->type = MutexType::Adaptive; break;
|
||||
default: throw std::invalid_argument("Invalid mutex type");
|
||||
default: return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ int main() {
|
||||
PthreadMutexattr attr = nullptr;
|
||||
Require(scePthreadMutexattrInit(&attr) == SCE_OK);
|
||||
Require(scePthreadMutexattrSettype(&attr, MUTEX_TYPE_ERRORCHECK) == SCE_OK);
|
||||
Require(scePthreadMutexattrSettype(&attr, 0) == SCE_KERNEL_ERROR_EINVAL);
|
||||
Require(scePthreadMutexattrSettype(&attr, 5) == SCE_KERNEL_ERROR_EINVAL);
|
||||
Require(scePthreadMutexattrSetprotocol(&attr, PRIO_NONE) == SCE_OK);
|
||||
Require(scePthreadMutexattrSetprotocol(&attr, PRIO_INHERIT) == SCE_OK);
|
||||
bool protectionRejected = false;
|
||||
|
||||
Reference in New Issue
Block a user