aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 74c3c66173a..259143ffad8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -885,6 +885,12 @@ lisp_free (block)
885/* The entry point is lisp_align_malloc which returns blocks of at most */ 885/* The entry point is lisp_align_malloc which returns blocks of at most */
886/* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ 886/* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */
887 887
888/* Use posix_memalloc if the system has it and we're using the system's
889 malloc (because our gmalloc.c routines don't have posix_memalign although
890 its memalloc could be used). */
891#if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC)
892#define USE_POSIX_MEMALIGN 1
893#endif
888 894
889/* BLOCK_ALIGN has to be a power of 2. */ 895/* BLOCK_ALIGN has to be a power of 2. */
890#define BLOCK_ALIGN (1 << 10) 896#define BLOCK_ALIGN (1 << 10)
@@ -950,7 +956,7 @@ struct ablocks
950#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) 956#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase)
951 957
952/* Pointer to the (not necessarily aligned) malloc block. */ 958/* Pointer to the (not necessarily aligned) malloc block. */
953#ifdef HAVE_POSIX_MEMALIGN 959#ifdef USE_POSIX_MEMALIGN
954#define ABLOCKS_BASE(abase) (abase) 960#define ABLOCKS_BASE(abase) (abase)
955#else 961#else
956#define ABLOCKS_BASE(abase) \ 962#define ABLOCKS_BASE(abase) \
@@ -991,7 +997,7 @@ lisp_align_malloc (nbytes, type)
991 mallopt (M_MMAP_MAX, 0); 997 mallopt (M_MMAP_MAX, 0);
992#endif 998#endif
993 999
994#ifdef HAVE_POSIX_MEMALIGN 1000#ifdef USE_POSIX_MEMALIGN
995 { 1001 {
996 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); 1002 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
997 if (err) 1003 if (err)
@@ -1107,7 +1113,7 @@ lisp_align_free (block)
1107 } 1113 }
1108 eassert ((aligned & 1) == aligned); 1114 eassert ((aligned & 1) == aligned);
1109 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); 1115 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
1110#ifdef HAVE_POSIX_MEMALIGN 1116#ifdef USE_POSIX_MEMALIGN
1111 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); 1117 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
1112#endif 1118#endif
1113 free (ABLOCKS_BASE (abase)); 1119 free (ABLOCKS_BASE (abase));