public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Add _REENT_LOCALE(ptr) Date: Wed, 13 Jul 2022 08:19:43 +0000 (GMT) [thread overview] Message-ID: <20220713081943.42D76385C41C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=50f078b48cea6664975b87cbacf2a7dfacb42fba commit 50f078b48cea6664975b87cbacf2a7dfacb42fba Author: Matt Joyce <matthew.joyce@embedded-brains.de> Date: Wed Feb 2 12:47:30 2022 +0100 Add _REENT_LOCALE(ptr) 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/reent.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 = LC_GLOBAL_LOCALE; if (newloc == LC_GLOBAL_LOCALE) - p->_locale = NULL; + _REENT_LOCALE(p) = NULL; else if (newloc) - p->_locale = newloc; + _REENT_LOCALE(p) = newloc; return current_locale; }
reply other threads:[~2022-07-13 8:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220713081943.42D76385C41C@sourceware.org \ --to=sh@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).