From cecac854b86d9b2221057faae39b20de79306756 Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 26 Jul 2002 09:35:46 +0000 Subject: [PATCH] [project @ 2002-07-26 09:35:46 by simonmar] Always return 8-byte-aligned memory from arenaAlloc(). Fixes problems with profiling on sparc-sun-solaris2, and might fix problems with Windows too. MERGE --- ghc/rts/Arena.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ghc/rts/Arena.c b/ghc/rts/Arena.c index ba6774b..87145ae 100644 --- a/ghc/rts/Arena.c +++ b/ghc/rts/Arena.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - $Id: Arena.c,v 1.2 2002/07/17 09:21:49 simonmar Exp $ + $Id: Arena.c,v 1.3 2002/07/26 09:35:46 simonmar Exp $ (c) The University of Glasgow 2001 Arena allocation. Arenas provide fast memory allocation at the @@ -24,8 +24,6 @@ #include "BlockAlloc.h" #include "Arena.h" -#include - // Each arena struct is allocated using malloc(). struct _Arena { bdescr *current; @@ -62,8 +60,12 @@ arenaAlloc( Arena *arena, size_t size ) nat req_blocks; bdescr *bd; - // round up to word size... - size_w = (size + sizeof(W_) - 1) / sizeof(W_); +// The minimum alignment of an allocated block. +#define MIN_ALIGN 8 + + // size of allocated block in words, rounded up to the nearest + // alignment chunk. + size_w = ((size + MIN_ALIGN - 1) / MIN_ALIGN) * (MIN_ALIGN/sizeof(W_)); if ( arena->free + size_w < arena->lim ) { // enough room in the current block... -- 1.7.10.4