From 349b2aa2e14d3fc2ffadfe629870e6af8f4652f0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 26 Mar 2026 10:25:04 +0100 Subject: [FEAT] src/lib: System libraries fixes. Signed-off-by: Amlal El Mahrouss --- src/libMsg/.keep | 0 src/libMsg/src/Server.cpp | 16 ++++++++-------- src/libPOSIXWrapper/src/.keep | 0 src/libPThread/src/.keep | 0 src/libPThread/src/Thread.cpp | 11 ++++++----- 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 src/libMsg/.keep delete mode 100644 src/libPOSIXWrapper/src/.keep delete mode 100644 src/libPThread/src/.keep diff --git a/src/libMsg/.keep b/src/libMsg/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/libMsg/src/Server.cpp b/src/libMsg/src/Server.cpp index a2f17e91..ed043d0b 100644 --- a/src/libMsg/src/Server.cpp +++ b/src/libMsg/src/Server.cpp @@ -4,37 +4,37 @@ // Official repository: https://github.com/ne-foss-org/nekernel #include +#include static libmsg_func_type* kFuncs{nullptr}; static SizeT kFuncCnt{0}; static SemaphoreRef kSemaphore{nullptr}; IMPORT_C UInt32 libmsg_close_library(Void) { - if (kSemaphore) return 0; + if (kSemaphore) return kErrorInvalidData; kFuncs = nullptr; kFuncCnt = 0; - return 0; + return kErrorSuccess; } IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head, VoidPtr arg, SizeT arg_size) { - if (kSemaphore) return 0; + if (kSemaphore) return kErrorInvalidData; + if (!head) return kErrorInvalidData; - if (!head) return 0; - - static kSemWaitTime = 1000; + static auto kSemWaitTime = 1000; kSemaphore = ::SemCreate(kSemWaitTime, kSemWaitTime, "libmsg_semaphore"); - if (!kSemaphore) return 0; + if (!kSemaphore) return kErrorInvalidData; kFuncs[head->l_index](head, arg, arg_size); ::SemClose(kSemaphore); kSemaphore = nullptr; - return 0; + return kErrorSuccess; } IMPORT_C Void libmsg_init_library(libmsg_func_type* funcs, SizeT cnt) { diff --git a/src/libPOSIXWrapper/src/.keep b/src/libPOSIXWrapper/src/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/libPThread/src/.keep b/src/libPThread/src/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/libPThread/src/Thread.cpp b/src/libPThread/src/Thread.cpp index 5324d979..0d5052f2 100644 --- a/src/libPThread/src/Thread.cpp +++ b/src/libPThread/src/Thread.cpp @@ -4,6 +4,7 @@ // Official repository: https://github.com/ne-foss-org/nekernel #include +#include PTHREAD_SAFE SInt32 pthread_detach(ThreadRef thread) { return ThrDetachThread(thread); @@ -24,23 +25,23 @@ PTHREAD_SAFE SInt32 pthread_exit(SInt32 retval) { PTHREAD_SAFE SInt32 pthread_join(ThreadRef thread, VoidPtr* retval) { SInt32* ret = (SInt32*) retval; - if (!ret) return -1; + if (!ret) return kErrorInvalidData; *ret = ThrJoinThread(thread); - return 0; + return kErrorSuccess; } PTHREAD_SAFE SInt32 pthread_create(_Output ThreadRef* thread, VoidPtr attr, VoidPtr (*start_routine)(VoidPtr), VoidPtr arg) { LIBSYS_UNUSED(attr); - if (!attr || !thread || !arg || !start_routine) return -1; + if (!attr || !thread || !arg || !start_routine) return kErrorInvalidData; /// @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); - if (!thrd) return -1; + if (!thrd) return kErrorInvalidData; *thread = thrd; - return 0; + return kErrorSuccess; } -- cgit v1.2.3