From 7d013a64de1cada889f3db5da793a7b965e87ac1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 6 Mar 2006 06:18:43 +0000 Subject: * malloc/malloc.c (MALLOC_ALIGNMENT): Revert to (2 * SIZE_SZ) value. The correct value differs only on powerpc32, and for now changing it there is causing more trouble than it's worth. * malloc/arena.c: Add compile-time sanity check on padding calculation. 2006-03-05 Jakub Jelinek * malloc/arena.c (heap_info): Adjust the padding size if MALLOC_ALIGNMENT > 2 * SIZE_SZ. --- malloc/arena.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'malloc/arena.c') diff --git a/malloc/arena.c b/malloc/arena.c index d0d223e..4d95462 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger , 2001. @@ -55,9 +55,18 @@ typedef struct _heap_info { mstate ar_ptr; /* Arena for this heap. */ struct _heap_info *prev; /* Previous heap. */ size_t size; /* Current size in bytes. */ - size_t pad; /* Make sure the following data is properly aligned. */ + /* Make sure the following data is properly aligned, particularly + that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of + MALLOG_ALIGNMENT. */ + char pad[-5 * SIZE_SZ & MALLOC_ALIGN_MASK]; } heap_info; +/* Get a compile-time error if the heap_info padding is not correct + to make alignment work as expected in sYSMALLOc. */ +extern int sanity_check_heap_info_alignment[(sizeof (heap_info) + + 2 * SIZE_SZ) % MALLOC_ALIGNMENT + ? -1 : 1]; + /* Thread specific data */ static tsd_key_t arena_key; -- cgit v1.1