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.
This commit is contained in:
parent
0985d418cb
commit
50f078b48c
|
@ -721,6 +721,7 @@ struct _reent
|
||||||
#define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency)
|
#define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency)
|
||||||
#define _REENT_ERRNO(_ptr) ((_ptr)->_errno)
|
#define _REENT_ERRNO(_ptr) ((_ptr)->_errno)
|
||||||
#define _REENT_INC(_ptr) ((_ptr)->_inc)
|
#define _REENT_INC(_ptr) ((_ptr)->_inc)
|
||||||
|
#define _REENT_LOCALE(_ptr) ((_ptr)->_locale)
|
||||||
#define _REENT_STDIN(_ptr) ((_ptr)->_stdin)
|
#define _REENT_STDIN(_ptr) ((_ptr)->_stdin)
|
||||||
#define _REENT_STDOUT(_ptr) ((_ptr)->_stdout)
|
#define _REENT_STDOUT(_ptr) ((_ptr)->_stdout)
|
||||||
#define _REENT_STDERR(_ptr) ((_ptr)->_stderr)
|
#define _REENT_STDERR(_ptr) ((_ptr)->_stderr)
|
||||||
|
|
|
@ -218,7 +218,7 @@ _ELIDABLE_INLINE struct __locale_t *
|
||||||
__get_locale_r (struct _reent *r)
|
__get_locale_r (struct _reent *r)
|
||||||
{
|
{
|
||||||
#ifdef __HAVE_LOCALE_INFO__
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
return r->_locale;
|
return _REENT_LOCALE(r);
|
||||||
#else
|
#else
|
||||||
return __get_global_locale();
|
return __get_global_locale();
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,7 +232,7 @@ _ELIDABLE_INLINE struct __locale_t *
|
||||||
__get_current_locale (void)
|
__get_current_locale (void)
|
||||||
{
|
{
|
||||||
#ifdef __HAVE_LOCALE_INFO__
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
return _REENT->_locale ?: __get_global_locale ();
|
return _REENT_LOCALE(_REENT) ?: __get_global_locale ();
|
||||||
#else
|
#else
|
||||||
return __get_global_locale();
|
return __get_global_locale();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,9 +64,9 @@ _uselocale_r (struct _reent *p, struct __locale_t *newloc)
|
||||||
if (!current_locale)
|
if (!current_locale)
|
||||||
current_locale = LC_GLOBAL_LOCALE;
|
current_locale = LC_GLOBAL_LOCALE;
|
||||||
if (newloc == LC_GLOBAL_LOCALE)
|
if (newloc == LC_GLOBAL_LOCALE)
|
||||||
p->_locale = NULL;
|
_REENT_LOCALE(p) = NULL;
|
||||||
else if (newloc)
|
else if (newloc)
|
||||||
p->_locale = newloc;
|
_REENT_LOCALE(p) = newloc;
|
||||||
return current_locale;
|
return current_locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue