diff --git a/src/internal/libc.h b/src/internal/libc.h index 51ee1860cd305793ed912dfc8933eef0aa7b0684..212f0e8bd8ff8263aad8821bc87420a965b0b0cd 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -23,8 +23,6 @@ struct __libc { volatile int ofl_lock[2]; size_t tls_size; size_t page_size; - volatile int uselocale_cnt; - volatile int bytelocale_cnt_minus_1; struct __locale_struct global_locale; }; diff --git a/src/internal/locale_impl.h b/src/internal/locale_impl.h index 9142f0c278133b44e91c19ee1a1852cc056db52b..5aebbf68866a8241e0c6aa4c3b4498496c30d1cb 100644 --- a/src/internal/locale_impl.h +++ b/src/internal/locale_impl.h @@ -20,11 +20,9 @@ const char *__lctrans_cur(const char *); #define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)-2]) #define LCTRANS_CUR(msg) __lctrans_cur(msg) -#define CURRENT_LOCALE \ - (libc.uselocale_cnt ? __pthread_self()->locale : &libc.global_locale) +#define CURRENT_LOCALE (__pthread_self()->locale) -#define CURRENT_UTF8 \ - (libc.bytelocale_cnt_minus_1<0 || __pthread_self()->locale->ctype_utf8) +#define CURRENT_UTF8 (__pthread_self()->locale->ctype_utf8) #undef MB_CUR_MAX #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1) diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 8ea389a3c118d570cbc3a0eb54d03ba52df39bf2..d797f43fe8855c3393fb41b965eaefabb578542c 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -55,12 +55,7 @@ char *setlocale(int cat, const char *name) return buf; } - if (name) { - int adj = libc.global_locale.ctype_utf8; - __setlocalecat(&libc.global_locale, cat, name); - adj -= libc.global_locale.ctype_utf8; - if (adj) a_fetch_add(&libc.bytelocale_cnt_minus_1, adj); - } + if (name) __setlocalecat(&libc.global_locale, cat, name); switch (cat) { case LC_CTYPE: diff --git a/src/locale/uselocale.c b/src/locale/uselocale.c index 510679575944dd1cfe04589d3e2b1b9f547c60ba..b70a0c185fb616a85b566e5ca82c5c6bf8c44207 100644 --- a/src/locale/uselocale.c +++ b/src/locale/uselocale.c @@ -10,15 +10,7 @@ locale_t __uselocale(locale_t new) if (new == LC_GLOBAL_LOCALE) new = global; - if (new && new != old) { - int adj = 0; - if (new == global) a_dec(&libc.uselocale_cnt); - else if (!new->ctype_utf8) adj++; - if (old == global) a_inc(&libc.uselocale_cnt); - else if (!old->ctype_utf8) adj--; - a_fetch_add(&libc.bytelocale_cnt_minus_1, adj); - self->locale = new; - } + self->locale = new; return old == global ? LC_GLOBAL_LOCALE : old; } diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 4eb8b8881d2871ed27153a506594924a9a8f90bb..de72818d778a30ae7be178096ed52e50ac3451e5 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -67,12 +67,6 @@ _Noreturn void __pthread_exit(void *result) exit(0); } - if (self->locale != &libc.global_locale) { - a_dec(&libc.uselocale_cnt); - if (self->locale->ctype_utf8) - a_dec(&libc.bytelocale_cnt_minus_1); - } - /* Process robust list in userspace to handle non-pshared mutexes * and the detached thread case where the robust list head will * be invalid when the kernel would process it. */