mastodonpp  0.0.0
xlocale.h
1 // -*- C++ -*-
2 //===--------------------- support/ibm/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 
11 #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
12 #define _LIBCPP_SUPPORT_IBM_XLOCALE_H
13 #include <support/ibm/locale_mgmt_aix.h>
14 
15 #if defined(_AIX)
16 #include "cstdlib"
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #if !defined(_AIX71)
23 // AIX 7.1 and higher has these definitions. Definitions and stubs
24 // are provied here as a temporary workaround on AIX 6.1.
25 static inline
26 int isalnum_l(int c, locale_t locale)
27 {
28  return __xisalnum(locale, c);
29 }
30 static inline
31 int isalpha_l(int c, locale_t locale)
32 {
33  return __xisalpha(locale, c);
34 }
35 static inline
36 int isblank_l(int c, locale_t locale)
37 {
38  return __xisblank(locale, c);
39 }
40 static inline
41 int iscntrl_l(int c, locale_t locale)
42 {
43  return __xiscntrl(locale, c);
44 }
45 static inline
46 int isdigit_l(int c, locale_t locale)
47 {
48  return __xisdigit(locale, c);
49 }
50 static inline
51 int isgraph_l(int c, locale_t locale)
52 {
53  return __xisgraph(locale, c);
54 }
55 static inline
56 int islower_l(int c, locale_t locale)
57 {
58  return __xislower(locale, c);
59 }
60 static inline
61 int isprint_l(int c, locale_t locale)
62 {
63  return __xisprint(locale, c);
64 }
65 
66 static inline
67 int ispunct_l(int c, locale_t locale)
68 {
69  return __xispunct(locale, c);
70 }
71 static inline
72 int isspace_l(int c, locale_t locale)
73 {
74  return __xisspace(locale, c);
75 }
76 static inline
77 int isupper_l(int c, locale_t locale)
78 {
79  return __xisupper(locale, c);
80 }
81 
82 static inline
83 int isxdigit_l(int c, locale_t locale)
84 {
85  return __xisxdigit(locale, c);
86 }
87 
88 static inline
89 int iswalnum_l(wchar_t wc, locale_t locale)
90 {
91  return __xiswalnum(locale, wc);
92 }
93 
94 static inline
95 int iswalpha_l(wchar_t wc, locale_t locale)
96 {
97  return __xiswalpha(locale, wc);
98 }
99 
100 static inline
101 int iswblank_l(wchar_t wc, locale_t locale)
102 {
103  return __xiswblank(locale, wc);
104 }
105 
106 static inline
107 int iswcntrl_l(wchar_t wc, locale_t locale)
108 {
109  return __xiswcntrl(locale, wc);
110 }
111 
112 static inline
113 int iswdigit_l(wchar_t wc, locale_t locale)
114 {
115  return __xiswdigit(locale, wc);
116 }
117 
118 static inline
119 int iswgraph_l(wchar_t wc, locale_t locale)
120 {
121  return __xiswgraph(locale, wc);
122 }
123 
124 static inline
125 int iswlower_l(wchar_t wc, locale_t locale)
126 {
127  return __xiswlower(locale, wc);
128 }
129 
130 static inline
131 int iswprint_l(wchar_t wc, locale_t locale)
132 {
133  return __xiswprint(locale, wc);
134 }
135 
136 static inline
137 int iswpunct_l(wchar_t wc, locale_t locale)
138 {
139  return __xiswpunct(locale, wc);
140 }
141 
142 static inline
143 int iswspace_l(wchar_t wc, locale_t locale)
144 {
145  return __xiswspace(locale, wc);
146 }
147 
148 static inline
149 int iswupper_l(wchar_t wc, locale_t locale)
150 {
151  return __xiswupper(locale, wc);
152 }
153 
154 static inline
155 int iswxdigit_l(wchar_t wc, locale_t locale)
156 {
157  return __xiswxdigit(locale, wc);
158 }
159 
160 static inline
161 int iswctype_l(wint_t wc, wctype_t desc, locale_t locale)
162 {
163  return __xiswctype(locale, wc, desc);
164 }
165 
166 static inline
167 int toupper_l(int c, locale_t locale)
168 {
169  return __xtoupper(locale, c);
170 }
171 static inline
172 int tolower_l(int c, locale_t locale)
173 {
174  return __xtolower(locale, c);
175 }
176 static inline
177 wint_t towupper_l(wint_t wc, locale_t locale)
178 {
179  return __xtowupper(locale, wc);
180 }
181 static inline
182 wint_t towlower_l(wint_t wc, locale_t locale)
183 {
184  return __xtowlower(locale, wc);
185 }
186 
187 static inline
188 int strcoll_l(const char *__s1, const char *__s2, locale_t locale)
189 {
190  return __xstrcoll(locale, __s1, __s2);
191 }
192 static inline
193 int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale)
194 {
195  return __xwcscoll(locale, __s1, __s2);
196 }
197 static inline
198 size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale)
199 {
200  return __xstrxfrm(locale, __s1, __s2, __n);
201 }
202 
203 static inline
204 size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
205  locale_t locale)
206 {
207  return __xwcsxfrm(locale, __ws1, __ws2, __n);
208 }
209 #endif // !defined(_AIX71)
210 
211 // strftime_l() is defined by POSIX. However, AIX 7.1 does not have it
212 // implemented yet.
213 static inline
214 size_t strftime_l(char *__s, size_t __size, const char *__fmt,
215  const struct tm *__tm, locale_t locale) {
216  return __xstrftime(locale, __s, __size, __fmt, __tm);
217 }
218 
219 // The following are not POSIX routines. These are quick-and-dirty hacks
220 // to make things pretend to work
221 static inline
222 long long strtoll_l(const char *__nptr, char **__endptr,
223  int __base, locale_t locale) {
224  return strtoll(__nptr, __endptr, __base);
225 }
226 static inline
227 long strtol_l(const char *__nptr, char **__endptr,
228  int __base, locale_t locale) {
229  return strtol(__nptr, __endptr, __base);
230 }
231 static inline
232 long double strtold_l(const char *__nptr, char **__endptr,
233  locale_t locale) {
234  return strtold(__nptr, __endptr);
235 }
236 static inline
237 unsigned long long strtoull_l(const char *__nptr, char **__endptr,
238  int __base, locale_t locale) {
239  return strtoull(__nptr, __endptr, __base);
240 }
241 static inline
242 unsigned long strtoul_l(const char *__nptr, char **__endptr,
243  int __base, locale_t locale) {
244  return strtoul(__nptr, __endptr, __base);
245 }
246 
247 static inline
248 int vasprintf(char **strp, const char *fmt, va_list ap)
249 {
250  const size_t buff_size = 256;
251  int str_size;
252  if ((*strp = (char *)malloc(buff_size)) == NULL)
253  {
254  return -1;
255  }
256  if ((str_size = vsnprintf(*strp, buff_size, fmt, ap)) >= buff_size)
257  {
258  if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL)
259  {
260  return -1;
261  }
262  str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
263  }
264  return str_size;
265 }
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // defined(_AIX)
271 #endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
locale_t
Definition: locale_win32.h:32