summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2006-03-09 23:06:58 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2006-03-09 23:06:58 +0000
commitcf2324583a46481354d86c5609dc4fe1ff322a22 (patch)
tree46c32fcdd8f8ef794c4de3ddce725f537013f4f1 /src/alloc.c
parent7e5d2348507bc616a2408f83ff8714178ddd9de3 (diff)
downloademacs-cf2324583a46481354d86c5609dc4fe1ff322a22.tar.gz
(USE_POSIX_MEMALIGN): New macro.
(ABLOCKS_BASE, lisp_align_malloc, lisp_align_free): Use it.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index bb5f550d175..ee84bd2fb29 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -883,6 +883,10 @@ lisp_free (block)
/* The entry point is lisp_align_malloc which returns blocks of at most */
/* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */
+/* Use posix_memalloc if the system has it and we're using the system's
+ malloc (because our gmalloc.c routines don't have posix_memalign although
+ its memalloc could be used). */
+#define USE_POSIX_MEMALIGN (HAVE_POSIX_MEMALIGN && SYSTEM_MALLOC)
/* BLOCK_ALIGN has to be a power of 2. */
#define BLOCK_ALIGN (1 << 10)
@@ -948,7 +952,7 @@ struct ablocks
#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase)
/* Pointer to the (not necessarily aligned) malloc block. */
-#ifdef HAVE_POSIX_MEMALIGN
+#ifdef USE_POSIX_MEMALIGN
#define ABLOCKS_BASE(abase) (abase)
#else
#define ABLOCKS_BASE(abase) \
@@ -989,7 +993,7 @@ lisp_align_malloc (nbytes, type)
mallopt (M_MMAP_MAX, 0);
#endif
-#ifdef HAVE_POSIX_MEMALIGN
+#ifdef USE_POSIX_MEMALIGN
{
int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
if (err)
@@ -1105,7 +1109,7 @@ lisp_align_free (block)
}
eassert ((aligned & 1) == aligned);
eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
-#ifdef HAVE_POSIX_MEMALIGN
+#ifdef USE_POSIX_MEMALIGN
eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
#endif
free (ABLOCKS_BASE (abase));