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 2D9A33856965 for ; Tue, 21 Jun 2022 12:49:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D9A33856965 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-0003ZL-J6 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-000Lo9-Pf 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 8775B4800AD 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 XCYY6tb3IJlL 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 957384801D9 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 oUgIRdtqaetQ 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 6FBBC4801E8 for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 08/14] Add _REENT_LOCALE(ptr) Date: Tue, 21 Jun 2022 14:49:25 +0200 Message-Id: <20220621124931.36450-9-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:44 -0000 From: Matt Joyce Add a _REENT_LOCALE() macro to encapsulate access to the _locale 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/sys/reent.h | 1 + newlib/libc/locale/setlocale.h | 4 ++-- newlib/libc/locale/uselocale.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index 2c1593a5f..4296188f5 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_INC(_ptr) ((_ptr)->_inc) +#define _REENT_LOCALE(_ptr) ((_ptr)->_locale) #define _REENT_STDIN(_ptr) ((_ptr)->_stdin) #define _REENT_STDOUT(_ptr) ((_ptr)->_stdout) #define _REENT_STDERR(_ptr) ((_ptr)->_stderr) diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocal= e.h index a0c80843a..9f7fd7c10 100644 --- a/newlib/libc/locale/setlocale.h +++ b/newlib/libc/locale/setlocale.h @@ -218,7 +218,7 @@ _ELIDABLE_INLINE struct __locale_t * __get_locale_r (struct _reent *r) { #ifdef __HAVE_LOCALE_INFO__ - return r->_locale; + return _REENT_LOCALE(r); #else return __get_global_locale(); #endif @@ -232,7 +232,7 @@ _ELIDABLE_INLINE struct __locale_t * __get_current_locale (void) { #ifdef __HAVE_LOCALE_INFO__ - return _REENT->_locale ?: __get_global_locale (); + return _REENT_LOCALE(_REENT) ?: __get_global_locale (); #else return __get_global_locale(); #endif diff --git a/newlib/libc/locale/uselocale.c b/newlib/libc/locale/uselocal= e.c index 83ebcdd19..799fb724a 100644 --- a/newlib/libc/locale/uselocale.c +++ b/newlib/libc/locale/uselocale.c @@ -64,9 +64,9 @@ _uselocale_r (struct _reent *p, struct __locale_t *newl= oc) if (!current_locale) current_locale =3D LC_GLOBAL_LOCALE; if (newloc =3D=3D LC_GLOBAL_LOCALE) - p->_locale =3D NULL; + _REENT_LOCALE(p) =3D NULL; else if (newloc) - p->_locale =3D newloc; + _REENT_LOCALE(p) =3D newloc; return current_locale; } =20 --=20 2.35.3