tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Alternative access for C locale



Hi all,
there was a concern about exposing the C locale via the special NULL
argument on source-changes. The attached patch provides LC_C_LOCALE and
LC_GLOBAL_LOCALE for access to the corresponding locales. Inside libc,
they are protected, so that access can avoid the GOT and use PC relative
addressing if supported by the platform. This removes the last potential
performance penality of the *_l wrapping.

The patch allows LC_GLOBAL_LOCALE for all locale functions, which is an
extension over POSIX. LC_C_LOCALE can be easily implemented using
newlocale() if necessary on platforms lacking it. I'm in the process of
getting it supported e.g. by Apple as well.

The patch contains one chunk from the mbsnrtowcs patch that is unrelated
and not for commit, but I don't want to edit that out before commit time.

Joerg
Index: include/locale.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/include/locale.h,v
retrieving revision 1.21
diff -u -p -r1.21 locale.h
--- include/locale.h    30 Apr 2013 00:45:04 -0000      1.21
+++ include/locale.h    7 May 2013 12:53:38 -0000
@@ -85,10 +85,6 @@ typedef struct _locale               *locale_t;
 #  endif
 #endif
 
-#ifdef __SETLOCALE_SOURCE__
-#define _LC_GLOBAL_LOCALE      ((locale_t)-1)
-#endif
-
 __BEGIN_DECLS
 struct lconv *localeconv(void);
 char *setlocale(int, const char *) __RENAME(__setlocale50);
@@ -109,6 +105,16 @@ locale_t   duplocale(locale_t);
 void           freelocale(locale_t);
 struct lconv   *localeconv_l(locale_t);
 locale_t       newlocale(int, const char *, locale_t);
+
+#ifndef _LIBC
+extern struct _locale  _lc_global_locale;
+extern const struct _locale _lc_C_locale;
+#else
+extern __dso_protected struct _locale  _lc_global_locale;
+extern __dso_protected const struct _locale _lc_C_locale;
+#endif
+#define LC_GLOBAL_LOCALE       (&_lc_global_locale)
+#define LC_C_LOCALE            ((locale_t)__UNCONST(&_lc_C_locale))
 #endif
 __END_DECLS
 
Index: lib/libc/gdtoa/strtod.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gdtoa/strtod.c,v
retrieving revision 1.13
diff -u -p -r1.13 strtod.c
--- lib/libc/gdtoa/strtod.c     19 Apr 2013 10:41:53 -0000      1.13
+++ lib/libc/gdtoa/strtod.c     7 May 2013 11:13:01 -0000
@@ -1103,7 +1103,7 @@ _int_strtod_l(CONST char *s00, char **se
 double
 strtod(CONST char *s, char **sp)
 {
-       return _int_strtod_l(s, sp, *_current_locale());
+       return _int_strtod_l(s, sp, LC_GLOBAL_LOCALE);
 }
 
 #ifdef __weak_alias
@@ -1113,7 +1113,5 @@ __weak_alias(strtod_l, _strtod_l)
 double
 strtod_l(CONST char *s, char **sp, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return _int_strtod_l(s, sp, loc);
 }
Index: lib/libc/gdtoa/strtof.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gdtoa/strtof.c,v
retrieving revision 1.6
diff -u -p -r1.6 strtof.c
--- lib/libc/gdtoa/strtof.c     18 Apr 2013 21:54:11 -0000      1.6
+++ lib/libc/gdtoa/strtof.c     7 May 2013 11:13:03 -0000
@@ -96,13 +96,11 @@ _int_strtof_l(CONST char *s, char **sp, 
 float
 strtof(CONST char *s, char **sp)
 {
-       return _int_strtof_l(s, sp, *_current_locale());
+       return _int_strtof_l(s, sp, LC_GLOBAL_LOCALE);
 }
 
 float
 strtof_l(CONST char *s, char **sp, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return _int_strtof_l(s, sp, loc);
 }
Index: lib/libc/gdtoa/strtof_vaxf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gdtoa/strtof_vaxf.c,v
retrieving revision 1.7
diff -u -p -r1.7 strtof_vaxf.c
--- lib/libc/gdtoa/strtof_vaxf.c        18 Apr 2013 21:54:11 -0000      1.7
+++ lib/libc/gdtoa/strtof_vaxf.c        7 May 2013 11:13:05 -0000
@@ -83,13 +83,11 @@ _int_strtof_l(CONST char *s, char **sp, 
 float
 strtof(CONST char *s, char **sp)
 {
-       return _int_strtof_l(s, sp, *_current_locale());
+       return _int_strtof_l(s, sp, LC_GLOBAL_LOCALE);
 }
 
 float
 strtof_l(CONST char *s, char **sp, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return _int_strtof_l(s, sp, loc);
 }
Index: lib/libc/gdtoa/strtold_subr.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gdtoa/strtold_subr.c,v
retrieving revision 1.2
diff -u -p -r1.2 strtold_subr.c
--- lib/libc/gdtoa/strtold_subr.c       18 Apr 2013 21:54:11 -0000      1.2
+++ lib/libc/gdtoa/strtold_subr.c       7 May 2013 11:13:07 -0000
@@ -53,13 +53,11 @@ _int_strtold_l(const char *nptr, char **
 long double
 strtold(CONST char *s, char **sp)
 {
-       return _int_strtold_l(s, sp, *_current_locale());
+       return _int_strtold_l(s, sp, LC_GLOBAL_LOCALE);
 }
 
 long double
 strtold_l(CONST char *s, char **sp, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return _int_strtold_l(s, sp, loc);
 }
Index: lib/libc/gen/isctype.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gen/isctype.c,v
retrieving revision 1.23
diff -u -p -r1.23 isctype.c
--- lib/libc/gen/isctype.c      16 Apr 2013 11:29:13 -0000      1.23
+++ lib/libc/gen/isctype.c      7 May 2013 11:06:20 -0000
@@ -57,8 +57,6 @@ is##name(int c) \
 int \
 is##name ## _l(int c, locale_t loc) \
 { \
-       if (loc == NULL) \
-               loc = _C_locale; \
        return (int)(((loc->cache->ctype_tab + 1)[c]) & (bit)); \
 }
 
@@ -84,8 +82,6 @@ toupper(int c)
 int
 toupper_l(int c, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return (int)(((loc->cache->toupper_tab + 1)[c]));
 }
 
@@ -98,8 +94,6 @@ tolower(int c)
 int
 tolower_l(int c, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return (int)(((loc->cache->tolower_tab + 1)[c]));
 }
 
Index: lib/libc/locale/Makefile.inc
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/Makefile.inc,v
retrieving revision 1.62
diff -u -p -r1.62 Makefile.inc
--- lib/libc/locale/Makefile.inc        30 Apr 2013 00:45:05 -0000      1.62
+++ lib/libc/locale/Makefile.inc        7 May 2013 11:03:43 -0000
@@ -6,7 +6,7 @@
 
 SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
        setlocale.c __mb_cur_max.c \
-       current_locale.c c_locale.c duplocale.c global_locale.c fix_grouping.c \
+       c_locale.c duplocale.c global_locale.c fix_grouping.c \
        freelocale.c localeconv.c newlocale.c nl_langinfo.c \
        generic_lc_all.c dummy_lc_collate.c \
        wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \
Index: lib/libc/locale/_wcstod.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/_wcstod.h,v
retrieving revision 1.3
diff -u -p -r1.3 _wcstod.h
--- lib/libc/locale/_wcstod.h   18 Apr 2013 22:23:17 -0000      1.3
+++ lib/libc/locale/_wcstod.h   7 May 2013 11:13:09 -0000
@@ -134,15 +134,13 @@ _RETURN_TYPE
 INT_NAME(, _FUNCNAME, )(const wchar_t * __restrict nptr,
     wchar_t ** __restrict endptr)
 {
-       return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, *_current_locale());
+       return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, LC_GLOBAL_LOCALE);
 }
 
 _RETURN_TYPE
 INT_NAME(, _FUNCNAME, _l)(const wchar_t * __restrict nptr,
     wchar_t ** __restrict endptr, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, loc);
 }
 #endif /*__WCSTOD_H_*/
Index: lib/libc/locale/_wcstol.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/_wcstol.h,v
retrieving revision 1.5
diff -u -p -r1.5 _wcstol.h
--- lib/libc/locale/_wcstol.h   16 Apr 2013 16:52:13 -0000      1.5
+++ lib/libc/locale/_wcstol.h   7 May 2013 11:13:11 -0000
@@ -150,14 +150,12 @@ __INT
 _FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
 {
        return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base,
-                                                 *_current_locale());
+                                                 LC_GLOBAL_LOCALE);
 }
 
 __INT
 INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
                              int base, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
 }
