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 0F03F3839C41 for ; Thu, 12 May 2022 12:11:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F03F3839C41 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 1np7ff-0001OT-LT for newlib@sourceware.org; Thu, 12 May 2022 14:11:55 +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 1np7ff-0007Ee-Po for newlib@sourceware.org; Thu, 12 May 2022 14:11:55 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 8227048016D for ; Thu, 12 May 2022 14:11:50 +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 H5v1YM7iom6u; Thu, 12 May 2022 14:11:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 28F1248016B; Thu, 12 May 2022 14:11:50 +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 0hb7z9GqH_d2; Thu, 12 May 2022 14:11:50 +0200 (CEST) Received: from joyce-tux.eb.localhost (unknown [10.10.171.30]) by mail.embedded-brains.de (Postfix) with ESMTPSA id C9662480141; Thu, 12 May 2022 14:11:49 +0200 (CEST) From: Matthew Joyce To: newlib@sourceware.org Subject: [PATCH v2 11/11] Remove __sglue member for one configuration Date: Thu, 12 May 2022 14:11:43 +0200 Message-Id: <20220512121143.21473-12-matthew.joyce@embedded-brains.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220512121143.21473-1-matthew.joyce@embedded-brains.de> References: <20220512121143.21473-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/26539/Thu May 12 10:04:41 2022) X-Spam-Status: No, score=-13.0 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 12 May 2022 12:11:58 -0000 From: Matt Joyce Removed __sglue member of struct reent when _REENT_GLOBAL_STDIO_STREAMS is defined. --- newlib/libc/include/sys/reent.h | 8 ++++---- newlib/libc/reent/reent.c | 6 +++++- newlib/libc/stdio/fcloseall.c | 5 +++++ newlib/libc/stdio/findfp.c | 9 ++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index 2c0598a5d..5cdc67f68 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -696,19 +696,19 @@ struct _reent /* These are here last so that __FILE can grow without changing the of= fsets of the above members (on the off chance that future binary compatib= ility would be broken otherwise). */ - struct _glue __sglue; /* root of glue chain */ # ifndef _REENT_GLOBAL_STDIO_STREAMS + struct _glue __sglue; /* root of glue chain */ __FILE __sf[3]; /* first three file descriptors */ # endif }; =20 #ifdef _REENT_GLOBAL_STDIO_STREAMS #define _REENT_STDIO_STREAM(var, index) &__sf[index] -#define _REENT_INIT_SGLUE(_ptr) { _NULL, 0, _NULL } +#define _REENT_INIT_SGLUE(_ptr) /* nothing to initialize */ #define _REENT_INIT_SGLUE_ZEROED(_ptr) /* nothing to set */ #else #define _REENT_STDIO_STREAM(var, index) &(var)->__sf[index] -#define _REENT_INIT_SGLUE(_ptr) { _NULL, 3, &(_ptr)->__sf[0] } +#define _REENT_INIT_SGLUE(_ptr) , { _NULL, 3, &(_ptr)->__sf[0] } #define _REENT_INIT_SGLUE_ZEROED(_ptr) \ (_ptr)->__sglue._niobs =3D 3; \ (_ptr)->__sglue._iobs =3D &(_ptr)->__sf[0]; @@ -758,7 +758,7 @@ struct _reent } \ }, \ _REENT_INIT_ATEXIT \ - _NULL, \ + _NULL \ _REENT_INIT_SGLUE(&(var)) \ } =20 diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c index 5a04fcf62..70f1c5f45 100644 --- a/newlib/libc/reent/reent.c +++ b/newlib/libc/reent/reent.c @@ -27,9 +27,10 @@ int errno; =20 #endif =20 +#ifndef _REENT_GLOBAL_STDIO_STREAMS /* Interim cleanup code */ =20 -void +static void cleanup_glue (struct _reent *ptr, struct _glue *glue) { @@ -39,6 +40,7 @@ cleanup_glue (struct _reent *ptr, =20 _free_r (ptr, glue); } +#endif =20 void _reclaim_reent (struct _reent *ptr) @@ -124,8 +126,10 @@ _reclaim_reent (struct _reent *ptr) before the program exits, and who wants to wait for that? */ ptr->__cleanup (ptr); =20 +#ifndef _REENT_GLOBAL_STDIO_STREAMS if (ptr->__sglue._next) cleanup_glue (ptr, ptr->__sglue._next); +#endif } =20 /* Malloc memory not reclaimed; no good way to return memory anywa= y. */ diff --git a/newlib/libc/stdio/fcloseall.c b/newlib/libc/stdio/fcloseall.= c index f14c28d34..642dc7d94 100644 --- a/newlib/libc/stdio/fcloseall.c +++ b/newlib/libc/stdio/fcloseall.c @@ -59,7 +59,12 @@ Required OS subroutines: <>, <>, <>, <>, int _fcloseall_r (struct _reent *ptr) { +#ifdef _REENT_GLOBAL_STDIO_STREAMS + /* There are no thread-specific FILE objects */ + return 0; +#else return _fwalk_sglue (ptr, _fclose_r, &ptr->__sglue); +#endif } =20 #ifndef _REENT_ONLY diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index bf471369c..cad50d4e1 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -242,8 +242,9 @@ cleanup_stdio (struct _reent *ptr) CLEANUP_FILE (ptr, ptr->_stdout); if (ptr->_stderr !=3D &__sf[2]) CLEANUP_FILE (ptr, ptr->_stderr); -#endif +#else (void) _fwalk_sglue (ptr, CLEANUP_FILE, &ptr->__sglue); +#endif } =20 /* @@ -326,21 +327,27 @@ __fp_unlock (struct _reent * ptr __unused, FILE * f= p) void __fp_lock_all (void) { +#ifndef _REENT_GLOBAL_STDIO_STREAMS struct _reent *ptr; +#endif =20 __sfp_lock_acquire (); =20 +#ifndef _REENT_GLOBAL_STDIO_STREAMS ptr =3D _REENT; (void) _fwalk_sglue (ptr, __fp_lock, &ptr->__sglue); +#endif } =20 void __fp_unlock_all (void) { +#ifndef _REENT_GLOBAL_STDIO_STREAMS struct _reent *ptr; =20 ptr =3D _REENT; (void) _fwalk_sglue (ptr, __fp_unlock, &ptr->__sglue); +#endif =20 __sfp_lock_release (); } --=20 2.31.1