diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2022-04-24 04:02:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 13:02:50 +0200 |
| commit | 589cc12296ae7253c62655859a5eef92ee42dbaf (patch) | |
| tree | dd8556994b43ed23dff2aed6bb4c019e5c0d7ec9 /include/MSL_C | |
| parent | a1099217d65362f16dd90284670a7dd37702a3ca (diff) | |
some MSL_C work (#192)
* wip
* bunch of MSL_C files
thanks to pikmin2 decomp for their work
* format / asm
* progress
* fix
* fix remove-asm to work with C files
* init / start
Diffstat (limited to 'include/MSL_C')
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/ansi_files.h | 65 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/char_io.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/ctype.h | 8 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/errno.h | 6 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/float.h | 1 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/mem.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/printf.h | 18 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/string.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/math.h | 74 |
9 files changed, 133 insertions, 69 deletions
diff --git a/include/MSL_C/MSL_Common/Src/ansi_files.h b/include/MSL_C/MSL_Common/Src/ansi_files.h index 684a827853..b16eccd5ef 100644 --- a/include/MSL_C/MSL_Common/Src/ansi_files.h +++ b/include/MSL_C/MSL_Common/Src/ansi_files.h @@ -1,39 +1,66 @@ #ifndef MSL_COMMON_SRC_ANSI_FILES_H #define MSL_COMMON_SRC_ANSI_FILES_H -#include "dolphin/types.h" +enum __file_kinds { + /* 0x0 */ CLOSED_FILE, + /* 0x1 */ DISK_FILE, + /* 0x2 */ CONSOLE_FILE, + /* 0x3 */ UNAVAILABLE_FILE, +}; + +enum __file_orientation { + /* 0x0 */ UNORIENTED, + /* 0x1 */ CHAR_ORIENTED, + /* 0x2 */ WIDE_ORIENTED, +}; + +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; -struct FILE { - /* 0x00 */ u32 handle; - /* 0x04 */ u32 file_mode; - /* 0x08 */ u32 file_state; - /* 0x0C */ u8 flag; +typedef struct _file_states { + unsigned int io_state : 3; + unsigned int free_buffer : 1; + unsigned char eof; + unsigned char error; +} file_states; + +typedef struct _FILE { + /* 0x00 */ unsigned int handle; + /* 0x04 */ file_modes file_mode; + /* 0x08 */ file_states file_state; + /* 0x0C */ unsigned char flag; /* 0x0D */ char char_buffer; /* 0x0E */ char char_buffer_2; /* 0x0F */ char ungetc_buffer[2]; - /* 0x12 */ u16 ungetc_wide_buffer[2]; - /* 0x18 */ u32 position; - /* 0x1C */ u8* buffer; - /* 0x20 */ u32 buffer_size; - /* 0x24 */ u8* buffer_ptr; - /* 0x28 */ u32 buffer_length; - /* 0x2C */ u32 buffer_alignment; - /* 0x30 */ u32 buffer_length2; - /* 0x34 */ u32 buffer_position; + /* 0x12 */ unsigned short ungetc_wide_buffer[2]; + /* 0x18 */ unsigned int position; + /* 0x1C */ unsigned char* buffer; + /* 0x20 */ unsigned int buffer_size; + /* 0x24 */ unsigned char* buffer_ptr; + /* 0x28 */ unsigned int buffer_length; + /* 0x2C */ unsigned int buffer_alignment; + /* 0x30 */ unsigned int buffer_length2; + /* 0x34 */ unsigned int buffer_position; /* 0x38 */ void* position_fn; /* 0x3C */ void* read_fn; /* 0x40 */ void* write_fn; /* 0x44 */ void* close_fn; /* 0x48 */ void* unknown; - /* 0x4C */ struct FILE* next_file; -}; + /* 0x4C */ struct _FILE* next_file; +} FILE; -struct files { +typedef struct _files { FILE stdin; FILE stdout; FILE stderr; FILE empty; -}; +} files; extern files __files; diff --git a/include/MSL_C/MSL_Common/Src/char_io.h b/include/MSL_C/MSL_Common/Src/char_io.h index 7363bc22cd..4a6e04cce9 100644 --- a/include/MSL_C/MSL_Common/Src/char_io.h +++ b/include/MSL_C/MSL_Common/Src/char_io.h @@ -4,6 +4,14 @@ #include "MSL_C/MSL_Common/Src/ansi_files.h" #include "dolphin/types.h" -extern "C" int fputs(const char*, FILE*); +#ifdef __cplusplus +extern "C" { +#endif + +int fputs(const char*, FILE*); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_CHAR_IO_H */ diff --git a/include/MSL_C/MSL_Common/Src/ctype.h b/include/MSL_C/MSL_Common/Src/ctype.h index f59c75d820..100460e708 100644 --- a/include/MSL_C/MSL_Common/Src/ctype.h +++ b/include/MSL_C/MSL_Common/Src/ctype.h @@ -3,8 +3,14 @@ #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { +#endif + int tolower(int); -}; + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_CTYPE_H */ diff --git a/include/MSL_C/MSL_Common/Src/errno.h b/include/MSL_C/MSL_Common/Src/errno.h deleted file mode 100644 index 4e3eb9a430..0000000000 --- a/include/MSL_C/MSL_Common/Src/errno.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MSL_COMMON_SRC_ERRNO_H -#define MSL_COMMON_SRC_ERRNO_H - -#include "dolphin/types.h" - -#endif /* MSL_COMMON_SRC_ERRNO_H */ diff --git a/include/MSL_C/MSL_Common/Src/float.h b/include/MSL_C/MSL_Common/Src/float.h index 9a39ae5743..a41c15e2f3 100644 --- a/include/MSL_C/MSL_Common/Src/float.h +++ b/include/MSL_C/MSL_Common/Src/float.h @@ -14,6 +14,7 @@ #define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x)) #define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x)) +#define isfinite(x) ((fpclassify(x) > 2)) #define __signbitf(x) ((*(u8*)&(x)) & 0x80) diff --git a/include/MSL_C/MSL_Common/Src/mem.h b/include/MSL_C/MSL_Common/Src/mem.h index e47536e0b7..73edb308ee 100644 --- a/include/MSL_C/MSL_Common/Src/mem.h +++ b/include/MSL_C/MSL_Common/Src/mem.h @@ -3,6 +3,14 @@ #include "dolphin/types.h" -extern "C" int memcmp(const void*, const void*, size_t); +#ifdef __cplusplus +extern "C" { +#endif + +int memcmp(const void*, const void*, size_t); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_MEM_H */ diff --git a/include/MSL_C/MSL_Common/Src/printf.h b/include/MSL_C/MSL_Common/Src/printf.h index 206517c803..e8cfdf2814 100644 --- a/include/MSL_C/MSL_Common/Src/printf.h +++ b/include/MSL_C/MSL_Common/Src/printf.h @@ -4,10 +4,18 @@ #include "Runtime.PPCEABI.H/__va_arg.h" #include "dolphin/types.h" -extern "C" size_t sprintf(const char*, const char*, ...); -extern "C" size_t snprintf(const char*, size_t, const char*, ...); -extern "C" size_t vsnprintf(char*, size_t, const char*, va_list); -extern "C" size_t vprintf(const char*, va_list); -extern "C" size_t printf(const char*, ...); +#ifdef __cplusplus +extern "C" { +#endif + +size_t sprintf(const char*, const char*, ...); +size_t snprintf(const char*, size_t, const char*, ...); +size_t vsnprintf(char*, size_t, const char*, va_list); +size_t vprintf(const char*, va_list); +size_t printf(const char*, ...); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_PRINTF_H */ diff --git a/include/MSL_C/MSL_Common/Src/string.h b/include/MSL_C/MSL_Common/Src/string.h index 38c7f3e7ea..c70f319597 100644 --- a/include/MSL_C/MSL_Common/Src/string.h +++ b/include/MSL_C/MSL_Common/Src/string.h @@ -3,8 +3,11 @@ #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { -void* memcpy(void*, const void*, s32); +#endif + +void* memcpy(void*, const void*, size_t); void* memset(void*, int, u32); char* strrchr(const char*, int); char* strchr(const char*, int); @@ -16,6 +19,9 @@ char* strcpy(char*, const char*); u32 strlen(const char*); int stricmp(const char*, const char*); -}; + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_STRING_H */ diff --git a/include/MSL_C/math.h b/include/MSL_C/math.h index 0de55c166d..478829c1f5 100644 --- a/include/MSL_C/math.h +++ b/include/MSL_C/math.h @@ -4,57 +4,60 @@ #include "MSL_C/MSL_Common/Src/float.h" #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { -s32 abs(s32); -f64 acos(f64); -f32 acosf(f32); -f64 asin(f64); -f64 atan(f64); -f64 atan2(f64); -f64 ceil(f64); -f64 copysign(f64, f64); -f64 cos(f64); -f32 cosf(f32); -f64 exp(f64); +#endif + +int abs(int); +double acos(double); +float acosf(float); +double asin(double); +double atan(double); +double atan2(double, double); +double ceil(double); +double copysign(double, double); +double cos(double); +float cosf(float); +double exp(double); -extern f32 __fabsf(f32); -inline f64 fabs(f64 f) { +extern float __fabsf(float); +inline double fabs(double f) { return __fabsf(f); } -inline f64 fabsf2(f32 f) { +inline double fabsf2(float f) { return __fabsf(f); } -inline f32 fabsf(f32 f) { +inline float fabsf(float f) { return fabsf2(f); } -f64 floor(f64); -f64 fmod(f64, f64); -inline f32 fmodf(f32 f1, f32 f2) { +double floor(double); +double fmod(double, double); +inline float fmodf(float f1, float f2) { return fmod(f1, f2); } -f64 frexp(f64, s32*); -f64 ldexp(f64, s32); -f64 modf(f64, f64*); -f64 pow(f64, f64); -f64 sin(f64); -f32 sinf(f32); -f64 sqrt(f64); -f64 tan(f64); -f32 tanf(f32); +double frexp(double, int*); +double ldexp(double, int); +double modf(double, double*); +double pow(double, double); +double sin(double); +float sinf(float); +double sqrt(double); +double tan(double); +float tanf(float); -extern f32 __float_nan[4]; -extern f32 __float_epsilon[4]; -extern f32 __float_max[4]; +extern float __float_nan[4]; +extern float __float_epsilon[4]; +extern float __float_max[4]; -inline f64 sqrt_step(f64 tmpd, f32 mag) { +inline double sqrt_step(double tmpd, float mag) { return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd)); } -inline f32 sqrtf(f32 mag) { +inline float sqrtf(float mag) { if (mag > 0.0f) { - f64 tmpd = __frsqrte(mag); + double tmpd = __frsqrte(mag); tmpd = sqrt_step(tmpd, mag); tmpd = sqrt_step(tmpd, mag); tmpd = sqrt_step(tmpd, mag); @@ -67,6 +70,9 @@ inline f32 sqrtf(f32 mag) { return mag; } } -} + +#ifdef __cplusplus +}; +#endif #endif |