Index: lib/libc/locale/_wcstoul.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/_wcstoul.h,v
retrieving revision 1.5
diff -u -p -r1.5 _wcstoul.h
--- lib/libc/locale/_wcstoul.h  16 Apr 2013 16:52:13 -0000      1.5
+++ lib/libc/locale/_wcstoul.h  7 May 2013 11:13:17 -0000
@@ -126,14 +126,12 @@ __UINT
 _FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
 {
        return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base,
-                                                 *_current_locale());
+                                                 LC_GLOBAL_LOCALE);
 }
 
 __UINT
 INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
                              int base, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
 }
Index: lib/libc/locale/c_locale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/c_locale.c,v
retrieving revision 1.2
diff -u -p -r1.2 c_locale.c
--- lib/libc/locale/c_locale.c  21 Apr 2013 17:45:46 -0000      1.2
+++ lib/libc/locale/c_locale.c  7 May 2013 12:24:56 -0000
@@ -145,7 +145,7 @@ static const struct _locale_cache_t _C_c
 #endif
 };
 
-static const struct _locale __C_locale = {
+__dso_protected const struct _locale _lc_C_locale = {
     .cache = __UNCONST(&_C_cache),
     .query = { _C_LOCALE },
     .part_name = {
@@ -172,5 +172,3 @@ static const struct _locale __C_locale =
            __UNCONST(&_DefaultTimeLocale),
     },
 };
-
-__dso_hidden struct _locale *_C_locale = __UNCONST(&__C_locale);
Index: lib/libc/locale/current_locale.c
===================================================================
RCS file: lib/libc/locale/current_locale.c
diff -N lib/libc/locale/current_locale.c
--- lib/libc/locale/current_locale.c    14 Apr 2013 23:30:16 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-/* $NetBSD: current_locale.c,v 1.4 2013/04/14 23:30:16 joerg Exp $ */
-
-/*-
- * Copyright (c)2008 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: current_locale.c,v 1.4 2013/04/14 23:30:16 joerg Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <langinfo.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
-#include <stdlib.h>
-
-#include "setlocale_local.h"
-
-static struct _locale *__current_locale = &_global_locale;
-
-struct _locale **
-_current_locale(void)
-{
-       return &__current_locale;
-}
Index: lib/libc/locale/freelocale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/freelocale.c,v
retrieving revision 1.1
diff -u -p -r1.1 freelocale.c
--- lib/libc/locale/freelocale.c        30 Apr 2013 00:45:05 -0000      1.1
+++ lib/libc/locale/freelocale.c        7 May 2013 10:59:36 -0000
@@ -44,8 +44,8 @@ void
 freelocale(locale_t locale)
 {
 
-       _DIAGASSERT(locale != _LC_GLOBAL_LOCALE);
+       _DIAGASSERT(locale != LC_GLOBAL_LOCALE);
+       _DIAGASSERT(locale != LC_C_LOCALE);
        _DIAGASSERT(locale != NULL);
-       _DIAGASSERT(locale != &_global_locale);
        free(locale);
 }
Index: lib/libc/locale/global_locale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/global_locale.c,v
retrieving revision 1.16
diff -u -p -r1.16 global_locale.c
--- lib/libc/locale/global_locale.c     21 Apr 2013 17:45:46 -0000      1.16
+++ lib/libc/locale/global_locale.c     7 May 2013 11:03:15 -0000
@@ -147,7 +147,7 @@ static struct _locale_cache_t _global_ca
 #endif
 };
 
-struct _locale _global_locale = {
+__dso_protected struct _locale _lc_global_locale = {
     .cache = &_global_cache,
     .query = { _C_LOCALE },
     .part_name = {
Index: lib/libc/locale/iswctype_mb.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/iswctype_mb.c,v
retrieving revision 1.12
diff -u -p -r1.12 iswctype_mb.c
--- lib/libc/locale/iswctype_mb.c       16 Apr 2013 11:39:13 -0000      1.12
+++ lib/libc/locale/iswctype_mb.c       7 May 2013 11:13:23 -0000
@@ -57,9 +57,6 @@ isw##name##_l(wint_t wc, locale_t loc)                
        _RuneLocale const *rl;                          \
        _WCTypeEntry const *te;                         \
                                                        \
-       if (loc == NULL)                                \
-               loc = _C_locale;                        \
-                                                       \
        rl = _RUNE_LOCALE(loc);                         \
        te = &rl->rl_wctype[index];                     \
        return _iswctype_priv(rl, wc, te);              \
@@ -67,7 +64,7 @@ isw##name##_l(wint_t wc, locale_t loc)                
 int                                                    \
 isw##name(wint_t wc)                                   \
 {                                                      \
-       return isw##name##_l(wc, *_current_locale());   \
+       return isw##name##_l(wc, LC_GLOBAL_LOCALE);     \
 }
 
 _ISWCTYPE_FUNC(alnum,  _WCTYPE_INDEX_ALNUM)
@@ -90,9 +87,6 @@ tow##name##_l(wint_t wc, locale_t loc)                
        _RuneLocale const *rl;                          \
        _WCTransEntry const *te;                        \
                                                        \
-       if (loc == NULL)                                \
-               loc = _C_locale;                        \
-                                                       \
        rl = _RUNE_LOCALE(loc);                         \
        te = &rl->rl_wctrans[index];                    \
        return _towctrans_priv(wc, te);                 \
@@ -100,7 +94,7 @@ tow##name##_l(wint_t wc, locale_t loc)               
 wint_t                                                 \
 tow##name(wint_t wc)                                   \
 {                                                      \
-       return tow##name##_l(wc, *_current_locale());   \
+       return tow##name##_l(wc, LC_GLOBAL_LOCALE);     \
 }
 _TOWCTRANS_FUNC(upper, _WCTRANS_INDEX_UPPER)
 _TOWCTRANS_FUNC(lower, _WCTRANS_INDEX_LOWER)
@@ -111,9 +105,6 @@ wctype_l(const char *charclass, locale_t
        _RuneLocale const *rl;
        size_t i;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        rl = _RUNE_LOCALE(loc);
        for (i = 0; i < _WCTYPE_NINDEXES; ++i) {
                if (!strcmp(rl->rl_wctype[i].te_name, charclass))
@@ -125,7 +116,7 @@ wctype_l(const char *charclass, locale_t
 wctype_t
 wctype(const char *charclass)
 {
-       return wctype_l(charclass, *_current_locale());
+       return wctype_l(charclass, LC_GLOBAL_LOCALE);
 }
 
 wctrans_t
@@ -134,9 +125,6 @@ wctrans_l(const char *charmap, locale_t 
        _RuneLocale const *rl;
        size_t i;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        rl = _RUNE_LOCALE(loc);
        for (i = 0; i < _WCTRANS_NINDEXES; ++i) {
                _DIAGASSERT(rl->rl_wctrans[i].te_name != NULL);
@@ -149,7 +137,7 @@ wctrans_l(const char *charmap, locale_t 
 wctrans_t
 wctrans(const char *charmap)
 {
-       return wctrans_l(charmap, *_current_locale());
+       return wctrans_l(charmap, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -163,9 +151,6 @@ iswctype_l(wint_t wc, wctype_t charclass
                return 0;
        }
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        rl = _RUNE_LOCALE(loc);
        te = (_WCTypeEntry const *)(void *)charclass;
        return _iswctype_priv(rl, wc, te);
@@ -174,7 +159,7 @@ iswctype_l(wint_t wc, wctype_t charclass
 int
 iswctype(wint_t wc, wctype_t charclass)
 {
-       return iswctype_l(wc, charclass, *_current_locale());
+       return iswctype_l(wc, charclass, LC_GLOBAL_LOCALE);
 }
 
 wint_t
@@ -209,9 +194,6 @@ wcwidth_l(wchar_t wc, locale_t loc)
        if (wc == L'\0')
                return 0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        rl = _RUNE_LOCALE(loc);
        x = _runetype_priv(rl, wc);
        if (x & _RUNETYPE_R)
@@ -222,7 +204,7 @@ wcwidth_l(wchar_t wc, locale_t loc)
 int
 wcwidth(wchar_t wc)
 {
-       return wcwidth_l(wc, *_current_locale());
+       return wcwidth_l(wc, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -234,9 +216,6 @@ wcswidth_l(const wchar_t * __restrict ws
 
        _DIAGASSERT(ws != NULL);
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        rl = _RUNE_LOCALE(loc);
        width = 0;
        while (wn > 0 && *ws != L'\0') {
@@ -252,5 +231,5 @@ wcswidth_l(const wchar_t * __restrict ws
 int
 wcswidth(const wchar_t * __restrict ws, size_t wn)
 {
-       return wcswidth_l(ws, wn, *_current_locale());
+       return wcswidth_l(ws, wn, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/locale/localeconv.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/localeconv.c,v
retrieving revision 1.20
diff -u -p -r1.20 localeconv.c
--- lib/libc/locale/localeconv.c        17 Apr 2013 20:40:13 -0000      1.20
+++ lib/libc/locale/localeconv.c        7 May 2013 11:08:46 -0000
@@ -47,7 +47,5 @@ localeconv(void)
 struct lconv *
 localeconv_l(locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        return loc->cache->ldata;
 }
Index: lib/libc/locale/multibyte_amd1.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/multibyte_amd1.c,v
retrieving revision 1.11
diff -u -p -r1.11 multibyte_amd1.c
--- lib/libc/locale/multibyte_amd1.c    19 Apr 2013 14:35:33 -0000      1.11
+++ lib/libc/locale/multibyte_amd1.c    7 May 2013 11:14:07 -0000
@@ -59,9 +59,6 @@ mbrlen_l(const char *s, size_t n, mbstat
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
 
        err0 = _citrus_ctype_mbrlen(_ps_to_ctype(ps), s, n,
@@ -75,7 +72,7 @@ mbrlen_l(const char *s, size_t n, mbstat
 size_t
 mbrlen(const char *s, size_t n, mbstate_t *ps)
 {
-       return mbrlen_l(s, n, ps, *_current_locale());
+       return mbrlen_l(s, n, ps, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -88,9 +85,6 @@ mbsinit_l(const mbstate_t *ps, locale_t 
        if (ps == NULL)
                return 1;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        if (_ps_to_runelocale(ps) == NULL)
                rl = _RUNE_LOCALE(loc);
        else
@@ -108,7 +102,7 @@ mbsinit_l(const mbstate_t *ps, locale_t 
 int
 mbsinit(const mbstate_t *ps)
 {
-       return mbsinit_l(ps, *_current_locale());
+       return mbsinit_l(ps, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -117,9 +111,6 @@ mbrtowc_l(wchar_t *pwc, const char *s, s
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
 
        err0 = _citrus_ctype_mbrtowc(_ps_to_ctype(ps), pwc, s, n,
@@ -133,7 +124,7 @@ mbrtowc_l(wchar_t *pwc, const char *s, s
 size_t
 mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 {
-       return mbrtowc_l(pwc, s, n, ps, *_current_locale());
+       return mbrtowc_l(pwc, s, n, ps, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -143,9 +134,6 @@ mbsrtowcs_l(wchar_t *pwcs, const char **
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
 
        err0 = _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps), pwcs, s, n,
@@ -159,17 +147,37 @@ mbsrtowcs_l(wchar_t *pwcs, const char **
 size_t
 mbsrtowcs(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps)
 {
-       return mbsrtowcs_l(pwcs, s, n, ps, *_current_locale());
+       return mbsrtowcs_l(pwcs, s, n, ps, LC_GLOBAL_LOCALE);
 }
 
 size_t
-wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t loc)
+mbsnrtowcs_l(wchar_t *pwcs, const char **s, size_t in, size_t n, mbstate_t *ps,
+    locale_t loc)
 {
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
+       _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
+
+       err0 = _citrus_ctype_mbsnrtowcs(_ps_to_ctype(ps), pwcs, s, in, n,
+                                       _ps_to_private(ps), &ret);
+       if (err0)
+               errno = err0;
+
+       return ret;
+}
+
+size_t
+mbsnrtowcs(wchar_t *pwcs, const char **s, size_t in, size_t n, mbstate_t *ps)
+{
+       return mbsnrtowcs_l(pwcs, s, in, n, ps, LC_GLOBAL_LOCALE);
+}
+
+size_t
+wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t loc)
+{
+       size_t ret;
+       int err0;
 
        _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
 
@@ -184,7 +192,7 @@ wcrtomb_l(char *s, wchar_t wc, mbstate_t
 size_t
 wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
 {
-       return wcrtomb_l(s, wc, ps, *_current_locale());
+       return wcrtomb_l(s, wc, ps, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -194,9 +202,6 @@ wcsrtombs_l(char *s, const wchar_t **ppw
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
 
        err0 = _citrus_ctype_wcsrtombs(_ps_to_ctype(ps), s, ppwcs, n,
@@ -210,7 +215,30 @@ wcsrtombs_l(char *s, const wchar_t **ppw
 size_t
 wcsrtombs(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps)
 {
-       return wcsrtombs_l(s, ppwcs, n, ps, *_current_locale());
+       return wcsrtombs_l(s, ppwcs, n, ps, LC_GLOBAL_LOCALE);
+}
+
+size_t
+wcsnrtombs_l(char *s, const wchar_t **ppwcs, size_t in, size_t n, mbstate_t 
*ps,
+    locale_t loc)
+{
+       size_t ret;
+       int err0;
+
+       _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
+
+       err0 = _citrus_ctype_wcsnrtombs(_ps_to_ctype(ps), s, ppwcs, in, n,
+                                       _ps_to_private(ps), &ret);
+       if (err0)
+               errno = err0;
+
+       return ret;
+}
+
+size_t
+wcsnrtombs(char *s, const wchar_t **ppwcs, size_t in, size_t n, mbstate_t *ps)
+{
+       return wcsnrtombs_l(s, ppwcs, in, n, ps, LC_GLOBAL_LOCALE);
 }
 
 wint_t
@@ -219,9 +247,6 @@ btowc_l(int c, locale_t loc)
        wint_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_btowc(_CITRUS_CTYPE(loc), c, &ret);
        if (err0)
                errno = err0;
@@ -232,7 +257,7 @@ btowc_l(int c, locale_t loc)
 wint_t
 btowc(int c)
 {
-       return btowc_l(c, *_current_locale());
+       return btowc_l(c, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -241,9 +266,6 @@ wctob_l(wint_t wc, locale_t loc)
        int ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_wctob(_CITRUS_CTYPE(loc), wc, &ret);
        if (err0)
                errno = err0;
@@ -254,14 +276,12 @@ wctob_l(wint_t wc, locale_t loc)
 int
 wctob(wint_t wc)
 {
-       return wctob_l(wc, *_current_locale());
+       return wctob_l(wc, LC_GLOBAL_LOCALE);
 }
 
 size_t
 _mb_cur_max_l(locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
 
        return _citrus_ctype_get_mb_cur_max(_CITRUS_CTYPE(loc));
 }
Index: lib/libc/locale/multibyte_c90.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/multibyte_c90.c,v
retrieving revision 1.9
diff -u -p -r1.9 multibyte_c90.c
--- lib/libc/locale/multibyte_c90.c     18 Apr 2013 22:22:21 -0000      1.9
+++ lib/libc/locale/multibyte_c90.c     7 May 2013 11:13:29 -0000
@@ -55,9 +55,6 @@ mblen_l(const char *s, size_t n, locale_
        int ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_mblen(_CITRUS_CTYPE(loc), s, n, &ret);
        if (err0)
                errno = err0;
@@ -69,7 +66,7 @@ mblen_l(const char *s, size_t n, locale_
 int
 mblen(const char *s, size_t n)
 {
-       return mblen_l(s, n, *_current_locale());
+       return mblen_l(s, n, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -78,9 +75,6 @@ mbstowcs_l(wchar_t *pwcs, const char *s,
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_mbstowcs(_CITRUS_CTYPE(loc), pwcs, s, n, &ret);
        if (err0)
                errno = err0;
@@ -91,7 +85,7 @@ mbstowcs_l(wchar_t *pwcs, const char *s,
 size_t
 mbstowcs(wchar_t *pwcs, const char *s, size_t n)
 {
-       return mbstowcs_l(pwcs, s, n, *_current_locale());
+       return mbstowcs_l(pwcs, s, n, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -100,9 +94,6 @@ mbtowc_l(wchar_t *pw, const char *s, siz
        int ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_mbtowc(_CITRUS_CTYPE(loc), pw, s, n, &ret);
        if (err0)
                errno = err0;
@@ -113,7 +104,7 @@ mbtowc_l(wchar_t *pw, const char *s, siz
 int
 mbtowc(wchar_t *pw, const char *s, size_t n)
 {
-       return mbtowc_l(pw, s, n, *_current_locale());
+       return mbtowc_l(pw, s, n, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -122,9 +113,6 @@ wcstombs_l(char *s, const wchar_t *wcs, 
        size_t ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_wcstombs(_CITRUS_CTYPE(loc), s, wcs, n, &ret);
        if (err0)
                errno = err0;
@@ -135,7 +123,7 @@ wcstombs_l(char *s, const wchar_t *wcs, 
 size_t
 wcstombs(char *s, const wchar_t *wcs, size_t n)
 {
-       return wcstombs_l(s, wcs, n, *_current_locale());
+       return wcstombs_l(s, wcs, n, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -144,9 +132,6 @@ wctomb_l(char *s, wchar_t wc, locale_t l
        int ret;
        int err0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        err0 = _citrus_ctype_wctomb(_CITRUS_CTYPE(loc), s, wc, &ret);
        if (err0)
                errno = err0;
@@ -157,5 +142,5 @@ wctomb_l(char *s, wchar_t wc, locale_t l
 int
 wctomb(char *s, wchar_t wc)
 {
-       return wctomb_l(s, wc, *_current_locale());
+       return wctomb_l(s, wc, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/locale/nb_lc_template.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/nb_lc_template.h,v
retrieving revision 1.5
diff -u -p -r1.5 nb_lc_template.h
--- lib/libc/locale/nb_lc_template.h    14 Apr 2013 23:30:16 -0000      1.5
+++ lib/libc/locale/nb_lc_template.h    7 May 2013 11:02:28 -0000
@@ -236,7 +236,7 @@ _PREFIX(setlocale)(const char * __restri
                        locale->part_impl[(size_t)_CATEGORY_ID]
                            = part->impl;
                        _PREFIX(build_cache)(locale->cache, part->impl);
-                       if (locale == &_global_locale)
+                       if (locale == LC_GLOBAL_LOCALE)
                                _PREFIX(fixup)(part->impl);
                }
        }
Index: lib/libc/locale/newlocale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/newlocale.c,v
retrieving revision 1.1
diff -u -p -r1.1 newlocale.c
--- lib/libc/locale/newlocale.c 30 Apr 2013 00:45:05 -0000      1.1
+++ lib/libc/locale/newlocale.c 7 May 2013 11:14:14 -0000
@@ -55,7 +55,7 @@ newlocale(int mask, const char *name, lo
        if (dst == NULL)
                return (locale_t)NULL;
        if (src == NULL)
-               src = *_current_locale();
+               src = LC_GLOBAL_LOCALE;
        memcpy(dst, src, sizeof(*src));
        strlcpy(&head[0], name, sizeof(head));
        tokens[0] = (const char *)&head[0];
Index: lib/libc/locale/setlocale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/setlocale.c,v
retrieving revision 1.62
diff -u -p -r1.62 setlocale.c
--- lib/libc/locale/setlocale.c 30 Apr 2013 00:45:05 -0000      1.62
+++ lib/libc/locale/setlocale.c 7 May 2013 11:14:18 -0000
@@ -101,7 +101,7 @@ __setlocale(int category, const char *na
        sl = _find_category(category);
        if (sl == NULL)
                return NULL;
-       impl = *_current_locale();
+       impl = LC_GLOBAL_LOCALE;
        return __UNCONST((*sl)(name, impl));
 }
 
Index: lib/libc/locale/setlocale_local.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/setlocale_local.h,v
retrieving revision 1.11
diff -u -p -r1.11 setlocale_local.h
--- lib/libc/locale/setlocale_local.h   14 Apr 2013 23:44:54 -0000      1.11
+++ lib/libc/locale/setlocale_local.h   7 May 2013 14:00:12 -0000
@@ -66,7 +66,6 @@ typedef const char *(*_locale_set_t)(con
 __BEGIN_DECLS
 _locale_set_t          _find_category(int);
 const char             *_get_locale_env(const char *);
-struct _locale         **_current_locale(void);
 char                   *__setlocale(int, const char *);
 
 const char *_generic_LC_ALL_setlocale(
@@ -85,14 +84,16 @@ const char *_citrus_LC_MESSAGES_setlocal
     const char * __restrict, struct _locale * __restrict);
 __END_DECLS
 
+#ifdef _LIBC
+extern __dso_protected struct _locale  _lc_global_locale;
+
 static __inline struct _locale_cache_t *
 _current_cache(void)
 {
-       return (*_current_locale())->cache;
+       return _lc_global_locale.cache;
 }
+#endif
 
-extern struct _locale  _global_locale;
-extern __dso_hidden struct _locale *_C_locale;
 extern size_t __mb_len_max_runtime;
 
 #endif /*_SETLOCALE_LOCAL_H_*/
Index: lib/libc/locale/wcscoll.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/wcscoll.c,v
retrieving revision 1.3
diff -u -p -r1.3 wcscoll.c
--- lib/libc/locale/wcscoll.c   18 Apr 2013 23:24:27 -0000      1.3
+++ lib/libc/locale/wcscoll.c   7 May 2013 11:14:00 -0000
@@ -44,8 +44,6 @@ __RCSID("$NetBSD: wcscoll.c,v 1.3 2013/0
 int
 wcscoll_l(const wchar_t *s1, const wchar_t *s2, locale_t loc)
 {
-       if (loc == NULL)
-               loc = _C_locale;
        /* XXX: LC_COLLATE should be implemented. */
        /* LINTED */ (void)loc;
        return (wcscmp(s1, s2));
@@ -54,5 +52,5 @@ wcscoll_l(const wchar_t *s1, const wchar
 int
 wcscoll(const wchar_t *s1, const wchar_t *s2)
 {
-       return wcscoll_l(s1, s2, *_current_locale());
+       return wcscoll_l(s1, s2, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/locale/wcsxfrm.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/wcsxfrm.c,v
retrieving revision 1.4
diff -u -p -r1.4 wcsxfrm.c
--- lib/libc/locale/wcsxfrm.c   18 Apr 2013 23:24:27 -0000      1.4
+++ lib/libc/locale/wcsxfrm.c   7 May 2013 11:14:02 -0000
@@ -46,8 +46,6 @@ wcsxfrm_l(wchar_t *s1, const wchar_t *s2
 {
        size_t len;
 
-       if (loc == NULL)
-               loc = _C_locale;
        /* XXX: LC_COLLATE should be implemented. */
        /* LINTED */(void)loc;
 
@@ -69,5 +67,5 @@ wcsxfrm_l(wchar_t *s1, const wchar_t *s2
 size_t
 wcsxfrm(wchar_t *s1, const wchar_t *s2, size_t n)
 {
-       return wcsxfrm_l(s1, s2, n, *_current_locale());
+       return wcsxfrm_l(s1, s2, n, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/stdio/vasprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vasprintf.c,v
retrieving revision 1.15
diff -u -p -r1.15 vasprintf.c
--- lib/libc/stdio/vasprintf.c  19 Apr 2013 15:22:25 -0000      1.15
+++ lib/libc/stdio/vasprintf.c  7 May 2013 11:14:24 -0000
@@ -88,7 +88,7 @@ err:
 int
 vasprintf(char **str, const char *fmt, va_list ap)
 {
-       return vasprintf_l(str, *_current_locale(), fmt, ap);
+       return vasprintf_l(str, LC_GLOBAL_LOCALE, fmt, ap);
 }
 
 int
Index: lib/libc/stdio/vdprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vdprintf.c,v
retrieving revision 1.3
diff -u -p -r1.3 vdprintf.c
--- lib/libc/stdio/vdprintf.c   19 Apr 2013 15:22:25 -0000      1.3
+++ lib/libc/stdio/vdprintf.c   7 May 2013 11:14:26 -0000
@@ -121,5 +121,5 @@ vdprintf_l(int fd, locale_t loc, const c
 int
 vdprintf(int fd, const char * __restrict fmt, va_list ap)
 {
-       return vdprintf_l(fd, *_current_locale(), fmt, ap);
+       return vdprintf_l(fd, LC_GLOBAL_LOCALE, fmt, ap);
 }
Index: lib/libc/stdio/vfscanf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vfscanf.c,v
retrieving revision 1.44
diff -u -p -r1.44 vfscanf.c
--- lib/libc/stdio/vfscanf.c    19 Apr 2013 23:32:17 -0000      1.44
+++ lib/libc/stdio/vfscanf.c    7 May 2013 11:14:28 -0000
@@ -132,7 +132,7 @@ __collate_range_cmp(int c1, int c2, loca
 int
 __svfscanf(FILE *fp, char const *fmt0, va_list ap)
 {
-       return __svfscanf_l(fp, *_current_locale(), fmt0, ap);
+       return __svfscanf_l(fp, LC_GLOBAL_LOCALE, fmt0, ap);
 }
 
 int
Index: lib/libc/stdio/vfwprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vfwprintf.c,v
retrieving revision 1.31
diff -u -p -r1.31 vfwprintf.c
--- lib/libc/stdio/vfwprintf.c  19 Apr 2013 15:22:25 -0000      1.31
+++ lib/libc/stdio/vfwprintf.c  7 May 2013 11:14:55 -0000
@@ -552,7 +552,7 @@ WDECL(vf,printf)(FILE * __restrict fp, c
        int ret;
 
        FLOCKFILE(fp);
-       ret = WDECL(__vf,printf_unlocked_l)(fp, *_current_locale(), fmt0, ap);
+       ret = WDECL(__vf,printf_unlocked_l)(fp, LC_GLOBAL_LOCALE, fmt0, ap);
        FUNLOCKFILE(fp);
        return ret;
 }
@@ -705,9 +705,6 @@ WDECL(__vf,printf_unlocked_l)(FILE *fp, 
        static const char xdigs_lower[16] = "0123456789abcdef";
        static const char xdigs_upper[16] = "0123456789ABCDEF";
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        /*
         * BEWARE, these `goto error' on error, PRINT uses `n2' and
         * PAD uses `n'.
Index: lib/libc/stdio/vfwscanf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vfwscanf.c,v
retrieving revision 1.9
diff -u -p -r1.9 vfwscanf.c
--- lib/libc/stdio/vfwscanf.c   19 Apr 2013 23:32:17 -0000      1.9
+++ lib/libc/stdio/vfwscanf.c   7 May 2013 11:14:54 -0000
@@ -114,7 +114,7 @@ static int parsefloat(FILE *, wchar_t *,
 int
 vfwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, va_list ap)
 {
-       return vfwscanf_l(fp, *_current_locale(), fmt, ap);
+       return vfwscanf_l(fp, LC_GLOBAL_LOCALE, fmt, ap);
 }
 
 int
@@ -171,9 +171,6 @@ __vfwscanf_unlocked_l(FILE * __restrict 
        static short basefix[17] =
                { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        nassigned = 0;
        nconversions = 0;
        nread = 0;
Index: lib/libc/stdio/vsnprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vsnprintf.c,v
retrieving revision 1.26
diff -u -p -r1.26 vsnprintf.c
--- lib/libc/stdio/vsnprintf.c  19 Apr 2013 15:22:25 -0000      1.26
+++ lib/libc/stdio/vsnprintf.c  7 May 2013 11:14:52 -0000
@@ -100,7 +100,7 @@ vsnprintf_l(char *str, size_t n, locale_
 int
 vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
 {
-       return vsnprintf_l(str, n, *_current_locale(), fmt, ap);
+       return vsnprintf_l(str, n, LC_GLOBAL_LOCALE, fmt, ap);
 }
 
 int
Index: lib/libc/stdio/vsprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vsprintf.c,v
retrieving revision 1.18
diff -u -p -r1.18 vsprintf.c
--- lib/libc/stdio/vsprintf.c   19 Apr 2013 15:22:25 -0000      1.18
+++ lib/libc/stdio/vsprintf.c   7 May 2013 11:14:51 -0000
@@ -83,7 +83,7 @@ vsprintf_l(char *str, locale_t loc, cons
 int
 vsprintf(char *str, const char *fmt, va_list ap)
 {
-       return vsprintf_l(str, *_current_locale(), fmt, ap);
+       return vsprintf_l(str, LC_GLOBAL_LOCALE, fmt, ap);
 }
 
 int
Index: lib/libc/stdio/vsscanf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vsscanf.c,v
retrieving revision 1.20
diff -u -p -r1.20 vsscanf.c
--- lib/libc/stdio/vsscanf.c    19 Apr 2013 23:32:17 -0000      1.20
+++ lib/libc/stdio/vsscanf.c    7 May 2013 11:14:49 -0000
@@ -85,5 +85,5 @@ vsscanf_l(const char *str, locale_t loc,
 int
 vsscanf(const char *str, const char *fmt, va_list ap)
 {
-       return vsscanf_l(str, *_current_locale(), fmt, ap);
+       return vsscanf_l(str, LC_GLOBAL_LOCALE, fmt, ap);
 }
Index: lib/libc/stdio/vswprintf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vswprintf.c,v
retrieving revision 1.4
diff -u -p -r1.4 vswprintf.c
--- lib/libc/stdio/vswprintf.c  19 Apr 2013 15:22:25 -0000      1.4
+++ lib/libc/stdio/vswprintf.c  7 May 2013 11:14:48 -0000
@@ -109,5 +109,5 @@ int
 vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt,
     va_list ap)
 {
-       return vswprintf_l(s, n, *_current_locale(), fmt, ap);
+       return vswprintf_l(s, n, LC_GLOBAL_LOCALE, fmt, ap);
 }
Index: lib/libc/stdio/vswscanf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/stdio/vswscanf.c,v
retrieving revision 1.11
diff -u -p -r1.11 vswscanf.c
--- lib/libc/stdio/vswscanf.c   22 Apr 2013 19:33:53 -0000      1.11
+++ lib/libc/stdio/vswscanf.c   7 May 2013 11:14:46 -0000
@@ -115,5 +115,5 @@ int
 vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
     va_list ap)
 {
-       return vswscanf_l(str, *_current_locale(), fmt, ap);
+       return vswscanf_l(str, LC_GLOBAL_LOCALE, fmt, ap);
 }
Index: lib/libc/string/strcoll.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/string/strcoll.c,v
retrieving revision 1.11
diff -u -p -r1.11 strcoll.c
--- lib/libc/string/strcoll.c   19 Apr 2013 23:28:47 -0000      1.11
+++ lib/libc/string/strcoll.c   7 May 2013 11:14:44 -0000
@@ -57,7 +57,7 @@ int
 strcoll(const char *s1, const char *s2)
 {
 
-       return strcoll_l(s1, s2, *_current_locale());
+       return strcoll_l(s1, s2, LC_GLOBAL_LOCALE);
 }
 
 int
@@ -66,9 +66,6 @@ strcoll_l(const char *s1, const char *s2
        _DIAGASSERT(s1 != NULL);
        _DIAGASSERT(s2 != NULL);
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        /* LC_COLLATE is unimplemented, hence always "C" */
        /* LINTED */ (void)loc;
        return (strcmp(s1, s2));
Index: lib/libc/string/strxfrm.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/string/strxfrm.c,v
retrieving revision 1.13
diff -u -p -r1.13 strxfrm.c
--- lib/libc/string/strxfrm.c   19 Apr 2013 23:28:47 -0000      1.13
+++ lib/libc/string/strxfrm.c   7 May 2013 11:14:42 -0000
@@ -62,8 +62,6 @@ strxfrm_l(char *dst, const char *src, si
 
        _DIAGASSERT(src != NULL);
 
-       if (loc == NULL)
-               loc = _C_locale;
        /* XXX: LC_COLLATE should be implemented. */
        /* LINTED */(void)loc;
 
@@ -83,5 +81,5 @@ strxfrm_l(char *dst, const char *src, si
 size_t
 strxfrm(char *dst, const char *src, size_t n)
 {
-       return strxfrm_l(dst, src, n, *_current_locale());
+       return strxfrm_l(dst, src, n, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/string/wcscasecmp.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/string/wcscasecmp.c,v
retrieving revision 1.3
diff -u -p -r1.3 wcscasecmp.c
--- lib/libc/string/wcscasecmp.c        18 Apr 2013 23:24:27 -0000      1.3
+++ lib/libc/string/wcscasecmp.c        7 May 2013 11:14:40 -0000
@@ -33,9 +33,6 @@ wcscasecmp_l(const wchar_t *s1, const wc
        int lc2  = 0;
        int diff = 0;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        _DIAGASSERT(s1);
        _DIAGASSERT(s2);
 
@@ -58,5 +55,5 @@ wcscasecmp_l(const wchar_t *s1, const wc
 int
 wcscasecmp(const wchar_t *s1, const wchar_t *s2)
 {
-       return wcscasecmp_l(s1, s2, *_current_locale());
+       return wcscasecmp_l(s1, s2, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/string/wcsncasecmp.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/string/wcsncasecmp.c,v
retrieving revision 1.3
diff -u -p -r1.3 wcsncasecmp.c
--- lib/libc/string/wcsncasecmp.c       18 Apr 2013 23:24:27 -0000      1.3
+++ lib/libc/string/wcsncasecmp.c       7 May 2013 11:14:39 -0000
@@ -36,9 +36,6 @@ wcsncasecmp_l(const wchar_t *s1, const w
        _DIAGASSERT(s1);
        _DIAGASSERT(s2);
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        while (n--) {
                lc1 = towlower_l(*s1, loc);
                lc2 = towlower_l(*s2, loc);
@@ -60,5 +57,5 @@ wcsncasecmp_l(const wchar_t *s1, const w
 int
 wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
 {
-       return wcsncasecmp_l(s1, s2, n, *_current_locale());
+       return wcsncasecmp_l(s1, s2, n, LC_GLOBAL_LOCALE);
 }
Index: lib/libc/time/strftime.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/time/strftime.c,v
retrieving revision 1.25
diff -u -p -r1.25 strftime.c
--- lib/libc/time/strftime.c    21 Apr 2013 17:45:46 -0000      1.25
+++ lib/libc/time/strftime.c    7 May 2013 11:14:32 -0000
@@ -111,7 +111,7 @@ size_t
 strftime_z(const timezone_t sp, char * __restrict s, size_t maxsize,
     const char * __restrict format, const struct tm * __restrict t)
 {
-       return strftime_lz(sp, s, maxsize, format, t, *_current_locale());
+       return strftime_lz(sp, s, maxsize, format, t, LC_GLOBAL_LOCALE);
 }
 
 size_t
@@ -121,9 +121,6 @@ strftime_lz(const timezone_t sp, char *c
        char *  p;
        int     warn;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        warn = IN_NONE;
        p = _fmt(sp, ((format == NULL) ? "%c" : format), t, s, s + maxsize,
            &warn, loc);
Index: lib/libc/time/strptime.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/time/strptime.c,v
retrieving revision 1.37
diff -u -p -r1.37 strptime.c
--- lib/libc/time/strptime.c    21 Apr 2013 17:45:47 -0000      1.37
+++ lib/libc/time/strptime.c    7 May 2013 11:14:34 -0000
@@ -77,7 +77,7 @@ static const u_char *find_string(const u
 char *
 strptime(const char *buf, const char *fmt, struct tm *tm)
 {
-       return strptime_l(buf, fmt, tm, *_current_locale());
+       return strptime_l(buf, fmt, tm, LC_GLOBAL_LOCALE);
 }
 
 char *
@@ -88,9 +88,6 @@ strptime_l(const char *buf, const char *
        int alt_format, i, split_year = 0, neg = 0, offs;
        const char *new_fmt;
 
-       if (loc == NULL)
-               loc = _C_locale;
-
        bp = (const u_char *)buf;
 
        while (bp != NULL && (c = *fmt++) != '\0') {


Home | Main Index | Thread Index | Old Index