From afdc4702385dfa66ba20b46b98d81bd224c2d84e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 18 Mar 2026 13:11:57 +0100 Subject: [FEAT] PThread implementation improvements for v2. Signed-off-by: Amlal El Mahrouss --- src/kernel/src/Json.cpp | 3 ++- src/libMsg/src/Server.cpp | 6 ++++-- src/libPThread/src/Thread.cpp | 6 +++++- src/libSoundSystem/SoundSystemKit/VirtualMixer.h | 8 +++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/kernel/src/Json.cpp b/src/kernel/src/Json.cpp index 06e428e9..ca8b10d3 100644 --- a/src/kernel/src/Json.cpp +++ b/src/kernel/src/Json.cpp @@ -5,4 +5,5 @@ #include -namespace Kernel {} \ No newline at end of file +namespace Kernel {} + diff --git a/src/libMsg/src/Server.cpp b/src/libMsg/src/Server.cpp index e4602047..a2f17e91 100644 --- a/src/libMsg/src/Server.cpp +++ b/src/libMsg/src/Server.cpp @@ -23,13 +23,15 @@ IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head, VoidPtr arg, SizeT ar if (!head) return 0; - kSemaphore = SemCreate(1000, 1000, "libmsg_semaphore"); + static kSemWaitTime = 1000; + + kSemaphore = ::SemCreate(kSemWaitTime, kSemWaitTime, "libmsg_semaphore"); if (!kSemaphore) return 0; kFuncs[head->l_index](head, arg, arg_size); - SemClose(kSemaphore); + ::SemClose(kSemaphore); kSemaphore = nullptr; return 0; diff --git a/src/libPThread/src/Thread.cpp b/src/libPThread/src/Thread.cpp index b70cf7d6..c1799d9c 100644 --- a/src/libPThread/src/Thread.cpp +++ b/src/libPThread/src/Thread.cpp @@ -23,8 +23,10 @@ PTHREAD_SAFE SInt32 pthread_exit(SInt32 retval) { PTHREAD_SAFE SInt32 pthread_join(ThreadRef thread, VoidPtr* retval) { SInt32* ret = (SInt32*) retval; - *ret = ThrJoinThread(thread); + if (!ret) return -1; + + *ret = ThrJoinThread(thread); return 0; } @@ -32,6 +34,8 @@ PTHREAD_SAFE SInt32 pthread_create(_Output ThreadRef* thread, VoidPtr at VoidPtr (*start_routine)(VoidPtr), VoidPtr arg) { LIBSYS_UNUSED(attr); + if (!attr || !thread || !arg || !start_routine) return -1; + /// @note passing zero means you'd have to read the argv until you hit a nullptr. ThreadRef thrd = ThrCreateThread("pthread_thread", (ThrProcKind) start_routine, 0, arg, 0); diff --git a/src/libSoundSystem/SoundSystemKit/VirtualMixer.h b/src/libSoundSystem/SoundSystemKit/VirtualMixer.h index 69fa341a..4a46eb73 100644 --- a/src/libSoundSystem/SoundSystemKit/VirtualMixer.h +++ b/src/libSoundSystem/SoundSystemKit/VirtualMixer.h @@ -10,9 +10,11 @@ #include namespace SoundSystem { -struct VirtualMixer; -struct VirtualSource; -struct VirtualVolume; + + struct VirtualMixer; + struct VirtualSource; + struct VirtualVolume; + } // namespace SoundSystem #endif -- cgit v1.2.3