From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id CBBD738346A7 for ; Tue, 10 May 2022 08:09:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBBD738346A7 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy06.your-server.de ([78.46.172.3]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1noKw9-000MqT-Cs for newlib@sourceware.org; Tue, 10 May 2022 10:09:41 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noKw9-000HId-HK for newlib@sourceware.org; Tue, 10 May 2022 10:09:41 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 35A3F48016E for ; Tue, 10 May 2022 10:09:41 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id fRgqYYG-2wh1; Tue, 10 May 2022 10:09:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id B3ABA480162; Tue, 10 May 2022 10:09:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YRCDU4K_xbEr; Tue, 10 May 2022 10:09:40 +0200 (CEST) Received: from joyce-tux.eb.localhost (unknown [10.10.171.30]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 8C4EC4800F4; Tue, 10 May 2022 10:09:40 +0200 (CEST) From: Matthew Joyce To: newlib@sourceware.org Subject: [PATCH 10/11] Add global __sglue object for all configurations Date: Tue, 10 May 2022 10:09:26 +0200 Message-Id: <20220510080927.28839-11-matthew.joyce@embedded-brains.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220510080927.28839-1-matthew.joyce@embedded-brains.de> References: <20220510080927.28839-1-matthew.joyce@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.5/26536/Mon May 9 10:04:57 2022) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 08:09:44 -0000 From: Matt Joyce 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(). --- 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/re= ent.h index 4b0d68610..708ec16e2 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->__sgl= ue); + 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 221052bd4..453103e77 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 +#ifndef _REENT_SMALL +struct _glue __sglue =3D {NULL, 3, &_GLOBAL_REENT->__sf[0]}; +#else +struct _glue __sglue =3D {NULL, 0, NULL}; +#endif #endif =20 #ifdef _STDIO_BSD_SEMANTICS @@ -158,7 +165,7 @@ sfmoreglue (struct _reent *d, int n) static void stdio_atexit (void) { - (void) _fwalk_sglue (_GLOBAL_REENT, CLEANUP_FILE, &_GLOBAL_REENT->__sg= lue); + (void) _fwalk_sglue (_GLOBAL_REENT, CLEANUP_FILE, &__sglue); } =20 /* @@ -175,15 +182,11 @@ __sfp (struct _reent *d) _newlib_sfp_lock_start (); =20 if (__stdio_atexit =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_atexit =3D stdio_atexit; } =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->__sglu= e); + (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 5bf6d8fc7..caeb5b095 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3138,7 +3138,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->__sgl= ue); + _fwalk_sglue (_GLOBAL_REENT, setmode_helper, &__sglue); } return res; } --=20 2.31.1