43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
/*
|
|
Minimal subset of stdlib, none of which have to be actually implemented,
|
|
even memory mnagement.
|
|
*/
|
|
|
|
#ifndef COM_STD_H
|
|
#define COM_STD_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#if COM_DEF_TARGET == COM_DEF_TARGET_LINUX
|
|
#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;
|
|
}
|
|
#endif
|
|
|
|
/* TODO: Remove, use buffer semantics instead. */
|
|
/* Note: Freeing is done by passing 0 size to pointer. */
|
|
void *com_std_alloc(void *ptr, size_t size);
|
|
|
|
/* Note: Functions listed below are only available for dev builds. */
|
|
/* Trigonometry functions are for reference testing of our own fixed point
|
|
* implementations. Do not use otherwise. */
|
|
void com_std_assert(bool holds);
|
|
void com_std_printf(char const *fmt, ...);
|
|
void com_std_print_str(char const *str, uint32_t len, bool newline);
|
|
double com_std_sqrt(double v);
|
|
double com_std_fabs(double v);
|
|
double com_std_sin(double v);
|
|
double com_std_cos(double v);
|
|
|
|
#endif
|