Module Name: src Committed By: christos Date: Sun Jul 28 17:41:21 UTC 2019
Modified Files: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly: c_locale.cc c_locale.h codecvt_members.cc ctype_members.cc monetary_members.cc numeric_members.cc time_members.cc Added Files: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly: xlocale_port.h Log Message: Factor out the uselocale() calls by providing the _l missing functions as inlines in xlocale_port.h except in c_locale.{cc,h} because the header gets installed. To generate a diff of this commit: cvs rdiff -u -r1.1.1.3 -r1.2 \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc cvs rdiff -u -r1.1.1.2 -r1.2 \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc cvs rdiff -u -r0 -r1.1 \ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/xlocale_port.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc:1.1.1.3 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc:1.1.1.3 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc Sun Jul 28 13:41:21 2019 @@ -34,7 +34,9 @@ #include <stdexcept> #include <limits> #include <langinfo.h> +#ifndef __NetBSD__ #include <xlocale.h> +#endif namespace std _GLIBCXX_VISIBILITY(default) { Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc:1.1.1.3 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc:1.1.1.3 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/ctype_members.cc Sun Jul 28 13:41:21 2019 @@ -33,6 +33,8 @@ #include <cstring> #include <cstdio> +#include "xlocale_port.h" + #ifndef _ISbit #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) #endif @@ -96,9 +98,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION case graph: __ret = wctype_l("graph", (locale_t)_M_c_locale_ctype); break; +#ifndef __NetBSD__ case blank: __ret = wctype_l("blank", (locale_t)_M_c_locale_ctype); break; +#endif default: __ret = __wmask_type(); } @@ -135,6 +139,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __hi; } + bool + ctype<wchar_t>:: + do_is(mask __m, char_type __c) const + { + bool __ret = false; + // Generically, 15 (instead of 11) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (__m & _M_bit[__bitcur] + && iswctype(__c, _M_wmask[__bitcur])) + { + __ret = true; + break; + } + return __ret; + } + + const wchar_t* + ctype<wchar_t>:: + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const + { + for (;__lo < __hi; ++__vec, ++__lo) + { + // Generically, 15 (instead of 11) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; + mask __m = 0; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (iswctype(*__lo, _M_wmask[__bitcur])) + __m |= _M_bit[__bitcur]; + *__vec = __m; + } + return __hi; + } + + const wchar_t* + ctype<wchar_t>:: + do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi && !this->do_is(__m, *__lo)) + ++__lo; + return __lo; + } + + const wchar_t* + ctype<wchar_t>:: + do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { + while (__lo < __hi && this->do_is(__m, *__lo) != 0) + ++__lo; + return __lo; + } + wchar_t ctype<wchar_t>:: do_widen(char __c) const @@ -159,9 +217,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { if (__wc >= 0 && __wc < 128 && _M_narrow_ok) return _M_narrow[__wc]; - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); - const int __c = wctob(__wc); - uselocale((locale_t)__old); + const int __c = wctob_l(__wc, (locale_t)_M_c_locale_ctype); return (__c == EOF ? __dfault : static_cast<char>(__c)); } @@ -170,7 +226,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault, char* __dest) const { - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); if (_M_narrow_ok) while (__lo < __hi) { @@ -178,7 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION *__dest = _M_narrow[*__lo]; else { - const int __c = wctob(*__lo); + const int __c = wctob_l(*__lo, (locale_t)_M_c_locale_ctype); *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); } ++__lo; @@ -187,23 +242,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else while (__lo < __hi) { - const int __c = wctob(*__lo); + const int __c = wctob_l(*__lo, (locale_t)_M_c_locale_ctype); *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); ++__lo; ++__dest; } - uselocale((locale_t)__old); return __hi; } void ctype<wchar_t>::_M_initialize_ctype() throw() { - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); wint_t __i; for (__i = 0; __i < 128; ++__i) { - const int __c = wctob(__i); + const int __c = wctob_l(__i, (locale_t)_M_c_locale_ctype); if (__c == EOF) break; else @@ -222,7 +275,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_bit[__k] = static_cast<mask>(_ISbit(__k)); _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]); } - uselocale((locale_t)__old); } #endif // _GLIBCXX_USE_WCHAR_T Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h:1.1.1.2 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h:1.1.1.2 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h Sun Jul 28 13:41:21 2019 @@ -40,7 +40,11 @@ #pragma GCC system_header #include <clocale> +#ifndef __NetBSD__ #include <xlocale.h> +#else +#include <cstdio> +#endif #define _GLIBCXX_NUM_CATEGORIES 0 @@ -59,20 +63,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { +#ifndef __NetBSD__ __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); +#endif __builtin_va_list __args; __builtin_va_start(__args, __fmt); +#ifndef __NetBSD__ #if _GLIBCXX_USE_C99_STDIO const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); #endif + uselocale((locale_t)__old); +#else + const int __ret = vsnprintf_l(__out, __size, (locale_t)__cloc, __fmt, + __args); +#endif + __builtin_va_end(__args); - uselocale((locale_t)__old); return __ret; } Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc:1.1.1.2 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc:1.1.1.2 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc Sun Jul 28 13:41:21 2019 @@ -34,6 +34,8 @@ #include <cstdlib> // For MB_CUR_MAX #include <climits> // For MB_LEN_MAX +#include "xlocale_port.h" + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -50,8 +52,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION result __ret = ok; state_type __tmp_state(__state); - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); - // wcsnrtombs is *very* fast but stops if encounters NUL characters: // in case we fall back to wcrtomb and then continue, in a loop. // NB: wcsnrtombs is a GNU extension @@ -65,16 +65,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __from_chunk_end = __from_end; __from = __from_next; - const size_t __conv = wcsnrtombs(__to_next, &__from_next, + const size_t __conv = wcsnrtombs_l(__to_next, &__from_next, __from_chunk_end - __from_next, - __to_end - __to_next, &__state); + __to_end - __to_next, &__state, + (locale_t)_M_c_locale_codecvt); if (__conv == static_cast<size_t>(-1)) { // In case of error, in order to stop at the exact place we // have to start again from the beginning with a series of // wcrtomb. for (; __from < __from_next; ++__from) - __to_next += wcrtomb(__to_next, *__from, &__tmp_state); + __to_next += wcrtomb_l(__to_next, *__from, &__tmp_state, + (locale_t)_M_c_locale_codecvt); __state = __tmp_state; __ret = error; } @@ -93,7 +95,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { extern_type __buf[MB_LEN_MAX]; __tmp_state = __state; - const size_t __conv2 = wcrtomb(__buf, *__from_next, &__tmp_state); + const size_t __conv2 = wcrtomb_l(__buf, *__from_next, &__tmp_state, + (locale_t)_M_c_locale_codecvt); if (__conv2 > static_cast<size_t>(__to_end - __to_next)) __ret = partial; else @@ -106,8 +109,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } - uselocale((locale_t)__old); - return __ret; } @@ -121,8 +122,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION result __ret = ok; state_type __tmp_state(__state); - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); - // mbsnrtowcs is *very* fast but stops if encounters NUL characters: // in case we store a L'\0' and then continue, in a loop. // NB: mbsnrtowcs is a GNU extension @@ -138,9 +137,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __from_chunk_end = __from_end; __from = __from_next; - size_t __conv = mbsnrtowcs(__to_next, &__from_next, + size_t __conv = mbsnrtowcs_l(__to_next, &__from_next, __from_chunk_end - __from_next, - __to_end - __to_next, &__state); + __to_end - __to_next, &__state, + (locale_t)_M_c_locale_codecvt); if (__conv == static_cast<size_t>(-1)) { // In case of error, in order to stop at the exact place we @@ -148,8 +148,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // mbrtowc. for (;; ++__to_next, __from += __conv) { - __conv = mbrtowc(__to_next, __from, __from_end - __from, - &__tmp_state); + __conv = mbrtowc_l(__to_next, __from, __from_end - __from, + &__tmp_state), (locale_t)_M_c_locale_codecvt); if (__conv == static_cast<size_t>(-1) || __conv == static_cast<size_t>(-2)) break; @@ -184,8 +184,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } - uselocale((locale_t)__old); - return __ret; } @@ -195,23 +193,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // XXX This implementation assumes that the encoding is // stateless and is either single-byte or variable-width. - int __ret = 0; - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); - if (MB_CUR_MAX == 1) - __ret = 1; - uselocale((locale_t)__old); - return __ret; + return MB_CUR_MAX_L((locale_t)_M_c_locale_codecvt) == 1 ? 1 : 0; } int codecvt<wchar_t, char, mbstate_t>:: do_max_length() const throw() { - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); // XXX Probably wrong for stateful encodings. - int __ret = MB_CUR_MAX; - uselocale((locale_t)__old); - return __ret; + return MB_CUR_MAX_L((locale_t)_M_c_locale_codecvt); } int @@ -222,8 +212,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION int __ret = 0; state_type __tmp_state(__state); - __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); - // mbsnrtowcs is *very* fast but stops if encounters NUL characters: // in case we advance past it and then continue, in a loop. // NB: mbsnrtowcs is a GNU extension @@ -242,9 +230,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __from_chunk_end = __end; const extern_type* __tmp_from = __from; - size_t __conv = mbsnrtowcs(__to, &__from, + size_t __conv = mbsnrtowcs_l(__to, &__from, __from_chunk_end - __from, - __max, &__state); + __max, &__state), + (locale_t)_M_c_locale_codecvt); if (__conv == static_cast<size_t>(-1)) { // In case of error, in order to stop at the exact place we @@ -252,8 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // mbrtowc. for (__from = __tmp_from;; __from += __conv) { - __conv = mbrtowc(0, __from, __end - __from, - &__tmp_state); + __conv = mbrtowc_l(0, __from, __end - __from, + &__tmp_state, (locale_t)_M_c_locale_codecvt); if (__conv == static_cast<size_t>(-1) || __conv == static_cast<size_t>(-2)) break; @@ -278,8 +267,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } - uselocale((locale_t)__old); - return __ret; } #endif Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc:1.1.1.2 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc:1.1.1.2 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/monetary_members.cc Sun Jul 28 13:41:21 2019 @@ -31,7 +31,8 @@ #include <locale> #include <cstring> -#include <xlocale.h> + +#include "xlocale_port.h" namespace std _GLIBCXX_VISIBILITY(default) { @@ -581,7 +582,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); // Named locale. lconv* lc = localeconv_l((locale_t) __cloc); @@ -647,7 +647,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); __wcs_ps = new wchar_t[__len + 1]; - mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); + mbsrtowcs_l(__wcs_ps, &__cpossign, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_positive_sign = __wcs_ps; } else @@ -662,7 +663,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); __wcs_ns = new wchar_t[__len + 1]; - mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); + mbsrtowcs_l(__wcs_ps, &__cpossign, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_negative_sign = __wcs_ns; } else @@ -676,7 +678,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len + 1]; - mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); + mbsrtowcs_l(__wcs, &__ccurr, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_curr_symbol = __wcs; } else @@ -690,7 +693,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION delete [] __group; delete [] __wcs_ps; delete [] __wcs_ns; - uselocale((locale_t)__old); __throw_exception_again; } @@ -703,8 +705,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char __nspace = lc->int_n_sep_by_space; _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); - - uselocale((locale_t)__old); } } @@ -741,7 +741,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); // Named locale. lconv* lc = localeconv_l((locale_t) __cloc); @@ -807,7 +806,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); __wcs_ps = new wchar_t[__len + 1]; - mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); + mbsrtowcs_l(__wcs_ps, &__cpossign, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_positive_sign = __wcs_ps; } else @@ -822,7 +822,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); __wcs_ns = new wchar_t[__len + 1]; - mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); + mbsrtowcs_l(__wcs_ns, &__cnegsign, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_negative_sign = __wcs_ns; } else @@ -836,7 +837,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len + 1]; - mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); + mbsrtowcs_l(__wcs, &__ccurr, __len + 1, &__state, + (locale_t)__cloc); _M_data->_M_curr_symbol = __wcs; } else @@ -850,7 +852,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION delete [] __group; delete [] __wcs_ps; delete [] __wcs_ns; - uselocale((locale_t)__old); __throw_exception_again; } @@ -863,8 +864,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char __nspace = lc->n_sep_by_space; _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); - - uselocale((locale_t)__old); } } Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc:1.1.1.2 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc:1.1.1.2 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/numeric_members.cc Sun Jul 28 13:41:21 2019 @@ -31,7 +31,8 @@ #include <locale> #include <cstring> -#include <xlocale.h> + +#include "xlocale_port.h" namespace std _GLIBCXX_VISIBILITY(default) { Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc:1.1.1.2 src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc:1.2 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc:1.1.1.2 Sat Jan 19 05:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/time_members.cc Sun Jul 28 13:41:21 2019 @@ -35,7 +35,8 @@ #include <cwchar> #include <stdlib.h> #include <langinfo.h> -#include <xlocale.h> + +#include "xlocale_port.h" namespace std _GLIBCXX_VISIBILITY(default) { Added files: Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/xlocale_port.h diff -u /dev/null src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/xlocale_port.h:1.1 --- /dev/null Sun Jul 28 13:41:21 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/xlocale_port.h Sun Jul 28 13:41:21 2019 @@ -0,0 +1,70 @@ +#ifndef __NetBSD__ +#include <xlocale.h> + +static __inline int +MB_CUR_MAX_L(locale_t __l) { + locale_t __old = uselocale(__l); + size_t __rv = MB_CUR_MAX; + (void)uselocale(__old); + return __rv; +} + +static __inline size_t +wcsnrtombs_l(char * __restrict __to, const wchar_t ** __restrict __from, + size_t __nwc, size_t __len, mbstate_t * __restrict __st, locale_t __l) +{ + locale_t __old = uselocale(__l); + size_t __rv = wcsnrtombs(__to, __from, __nwc, __len, __st); + (void)uselocale(__old); + return __rv; +} + +static __inline size_t +mbsnrtowcs_l(wchar_t * __restrict __to, const char ** __restrict __from, + size_t __nms, size_t __len, mbstate_t * __restrict __st, locale_t __l) +{ + locale_t __old = uselocale(__l); + size_t __rv = mbsnrtowcs(__to, __from, __nms, __len, __st); + (void)uselocale(__old); + return __rv; +} + +static __inline size_t +wcrtomb_l(char * __restrict __to, wchar_t __from, + mbstate_t * __restrict __st, locale_t __l) +{ + locale_t __old = uselocale(__l); + size_t __rv = wcrtomb(__to, __from, __st); + (void)uselocale(__old); + return __rv; +} + +static __inline size_t +mbrtowc_l(wchar_t * __restrict __to, const char * __restrict __from, + size_t __len, mbstate_t * __restrict __st, locale_t __l) +{ + locale_t __old = uselocale(__l); + size_t __rv = mbrtowc(__to, __from, __len, __st); + (void)uselocale(__old); + return __rv; +} + +static __inline size_t +mbsrtowcs_l(wchar_t * __restrict __to, const char ** __restrict __from, + size_t __len, mbstate_t * __restrict __st, locale_t __l) +{ + locale_t __old = uselocale(__l); + size_t __rv = mbsrtowcs(__to, __from, __len, __st); + (void)uselocale(__old); + return __rv; +} + +static __inline int +wctob_l(wint_t __wc, locale_t __l) +{ + locale_t __old = uselocale(__l); + int __rv = wctob(__wc); + (void)uselocale(__old); + return __rv; +} +#endif