43 lines
1.4 KiB
C
43 lines
1.4 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>
|
|
|
|
/* Generic system interface, linux/bsd derived. */
|
|
typedef void *com_std_fd;
|
|
#define COM_STD_OPEN_READ (1 << 0)
|
|
#define COM_STD_OPEN_WRITE (1 << 1)
|
|
com_std_fd com_std_open(char const *path, uint32_t flags);
|
|
bool com_std_write(com_std_fd fd, void const *data, uint32_t bytes);
|
|
int32_t com_std_read(com_std_fd fd, void *data, uint32_t upto);
|
|
bool com_std_sfwd(com_std_fd fd, uint32_t bytes);
|
|
com_std_fd com_std_socket(bool isnetwork);
|
|
bool com_std_connect(com_std_fd sock, bool isnetwork, char const *address);
|
|
void com_std_exit(uint32_t status) __attribute__((noreturn));
|
|
void com_std_close(com_std_fd fd);
|
|
|
|
/* TODO: Remove, use buffer semantics instead. */
|
|
/* Instead have a mmap functions here. */
|
|
/* 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
|