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_LOCALE_BASE_API_H 10 #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H 11 12 #if defined(_LIBCPP_MSVCRT_LIKE) 13 # include <__locale_dir/locale_base_api/win32.h> 14 #elif defined(_AIX) || defined(__MVS__) 15 # include <__locale_dir/locale_base_api/ibm.h> 16 #elif defined(__ANDROID__) 17 # include <__locale_dir/locale_base_api/android.h> 18 #elif defined(__sun__) 19 # include <__locale_dir/locale_base_api/solaris.h> 20 #elif defined(_NEWLIB_VERSION) 21 # include <__locale_dir/locale_base_api/newlib.h> 22 #elif defined(__OpenBSD__) 23 # include <__locale_dir/locale_base_api/openbsd.h> 24 #elif defined(__Fuchsia__) 25 # include <__locale_dir/locale_base_api/fuchsia.h> 26 #elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) 27 # include <__locale_dir/locale_base_api/musl.h> 28 #elif defined(__APPLE__) || defined(__FreeBSD__) 29 # include <xlocale.h> 30 #endif 31 32 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 33 # pragma GCC system_header 34 #endif 35 36 /* 37 The platform-specific headers have to provide the following interface: 38 39 // TODO: rename this to __libcpp_locale_t 40 using locale_t = implementation-defined; 41 42 implementation-defined __libcpp_mb_cur_max_l(locale_t); 43 wint_t __libcpp_btowc_l(int, locale_t); 44 int __libcpp_wctob_l(wint_t, locale_t); 45 size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t); 46 size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t); 47 size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t); 48 size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t); 49 int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t); 50 size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t); 51 lconv* __libcpp_localeconv_l(locale_t); 52 size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t); 53 int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...); 54 int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...); 55 int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...); 56 57 // TODO: change these to reserved names 58 float strtof_l(const char* str, char** str_end, locale_t); 59 double strtod_l(const char* str, char** str_end, locale_t); 60 long double strtold_l(const char* str, char** str_end, locale_t); 61 long long strtoll_l(const char* str, char** str_end, locale_t); 62 unsigned long long strtoull_l(const char* str, char** str_end, locale_t); 63 64 locale_t newlocale(int category_mask, const char* locale, locale_t base); 65 void freelocale(locale_t); 66 67 int islower_l(int ch, locale_t); 68 int isupper_l(int ch, locale_t); 69 int isdigit_l(int ch, locale_t); 70 int isxdigit_l(int ch, locale_t); 71 int strcoll_l(const char* lhs, const char* rhs, locale_t); 72 size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t); 73 int wcscoll_l(const char* lhs, const char* rhs, locale_t); 74 size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t); 75 int toupper_l(int ch, locale_t); 76 int tolower_l(int ch, locale_t); 77 int iswspace_l(wint_t ch, locale_t); 78 int iswprint_l(wint_t ch, locale_t); 79 int iswcntrl_l(wint_t ch, locale_t); 80 int iswupper_l(wint_t ch, locale_t); 81 int iswlower_l(wint_t ch, locale_t); 82 int iswalpha_l(wint_t ch, locale_t); 83 int iswblank_l(wint_t ch, locale_t); 84 int iswdigit_l(wint_t ch, locale_t); 85 int iswpunct_l(wint_t ch, locale_t); 86 int iswxdigit_l(wint_t ch, locale_t); 87 wint_t towupper_l(wint_t ch, locale_t); 88 wint_t towlower_l(wint_t ch, locale_t); 89 size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t); 90 91 92 These functions are equivalent to their C counterparts, 93 except that locale_t is used instead of the current global locale. 94 95 The variadic functions may be implemented as templates with a parameter pack instead of variadic functions. 96 */ 97 98 #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H 99