mirror of
https://github.com/zeldaret/st
synced 2026-09-07 03:09:52 -04:00
Match MSL_C (#8)
* match wstring.c * match math_api.c, mbstring.c, mem.c and mem_funcs.c * more progress * build issues * fix non-matching issues * reorganise files * match fdlibm (+ libc progress) * fix jp build * solved some non-matchings and progress * removed types.h usage in libc * match data and add missing delinks for jp
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#ifndef _C_ABORT_EXIT_ARM_EABI_H
|
||||
#define _C_ABORT_EXIT_ARM_EABI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SIGABRT 1
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
void abort(void);
|
||||
void exit(int status);
|
||||
void __exit(int status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _C_ANSI_FILES_H
|
||||
#define _C_ANSI_FILES_H
|
||||
|
||||
#include <file_struc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define console_buff_mode _IOLBF
|
||||
#define console_buff_size 256
|
||||
|
||||
typedef unsigned char console_buff[console_buff_size];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef _C_ANSI_FP_H
|
||||
#define _C_ANSI_FP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FLOATDECIMAL ((char) (0))
|
||||
#define FIXEDDECIMAL ((char) (1))
|
||||
|
||||
#define DBL_MIN 0x1.0000000000000P-1022
|
||||
#define DBL_EPSILON 0x1.0000000000000P-52
|
||||
#define DBL_MAX 0x1.fffffffffffffP1023
|
||||
|
||||
#define LDBL_MIN 0x1.0000000000000P-1022L
|
||||
#define LDBL_EPSILON 0x1.0000000000000P-52L
|
||||
#define LDBL_MAX 0x1.fffffffffffffP1023L
|
||||
|
||||
typedef struct decimal {
|
||||
unsigned char sgn;
|
||||
char unused;
|
||||
short exp;
|
||||
struct {
|
||||
unsigned char length;
|
||||
unsigned char text[32];
|
||||
unsigned char unused;
|
||||
} sig;
|
||||
} decimal;
|
||||
|
||||
typedef struct decform {
|
||||
char style;
|
||||
char unused;
|
||||
short digits;
|
||||
} decform;
|
||||
|
||||
void __num2dec(const decform *f, double x, decimal *d);
|
||||
double __dec2num(const decimal *d);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _C_ARITH_H
|
||||
#define _C_ARITH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int abs(int __x);
|
||||
long labs(long __x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _C_BUFFER_IO_H
|
||||
#define _C_BUFFER_IO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int __flush_buffer(FILE *file, size_t *length);
|
||||
void __prep_buffer(FILE *file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _C_CONSOLE_IO_H
|
||||
#define _C_CONSOLE_IO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int __read_console(unsigned int handle, unsigned char *buffer, int *count, void *ref);
|
||||
extern int __write_console(unsigned int handle, unsigned char *buffer, int *count, void *ref);
|
||||
extern int __close_console();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef MSL_COMMON_CRITICAL_REGIONS_H
|
||||
#define MSL_COMMON_CRITICAL_REGIONS_H
|
||||
|
||||
#include <nitro/os/mutex.h>
|
||||
|
||||
enum critical_regions {
|
||||
atexit_funcs_access = 0,
|
||||
malloc_pool_access = 1,
|
||||
stdin_access = 2,
|
||||
stdout_access = 3,
|
||||
stderr_access = 4,
|
||||
files_access = 5,
|
||||
console_status_access = 6,
|
||||
signal_funcs_access = 7,
|
||||
thread_access = 8,
|
||||
num_critical_regions = 9
|
||||
};
|
||||
|
||||
extern OSMutex __cs[num_critical_regions];
|
||||
extern int __cs_id[num_critical_regions];
|
||||
extern int __cs_ref[num_critical_regions];
|
||||
|
||||
static inline void __begin_critical_region(int region) {
|
||||
OSThread *currentThread;
|
||||
|
||||
if (OS_TryLockMutex(&__cs[region]) == 0) {
|
||||
currentThread = OS_GetCurrentThread();
|
||||
__cs_id[region] = OS_GetThreadId(currentThread);
|
||||
__cs_ref[region] = 1;
|
||||
} else {
|
||||
currentThread = OS_GetCurrentThread();
|
||||
if (OS_GetThreadId(currentThread) == __cs_id[region]) {
|
||||
__cs_ref[region]++;
|
||||
} else {
|
||||
OS_LockMutex(&__cs[region]);
|
||||
currentThread = OS_GetCurrentThread();
|
||||
__cs_id[region] = OS_GetThreadId(currentThread);
|
||||
__cs_ref[region] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void __end_critical_region(int region) {
|
||||
if (--__cs_ref[region] == 0) {
|
||||
OS_UnlockMutex(&__cs[region]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MSL_COMMON_CRITICAL_REGIONS_H
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef _C_CTYPE_H
|
||||
#define _C_CTYPE_H
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define __msl_cmap_size 128
|
||||
|
||||
extern const unsigned short __ctype_mapC[__msl_cmap_size];
|
||||
extern const unsigned char __lower_mapC[__msl_cmap_size];
|
||||
extern const unsigned char __upper_mapC[__msl_cmap_size];
|
||||
|
||||
#define _MSL_CMAP_ACCESS __ctype_mapC
|
||||
#define _MSL_CLOWER_ACCESS __lower_mapC
|
||||
#define _MSL_CUPPER_ACCESS __upper_mapC
|
||||
|
||||
#define __msl_alpha 0x001
|
||||
#define __msl_blank 0x002
|
||||
#define __msl_cntrl 0x004
|
||||
#define __msl_digit 0x008
|
||||
#define __msl_graph 0x010
|
||||
#define __msl_lower 0x020
|
||||
#define __msl_print 0x040
|
||||
#define __msl_punct 0x080
|
||||
#define __msl_space 0x100
|
||||
#define __msl_upper 0x200
|
||||
#define __msl_xdigit 0x400
|
||||
|
||||
static inline int isalpha(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? 0 : (int) (_MSL_CMAP_ACCESS[c] & __msl_alpha);
|
||||
}
|
||||
|
||||
static inline int isdigit(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? 0 : (int) (_MSL_CMAP_ACCESS[c] & __msl_digit);
|
||||
}
|
||||
|
||||
static inline int isspace(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? 0 : (int) (_MSL_CMAP_ACCESS[c] & __msl_space);
|
||||
}
|
||||
|
||||
static inline int isupper(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? 0 : (int) (_MSL_CMAP_ACCESS[c] & __msl_upper);
|
||||
}
|
||||
|
||||
static inline int isxdigit(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? 0 : (int) (_MSL_CMAP_ACCESS[c] & __msl_xdigit);
|
||||
}
|
||||
|
||||
static inline int toupper(unsigned int c) {
|
||||
return ((c < 0) || (c >= __msl_cmap_size)) ? c : (int) (_MSL_CUPPER_ACCESS[c]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _C_ERRNO_H
|
||||
#define _C_ERRNO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int errno;
|
||||
|
||||
#define ENOERR 0
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
#define ESIGPARM 36
|
||||
#define EFPOS 40
|
||||
#define EILSEQ 84
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef _C_FDLIBM_H
|
||||
#define _C_FDLIBM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
/**
|
||||
* For including FDLIBM declarations without also including its many macros.
|
||||
*/
|
||||
|
||||
double __ieee754_acos(double);
|
||||
double __ieee754_fmod(double, double);
|
||||
double __ieee754_log(double);
|
||||
double __ieee754_log10(double);
|
||||
double __ieee754_pow(double, double);
|
||||
double __ieee754_sqrt(double);
|
||||
double __ieee754_atan2(double, double);
|
||||
double __ieee754_asin(double);
|
||||
double __ieee754_exp(double);
|
||||
int __ieee754_rem_pio2(double, double *);
|
||||
|
||||
double __kernel_sin(double, double, int);
|
||||
double __kernel_cos(double, double);
|
||||
double __kernel_tan(double, double, int);
|
||||
|
||||
double nan(const char *arg);
|
||||
double atan(double x);
|
||||
double ceil(double x);
|
||||
double copysign(double x, double y);
|
||||
double cos(double x);
|
||||
double floor(double x);
|
||||
double frexp(double x, int *eptr);
|
||||
double ldexp(double value, int exp);
|
||||
double modf(double x, double *iptr);
|
||||
double sin(double x);
|
||||
double tan(double x);
|
||||
double acos(double x);
|
||||
double asin(double x);
|
||||
double atan2(double y, double x);
|
||||
double fmod(double x, double y);
|
||||
double pow(double x, double y);
|
||||
double sqrt(double x);
|
||||
double log(double x);
|
||||
float log10f(float x);
|
||||
|
||||
// In reality, these are "weak" functions which all have C++ names (except scalbn).
|
||||
// We fake it by defining them as strong C functions instead.
|
||||
float sin__Ff(float x);
|
||||
float cos__Ff(float x);
|
||||
double scalbn(double x, int n);
|
||||
double fabs__Fd(double x);
|
||||
float fabsf__Ff(float x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _C_FILE_IO_H
|
||||
#define _C_FILE_IO_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int fclose(FILE *file);
|
||||
int fflush(FILE *file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _C_FILE_POS_H
|
||||
#define _C_FILE_POS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int fseek(FILE *stream, unsigned int offset, int whence);
|
||||
int _fseek(FILE *stream, unsigned int offset, int whence);
|
||||
int ftell(FILE *stream);
|
||||
int _ftell(FILE *stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef _C_FILE_STRUC_H
|
||||
#define _C_FILE_STRUC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned long __file_handle;
|
||||
typedef unsigned long fpos_t;
|
||||
typedef struct _FILE _FILE, *P_FILE;
|
||||
|
||||
#define __ungetc_buffer_size 2
|
||||
|
||||
enum __file_kinds {
|
||||
__closed_file,
|
||||
__disk_file,
|
||||
__console_file,
|
||||
__unavailable_file
|
||||
};
|
||||
|
||||
enum __open_modes {
|
||||
__must_exist,
|
||||
__create_if_necessary,
|
||||
__create_or_truncate
|
||||
};
|
||||
|
||||
enum __file_orientation {
|
||||
__unoriented,
|
||||
__char_oriented,
|
||||
__wide_oriented
|
||||
};
|
||||
|
||||
enum __io_modes {
|
||||
__read = 1,
|
||||
__write = 2,
|
||||
__read_write = 3,
|
||||
__append = 4
|
||||
};
|
||||
|
||||
typedef struct __file_modes {
|
||||
unsigned int open_mode : 2;
|
||||
unsigned int io_mode : 3;
|
||||
unsigned int buffer_mode : 2;
|
||||
unsigned int file_kind : 3;
|
||||
unsigned int file_orientation : 2;
|
||||
unsigned int binary_io : 1;
|
||||
} __file_modes;
|
||||
|
||||
enum __io_states {
|
||||
__neutral,
|
||||
__writing,
|
||||
__reading,
|
||||
__rereading
|
||||
};
|
||||
|
||||
typedef struct __file_state {
|
||||
unsigned int io_state : 3;
|
||||
unsigned int free_buffer : 1;
|
||||
unsigned char eof;
|
||||
unsigned char error;
|
||||
} __file_state;
|
||||
|
||||
typedef void *__ref_con;
|
||||
typedef void (*__idle_proc)(void);
|
||||
typedef int (*__pos_proc)(unsigned int file, unsigned int *position, int mode, void *ref);
|
||||
typedef int (*__io_proc)(unsigned int handle, unsigned char *buffer, int *count, void *ref);
|
||||
typedef int (*__close_proc)(unsigned int file);
|
||||
|
||||
struct _FILE {
|
||||
__file_handle handle;
|
||||
__file_modes mode;
|
||||
__file_state state;
|
||||
unsigned char char_buffer;
|
||||
unsigned char char_buffer_overflow;
|
||||
unsigned char ungetc_buffer[__ungetc_buffer_size];
|
||||
wchar_t ungetwc_buffer[__ungetc_buffer_size];
|
||||
unsigned int position;
|
||||
unsigned char *buffer;
|
||||
unsigned int buffer_size;
|
||||
unsigned char *buffer_ptr;
|
||||
unsigned int buffer_len;
|
||||
unsigned int buffer_alignment;
|
||||
unsigned int saved_buffer_len;
|
||||
unsigned int buffer_pos;
|
||||
__pos_proc position_proc;
|
||||
__io_proc read_proc;
|
||||
__io_proc write_proc;
|
||||
__close_proc close_proc;
|
||||
__ref_con ref_con;
|
||||
};
|
||||
|
||||
typedef struct _FILE FILE;
|
||||
|
||||
#define _IONBF 0
|
||||
#define _IOLBF 1
|
||||
#define _IOFBF 2
|
||||
|
||||
// define standard C file pointer location names
|
||||
#define SEEK_SET (0)
|
||||
#define SEEK_CUR (1)
|
||||
#define SEEK_END (2)
|
||||
|
||||
#define set_error(file) \
|
||||
do { \
|
||||
(file)->state.error = 1; \
|
||||
(file)->buffer_len = 0; \
|
||||
} while (FALSE)
|
||||
|
||||
#define stdin &(__files[0])
|
||||
#define stdout &(__files[1])
|
||||
#define stderr &(__files[2])
|
||||
|
||||
#define _STATIC_FILES 3
|
||||
|
||||
extern FILE __files[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef _C_FLOAT_H
|
||||
#define _C_FLOAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FLT_MAX 3.402823466e+38f
|
||||
#define FLT_EPSILON 1.192092896e-07f
|
||||
#define FLT_MIN 1.175494351e-38f
|
||||
|
||||
#define DBL_EPSILON 1.1920929e-07
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_10_EXP (-308)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define LDBL_MAX 0x1.fffffffffffffP1023L
|
||||
#define LDBL_EPSILON 0x1.0000000000000P-52L
|
||||
#define LDBL_MIN 0x1.0000000000000P-1022L
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef _C_LIMITS_H
|
||||
#define _C_LIMITS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SCHAR_MIN (-0x7F - 1)
|
||||
#define SCHAR_MAX 0x7F
|
||||
#define UCHAR_MAX 0xFFU
|
||||
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
|
||||
#define SHRT_MIN (-0x7FFF - 1)
|
||||
#define SHRT_MAX 0x7FFF
|
||||
#define USHRT_MAX 0xFFFF
|
||||
|
||||
#define INT_MIN (-0x7FFFFFFF - 1)
|
||||
#define INT_MAX 0x7FFFFFFF
|
||||
#define UINT_MAX 0xFFFFFFFF
|
||||
|
||||
#define LONG_MIN (-0x7FFFFFFFL - 1)
|
||||
#define LONG_MAX 0x7FFFFFFFL
|
||||
#define ULONG_MAX 0xFFFFFFFFUL
|
||||
|
||||
#define LLONG_MIN (-0x7FFFFFFFFFFFFFFFLL - 1)
|
||||
#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
|
||||
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
|
||||
#define CHAR_BIT 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef _C_LOCALE_H
|
||||
#define _C_LOCALE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _COMPONENT_NAME_LEN 8
|
||||
|
||||
typedef int (*__decode_mbyte)(unsigned short *, const char *, int);
|
||||
typedef int (*__encode_mbyte)(char *, unsigned short);
|
||||
|
||||
struct _loc_coll_cmpt {
|
||||
int char_start_value;
|
||||
int char_coll_tab_size;
|
||||
short char_spec_accents;
|
||||
unsigned short *char_coll_table_ptr;
|
||||
};
|
||||
|
||||
struct _loc_ctype_cmpt {
|
||||
/* 0x00 */ __decode_mbyte decode_mb;
|
||||
/* 0x04 */ __encode_mbyte encode_wc;
|
||||
};
|
||||
|
||||
struct _loc_time_cmpt {
|
||||
char *am_pm;
|
||||
char *DateTime_Format;
|
||||
char *Twelve_hr_format;
|
||||
char *Date_Format;
|
||||
char *Time_Format;
|
||||
char *Day_Names;
|
||||
char *MonthNames;
|
||||
char *TimeZone;
|
||||
};
|
||||
|
||||
struct __locale {
|
||||
/* 0x00 */ struct _loc_time_cmpt *time_cmpt_ptr;
|
||||
/* 0x04 */ struct _loc_coll_cmpt *coll_cmpt_ptr;
|
||||
/* 0x08 */ struct _loc_ctype_cmpt *ctype_cmpt_ptr;
|
||||
};
|
||||
|
||||
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 p_cs_precedes;
|
||||
char n_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char *int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
extern struct lconv __lconv;
|
||||
extern struct __locale _current_locale;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef _C_MATH_H
|
||||
#define _C_MATH_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <fdlibm.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DONT_INLINE_SQRT
|
||||
|
||||
#define M_PI 3.1415926535897932
|
||||
#define M_SQRT3 1.7320499420166016
|
||||
|
||||
extern int __float_nan[];
|
||||
extern int __float_huge[];
|
||||
extern int __double_huge[];
|
||||
|
||||
#define NAN (*(float *) __float_nan)
|
||||
#define INFINITY (*(float *) __float_huge)
|
||||
#define HUGE_VAL (*(double *) __double_huge)
|
||||
|
||||
// f64 bit-twiddling macros
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#define __HI(x) (((int *) &x)[0])
|
||||
#define __LO(x) (((int *) &x)[1])
|
||||
#else
|
||||
#define __HI(x) (((int *) &x)[1])
|
||||
#define __LO(x) (((int *) &x)[0])
|
||||
#endif
|
||||
|
||||
#define FP_NAN 1
|
||||
#define FP_INFINITE 2
|
||||
#define FP_ZERO 3
|
||||
#define FP_NORMAL 4
|
||||
#define FP_SUBNORMAL 5
|
||||
|
||||
int __fpclassifyd(double x);
|
||||
int __signbitd(double x);
|
||||
double fabs(double x);
|
||||
double nan(const char *x);
|
||||
double sqrt(double __x);
|
||||
|
||||
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf((float) (x)) : __fpclassifyd((double) (x)))
|
||||
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf((float) (x)) : __signbitd((double) (x)))
|
||||
|
||||
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
||||
#define isnan(x) (fpclassify(x) == FP_NAN)
|
||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
||||
#define isfinite(x) (fpclassify(x) > FP_INFINITE)
|
||||
|
||||
static inline long double fabsl(long double x) {
|
||||
return (long double) fabs((double) x);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _C_MBSTRING_H
|
||||
#define _C_MBSTRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int mbtowc(wchar_t *pwc, const char *s, int n);
|
||||
int __mbtowc_noconv(wchar_t *pwc, const char *str, int n);
|
||||
int __wctomb_noconv(char *s, wchar_t wchar);
|
||||
size_t mbstowcs(wchar_t *pDest, const char *pSrc, size_t num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _C_MEM_H
|
||||
#define _C_MEM_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *memcpy(void *dst, const void *src, int n);
|
||||
void *memmove(void *dst, const void *src, size_t len);
|
||||
void *memset(void *dest, int val, int n);
|
||||
void *memchr(const void *src, int val, int n);
|
||||
int memcmp(const void *src1, const void *src2, int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _C_MEM_FUNCS_H
|
||||
#define _C_MEM_FUNCS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void __fill_mem(void *dst, int val, unsigned int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _C_PRINTF_H
|
||||
#define _C_PRINTF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int printf(const char *format, ...);
|
||||
int fprintf(FILE *, const char *format, ...);
|
||||
int vprintf(const char *, va_list);
|
||||
int vsnprintf(char *, size_t, const char *, va_list);
|
||||
int vsprintf(char *, const char *, va_list);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
int sprintf(char *, const char *, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _C_SCANF_H
|
||||
#define _C_SCANF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int vsscanf(const char *, const char *, va_list);
|
||||
int sscanf(const char *, const char *, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _C_SECURE_ERROR_H
|
||||
#define _C_SECURE_ERROR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*msl_constraint_handler)(int, int, int);
|
||||
|
||||
void __msl_runtime_constraint_violation_s(int param1, int param2, int param3);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _C_SIGNAL_H
|
||||
#define _C_SIGNAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void exit(int);
|
||||
|
||||
typedef void (*sig_func)(int sig);
|
||||
|
||||
int raise(int sig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _C_STDARG_H
|
||||
#define _C_STDARG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef char *va_list;
|
||||
|
||||
#define __fourbytealign(n) ((((unsigned int) (n)) + 3U) & ~3U)
|
||||
#define __va_start(parm) ((va_list) ((char *) ((unsigned int) (&parm) & ~3U) + __fourbytealign(sizeof(parm))))
|
||||
|
||||
#define va_start(ap, parm) ((ap) = __va_start(parm))
|
||||
#define va_arg(ap, type) (*(type *) ((ap += __fourbytealign(sizeof(type))) - __fourbytealign(sizeof(type))))
|
||||
#define va_end(ap) ((void) 0)
|
||||
#define va_copy(dest, src) dest = src
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+28
-1
@@ -1,8 +1,35 @@
|
||||
#ifndef _C_STDDEF_H
|
||||
#define _C_STDDEF_H
|
||||
|
||||
#define NULL 0
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef nullptr
|
||||
#define nullptr 0
|
||||
#endif
|
||||
|
||||
#define offsetof(ST, M) ((size_t) &(((ST *) 0)->M))
|
||||
|
||||
typedef signed long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
typedef intptr_t ptrdiff_t;
|
||||
|
||||
typedef unsigned int size_t;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef int bool;
|
||||
typedef unsigned short wchar_t;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _C_STDIO_H
|
||||
#define _C_STDIO_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#include <stdio_api.h>
|
||||
#include <file_pos.h>
|
||||
#include <file_io.h>
|
||||
#include <printf.h>
|
||||
#include <scanf.h>
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef _C_STDIO_API_H
|
||||
#define _C_STDIO_API_H
|
||||
|
||||
#include <file_struc.h>
|
||||
#include <stddef.h>
|
||||
#include <wchar_io.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum __ReadProcActions {
|
||||
__GetAChar,
|
||||
__UngetAChar,
|
||||
__TestForError
|
||||
};
|
||||
|
||||
enum __WReadProcActions {
|
||||
__GetAwChar,
|
||||
__UngetAwChar,
|
||||
__TestForwcsError
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *CharStr;
|
||||
size_t MaxCharCount;
|
||||
size_t CharsWritten;
|
||||
} __OutStrCtrl;
|
||||
|
||||
typedef struct {
|
||||
char *NextChar;
|
||||
int NullCharDetected;
|
||||
} __InStrCtrl;
|
||||
|
||||
typedef struct {
|
||||
wchar_t *wCharStr;
|
||||
size_t MaxCharCount;
|
||||
size_t CharsWritten;
|
||||
} __wOutStrCtrl;
|
||||
|
||||
typedef struct {
|
||||
wchar_t *wNextChar;
|
||||
int wNullCharDetected;
|
||||
} __wInStrCtrl;
|
||||
|
||||
size_t __fwrite(const void *pPtr, size_t memb_size, size_t num_memb, FILE *file);
|
||||
int __StringRead(void *, int, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,15 +1,20 @@
|
||||
#ifndef _C_STRING_H
|
||||
#define _C_STRING_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned int size_t;
|
||||
|
||||
size_t strlen(const char *str);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
char *strncpy(char *dest, const char *src, size_t num);
|
||||
char *strcat(char *dest, const char *src);
|
||||
int strcmp(char *str1, char *str2);
|
||||
int strncmp(char *str1, char *str2, size_t num);
|
||||
const char *strchr(const char *str, char ch);
|
||||
const char *strstr(const char *str1, const char *str2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _C_WCHAR_H
|
||||
#define _C_WCHAR_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int fwide(FILE *stream, int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _C_WSTRING_H
|
||||
#define _C_WSTRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
size_t wcslen(const wchar_t *str);
|
||||
wchar_t *wcscpy(wchar_t *dest, const wchar_t *src);
|
||||
wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t n);
|
||||
const wchar_t *wcschr(const wchar_t *str, wchar_t chr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user