diff options
Diffstat (limited to 'meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch')
-rw-r--r-- | meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch | 566 |
1 files changed, 566 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch new file mode 100644 index 0000000000..c45b557ab7 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch | |||
@@ -0,0 +1,566 @@ | |||
1 | From 11d7633178301add26a24657e2f1596a2f7dddce Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Wed, 18 Mar 2015 01:33:49 +0000 | ||
4 | Subject: [PATCH 24/25] eglibc: Forward port cross locale generation support | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | locale/Makefile | 3 ++- | ||
11 | locale/catnames.c | 48 +++++++++++++++++++++++++++++++++++ | ||
12 | locale/localeinfo.h | 2 +- | ||
13 | locale/programs/charmap-dir.c | 6 +++++ | ||
14 | locale/programs/ld-collate.c | 17 ++++++------- | ||
15 | locale/programs/ld-ctype.c | 27 ++++++++++---------- | ||
16 | locale/programs/ld-time.c | 31 +++++++++++++++-------- | ||
17 | locale/programs/linereader.c | 2 +- | ||
18 | locale/programs/localedef.c | 8 ++++++ | ||
19 | locale/programs/locfile.c | 5 +++- | ||
20 | locale/programs/locfile.h | 59 +++++++++++++++++++++++++++++++++++++++++-- | ||
21 | locale/setlocale.c | 30 ---------------------- | ||
22 | 12 files changed, 169 insertions(+), 69 deletions(-) | ||
23 | create mode 100644 locale/catnames.c | ||
24 | |||
25 | diff --git a/locale/Makefile b/locale/Makefile | ||
26 | index c5379e6..c98c675 100644 | ||
27 | --- a/locale/Makefile | ||
28 | +++ b/locale/Makefile | ||
29 | @@ -25,7 +25,8 @@ include ../Makeconfig | ||
30 | headers = locale.h bits/locale.h langinfo.h xlocale.h | ||
31 | routines = setlocale findlocale loadlocale loadarchive \ | ||
32 | localeconv nl_langinfo nl_langinfo_l mb_cur_max \ | ||
33 | - newlocale duplocale freelocale uselocale | ||
34 | + newlocale duplocale freelocale uselocale \ | ||
35 | + catnames | ||
36 | tests = tst-C-locale tst-locname tst-duplocale | ||
37 | categories = ctype messages monetary numeric time paper name \ | ||
38 | address telephone measurement identification collate | ||
39 | diff --git a/locale/catnames.c b/locale/catnames.c | ||
40 | new file mode 100644 | ||
41 | index 0000000..9fad357 | ||
42 | --- /dev/null | ||
43 | +++ b/locale/catnames.c | ||
44 | @@ -0,0 +1,48 @@ | ||
45 | +/* Copyright (C) 2006 Free Software Foundation, Inc. | ||
46 | + This file is part of the GNU C Library. | ||
47 | + | ||
48 | + The GNU C Library is free software; you can redistribute it and/or | ||
49 | + modify it under the terms of the GNU Lesser General Public | ||
50 | + License as published by the Free Software Foundation; either | ||
51 | + version 2.1 of the License, or (at your option) any later version. | ||
52 | + | ||
53 | + The GNU C Library is distributed in the hope that it will be useful, | ||
54 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
55 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
56 | + Lesser General Public License for more details. | ||
57 | + | ||
58 | + You should have received a copy of the GNU Lesser General Public | ||
59 | + License along with the GNU C Library; if not, write to the Free | ||
60 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
61 | + 02111-1307 USA. */ | ||
62 | + | ||
63 | +#include "localeinfo.h" | ||
64 | + | ||
65 | +/* Define an array of category names (also the environment variable names). */ | ||
66 | +const union catnamestr_t _nl_category_names attribute_hidden = | ||
67 | + { | ||
68 | + { | ||
69 | +#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
70 | + category_name, | ||
71 | +#include "categories.def" | ||
72 | +#undef DEFINE_CATEGORY | ||
73 | + } | ||
74 | + }; | ||
75 | + | ||
76 | +const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = | ||
77 | + { | ||
78 | +#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
79 | + [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)), | ||
80 | +#include "categories.def" | ||
81 | +#undef DEFINE_CATEGORY | ||
82 | + }; | ||
83 | + | ||
84 | +/* An array of their lengths, for convenience. */ | ||
85 | +const uint8_t _nl_category_name_sizes[] attribute_hidden = | ||
86 | + { | ||
87 | +#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
88 | + [category] = sizeof (category_name) - 1, | ||
89 | +#include "categories.def" | ||
90 | +#undef DEFINE_CATEGORY | ||
91 | + [LC_ALL] = sizeof ("LC_ALL") - 1 | ||
92 | + }; | ||
93 | diff --git a/locale/localeinfo.h b/locale/localeinfo.h | ||
94 | index 94627f3..d0db77b 100644 | ||
95 | --- a/locale/localeinfo.h | ||
96 | +++ b/locale/localeinfo.h | ||
97 | @@ -224,7 +224,7 @@ __libc_tsd_define (extern, __locale_t, LOCALE) | ||
98 | unused. We can manage this playing some tricks with weak references. | ||
99 | But with thread-local locale settings, it becomes quite ungainly unless | ||
100 | we can use __thread variables. So only in that case do we attempt this. */ | ||
101 | -#ifndef SHARED | ||
102 | +#if !defined SHARED && !defined IN_GLIBC_LOCALEDEF | ||
103 | # include <tls.h> | ||
104 | # define NL_CURRENT_INDIRECT 1 | ||
105 | #endif | ||
106 | diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c | ||
107 | index 99fcd35..5e528dc 100644 | ||
108 | --- a/locale/programs/charmap-dir.c | ||
109 | +++ b/locale/programs/charmap-dir.c | ||
110 | @@ -19,7 +19,9 @@ | ||
111 | #include <error.h> | ||
112 | #include <fcntl.h> | ||
113 | #include <libintl.h> | ||
114 | +#ifndef NO_UNCOMPRESS | ||
115 | #include <spawn.h> | ||
116 | +#endif | ||
117 | #include <stdio.h> | ||
118 | #include <stdlib.h> | ||
119 | #include <string.h> | ||
120 | @@ -156,6 +158,7 @@ charmap_closedir (CHARMAP_DIR *cdir) | ||
121 | return closedir (dir); | ||
122 | } | ||
123 | |||
124 | +#ifndef NO_UNCOMPRESS | ||
125 | /* Creates a subprocess decompressing the given pathname, and returns | ||
126 | a stream reading its output (the decompressed data). */ | ||
127 | static | ||
128 | @@ -204,6 +207,7 @@ fopen_uncompressed (const char *pathname, const char *compressor) | ||
129 | } | ||
130 | return NULL; | ||
131 | } | ||
132 | +#endif | ||
133 | |||
134 | /* Opens a charmap for reading, given its name (not an alias name). */ | ||
135 | FILE * | ||
136 | @@ -226,6 +230,7 @@ charmap_open (const char *directory, const char *name) | ||
137 | if (stream != NULL) | ||
138 | return stream; | ||
139 | |||
140 | +#ifndef NO_UNCOMPRESS | ||
141 | memcpy (p, ".gz", 4); | ||
142 | stream = fopen_uncompressed (pathname, "gzip"); | ||
143 | if (stream != NULL) | ||
144 | @@ -235,6 +240,7 @@ charmap_open (const char *directory, const char *name) | ||
145 | stream = fopen_uncompressed (pathname, "bzip2"); | ||
146 | if (stream != NULL) | ||
147 | return stream; | ||
148 | +#endif | ||
149 | |||
150 | return NULL; | ||
151 | } | ||
152 | diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c | ||
153 | index 1e125f6..3b2867f 100644 | ||
154 | --- a/locale/programs/ld-collate.c | ||
155 | +++ b/locale/programs/ld-collate.c | ||
156 | @@ -350,7 +350,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen, | ||
157 | } | ||
158 | if (wcs != NULL) | ||
159 | { | ||
160 | - size_t nwcs = wcslen ((wchar_t *) wcs); | ||
161 | + size_t nwcs = wcslen_uint32 (wcs); | ||
162 | uint32_t zero = 0; | ||
163 | /* Handle <U0000> as a single character. */ | ||
164 | if (nwcs == 0) | ||
165 | @@ -1776,8 +1776,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name); | ||
166 | |||
167 | if ((*eptr)->nwcs == runp->nwcs) | ||
168 | { | ||
169 | - int c = wmemcmp ((wchar_t *) (*eptr)->wcs, | ||
170 | - (wchar_t *) runp->wcs, runp->nwcs); | ||
171 | + int c = wmemcmp_uint32 ((*eptr)->wcs, runp->wcs, runp->nwcs); | ||
172 | |||
173 | if (c == 0) | ||
174 | { | ||
175 | @@ -2010,9 +2009,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) | ||
176 | one consecutive entry. */ | ||
177 | if (runp->wcnext != NULL | ||
178 | && runp->nwcs == runp->wcnext->nwcs | ||
179 | - && wmemcmp ((wchar_t *) runp->wcs, | ||
180 | - (wchar_t *)runp->wcnext->wcs, | ||
181 | - runp->nwcs - 1) == 0 | ||
182 | + && wmemcmp_uint32 (runp->wcs, | ||
183 | + runp->wcnext->wcs, | ||
184 | + runp->nwcs - 1) == 0 | ||
185 | && (runp->wcs[runp->nwcs - 1] | ||
186 | == runp->wcnext->wcs[runp->nwcs - 1] + 1)) | ||
187 | { | ||
188 | @@ -2036,9 +2035,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) | ||
189 | runp = runp->wcnext; | ||
190 | while (runp->wcnext != NULL | ||
191 | && runp->nwcs == runp->wcnext->nwcs | ||
192 | - && wmemcmp ((wchar_t *) runp->wcs, | ||
193 | - (wchar_t *)runp->wcnext->wcs, | ||
194 | - runp->nwcs - 1) == 0 | ||
195 | + && wmemcmp_uint32 (runp->wcs, | ||
196 | + runp->wcnext->wcs, | ||
197 | + runp->nwcs - 1) == 0 | ||
198 | && (runp->wcs[runp->nwcs - 1] | ||
199 | == runp->wcnext->wcs[runp->nwcs - 1] + 1)); | ||
200 | |||
201 | diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c | ||
202 | index 0fd141c..68136e6 100644 | ||
203 | --- a/locale/programs/ld-ctype.c | ||
204 | +++ b/locale/programs/ld-ctype.c | ||
205 | @@ -926,7 +926,7 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap, | ||
206 | allocate_arrays (ctype, charmap, ctype->repertoire); | ||
207 | |||
208 | default_missing_len = (ctype->default_missing | ||
209 | - ? wcslen ((wchar_t *) ctype->default_missing) | ||
210 | + ? wcslen_uint32 (ctype->default_missing) | ||
211 | : 0); | ||
212 | |||
213 | init_locale_data (&file, nelems); | ||
214 | @@ -1937,7 +1937,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype, | ||
215 | ignore = 1; | ||
216 | else | ||
217 | /* This value is usable. */ | ||
218 | - obstack_grow (ob, to_wstr, wcslen ((wchar_t *) to_wstr) * 4); | ||
219 | + obstack_grow (ob, to_wstr, wcslen_uint32 (to_wstr) * 4); | ||
220 | |||
221 | first = 0; | ||
222 | } | ||
223 | @@ -2471,8 +2471,8 @@ with character code range values one must use the absolute ellipsis `...'")); | ||
224 | } | ||
225 | |||
226 | handle_tok_digit: | ||
227 | - class_bit = _ISwdigit; | ||
228 | - class256_bit = _ISdigit; | ||
229 | + class_bit = BITw (tok_digit); | ||
230 | + class256_bit = BIT (tok_digit); | ||
231 | handle_digits = 1; | ||
232 | goto read_charclass; | ||
233 | |||
234 | @@ -3929,8 +3929,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, | ||
235 | |||
236 | while (idx < number) | ||
237 | { | ||
238 | - int res = wcscmp ((const wchar_t *) sorted[idx]->from, | ||
239 | - (const wchar_t *) runp->from); | ||
240 | + int res = wcscmp_uint32 (sorted[idx]->from, runp->from); | ||
241 | if (res == 0) | ||
242 | { | ||
243 | replace = 1; | ||
244 | @@ -3967,11 +3966,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, | ||
245 | for (size_t cnt = 0; cnt < number; ++cnt) | ||
246 | { | ||
247 | struct translit_to_t *srunp; | ||
248 | - from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1; | ||
249 | + from_len += wcslen_uint32 (sorted[cnt]->from) + 1; | ||
250 | srunp = sorted[cnt]->to; | ||
251 | while (srunp != NULL) | ||
252 | { | ||
253 | - to_len += wcslen ((const wchar_t *) srunp->str) + 1; | ||
254 | + to_len += wcslen_uint32 (srunp->str) + 1; | ||
255 | srunp = srunp->next; | ||
256 | } | ||
257 | /* Plus one for the extra NUL character marking the end of | ||
258 | @@ -3995,18 +3994,18 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, | ||
259 | ctype->translit_from_idx[cnt] = from_len; | ||
260 | ctype->translit_to_idx[cnt] = to_len; | ||
261 | |||
262 | - len = wcslen ((const wchar_t *) sorted[cnt]->from) + 1; | ||
263 | - wmemcpy ((wchar_t *) &ctype->translit_from_tbl[from_len], | ||
264 | - (const wchar_t *) sorted[cnt]->from, len); | ||
265 | + len = wcslen_uint32 (sorted[cnt]->from) + 1; | ||
266 | + wmemcpy_uint32 (&ctype->translit_from_tbl[from_len], | ||
267 | + sorted[cnt]->from, len); | ||
268 | from_len += len; | ||
269 | |||
270 | ctype->translit_to_idx[cnt] = to_len; | ||
271 | srunp = sorted[cnt]->to; | ||
272 | while (srunp != NULL) | ||
273 | { | ||
274 | - len = wcslen ((const wchar_t *) srunp->str) + 1; | ||
275 | - wmemcpy ((wchar_t *) &ctype->translit_to_tbl[to_len], | ||
276 | - (const wchar_t *) srunp->str, len); | ||
277 | + len = wcslen_uint32 (srunp->str) + 1; | ||
278 | + wmemcpy_uint32 (&ctype->translit_to_tbl[to_len], | ||
279 | + srunp->str, len); | ||
280 | to_len += len; | ||
281 | srunp = srunp->next; | ||
282 | } | ||
283 | diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c | ||
284 | index 87531bc..5f2c266 100644 | ||
285 | --- a/locale/programs/ld-time.c | ||
286 | +++ b/locale/programs/ld-time.c | ||
287 | @@ -215,8 +215,10 @@ No definition for %s category found"), "LC_TIME")); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | + static const uint32_t wt_fmt_ampm[] | ||
292 | + = { '%','I',':','%','M',':','%','S',' ','%','p',0 }; | ||
293 | time->t_fmt_ampm = "%I:%M:%S %p"; | ||
294 | - time->wt_fmt_ampm = (const uint32_t *) L"%I:%M:%S %p"; | ||
295 | + time->wt_fmt_ampm = wt_fmt_ampm; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | @@ -226,7 +228,7 @@ No definition for %s category found"), "LC_TIME")); | ||
300 | const int days_per_month[12] = { 31, 29, 31, 30, 31, 30, | ||
301 | 31, 31, 30, 31 ,30, 31 }; | ||
302 | size_t idx; | ||
303 | - wchar_t *wstr; | ||
304 | + uint32_t *wstr; | ||
305 | |||
306 | time->era_entries = | ||
307 | (struct era_data *) xmalloc (time->num_era | ||
308 | @@ -464,18 +466,18 @@ No definition for %s category found"), "LC_TIME")); | ||
309 | } | ||
310 | |||
311 | /* Now generate the wide character name and format. */ | ||
312 | - wstr = wcschr ((wchar_t *) time->wera[idx], L':');/* end direction */ | ||
313 | - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end offset */ | ||
314 | - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end start */ | ||
315 | - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end end */ | ||
316 | + wstr = wcschr_uint32 (time->wera[idx], L':'); /* end direction */ | ||
317 | + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end offset */ | ||
318 | + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end start */ | ||
319 | + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end end */ | ||
320 | if (wstr != NULL) | ||
321 | { | ||
322 | - time->era_entries[idx].wname = (uint32_t *) wstr + 1; | ||
323 | - wstr = wcschr (wstr + 1, L':'); /* end name */ | ||
324 | + time->era_entries[idx].wname = wstr + 1; | ||
325 | + wstr = wcschr_uint32 (wstr + 1, L':'); /* end name */ | ||
326 | if (wstr != NULL) | ||
327 | { | ||
328 | *wstr = L'\0'; | ||
329 | - time->era_entries[idx].wformat = (uint32_t *) wstr + 1; | ||
330 | + time->era_entries[idx].wformat = wstr + 1; | ||
331 | } | ||
332 | else | ||
333 | time->era_entries[idx].wname = | ||
334 | @@ -534,7 +536,16 @@ No definition for %s category found"), "LC_TIME")); | ||
335 | if (time->date_fmt == NULL) | ||
336 | time->date_fmt = "%a %b %e %H:%M:%S %Z %Y"; | ||
337 | if (time->wdate_fmt == NULL) | ||
338 | - time->wdate_fmt = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y"; | ||
339 | + { | ||
340 | + static const uint32_t wdate_fmt[] = | ||
341 | + { '%','a',' ', | ||
342 | + '%','b',' ', | ||
343 | + '%','e',' ', | ||
344 | + '%','H',':','%','M',':','%','S',' ', | ||
345 | + '%','Z',' ', | ||
346 | + '%','Y',0 }; | ||
347 | + time->wdate_fmt = wdate_fmt; | ||
348 | + } | ||
349 | } | ||
350 | |||
351 | |||
352 | diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c | ||
353 | index b885f65..0afb631 100644 | ||
354 | --- a/locale/programs/linereader.c | ||
355 | +++ b/locale/programs/linereader.c | ||
356 | @@ -595,7 +595,7 @@ get_string (struct linereader *lr, const struct charmap_t *charmap, | ||
357 | { | ||
358 | int return_widestr = lr->return_widestr; | ||
359 | char *buf; | ||
360 | - wchar_t *buf2 = NULL; | ||
361 | + uint32_t *buf2 = NULL; | ||
362 | size_t bufact; | ||
363 | size_t bufmax = 56; | ||
364 | |||
365 | diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c | ||
366 | index 6becd9a..8ddd080 100644 | ||
367 | --- a/locale/programs/localedef.c | ||
368 | +++ b/locale/programs/localedef.c | ||
369 | @@ -114,6 +114,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; | ||
370 | #define OPT_LIST_ARCHIVE 309 | ||
371 | #define OPT_LITTLE_ENDIAN 400 | ||
372 | #define OPT_BIG_ENDIAN 401 | ||
373 | +#define OPT_UINT32_ALIGN 402 | ||
374 | |||
375 | /* Definitions of arguments for argp functions. */ | ||
376 | static const struct argp_option options[] = | ||
377 | @@ -150,6 +151,8 @@ static const struct argp_option options[] = | ||
378 | N_("Generate little-endian output") }, | ||
379 | { "big-endian", OPT_BIG_ENDIAN, NULL, 0, | ||
380 | N_("Generate big-endian output") }, | ||
381 | + { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0, | ||
382 | + N_("Set the target's uint32_t alignment in bytes (default 4)") }, | ||
383 | { NULL, 0, NULL, 0, NULL } | ||
384 | }; | ||
385 | |||
386 | @@ -239,12 +242,14 @@ main (int argc, char *argv[]) | ||
387 | ctype locale. (P1003.2 4.35.5.2) */ | ||
388 | setlocale (LC_CTYPE, "POSIX"); | ||
389 | |||
390 | +#ifndef NO_SYSCONF | ||
391 | /* Look whether the system really allows locale definitions. POSIX | ||
392 | defines error code 3 for this situation so I think it must be | ||
393 | a fatal error (see P1003.2 4.35.8). */ | ||
394 | if (sysconf (_SC_2_LOCALEDEF) < 0) | ||
395 | WITH_CUR_LOCALE (error (3, 0, _("\ | ||
396 | FATAL: system does not define `_POSIX2_LOCALEDEF'"))); | ||
397 | +#endif | ||
398 | |||
399 | /* Process charmap file. */ | ||
400 | charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1); | ||
401 | @@ -338,6 +343,9 @@ parse_opt (int key, char *arg, struct argp_state *state) | ||
402 | case OPT_BIG_ENDIAN: | ||
403 | set_big_endian (true); | ||
404 | break; | ||
405 | + case OPT_UINT32_ALIGN: | ||
406 | + uint32_align_mask = strtol (arg, NULL, 0) - 1; | ||
407 | + break; | ||
408 | case 'c': | ||
409 | force_output = 1; | ||
410 | break; | ||
411 | diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c | ||
412 | index 32f5cd2..02967b0 100644 | ||
413 | --- a/locale/programs/locfile.c | ||
414 | +++ b/locale/programs/locfile.c | ||
415 | @@ -544,6 +544,9 @@ compare_files (const char *filename1, const char *filename2, size_t size, | ||
416 | machine running localedef. */ | ||
417 | bool swap_endianness_p; | ||
418 | |||
419 | +/* The target's value of __align__(uint32_t) - 1. */ | ||
420 | +unsigned int uint32_align_mask = 3; | ||
421 | + | ||
422 | /* When called outside a start_locale_structure/end_locale_structure | ||
423 | or start_locale_prelude/end_locale_prelude block, record that the | ||
424 | next byte in FILE's obstack will be the first byte of a new element. | ||
425 | @@ -621,7 +624,7 @@ add_locale_string (struct locale_file *file, const char *string) | ||
426 | void | ||
427 | add_locale_wstring (struct locale_file *file, const uint32_t *string) | ||
428 | { | ||
429 | - add_locale_uint32_array (file, string, wcslen ((const wchar_t *) string) + 1); | ||
430 | + add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1); | ||
431 | } | ||
432 | |||
433 | /* Record that FILE's next element is the 32-bit integer VALUE. */ | ||
434 | diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h | ||
435 | index a3dd904..2c7763a 100644 | ||
436 | --- a/locale/programs/locfile.h | ||
437 | +++ b/locale/programs/locfile.h | ||
438 | @@ -71,6 +71,8 @@ extern void write_all_categories (struct localedef_t *definitions, | ||
439 | |||
440 | extern bool swap_endianness_p; | ||
441 | |||
442 | +extern unsigned int uint32_align_mask; | ||
443 | + | ||
444 | /* Change the output to be big-endian if BIG_ENDIAN is true and | ||
445 | little-endian otherwise. */ | ||
446 | static inline void | ||
447 | @@ -89,7 +91,8 @@ maybe_swap_uint32 (uint32_t value) | ||
448 | } | ||
449 | |||
450 | /* Likewise, but munge an array of N uint32_ts starting at ARRAY. */ | ||
451 | -static inline void | ||
452 | +static void | ||
453 | +__attribute__ ((unused)) | ||
454 | maybe_swap_uint32_array (uint32_t *array, size_t n) | ||
455 | { | ||
456 | if (swap_endianness_p) | ||
457 | @@ -99,7 +102,8 @@ maybe_swap_uint32_array (uint32_t *array, size_t n) | ||
458 | |||
459 | /* Like maybe_swap_uint32_array, but the array of N elements is at | ||
460 | the end of OBSTACK's current object. */ | ||
461 | -static inline void | ||
462 | +static void | ||
463 | +__attribute__ ((unused)) | ||
464 | maybe_swap_uint32_obstack (struct obstack *obstack, size_t n) | ||
465 | { | ||
466 | maybe_swap_uint32_array ((uint32_t *) obstack_next_free (obstack) - n, n); | ||
467 | @@ -276,4 +280,55 @@ extern void identification_output (struct localedef_t *locale, | ||
468 | const struct charmap_t *charmap, | ||
469 | const char *output_path); | ||
470 | |||
471 | +static size_t wcslen_uint32 (const uint32_t *str) __attribute__ ((unused)); | ||
472 | +static uint32_t * wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); | ||
473 | +static uint32_t * wcschr_uint32 (const uint32_t *s, uint32_t ch) __attribute__ ((unused)); | ||
474 | +static int wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) __attribute__ ((unused)); | ||
475 | +static int wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); | ||
476 | + | ||
477 | +static size_t | ||
478 | +wcslen_uint32 (const uint32_t *str) | ||
479 | +{ | ||
480 | + size_t len = 0; | ||
481 | + while (str[len] != 0) | ||
482 | + len++; | ||
483 | + return len; | ||
484 | +} | ||
485 | + | ||
486 | +static int | ||
487 | +wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) | ||
488 | +{ | ||
489 | + while (n-- != 0) | ||
490 | + { | ||
491 | + int diff = *s1++ - *s2++; | ||
492 | + if (diff != 0) | ||
493 | + return diff; | ||
494 | + } | ||
495 | + return 0; | ||
496 | +} | ||
497 | + | ||
498 | +static int | ||
499 | +wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) | ||
500 | +{ | ||
501 | + while (*s1 != 0 && *s1 == *s2) | ||
502 | + s1++, s2++; | ||
503 | + return *s1 - *s2; | ||
504 | +} | ||
505 | + | ||
506 | +static uint32_t * | ||
507 | +wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) | ||
508 | +{ | ||
509 | + return memcpy (s1, s2, n * sizeof (uint32_t)); | ||
510 | +} | ||
511 | + | ||
512 | +static uint32_t * | ||
513 | +wcschr_uint32 (const uint32_t *s, uint32_t ch) | ||
514 | +{ | ||
515 | + do | ||
516 | + if (*s == ch) | ||
517 | + return (uint32_t *) s; | ||
518 | + while (*s++ != 0); | ||
519 | + return 0; | ||
520 | +} | ||
521 | + | ||
522 | #endif /* locfile.h */ | ||
523 | diff --git a/locale/setlocale.c b/locale/setlocale.c | ||
524 | index 69b3141..1cef0be 100644 | ||
525 | --- a/locale/setlocale.c | ||
526 | +++ b/locale/setlocale.c | ||
527 | @@ -64,36 +64,6 @@ static char *const _nl_current_used[] = | ||
528 | #endif | ||
529 | |||
530 | |||
531 | -/* Define an array of category names (also the environment variable names). */ | ||
532 | -const union catnamestr_t _nl_category_names attribute_hidden = | ||
533 | - { | ||
534 | - { | ||
535 | -#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
536 | - category_name, | ||
537 | -#include "categories.def" | ||
538 | -#undef DEFINE_CATEGORY | ||
539 | - } | ||
540 | - }; | ||
541 | - | ||
542 | -const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = | ||
543 | - { | ||
544 | -#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
545 | - [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)), | ||
546 | -#include "categories.def" | ||
547 | -#undef DEFINE_CATEGORY | ||
548 | - }; | ||
549 | - | ||
550 | -/* An array of their lengths, for convenience. */ | ||
551 | -const uint8_t _nl_category_name_sizes[] attribute_hidden = | ||
552 | - { | ||
553 | -#define DEFINE_CATEGORY(category, category_name, items, a) \ | ||
554 | - [category] = sizeof (category_name) - 1, | ||
555 | -#include "categories.def" | ||
556 | -#undef DEFINE_CATEGORY | ||
557 | - [LC_ALL] = sizeof ("LC_ALL") - 1 | ||
558 | - }; | ||
559 | - | ||
560 | - | ||
561 | #ifdef NL_CURRENT_INDIRECT | ||
562 | # define WEAK_POSTLOAD(postload) weak_extern (postload) | ||
563 | #else | ||
564 | -- | ||
565 | 2.8.2 | ||
566 | |||