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 <corinna@vinschen.de>
This commit is contained in:
		| @@ -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; \ | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user