diff options
Diffstat (limited to 'src/lib/include')
-rw-r--r-- | src/lib/include/assert.h | 6 | ||||
-rw-r--r-- | src/lib/include/errno.h | 7 | ||||
-rw-r--r-- | src/lib/include/locale.h | 35 | ||||
l--------- | src/lib/include/lua/lauxlib.h | 1 | ||||
l--------- | src/lib/include/lua/lua.h | 1 | ||||
l--------- | src/lib/include/lua/lua.hpp | 1 | ||||
l--------- | src/lib/include/lua/luaconf.h | 1 | ||||
l--------- | src/lib/include/lua/lualib.h | 1 | ||||
-rw-r--r-- | src/lib/include/math.h | 38 | ||||
-rw-r--r-- | src/lib/include/setjmp.h | 19 | ||||
-rw-r--r-- | src/lib/include/signal.h | 15 | ||||
-rw-r--r-- | src/lib/include/stdio.h | 85 | ||||
-rw-r--r-- | src/lib/include/stdlib.h | 29 | ||||
-rw-r--r-- | src/lib/include/time.h | 45 |
14 files changed, 279 insertions, 5 deletions
diff --git a/src/lib/include/assert.h b/src/lib/include/assert.h new file mode 100644 index 0000000..af02bb5 --- /dev/null +++ b/src/lib/include/assert.h @@ -0,0 +1,6 @@ +#pragma once + +// TODO + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/errno.h b/src/lib/include/errno.h new file mode 100644 index 0000000..254cdc0 --- /dev/null +++ b/src/lib/include/errno.h @@ -0,0 +1,7 @@ +#pragma once + + +extern int errno; + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/locale.h b/src/lib/include/locale.h new file mode 100644 index 0000000..3d5424c --- /dev/null +++ b/src/lib/include/locale.h @@ -0,0 +1,35 @@ +#pragma once + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; +struct lconv *localeconv(void); + +#define LC_ALL 1 +#define LC_COLLATE 2 +#define LC_CTYPE 3 +#define LC_MONETARY 4 +#define LC_TIME 5 +#define LC_NUMERIC 6 + +char *setlocale(int category, const char *locale); + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/lua/lauxlib.h b/src/lib/include/lua/lauxlib.h new file mode 120000 index 0000000..dbb800e --- /dev/null +++ b/src/lib/include/lua/lauxlib.h @@ -0,0 +1 @@ +../../lualib/lauxlib.h
\ No newline at end of file diff --git a/src/lib/include/lua/lua.h b/src/lib/include/lua/lua.h new file mode 120000 index 0000000..e97f648 --- /dev/null +++ b/src/lib/include/lua/lua.h @@ -0,0 +1 @@ +../../lua/lua.h
\ No newline at end of file diff --git a/src/lib/include/lua/lua.hpp b/src/lib/include/lua/lua.hpp new file mode 120000 index 0000000..22e5fad --- /dev/null +++ b/src/lib/include/lua/lua.hpp @@ -0,0 +1 @@ +../../lualib/lua.hpp
\ No newline at end of file diff --git a/src/lib/include/lua/luaconf.h b/src/lib/include/lua/luaconf.h new file mode 120000 index 0000000..2e851b6 --- /dev/null +++ b/src/lib/include/lua/luaconf.h @@ -0,0 +1 @@ +../../lua/luaconf.h
\ No newline at end of file diff --git a/src/lib/include/lua/lualib.h b/src/lib/include/lua/lualib.h new file mode 120000 index 0000000..20094b8 --- /dev/null +++ b/src/lib/include/lua/lualib.h @@ -0,0 +1 @@ +../../lualib/lualib.h
\ No newline at end of file diff --git a/src/lib/include/math.h b/src/lib/include/math.h new file mode 100644 index 0000000..64c46e7 --- /dev/null +++ b/src/lib/include/math.h @@ -0,0 +1,38 @@ +#pragma once + +// TODO + +#define INFINITY 0 + +#define NAN 0 + +#define HUGE_VAL 0 +#define HUGE_VALF 0 +#define HUGE_VALL 0 + +float fabsf(float x); + + float cosf(float x); + float sinf(float x); + float tanf(float x); + + float acosf(float x); + float asinf(float x); +float atan2f(float y, float x); + +float floorf(float x); +float ceilf(float x); +float fmodf(float x, float y); +float sqrtf(float x); +float logf(float x); +float log2f(float x); +float log10f(float x); +float expf(float x); +float frexpf(float x, int *exp); + float powf(float x, float y); + + + + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/setjmp.h b/src/lib/include/setjmp.h new file mode 100644 index 0000000..7fab8c3 --- /dev/null +++ b/src/lib/include/setjmp.h @@ -0,0 +1,19 @@ +#pragma once + +// TODO + +struct _jmp_buf { + // TODO + int a; +}; +typedef struct _jmp_buf jmp_buf; + +int setjmp(jmp_buf env); +//int sigsetjmp(sigjmp_buf env, int savesigs); + +void longjmp(jmp_buf env, int val); +//void siglongjmp(sigjmp_buf env, int val); + + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/signal.h b/src/lib/include/signal.h new file mode 100644 index 0000000..297db87 --- /dev/null +++ b/src/lib/include/signal.h @@ -0,0 +1,15 @@ +#pragma once + +// TODO + +typedef int sig_atomic_t; + +#define SIG_DFL 0 // stupid + +#define SIGINT 42 // stupid + +void (*signal(int sig, void (*func)(int)))(int); + + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/stdio.h b/src/lib/include/stdio.h index a0d741f..f46add4 100644 --- a/src/lib/include/stdio.h +++ b/src/lib/include/stdio.h @@ -6,11 +6,86 @@ extern fd_t stdio; -void putchar(int c); -void puts(char* s); -void printf(char* arg, ...); - -int getchar(); +// CUSTOM! void getline(char* buf, size_t l); + +//TODO below +struct file_t { + fd_t fd; +}; +typedef struct file_t FILE; + + +int fgetc(FILE *stream); +char *fgets(char *s, int size, FILE *stream); +int getc(FILE *stream); +int getchar(void); +int ungetc(int c, FILE *stream); + +int fputc(int c, FILE *stream); +int fputs(const char *s, FILE *stream); +int putc(int c, FILE *stream); +int putchar(int c); +int puts(const char *s); + +FILE *fopen(const char *path, const char *mode); +FILE *freopen(const char *path, const char *mode, FILE *stream); + +void clearerr(FILE *stream); +int feof(FILE *stream); +int ferror(FILE *stream); +int fileno(FILE *stream); + + +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); +size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); + +int fflush(FILE* f); +int fclose(FILE* f); + +#define EOF ((int)-1) + +extern FILE *stdin, *stdout, *stderr; + +#define BUFSIZ 0 +void setbuf(FILE *stream, char *buf); +void setbuffer(FILE *stream, char *buf, size_t size); +void setlinebuf(FILE *stream); +int setvbuf(FILE *stream, char *buf, int mode, size_t size); + +#define _IOFBF 0 +#define _IOLBF 1 +#define _IONBF 2 + +typedef size_t fpos_t; //TODO + +int fseek(FILE *stream, long offset, int whence); +long ftell(FILE *stream); +void rewind(FILE *stream); +int fgetpos(FILE *stream, fpos_t *pos); +int fsetpos(FILE *stream, const fpos_t *pos); + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define L_tmpnam 12 +FILE *tmpfile(void); +char *tmpnam(char *s); + +int rename(const char *old, const char *new); +int remove(const char *pathname); + + + + + +int printf(const char *format, ...); +int fprintf(FILE *stream, const char *format, ...); +int dprintf(int fd, const char *format, ...); +int sprintf(char *str, const char *format, ...); +int snprintf(char *str, size_t size, const char *format, ...); + + /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/stdlib.h b/src/lib/include/stdlib.h new file mode 100644 index 0000000..29d8661 --- /dev/null +++ b/src/lib/include/stdlib.h @@ -0,0 +1,29 @@ +#pragma once + +#include "malloc.h" + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 255 + +int rand(void); +//int rand_r(unsigned int *seedp); +void srand(unsigned int seed); + +#define RAND_MAX 1 + +void abort() __attribute__((__noreturn__)); + + +double strtod(const char *nptr, char **endptr); +float strtof(const char *nptr, char **endptr); +long double strtold(const char *nptr, char **endptr); + +char *getenv(const char *name); + +int system(const char *command); + +int abs(int j); + + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/time.h b/src/lib/include/time.h new file mode 100644 index 0000000..6529c9a --- /dev/null +++ b/src/lib/include/time.h @@ -0,0 +1,45 @@ +#pragma once + +// TODO + +struct tm { + int tm_sec; // Seconds [0,60]. + int tm_min; // Minutes [0,59]. + int tm_hour; // Hour [0,23]. + int tm_mday; // Day of month [1,31]. + int tm_mon; // Month of year [0,11]. + int tm_year; // Years since 1900. + int tm_wday; // Day of week [0,6] (Sunday =0). + int tm_yday; // Day of year [0,365]. + int tm_isdst; // Daylight Savings flag. +}; + +typedef int64_t time_t; + +time_t time(time_t*); +double difftime(time_t time1, time_t time0); + +char *asctime(const struct tm *tm); +char *asctime_r(const struct tm *tm, char *buf); + +char *ctime(const time_t *timep); +char *ctime_r(const time_t *timep, char *buf); + +struct tm *gmtime(const time_t *timep); +struct tm *gmtime_r(const time_t *timep, struct tm *result); + +struct tm *localtime(const time_t *timep); +struct tm *localtime_r(const time_t *timep, struct tm *result); + +time_t mktime(struct tm *tm); + +size_t strftime(char *s, size_t max, const char *format, const struct tm *tm); + + +#define CLOCKS_PER_SEC 1 +typedef int clock_t; +clock_t clock(void); + + + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ |