summaryrefslogtreecommitdiff
path: root/libraries/euler/include
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/euler/include')
-rw-r--r--libraries/euler/include/cassert13
-rw-r--r--libraries/euler/include/cctype7
l---------libraries/euler/include/cstddef1
l---------libraries/euler/include/cstdint1
-rw-r--r--libraries/euler/include/cstdio19
-rw-r--r--libraries/euler/include/cstring14
-rw-r--r--libraries/euler/include/euler/syscall.hpp48
7 files changed, 103 insertions, 0 deletions
diff --git a/libraries/euler/include/cassert b/libraries/euler/include/cassert
new file mode 100644
index 0000000..bc716a0
--- /dev/null
+++ b/libraries/euler/include/cassert
@@ -0,0 +1,13 @@
+#pragma once
+
+namespace euler {
+ [[noreturn]] void assert_failed(
+ const char *file, const char *function, int line, const char *condition);
+}
+
+#ifdef NDEBUG
+#define assert(condition) ((void)0)
+#else
+#define assert(condition) ((condition) ? ((void)0) : \
+ euler::assert_failed(__FILE__, __func__, __LINE__, #condition))
+#endif
diff --git a/libraries/euler/include/cctype b/libraries/euler/include/cctype
new file mode 100644
index 0000000..087b191
--- /dev/null
+++ b/libraries/euler/include/cctype
@@ -0,0 +1,7 @@
+#pragma once
+
+namespace std {
+
+ int isspace(int ch);
+
+}
diff --git a/libraries/euler/include/cstddef b/libraries/euler/include/cstddef
new file mode 120000
index 0000000..9eac9b6
--- /dev/null
+++ b/libraries/euler/include/cstddef
@@ -0,0 +1 @@
+../../../mintsuki-freestanding-headers/stddef.h \ No newline at end of file
diff --git a/libraries/euler/include/cstdint b/libraries/euler/include/cstdint
new file mode 120000
index 0000000..b087235
--- /dev/null
+++ b/libraries/euler/include/cstdint
@@ -0,0 +1 @@
+../../../mintsuki-freestanding-headers/stdint.h \ No newline at end of file
diff --git a/libraries/euler/include/cstdio b/libraries/euler/include/cstdio
new file mode 100644
index 0000000..3bb293b
--- /dev/null
+++ b/libraries/euler/include/cstdio
@@ -0,0 +1,19 @@
+#pragma once
+
+#define EOF (-1)
+
+namespace euler {
+ struct file_t;
+}
+
+namespace std {
+
+ typedef euler::file_t FILE;
+
+ FILE *fopen(const char *path, const char *mode);
+ int fclose(FILE *file);
+
+ int fgetc(FILE *from);
+ int ungetc(int ch, FILE *from);
+
+}
diff --git a/libraries/euler/include/cstring b/libraries/euler/include/cstring
new file mode 100644
index 0000000..65d00dc
--- /dev/null
+++ b/libraries/euler/include/cstring
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <cstddef>
+
+namespace std {
+
+ static inline size_t strlen(const char *str) {
+ size_t i = 0;
+ while (str[i])
+ ++i;
+ return i;
+ }
+
+}
diff --git a/libraries/euler/include/euler/syscall.hpp b/libraries/euler/include/euler/syscall.hpp
new file mode 100644
index 0000000..781d444
--- /dev/null
+++ b/libraries/euler/include/euler/syscall.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <cstdint>
+
+namespace euler::syscall {
+
+ typedef uint32_t encoded_color;
+ typedef int32_t exit_code;
+ typedef uint64_t file_handle;
+
+ enum [[nodiscard]] file_result : uint64_t {
+ success,
+ bad_file_handle,
+ device_error,
+ file_system_corrupt,
+ out_of_bounds,
+ does_not_exist,
+ directory
+ };
+
+}
+
+extern "C" {
+
+ euler::syscall::encoded_color _syscall_encode_color(
+ uint8_t red, uint8_t green, uint8_t blue);
+
+ void _syscall_get_framebuffer(
+ euler::syscall::encoded_color *&ptr_out, uint32_t &width_out,
+ uint32_t &height_out, uint32_t &pitch_out);
+
+ euler::syscall::file_result _syscall_open_file(
+ const char *path, uint64_t path_length, euler::syscall::file_handle &out);
+
+ euler::syscall::file_result _syscall_get_file_length(
+ euler::syscall::file_handle file, uint64_t &out);
+
+ euler::syscall::file_result _syscall_read_from_file(
+ euler::syscall::file_handle file,
+ uint64_t start_offset, uint64_t length, void *into);
+
+ [[noreturn]] void _syscall_end_this_process(euler::syscall::exit_code code);
+
+ [[nodiscard]] void *_syscall_get_new_pages(uint64_t count);
+
+ void _syscall_close_file(euler::syscall::file_handle file);
+
+}