From 45717c8317772f067b875d04d5a18a981dfe51fd Mon Sep 17 00:00:00 2001 From: Extrems Date: Mon, 25 Nov 2024 18:12:39 -0500 Subject: [PATCH] Help reduce binary size for gekkoboot --- libogc/console.c | 31 ++++++++++++++++++++++--------- libogc/exception.c | 3 +-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libogc/console.c b/libogc/console.c index 4dc24e4..4f07081 100644 --- a/libogc/console.c +++ b/libogc/console.c @@ -17,10 +17,10 @@ #include #include -static int __console_fstat(struct _reent *r,void *fd,struct stat *st); +static int __console_fstat_r(struct _reent *r,void *fd,struct stat *st); //--------------------------------------------------------------------------------- -static const devoptab_t dotab_stdout = { +static devoptab_t dotab_stdout = { //--------------------------------------------------------------------------------- "stdout", // device name 0, // size of file structure @@ -29,7 +29,7 @@ static const devoptab_t dotab_stdout = { __console_write, // device write NULL, // device read NULL, // device seek - __console_fstat, // device fstat + __console_fstat_r, // device fstat NULL, // device stat NULL, // device link NULL, // device unlink @@ -512,16 +512,14 @@ static int __console_parse_escsequence(const char *pchr) ssize_t __console_write(struct _reent *r,void *fd,const char *ptr,size_t len) { - ssize_t i = -1; + size_t i; const char *tmp = ptr; console_data_s *con; char chr; - if(stdcon) i = _fwrite_r(r,ptr,1,len,stdcon); - - if(!curr_con) return i; + if(!curr_con) return -1; con = curr_con; - if(!tmp || len<=0) return i; + if(!tmp || len<=0) return -1; i = 0; while(*tmp!='\0' && ist_mode = S_IFCHR; @@ -685,6 +694,8 @@ void CON_EnableGecko(s32 chan,bool safe) setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); + dotab_stdout.write_r = __console_write_r; + devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; } @@ -722,6 +733,8 @@ void CON_EnableBarnacle(s32 chan,s32 dev) setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); + dotab_stdout.write_r = __console_write_r; + devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; } diff --git a/libogc/exception.c b/libogc/exception.c index 417d1db..fe52ea3 100644 --- a/libogc/exception.c +++ b/libogc/exception.c @@ -241,8 +241,7 @@ void c_default_exceptionhandler(frame_context *pCtx) { GX_AbortFrame(); VIDEO_SetFramebuffer(exception_xfb); - __console_init(exception_xfb,20,20,640,574,1280); - CON_EnableGecko(1, true); + __console_init(exception_xfb,0,0,640,576,1280); kprintf("\n\n\n\tException (%s) occurred!\n", exception_name[pCtx->EXCPT_Number]);