From 274c75005985b277dc1c9506e79e73f65d8cd586 Mon Sep 17 00:00:00 2001 From: Ilya Zakharevich Date: Wed, 17 Jun 1998 00:44:26 -0400 Subject: [PATCH] fix alignment issues in malloc.c on 64-bit platforms (via private mail) Message-Id: <199806170844.EAA24584@monk.mps.ohio-state.edu> Subject: Re: _67 not okay p4raw-id: //depot/perl@1184 --- malloc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/malloc.c b/malloc.c index ad6ef07..6abd450 100644 --- a/malloc.c +++ b/malloc.c @@ -307,6 +307,19 @@ static int findbucket _((union overhead *freep, int srchlen)); # define BUCKETS_PER_POW2 1 #endif +#if !defined(MEM_ALIGNBYTES) || ((MEM_ALIGNBYTES > 4) && !defined(STRICT_ALIGNMENT)) +/* Figure out the alignment of void*. */ +struct aligner { + char c; + void *p; +}; +# define ALIGN_SMALL ((int)((caddr_t)&(((struct aligner*)0)->p))) +#else +# define ALIGN_SMALL MEM_ALIGNBYTES +#endif + +#define IF_ALIGN_8(yes,no) ((ALIGN_SMALL>4) ? (yes) : (no)) + #ifdef BUCKETS_ROOT2 # define MAX_BUCKET_BY_TABLE 13 static u_short buck_size[MAX_BUCKET_BY_TABLE + 1] = @@ -451,7 +464,7 @@ static char bucket_of[] = /* 0 to 15 in 4-byte increments. */ (sizeof(void*) > 4 ? 6 : 5), /* 4/8, 5-th bucket for better reports */ 6, /* 8 */ - 7, 8, /* 12, 16 */ + IF_ALIGN_8(8,7), 8, /* 16/12, 16 */ 9, 9, 10, 10, /* 24, 32 */ 11, 11, 11, 11, /* 48 */ 12, 12, 12, 12, /* 64 */ -- 2.7.4