diff options
Diffstat (limited to 'dev/LibCompiler/Defines.h')
| -rw-r--r-- | dev/LibCompiler/Defines.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/dev/LibCompiler/Defines.h b/dev/LibCompiler/Defines.h index eacf9c0..1e1d4d9 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 Mahrouss, all rights reserved ------------------------------------------- */ @@ -48,7 +48,7 @@ #define Int8 int8_t #define UInt8 uint8_t -#define CharType char +#define Char char #define Boolean bool #include <cassert> @@ -99,22 +99,16 @@ #define LC_IMPORT_C extern "C" #define LC_IMPORT extern - -#include <ctime> -#include <fstream> -#include <string> -#include <vector> - namespace LibCompiler { inline constexpr int kBaseYear = 1900; -typedef std::string String; +typedef std::string STLString; -inline String current_date() noexcept { +inline STLString current_date() noexcept { auto time_data = time(nullptr); auto time_struct = gmtime(&time_data); - String fmt = std::to_string(kBaseYear + time_struct->tm_year); + STLString fmt = std::to_string(kBaseYear + time_struct->tm_year); fmt += "-"; fmt += std::to_string(time_struct->tm_mon + 1); @@ -124,7 +118,7 @@ inline String current_date() noexcept { return fmt; } -inline bool to_str(CharType* str, Int32 limit, Int32 base) noexcept { +inline bool to_str(Char* str, Int32 limit, Int32 base) noexcept { if (limit == 0) return false; Int32 copy_limit = limit; @@ -144,7 +138,15 @@ inline bool to_str(CharType* str, Int32 limit, Int32 base) noexcept { return true; } -using String = std::basic_string<CharType>; +inline bool install_signal(Int32 signal, void (*handler)(int)) noexcept { + if (handler == nullptr) return false; + + if (::signal(signal, handler) == SIG_ERR) { + return false; + } + + return true; +} } // namespace LibCompiler #define PACKED __attribute__((packed)) |
