mirror of https://github.com/flysand7/ciabatta.git
Filled in the headers
This commit is contained in:
parent
f8aef19b5c
commit
7611f8bda4
|
@ -1,5 +1,13 @@
|
|||
#if !defined(_platform_h)
|
||||
#define _platform_h
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Microsoft uses this to refer to the secure functions so we'll allow it
|
||||
#ifdef __STDC_WANT_SECURE_LIB__
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#endif
|
||||
|
||||
#ifdef
|
||||
|
||||
// Compiler Identification
|
||||
|
||||
|
@ -15,8 +23,13 @@
|
|||
#define _compiler_clang
|
||||
#endif
|
||||
|
||||
#if defined(__CUIKC__)
|
||||
#define _compiler_cuik
|
||||
#endif
|
||||
|
||||
#if !(defined(_compiler_msvc) \
|
||||
|| defined(_compiler_gnu) \
|
||||
|| defined(_compiler_cuik) \
|
||||
|| defined(_compiler_clang))
|
||||
#error "Unsupported Compiler"
|
||||
#endif
|
||||
|
@ -44,4 +57,9 @@
|
|||
#error "Unsupported OS"
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
typedef int errno_t;
|
||||
typedef size_t rsize_t;
|
||||
#endif
|
||||
|
||||
#endif
|
16
inc/ctype.h
16
inc/ctype.h
|
@ -0,0 +1,16 @@
|
|||
#include "_platform.h"
|
||||
|
||||
int isalnum(int c);
|
||||
int isalpha(int c);
|
||||
int isblank(int c);
|
||||
int iscntrl(int c);
|
||||
int isdigit(int c);
|
||||
int isgraph(int c);
|
||||
int islower(int c);
|
||||
int isprint(int c);
|
||||
int ispunct(int c);
|
||||
int isspace(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
int tolower(int c);
|
||||
int toupper(int c);
|
|
@ -0,0 +1,8 @@
|
|||
#include "_platform.h"
|
||||
|
||||
#define EDOM 1
|
||||
#define EILSEQ 2
|
||||
#define ERANGE 3
|
||||
|
||||
// TODO: implement this
|
||||
#define errno 0
|
23
inc/fenv.h
23
inc/fenv.h
|
@ -0,0 +1,23 @@
|
|||
typedef unsigned long fexcept_t;
|
||||
typedef struct fenv_t fenv_t;
|
||||
|
||||
#define FE_DIVBYZERO 0x04
|
||||
#define FE_INEXACT 0x20
|
||||
#define FE_INVALID 0x01
|
||||
#define FE_OVERFLOW 0x08
|
||||
#define FE_UNDERFLOW 0x10
|
||||
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
|
||||
|
||||
#define FE_TONEAREST 0x000
|
||||
#define FE_UPWARD 0x200
|
||||
#define FE_DOWNWARD 0x100
|
||||
#define FE_TOWARDZERO 0x300
|
||||
|
||||
// TODO: implement this
|
||||
#define FE_DFL_ENV ((fenv_t*)0)
|
||||
|
||||
int feclearexcept(int excepts);
|
||||
int fegetexceptflag(fexcept_t *flagp, int excepts);
|
||||
int feraiseexcept(int excepts);
|
||||
int fesetexceptflag(const fexcept_t *flagp, int excepts);
|
||||
int fetestexcept(int excepts);
|
39
inc/locale.h
39
inc/locale.h
|
@ -0,0 +1,39 @@
|
|||
#include "_platform.h"
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point; // "."
|
||||
char *thousands_sep; // ""
|
||||
char *grouping; // ""
|
||||
char *mon_decimal_point; // ""
|
||||
char *mon_thousands_sep; // ""
|
||||
char *mon_grouping; // ""
|
||||
char *positive_sign; // ""
|
||||
char *negative_sign; // ""
|
||||
char *currency_symbol; // ""
|
||||
char frac_digits; // CHAR_MAX
|
||||
char p_cs_precedes; // CHAR_MAX
|
||||
char n_cs_precedes; // CHAR_MAX
|
||||
char p_sep_by_space; // CHAR_MAX
|
||||
char n_sep_by_space; // CHAR_MAX
|
||||
char p_sign_posn; // CHAR_MAX
|
||||
char n_sign_posn; // CHAR_MAX
|
||||
char *int_curr_symbol; // ""
|
||||
char int_frac_digits; // CHAR_MAX
|
||||
char int_p_cs_precedes; // CHAR_MAX
|
||||
char int_n_cs_precedes; // CHAR_MAX
|
||||
char int_p_sep_by_space; // CHAR_MAX
|
||||
char int_n_sep_by_space; // CHAR_MAX
|
||||
char int_p_sign_posn; // CHAR_MAX
|
||||
char int_n_sign_posn; // CHAR_MAX
|
||||
};
|
||||
|
||||
// Locale categories
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
|
||||
char *setlocale(int category, const char *locale);
|
||||
struct lconv *localeconv(void);
|
227
inc/math.h
227
inc/math.h
|
@ -0,0 +1,227 @@
|
|||
#include "_platform.h"
|
||||
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
|
||||
#ifndef _HUGE_ENUF
|
||||
#define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow
|
||||
#endif
|
||||
|
||||
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
#define HUGE_VAL ((double)INFINITY)
|
||||
#define HUGE_VALF ((float)INFINITY)
|
||||
#define HUGE_VALL ((long double)INFINITY)
|
||||
|
||||
// Positive NaN
|
||||
#define NAN (-(float)(INFINITY * 0.0F))
|
||||
|
||||
#define FP_SUBNORMAL (-2)
|
||||
#define FP_NORMAL (-1)
|
||||
#define FP_ZERO 0
|
||||
#define FP_INFINITE 1
|
||||
#define FP_NAN 2
|
||||
|
||||
FP_INFINITE
|
||||
FP_NAN
|
||||
FP_NORMAL
|
||||
FP_SUBNORMAL
|
||||
FP_ZERO
|
||||
#define FP_FAST_FMA 1
|
||||
#define FP_FAST_FMAF 1
|
||||
#define FP_FAST_FMAL 1
|
||||
|
||||
#define FP_ILOGB0 (-0x7FFFFFFFu - 1u)
|
||||
#define FP_ILOGBNAN 0x7FFFFFFFu
|
||||
|
||||
#define MATH_ERRNO 1
|
||||
#define MATH_ERREXCEPT 2
|
||||
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
|
||||
|
||||
// TODO: implement this
|
||||
#define fpclassify(x) 0
|
||||
#define isfinite(x) 0
|
||||
#define isinf(x) 0
|
||||
#define isnan(x) 0
|
||||
#define isnormal(x) 0
|
||||
#define signbit(x) 0
|
||||
|
||||
// TODO: implement this, search it up, they're a bit different semantics than
|
||||
// the names might suggest
|
||||
#define isgreater(x, y) 0
|
||||
#define isgreaterequal(x, y) 0
|
||||
#define isless(x, y) 0
|
||||
#define islessequal(x, y) 0
|
||||
#define islessgreater(x, y) 0
|
||||
#define isunordered(x, y) 0
|
||||
|
||||
double acos(double x);
|
||||
float acosf(float x);
|
||||
long double acosl(long double x);
|
||||
double asin(double x);
|
||||
float asinf(float x);
|
||||
long double asinl(long double x);
|
||||
double atan(double x);
|
||||
float atanf(float x);
|
||||
long double atanl(long double x);
|
||||
double atan2(double y, double x);
|
||||
float atan2f(float y, float x);
|
||||
long double atan2l(long double y, long double x);
|
||||
double cos(double x);
|
||||
float cosf(float x);
|
||||
long double cosl(long double x);
|
||||
double sin(double x);
|
||||
float sinf(float x);
|
||||
long double sinl(long double x);
|
||||
double tan(double x);
|
||||
float tanf(float x);
|
||||
long double tanl(long double x);
|
||||
double acosh(double x);
|
||||
float acoshf(float x);
|
||||
long double acoshl(long double x);
|
||||
double asinh(double x);
|
||||
float asinhf(float x);
|
||||
long double asinhl(long double x);
|
||||
double atanh(double x);
|
||||
float atanhf(float x);
|
||||
long double atanhl(long double x);
|
||||
double cosh(double x);
|
||||
float coshf(float x);
|
||||
long double coshl(long double x);
|
||||
double sinh(double x);
|
||||
float sinhf(float x);
|
||||
long double sinhl(long double x);
|
||||
double tanh(double x);
|
||||
float tanhf(float x);
|
||||
long double tanhl(long double x);
|
||||
double exp(double x);
|
||||
float expf(float x);
|
||||
long double expl(long double x);
|
||||
double exp2(double x);
|
||||
float exp2f(float x);
|
||||
long double exp2l(long double x);
|
||||
double expm1(double x);
|
||||
float expm1f(float x);
|
||||
long double expm1l(long double x);
|
||||
double frexp(double value, int *exp);
|
||||
float frexpf(float value, int *exp);
|
||||
long double frexpl(long double value, int *exp);
|
||||
int ilogb(double x);
|
||||
int ilogbf(float x);
|
||||
int ilogbl(long double x);
|
||||
double ldexp(double x, int exp);
|
||||
float ldexpf(float x, int exp);
|
||||
long double ldexpl(long double x, int exp);
|
||||
double log(double x);
|
||||
float logf(float x);
|
||||
long double logl(long double x);
|
||||
double log10(double x);
|
||||
float log10f(float x);
|
||||
long double log10l(long double x);
|
||||
double log1p(double x);
|
||||
float log1pf(float x);
|
||||
long double log1pl(long double x);
|
||||
double log2(double x);
|
||||
float log2f(float x);
|
||||
long double log2l(long double x);
|
||||
double logb(double x);
|
||||
float logbf(float x);
|
||||
long double logbl(long double x);
|
||||
double modf(double value, double *iptr);
|
||||
float modff(float value, float *iptr);
|
||||
long double modfl(long double value, long double *iptr);
|
||||
double scalbn(double x, int n);
|
||||
float scalbnf(float x, int n);
|
||||
long double scalbnl(long double x, int n);
|
||||
double scalbln(double x, long int n);
|
||||
float scalblnf(float x, long int n);
|
||||
long double scalblnl(long double x, long int n);
|
||||
double cbrt(double x);
|
||||
float cbrtf(float x);
|
||||
long double cbrtl(long double x);
|
||||
double fabs(double x);
|
||||
float fabsf(float x);
|
||||
long double fabsl(long double x);
|
||||
double hypot(double x, double y);
|
||||
float hypotf(float x, float y);
|
||||
long double hypotl(long double x, long double y);
|
||||
double pow(double x, double y);
|
||||
float powf(float x, float y);
|
||||
long double powl(long double x, long double y);
|
||||
double sqrt(double x);
|
||||
float sqrtf(float x);
|
||||
long double sqrtl(long double x);
|
||||
double erf(double x);
|
||||
float erff(float x);
|
||||
long double erfl(long double x);
|
||||
double erfc(double x);
|
||||
float erfcf(float x);
|
||||
long double erfcl(long double x);
|
||||
double lgamma(double x);
|
||||
float lgammaf(float x);
|
||||
long double lgammal(long double x);
|
||||
double tgamma(double x);
|
||||
float tgammaf(float x);
|
||||
long double tgammal(long double x);
|
||||
double ceil(double x);
|
||||
float ceilf(float x);
|
||||
long double ceill(long double x);
|
||||
double floor(double x);
|
||||
float floorf(float x);
|
||||
long double floorl(long double x);
|
||||
double nearbyint(double x);
|
||||
float nearbyintf(float x);
|
||||
long double nearbyintl(long double x);
|
||||
double rint(double x);
|
||||
float rintf(float x);
|
||||
long double rintl(long double x);
|
||||
long int lrint(double x);
|
||||
long int lrintf(float x);
|
||||
long int lrintl(long double x);
|
||||
long long int llrint(double x);
|
||||
long long int llrintf(float x);
|
||||
long long int llrintl(long double x);
|
||||
double round(double x);
|
||||
float roundf(float x);
|
||||
long double roundl(long double x);
|
||||
long int lround(double x);
|
||||
long int lroundf(float x);
|
||||
long int lroundl(long double x);
|
||||
long long int llround(double x);
|
||||
long long int llroundf(float x);
|
||||
long long int llroundl(long double x);
|
||||
double trunc(double x);
|
||||
float truncf(float x);
|
||||
long double truncl(long double x);
|
||||
double fmod(double x, double y);
|
||||
float fmodf(float x, float y);
|
||||
long double fmodl(long double x, long double y);
|
||||
double remainder(double x, double y);
|
||||
float remainderf(float x, float y);
|
||||
long double remainderl(long double x, long double y);
|
||||
double remquo(double x, double y, int *quo);
|
||||
float remquof(float x, float y, int *quo);
|
||||
long double remquol(long double x, long double y, int *quo);
|
||||
double copysign(double x, double y);
|
||||
float copysignf(float x, float y);
|
||||
long double copysignl(long double x, long double y);
|
||||
double nan(const char *tagp);
|
||||
float nanf(const char *tagp);
|
||||
long double nanl(const char *tagp);
|
||||
double nextafter(double x, double y);
|
||||
float nextafterf(float x, float y);
|
||||
long double nextafterl(long double x, long double y);
|
||||
double nexttoward(double x, long double y);
|
||||
float nexttowardf(float x, long double y);
|
||||
long double nexttowardl(long double x, long double y);
|
||||
double fdim(double x, double y);
|
||||
float fdimf(float x, float y);
|
||||
long double fdiml(long double x, long double y);
|
||||
double fmax(double x, double y);
|
||||
float fmaxf(float x, float y);
|
||||
long double fmaxl(long double x, long double y);
|
||||
double fmin(double x, double y);
|
||||
float fminf(float x, float y);
|
||||
long double fminl(long double x, long double y);
|
||||
double fma(double x, double y, double z);
|
||||
float fmaf(float x, float y, float z);
|
||||
long double fmal(long double x, long double y, long double z);
|
20
inc/signal.h
20
inc/signal.h
|
@ -0,0 +1,20 @@
|
|||
#include "_platform.h"
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
// TODO: implement this
|
||||
#define SIG_DFL (-1)
|
||||
#define SIG_ERR (-1)
|
||||
#define SIG_IGN (-1)
|
||||
|
||||
// not sure why but windows picked these, we can change it later
|
||||
#define SIGINT 2
|
||||
#define SIGILL 4
|
||||
#define SIGFPE 8
|
||||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
#define SIGBREAK 21
|
||||
#define SIGABRT 22
|
||||
|
||||
void (*signal(int sig, void (*func)(int)))(int);
|
||||
int raise(int sig);
|
85
inc/stdio.h
85
inc/stdio.h
|
@ -1,4 +1,87 @@
|
|||
#include "_platform.h"
|
||||
|
||||
#define EOF -1
|
||||
typedef struct FILE FILE;
|
||||
typedef int64_t fpos_t;
|
||||
|
||||
#define _IOFBF 0x0000
|
||||
#define _IOLBF 0x0040
|
||||
#define _IONBF 0x0004
|
||||
|
||||
#define BUFSIZ 512
|
||||
|
||||
#define EOF (-1)
|
||||
|
||||
#define FOPEN_MAX 20
|
||||
|
||||
#ifdef _os_win
|
||||
#define FILENAME_MAX 260
|
||||
#else
|
||||
#define FILENAME_MAX 4096
|
||||
#endif
|
||||
|
||||
#define L_tmpnam FILENAME_MAX
|
||||
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#define SEEK_SET 0
|
||||
|
||||
#define TMP_MAX INT_MAX
|
||||
|
||||
// TODO: complete these, they don't need to be macros btw, could be external globals
|
||||
#define stderr ((FILE*)NULL)
|
||||
#define stdin ((FILE*)NULL)
|
||||
#define stdout ((FILE*)NULL)
|
||||
|
||||
int remove(const char *filename);
|
||||
int rename(const char *oldname, const char *newname);
|
||||
FILE *tmpfile(void);
|
||||
char *tmpnam(char *s);
|
||||
int fclose(FILE *stream);
|
||||
int fflush(FILE *stream);
|
||||
FILE *fopen(const char * restrict filename, const char * restrict mode);
|
||||
FILE *freopen(const char * restrict filename, const char * restrict mode, FILE * restrict stream);
|
||||
void setbuf(FILE * restrict stream, char * restrict buf);
|
||||
int setvbuf(FILE * restrict stream, char * restrict buf, int mode, size_t size);
|
||||
int fprintf(FILE * restrict stream, const char * restrict format, ...);
|
||||
int fscanf(FILE * restrict stream, const char * restrict format, ...);
|
||||
int printf(const char * restrict format, ...);
|
||||
int scanf(const char * restrict format, ...);
|
||||
int snprintf(char * restrict s, size_t n, const char * restrict format, ...);
|
||||
int sprintf(char * restrict s, const char * restrict format, ...);
|
||||
int sscanf(const char * restrict s, const char * restrict format, ...);
|
||||
int vfprintf(FILE * restrict stream, const char * restrict format, va_list arg);
|
||||
int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg);
|
||||
int vprintf(const char * restrict format, va_list arg);
|
||||
int vscanf(const char * restrict format, va_list arg);
|
||||
int vsnprintf(char * restrict s, size_t n, const char * restrict format, va_list arg);
|
||||
int vsprintf(char * restrict s, const char * restrict format, va_list arg);
|
||||
int vsscanf(const char * restrict s, const char * restrict format, va_list arg);
|
||||
int fgetc(FILE *stream);
|
||||
char *fgets(char * restrict s, int n, FILE * restrict stream);
|
||||
int fputc(int c, FILE *stream);
|
||||
int fputs(const char * restrict s, FILE * restrict stream);
|
||||
int getc(FILE *stream);
|
||||
int getchar(void);
|
||||
int putc(int c, FILE *stream);
|
||||
int putchar(int c);
|
||||
int puts(const char *s);
|
||||
int ungetc(int c, FILE *stream);
|
||||
size_t fread(void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream);
|
||||
size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream);
|
||||
int fgetpos(FILE * restrict stream, fpos_t * restrict pos);
|
||||
int fseek(FILE *stream, long int offset, int whence);
|
||||
int fsetpos(FILE *stream, const fpos_t *pos);
|
||||
long int ftell(FILE *stream);
|
||||
void rewind(FILE *stream);
|
||||
void clearerr(FILE *stream);
|
||||
int feof(FILE *stream);
|
||||
int ferror(FILE *stream);
|
||||
void perror(const char *s);
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
#define L_tmpnam_s L_tmpnam
|
||||
#define TMP_MAX_S TMP_MAX
|
||||
|
||||
errno_t tmpfile_s(FILE * restrict * restrict streamptr);
|
||||
errno_t tmpnam_s(char *s, rsize_t maxsize);
|
||||
#endif
|
||||
|
|
71
inc/stdlib.h
71
inc/stdlib.h
|
@ -1,2 +1,71 @@
|
|||
#include "_platform.h"
|
||||
|
||||
#define NULL ((void *)0)
|
||||
typedef struct div_t {
|
||||
int quot;
|
||||
int rem;
|
||||
} div_t;
|
||||
|
||||
typedef struct ldiv_t {
|
||||
long quot;
|
||||
long rem;
|
||||
} ldiv_t;
|
||||
|
||||
typedef struct lldiv_t {
|
||||
long long quot;
|
||||
long long rem;
|
||||
} lldiv_t;
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
#define RAND_MAX 65536
|
||||
#define MB_CUR_MAX 5
|
||||
|
||||
double atof(const char *nptr);
|
||||
int atoi(const char *nptr);
|
||||
long int atol(const char *nptr);
|
||||
long long int atoll(const char *nptr);
|
||||
double strtod(const char * restrict nptr, char ** restrict endptr);
|
||||
float strtof(const char * restrict nptr, char ** restrict endptr);
|
||||
long double strtold(const char * restrict nptr, char ** restrict endptr);
|
||||
long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
long long int strtoll(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
unsigned long long int strtoull(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
int rand(void);
|
||||
void srand(unsigned int seed);
|
||||
void *aligned_alloc(size_t alignment, size_t size);
|
||||
void *calloc(size_t nmemb, size_t size);
|
||||
void free(void *ptr);
|
||||
void *malloc(size_t size);
|
||||
void *realloc(void *ptr, size_t size);
|
||||
_Noreturn void abort(void);
|
||||
int atexit(void (*func)(void));
|
||||
int at_quick_exit(void (*func)(void));
|
||||
_Noreturn void exit(int status);
|
||||
_Noreturn void _Exit(int status);
|
||||
char *getenv(const char *name);
|
||||
_Noreturn void quick_exit(int status);
|
||||
int system(const char *string);
|
||||
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
|
||||
void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
|
||||
int abs(int j);
|
||||
long int labs(long int j);
|
||||
long long int llabs(long long int j);
|
||||
div_t div(int numer, int denom);
|
||||
ldiv_t ldiv(long int numer, long int denom);
|
||||
lldiv_t lldiv(long long int numer, long long int denom);
|
||||
int mblen(const char *s, size_t n);
|
||||
int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n);
|
||||
int wctomb(char *s, wchar_t wchar);
|
||||
size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n);
|
||||
size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n);
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
typedef void (*constraint_handler_t)(const char * restrict msg, void * restrict ptr, errno_t error);
|
||||
|
||||
constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);
|
||||
void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error);
|
||||
void ignore_handler_s(const char * restrict msg, void * restrict ptr, errno_t error);
|
||||
errno_t getenv_s(size_t * restrict len, char * restrict value, rsize_t maxsize, const char * restrict name);
|
||||
#endif
|
||||
|
|
41
inc/string.h
41
inc/string.h
|
@ -0,0 +1,41 @@
|
|||
#include "_platform.h"
|
||||
|
||||
void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
|
||||
void *memmove(void *s1, const void *s2, size_t n);
|
||||
char *strcpy(char * restrict s1, const char * restrict s2);
|
||||
char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
|
||||
char *strcat(char * restrict s1, const char * restrict s2);
|
||||
char *strncat(char * restrict s1, const char * restrict s2, size_t n);
|
||||
int memcmp(const void *s1, const void *s2, size_t n);
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
int strcoll(const char *s1, const char *s2);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n);
|
||||
void *memchr(const void *s, int c, size_t n);
|
||||
char *strchr(const char *s, int c);
|
||||
size_t strcspn(const char *s1, const char *s2);
|
||||
char *strpbrk(const char *s1, const char *s2);
|
||||
char *strrchr(const char *s, int c);
|
||||
size_t strspn(const char *s1, const char *s2);
|
||||
char *strstr(const char *s1, const char *s2);
|
||||
char *strtok(char * restrict s1, const char * restrict s2);
|
||||
void *memset(void *s, int c, size_t n);
|
||||
char *strerror(int errnum);
|
||||
size_t strlen(const char *s);
|
||||
|
||||
#if __STDC_WANT_LIB_EXT1__
|
||||
errno_t memcpy_s(void * restrict s1, rsize_t s1max, const void * restrict s2, rsize_t n);
|
||||
errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n);
|
||||
errno_t strcpy_s(char * restrict s1, rsize_t s1max, const char * restrict s2);
|
||||
errno_t strncpy_s(char * restrict s1, rsize_t s1max,
|
||||
const char * restrict s2, rsize_t n);
|
||||
errno_t strcat_s(char * restrict s1, rsize_t s1max, const char * restrict s2);
|
||||
errno_t strncat_s(char * restrict s1, rsize_t s1max,
|
||||
const char * restrict s2, rsize_t n);
|
||||
char *strtok_s(char * restrict s1, rsize_t * restrict s1max,
|
||||
const char * restrict s2, char ** restrict ptr);
|
||||
errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n);
|
||||
errno_t strerror_s(char *s, rsize_t maxsize, errno_t errnum);
|
||||
size_t strerrorlen_s(errno_t errnum);
|
||||
size_t strnlen_s(const char *s, size_t maxsize);
|
||||
#endif
|
64
inc/tgmath.h
64
inc/tgmath.h
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
these are type generic so they're macrod and use C11's _Generic
|
||||
|
||||
acos
|
||||
asin
|
||||
atan
|
||||
acosh
|
||||
asinh
|
||||
atanh
|
||||
cos
|
||||
sin
|
||||
tan
|
||||
cosh
|
||||
sinh
|
||||
tanh
|
||||
exp
|
||||
log
|
||||
pow
|
||||
sqrt
|
||||
fabs
|
||||
atan2
|
||||
cbrt
|
||||
ceil
|
||||
copysign
|
||||
erf
|
||||
erfc
|
||||
exp2
|
||||
expm1
|
||||
fdim
|
||||
floor
|
||||
fma
|
||||
fmax
|
||||
fmin
|
||||
fmod
|
||||
frexp
|
||||
hypot
|
||||
ilogb
|
||||
ldexp
|
||||
lgamma
|
||||
llrint
|
||||
llround
|
||||
log10
|
||||
log1p
|
||||
log2
|
||||
logb
|
||||
lrint
|
||||
lround
|
||||
nearbyint
|
||||
nextafter
|
||||
nexttoward
|
||||
remainder
|
||||
remquo
|
||||
rint
|
||||
round
|
||||
scalbn
|
||||
scalbln
|
||||
tgamma
|
||||
trunc
|
||||
carg
|
||||
cimag
|
||||
conj
|
||||
cproj
|
||||
creal
|
||||
*/
|
|
@ -0,0 +1,68 @@
|
|||
#include "_platform.h"
|
||||
|
||||
#define thread_local _Thread_local
|
||||
#define ONCE_FLAG_INIT 1
|
||||
|
||||
#define TSS_DTOR_ITERATIONS 32
|
||||
|
||||
typedef struct cnd_t {
|
||||
int idk_yet;
|
||||
} cnd_t;
|
||||
|
||||
typedef struct thrd_t {
|
||||
int idk_yet;
|
||||
} thrd_t;
|
||||
|
||||
typedef struct tss_t {
|
||||
int idk_yet;
|
||||
} tss_t;
|
||||
|
||||
typedef struct mtx_t {
|
||||
int idk_yet;
|
||||
} mtx_t;
|
||||
|
||||
typedef void(*tss_dtor_t)(void*);
|
||||
typedef int(*thrd_start_t)(void*);
|
||||
|
||||
// TODO: change this maybe?
|
||||
typedef int once_flag;
|
||||
|
||||
enum {
|
||||
mtx_plain = 1,
|
||||
mtx_recursive = 2,
|
||||
mtx_timed = 4
|
||||
};
|
||||
|
||||
enum {
|
||||
thrd_success,
|
||||
thrd_timedout,
|
||||
thrd_busy,
|
||||
thrd_error,
|
||||
thrd_nomem
|
||||
};
|
||||
|
||||
void call_once(once_flag *flag, void (*func)(void));
|
||||
int cnd_broadcast(cnd_t *cond);
|
||||
void cnd_destroy(cnd_t *cond);
|
||||
int cnd_init(cnd_t *cond);
|
||||
int cnd_signal(cnd_t *cond);
|
||||
int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, const struct timespec *restrict ts);
|
||||
int cnd_wait(cnd_t *cond, mtx_t *mtx);
|
||||
void mtx_destroy(mtx_t *mtx);
|
||||
int mtx_init(mtx_t *mtx, int type);
|
||||
int mtx_lock(mtx_t *mtx);
|
||||
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts);
|
||||
int mtx_trylock(mtx_t *mtx);
|
||||
int mtx_unlock(mtx_t *mtx);
|
||||
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
|
||||
thrd_t thrd_current(void);
|
||||
int thrd_detach(thrd_t thr);
|
||||
int thrd_equal(thrd_t thr0, thrd_t thr1);
|
||||
_Noreturn void thrd_exit(int res);
|
||||
int thrd_join(thrd_t thr, int *res);
|
||||
int thrd_sleep(const struct timespec *duration, struct timespec *remaining);
|
||||
void thrd_yield(void);
|
||||
int tss_create(tss_t *key, tss_dtor_t dtor);
|
||||
void tss_delete(tss_t key);
|
||||
void *tss_get(tss_t key);
|
||||
int tss_set(tss_t key, void *val);
|
40
inc/time.h
40
inc/time.h
|
@ -0,0 +1,40 @@
|
|||
#include "_platform.h"
|
||||
|
||||
// The number of clock ticks per second
|
||||
#define CLOCKS_PER_SEC ((clock_t)1000)
|
||||
#define TIME_UTC 1
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec; // Seconds - >= 0
|
||||
long tv_nsec; // Nanoseconds - [0, 999999999]
|
||||
};
|
||||
|
||||
struct tm {
|
||||
int tm_sec; // seconds after the minute - [0, 60] including leap second
|
||||
int tm_min; // minutes after the hour - [0, 59]
|
||||
int tm_hour; // hours since midnight - [0, 23]
|
||||
int tm_mday; // day of the month - [1, 31]
|
||||
int tm_mon; // months since January - [0, 11]
|
||||
int tm_year; // years since 1900
|
||||
int tm_wday; // days since Sunday - [0, 6]
|
||||
int tm_yday; // days since January 1 - [0, 365]
|
||||
int tm_isdst; // daylight savings time flag
|
||||
};
|
||||
|
||||
clock_t clock(void);
|
||||
double difftime(time_t time1, time_t time0);
|
||||
time_t mktime(struct tm *timeptr);
|
||||
time_t time(time_t *timer);
|
||||
int timespec_get(timespec *ts, int base);
|
||||
char *asctime(const struct tm *timeptr);
|
||||
char *ctime(const time_t *timer);
|
||||
struct tm *gmtime(const time_t *timer);
|
||||
struct tm *localtime(const time_t *timer);
|
||||
size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, const struct tm * restrict timeptr);
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
errno_t asctime_s(char *s, rsize_t maxsize, const struct tm *timeptr);
|
||||
errno_t ctime_s(char *s, rsize_t maxsize, const time_t *timer);
|
||||
struct tm *gmtime_s(const time_t * restrict timer, struct tm * restrict result);
|
||||
struct tm *localtime_s(const time_t * restrict timer, struct tm * restrict result);
|
||||
#endif
|
10
inc/uchar.h
10
inc/uchar.h
|
@ -0,0 +1,10 @@
|
|||
#include "_platform.h"
|
||||
|
||||
typedef struct mbstate_t mbstate_t;
|
||||
typedef uint16_t char16_t;
|
||||
typedef uint32_t char32_t;
|
||||
|
||||
size_t mbrtoc16(char16_t * restrict pc16, const char * restrict s, size_t n, mbstate_t * restrict ps);
|
||||
size_t c16rtomb(char * restrict s, char16_t c16, mbstate_t * restrict ps);
|
||||
size_t mbrtoc32(char32_t * restrict pc32, const char * restrict s, size_t n, mbstate_t * restrict ps);
|
||||
size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps);
|
104
inc/wchar.h
104
inc/wchar.h
|
@ -0,0 +1,104 @@
|
|||
// On linux this will be UTF-32, on windows it's UTF-16
|
||||
#include "_platform.h"
|
||||
|
||||
typedef struct mbstate_t mbstate_t;
|
||||
typedef wchar_t wint_t;
|
||||
|
||||
#define WCHAR_MIN 0x0000
|
||||
#define WCHAR_MAX 0xffff
|
||||
|
||||
#ifndef WEOF
|
||||
#define WEOF 0
|
||||
#endif
|
||||
|
||||
int fwprintf(FILE * restrict stream, const wchar_t * restrict format, ...);
|
||||
int fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...);
|
||||
int swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...);
|
||||
int swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...);
|
||||
int vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list arg);
|
||||
int vfwscanf(FILE * restrict stream, const wchar_t * restrict format, va_list arg);
|
||||
int vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg);
|
||||
int vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg);
|
||||
int vwprintf(const wchar_t * restrict format, va_list arg);
|
||||
int vwscanf(const wchar_t * restrict format, va_list arg);
|
||||
int wprintf(const wchar_t * restrict format, ...);
|
||||
int wscanf(const wchar_t * restrict format, ...);
|
||||
wint_t fgetwc(FILE *stream);
|
||||
wchar_t *fgetws(wchar_t * restrict s, int n, FILE * restrict stream);
|
||||
wint_t fputwc(wchar_t c, FILE *stream);
|
||||
int fputws(const wchar_t * restrict s,
|
||||
FILE * restrict stream);
|
||||
int fwide(FILE *stream, int mode);
|
||||
wint_t getwc(FILE *stream);
|
||||
wint_t getwchar(void);
|
||||
wint_t putwc(wchar_t c, FILE *stream);
|
||||
wint_t putwchar(wchar_t c);
|
||||
wint_t ungetwc(wint_t c, FILE *stream);
|
||||
double wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr);
|
||||
float wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr);
|
||||
long double wcstold(const wchar_t * restrict nptr, wchar_t ** restrict endptr);
|
||||
long int wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
|
||||
long long int wcstoll(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
|
||||
unsigned long int wcstoul(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
|
||||
unsigned long long int wcstoull(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
|
||||
wchar_t *wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2);
|
||||
wchar_t *wcsncpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);
|
||||
wchar_t *wmemcpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);
|
||||
wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n);
|
||||
wchar_t *wcscat(wchar_t * restrict s1, const wchar_t * restrict s2);
|
||||
wchar_t *wcsncat(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);
|
||||
int wcscmp(const wchar_t *s1, const wchar_t *s2);
|
||||
int wcscoll(const wchar_t *s1, const wchar_t *s2);
|
||||
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
|
||||
size_t wcsxfrm(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);
|
||||
int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
|
||||
wchar_t *wcschr(const wchar_t *s, wchar_t c);
|
||||
size_t wcscspn(const wchar_t *s1, const wchar_t *s2);
|
||||
wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);
|
||||
wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
|
||||
size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
|
||||
wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);
|
||||
wchar_t *wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr);
|
||||
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
|
||||
size_t wcslen(const wchar_t *s);
|
||||
wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
|
||||
size_t wcsftime(wchar_t * restrict s, size_t maxsize, const wchar_t * restrict format, const struct tm * restrict timeptr);
|
||||
wint_t btowc(int c);
|
||||
int wctob(wint_t c);
|
||||
int mbsinit(const mbstate_t *ps);
|
||||
size_t mbrlen(const char * restrict s, size_t n, mbstate_t * restrict ps);
|
||||
size_t mbrtowc(wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps);
|
||||
size_t wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps);
|
||||
size_t mbsrtowcs(wchar_t * restrict dst, const char ** restrict src, size_t len, mbstate_t * restrict ps);
|
||||
size_t wcsrtombs(char * restrict dst, const wchar_t ** restrict src, size_t len, mbstate_t * restrict ps);
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
int fwprintf_s(FILE * restrict stream, const wchar_t * restrict format, ...);
|
||||
int fwscanf_s(FILE * restrict stream, const wchar_t * restrict format, ...);
|
||||
int snwprintf_s(wchar_t * restrict s, rsize_t n, const wchar_t * restrict format, ...);
|
||||
int swprintf_s(wchar_t * restrict s, rsize_t n, const wchar_t * restrict format, ...);
|
||||
int swscanf_s(const wchar_t * restrict s, const wchar_t * restrict format, ...);
|
||||
int vfwprintf_s(FILE * restrict stream, const wchar_t * restrict format, va_list arg);
|
||||
int vfwscanf_s(FILE * restrict stream, const wchar_t * restrict format, va_list arg);
|
||||
int vsnwprintf_s(wchar_t * restrict s, rsize_t n, const wchar_t * restrict format, va_list arg);
|
||||
int vswprintf_s(wchar_t * restrict s, rsize_t n, const wchar_t * restrict format, va_list arg);
|
||||
int vswscanf_s(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg);
|
||||
int vwprintf_s(const wchar_t * restrict format, va_list arg);
|
||||
int vwscanf_s(const wchar_t * restrict format, va_list arg);
|
||||
int wprintf_s(const wchar_t * restrict format, ...);
|
||||
int wscanf_s(const wchar_t * restrict format, ...);
|
||||
errno_t wcscpy_s(wchar_t * restrict s1, rsize_t s1max, const wchar_t * restrict s2);
|
||||
errno_t wcsncpy_s(wchar_t * restrict s1, rsize_t s1max, const wchar_t * restrict s2, rsize_t n);
|
||||
errno_t wmemcpy_s(wchar_t * restrict s1, rsize_t s1max, const wchar_t * restrict s2, rsize_t n);
|
||||
errno_t wmemmove_s(wchar_t *s1, rsize_t s1max, const wchar_t *s2, rsize_t n);
|
||||
errno_t wcscat_s(wchar_t * restrict s1, rsize_t s1max, const wchar_t * restrict s2);
|
||||
errno_t wcsncat_s(wchar_t * restrict s1, rsize_t s1max, const wchar_t * restrict s2, rsize_t n);
|
||||
wchar_t *wcstok_s(wchar_t * restrict s1, rsize_t * restrict s1max,
|
||||
const wchar_t * restrict s2, wchar_t ** restrict ptr);
|
||||
size_t wcsnlen_s(const wchar_t *s, size_t maxsize);
|
||||
errno_t wcrtomb_s(size_t * restrict retval,
|
||||
char * restrict s, rsize_t smax,
|
||||
wchar_t wc, mbstate_t * restrict ps);
|
||||
errno_t mbsrtowcs_s(size_t * restrict retval, wchar_t * restrict dst, rsize_t dstmax, const char ** restrict src, rsize_t len, mbstate_t * restrict ps);
|
||||
errno_t wcsrtombs_s(size_t * restrict retval, char * restrict dst, rsize_t dstmax, const wchar_t ** restrict src, rsize_t len, mbstate_t * restrict ps);
|
||||
#endif
|
28
inc/wctype.h
28
inc/wctype.h
|
@ -0,0 +1,28 @@
|
|||
#include "_platform.h"
|
||||
|
||||
typedef int wint_t;
|
||||
wctrans_t;
|
||||
wctype_t;
|
||||
|
||||
#ifndef WEOF
|
||||
#define WEOF 0
|
||||
#endif
|
||||
|
||||
int iswalnum(wint_t wc);
|
||||
int iswalpha(wint_t wc);
|
||||
int iswblank(wint_t wc);
|
||||
int iswcntrl(wint_t wc);
|
||||
int iswdigit(wint_t wc);
|
||||
int iswgraph(wint_t wc);
|
||||
int iswlower(wint_t wc);
|
||||
int iswprint(wint_t wc);
|
||||
int iswpunct(wint_t wc);
|
||||
int iswspace(wint_t wc);
|
||||
int iswupper(wint_t wc);
|
||||
int iswxdigit(wint_t wc);
|
||||
int iswctype(wint_t wc, wctype_t desc);
|
||||
wctype_t wctype(const char *property);
|
||||
wint_t towlower(wint_t wc);
|
||||
wint_t towupper(wint_t wc);
|
||||
wint_t towctrans(wint_t wc, wctrans_t desc);
|
||||
wctrans_t wctrans(const char *property);
|
Loading…
Reference in New Issue