Rename __unused struct members to include a namespace
[uclibc-ng.git] / libc / sysdeps / linux / common / bits / uClibc_locale.h
blob43c1e510e9e4415c92c2de6d3ceb0763a0ea0b71
1 /* Copyright (C) 2002, 2003 Manuel Novoa III
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * The GNU C Library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with the GNU C Library; see the file COPYING.LIB. If
15 * not, see <http://www.gnu.org/licenses/>.
18 /* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
20 * Besides uClibc, I'm using this code in my libc for elks, which is
21 * a 16-bit environment with a fairly limited compiler. It would make
22 * things much easier for me if this file isn't modified unnecessarily.
23 * In particular, please put any new or replacement functions somewhere
24 * else, and modify the makefile to use your version instead.
25 * Thanks. Manuel
27 * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
29 #ifndef _UCLIBC_LOCALE_H
30 #define _UCLIBC_LOCALE_H
32 /**********************************************************************/
33 /* uClibc compatibilty stuff */
35 #ifdef __UCLIBC_HAS_LOCALE__
37 # undef __LOCALE_C_ONLY
39 #else
41 # define __LOCALE_C_ONLY
43 # ifdef _LIBC
44 # define __XL_NPP(N) N
45 # define __LOCALE_PARAM
46 # define __LOCALE_ARG
47 # endif
49 #endif
51 /**********************************************************************/
53 #define __NL_ITEM_CATEGORY_SHIFT 8
54 #define __NL_ITEM_INDEX_MASK 0xff
56 /* TODO: Make sure these agree with the locale mmap file gererator! */
58 #define __LC_CTYPE 0
59 #define __LC_NUMERIC 1
60 #define __LC_MONETARY 2
61 #define __LC_TIME 3
62 #define __LC_COLLATE 4
63 #define __LC_MESSAGES 5
64 #define __LC_ALL 6
66 /**********************************************************************/
67 #ifndef __LOCALE_C_ONLY
69 enum {
70 __ctype_encoding_7_bit, /* C/POSIX */
71 __ctype_encoding_utf8, /* UTF-8 */
72 __ctype_encoding_8_bit /* for 8-bit codeset locales */
75 #define LOCALE_STRING_SIZE (2 * __LC_ALL + 2)
78 * '#' + 2_per_category + '\0'
79 * {locale row # : 0 = C|POSIX} + 0x8001
80 * encoded in two chars as (((N+1) >> 8) | 0x80) and ((N+1) & 0xff)
81 * so decode is ((((uint16_t)(*s & 0x7f)) << 8) + s[1]) - 1
83 * Note: 0s are not used as they are nul-terminators for strings.
84 * Note: 0xff, 0xff is the encoding for a non-selected locale.
85 * (see setlocale() below).
86 * In particular, C/POSIX locale is '#' + "\x80\x01"}*LC_ALL + nul.
89 struct __uclibc_locale_struct;
90 typedef struct __uclibc_locale_struct *__locale_t;
92 #ifdef _LIBC
94 /* extern void _locale_set(const unsigned char *p); */
95 extern void weak_function _locale_init(void) attribute_hidden;
97 #include <stddef.h>
98 #include <stdint.h>
99 #include <bits/uClibc_touplow.h>
100 #ifndef __UCLIBC_GEN_LOCALE
101 # include <bits/uClibc_locale_data.h>
102 #endif
104 #ifndef __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */
105 typedef struct {
106 uint16_t num_weights;
107 uint16_t num_starters;
108 uint16_t ii_shift;
109 uint16_t ti_shift;
110 uint16_t ii_len;
111 uint16_t ti_len;
112 uint16_t max_weight;
113 uint16_t num_col_base;
114 uint16_t max_col_index;
115 uint16_t undefined_idx;
116 uint16_t range_low;
117 uint16_t range_count;
118 uint16_t range_base_weight;
119 uint16_t range_rule_offset; /* change name to index? */
121 uint16_t ii_mask;
122 uint16_t ti_mask;
124 const uint16_t *index2weight_tbl;
125 const uint16_t *index2ruleidx_tbl;
126 const uint16_t *multistart_tbl;
127 /* uint16_t wcs2colidt_offset_low; */
128 /* uint16_t wcs2colidt_offset_hi; */
129 const uint16_t *wcs2colidt_tbl;
131 /* uint16_t undefined_idx; */
132 const uint16_t *overrides_tbl;
133 /* uint16_t *multistart_tbl; */
135 const uint16_t *weightstr;
136 const uint16_t *ruletable;
139 uint16_t *index2weight;
140 uint16_t *index2ruleidx;
142 uint16_t MAX_WEIGHTS;
143 } __collate_t;
145 /* static unsigned char cur_locale[LOCALE_STRING_SIZE]; */
147 struct __uclibc_locale_struct {
148 #ifdef __UCLIBC_HAS_XLOCALE__
149 const __ctype_mask_t *__ctype_b;
150 const __ctype_touplow_t *__ctype_tolower;
151 const __ctype_touplow_t *__ctype_toupper;
152 #endif
154 /* For now, just embed this in the structure. */
155 __ctype_mask_t __ctype_b_data[256 + __UCLIBC_CTYPE_B_TBL_OFFSET];
156 __ctype_touplow_t __ctype_tolower_data[256 + __UCLIBC_CTYPE_TO_TBL_OFFSET];
157 __ctype_touplow_t __ctype_toupper_data[256 + __UCLIBC_CTYPE_TO_TBL_OFFSET];
159 /* int tables_loaded; */
160 /* unsigned char lctypes[LOCALE_STRING_SIZE]; */
161 unsigned char cur_locale[LOCALE_STRING_SIZE];
163 /* NL_LANGINFO stuff. BEWARE ORDERING!!! must agree with NL_* constants! */
164 /* Also, numeric must be followed by monetary and the items must be in
165 * the "struct lconv" order. */
167 uint16_t category_offsets[__LC_ALL]; /* TODO -- fix? */
168 unsigned char category_item_count[__LC_ALL]; /* TODO - fix */
170 /* ctype */
171 unsigned char encoding; /* C/POSIX, 8-bit, UTF-8 */
172 unsigned char mb_cur_max; /* determined by encoding _AND_ translit!!! */
173 const unsigned char outdigit_length[10];
175 #ifdef __CTYPE_HAS_8_BIT_LOCALES
176 const unsigned char *idx8ctype;
177 const unsigned char *tbl8ctype;
178 const unsigned char *idx8uplow;
179 const unsigned char *tbl8uplow;
180 # ifdef __UCLIBC_HAS_WCHAR__
181 const unsigned char *idx8c2wc;
182 const uint16_t *tbl8c2wc; /* char > 0x7f to wide char */
183 const unsigned char *idx8wc2c;
184 const unsigned char *tbl8wc2c;
185 /* translit */
186 # endif
187 #endif /* __CTYPE_HAS_8_BIT_LOCALES */
188 #ifdef __UCLIBC_HAS_WCHAR__
190 const uint16_t *code2flag;
192 const unsigned char *tblwctype;
193 const unsigned char *tblwuplow;
194 /* const unsigned char *tblwcomb; */
195 const int32_t *tblwuplow_diff; /* yes... signed */
196 /* width?? */
198 wchar_t decimal_point_wc;
199 wchar_t thousands_sep_wc;
200 int decimal_point_len;
201 int thousands_sep_len;
203 #endif /* __UCLIBC_HAS_WCHAR__ */
205 /* ctype */
206 const char *outdigit0_mb;
207 const char *outdigit1_mb;
208 const char *outdigit2_mb;
209 const char *outdigit3_mb;
210 const char *outdigit4_mb;
211 const char *outdigit5_mb;
212 const char *outdigit6_mb;
213 const char *outdigit7_mb;
214 const char *outdigit8_mb;
215 const char *outdigit9_mb;
216 const char *codeset; /* MUST BE LAST!!! */
218 /* numeric */
219 const char *decimal_point;
220 const char *thousands_sep;
221 const char *grouping;
223 /* monetary */
224 const char *int_curr_symbol;
225 const char *currency_symbol;
226 const char *mon_decimal_point;
227 const char *mon_thousands_sep;
228 const char *mon_grouping;
229 const char *positive_sign;
230 const char *negative_sign;
231 const char *int_frac_digits;
232 const char *frac_digits;
233 const char *p_cs_precedes;
234 const char *p_sep_by_space;
235 const char *n_cs_precedes;
236 const char *n_sep_by_space;
237 const char *p_sign_posn;
238 const char *n_sign_posn;
239 const char *int_p_cs_precedes;
240 const char *int_p_sep_by_space;
241 const char *int_n_cs_precedes;
242 const char *int_n_sep_by_space;
243 const char *int_p_sign_posn;
244 const char *int_n_sign_posn;
246 const char *crncystr; /* not returned by localeconv */
248 /* time */
249 const char *abday_1;
250 const char *abday_2;
251 const char *abday_3;
252 const char *abday_4;
253 const char *abday_5;
254 const char *abday_6;
255 const char *abday_7;
257 const char *day_1;
258 const char *day_2;
259 const char *day_3;
260 const char *day_4;
261 const char *day_5;
262 const char *day_6;
263 const char *day_7;
265 const char *abmon_1;
266 const char *abmon_2;
267 const char *abmon_3;
268 const char *abmon_4;
269 const char *abmon_5;
270 const char *abmon_6;
271 const char *abmon_7;
272 const char *abmon_8;
273 const char *abmon_9;
274 const char *abmon_10;
275 const char *abmon_11;
276 const char *abmon_12;
278 const char *mon_1;
279 const char *mon_2;
280 const char *mon_3;
281 const char *mon_4;
282 const char *mon_5;
283 const char *mon_6;
284 const char *mon_7;
285 const char *mon_8;
286 const char *mon_9;
287 const char *mon_10;
288 const char *mon_11;
289 const char *mon_12;
291 const char *am_str;
292 const char *pm_str;
294 const char *d_t_fmt;
295 const char *d_fmt;
296 const char *t_fmt;
297 const char *t_fmt_ampm;
298 const char *era;
300 const char *era_year; /* non SUSv3 */
301 const char *era_d_fmt;
302 const char *alt_digits;
303 const char *era_d_t_fmt;
304 const char *era_t_fmt;
306 /* messages */
307 const char *yesexpr;
308 const char *noexpr;
309 const char *yesstr;
310 const char *nostr;
312 /* collate is at the end */
313 __collate_t collate;
316 extern struct __uclibc_locale_struct __global_locale_data;
317 extern struct __uclibc_locale_struct *__global_locale;
318 #endif /* !__UCLIBC_GEN_LOCALE */
320 #if defined IS_IN_libc || defined NOT_IN_libc
321 /* If you plan to remove xxx_IN_libc guards,
322 * remove attribute_hidden, it won't work.
324 extern int __locale_mbrtowc_l(wchar_t *__restrict dst,
325 const char *__restrict src,
326 __locale_t loc) attribute_hidden;
327 #endif
329 /**********************************************************************/
330 #ifdef __UCLIBC_HAS_XLOCALE__
332 extern __locale_t __curlocale_var;
333 # ifdef __UCLIBC_HAS_THREADS__
334 extern __locale_t __curlocale(void) __THROW __attribute__ ((__const__));
335 libc_hidden_proto(__curlocale)
336 extern __locale_t __curlocale_set(__locale_t newloc);
337 libc_hidden_proto(__curlocale_set)
338 # define __UCLIBC_CURLOCALE (__curlocale())
339 # else
340 # define __UCLIBC_CURLOCALE (__curlocale_var)
341 # endif
343 #elif defined(__UCLIBC_HAS_LOCALE__)
345 # define __UCLIBC_CURLOCALE (__global_locale)
347 #endif
348 /**********************************************************************/
349 #if defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE)
351 # define __XL_NPP(N) N ## _l
352 # define __LOCALE_PARAM , __locale_t locale_arg
353 # define __LOCALE_ARG , locale_arg
354 # define __LOCALE_PTR locale_arg
356 #else
358 # define __XL_NPP(N) N
359 # define __LOCALE_PARAM
360 # define __LOCALE_ARG
361 # define __LOCALE_PTR __UCLIBC_CURLOCALE
363 #endif
364 /**********************************************************************/
366 #endif /* _LIBC */
368 #endif /* !defined(__LOCALE_C_ONLY) */
370 #endif /* _UCLIBC_LOCALE_H */