This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

collate_output: Assertion `idx[cnt] % 4 == 0' failed.


ld-collate.c requires an alignment of 4 when previous items where only
aligned at __alignof__ (int32_t).  The latter is 2 on m68k-linux, thus the
assertion may fail.

2000-09-26  Andreas Schwab  <schwab@suse.de>

	* locale/programs/ld-collate.c (collate_output): Only require
	alignment on __alignof__ (int32_t) instead of 4.
	* locale/loadlocale.c (_nl_load_locale): Likewise.
	* string/strcoll.c: Likewise.

Index: locale/loadlocale.c
===================================================================
RCS file: /cvs/glibc/libc/locale/loadlocale.c,v
retrieving revision 1.37
diff -u -a -u -r1.37 locale/loadlocale.c
--- locale/loadlocale.c	2000/09/01 02:23:48	1.37
+++ locale/loadlocale.c	2000/09/26 11:43:30
@@ -217,7 +217,7 @@
 	}
       if (__builtin_expect (_nl_value_types[category][cnt] == word, 0))
 	{
-	  assert (idx % 4 == 0);
+	  assert (idx % __alignof__ (u_int32_t) == 0);
 	  newdata->values[cnt].word =
 	    *((u_int32_t *) (newdata->filedata + idx));
 	}
Index: locale/programs/ld-collate.c
===================================================================
RCS file: /cvs/glibc/libc/locale/programs/ld-collate.c,v
retrieving revision 1.86
diff -u -a -u -r1.86 locale/programs/ld-collate.c
--- locale/programs/ld-collate.c	2000/09/11 20:32:13	1.86
+++ locale/programs/ld-collate.c	2000/09/26 11:43:46
@@ -2204,21 +2204,21 @@
   iov[2 + cnt].iov_base = NULL;
   iov[2 + cnt].iov_len = 0;
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP2));
   iov[2 + cnt].iov_base = NULL;
   iov[2 + cnt].iov_len = 0;
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP3));
   iov[2 + cnt].iov_base = NULL;
   iov[2 + cnt].iov_len = 0;
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   /* Since we are using the sign of an integer to mark indirection the
@@ -2368,7 +2368,7 @@
   iov[2 + cnt].iov_len = tablewc.result_size;
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
   assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_WEIGHTWC));
@@ -2376,7 +2376,7 @@
   iov[2 + cnt].iov_base = obstack_finish (&weightpool);
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
   assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_EXTRAWC));
@@ -2384,7 +2384,7 @@
   iov[2 + cnt].iov_base = obstack_finish (&extrapool);
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
   assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_INDIRECTWC));
@@ -2392,7 +2392,7 @@
   iov[2 + cnt].iov_base = obstack_finish (&indirectpool);
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
   assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
 
@@ -2493,14 +2493,14 @@
   iov[2 + cnt].iov_base = &elem_size;
   iov[2 + cnt].iov_len = sizeof (int32_t);
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_TABLEMB));
   iov[2 + cnt].iov_base = elem_table;
   iov[2 + cnt].iov_len = elem_size * 2 * sizeof (int32_t);
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_EXTRAMB));
@@ -2518,7 +2518,7 @@
   assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQWC));
   iov[2 + cnt].iov_base = collate->wcseqorder.result;
   iov[2 + cnt].iov_len = collate->wcseqorder.result_size;
-  assert (idx[cnt] % 4 == 0);
+  assert (idx[cnt] % __alignof__ (int32_t) == 0);
   ++cnt;
 
   assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
Index: string/strcoll.c
===================================================================
RCS file: /cvs/glibc/libc/string/strcoll.c,v
retrieving revision 1.23
diff -u -a -u -r1.23 string/strcoll.c
--- string/strcoll.c	2000/09/01 19:24:53	1.23
+++ string/strcoll.c	2000/09/26 13:15:46
@@ -127,10 +127,10 @@
 #endif
   use_malloc = 0;
 
-  assert (((uintptr_t) table) % sizeof (table[0]) == 0);
-  assert (((uintptr_t) weights) % sizeof (weights[0]) == 0);
-  assert (((uintptr_t) extra) % sizeof (extra[0]) == 0);
-  assert (((uintptr_t) indirect) % sizeof (indirect[0]) == 0);
+  assert (((uintptr_t) table) % __alignof__ (table[0]) == 0);
+  assert (((uintptr_t) weights) % __alignof__ (weights[0]) == 0);
+  assert (((uintptr_t) extra) % __alignof__ (extra[0]) == 0);
+  assert (((uintptr_t) indirect) % __alignof__ (indirect[0]) == 0);
 
   /* We need this a few times.  */
   s1len = STRLEN (s1);

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]