diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-02 19:38:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-02 19:38:33 +0200 |
| commit | 87979899ce833ca477bb563b84e3698224119dab (patch) | |
| tree | df67a0724de4c76ce594222747220c233c3bc7f5 /dev/LibCompiler/Defines.h | |
| parent | 3afc481dc64a07fe7fcaff9ce7a12a492c3ec8e7 (diff) | |
| parent | fb12b9730d78052f5cafbd84fbc9a830a22cec17 (diff) | |
Merge pull request #4 from nekernel-org/dev
0.0.1
Diffstat (limited to 'dev/LibCompiler/Defines.h')
| -rw-r--r-- | dev/LibCompiler/Defines.h | 136 |
1 files changed, 66 insertions, 70 deletions
diff --git a/dev/LibCompiler/Defines.h b/dev/LibCompiler/Defines.h index b13cd86..eacf9c0 100644 --- a/dev/LibCompiler/Defines.h +++ b/dev/LibCompiler/Defines.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved ------------------------------------------- */ @@ -9,19 +9,23 @@ #ifndef Yes #define Yes true -#endif // ifndef Yes +#endif // ifndef Yes #ifndef No #define No false -#endif // ifndef No +#endif // ifndef No #ifndef YES #define YES true -#endif // ifndef YES +#endif // ifndef YES #ifndef NO #define NO false -#endif // ifndef NO +#endif // ifndef NO + +#ifndef BOOL +#define BOOL bool +#endif // ifndef BOOL #define SizeType size_t @@ -30,37 +34,36 @@ #define UIntPtr uintptr_t -#define Int64 int64_t +#define Int64 int64_t #define UInt64 uint64_t -#define Int32 int +#define Int32 int #define UInt32 unsigned #define Bool bool -#define Int16 int16_t +#define Int16 int16_t #define UInt16 uint16_t -#define Int8 int8_t +#define Int8 int8_t #define UInt8 uint8_t #define CharType char -#define Boolean bool +#define Boolean bool -#include <filesystem> -#include <cstdint> #include <cassert> -#include <cstring> -#include <iostream> -#include <utility> #include <cctype> +#include <cstdint> #include <cstdio> +#include <cstring> +#include <filesystem> #include <fstream> +#include <iostream> #include <memory> +#include <new> #include <string> +#include <utility> #include <vector> -#include <vector> -#include <new> #define nullPtr std::nullptr_t @@ -78,76 +81,71 @@ #define rt_copy_memory(dst, src, len) memcpy(dst, src, len) #endif -#define LIBCOMPILER_COPY_DELETE(KLASS) \ - KLASS& operator=(const KLASS&) = delete; \ - KLASS(const KLASS&) = delete; +#define LIBCOMPILER_COPY_DELETE(KLASS) \ + KLASS& operator=(const KLASS&) = delete; \ + KLASS(const KLASS&) = delete; -#define LIBCOMPILER_COPY_DEFAULT(KLASS) \ - KLASS& operator=(const KLASS&) = default; \ - KLASS(const KLASS&) = default; +#define LIBCOMPILER_COPY_DEFAULT(KLASS) \ + KLASS& operator=(const KLASS&) = default; \ + KLASS(const KLASS&) = default; -#define LIBCOMPILER_MOVE_DELETE(KLASS) \ - KLASS& operator=(KLASS&&) = delete; \ - KLASS(KLASS&&) = delete; +#define LIBCOMPILER_MOVE_DELETE(KLASS) \ + KLASS& operator=(KLASS&&) = delete; \ + KLASS(KLASS&&) = delete; -#define LIBCOMPILER_MOVE_DEFAULT(KLASS) \ - KLASS& operator=(KLASS&&) = default; \ - KLASS(KLASS&&) = default; +#define LIBCOMPILER_MOVE_DEFAULT(KLASS) \ + KLASS& operator=(KLASS&&) = default; \ + KLASS(KLASS&&) = default; #define LC_IMPORT_C extern "C" -#define LC_IMPORT extern +#define LC_IMPORT extern #include <ctime> #include <fstream> #include <string> #include <vector> -namespace LibCompiler -{ - inline constexpr int kBaseYear = 1900; +namespace LibCompiler { +inline constexpr int kBaseYear = 1900; - typedef std::string String; +typedef std::string String; - inline String current_date() noexcept - { - auto time_data = time(nullptr); - auto time_struct = gmtime(&time_data); +inline String current_date() noexcept { + auto time_data = time(nullptr); + auto time_struct = gmtime(&time_data); - String fmt = std::to_string(kBaseYear + time_struct->tm_year); + String fmt = std::to_string(kBaseYear + time_struct->tm_year); - fmt += "-"; - fmt += std::to_string(time_struct->tm_mon + 1); - fmt += "-"; - fmt += std::to_string(time_struct->tm_mday); + fmt += "-"; + fmt += std::to_string(time_struct->tm_mon + 1); + fmt += "-"; + fmt += std::to_string(time_struct->tm_mday); - return fmt; - } + return fmt; +} - inline bool to_str(CharType* str, Int32 limit, Int32 base) noexcept - { - if (limit == 0) - return false; +inline bool to_str(CharType* str, Int32 limit, Int32 base) noexcept { + if (limit == 0) return false; - Int32 copy_limit = limit; - Int32 cnt = 0; - Int32 ret = base; + Int32 copy_limit = limit; + Int32 cnt = 0; + Int32 ret = base; - while (limit != 1) - { - ret = ret % 10; - str[cnt] = ret; + while (limit != 1) { + ret = ret % 10; + str[cnt] = ret; - ++cnt; - --limit; - --ret; - } + ++cnt; + --limit; + --ret; + } - str[copy_limit] = '\0'; - return true; - } + str[copy_limit] = '\0'; + return true; +} - using String = std::basic_string<CharType>; -} // namespace LibCompiler +using String = std::basic_string<CharType>; +} // namespace LibCompiler #define PACKED __attribute__((packed)) @@ -156,10 +154,8 @@ typedef char char_type; #define kObjectFileExt ".obj" #define kBinaryFileExt ".bin" -#define kAsmFileExts \ - { \ - ".64x", ".32x", ".masm", ".s", ".S", ".asm", ".x64" \ - } +#define kAsmFileExts \ + { ".64x", ".32x", ".masm", ".s", ".S", ".asm", ".x64" } #define kAsmFileExtsMax 7 @@ -167,6 +163,6 @@ typedef char char_type; #ifdef MSVC #pragma scalar_storage_order big - endian -#endif // ifdef MSVC +#endif // ifdef MSVC #endif /* ifndef __LIBCOMPILER_DEFINES_H__ */ |
