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