diff options
| author | Paul Eggert | 2016-01-30 14:20:57 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-30 15:26:08 -0800 |
| commit | a4817d834e7d125d31049dfb6fd0a0df4782bad0 (patch) | |
| tree | b2e63ff90a6307c20982e55fd779f670c28f6244 /src/alloc.c | |
| parent | e4cd4a76a621927bc155a18353ef7fd09133887d (diff) | |
| download | emacs-a4817d834e7d125d31049dfb6fd0a0df4782bad0.tar.gz emacs-a4817d834e7d125d31049dfb6fd0a0df4782bad0.zip | |
Include <malloc.h> when advisable
This should help insulate us better from future glibc changes.
It is good hygiene to include .h files for APIs that Emacs uses.
Fix type clashes between Emacs and GNU <malloc.h> (Bug#22086).
* configure.ac: Check for malloc.h.
* src/alloc.c: Include <malloc.h> depending on HAVE_MALLOC_H,
not on DOUG_LEA_MALLOC.
* src/emacs.c, src/gmalloc.c (malloc_enable_thread):
Remove decl (now in lisp.h).
* src/gmalloc.c: Include stddef.h earlier, for ptrdiff_t.
[emacs]: Include lisp.h.
[HAVE_MALLOC_H]: Include <malloc.h>.
(__MALLOC_HOOK_VOLATILE): New macro, if not already defined.
(__after_morecore_hook, __malloc_initialize_hook, __morecore)
(__default_morecore):
[!HAVE_MALLOC_H]: New decls near non-inclusion of <malloc.h>.
(calloc): Make it clear that the macro should not be used.
Remove unused decl.
(malloc_info): New macro, to avoid clash with glibc <malloc.h>.
(__morecore, __default_morecore, __after_morecore_hook)
(__malloc_extra_blocks, __malloc_initialize_hook, __free_hook)
(__malloc_hook, __realloc_hook, __memalign_hook, memory_warnings):
Remove later decls.
(gmalloc_hook, gfree_hook, grealloc_hook):
Rename from __malloc_hook, __free_hook, __realloc_hook to
avoid type collision with glibc <malloc.h>. All uses changed.
(gmalloc_hook):
(__malloc_extra_blocks) [DOUG_LEA_MALLOC||HYBRID_MALLOC||SYSTEM_MALLOC]:
Now static.
(gmalloc_hook, __malloc_extra_blocks): Define even if [!HYBRID_MALLOC].
(__malloc_initialize_hook, __after_morecore_hook):
Declare with types compatible with glibc.
(__memalign_hook, hybrid_calloc) [HYBRID_MALLOC]:
Remove. All uses removed.
* src/lisp.h (__malloc_extra_blocks, malloc_enable_thread): New decls.
* src/ralloc.c, src/vm-limit.c:
Simplify includes and include <malloc.h> if available.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c index 617148e85e5..039b7285e39 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -59,6 +59,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 59 | #include "dosfns.h" /* For dos_memory_info. */ | 59 | #include "dosfns.h" /* For dos_memory_info. */ |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | #ifdef HAVE_MALLOC_H | ||
| 63 | # include <malloc.h> | ||
| 64 | #endif | ||
| 65 | |||
| 62 | #if (defined ENABLE_CHECKING \ | 66 | #if (defined ENABLE_CHECKING \ |
| 63 | && defined HAVE_VALGRIND_VALGRIND_H \ | 67 | && defined HAVE_VALGRIND_VALGRIND_H \ |
| 64 | && !defined USE_VALGRIND) | 68 | && !defined USE_VALGRIND) |
| @@ -107,8 +111,6 @@ my_heap_start (void) | |||
| 107 | 111 | ||
| 108 | #ifdef DOUG_LEA_MALLOC | 112 | #ifdef DOUG_LEA_MALLOC |
| 109 | 113 | ||
| 110 | #include <malloc.h> | ||
| 111 | |||
| 112 | /* Specify maximum number of areas to mmap. It would be nice to use a | 114 | /* Specify maximum number of areas to mmap. It would be nice to use a |
| 113 | value that explicitly means "no limit". */ | 115 | value that explicitly means "no limit". */ |
| 114 | 116 | ||