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/MSL_Common | |
| 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/MSL_Common')
| -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 |
8 files changed, 93 insertions, 35 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 */ |
