blob: 99f710e8f44ea38471ae144962cc9a9e634fb40e [file] [log] [blame]
Dan Albert1d4a1ed2016-05-25 22:36:09 -07001// -*- 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
22extern "C" {
23#endif
24
25static inline int isalnum_l(int c, locale_t) {
26 return isalnum(c);
27}
28
29static inline int isalpha_l(int c, locale_t) {
30 return isalpha(c);
31}
32
33static inline int isblank_l(int c, locale_t) {
34 return isblank(c);
35}
36
37static inline int iscntrl_l(int c, locale_t) {
38 return iscntrl(c);
39}
40
41static inline int isdigit_l(int c, locale_t) {
42 return isdigit(c);
43}
44
45static inline int isgraph_l(int c, locale_t) {
46 return isgraph(c);
47}
48
49static inline int islower_l(int c, locale_t) {
50 return islower(c);
51}
52
53static inline int isprint_l(int c, locale_t) {
54 return isprint(c);
55}
56
57static inline int ispunct_l(int c, locale_t) {
58 return ispunct(c);
59}
60
61static inline int isspace_l(int c, locale_t) {
62 return isspace(c);
63}
64
65static inline int isupper_l(int c, locale_t) {
66 return isupper(c);
67}
68
69static inline int isxdigit_l(int c, locale_t) {
70 return isxdigit(c);
71}
72
73static inline int iswalnum_l(wint_t c, locale_t) {
74 return iswalnum(c);
75}
76
77static inline int iswalpha_l(wint_t c, locale_t) {
78 return iswalpha(c);
79}
80
81static inline int iswblank_l(wint_t c, locale_t) {
82 return iswblank(c);
83}
84
85static inline int iswcntrl_l(wint_t c, locale_t) {
86 return iswcntrl(c);
87}
88
89static inline int iswdigit_l(wint_t c, locale_t) {
90 return iswdigit(c);
91}
92
93static inline int iswgraph_l(wint_t c, locale_t) {
94 return iswgraph(c);
95}
96
97static inline int iswlower_l(wint_t c, locale_t) {
98 return iswlower(c);
99}
100
101static inline int iswprint_l(wint_t c, locale_t) {
102 return iswprint(c);
103}
104
105static inline int iswpunct_l(wint_t c, locale_t) {
106 return iswpunct(c);
107}
108
109static inline int iswspace_l(wint_t c, locale_t) {
110 return iswspace(c);
111}
112
113static inline int iswupper_l(wint_t c, locale_t) {
114 return iswupper(c);
115}
116
117static inline int iswxdigit_l(wint_t c, locale_t) {
118 return iswxdigit(c);
119}
120
121static inline int toupper_l(int c, locale_t) {
122 return toupper(c);
123}
124
125static inline int tolower_l(int c, locale_t) {
126 return tolower(c);
127}
128
129static inline int towupper_l(int c, locale_t) {
130 return towupper(c);
131}
132
133static inline int towlower_l(int c, locale_t) {
134 return towlower(c);
135}
136
137static inline int strcoll_l(const char *s1, const char *s2, locale_t) {
138 return strcoll(s1, s2);
139}
140
141static inline size_t strxfrm_l(char *dest, const char *src, size_t n,
142 locale_t) {
143 return strxfrm(dest, src, n);
144}
145
146static 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
151static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) {
152 return wcscoll(ws1, ws2);
153}
154
155static 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
160static inline long double strtold_l(const char *nptr, char **endptr, locale_t) {
161 return strtold(nptr, endptr);
162}
163
164static inline long long strtoll_l(const char *nptr, char **endptr, int base,
165 locale_t) {
166 return strtoll(nptr, endptr, base);
167}
168
169static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
170 int base, locale_t) {
171 return strtoull(nptr, endptr, base);
172}
173
174static 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
179static 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
185static 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