Skip to content

Commit fd5a2bf

Browse files
committed
[libc++] Add missing includes to xlocale helpers
Also, make sure those are compatible with _LIBCPP_HAS_NO_WIDE_CHARACTERS. Differential Revision: https://reviews.llvm.org/D136682
1 parent 22ea0e5 commit fd5a2bf

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

libcxx/include/__support/xlocale/__nop_locale_mgmt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
1111
#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
1212

13+
#include <__config>
14+
1315
#ifdef __cplusplus
1416
extern "C" {
1517
#endif

libcxx/include/__support/xlocale/__posix_l_fallback.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
1616
#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
1717

18+
#include <__config>
19+
#include <ctype.h>
20+
#include <time.h>
21+
22+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23+
# include <wctype.h>
24+
#endif
25+
1826
#ifdef __cplusplus
1927
extern "C" {
2028
#endif
@@ -67,6 +75,15 @@ inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
6775
return ::isxdigit(__c);
6876
}
6977

78+
inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
79+
return ::toupper(__c);
80+
}
81+
82+
inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
83+
return ::tolower(__c);
84+
}
85+
86+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
7087
inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
7188
return ::iswalnum(__c);
7289
}
@@ -115,21 +132,14 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
115132
return ::iswxdigit(__c);
116133
}
117134

118-
inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
119-
return ::toupper(__c);
120-
}
121-
122-
inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
123-
return ::tolower(__c);
124-
}
125-
126135
inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
127136
return ::towupper(__c);
128137
}
129138

130139
inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
131140
return ::towlower(__c);
132141
}
142+
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
133143

134144
inline _LIBCPP_HIDE_FROM_ABI int
135145
strcoll_l(const char *__s1, const char *__s2, locale_t) {
@@ -147,6 +157,7 @@ strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
147157
return ::strftime(__s, __max, __format, __tm);
148158
}
149159

160+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
150161
inline _LIBCPP_HIDE_FROM_ABI int
151162
wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
152163
return ::wcscoll(__ws1, __ws2);
@@ -156,6 +167,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
156167
wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
157168
return ::wcsxfrm(__dest, __src, __n);
158169
}
170+
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
159171

160172
#ifdef __cplusplus
161173
}

libcxx/include/__support/xlocale/__strtonum_fallback.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
#ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
1616
#define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
1717

18+
#include <__config>
19+
#include <stdlib.h>
20+
21+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
22+
# include <wchar.h>
23+
#endif
24+
1825
#ifdef __cplusplus
1926
extern "C" {
2027
#endif
@@ -44,6 +51,7 @@ strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
4451
return ::strtoull(__nptr, __endptr, __base);
4552
}
4653

54+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4755
inline _LIBCPP_HIDE_FROM_ABI long long
4856
wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
4957
return ::wcstoll(__nptr, __endptr, __base);
@@ -58,6 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double
5866
wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
5967
return ::wcstold(__nptr, __endptr);
6068
}
69+
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
6170

6271
#ifdef __cplusplus
6372
}

0 commit comments

Comments
 (0)