diff options
author | Matt Joyce <matthew.joyce@embedded-brains.de> | 2022-05-02 09:58:25 +0300 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-05-13 13:41:10 +0300 |
commit | 8b96542ed18990c9300daa4faba89ce8227b4482 (patch) | |
tree | b331d5c33ca9dbbbfa69151f6569dd003be0555e /newlib/libc/stdio | |
parent | 3941c8a88ad1a1670ceac6e1889496174efd398f (diff) |
Add global __sglue object for all configurations
Added a new global __sglue object for all configurations.
Decouples the global file object list from the _GLOBAL_REENT
structure by using this new object instead of the __sglue member
of _GLOBAL_REENT in __sfp() and _fwalk_sglue().
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r-- | newlib/libc/stdio/fcloseall.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/fflush.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/findfp.c | 15 | ||||
-rw-r--r-- | newlib/libc/stdio/refill.c | 2 |
4 files changed, 12 insertions, 9 deletions
diff --git a/newlib/libc/stdio/fcloseall.c b/newlib/libc/stdio/fcloseall.c index 4d4e3554b..f14c28d34 100644 --- a/newlib/libc/stdio/fcloseall.c +++ b/newlib/libc/stdio/fcloseall.c @@ -67,7 +67,7 @@ _fcloseall_r (struct _reent *ptr) int fcloseall (void) { - return _fcloseall_r (_GLOBAL_REENT); + return _fwalk_sglue (_GLOBAL_REENT, _fclose_r, &__sglue); } #endif diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 6e946da7b..bbec4a19b 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -286,7 +286,7 @@ int fflush (register FILE * fp) { if (fp == NULL) - return _fwalk_sglue (_GLOBAL_REENT, _fflush_r, &_GLOBAL_REENT->__sglue); + return _fwalk_sglue (_GLOBAL_REENT, _fflush_r, &__sglue); return _fflush_r (_REENT, fp); } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 1627032a3..29c068a12 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -39,6 +39,13 @@ const struct __sFILE_fake __sf_fake_stderr = #ifdef _REENT_GLOBAL_STDIO_STREAMS __FILE __sf[3]; +struct _glue __sglue = {NULL, 3, &__sf[0]}; +#else +#ifdef _REENT_SMALL +struct _glue __sglue = {NULL, 0, NULL}; +#else +struct _glue __sglue = {NULL, 3, &_GLOBAL_REENT->__sf[0]}; +#endif #endif #ifdef _STDIO_BSD_SEMANTICS @@ -158,7 +165,7 @@ sfmoreglue (struct _reent *d, int n) static void stdio_exit_handler (void) { - (void) _fwalk_sglue (_GLOBAL_REENT, CLEANUP_FILE, &_GLOBAL_REENT->__sglue); + (void) _fwalk_sglue (_GLOBAL_REENT, CLEANUP_FILE, &__sglue); } /* @@ -175,15 +182,11 @@ __sfp (struct _reent *d) _newlib_sfp_lock_start (); if (__stdio_exit_handler == NULL) { -#ifdef _REENT_GLOBAL_STDIO_STREAMS - _GLOBAL_REENT->__sglue._niobs = 3; - _GLOBAL_REENT->__sglue._iobs = &__sf[0]; -#endif __sinit (_GLOBAL_REENT); __stdio_exit_handler = stdio_exit_handler; } - for (g = &_GLOBAL_REENT->__sglue;; g = g->_next) + for (g = &__sglue;; g = g->_next) { for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) if (fp->_flags == 0) diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index 4084d7250..8516d8576 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -105,7 +105,7 @@ __srefill_r (struct _reent * ptr, /* Ignore this file in _fwalk_sglue to avoid potential deadlock. */ short orig_flags = fp->_flags; fp->_flags = 1; - (void) _fwalk_sglue (_GLOBAL_REENT, lflush, &_GLOBAL_REENT->__sglue); + (void) _fwalk_sglue (_GLOBAL_REENT, lflush, &__sglue); fp->_flags = orig_flags; /* Now flush this file without locking it. */ |