1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 ////////////////////////////////////////////////////////////////////////////////
11 // Minimal xlocale implementation for Solaris. This implements the subset of
12 // the xlocale APIs that libc++ depends on.
13 ////////////////////////////////////////////////////////////////////////////////
14 #ifndef __XLOCALE_H_INCLUDED
15 #define __XLOCALE_H_INCLUDED
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21
22 typedef struct _LC_locale_t* locale_t;
23
24 #define LC_COLLATE_MASK (1<<0)
25 #define LC_CTYPE_MASK (1<<1)
26 #define LC_MESSAGES_MASK (1<<2)
27 #define LC_MONETARY_MASK (1<<3)
28 #define LC_NUMERIC_MASK (1<<4)
29 #define LC_TIME_MASK (1<<5)
30 #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \
31 LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
32
33 #define LC_GLOBAL_LOCALE ((locale_t)-1)
34
35 size_t __mb_cur_max(locale_t l);
36 #define MB_CUR_MAX_L(l) __mb_cur_max(l)
37
38 locale_t newlocale(int mask, const char * locale, locale_t base);
39 void freelocale(locale_t loc);
40
41 wint_t btowc_l(int __c, locale_t __l);
42
43 int wctob_l(wint_t __c, locale_t __l);
44
45 size_t wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l);
46
47 size_t mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
48 mbstate_t *__ps, locale_t __l);
49
50 int mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l);
51
52 size_t mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l);
53
54 struct lconv *localeconv_l(locale_t __l);
55
56 size_t mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
57 mbstate_t *__ps, locale_t __l);
58
59 int sprintf_l(char *__s, locale_t __l, const char *__format, ...);
60
61 int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...);
62
63 int asprintf_l(char **__s, locale_t __l, const char *__format, ...);
64
65 int sscanf_l(const char *__s, locale_t __l, const char *__format, ...);
66
67 int isalnum_l(int,locale_t);
68 int isalpha_l(int,locale_t);
69 int isblank_l(int,locale_t);
70 int iscntrl_l(int,locale_t);
71 int isdigit_l(int,locale_t);
72 int isgraph_l(int,locale_t);
73 int islower_l(int,locale_t);
74 int isprint_l(int,locale_t);
75 int ispunct_l(int,locale_t);
76 int isspace_l(int,locale_t);
77 int isupper_l(int,locale_t);
78 int isxdigit_l(int,locale_t);
79
80 int iswalnum_l(wchar_t,locale_t);
81 int iswalpha_l(wchar_t,locale_t);
82 int iswblank_l(wchar_t,locale_t);
83 int iswcntrl_l(wchar_t,locale_t);
84 int iswdigit_l(wchar_t,locale_t);
85 int iswgraph_l(wchar_t,locale_t);
86 int iswlower_l(wchar_t,locale_t);
87 int iswprint_l(wchar_t,locale_t);
88 int iswpunct_l(wchar_t,locale_t);
89 int iswspace_l(wchar_t,locale_t);
90 int iswupper_l(wchar_t,locale_t);
91 int iswxdigit_l(wchar_t,locale_t);
92
93 int iswctype_l(wint_t, wctype_t, locale_t);
94
95 int toupper_l(int __c, locale_t __l);
96 int tolower_l(int __c, locale_t __l);
97 wint_t towupper_l(wint_t __c, locale_t __l);
98 wint_t towlower_l(wint_t __c, locale_t __l);
99
100
101 int strcoll_l(const char *__s1, const char *__s2, locale_t __l);
102 int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t __l);
103 size_t strftime_l(char *__s, size_t __size, const char *__fmt, const struct tm
104 *__tm, locale_t __l);
105
106 size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t __l);
107
108 size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
109 locale_t __l);
110
111
112
113 size_t
114 mbsnrtowcs_l(wchar_t * __restrict dst, const char ** __restrict src,
115 size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc);
116
117
118 size_t
119 wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src,
120 size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc);
121
122 locale_t __cloc(void);
123
124 // FIXME: These are quick-and-dirty hacks to make things pretend to work
125 static inline
strtoll_l(const char * __nptr,char ** __endptr,int __base,locale_t __loc)126 long long strtoll_l(const char *__nptr, char **__endptr,
127 int __base, locale_t __loc) {
128 return strtoll(__nptr, __endptr, __base);
129 }
130 static inline
strtol_l(const char * __nptr,char ** __endptr,int __base,locale_t __loc)131 long strtol_l(const char *__nptr, char **__endptr,
132 int __base, locale_t __loc) {
133 return strtol(__nptr, __endptr, __base);
134 }
135 static inline
strtold_l(const char * __nptr,char ** __endptr,locale_t __loc)136 long double strtold_l(const char *__nptr, char **__endptr,
137 locale_t __loc) {
138 return strtold(__nptr, __endptr);
139 }
140 static inline
strtoull_l(const char * __nptr,char ** __endptr,int __base,locale_t __loc)141 unsigned long long strtoull_l(const char *__nptr, char **__endptr,
142 int __base, locale_t __loc) {
143 return strtoull(__nptr, __endptr, __base);
144 }
145 static inline
strtoul_l(const char * __nptr,char ** __endptr,int __base,locale_t __loc)146 unsigned long strtoul_l(const char *__nptr, char **__endptr,
147 int __base, locale_t __loc) {
148 return strtoul(__nptr, __endptr, __base);
149 }
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif
156