[libc++] Reduce the dependency of the locale base API on the base sys… · llvm/llvm-project@43a04b1 (original) (raw)
`@@ -23,19 +23,24 @@
`
23
23
`// Variadic functions may be implemented as templates with a parameter pack instead
`
24
24
`// of C-style variadic functions.
`
25
25
`//
`
``
26
`+
// Most of these functions are only required when building the library. Functions that are also
`
``
27
`+
// required when merely using the headers are marked as such below.
`
``
28
`+
//
`
26
29
`// TODO: __localeconv shouldn't take a reference, but the Windows implementation doesn't allow copying __locale_t
`
``
30
`+
// TODO: Eliminate the need for any of these functions from the headers.
`
27
31
`//
`
28
32
`// Locale management
`
29
33
`// -----------------
`
30
34
`// namespace __locale {
`
31
``
`-
// using __locale_t = implementation-defined;
`
``
35
`+
// using __locale_t = implementation-defined; // required by the headers
`
32
36
`// using __lconv_t = implementation-defined;
`
33
37
`// __locale_t __newlocale(int, const char*, __locale_t);
`
34
38
`// void __freelocale(__locale_t);
`
35
39
`// char* __setlocale(int, const char*);
`
36
40
`// __lconv_t* __localeconv(__locale_t&);
`
37
41
`// }
`
38
42
`//
`
``
43
`+
// // required by the headers
`
39
44
`// #define _LIBCPP_COLLATE_MASK /* implementation-defined */
`
40
45
`// #define _LIBCPP_CTYPE_MASK /* implementation-defined */
`
41
46
`// #define _LIBCPP_MONETARY_MASK /* implementation-defined */
`
`@@ -48,6 +53,7 @@
`
48
53
`// Strtonum functions
`
49
54
`// ------------------
`
50
55
`// namespace __locale {
`
``
56
`+
// // required by the headers
`
51
57
`// float __strtof(const char*, char**, __locale_t);
`
52
58
`// double __strtod(const char*, char**, __locale_t);
`
53
59
`// long double __strtold(const char*, char**, __locale_t);
`
`@@ -60,8 +66,8 @@
`
60
66
`// namespace __locale {
`
61
67
`// int __islower(int, __locale_t);
`
62
68
`// int __isupper(int, __locale_t);
`
63
``
`-
// int __isdigit(int, __locale_t);
`
64
``
`-
// int __isxdigit(int, __locale_t);
`
``
69
`+
// int __isdigit(int, __locale_t); // required by the headers
`
``
70
`+
// int __isxdigit(int, __locale_t); // required by the headers
`
65
71
`// int __toupper(int, __locale_t);
`
66
72
`// int __tolower(int, __locale_t);
`
67
73
`// int __strcoll(const char*, const char*, __locale_t);
`
99
105
`// int __mbtowc(wchar_t*, const char*, size_t, __locale_t);
`
100
106
`// size_t __mbrlen(const char*, size_t, mbstate_t*, __locale_t);
`
101
107
`// size_t __mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*, __locale_t);
`
102
``
`-
// int __snprintf(char*, size_t, __locale_t, const char*, ...);
`
103
``
`-
// int __asprintf(char**, __locale_t, const char*, ...);
`
104
``
`-
// int __sscanf(const char*, __locale_t, const char*, ...);
`
``
108
`+
//
`
``
109
`+
// int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers
`
``
110
`+
// int __asprintf(char**, __locale_t, const char*, ...); // required by the headers
`
``
111
`+
// int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers
`
105
112
`// }
`
106
113
``
107
114
`#if defined(APPLE)
`
`@@ -143,8 +150,19 @@ namespace __locale {
`
143
150
`//
`
144
151
`// Locale management
`
145
152
`//
`
``
153
`+
define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
`
``
154
`+
define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
`
``
155
`+
define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
`
``
156
`+
define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
`
``
157
`+
define _LIBCPP_TIME_MASK LC_TIME_MASK
`
``
158
`+
define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
`
``
159
`+
define _LIBCPP_ALL_MASK LC_ALL_MASK
`
``
160
`+
define _LIBCPP_LC_ALL LC_ALL
`
``
161
+
146
162
`using __locale_t _LIBCPP_NODEBUG = locale_t;
`
147
``
`-
using __lconv_t _LIBCPP_NODEBUG = lconv;
`
``
163
+
``
164
`+
if defined(_LIBCPP_BUILDING_LIBRARY)
`
``
165
`+
using __lconv_t _LIBCPP_NODEBUG = lconv;
`
148
166
``
149
167
`inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {
`
150
168
`return newlocale(__category_mask, __name, __loc);
`
`@@ -157,15 +175,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc
`
157
175
`inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); }
`
158
176
``
159
177
`inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); }
`
160
``
-
161
``
`-
define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
`
162
``
`-
define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
`
163
``
`-
define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
`
164
``
`-
define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
`
165
``
`-
define _LIBCPP_TIME_MASK LC_TIME_MASK
`
166
``
`-
define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
`
167
``
`-
define _LIBCPP_ALL_MASK LC_ALL_MASK
`
168
``
`-
define _LIBCPP_LC_ALL LC_ALL
`
``
178
`+
endif // _LIBCPP_BUILDING_LIBRARY
`
169
179
``
170
180
`//
`
171
181
`// Strtonum functions
`
`@@ -194,10 +204,15 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
`
194
204
`//
`
195
205
`// Character manipulation functions
`
196
206
`//
`
``
207
`+
if defined(_LIBCPP_BUILDING_LIBRARY)
`
197
208
`inline _LIBCPP_HIDE_FROM_ABI int __islower(int __ch, __locale_t __loc) { return islower_l(__ch, __loc); }
`
198
209
`inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __ch, __locale_t __loc) { return isupper_l(__ch, __loc); }
`
``
210
`+
endif
`
``
211
+
199
212
`inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); }
`
200
213
`inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); }
`
``
214
+
``
215
`+
if defined(_LIBCPP_BUILDING_LIBRARY)
`
201
216
`inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
`
202
217
`return strcoll_l(__s1, __s2, __loc);
`
203
218
`}
`
`@@ -207,7 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
`
207
222
`inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); }
`
208
223
`inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); }
`
209
224
``
210
``
`-
if _LIBCPP_HAS_WIDE_CHARACTERS
`
``
225
`+
if _LIBCPP_HAS_WIDE_CHARACTERS
`
211
226
`inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) {
`
212
227
`return wcscoll_l(__s1, __s2, __loc);
`
213
228
`}
`
`@@ -229,7 +244,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret
`
229
244
`inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); }
`
230
245
`inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); }
`
231
246
`inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); }
`
232
``
`-
endif
`
``
247
`+
endif
`
233
248
``
234
249
`inline _LIBCPP_HIDE_FROM_ABI size_t
`
235
250
`__strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {
`
`@@ -242,7 +257,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca
`
242
257
`inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) {
`
243
258
`return __libcpp_mb_cur_max_l(__loc);
`
244
259
`}
`
245
``
`-
if _LIBCPP_HAS_WIDE_CHARACTERS
`
``
260
`+
if _LIBCPP_HAS_WIDE_CHARACTERS
`
246
261
`inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); }
`
247
262
`inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); }
`
248
263
`inline _LIBCPP_HIDE_FROM_ABI size_t
`
`@@ -270,7 +285,8 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
`
270
285
`__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
`
271
286
`return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
`
272
287
`}
`
273
``
`-
endif
`
``
288
`+
endif // _LIBCPP_HAS_WIDE_CHARACTERS
`
``
289
`+
endif // _LIBCPP_BUILDING_LIBRARY
`
274
290
``
275
291
`_LIBCPP_DIAGNOSTIC_PUSH
`
276
292
`_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
`