From: Ilya Zakharevich Date: Wed, 17 Jun 1998 04:44:26 +0000 (-0400) Subject: fix alignment issues in malloc.c on 64-bit platforms (via private mail) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=274c75005985b277dc1c9506e79e73f65d8cd586;p=p5sagit%2Fp5-mst-13.2.git 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 --- 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 */