]> git.saurik.com Git - apple/libc.git/blobdiff - locale/xlocale.c
Libc-1353.11.2.tar.gz
[apple/libc.git] / locale / xlocale.c
index e5db93fe0bfdd228c780ae415ef0db5c533dcbab..6efb9a579ee288df117d1e76ab24434d917b6a66 100644 (file)
@@ -32,7 +32,7 @@
        0, XPERMANENT,                  \
        {}, {}, {}, {}, {},             \
        {}, {}, {}, {}, {},             \
-       LOCK_INITIALIZER,               \
+       OS_UNFAIR_LOCK_INIT,            \
        XMAGIC,                         \
        1, 0, 0, 0, 0, 0, 1, 1, 0,      \
        NULL,                           \
 }
 
 static char C[] = "C";
-static const struct _xlocale __c_locale = C_LOCALE_INITIALIZER;
+static struct _xlocale __c_locale = C_LOCALE_INITIALIZER;
 const locale_t _c_locale = (const locale_t)&__c_locale;
-__private_extern__ struct _xlocale __global_locale = C_LOCALE_INITIALIZER;
-__private_extern__ pthread_key_t __locale_key = (pthread_key_t)-1;
+struct _xlocale __global_locale = C_LOCALE_INITIALIZER;
+pthread_key_t __locale_key = (pthread_key_t)-1;
 
 extern int __collate_load_tables(const char *, locale_t);
 extern int __detect_path_locale(void);
@@ -105,7 +105,7 @@ _duplocale(locale_t loc)
                return NULL;
        new->__refcount = 1;
        new->__free_extra = (__free_extra_t)_releaselocale;
-       new->__lock = LOCK_INITIALIZER;
+       new->__lock = OS_UNFAIR_LOCK_INIT;
        if (loc == NULL)
                loc = __current_locale();
        else if (loc == LC_GLOBAL_LOCALE)
@@ -114,7 +114,7 @@ _duplocale(locale_t loc)
                *new = __c_locale;
                new->__refcount = 1;
                new->__free_extra = (__free_extra_t)_releaselocale;
-               new->__lock = LOCK_INITIALIZER;
+               new->__lock = OS_UNFAIR_LOCK_INIT;
                return new;
        }
        XL_LOCK(loc);
@@ -391,10 +391,7 @@ querylocale(int mask, locale_t loc)
                errno = EINVAL;
                return NULL;
        }
-       if (loc == NULL)
-               loc = __current_locale();
-       else if (loc == LC_GLOBAL_LOCALE)
-               loc = &__global_locale;
+       DEFAULT_CURRENT_LOCALE(loc);
        m = ffs(mask);
        if (m == 0 || m > _LC_NUM_MASK) {
                errno = EINVAL;
@@ -483,18 +480,13 @@ ___mb_cur_max_l(locale_t loc)
 static void
 __xlocale_release(void *loc)
 {
-       XL_RELEASE((locale_t)loc);
+       locale_t l = loc;
+       XL_RELEASE(l);
 }
 
 /*
  * Called from the Libc initializer to setup the thread-specific key.
  */
-/*
- * Partition _pthread_keys in a lower part that dyld can use, and an upper
- * part for libSystem.  The libSystem part starts at __pthread_tsd_first = 10.
- * dyld will set this value to 1.
- */
-
 __private_extern__ void
 __xlocale_init(void)
 {