From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1921) id 42D76385C41C; Wed, 13 Jul 2022 08:19:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42D76385C41C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sebastian Huber To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Add _REENT_LOCALE(ptr) X-Act-Checkin: newlib-cygwin X-Git-Author: Matt Joyce X-Git-Refname: refs/heads/master X-Git-Oldrev: 0985d418cb2d0a5ba56518e9e1fb9a31f3c7ba48 X-Git-Newrev: 50f078b48cea6664975b87cbacf2a7dfacb42fba Message-Id: <20220713081943.42D76385C41C@sourceware.org> Date: Wed, 13 Jul 2022 08:19:43 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 08:19:43 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D50f078b48ce= a6664975b87cbacf2a7dfacb42fba commit 50f078b48cea6664975b87cbacf2a7dfacb42fba Author: Matt Joyce Date: Wed Feb 2 12:47:30 2022 +0100 Add _REENT_LOCALE(ptr) =20 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. Diff: --- 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/reen= t.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/setlocale.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/uselocale.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 *newloc) 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; }