summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1998-06-17 00:44:26 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-22 00:57:27 +0000
commit274c75005985b277dc1c9506e79e73f65d8cd586 (patch)
treeae06f4d0177ef352d7ec1c4dfd657d383436009a /malloc.c
parent971976310b251a01daaf56e60430ae8263953b2d (diff)
downloadperl-274c75005985b277dc1c9506e79e73f65d8cd586.tar.gz
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
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/malloc.c b/malloc.c
index ad6ef07f7f..6abd4502c3 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 */