am 9b22c21c
: Merge "Make uselocale(3) claim its pthread key in an ELF constructor."
* commit '9b22c21ceec0a65875081525218315d08bbd36b5': Make uselocale(3) claim its pthread key in an ELF constructor.
This commit is contained in:
commit
ccad97362a
@ -39,8 +39,11 @@ struct __locale_t {
|
||||
static pthread_once_t gLocaleOnce = PTHREAD_ONCE_INIT;
|
||||
static lconv gLocale;
|
||||
|
||||
static pthread_once_t gUselocaleKeyOnce = PTHREAD_ONCE_INIT;
|
||||
// We don't use pthread_once for this so that we know when the resource (a TLS slot) will be taken.
|
||||
static pthread_key_t gUselocaleKey;
|
||||
__attribute__((constructor)) static void __bionic_tls_uselocale_key_init() {
|
||||
pthread_key_create(&gUselocaleKey, NULL);
|
||||
}
|
||||
|
||||
static void __locale_init() {
|
||||
gLocale.decimal_point = const_cast<char*>(".");
|
||||
@ -72,10 +75,6 @@ static void __locale_init() {
|
||||
gLocale.int_n_sign_posn = CHAR_MAX;
|
||||
}
|
||||
|
||||
static void __uselocale_key_init() {
|
||||
pthread_key_create(&gUselocaleKey, NULL);
|
||||
}
|
||||
|
||||
static bool __is_supported_locale(const char* locale) {
|
||||
return (strcmp(locale, "") == 0 || strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0);
|
||||
}
|
||||
@ -139,8 +138,6 @@ char* setlocale(int category, char const* locale_name) {
|
||||
}
|
||||
|
||||
locale_t uselocale(locale_t new_locale) {
|
||||
pthread_once(&gUselocaleKeyOnce, __uselocale_key_init);
|
||||
|
||||
locale_t old_locale = static_cast<locale_t>(pthread_getspecific(gUselocaleKey));
|
||||
|
||||
// If this is the first call to uselocale(3) on this thread, we return LC_GLOBAL_LOCALE.
|
||||
|
@ -80,7 +80,7 @@ enum {
|
||||
* pthread_key_create; grep for GLOBAL_INIT_THREAD_LOCAL_BUFFER to find those. We need to manually
|
||||
* maintain that second number, but pthread_test will fail if we forget.
|
||||
*/
|
||||
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 4
|
||||
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 5
|
||||
|
||||
#define BIONIC_ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user