diff options
| author | Ken Brown | 2014-08-28 10:48:02 -0400 |
|---|---|---|
| committer | Ken Brown | 2014-08-28 10:48:02 -0400 |
| commit | ea652500776aacbb8cb64f9ecca16a2d2c7add80 (patch) | |
| tree | c759fc62dfa422e8fb636aef6dbb04df2c68cc7e /src/ralloc.c | |
| parent | a7ef7a0e53ae1f391f4bda207bb5e9b9d833d354 (diff) | |
| download | emacs-ea652500776aacbb8cb64f9ecca16a2d2c7add80.tar.gz emacs-ea652500776aacbb8cb64f9ecca16a2d2c7add80.zip | |
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/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index c82cd4548d2..e63ed34c89b 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -35,9 +35,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 35 | #define M_TOP_PAD -2 | 35 | #define M_TOP_PAD -2 |
| 36 | extern int mallopt (int, int); | 36 | extern int mallopt (int, int); |
| 37 | #else /* not DOUG_LEA_MALLOC */ | 37 | #else /* not DOUG_LEA_MALLOC */ |
| 38 | #ifndef SYSTEM_MALLOC | 38 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 39 | extern size_t __malloc_extra_blocks; | 39 | extern size_t __malloc_extra_blocks; |
| 40 | #endif /* SYSTEM_MALLOC */ | 40 | #endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ |
| 41 | #endif /* not DOUG_LEA_MALLOC */ | 41 | #endif /* not DOUG_LEA_MALLOC */ |
| 42 | 42 | ||
| 43 | #else /* not emacs */ | 43 | #else /* not emacs */ |
| @@ -95,7 +95,7 @@ static int extra_bytes; | |||
| 95 | /* The hook `malloc' uses for the function which gets more space | 95 | /* The hook `malloc' uses for the function which gets more space |
| 96 | from the system. */ | 96 | from the system. */ |
| 97 | 97 | ||
| 98 | #ifndef SYSTEM_MALLOC | 98 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 99 | extern void *(*__morecore) (ptrdiff_t); | 99 | extern void *(*__morecore) (ptrdiff_t); |
| 100 | #endif | 100 | #endif |
| 101 | 101 | ||
| @@ -1179,7 +1179,7 @@ r_alloc_init (void) | |||
| 1179 | r_alloc_initialized = 1; | 1179 | r_alloc_initialized = 1; |
| 1180 | 1180 | ||
| 1181 | page_size = PAGE; | 1181 | page_size = PAGE; |
| 1182 | #ifndef SYSTEM_MALLOC | 1182 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 1183 | real_morecore = __morecore; | 1183 | real_morecore = __morecore; |
| 1184 | __morecore = r_alloc_sbrk; | 1184 | __morecore = r_alloc_sbrk; |
| 1185 | 1185 | ||
| @@ -1198,7 +1198,7 @@ r_alloc_init (void) | |||
| 1198 | mallopt (M_TOP_PAD, 64 * 4096); | 1198 | mallopt (M_TOP_PAD, 64 * 4096); |
| 1199 | unblock_input (); | 1199 | unblock_input (); |
| 1200 | #else | 1200 | #else |
| 1201 | #ifndef SYSTEM_MALLOC | 1201 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 1202 | /* Give GNU malloc's morecore some hysteresis so that we move all | 1202 | /* Give GNU malloc's morecore some hysteresis so that we move all |
| 1203 | the relocatable blocks much less often. The number used to be | 1203 | the relocatable blocks much less often. The number used to be |
| 1204 | 64, but alloc.c would override that with 32 in code that was | 1204 | 64, but alloc.c would override that with 32 in code that was |
| @@ -1211,7 +1211,7 @@ r_alloc_init (void) | |||
| 1211 | #endif | 1211 | #endif |
| 1212 | #endif | 1212 | #endif |
| 1213 | 1213 | ||
| 1214 | #ifndef SYSTEM_MALLOC | 1214 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 1215 | first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start); | 1215 | first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start); |
| 1216 | 1216 | ||
| 1217 | /* The extra call to real_morecore guarantees that the end of the | 1217 | /* The extra call to real_morecore guarantees that the end of the |