summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichard <richard@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2006-09-07 17:07:34 +0000
committerrichard <richard@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2006-09-07 17:07:34 +0000
commitba4ae17440aacd42a5de2e6e35564134f3b9a839 (patch)
tree96a4d81456806f4d83d2eeb9061c7e9e011adbb1
parent49272c94417875e5255681b3eacee05ef0db27fb (diff)
downloadeglibc2-ba4ae17440aacd42a5de2e6e35564134f3b9a839.tar.gz
* locale/programs/ld-collate.c (obstack_int32_grow): Only use
obstack_int_grow if the object size is int-aligned. (obstack_int32_grow_fast): Likewise obstack_int_grow_fast. (new_element): Handle <U0000> as a single character. (collate_output): Use uint32_align_mask. Use obstack_int32_grow_fast rather than obstack_int32_grow for an int32 that has already been allocated. * locale/programs/localedef.c (OPT_UINT32_ALIGN): New macro. (options): Add --uint32-align. (parse_opt): Handle it. * locale/programs/locfile.c (uint32_align_mask): New variable. * locale/programs/locfile.h (uint32_align_mask): Declare. git-svn-id: svn://svn.eglibc.org/trunk@166 7b3dc134-2b1b-0410-93df-9e9f96275f8d
-rw-r--r--libc/ChangeLog.eglibc15
-rw-r--r--libc/locale/programs/ld-collate.c42
-rw-r--r--libc/locale/programs/localedef.c6
-rw-r--r--libc/locale/programs/locfile.c3
-rw-r--r--libc/locale/programs/locfile.h2
5 files changed, 47 insertions, 21 deletions
diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc
index cab348a82..68fb78621 100644
--- a/libc/ChangeLog.eglibc
+++ b/libc/ChangeLog.eglibc
@@ -1,5 +1,20 @@
2006-09-07 Richard Sandiford <richard@codesourcery.com>
+ * locale/programs/ld-collate.c (obstack_int32_grow): Only use
+ obstack_int_grow if the object size is int-aligned.
+ (obstack_int32_grow_fast): Likewise obstack_int_grow_fast.
+ (new_element): Handle <U0000> as a single character.
+ (collate_output): Use uint32_align_mask. Use obstack_int32_grow_fast
+ rather than obstack_int32_grow for an int32 that has already been
+ allocated.
+ * locale/programs/localedef.c (OPT_UINT32_ALIGN): New macro.
+ (options): Add --uint32-align.
+ (parse_opt): Handle it.
+ * locale/programs/locfile.c (uint32_align_mask): New variable.
+ * locale/programs/locfile.h (uint32_align_mask): Declare.
+
+2006-09-07 Richard Sandiford <richard@codesourcery.com>
+
* argp/argp-help.c (__argp_short_program_name): Protect function name
from macro expansion.
* argp/argp-namefrob.h: Don't include mempcpy.h, strcase.h,
diff --git a/libc/locale/programs/ld-collate.c b/libc/locale/programs/ld-collate.c
index 856f243bb..6246f1247 100644
--- a/libc/locale/programs/ld-collate.c
+++ b/libc/locale/programs/ld-collate.c
@@ -44,7 +44,8 @@ __attribute ((always_inline))
obstack_int32_grow (struct obstack *obstack, int32_t data)
{
data = maybe_swap_uint32 (data);
- if (sizeof (int32_t) == sizeof (int))
+ if (sizeof (int32_t) == sizeof (int)
+ && (obstack_object_size (obstack) & (__alignof__ (int) - 1)) == 0)
obstack_int_grow (obstack, data);
else
obstack_grow (obstack, &data, sizeof (int32_t));
@@ -55,7 +56,8 @@ __attribute ((always_inline))
obstack_int32_grow_fast (struct obstack *obstack, int32_t data)
{
data = maybe_swap_uint32 (data);
- if (sizeof (int32_t) == sizeof (int))
+ if (sizeof (int32_t) == sizeof (int)
+ && (obstack_object_size (obstack) & (__alignof__ (int) - 1)) == 0)
obstack_int_grow_fast (obstack, data);
else
obstack_grow (obstack, &data, sizeof (int32_t));
@@ -327,6 +329,9 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen,
{
size_t nwcs = wcslen_uint32 (wcs);
uint32_t zero = 0;
+ /* Handle <U0000> as a single character. */
+ if (nwcs == 0)
+ nwcs = 1;
obstack_grow (&collate->mempool, wcs, nwcs * sizeof (uint32_t));
obstack_grow (&collate->mempool, &zero, sizeof (uint32_t));
newp->wcs = (uint32_t *) obstack_finish (&collate->mempool);
@@ -2040,8 +2045,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
struct element_t *runp = collate->mbheads[ch];
struct element_t *lastp;
- assert ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) == 0);
+ assert ((obstack_object_size (&extrapool) & uint32_align_mask) == 0);
tablemb[ch] = -obstack_object_size (&extrapool);
@@ -2067,10 +2071,10 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
/* Compute how much space we will need. */
added = ((sizeof (int32_t) + 1 + 2 * (runp->nmbs - 1)
- + __alignof__ (int32_t) - 1)
- & ~(__alignof__ (int32_t) - 1));
+ + uint32_align_mask)
+ & ~uint32_align_mask);
assert ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) == 0);
+ & uint32_align_mask) == 0);
obstack_make_room (&extrapool, added);
/* More than one consecutive entry. We mark this by having
@@ -2128,10 +2132,10 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
weightidx = output_weight (&weightpool, collate, runp);
added = ((sizeof (int32_t) + 1 + runp->nmbs - 1
- + __alignof__ (int32_t) - 1)
- & ~(__alignof__ (int32_t) - 1));
+ + uint32_align_mask)
+ & ~uint32_align_mask);
assert ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) == 0);
+ & uint32_align_mask) == 0);
obstack_make_room (&extrapool, added);
obstack_int32_grow_fast (&extrapool, weightidx);
@@ -2143,8 +2147,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
}
/* Add alignment bytes if necessary. */
- while ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) != 0)
+ while ((obstack_object_size (&extrapool) & uint32_align_mask) != 0)
obstack_1grow_fast (&extrapool, '\0');
/* Next entry. */
@@ -2153,15 +2156,14 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
}
while (runp != NULL);
- assert ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) == 0);
+ assert ((obstack_object_size (&extrapool) & uint32_align_mask) == 0);
/* If the final entry in the list is not a single character we
add an UNDEFINED entry here. */
if (lastp->nmbs != 1)
{
- int added = ((sizeof (int32_t) + 1 + 1 + __alignof__ (int32_t) - 1)
- & ~(__alignof__ (int32_t) - 1));
+ int added = ((sizeof (int32_t) + 1 + 1 + uint32_align_mask)
+ & ~uint32_align_mask);
obstack_make_room (&extrapool, added);
obstack_int32_grow_fast (&extrapool, 0);
@@ -2171,15 +2173,13 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
obstack_1grow_fast (&extrapool, 0);
/* Add alignment bytes if necessary. */
- while ((obstack_object_size (&extrapool)
- & (__alignof__ (int32_t) - 1)) != 0)
+ while ((obstack_object_size (&extrapool) & uint32_align_mask) != 0)
obstack_1grow_fast (&extrapool, '\0');
}
}
/* Add padding to the tables if necessary. */
- while ((obstack_object_size (&weightpool) & (__alignof__ (int32_t) - 1))
- != 0)
+ while ((obstack_object_size (&weightpool) & uint32_align_mask) != 0)
obstack_1grow (&weightpool, 0);
/* Now add the four tables. */
@@ -2298,7 +2298,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
/* And add the end byte sequence. Without length this
time. */
for (i = 1; i < curp->nwcs; ++i)
- obstack_int32_grow (&extrapool, curp->wcs[i]);
+ obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
}
else
{
diff --git a/libc/locale/programs/localedef.c b/libc/locale/programs/localedef.c
index 82ec2e398..524813358 100644
--- a/libc/locale/programs/localedef.c
+++ b/libc/locale/programs/localedef.c
@@ -114,6 +114,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
#define OPT_LIST_ARCHIVE 309
#define OPT_LITTLE_ENDIAN 400
#define OPT_BIG_ENDIAN 401
+#define OPT_UINT32_ALIGN 402
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
@@ -148,6 +149,8 @@ static const struct argp_option options[] =
{ "little-endian", OPT_LITTLE_ENDIAN, NULL, 0,
N_("Generate little-endian output") },
{ "big-endian", OPT_BIG_ENDIAN, NULL, 0, N_("Generate big-endian output") },
+ { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0,
+ N_("Set the target's uint32_t alignment in bytes (default 4)") },
{ NULL, 0, NULL, 0, NULL }
};
@@ -341,6 +344,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
case OPT_BIG_ENDIAN:
set_big_endian (1);
break;
+ case OPT_UINT32_ALIGN:
+ uint32_align_mask = strtol (arg, NULL, 0) - 1;
+ break;
case 'c':
force_output = 1;
break;
diff --git a/libc/locale/programs/locfile.c b/libc/locale/programs/locfile.c
index 97cadbd51..8ba3b7404 100644
--- a/libc/locale/programs/locfile.c
+++ b/libc/locale/programs/locfile.c
@@ -542,6 +542,9 @@ compare_files (const char *filename1, const char *filename2, size_t size,
machine running localedef. */
int swap_endianness_p;
+/* The target's value of __align__(uint32_t) - 1. */
+unsigned int uint32_align_mask = 3;
+
/* When called outside a start_locale_structure()/end_locale_structure()
or start_locale_prelude()/end_locale_prelude() block, record that the
next byte in FILE's obstack will be the first byte of a new element.
diff --git a/libc/locale/programs/locfile.h b/libc/locale/programs/locfile.h
index c649f9604..5116283eb 100644
--- a/libc/locale/programs/locfile.h
+++ b/libc/locale/programs/locfile.h
@@ -67,6 +67,8 @@ extern void write_all_categories (struct localedef_t *definitions,
extern int swap_endianness_p;
+extern unsigned int uint32_align_mask;
+
/* Change the output to be big-endian if BIG_ENDIAN is true and
little-endian otherwise. */
static inline void