#include "../std.h" #include #include static inline long com_std_syscall(long number, long arg1, long arg2, long arg3) { long ret; __asm__ volatile("syscall" : "=a"(ret) : "a"(number), "D"(arg1), "S"(arg2), "d"(arg3) : "rcx", "r11", "memory"); return ret; } 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); } /* TODO: Figure out a way to make it easy to deal with. */ void com_std_printf(char const *fmt, ...) { // va_list args; // va_start(args, fmt); // vprintf(fmt, args); // va_end(args); } double com_std_sqrt(double v) { return __builtin_sqrt(v); } double com_std_fabs(double v) { return __builtin_fabs(v); } double com_std_sin(double v) { return __builtin_sin(v); } double com_std_cos(double v) { return __builtin_cos(v); }