diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-12-09 16:58:32 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-12-09 16:58:32 -0500 |
commit | 37fcc13c12ade19c37a1a8ac80be4a14e21cff1e (patch) | |
tree | bf9b3460c0ca84c4abdaab1f276e6f6e6d676c1c /src/locale/newlocale.c | |
parent | c53e9b239418eb3e0e8be256abd0f6ad7608bbcf (diff) | |
download | musl-37fcc13c12ade19c37a1a8ac80be4a14e21cff1e.tar.gz musl-37fcc13c12ade19c37a1a8ac80be4a14e21cff1e.tar.bz2 musl-37fcc13c12ade19c37a1a8ac80be4a14e21cff1e.tar.xz musl-37fcc13c12ade19c37a1a8ac80be4a14e21cff1e.zip |
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).
Diffstat (limited to 'src/locale/newlocale.c')
-rw-r--r-- | src/locale/newlocale.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c index d20a8489..8eee2e10 100644 --- a/src/locale/newlocale.c +++ b/src/locale/newlocale.c @@ -2,6 +2,7 @@ #include <string.h> #include <pthread.h> #include "locale_impl.h" +#include "lock.h" static pthread_once_t default_locale_once; static struct __locale_struct default_locale, default_ctype_locale; @@ -19,7 +20,7 @@ int __loc_is_allocated(locale_t loc) && loc != &default_locale && loc != &default_ctype_locale; } -locale_t __newlocale(int mask, const char *name, locale_t loc) +static locale_t do_newlocale(int mask, const char *name, locale_t loc) { struct __locale_struct tmp; @@ -55,4 +56,12 @@ locale_t __newlocale(int mask, const char *name, locale_t loc) return loc; } +locale_t __newlocale(int mask, const char *name, locale_t loc) +{ + LOCK(__locale_lock); + loc = do_newlocale(mask, name, loc); + UNLOCK(__locale_lock); + return loc; +} + weak_alias(__newlocale, newlocale); |