[PATCH] use 8 byte alignment in _dl_malloc
Atsushi Nemoto
anemo at mba.ocn.ne.jp
Sat Feb 17 06:22:24 PST 2007
On Fri, 16 Feb 2007 09:44:57 -0800 (PST), Pandit Panburana <ppanbura at yahoo.com> wrote:
> I agree 8 byte alignment is surely a safe bet but I am more
> concern on platforms or environment that is sensitive to overhead
> when they can do with less.
OK, then how about this?
-------------- next part --------------
diff -urp uClibc-20070214/ldso/ldso/ldso.c uClibc/ldso/ldso/ldso.c
--- uClibc-20070214/ldso/ldso/ldso.c 2007-02-14 17:10:10.000000000 +0900
+++ uClibc/ldso/ldso/ldso.c 2007-02-17 23:17:22.292959096 +0900
@@ -929,6 +929,7 @@ static int _dl_suid_ok(void)
void *_dl_malloc(int size)
{
void *retval;
+ int align;
#if 0
_dl_debug_early("request for %d bytes\n", size);
@@ -950,10 +951,15 @@ void *_dl_malloc(int size)
_dl_malloc_addr += size;
/*
- * Align memory to 4 byte boundary. Some platforms require this,
+ * Align memory to 4 or 8 byte boundary. Some platforms require this,
* others simply get better performance.
*/
- _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
+#if __WORDSIZE > 32 || defined(__mips64)
+ align = 8;
+#else
+ align = 4;
+#endif
+ _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + align - 1) & ~(align - 1));
return retval;
}
More information about the uClibc
mailing list