the code being removed used atomics to track whether any threads might
be using a locale other than the current global locale, and whether
any threads might have abstract 8-bit (non-UTF-8) LC_CTYPE active, a
feature which was never committed (still pending). the motivations
were to support early execution prior to setup of the thread pointer,
to partially support systems (ancient kernels) where thread pointer
setup is not possible, and to avoid high performance cost on archs
where accessing the thread pointer may be very slow.
since commit
19a1fe670acb3ab9ead0fe31859ca7d4fe40dd54, the thread
pointer is always available, so these hacks are no longer needed.
removing them greatly simplifies the affected code.
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;
};
#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)
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:
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;
}
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. */