1//===-----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__std_mbstate_t.h>
15#include <cstdlib>
16#if _LIBCPP_HAS_WIDE_CHARACTERS
17# include <cwchar>
18#endif
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#if defined(_LIBCPP_BUILDING_LIBRARY)
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __locale {
28
29inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t) { return MB_CUR_MAX; }
30
31# if _LIBCPP_HAS_WIDE_CHARACTERS
32inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t) { return std::btowc(__c); }
33
34inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t) { return std::wctob(__c); }
35
36inline _LIBCPP_HIDE_FROM_ABI size_t
37__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t) {
38 return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // Non-standard
39}
40
41inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t) {
42 return std::wcrtomb(__s, __wc, __ps);
43}
44
45inline _LIBCPP_HIDE_FROM_ABI size_t
46__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t) {
47 return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // Non-standard
48}
49
50inline _LIBCPP_HIDE_FROM_ABI size_t
51__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t) {
52 return std::mbrtowc(__pwc, __s, __n, __ps);
53}
54
55inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t) {
56 return std::mbtowc(__pwc, __pmb, __max);
57}
58
59inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t) {
60 return std::mbrlen(__s, __n, __ps);
61}
62
63inline _LIBCPP_HIDE_FROM_ABI size_t
64__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t) {
65 return std::mbsrtowcs(__dest, __src, __len, __ps);
66}
67# endif // _LIBCPP_HAS_WIDE_CHARACTERS
68
69} // namespace __locale
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP_BUILDING_LIBRARY
73#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H