aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier2006-03-09 23:06:58 +0000
committerStefan Monnier2006-03-09 23:06:58 +0000
commit349a450079672dcf0cb5bffb40feb388fa6879c9 (patch)
tree3a27191803a7ae6783e1f72796c9a035dc866e10 /src/alloc.c
parent3f9c65caa44929c85caa57e1470667f1730a0f45 (diff)
downloademacs-349a450079672dcf0cb5bffb40feb388fa6879c9.tar.gz
emacs-349a450079672dcf0cb5bffb40feb388fa6879c9.zip
(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)
883/* The entry point is lisp_align_malloc which returns blocks of at most */ 883/* The entry point is lisp_align_malloc which returns blocks of at most */
884/* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ 884/* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */
885 885
886/* Use posix_memalloc if the system has it and we're using the system's
887 malloc (because our gmalloc.c routines don't have posix_memalign although
888 its memalloc could be used). */
889#define USE_POSIX_MEMALIGN (HAVE_POSIX_MEMALIGN && SYSTEM_MALLOC)
886 890
887/* BLOCK_ALIGN has to be a power of 2. */ 891/* BLOCK_ALIGN has to be a power of 2. */
888#define BLOCK_ALIGN (1 << 10) 892#define BLOCK_ALIGN (1 << 10)
@@ -948,7 +952,7 @@ struct ablocks
948#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) 952#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase)
949 953
950/* Pointer to the (not necessarily aligned) malloc block. */ 954/* Pointer to the (not necessarily aligned) malloc block. */
951#ifdef HAVE_POSIX_MEMALIGN 955#ifdef USE_POSIX_MEMALIGN
952#define ABLOCKS_BASE(abase) (abase) 956#define ABLOCKS_BASE(abase) (abase)
953#else 957#else
954#define ABLOCKS_BASE(abase) \ 958#define ABLOCKS_BASE(abase) \
@@ -989,7 +993,7 @@ lisp_align_malloc (nbytes, type)
989 mallopt (M_MMAP_MAX, 0); 993 mallopt (M_MMAP_MAX, 0);
990#endif 994#endif
991 995
992#ifdef HAVE_POSIX_MEMALIGN 996#ifdef USE_POSIX_MEMALIGN
993 { 997 {
994 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); 998 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
995 if (err) 999 if (err)
@@ -1105,7 +1109,7 @@ lisp_align_free (block)
1105 } 1109 }
1106 eassert ((aligned & 1) == aligned); 1110 eassert ((aligned & 1) == aligned);
1107 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); 1111 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
1108#ifdef HAVE_POSIX_MEMALIGN 1112#ifdef USE_POSIX_MEMALIGN
1109 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); 1113 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
1110#endif 1114#endif
1111 free (ABLOCKS_BASE (abase)); 1115 free (ABLOCKS_BASE (abase));