[PATCH] use 8 byte alignment in _dl_malloc

Atsushi Nemoto anemo at mba.ocn.ne.jp
Fri Feb 16 00:16:40 PST 2007


I found many unaligned access when using shared uClibc on mips
n32/n64.  This patch fix this problem.  I just increment alignment
value to 8 while I suppose it is not worth to do #ifdef here.

--- uClibc-20070214/ldso/ldso/ldso.c	2007-02-14 17:10:10.000000000 +0900
+++ uClibc/ldso/ldso/ldso.c	2007-02-16 16:47:48.000000000 +0900
@@ -950,10 +950,10 @@ void *_dl_malloc(int size)
 	_dl_malloc_addr += size;
 
 	/*
-	 * Align memory to 4 byte boundary.  Some platforms require this,
+	 * Align memory to 8 byte boundary.  Some platforms require this,
 	 * others simply get better performance.
 	 */
-	_dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
+	_dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + 7) & ~(7));
 	return retval;
 }
 


More information about the uClibc mailing list