about summary refs log tree commit diff
path: root/src/locale/uselocale.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-05-16 01:53:54 -0400
committerRich Felker <dalias@aerifal.cx>2015-05-16 01:53:54 -0400
commit68630b55c0c7219fe9df70dc28ffbf9efc8021d8 (patch)
tree2a412da23113bfd688bbef64880e78f41222dcec /src/locale/uselocale.c
parent707d7c30f3379441de9b320536ddfd354f4c2143 (diff)
downloadmusl-68630b55c0c7219fe9df70dc28ffbf9efc8021d8.tar.gz
musl-68630b55c0c7219fe9df70dc28ffbf9efc8021d8.tar.xz
musl-68630b55c0c7219fe9df70dc28ffbf9efc8021d8.zip
eliminate costly tricks to avoid TLS access for current locale state
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.
Diffstat (limited to 'src/locale/uselocale.c')
-rw-r--r--src/locale/uselocale.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/locale/uselocale.c b/src/locale/uselocale.c
index 51067957..b70a0c18 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;
 }