On 04/06/2011 07:40 PM, Bernd Schmidt wrote:
> In commit 3e0a1f388, Richard tried to fix malloc alignments by using
>  alignof (double __attribute_aligned__(sizeof (size_t))).
> This doesn't work, since attribute_aligned overrides the alignment
> rather than providing a minimum. On C6X, malloc returns four-byte
> aligned values rather than the necessary eight-byte alignment.
> 
> It's simpler to use a comparison and pick the bigger of the two values,
> so that's what I've done. Ok?

Again with the right address for Richard.


Bernd
Index: libc/stdlib/malloc/heap.h
===================================================================
--- libc/stdlib/malloc/heap.h   (revision 301801)
+++ libc/stdlib/malloc/heap.h   (working copy)
@@ -30,8 +30,10 @@
 /* The heap allocates in multiples of, and aligned to, HEAP_GRANULARITY.
    HEAP_GRANULARITY must be a power of 2.  Malloc depends on this being the
    same as MALLOC_ALIGNMENT.  */
-#define HEAP_GRANULARITY_TYPE  double __attribute_aligned__ (sizeof (size_t))
-#define HEAP_GRANULARITY       (__alignof__ (HEAP_GRANULARITY_TYPE))
+#define HEAP_GRANULARITY_TYPE  double __attribute_aligned__ (HEAP_GRANULARITY)
+#define HEAP_GRANULARITY \
+  (__alignof__ (double) > sizeof (size_t) ? __alignof__ (double) : sizeof 
(size_t))
+
 
 
 /* The HEAP_INIT macro can be used as a static initializer for a heap
Index: libc/stdlib/malloc/malloc.h
===================================================================
--- libc/stdlib/malloc/malloc.h (revision 301801)
+++ libc/stdlib/malloc/malloc.h (working copy)
@@ -17,7 +17,7 @@
    alignment can be a significant win on targets like m68k and Coldfire,
    where __alignof__(double) == 2.  */
 #define MALLOC_ALIGNMENT \
-  __alignof__ (double __attribute_aligned__ (sizeof (size_t)))
+  (__alignof__ (double) > sizeof (size_t) ? __alignof__ (double) : sizeof 
(size_t))
 
 /* The system pagesize... */
 extern size_t __pagesize;
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to