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 F089738346AB for ; Tue, 10 May 2022 08:09:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F089738346AB 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 1noKw7-000Mq6-H0 for newlib@sourceware.org; Tue, 10 May 2022 10:09:39 +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 1noKw7-000H9d-LP for newlib@sourceware.org; Tue, 10 May 2022 10:09:39 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 58CB148015F for ; Tue, 10 May 2022 10:09:39 +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 QtZp5aexm01F; Tue, 10 May 2022 10:09:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 0A1174800B0; Tue, 10 May 2022 10:09:39 +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 3IgymdOfZny0; Tue, 10 May 2022 10:09:38 +0200 (CEST) Received: from joyce-tux.eb.localhost (unknown [10.10.171.30]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 8E89A480024; Tue, 10 May 2022 10:09:38 +0200 (CEST) From: Matthew Joyce To: newlib@sourceware.org Subject: [PATCH 04/11] Add two __sglue initialization macros Date: Tue, 10 May 2022 10:09:20 +0200 Message-Id: <20220510080927.28839-5-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=-11.8 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:42 -0000 From: Matt Joyce Added _REENT_INIT_SGLUE and _REENT_INIT_SGLUE_ZEROED macros to initialize __sglue member of struct _reent. This allows further simplification of __sinit() and facilitates the removal of __sglue as a member of struct _reent for certain configurations in a follow-on patch. --- newlib/libc/include/sys/reent.h | 9 ++++++++- newlib/libc/stdio/findfp.c | 7 +------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index e0b0ccffb..4b0d68610 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -702,8 +702,14 @@ struct _reent =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_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_ZEROED(_ptr) \ + (_ptr)->__sglue._niobs =3D 3; \ + (_ptr)->__sglue._iobs =3D &(_ptr)->__sf[0]; #endif =20 #define _REENT_INIT(var) \ @@ -751,7 +757,7 @@ struct _reent }, \ _REENT_INIT_ATEXIT \ _NULL, \ - {_NULL, 0, _NULL} \ + _REENT_INIT_SGLUE(&(var)) \ } =20 #define _REENT_INIT_PTR_ZEROED(var) \ @@ -766,6 +772,7 @@ struct _reent (var)->_new._reent._r48._mult[1] =3D _RAND48_MULT_1; \ (var)->_new._reent._r48._mult[2] =3D _RAND48_MULT_2; \ (var)->_new._reent._r48._add =3D _RAND48_ADD; \ + _REENT_INIT_SGLUE_ZEROED(var) \ } =20 #define _REENT_CHECK_RAND48(ptr) /* nothing */ diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 8327b1992..66867e664 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -246,12 +246,7 @@ __sinit (struct _reent *s) /* make sure we clean up on exit */ s->__cleanup =3D cleanup_stdio; /* conservative */ =20 -#ifndef _REENT_SMALL -# ifndef _REENT_GLOBAL_STDIO_STREAMS - s->__sglue._niobs =3D 3; - s->__sglue._iobs =3D &s->__sf[0]; -# endif /* _REENT_GLOBAL_STDIO_STREAMS */ -#else +#ifdef _REENT_SMALL # ifndef _REENT_GLOBAL_STDIO_STREAMS s->_stdin =3D __sfp(s); s->_stdout =3D __sfp(s); --=20 2.31.1