From f2eabdb6257c09cf2890dac5e9737912728542af Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 2 Feb 2023 17:29:19 -0400 Subject: global: Add rest of Dolphin SDK proper, add MSL, and MetroTRK Finally, it links properly. --- src/MSL_C.PPCEABI.bare.H/ansi_files.c | 119 ++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/MSL_C.PPCEABI.bare.H/ansi_files.c (limited to 'src/MSL_C.PPCEABI.bare.H/ansi_files.c') diff --git a/src/MSL_C.PPCEABI.bare.H/ansi_files.c b/src/MSL_C.PPCEABI.bare.H/ansi_files.c new file mode 100644 index 0000000..14cd868 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/ansi_files.c @@ -0,0 +1,119 @@ +#include "ansi_files.h" + +static unsigned char stdin_buff[0x100]; +static unsigned char stdout_buff[0x100]; +static unsigned char stderr_buff[0x100]; + +extern int fclose(FILE*); +extern int __read_console(__file_handle file, unsigned char* buff, size_t* count, + __idle_proc idle_proc); +extern int __write_console(__file_handle file, unsigned char* buff, size_t* count, + __idle_proc idle_proc); +extern int __close_console(__file_handle file); + +FILE __files[4] = { + {0, + {0, 1, 1, 2, 0}, + {0, 0, 0, 0}, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stdin_buff, + sizeof(stdin_buff), + stdin_buff, + 0, + 0, + 0, + 0, + NULL, + &__read_console, + &__write_console, + &__close_console, + 0, + &__files[1]}, + {1, + {0, 2, 1, 2, 0}, + {0, 0, 0, 0}, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stdout_buff, + sizeof(stdout_buff), + stdout_buff, + 0, + 0, + 0, + 0, + NULL, + &__read_console, + &__write_console, + &__close_console, + 0, + &__files[2]}, + {2, + {0, 2, 0, 2, 0}, + {0, 0, 0, 0}, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stderr_buff, + sizeof(stderr_buff), + stderr_buff, + 0, + 0, + 0, + 0, + NULL, + &__read_console, + &__write_console, + &__close_console, + 0, + &__files[3]}, +}; + +void __close_all() { + FILE* p = &__files[0]; + FILE* plast; + + // __begin_critical_region(2); + + while (p != NULL) { + if (p->mode.file_kind != __closed_file) { + fclose(p); + } + + plast = p; + p = p->next_file_struct; + if (plast->is_dynamically_allocated) + free(plast); + else { + plast->mode.file_kind = __unavailable_file; + if ((p != NULL) && p->is_dynamically_allocated) + plast->next_file_struct = NULL; + } + } + + // __end_critical_region(2); +} + +int __flush_all() { + int retval = 0; + FILE* __stream; + __stream = &__files[0]; + while (__stream) { + if ((__stream->mode.file_kind) && (fflush(__stream))) { + retval = -1; + } + __stream = __stream->next_file_struct; + }; + return retval; +} -- cgit v1.2.3-13-gbd6f