mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-30 01:01:21 +00:00
kernel: destroy untouched static rwlocks without allocation
This commit is contained in:
1 parent
97bef2992f
commit
4592e4c178
2 files changed
+16
-1
No files matched your search
@@ -2277,7 +2277,10 @@ int KYTY_SYSV_ABI PthreadRwlockDestroy(PthreadRwlock* rwlock) {
|
|||||||
return KERNEL_ERROR_EINVAL;
|
return KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT_NOT_IMPLEMENTED(*rwlock == nullptr);
|
// SCE_PTHREAD_RWLOCK_INITIALIZER has no allocated resources until first use.
|
||||||
|
if (*rwlock == nullptr) {
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard lock((*rwlock)->m);
|
std::lock_guard lock((*rwlock)->m);
|
||||||
|
|||||||
@@ -101,6 +101,17 @@ void WaitForMutexTest(Predicate ready) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestStaticRwlockDestroy() {
|
||||||
|
using namespace Libs::LibKernel;
|
||||||
|
PthreadRwlock rwlock = nullptr;
|
||||||
|
Check(PthreadRwlockDestroy(nullptr) == KERNEL_ERROR_EINVAL &&
|
||||||
|
PthreadRwlockDestroy(&rwlock) == OK && rwlock == nullptr,
|
||||||
|
"destroy an untouched static rwlock without allocating it");
|
||||||
|
Check(PthreadRwlockRdlock(&rwlock) == OK && PthreadRwlockUnlock(&rwlock) == OK &&
|
||||||
|
PthreadRwlockDestroy(&rwlock) == OK,
|
||||||
|
"static rwlock remains usable after destroying its untouched initializer");
|
||||||
|
}
|
||||||
|
|
||||||
struct MutexWaiter {
|
struct MutexWaiter {
|
||||||
Libs::LibKernel::PthreadMutex *mutex;
|
Libs::LibKernel::PthreadMutex *mutex;
|
||||||
Libs::LibKernel::KernelUseconds timeout = 0;
|
Libs::LibKernel::KernelUseconds timeout = 0;
|
||||||
@@ -2723,6 +2734,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestMutexHandoff();
|
TestMutexHandoff();
|
||||||
|
TestStaticRwlockDestroy();
|
||||||
if (argc == 2 && std::string_view(argv[1]) == "--mutex-only") {
|
if (argc == 2 && std::string_view(argv[1]) == "--mutex-only") {
|
||||||
subsystems.Destroy();
|
subsystems.Destroy();
|
||||||
std::printf("KernelFileSystemTests: mutex cases passed\n");
|
std::printf("KernelFileSystemTests: mutex cases passed\n");
|
||||||
|
|||||||
Reference in new issue
Block a user