1 // -*- C++ -*-
2 //===------------------- support/xlocale/xlocale.h ------------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 // This is a shared implementation of a shim to provide extended locale support
11 // on top of libc's that don't support it (like Android's bionic, and Newlib).
12 //
13 // The 'illusion' only works when the specified locale is "C" or "POSIX", but
14 // that's about as good as we can do without implementing full xlocale support
15 // in the underlying libc.
16 //===----------------------------------------------------------------------===//
17
18 #ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H
19 #define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
isalnum_l(int c,locale_t)25 static inline int isalnum_l(int c, locale_t) {
26 return isalnum(c);
27 }
28
isalpha_l(int c,locale_t)29 static inline int isalpha_l(int c, locale_t) {
30 return isalpha(c);
31 }
32
isblank_l(int c,locale_t)33 static inline int isblank_l(int c, locale_t) {
34 return isblank(c);
35 }
36
iscntrl_l(int c,locale_t)37 static inline int iscntrl_l(int c, locale_t) {
38 return iscntrl(c);
39 }
40
isdigit_l(int c,locale_t)41 static inline int isdigit_l(int c, locale_t) {
42 return isdigit(c);
43 }
44
isgraph_l(int c,locale_t)45 static inline int isgraph_l(int c, locale_t) {
46 return isgraph(c);
47 }
48
islower_l(int c,locale_t)49 static inline int islower_l(int c, locale_t) {
50 return islower(c);
51 }
52
isprint_l(int c,locale_t)53 static inline int isprint_l(int c, locale_t) {
54 return isprint(c);
55 }
56
ispunct_l(int c,locale_t)57 static inline int ispunct_l(int c, locale_t) {
58 return ispunct(c);
59 }
60
isspace_l(int c,locale_t)61 static inline int isspace_l(int c, locale_t) {
62 return isspace(c);
63 }
64
isupper_l(int c,locale_t)65 static inline int isupper_l(int c, locale_t) {
66 return isupper(c);
67 }
68
isxdigit_l(int c,locale_t)69 static inline int isxdigit_l(int c, locale_t) {
70 return isxdigit(c);
71 }
72
iswalnum_l(wint_t c,locale_t)73 static inline int iswalnum_l(wint_t c, locale_t) {
74 return iswalnum(c);
75 }
76
iswalpha_l(wint_t c,locale_t)77 static inline int iswalpha_l(wint_t c, locale_t) {
78 return iswalpha(c);
79 }
80
iswblank_l(wint_t c,locale_t)81 static inline int iswblank_l(wint_t c, locale_t) {
82 return iswblank(c);
83 }
84
iswcntrl_l(wint_t c,locale_t)85 static inline int iswcntrl_l(wint_t c, locale_t) {
86 return iswcntrl(c);
87 }
88
iswdigit_l(wint_t c,locale_t)89 static inline int iswdigit_l(wint_t c, locale_t) {
90 return iswdigit(c);
91 }
92
iswgraph_l(wint_t c,locale_t)93 static inline int iswgraph_l(wint_t c, locale_t) {
94 return iswgraph(c);
95 }
96
iswlower_l(wint_t c,locale_t)97 static inline int iswlower_l(wint_t c, locale_t) {
98 return iswlower(c);
99 }
100
iswprint_l(wint_t c,locale_t)101 static inline int iswprint_l(wint_t c, locale_t) {
102 return iswprint(c);
103 }
104
iswpunct_l(wint_t c,locale_t)105 static inline int iswpunct_l(wint_t c, locale_t) {
106 return iswpunct(c);
107 }
108
iswspace_l(wint_t c,locale_t)109 static inline int iswspace_l(wint_t c, locale_t) {
110 return iswspace(c);
111 }
112
iswupper_l(wint_t c,locale_t)113 static inline int iswupper_l(wint_t c, locale_t) {
114 return iswupper(c);
115 }
116
iswxdigit_l(wint_t c,locale_t)117 static inline int iswxdigit_l(wint_t c, locale_t) {
118 return iswxdigit(c);
119 }
120
toupper_l(int c,locale_t)121 static inline int toupper_l(int c, locale_t) {
122 return toupper(c);
123 }
124
tolower_l(int c,locale_t)125 static inline int tolower_l(int c, locale_t) {
126 return tolower(c);
127 }
128
towupper_l(int c,locale_t)129 static inline int towupper_l(int c, locale_t) {
130 return towupper(c);
131 }
132
towlower_l(int c,locale_t)133 static inline int towlower_l(int c, locale_t) {
134 return towlower(c);
135 }
136
strcoll_l(const char * s1,const char * s2,locale_t)137 static inline int strcoll_l(const char *s1, const char *s2, locale_t) {
138 return strcoll(s1, s2);
139 }
140
strxfrm_l(char * dest,const char * src,size_t n,locale_t)141 static inline size_t strxfrm_l(char *dest, const char *src, size_t n,
142 locale_t) {
143 return strxfrm(dest, src, n);
144 }
145
strftime_l(char * s,size_t max,const char * format,const struct tm * tm,locale_t)146 static inline size_t strftime_l(char *s, size_t max, const char *format,
147 const struct tm *tm, locale_t) {
148 return strftime(s, max, format, tm);
149 }
150
wcscoll_l(const wchar_t * ws1,const wchar_t * ws2,locale_t)151 static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) {
152 return wcscoll(ws1, ws2);
153 }
154
wcsxfrm_l(wchar_t * dest,const wchar_t * src,size_t n,locale_t)155 static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n,
156 locale_t) {
157 return wcsxfrm(dest, src, n);
158 }
159
strtold_l(const char * nptr,char ** endptr,locale_t)160 static inline long double strtold_l(const char *nptr, char **endptr, locale_t) {
161 return strtold(nptr, endptr);
162 }
163
strtoll_l(const char * nptr,char ** endptr,int base,locale_t)164 static inline long long strtoll_l(const char *nptr, char **endptr, int base,
165 locale_t) {
166 return strtoll(nptr, endptr, base);
167 }
168
strtoull_l(const char * nptr,char ** endptr,int base,locale_t)169 static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
170 int base, locale_t) {
171 return strtoull(nptr, endptr, base);
172 }
173
wcstoll_l(const wchar_t * nptr,wchar_t ** endptr,int base,locale_t)174 static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
175 int base, locale_t) {
176 return wcstoll(nptr, endptr, base);
177 }
178
wcstoull_l(const wchar_t * nptr,wchar_t ** endptr,int base,locale_t)179 static inline unsigned long long wcstoull_l(const wchar_t *nptr,
180 wchar_t **endptr, int base,
181 locale_t) {
182 return wcstoull(nptr, endptr, base);
183 }
184
wcstold_l(const wchar_t * nptr,wchar_t ** endptr,locale_t)185 static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
186 locale_t) {
187 return wcstold(nptr, endptr);
188 }
189
190 #ifdef __cplusplus
191 }
192 #endif
193
194 #endif // _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H
195