no libc, start on socket x11
This commit is contained in:
+3
-2
@@ -5,8 +5,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <tgmath.h>
|
||||
|
||||
void *com_std_realloc(void *ptr, size_t size) { return realloc(ptr, size); }
|
||||
void com_std_free(void *ptr) { free(ptr); }
|
||||
void *com_std_alloc(void *ptr, size_t size) {
|
||||
return size != 0 ? realloc(ptr, size) : (free(ptr), NULL);
|
||||
}
|
||||
void com_std_assert(bool holds) { assert(holds); }
|
||||
void com_std_printf(char const *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "../std.h"
|
||||
#include <stdarg.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
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); }
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#include "../std.h"
|
||||
|
||||
void *com_std_realloc(void *ptr, size_t size) { return NULL; }
|
||||
void com_std_free(void *ptr) {}
|
||||
void *com_std_alloc(void *ptr, size_t size) { return NULL; }
|
||||
void com_std_assert(bool holds) {}
|
||||
void com_std_printf(char const *fmt, ...) {}
|
||||
double com_std_sqrt(double v) { return 0; }
|
||||
double com_std_fabs(double v) { return 0; }
|
||||
double com_std_sin(double v) { return 0; }
|
||||
double com_std_cos(double v) { return 0; }
|
||||
|
||||
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); }
|
||||
|
||||
Reference in New Issue
Block a user