diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-23 09:44:36 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-23 09:44:36 +0100 |
| commit | 9392f90f768fefb01b555caeb4211ba3e074a743 (patch) | |
| tree | 3abc3848792ed1b58b1154df48eefbefd9bffe88 | |
| parent | 8c317ab239e71233de0d8783408b39fbd402d456 (diff) | |
[FEAT] Improve libThread with additional ThrExitThread function, X11 and al versioning.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | .github/pull_request_template.md | 9 | ||||
| -rw-r--r-- | doc/requirements/__ne_arch.md | 3 | ||||
| -rw-r--r-- | frameworks/libThread.fwrk/headers/Config.h | 2 | ||||
| -rw-r--r-- | frameworks/libThread.fwrk/src/ThreadMgr.cpp | 25 | ||||
| -rw-r--r-- | frameworks/libX11.fwrk/headers/Config.h | 2 |
5 files changed, 35 insertions, 6 deletions
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a0446d7..f32259d 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,12 @@ +--- +name: Feature PR +about: Create a feature PR to help us improve the project. +title: '' +labels: 'feature' +assignees: '' + +--- + # [PR] <Title of PR> <Describe briefly your PR here.> diff --git a/doc/requirements/__ne_arch.md b/doc/requirements/__ne_arch.md index 1fb45e2..d532d0c 100644 --- a/doc/requirements/__ne_arch.md +++ b/doc/requirements/__ne_arch.md @@ -6,3 +6,6 @@ The `__ne_arch` macro takes care of reporting NeSystem's running ISA+Computer_Ar You use this for platform specific code. Recommended for C/C++ programs, JVM and VM based languages should not rely on this macro. +## Introduced: + +- NeSystem v0.1.5 diff --git a/frameworks/libThread.fwrk/headers/Config.h b/frameworks/libThread.fwrk/headers/Config.h index c6734a4..f69f0f5 100644 --- a/frameworks/libThread.fwrk/headers/Config.h +++ b/frameworks/libThread.fwrk/headers/Config.h @@ -8,4 +8,6 @@ #include <libSystem/SystemKit/System.h> +#define LIBTHREAD_VERSION 0x100000 + #endif // LIBTHREAD_FOUNDATION_H diff --git a/frameworks/libThread.fwrk/src/ThreadMgr.cpp b/frameworks/libThread.fwrk/src/ThreadMgr.cpp index 7361f86..6a7843f 100644 --- a/frameworks/libThread.fwrk/src/ThreadMgr.cpp +++ b/frameworks/libThread.fwrk/src/ThreadMgr.cpp @@ -3,6 +3,7 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/ne_system +#include <libSystem/SystemKit/Err.h> #include <libThread.fwrk/headers/Config.h> #define kThreadMapMax (1024UL) @@ -21,15 +22,15 @@ static ThreadRef kCurrentThread; static __THREAD_UNSAFE Void _ThrRunThread(SInt32 argument_count, VoidPtr args, ThrProcKind procedure, ThreadRef ref) { - static SemaphoreRef sem_ref = SemCreate(0, 1000, "ThreadSem"); - + static SemaphoreRef sem_ref = SemCreate(0, 1000, "ThreadSem"); + if (sem_ref) return; - - auto ret = procedure(argument_count, (Char**) args); + + auto ret = procedure(argument_count, (Char**) args); kThreadExitCodes[kThreadMapMax % ref->__hash] = ret; if (ref == kCurrentThread) kCurrentThread = nullptr; - + SemClose(sem_ref); sem_ref = nullptr; } @@ -46,7 +47,7 @@ IMPORT_C ThreadRef ThrCreateThread(const Char* thread_name, ThrProcKind procedur } ref->__hash = *(UInt32*) thread_name; - ref->__hash += kThreadBaseHash; // pad hash with a seed. + ref->__hash += kThreadBaseHash; // pad hash with a seed. ref->__self = (VoidPtr) procedure; @@ -59,3 +60,15 @@ IMPORT_C ThreadRef ThrCreateThread(const Char* thread_name, ThrProcKind procedur return ref; } + +IMPORT_C SInt32 ThrExitThread(_Input ThreadRef ref, _Input SInt32 exit_code) { + if (!ref) return kErrorInvalidData; + + kThreadMap[kThreadMapMax % ref->__hash] = nullptr; + kThreadHeads[kThreadMapMax % ref->__hash] = nullptr; + + if (kCurrentThread == ref) kCurrentThread = nullptr; + + kThreadExitCodes[kThreadMapMax % ref->__hash] = exit_code; + return kErrorSuccess; +}
\ No newline at end of file diff --git a/frameworks/libX11.fwrk/headers/Config.h b/frameworks/libX11.fwrk/headers/Config.h index 7466eaf..1207451 100644 --- a/frameworks/libX11.fwrk/headers/Config.h +++ b/frameworks/libX11.fwrk/headers/Config.h @@ -8,6 +8,8 @@ #include <libSystem/SystemKit/System.h> +#define LIBX11_VERSION 0x100000 + #define _X11_ARRAY_CHECK(PTR) PTR != nullptr #define _X11_ARRAY_INDEX(ARR, PTR, LEN) ARR[((SInt64) PTR) % LEN] |
