generalization of syscalls

This commit is contained in:
veclavtlica
2026-10-07 17:16:18 +03:00
parent e7abe1a1d2
commit 3db75378c4
9 changed files with 231 additions and 40 deletions
+8 -4
View File
@@ -1,3 +1,7 @@
/*
Generic linux std parts.
*/
#include "../def.h"
#include "../std.h"
#include "../str.h"
@@ -8,18 +12,18 @@ void *com_std_alloc(void *ptr, size_t size) { return NULL; }
void com_std_assert(bool holds) {
/* TODO: Write line info to stderr as well. */
if (!holds)
com_std_syscall(__NR_exit, -1, 0, 0);
com_std_exit(-1);
}
/* TODO: Figure out a way to make it easy to deal with. */
void com_std_printf(char const *fmt, ...) {
com_std_syscall(1, 1, (intptr_t)fmt, com_str_ext_len(fmt));
com_std_write((void *)1, fmt, com_str_ext_len(fmt));
}
void com_std_print_str(char const *str, uint32_t len, bool newline) {
com_std_syscall(1, 1, (intptr_t)str, len);
com_std_write((void *)1, str, len);
if (newline)
com_std_syscall(1, 1, (intptr_t)"\n", 1);
com_std_write((void *)1, "\n", 1);
}
double com_std_sqrt(double v) { return __builtin_sqrt(v); }