diff options
Diffstat (limited to 'src/libSystem')
| -rw-r--r-- | src/libSystem/SystemKit/Macros.h | 5 | ||||
| -rw-r--r-- | src/libSystem/SystemKit/System.h | 22 | ||||
| -rw-r--r-- | src/libSystem/libSystem.json | 2 | ||||
| -rw-r--r-- | src/libSystem/src/JailCalls.cpp | 5 | ||||
| -rw-r--r-- | src/libSystem/src/SystemCalls.cpp | 12 |
5 files changed, 36 insertions, 10 deletions
diff --git a/src/libSystem/SystemKit/Macros.h b/src/libSystem/SystemKit/Macros.h index 37150b01..1673d427 100644 --- a/src/libSystem/SystemKit/Macros.h +++ b/src/libSystem/SystemKit/Macros.h @@ -15,6 +15,9 @@ #define ATTRIBUTE(X) __attribute__((X)) +#define __THREAD_SAFE ATTRIBUTE(thread_safe) +#define __THREAD_UNSAFE + #define IMPORT_CXX extern "C++" #define IMPORT_C extern "C" @@ -91,7 +94,7 @@ typedef nullPtr NullPtr; #endif #ifndef kib_cast -#define kib_cast(X) (UInt64)((X) *1024) +#define kib_cast(X) (UInt64)((X) * 1024) #endif #ifndef MIB diff --git a/src/libSystem/SystemKit/System.h b/src/libSystem/SystemKit/System.h index 1a7298d8..324aae5c 100644 --- a/src/libSystem/SystemKit/System.h +++ b/src/libSystem/SystemKit/System.h @@ -14,12 +14,15 @@ /// @brief Secure TTY device path. #define kSecurePrintDevicePath "/devices/stty{}{}" +/// @brief Laser-disc path (Blu-ray, DVD, CD, etc.) #define kCDDevicePath "/devices/dvd{}{}" // ------------------------------------------------------------------------------------------ // /// @brief Types API. // ------------------------------------------------------------------------------------------ // +/// @brief Reference type, used for all references in the system, such as file descriptors, dylib +/// handles, thread handles, etc. struct REF_TYPE { UInt64 __hash; /// @brief Hash of the syscall VoidPtr __self; /// @brief Syscall self value. @@ -209,12 +212,15 @@ typedef SInt32 (*ThrProcKind)(SInt32 argc, Char** argv); /// @param flags Thread flags. /// @return the thread object. IMPORT_C ThreadRef ThrCreateThread(const Char* thread_name, ThrProcKind procedure, - SInt32 argument_count, SInt32 flags); + SInt32 argument_count, VoidPtr args, SInt32 flags); /// @brief Yields the current thread. /// @param thread the thread to yield. IMPORT_C SInt32 ThrYieldThread(ThreadRef thrd); +/// @brief Get the current thread's ID. +IMPORT_C ThreadRef ThrCurrentThread(Void); + /// @brief Joins a thread. /// @param thread the thread to join. IMPORT_C SInt32 ThrJoinThread(ThreadRef thrd); @@ -388,4 +394,18 @@ IMPORT_C Char* StrFmt(const Char* fmt, ...); IMPORT_C UInt64 StrMathToNumber(const Char* in, const Char** endp, const SInt16 base); +// ------------------------------------------------------------------------------------------ // +// @brief Semaphore API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Create a semaphore. +IMPORT_C _Output SemaphoreRef SemCreate(_Input UInt32 initial_count, _Input UInt32 max_count, + _Input const Char* name); + +/// @brief Wait on a semaphore. +IMPORT_C SInt32 SemWait(_Input SemaphoreRef sem); + +/// @brief Close a semaphore. +IMPORT_C SInt32 SemClose(_Input SemaphoreRef sem); + #endif // ifndef SYSTEMKIT_SYSTEM_H diff --git a/src/libSystem/libSystem.json b/src/libSystem/libSystem.json index 16557645..14f4bfc5 100644 --- a/src/libSystem/libSystem.json +++ b/src/libSystem/libSystem.json @@ -17,5 +17,5 @@ "kLibSystemVersionHighest=0x0100", "kLibSystemVersionLowest=0x0100" ], - "description": "The System Call Kit for the NeKernel Stack." + "description": "The System Call Kit for the NeSystem." } diff --git a/src/libSystem/src/JailCalls.cpp b/src/libSystem/src/JailCalls.cpp index 674e916a..e5e11a43 100644 --- a/src/libSystem/src/JailCalls.cpp +++ b/src/libSystem/src/JailCalls.cpp @@ -11,5 +11,6 @@ using namespace LibSystem; -IMPORT_C struct JAIL* JailGetCurrent(Void) { return (struct JAIL*) libsys_syscall_arg_1(SYSCALL_HASH("JailGetCurrent")); } - +IMPORT_C struct JAIL* JailGetCurrent(Void) { + return (struct JAIL*) libsys_syscall_arg_1(SYSCALL_HASH("JailGetCurrent")); +} diff --git a/src/libSystem/src/SystemCalls.cpp b/src/libSystem/src/SystemCalls.cpp index 470bc237..c5497f91 100644 --- a/src/libSystem/src/SystemCalls.cpp +++ b/src/libSystem/src/SystemCalls.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <libSystem/SystemKit/Err.h> #include <libSystem/SystemKit/Syscall.h> #include <libSystem/SystemKit/System.h> @@ -126,7 +125,9 @@ IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) Verify::sys_safe_cast<Char, Void>(drv_letter))); } -IMPORT_C Void IoCloseFile(_Input Ref desc) { libsys_syscall_arg_2(SYSCALL_HASH("IoCloseFile"), static_cast<VoidPtr>(desc)); } +IMPORT_C Void IoCloseFile(_Input Ref desc) { + libsys_syscall_arg_2(SYSCALL_HASH("IoCloseFile"), static_cast<VoidPtr>(desc)); +} IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) { auto ret_ptr = libsys_syscall_arg_3(SYSCALL_HASH("IoSeekFile"), static_cast<VoidPtr>(desc), @@ -134,7 +135,7 @@ IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) { if (!ret_ptr) return ~0UL; - auto ret = static_cast<volatile UInt64*>(ret_ptr); + auto ret = static_cast<volatile UInt64*>(ret_ptr); UInt64 result = *ret; MUST_PASS(result != ~0UL); @@ -160,7 +161,9 @@ IMPORT_C SInt32 PrintRelease(_Input IORef buf) { return static_cast<SInt32>(*ret); } -IMPORT_C IORef PrintCreate(Void) { return static_cast<IORef>(libsys_syscall_arg_1(SYSCALL_HASH("PrintCreate"))); } +IMPORT_C IORef PrintCreate(Void) { + return static_cast<IORef>(libsys_syscall_arg_1(SYSCALL_HASH("PrintCreate"))); +} IMPORT_C VoidPtr MmCreateHeap(UInt64 initial_size, UInt32 max_size) { return static_cast<VoidPtr>(libsys_syscall_arg_3(SYSCALL_HASH("MmCreateHeap"), @@ -223,4 +226,3 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const Char* fmt, ...) { IMPORT_C UInt64 PrintSize(IORef ref) { return *static_cast<UInt64*>(libsys_syscall_arg_2(SYSCALL_HASH("PrintSize"), ref)); } - |
