xref: /freebsd/contrib/llvm-project/libcxx/include/__locale_dir/locale_base_api.h (revision c809b0184d0a6543bc5327d4252fa56a07ce4689)
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__)
29 #  include <xlocale.h>
30 #elif defined(__FreeBSD__)
31 #  if __has_feature(modules)
32 #    include <stdio.h>
33 #    include <stdlib.h>
34 #  endif
35 #  include <xlocale.h>
36 #endif
37 
38 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39 #  pragma GCC system_header
40 #endif
41 
42 /*
43 The platform-specific headers have to provide the following interface:
44 
45 // TODO: rename this to __libcpp_locale_t
46 using locale_t = implementation-defined;
47 
48 implementation-defined __libcpp_mb_cur_max_l(locale_t);
49 wint_t __libcpp_btowc_l(int, locale_t);
50 int __libcpp_wctob_l(wint_t, locale_t);
51 size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t);
52 size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t);
53 size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t);
54 size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t);
55 int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t);
56 size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t);
57 lconv* __libcpp_localeconv_l(locale_t);
58 size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t);
59 int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...);
60 int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...);
61 int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...);
62 
63 // TODO: change these to reserved names
64 float strtof_l(const char* str, char** str_end, locale_t);
65 double strtod_l(const char* str, char** str_end, locale_t);
66 long double strtold_l(const char* str, char** str_end, locale_t);
67 long long strtoll_l(const char* str, char** str_end, locale_t);
68 unsigned long long strtoull_l(const char* str, char** str_end, locale_t);
69 
70 locale_t newlocale(int category_mask, const char* locale, locale_t base);
71 void freelocale(locale_t);
72 
73 int islower_l(int ch, locale_t);
74 int isupper_l(int ch, locale_t);
75 int isdigit_l(int ch, locale_t);
76 int isxdigit_l(int ch, locale_t);
77 int strcoll_l(const char* lhs, const char* rhs, locale_t);
78 size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t);
79 int wcscoll_l(const char* lhs, const char* rhs, locale_t);
80 size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t);
81 int toupper_l(int ch, locale_t);
82 int tolower_l(int ch, locale_t);
83 int iswspace_l(wint_t ch, locale_t);
84 int iswprint_l(wint_t ch, locale_t);
85 int iswcntrl_l(wint_t ch, locale_t);
86 int iswupper_l(wint_t ch, locale_t);
87 int iswlower_l(wint_t ch, locale_t);
88 int iswalpha_l(wint_t ch, locale_t);
89 int iswblank_l(wint_t ch, locale_t);
90 int iswdigit_l(wint_t ch, locale_t);
91 int iswpunct_l(wint_t ch, locale_t);
92 int iswxdigit_l(wint_t ch, locale_t);
93 wint_t towupper_l(wint_t ch, locale_t);
94 wint_t towlower_l(wint_t ch, locale_t);
95 size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t);
96 
97 
98 These functions are equivalent to their C counterparts,
99 except that locale_t is used instead of the current global locale.
100 
101 The variadic functions may be implemented as templates with a parameter pack instead of variadic functions.
102 */
103 
104 #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
105