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 109FC385695F for ; Tue, 21 Jun 2022 12:49:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 109FC385695F 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 1o3dK8-0003ZJ-DS for newlib@sourceware.org; Tue, 21 Jun 2022 14:49:40 +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-000LmO-KB 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 5BE254801E6 for ; Tue, 21 Jun 2022 14:49:35 +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 lAP1NS8fH8Z0 for ; Tue, 21 Jun 2022 14:49:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 0483C4800AD for ; Tue, 21 Jun 2022 14:49:35 +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 1AElNgFVDAvH 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 D727D4801E3 for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 13/14] Add _REENT_IS_NULL() Date: Tue, 21 Jun 2022 14:49:30 +0200 Message-Id: <20220621124931.36450-14-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.6 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:43 -0000 From: Matt Joyce In a follow up patch, struct _reent is optionally replaced by dedicated thread-local objects. In this case,_REENT is optionally defined to NULL.= Add the _REENT_IS_NULL() macro to disable this check on demand. --- newlib/libc/include/sys/reent.h | 2 ++ newlib/libc/machine/spu/c99ppe.h | 8 +++++++- newlib/libc/stdio/local.h | 3 ++- newlib/libc/sys/arm/syscalls.c | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index fa9c6cf82..90f848180 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -763,6 +763,8 @@ extern struct _reent _impure_data __ATTRIBUTE_IMPURE_= DATA__; # define _REENT _impure_ptr #endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */ =20 +#define _REENT_IS_NULL(_ptr) ((_ptr) =3D=3D NULL) + #define _GLOBAL_REENT (&_impure_data) =20 /* This value is used in stdlib/misc.c. reent/reent.c has to know it diff --git a/newlib/libc/machine/spu/c99ppe.h b/newlib/libc/machine/spu/c= 99ppe.h index 7b3fcb6b7..6e03d2cb9 100644 --- a/newlib/libc/machine/spu/c99ppe.h +++ b/newlib/libc/machine/spu/c99ppe.h @@ -104,6 +104,12 @@ FILE *__sfp (struct _reent *); #define __sfp_free(fp) ( (fp)->_fp =3D 0 ) =20 #define CHECK_INIT(ptr) \ - do { if ((ptr) && !_REENT_CLEANUP(ptr)) __sinit (ptr); } while (0) + do \ + { \ + if (!_REENT_IS_NULL(ptr) && \ + !_REENT_CLEANUP(ptr)) \ + __sinit (ptr); \ + } \ + while (0) #define CHECK_STR_INIT(ptr) /* currently, do nothing */ #endif /* __ASSEMBLER__ */ diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 24eaff351..b34c7c9d8 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -197,7 +197,8 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _re= ent *, void *, do \ { \ struct _reent *_check_init_ptr =3D (ptr); \ - if ((_check_init_ptr) && !_REENT_CLEANUP(_check_init_ptr))\ + if (!_REENT_IS_NULL(_check_init_ptr) && \ + !_REENT_CLEANUP(_check_init_ptr)) \ __sinit (_check_init_ptr); \ } \ while (0) diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscall= s.c index 325c0117f..dd49ca061 100644 --- a/newlib/libc/sys/arm/syscalls.c +++ b/newlib/libc/sys/arm/syscalls.c @@ -60,7 +60,8 @@ extern void __sinit (struct _reent *); #define CHECK_INIT(ptr) \ do \ { \ - if ((ptr) && !_REENT_CLEANUP(ptr)) \ + if (!_REENT_IS_NULL(ptr) && \ + !_REENT_CLEANUP(ptr)) \ __sinit (ptr); \ } \ while (0) --=20 2.35.3