From 36dc1f859a13e428c441fc8f4f35550fe12ed72f Mon Sep 17 00:00:00 2001 From: nasr Date: Sun, 19 Apr 2026 18:38:22 +0200 Subject: feature(base): refactored the base library. removed some files etc and did stuff --- source/base/base_os.h | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'source/base/base_os.h') diff --git a/source/base/base_os.h b/source/base/base_os.h index 82aa70d..2e192c5 100644 --- a/source/base/base_os.h +++ b/source/base/base_os.h @@ -15,7 +15,6 @@ load_file(mem_arena *arena, const char *path) string8 result = {0}; struct stat sbuf = {0}; - // TODO(nasr): abstract this to a platform layer s32 file = open(path, O_RDONLY); if(file == -1) { @@ -28,9 +27,7 @@ load_file(mem_arena *arena, const char *path) return (string8){0}; } - result = PushString8(arena, sbuf.st_size); - result.size = (u64)sbuf.st_size; if(result.size != 0) { @@ -68,8 +65,9 @@ write_file(const char *path, string8 data) return result; } -#define os_write(buf, count) _os_write(STDIN_FD, buf, count) -#define os_read(buf, count) _os_read(STDIN_FD, buf, count) +#if 0 +#define os_write(buf, count) _os_write(STDOUT_FD, buf, count) +#define os_read(buf, count) _os_read(STDIN_FD, buf, count) internal s64 _os_write(s32 fd, void const *buf, u64 count) @@ -83,6 +81,7 @@ _os_read(s32 fd, void *buf, u64 count) return syscall(SYS_read, fd, buf, count); } + internal void log_s8(string8 s) { @@ -100,10 +99,10 @@ _log(const char *str) #else unused(str); #endif - } #endif + internal void write_string(const char *str) { @@ -112,10 +111,11 @@ write_string(const char *str) os_write(str, len); } +#endif + internal void write_int(s32 num) { - if (num < 0) { write(STDERR_FILENO, "-", 1); @@ -124,22 +124,7 @@ write_int(s32 num) if (num >= 10) write_int(num / 10); char digit = '0' + (num % 10); - write(STDERR_FILENO, &digit, 1); } -internal inline void -sleep_ms(long ms) -{ - struct timespec ts; - ts.tv_sec = ms / 1000; - ts.tv_nsec = (ms % 1000) * 1000000L; - - while (nanosleep(&ts, &ts)) - { - NULL; - } -} - - -#endif +#endif /* BASE_IMPLEMENTATION */ -- cgit v1.3