From 7199e74aa22e592a3b77bdd81f735edca5470596 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 20 Jan 2024 17:59:40 -0500 Subject: update --- libraries/euler/include/cassert | 13 +++++++++ libraries/euler/include/cctype | 7 +++++ libraries/euler/include/cstddef | 1 + libraries/euler/include/cstdint | 1 + libraries/euler/include/cstdio | 19 ++++++++++++ libraries/euler/include/cstring | 14 +++++++++ libraries/euler/include/euler/syscall.hpp | 48 +++++++++++++++++++++++++++++++ 7 files changed, 103 insertions(+) create mode 100644 libraries/euler/include/cassert create mode 100644 libraries/euler/include/cctype create mode 120000 libraries/euler/include/cstddef create mode 120000 libraries/euler/include/cstdint create mode 100644 libraries/euler/include/cstdio create mode 100644 libraries/euler/include/cstring create mode 100644 libraries/euler/include/euler/syscall.hpp (limited to 'libraries/euler/include') 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 + +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 + +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); + +} -- cgit v1.2.3