From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1921) id 396E33839C72; Fri, 13 May 2022 11:20:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 396E33839C72 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sebastian Huber To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org Subject: [newlib-cygwin] Add global __sglue object for all configurations X-Act-Checkin: newlib-cygwin X-Git-Author: Matt Joyce X-Git-Refname: refs/heads/master X-Git-Oldrev: 3941c8a88ad1a1670ceac6e1889496174efd398f X-Git-Newrev: 8b96542ed18990c9300daa4faba89ce8227b4482 Message-Id: <20220513112012.396E33839C72@sourceware.org> Date: Fri, 13 May 2022 11:20:12 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 11:20:12 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D8b96542ed18= 990c9300daa4faba89ce8227b4482 commit 8b96542ed18990c9300daa4faba89ce8227b4482 Author: Matt Joyce Date: Mon May 2 08:58:25 2022 +0200 Add global __sglue object for all configurations =20 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(). Diff: --- newlib/libc/include/sys/reent.h | 2 ++ newlib/libc/stdio/fcloseall.c | 2 +- newlib/libc/stdio/fflush.c | 2 +- newlib/libc/stdio/findfp.c | 15 +++++++++------ newlib/libc/stdio/refill.c | 2 +- winsup/cygwin/syscalls.cc | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reen= t.h index 469f2df28..44a671079 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -304,6 +304,8 @@ struct _glue __FILE *_iobs; }; =20 +extern struct _glue __sglue; + /* * rand48 family support * 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); } =20 #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 =3D=3D NULL) - return _fwalk_sglue (_GLOBAL_REENT, _fflush_r, &_GLOBAL_REENT->__sglue= ); + return _fwalk_sglue (_GLOBAL_REENT, _fflush_r, &__sglue); =20 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 =3D =20 #ifdef _REENT_GLOBAL_STDIO_STREAMS __FILE __sf[3]; +struct _glue __sglue =3D {NULL, 3, &__sf[0]}; +#else +#ifdef _REENT_SMALL +struct _glue __sglue =3D {NULL, 0, NULL}; +#else +struct _glue __sglue =3D {NULL, 3, &_GLOBAL_REENT->__sf[0]}; +#endif #endif =20 #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->__sglu= e); + (void) _fwalk_sglue (_GLOBAL_REENT, CLEANUP_FILE, &__sglue); } =20 /* @@ -175,15 +182,11 @@ __sfp (struct _reent *d) _newlib_sfp_lock_start (); =20 if (__stdio_exit_handler =3D=3D NULL) { -#ifdef _REENT_GLOBAL_STDIO_STREAMS - _GLOBAL_REENT->__sglue._niobs =3D 3; - _GLOBAL_REENT->__sglue._iobs =3D &__sf[0]; -#endif __sinit (_GLOBAL_REENT); __stdio_exit_handler =3D stdio_exit_handler; } =20 - for (g =3D &_GLOBAL_REENT->__sglue;; g =3D g->_next) + for (g =3D &__sglue;; g =3D g->_next) { for (fp =3D g->_iobs, n =3D g->_niobs; --n >=3D 0; fp++) if (fp->_flags =3D=3D 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 =3D fp->_flags; fp->_flags =3D 1; - (void) _fwalk_sglue (_GLOBAL_REENT, lflush, &_GLOBAL_REENT->__sglue); + (void) _fwalk_sglue (_GLOBAL_REENT, lflush, &__sglue); fp->_flags =3D orig_flags; =20 /* Now flush this file without locking it. */ diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index fb994ac41..bb9df76cf 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3135,7 +3135,7 @@ cygwin_setmode (int fd, int mode) _my_tls.locals.setmode_mode =3D O_TEXT; else _my_tls.locals.setmode_mode =3D O_BINARY; - _fwalk_sglue (_GLOBAL_REENT, setmode_helper, &_GLOBAL_REENT->__sglue= ); + _fwalk_sglue (_GLOBAL_REENT, setmode_helper, &__sglue); } return res; }