summaryrefslogtreecommitdiffhomepage
path: root/src/libPThread
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-15 13:12:19 +0100
committerGitHub <noreply@github.com>2026-03-15 13:12:19 +0100
commitf2da24874369c5a0e8937e848a86d74f2ac564ba (patch)
treecea6ca62870c3db390902a21543a99b31caa4170 /src/libPThread
parent984e7503e0c7605f60dac3e8d2de40d3fdf36eae (diff)
parentf58844c6bb8e6c979347050782068bdfe58089d3 (diff)
Merge pull request #139 from ne-foss-org/pthread-system
[FEAT] Pthread system
Diffstat (limited to 'src/libPThread')
-rw-r--r--src/libPThread/.keep0
-rw-r--r--src/libPThread/PThreadKit/.keep0
-rw-r--r--src/libPThread/PThreadKit/Thread.h14
-rw-r--r--src/libPThread/libPThread.json22
-rw-r--r--src/libPThread/src/.keep0
-rw-r--r--src/libPThread/src/Thread.cpp33
6 files changed, 69 insertions, 0 deletions
diff --git a/src/libPThread/.keep b/src/libPThread/.keep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/libPThread/.keep
diff --git a/src/libPThread/PThreadKit/.keep b/src/libPThread/PThreadKit/.keep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/libPThread/PThreadKit/.keep
diff --git a/src/libPThread/PThreadKit/Thread.h b/src/libPThread/PThreadKit/Thread.h
new file mode 100644
index 00000000..053885e7
--- /dev/null
+++ b/src/libPThread/PThreadKit/Thread.h
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org)
+// Licensed under the Apache License, Version 2.0 (see LICENSE file)
+// Official repository: https://github.com/ne-foss-org/nekernel
+
+#ifndef LIBPOSIX_POSIXKIT_THREAD_H
+#define LIBPOSIX_POSIXKIT_THREAD_H
+
+#include <libPOSIXWrapper/POSIXKit/unistd.h>
+
+#define PTHREAD_UNSAFE /* hint */
+#define PTHREAD_SAFE /* hint */
+
+#endif // LIBPOSIX_POSIXKIT_THREAD_H
diff --git a/src/libPThread/libPThread.json b/src/libPThread/libPThread.json
new file mode 100644
index 00000000..a5cfba73
--- /dev/null
+++ b/src/libPThread/libPThread.json
@@ -0,0 +1,22 @@
+{
+ "compiler_path": "x86_64-w64-mingw32-gcc",
+ "compiler_std": "c++20",
+ "headers_path": ["../", "./"],
+ "sources_path": ["src/*.cpp"],
+ "output_name": "libPThread.dll",
+ "compiler_flags": [
+ "-ffreestanding",
+ "-shared",
+ "-std=c++20",
+ "-fno-rtti",
+ "-fno-exceptions",
+ "-Wl,--subsystem=17"
+ ],
+ "cpp_macros": [
+ "__NEOSKRNL__",
+ "kPosixVersionHighest=0x0100",
+ "kPosixVersionLowest=0x0100",
+ "kPosixVersion=0x0100"
+ ],
+ "description": "The NeKernel PThread System. Refer to: https://man7.org/linux/man-pages/man7/pthreads.7.html"
+}
diff --git a/src/libPThread/src/.keep b/src/libPThread/src/.keep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/libPThread/src/.keep
diff --git a/src/libPThread/src/Thread.cpp b/src/libPThread/src/Thread.cpp
new file mode 100644
index 00000000..34a610cd
--- /dev/null
+++ b/src/libPThread/src/Thread.cpp
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org)
+// Licensed under the Apache License, Version 2.0 (see LICENSE file)
+// Official repository: https://github.com/ne-foss-org/nekernel
+
+#include <libPThread/PThreadKit/Thread.h>
+
+namespace POSIXKit::Detail {
+
+ /// @brief Max path structure.
+ constexpr auto kMaxPathLen = 255;
+ static constexpr auto kCanaryValue = 0xf0f0488f;
+
+ /// @brief Thread Information Structure.
+ struct ThreadFrameParams final {
+ SInt64 fCanary;
+ VoidPtr fStackPtr;
+ VoidPtr fCodePtr;
+ SizeT fCodeSz;
+ SizeT fStackSz;
+ SInt64 fThrdID;
+ SInt64 fUsrID, fGrpID;
+ SInt64* fFD{};
+ SizeT fFDCnt;
+ Char fCWD[kMaxPathLen];
+ Char fRoot[kMaxPathLen];
+ ThreadRef fRef;
+ };
+
+} // namespace POSIX::Detail
+
+
+