diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-05-23 07:53:50 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-05-23 07:53:50 +0000 |
| commit | f5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (patch) | |
| tree | c9305701aa2d4ee0235c85c67cd6633e5763ec21 /SDK/Library/CoreSystem | |
| parent | ca675beb41dba8d7d16c5793b55d1672f38be3b4 (diff) | |
| parent | 06b1a4bb12b4043b606d8bb0d55942d636c6833e (diff) | |
Merged in MHR-23 (pull request #13)
MHR-23
Diffstat (limited to 'SDK/Library/CoreSystem')
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Alert.h | 8 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Defines.h | 69 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/File.h | 28 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Heap.h | 16 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Hint.h | 2 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Intl.h | 13 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Math.h | 12 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Rsrc.h | 5 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Thread.h | 14 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Headers/Transport.h | 48 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Private.xml | 4 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/ReadMe.md | 4 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/App.c | 10 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/CRTStartup.c | 12 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/File.c | 35 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/Heap.c | 31 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/Math.c | 4 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/Sources/Thread.c | 9 | ||||
| -rw-r--r-- | SDK/Library/CoreSystem/amd64.mk | 2 |
19 files changed, 215 insertions, 111 deletions
diff --git a/SDK/Library/CoreSystem/Headers/Alert.h b/SDK/Library/CoreSystem/Headers/Alert.h index 57c9afeb..7decd4ca 100644 --- a/SDK/Library/CoreSystem/Headers/Alert.h +++ b/SDK/Library/CoreSystem/Headers/Alert.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -18,4 +18,8 @@ #include <Headers/Defines.h> -CA_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...); +/// @brief Shows an alert box, as provided by the OS. +/// @param fmt The alert formating. +/// @param +/// @return +CS_EXTERN_C VoidType UiAlert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Library/CoreSystem/Headers/Defines.h b/SDK/Library/CoreSystem/Headers/Defines.h index 600e9ab6..a7e46234 100644 --- a/SDK/Library/CoreSystem/Headers/Defines.h +++ b/SDK/Library/CoreSystem/Headers/Defines.h @@ -1,49 +1,49 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ #pragma once -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS +#ifdef CS_MUST_PASS +#undef CS_MUST_PASS #endif #ifdef _DEBUG -#define CA_MUST_PASS(e) \ +#define CS_MUST_PASS(e) \ { \ if (!e) \ { \ - Alert("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \ + UiAlert("Assertion failed.\nExpression :%s\nFile: %s\nLine: %i", #e, __FILE__, __LINE__) RtAssertTriggerInterrupt() \ } \ } #else -#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#define CS_MUST_PASS(e) CS_UNREFERENCED_PARAMETER(e) #endif #ifdef __cplusplus -#define CA_EXTERN_C extern "C" +#define CS_EXTERN_C extern "C" #else -#define CA_EXTERN_C extern +#define CS_EXTERN_C extern #endif struct ApplicationInterface; struct GUID; -CA_EXTERN_C void RtAssertTriggerInterrupt(void); +CS_EXTERN_C void RtAssertTriggerInterrupt(void); -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) +#define CS_STDCALL __attribute__((stdcall)) +#define CS_CDECL __attribute__((cdecl)) +#define CS_MSCALL __attribute__((ms_abi)) #define PACKED __attribute__((packed)) -#define CA_PASCAL CA_STDCALL +#define CS_PASCAL CS_STDCALL #include <Headers/Hint.h> @@ -79,20 +79,20 @@ typedef CharacterTypeUTF8 BooleanType; #define Yes 1 #define No 0 -#define CA_PTR * +#define CS_PTR * -#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) +#define CS_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) #ifdef __x86_64__ -#define CA_FAR __far -#define CA_NEAR __near +#define CS_FAR __far +#define CS_NEAR __near #define _M_AMD64 2 #else -#define CA_FAR -#define CA_NEAR +#define CS_FAR +#define CS_NEAR #endif @@ -112,14 +112,14 @@ typedef CharacterTypeUTF8 BooleanType; #define _M_RISCV 6 #endif -#define CA_STATIC static -#define CA_INLINE inline -#define CA_CONST const +#define CS_STATIC static +#define CS_INLINE inline +#define CS_CONST const #ifdef __cplusplus -#define CA_CONSTEXPR constexpr +#define CS_CONSTEXPR constexpr #else -#define CA_CONSTEXPR +#define CS_CONSTEXPR #endif // __cplusplus enum RtProcessCall @@ -144,6 +144,11 @@ enum RtProcessCall kCallRandomNumberGenerator, kCallGetArgsCount, kCallGetArgsPtr, + kCallFileExists, + kCallDirectoryExists, + kCallSymlinkExists, + kCallDeviceExists, + kCallDriveExists, /// @brief Number of process calls. kCallsCount, }; @@ -171,19 +176,19 @@ typedef struct ApplicationInterface #ifdef __cplusplus -#define CA_COPY_DELETE(KLASS) \ +#define CS_COPY_DELETE(KLASS) \ KLASS& operator=(const KLASS&) = delete; \ KLASS(const KLASS&) = delete; -#define CA_COPY_DEFAULT(KLASS) \ +#define CS_COPY_DEFAULT(KLASS) \ KLASS& operator=(const KLASS&) = default; \ KLASS(const KLASS&) = default; -#define CA_MOVE_DELETE(KLASS) \ +#define CS_MOVE_DELETE(KLASS) \ KLASS& operator=(KLASS&&) = delete; \ KLASS(KLASS&&) = delete; -#define CA_MOVE_DEFAULT(KLASS) \ +#define CS_MOVE_DEFAULT(KLASS) \ KLASS& operator=(KLASS&&) = default; \ KLASS(KLASS&&) = default; @@ -201,19 +206,19 @@ using StrType = CharacterTypeUTF8[N]; /// @brief Get app singleton. /// @param /// @return -CA_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); +CS_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); /// @brief Get argument count /// @param /// @return -CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); +CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); /// @brief Get argument pointer. /// @param /// @return -CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); +CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); -CA_EXTERN_C ApplicationInterfaceRef kSharedApplication; +CS_EXTERN_C ApplicationInterfaceRef kSharedApplication; typedef CharacterTypeUTF8 StrType255[255]; diff --git a/SDK/Library/CoreSystem/Headers/File.h b/SDK/Library/CoreSystem/Headers/File.h index 09cd0b88..594b4edb 100644 --- a/SDK/Library/CoreSystem/Headers/File.h +++ b/SDK/Library/CoreSystem/Headers/File.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -8,6 +8,8 @@ #include <Headers/Defines.h> +struct _Fork; + /// @brief Filesystem wrapper. typedef QWordType FSRef; @@ -16,37 +18,35 @@ typedef QWordType FSRef; /// @param path where to find it. /// @param rest the restrict (rw, rwe, r+, w+, r, w) /// @return FSRef the file. -CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); +CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); /// @brief Closes the file and flushes it to the said file. -/// @param refFs the filesystem reference. +/// @param refCS the filesystem reference. /// @return -CA_EXTERN_C VoidType FsCloseFile(FSRef refFs); +CS_EXTERN_C VoidType CSCloseFile(FSRef refCS); -#define kMaxForkNameLength 256 /* long fork names. */ +#define kMaxForkNameLength (256U) /* long fork names. */ /// @brief A fork information header. typedef struct _Fork { - PtrVoidType forkData; - SizeType forkSize; Int32Type forkFlags; Int32Type forkKind; CharacterTypeUTF8 forkName[kMaxForkNameLength]; -} ForkType; + SizeType forkSize; + CharacterTypeUTF8 forkData[]; +} ForkType, ForkTypePtr; typedef ForkType* FSForkRef; /// @brief Gets the fork inside a file. -/// @param refFs the filesystem ref +/// @param refCS the filesystem ref /// @param forkName the fork's name /// @return the fork data. -CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName); +CS_EXTERN_C FSForkRef CSGetFork(FSRef refCS, const CharacterTypeUTF8* forkName); /// @brief Check if the filesystem path is valid. /// @return if not return false, or true. -CA_EXTERN_C BooleanType FsIsValidPath(const CharacterTypeUTF8* path); +CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path); -/// @note not only limited to, there is code forks, icon forks... -#define FsGetDataFork(refFs) FsGetFork(refFs, "data") -#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc") +/// END OF FILE diff --git a/SDK/Library/CoreSystem/Headers/Heap.h b/SDK/Library/CoreSystem/Headers/Heap.h index 0a02bb1a..b2ad6e74 100644 --- a/SDK/Library/CoreSystem/Headers/Heap.h +++ b/SDK/Library/CoreSystem/Headers/Heap.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -8,9 +8,9 @@ #include <Headers/Defines.h> -#define kAllocationTypes 2 +#define cAllocationKindCount (2U) -enum RtAllocationKind +enum CsAllocationKind { kStandardAllocation = 0xC, kArrayAllocation = 0xD, @@ -20,20 +20,20 @@ enum RtAllocationKind /// @param sz the size /// @param flags the allocation flags. /// @return -CA_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz, - DWordType flags); +CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, + DWordType flags); /// @brief Check if the pointer exists. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C BooleanType RtHeapPtrExists(PtrVoidType ptr); +CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr); /// @brief Gets the size of the process' pointer. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C QWordType RtHeapGetSize(PtrVoidType ptr); +CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr); /// @brief Frees the process pointer. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C VoidType RtHeapFree(PtrVoidType ptr); +CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr); diff --git a/SDK/Library/CoreSystem/Headers/Hint.h b/SDK/Library/CoreSystem/Headers/Hint.h index d775f52d..ee14711d 100644 --- a/SDK/Library/CoreSystem/Headers/Hint.h +++ b/SDK/Library/CoreSystem/Headers/Hint.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ diff --git a/SDK/Library/CoreSystem/Headers/Intl.h b/SDK/Library/CoreSystem/Headers/Intl.h index 5e4ef49e..b868adca 100644 --- a/SDK/Library/CoreSystem/Headers/Intl.h +++ b/SDK/Library/CoreSystem/Headers/Intl.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -12,13 +12,18 @@ typedef UInt64Type IntlRef; -/// @brief locale getter and setters. - +/// @brief Get app locale. +/// @param name locale name. +/// @return IntlRef IntlGetLocale(const char* name); + +/// @brief Set app locale. +/// @param intl the locale +/// @return BooleanType IntlSetLocale(const IntlRef intl); /// @brief locale helpers. /// @brief translate a string from a locale. const CharacterTypeUTF8* Intl(const CharacterTypeUTF8* input, - const IntlRef locale); + const IntlRef locale); diff --git a/SDK/Library/CoreSystem/Headers/Math.h b/SDK/Library/CoreSystem/Headers/Math.h index 87c792eb..0a13e86f 100644 --- a/SDK/Library/CoreSystem/Headers/Math.h +++ b/SDK/Library/CoreSystem/Headers/Math.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -14,14 +14,14 @@ /// @brief Number generator helper. /// @return Random generated number. -CA_EXTERN_C SizeType MathRand(VoidType); +CS_EXTERN_C SizeType MathRand(VoidType); /////////////////////////////////////////////////////////////////////// /// Mathematical functions /// /////////////////////////////////////////////////////////////////////// -CA_EXTERN_C FloatType Sqrt(FloatType number); +CS_EXTERN_C FloatType Sqrt(FloatType number); -CA_EXTERN_C FloatType Cosine(FloatType number); -CA_EXTERN_C FloatType Sine(FloatType number); -CA_EXTERN_C FloatType Tangent(FloatType number);
\ No newline at end of file +CS_EXTERN_C FloatType Cosine(FloatType number); +CS_EXTERN_C FloatType Sine(FloatType number); +CS_EXTERN_C FloatType Tangent(FloatType number);
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Headers/Rsrc.h b/SDK/Library/CoreSystem/Headers/Rsrc.h index 7d76f50d..7fe52910 100644 --- a/SDK/Library/CoreSystem/Headers/Rsrc.h +++ b/SDK/Library/CoreSystem/Headers/Rsrc.h @@ -1,9 +1,12 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ #pragma once #include <Headers/Defines.h> + +/// @file Rsrc.h +/// @brief RXML forks.
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Headers/Thread.h b/SDK/Library/CoreSystem/Headers/Thread.h index f0360b63..15b40df3 100644 --- a/SDK/Library/CoreSystem/Headers/Thread.h +++ b/SDK/Library/CoreSystem/Headers/Thread.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -19,7 +19,7 @@ typedef QWordType ThreadRef; /// @brief Main application thread. -CA_EXTERN_C ThreadRef kMainThread; +CS_EXTERN_C ThreadRef kMainThread; typedef VoidType (*ThreadEntrypointKind)(VoidType); @@ -27,21 +27,21 @@ typedef VoidType (*ThreadEntrypointKind)(VoidType); /// @param threadName the thread's name. /// @param threadStart where to start. /// @return -CA_EXTERN_C ThreadRef CTCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); +CS_EXTERN_C ThreadRef CSThreadCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); /// @brief Dispoes the thread, and exits with code kThreadErrorExit /// @param ref the thread reference. /// @return nothing. -CA_EXTERN_C VoidType CTRelease(ThreadRef ref); +CS_EXTERN_C VoidType CSThreadRelease(ThreadRef ref); /// @brief Waits for the thread to complete. /// @param ref the thread reference. /// @return nothing. -CA_EXTERN_C VoidType CTJoin(ThreadRef ref); +CS_EXTERN_C VoidType CSThreadJoin(ThreadRef ref); /// @brief Yields the current thread. /// @param ref the thead reference. -/// @return -CA_EXTERN_C VoidType CTYield(ThreadRef ref); +/// @return +CS_EXTERN_C VoidType CSThreadYield(ThreadRef ref); #endif // __THREAD__ diff --git a/SDK/Library/CoreSystem/Headers/Transport.h b/SDK/Library/CoreSystem/Headers/Transport.h new file mode 100644 index 00000000..3f6db3f1 --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Transport.h @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +// +// Created by Amlal on 5/12/24 +// + +#ifndef __TRANSPORT__ +#define __TRANSPORT__ + +/// @file: Transport.h +/// @brief Open Transport Layer, an alternative to berkeley sockets. + +#include <Headers/Defines.h> + +typedef QWordType TrStreamType; + +/// @brief Opens a new socket +/// @param afType address family +/// @param sockType type of socket +/// @param sockProto socket protocol. +/// @return The STREAMS socket. +/// @note return is const. +CS_EXTERN_C CS_CONST TrStreamType CSOpenSocket(UInt32Type afType, UInt32Type sockType, UInt32Type sockProto); + +/// @brief Close a STREAMS socket. +/// @param streams The streams socket. +/// @return +CS_EXTERN_C VoidType CSCloseSocket(CS_CONST TrStreamType streams); + +/// @brief Get OpenTransport version. +/// @param void +/// @return +CS_EXTERN_C CS_CONST Int32Type CSGetVersion(VoidType); + +enum +{ + TrSocketProtoTCP, /// TCP socket + TrSocketProtoUDP, /// UDP socket + TrSocketProtoUN, /// IPC socket + TrSocketProtoRaw, /// Raw socket + TrSocketProtoCount, +}; + +#endif // __TRANSPORT__
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Private.xml b/SDK/Library/CoreSystem/Private.xml new file mode 100644 index 00000000..4be6c388 --- /dev/null +++ b/SDK/Library/CoreSystem/Private.xml @@ -0,0 +1,4 @@ +<SourceDeploy> + <File name="Headers/Hint.h" hidden="true"/> + <Directory name="Sources/" hidden="true"/> +</SourceDeploy>
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/ReadMe.md b/SDK/Library/CoreSystem/ReadMe.md index be075a59..ae5df339 100644 --- a/SDK/Library/CoreSystem/ReadMe.md +++ b/SDK/Library/CoreSystem/ReadMe.md @@ -1,5 +1,5 @@ # CoreSystem -## System Core framework. +## Core System framework. Currently contains: @@ -8,6 +8,6 @@ Currently contains: - Data API. - Threading API. -Needs: +Needs to have: - Device API - Drive API.
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/App.c b/SDK/Library/CoreSystem/Sources/App.c index 6c6f22f3..42ea19c6 100644 --- a/SDK/Library/CoreSystem/Sources/App.c +++ b/SDK/Library/CoreSystem/Sources/App.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -12,9 +12,9 @@ ApplicationInterfaceRef kSharedApplication = NullPtr; /// @brief Gets the app arguments count. /// @param void no arguments. /// @return The number of arguments given to the application. -CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) +CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) { - CA_MUST_PASS(kSharedApplication); + CS_MUST_PASS(kSharedApplication); return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); } @@ -22,9 +22,9 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) /// @brief Gets the app arguments pointer. /// @param void no arguments. /// @return -CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) +CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) { - CA_MUST_PASS(kSharedApplication); + CS_MUST_PASS(kSharedApplication); return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, kCallGetArgsPtr); diff --git a/SDK/Library/CoreSystem/Sources/CRTStartup.c b/SDK/Library/CoreSystem/Sources/CRTStartup.c new file mode 100644 index 00000000..1cfad65d --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/CRTStartup.c @@ -0,0 +1,12 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include <Headers/Defines.h> + +VoidType __DllMainCRTStartup(VoidType) +{ + kSharedApplication = RtGetAppPointer(); +}
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/File.c b/SDK/Library/CoreSystem/Sources/File.c index 6488bccf..7547e7f2 100644 --- a/SDK/Library/CoreSystem/Sources/File.c +++ b/SDK/Library/CoreSystem/Sources/File.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -20,24 +20,39 @@ enum FileOp /// @param path where to find it. /// @param rest the restrict (rw, rwe, r+, w+, r, w) /// @return FSRef the file. -CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, +CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* rest) { - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(path && FsIsValidPath(path) == Yes); - CA_MUST_PASS(rest); + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(path && CSIsValidPath(path) == Yes); + CS_MUST_PASS(rest); return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, rest); } /// @brief Closes the file and flushes it to the said file. -/// @param refFs the filesystem reference. +/// @param refCS the filesystem reference. /// @return -CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) +CS_EXTERN_C VoidType CSCloseFile(FSRef refCS) { - CA_MUST_PASS(kSharedApplication); + CS_MUST_PASS(kSharedApplication); - kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile); - kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs); + kSharedApplication->Invoke(kSharedApplication, refCS, kFlushFile); + kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refCS); } + +/// @brief Check if filesystem path is valid. +/// @param path +/// @return +CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(path); + + return kSharedApplication->Invoke(kSharedApplication, kCallFileExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDirectoryExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallSymlinkExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDriveExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDeviceExists, path); +}
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/Heap.c b/SDK/Library/CoreSystem/Sources/Heap.c index f3e9f914..e7a77ba5 100644 --- a/SDK/Library/CoreSystem/Sources/Heap.c +++ b/SDK/Library/CoreSystem/Sources/Heap.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -11,11 +11,11 @@ /// @param sz size of object. /// @param flags flags. /// @return -CA_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz, DWordType flags) +CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, DWordType flags) { - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(sz); - CA_MUST_PASS(flags); + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(sz); + CS_MUST_PASS(flags); return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, kCallAllocPtr, sz, flags); @@ -23,33 +23,32 @@ CA_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz, DWordType flags) /// @brief Free pointer from the user's heap. /// @param ptr the pointer to free. -CA_EXTERN_C VoidType RtHeapFree(PtrVoidType ptr) +CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr) { - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(ptr); + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(ptr); - CA_UNREFERENCED_PARAMETER( + CS_UNREFERENCED_PARAMETER( kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); } /// @brief Get pointer size. /// @param ptr the pointer to find. /// @return the size. -CA_EXTERN_C QWordType RtHeapGetSize(PtrVoidType ptr) +CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr) { - CA_MUST_PASS(kSharedApplication); + CS_MUST_PASS(kSharedApplication); - CA_MUST_PASS(ptr); + CS_MUST_PASS(ptr); return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); } /// @brief Check if the pointer exists. /// @param ptr the pointer to check. /// @return if it exists -CA_EXTERN_C BooleanType RtHeapPtrExists(PtrVoidType ptr) +CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr) { - CA_MUST_PASS(kSharedApplication); - - CA_MUST_PASS(ptr); + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(ptr); return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); } diff --git a/SDK/Library/CoreSystem/Sources/Math.c b/SDK/Library/CoreSystem/Sources/Math.c index b41f8a54..19df42f3 100644 --- a/SDK/Library/CoreSystem/Sources/Math.c +++ b/SDK/Library/CoreSystem/Sources/Math.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright SoftwareLabs + Copyright SoftwareLabs ------------------------------------------- */ @@ -8,7 +8,7 @@ /// @brief Number generator helper. /// @return Random generated number. -CA_EXTERN_C SizeType MathRand(VoidType) +CS_EXTERN_C SizeType MathRand(VoidType) { return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); }
\ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/Thread.c b/SDK/Library/CoreSystem/Sources/Thread.c new file mode 100644 index 00000000..7d00bf9e --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/Thread.c @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include <Headers/Thread.h> + +ThreadRef kMainThread = 0; diff --git a/SDK/Library/CoreSystem/amd64.mk b/SDK/Library/CoreSystem/amd64.mk index 33303430..e64de90f 100644 --- a/SDK/Library/CoreSystem/amd64.mk +++ b/SDK/Library/CoreSystem/amd64.mk @@ -6,7 +6,7 @@ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CCINC=-I./ -CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared +CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -e __DllMainCRTStartup -shared OUTPUT=CoreSystem.lib .PHONY: all |
