From a68ca43b9014ae45feb3162a5f066524e2b38e1a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 6 Jul 2016 15:41:35 +0200 Subject: [PATCH] Redefine locale info in struct _reent for per-thread locales The _reent members _current_category and _current_locale are not used at all. _current_locale is set to "C" in various points of the code but its value is just as unused as _current_category. This patch redefines these members without changing the size of the structure to allow for an implementation of per-thread locales per POSIX-1.2008 (i.e. uselocale and usage of the per-thread locale in subsequent function calls). Signed-off-by: Corinna Vinschen --- newlib/libc/include/sys/reent.h | 17 +++++++++++------ winsup/cygwin/dcrt0.cc | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h index 5481ca234..28fbecbdc 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -37,6 +37,11 @@ typedef __uint32_t __ULong; struct _reent; +/* TODO: This structure type isn't defined yet. It's supposed to be used + by locale-specific functions in case a pre-thread locale per SUSv4 has + been specified. */ +struct _thr_locale_t; + /* * If _REENT_SMALL is defined, we make struct _reent as small as possible, * by having nearly everything possible allocated at first use. @@ -384,8 +389,9 @@ struct _reent int __sdidinit; /* 1 means stdio has been init'd */ - int _current_category; /* unused */ - _CONST char *_current_locale; /* unused */ + /* TODO */ + int _unspecified_locale_info; /* unused, reserved for locale stuff */ + struct _thr_locale_t *_locale;/* per-thread locale */ struct _mprec *_mp; @@ -450,7 +456,6 @@ extern const struct __sFILE_fake __sf_fake_stderr; { (var)->_stdin = (__FILE *)&__sf_fake_stdin; \ (var)->_stdout = (__FILE *)&__sf_fake_stdout; \ (var)->_stderr = (__FILE *)&__sf_fake_stderr; \ - (var)->_current_locale = "C"; \ } /* Only built the assert() calls if we are built with debugging. */ @@ -577,8 +582,9 @@ struct _reent int _inc; /* used by tmpnam */ char _emergency[_REENT_EMERGENCY_SIZE]; - int _current_category; /* used by setlocale */ - _CONST char *_current_locale; + /* TODO */ + int _unspecified_locale_info; /* unused, reserved for locale stuff */ + struct _thr_locale_t *_locale;/* per-thread locale */ int __sdidinit; /* 1 means stdio has been init'd */ @@ -697,7 +703,6 @@ struct _reent { (var)->_stdin = &(var)->__sf[0]; \ (var)->_stdout = &(var)->__sf[1]; \ (var)->_stderr = &(var)->__sf[2]; \ - (var)->_current_locale = "C"; \ (var)->_new._reent._rand_next = 1; \ (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \ diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 2b8b9f51c..232841176 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -740,7 +740,6 @@ dll_crt0_0 () _impure_ptr->_stdin = &_impure_ptr->__sf[0]; _impure_ptr->_stdout = &_impure_ptr->__sf[1]; _impure_ptr->_stderr = &_impure_ptr->__sf[2]; - _impure_ptr->_current_locale = "C"; user_data->impure_ptr = _impure_ptr; user_data->impure_ptr_ptr = &_impure_ptr;