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 C28503857415 for ; Tue, 21 Jun 2022 12:49:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C28503857415 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 sslproxy02.your-server.de ([78.47.166.47]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o3dK2-0003Z0-WD for newlib@sourceware.org; Tue, 21 Jun 2022 14:49:35 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o3dK3-000Lhu-6F for newlib@sourceware.org; Tue, 21 Jun 2022 14:49:35 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id DD106480136 for ; Tue, 21 Jun 2022 14:49:34 +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 TSGNVPqjgTvu for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 655C64801E6 for ; Tue, 21 Jun 2022 14:49:34 +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 Dj46yAf35sLC for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) Received: from zimbra.eb.localhost (unknown [192.168.96.242]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 42F1548013E for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 05/14] Add _REENT_STDOUT(ptr) Date: Tue, 21 Jun 2022 14:49:22 +0200 Message-Id: <20220621124931.36450-6-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220621124931.36450-1-sebastian.huber@embedded-brains.de> References: <20220621124931.36450-1-sebastian.huber@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.6/26579/Tue Jun 21 10:15:30 2022) X-Spam-Status: No, score=-11.5 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: Tue, 21 Jun 2022 12:49:39 -0000 From: Matt Joyce Add a _REENT_STDOUT() macro to encapsulate access to the _stdout member of struct reent. This will help to replace the struct member with a thread-local storage object in a follow up patch. --- newlib/libc/include/stdio.h | 4 ++-- newlib/libc/include/sys/reent.h | 1 + newlib/libc/include/wchar.h | 4 ++-- newlib/libc/machine/spu/stdio.c | 4 ++-- newlib/libc/stdio/findfp.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index c802b3737..95cc55fa9 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -168,11 +168,11 @@ typedef _ssize_t ssize_t; #define TMP_MAX 26 =20 #define stdin _REENT_STDIN(_REENT) -#define stdout (_REENT->_stdout) +#define stdout _REENT_STDOUT(_REENT) #define stderr (_REENT->_stderr) =20 #define _stdin_r(x) _REENT_STDIN(x) -#define _stdout_r(x) ((x)->_stdout) +#define _stdout_r(x) _REENT_STDOUT(x) #define _stderr_r(x) ((x)->_stderr) =20 /* diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index 801fe20f4..652a330cb 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -721,6 +721,7 @@ struct _reent #define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency) #define _REENT_ERRNO(_ptr) ((_ptr)->_errno) #define _REENT_STDIN(_ptr) ((_ptr)->_stdin) +#define _REENT_STDOUT(_ptr) ((_ptr)->_stdout) =20 #define _REENT_INIT_PTR(var) \ { memset((var), 0, sizeof(*(var))); \ diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h index 5e9202820..7c37427e6 100644 --- a/newlib/libc/include/wchar.h +++ b/newlib/libc/include/wchar.h @@ -321,13 +321,13 @@ int _wscanf_r (struct _reent *, const wchar_t *, ..= .); #define getwc(fp) fgetwc(fp) #define putwc(wc,fp) fputwc((wc), (fp)) #define getwchar() fgetwc(_REENT_STDIN(_REENT)) -#define putwchar(wc) fputwc((wc), _REENT->_stdout) +#define putwchar(wc) fputwc((wc), _REENT_STDOUT(_REENT)) =20 #if __GNU_VISIBLE #define getwc_unlocked(fp) fgetwc_unlocked(fp) #define putwc_unlocked(wc,fp) fputwc_unlocked((wc), (fp)) #define getwchar_unlocked() fgetwc_unlocked(_REENT_STDIN(_REENT)) -#define putwchar_unlocked(wc) fputwc_unlocked((wc), _REENT->_stdout) +#define putwchar_unlocked(wc) fputwc_unlocked((wc), _REENT_STDOUT(_REENT= )) #endif =20 _END_STD_C diff --git a/newlib/libc/machine/spu/stdio.c b/newlib/libc/machine/spu/st= dio.c index 756628303..769b8f1c9 100644 --- a/newlib/libc/machine/spu/stdio.c +++ b/newlib/libc/machine/spu/stdio.c @@ -70,8 +70,8 @@ __sinit (struct _reent *s) _REENT_STDIN(s) =3D &s->__sf[0]; _REENT_STDIN(s)->_fp =3D SPE_STDIN; =20 - s->_stdout =3D &s->__sf[1]; - s->_stdout->_fp =3D SPE_STDOUT; + _REENT_STDOUT(s) =3D &s->__sf[1]; + _REENT_STDOUT(s)->_fp =3D SPE_STDOUT; =20 s->_stderr =3D &s->__sf[2]; s->_stderr->_fp =3D SPE_STDERR; diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index d2292d3e0..04e3517a7 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -220,8 +220,8 @@ cleanup_stdio (struct _reent *ptr) { if (_REENT_STDIN(ptr) !=3D &__sf[0]) CLEANUP_FILE (ptr, _REENT_STDIN(ptr)); - if (ptr->_stdout !=3D &__sf[1]) - CLEANUP_FILE (ptr, ptr->_stdout); + if (_REENT_STDOUT(ptr) !=3D &__sf[1]) + CLEANUP_FILE (ptr, _REENT_STDOUT(ptr)); if (ptr->_stderr !=3D &__sf[2]) CLEANUP_FILE (ptr, ptr->_stderr); } --=20 2.35.3