diff --git a/libcxx/include/__bsd_locale_defaults.h b/libcxx/include/__bsd_locale_defaults.h --- a/libcxx/include/__bsd_locale_defaults.h +++ b/libcxx/include/__bsd_locale_defaults.h @@ -14,23 +14,79 @@ #ifndef _LIBCPP___BSD_LOCALE_DEFAULTS_H #define _LIBCPP___BSD_LOCALE_DEFAULTS_H +#include <__config> +#include <__utility/declval.h> +#include <__utility/forward.h> +#include +#include + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc) -#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc) -#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc) -#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc) -#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc) -#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc) -#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l) -#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l) -#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l) -#define __libcpp_localeconv_l(l) localeconv_l(l) -#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l) -#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__) -#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__) -#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__) +inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX_L(std::declval())) +__libcpp_mb_cur_max_l(locale_t __loc) _NOEXCEPT { + return MB_CUR_MAX_L(__loc); +} + +inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __loc) _NOEXCEPT { + return ::btowc_l(__c, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __loc) _NOEXCEPT { + return ::wctob_l(__c, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcsnrtombs_l( + char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI size_t +__libcpp_wcrtomb_l(char* __src, wchar_t __wc, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::wcrtomb_l(__src, __wc, __ps, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbsnrtowcs_l( + wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI size_t +__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::mbrtowc_l(__pwc, __s, __n, __ps, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI int +__libcpp_mbtowc_l(wchar_t* __pwc, const char* __s, size_t __n, locale_t __loc) _NOEXCEPT { + return ::mbtowc_l(__pwc, __s, __n, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI size_t +__libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::mbrlen_l(__s, __n, __ps, __loc); +} + +inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t __loc) _NOEXCEPT { return ::localeconv_l(__loc); } + +inline _LIBCPP_HIDE_FROM_ABI size_t +__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __loc) _NOEXCEPT { + return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc); +} + +template +int __libcpp_snprintf_l(char* __str, size_t __size, locale_t __loc, const char* __format, _Args&&... __args) _NOEXCEPT { + return ::snprintf_l(__str, __size, __loc, __format, std::forward<_Args>(__args)...); +} + +template +int __libcpp_asprintf_l(char** __ret, locale_t __loc, const char* __format, _Args&&... __args) _NOEXCEPT { + return ::asprintf_l(__ret, __loc, __format, std::forward<_Args>(__args)...); +} + +template +int __libcpp_sscanf_l(const char* __str, locale_t __loc, const char* __format, _Args&&... __args) _NOEXCEPT { + return ::sscanf_l(__str, __loc, __format, std::forward<_Args>(__args)...); +} #endif // _LIBCPP___BSD_LOCALE_DEFAULTS_H