summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/Defines.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-29 10:48:12 +0200
committerGitHub <noreply@github.com>2025-05-29 10:48:12 +0200
commit433bb5ef102b2bfa0049468be00d63011da8b973 (patch)
treee0893a30710477045a5bb085cb7a27aada425c14 /dev/LibCompiler/Defines.h
parent1ddeab9a4426abd781a5066ba79af2ba64de11d9 (diff)
parent756ee7f8dc954e27350fe5bdfbaa83b9f69780c8 (diff)
Merge pull request #6 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'dev/LibCompiler/Defines.h')
-rw-r--r--dev/LibCompiler/Defines.h28
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))