From 37fcc13c12ade19c37a1a8ac80be4a14e21cff1e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 9 Dec 2020 16:58:32 -0500 Subject: lift locale lock out of internal __get_locale this allows the lock to be shared with setlocale, eliminates repeated per-category lock/unlock in newlocale, and will allow the use of pthread_once in newlocale to be dropped (to be done separately). --- src/locale/locale_map.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/locale/locale_map.c') diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c index fa51f2e3..da61f7fc 100644 --- a/src/locale/locale_map.c +++ b/src/locale/locale_map.c @@ -28,8 +28,8 @@ static const char envvars[][12] = { "LC_MESSAGES", }; -static volatile int lock[1]; -volatile int *const __locale_lockptr = lock; +volatile int __locale_lock[1]; +volatile int *const __locale_lockptr = __locale_lock; const struct __locale_map *__get_locale(int cat, const char *val) { @@ -63,14 +63,6 @@ const struct __locale_map *__get_locale(int cat, const char *val) for (p=loc_head; p; p=p->next) if (!strcmp(val, p->name)) return p; - LOCK(lock); - - for (p=loc_head; p; p=p->next) - if (!strcmp(val, p->name)) { - UNLOCK(lock); - return p; - } - if (!libc.secure) path = getenv("MUSL_LOCPATH"); /* FIXME: add a default path? */ @@ -117,6 +109,5 @@ const struct __locale_map *__get_locale(int cat, const char *val) * requested name was "C" or "POSIX". */ if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; - UNLOCK(lock); return new; } -- cgit v1.2.1