diff options
author | Ken Brown <kbrown@cornell.edu> | 2014-08-28 10:48:02 -0400 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2014-08-28 10:48:02 -0400 |
commit | ea652500776aacbb8cb64f9ecca16a2d2c7add80 (patch) | |
tree | c759fc62dfa422e8fb636aef6dbb04df2c68cc7e /src/alloc.c | |
parent | a7ef7a0e53ae1f391f4bda207bb5e9b9d833d354 (diff) | |
download | emacs-ea652500776aacbb8cb64f9ecca16a2d2c7add80.tar.gz |
Add support for HYBRID_MALLOC, allowing the use of gmalloc before
dumping and the system malloc after dumping. (Bug#18222)
* configure.ac (HYBRID_MALLOC): New macro; define to use gmalloc
before dumping and the system malloc after dumping. Define on Cygwin.
* src/conf_post.h (malloc, realloc, calloc, free) [HYBRID_MALLOC]:
Define as macros, expanding to hybrid_malloc, etc.
(HYBRID_GET_CURRENT_DIR_NAME): New macro.
(get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: Define as
macro.
* src/gmalloc.c: Set up the infrastructure for HYBRID_MALLOC, with a
full implementation on Cygwin. Remove Cygwin-specific code that
is no longer needed.
(malloc, realloc, calloc, free, aligned_alloc) [HYBRID_MALLOC]:
Redefine as macros expanding to gmalloc, grealloc, etc.
(DUMPED, ALLOCATED_BEFORE_DUMPING) [CYGWIN]: New macros.
(get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: Undefine.
(USE_PTHREAD, posix_memalign) [HYBRID_MALLOC]: Don't define.
(hybrid_malloc, hybrid_calloc, hybrid_free, hybrid_realloc)
[HYBRID_MALLOC]:
(hybrid_get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]:
(hybrid_aligned_alloc) [HYBRID_MALLOC && (HAVE_ALIGNED_ALLOC ||
HAVE_POSIX_MEMALIGN)]: New functions.
* src/alloc.c (aligned_alloc) [HYBRID_MALLOC && (ALIGNED_ALLOC ||
HAVE_POSIX_MEMALIGN)]: Define as macro expanding to
hybrid_aligned_alloc; declare.
(USE_ALIGNED_ALLOC) [HYBRID_MALLOC && (ALIGNED_ALLOC ||
HAVE_POSIX_MEMALIGN)]: Define.
(refill_memory_reserve) [HYBRID_MALLOC]: Do nothing.
* src/sysdep.c (get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]:
Define as macro, expanding to gget_current_dir_name, and define
the latter.
* src/emacs.c (main) [HYBRID_MALLOC]: Don't call memory_warnings() or
malloc_enable_thread(). Don't initialize malloc.
* src/lisp.h (NONPOINTER_BITS) [CYGWIN]: Define (because GNU_MALLOC is
no longer defined on Cygwin).
(refill_memory_reserve) [HYBRID_MALLOC]: Don't declare.
* src/sheap.c (bss_sbrk_buffer_end): New variable.
* src/unexcw.c (__malloc_initialized): Remove variable.
* src/ralloc.c: Throughout, treat HYBRID_MALLOC the same as
SYSTEM_MALLOC.
* src/xdisp.c (decode_mode_spec) [HYBRID_MALLOC]: Don't check
Vmemory_full.
Diffstat (limited to 'src/alloc.c')
-rw-r--r-- | src/alloc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c index ac154b587e6..9c81ae2eedf 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -80,7 +80,7 @@ static bool valgrind_p; marked objects. */ #if (defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC \ - || defined GC_CHECK_MARKED_OBJECTS) + || defined HYBRID_MALLOC || defined GC_CHECK_MARKED_OBJECTS) #undef GC_MALLOC_CHECK #endif @@ -285,7 +285,7 @@ static void gc_sweep (void); static Lisp_Object make_pure_vector (ptrdiff_t); static void mark_buffer (struct buffer *); -#if !defined REL_ALLOC || defined SYSTEM_MALLOC +#if !defined REL_ALLOC || defined SYSTEM_MALLOC || defined HYBRID_MALLOC static void refill_memory_reserve (void); #endif static void compact_small_strings (void); @@ -1014,10 +1014,17 @@ lisp_free (void *block) clang 3.3 anyway. */ #if ! ADDRESS_SANITIZER -# if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC +# if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC # define USE_ALIGNED_ALLOC 1 /* Defined in gmalloc.c. */ void *aligned_alloc (size_t, size_t); +# elif defined HYBRID_MALLOC +# if defined ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN +# define USE_ALIGNED_ALLOC 1 +# define aligned_alloc hybrid_aligned_alloc +/* Defined in gmalloc.c. */ +void *aligned_alloc (size_t, size_t); +# endif # elif defined HAVE_ALIGNED_ALLOC # define USE_ALIGNED_ALLOC 1 # elif defined HAVE_POSIX_MEMALIGN @@ -3829,7 +3836,7 @@ memory_full (size_t nbytes) void refill_memory_reserve (void) { -#ifndef SYSTEM_MALLOC +#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC if (spare_memory[0] == 0) spare_memory[0] = malloc (SPARE_MEMORY); if (spare_memory[1] == 0) |