summaryrefslogtreecommitdiff
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-01-30 14:20:57 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-01-30 15:26:07 -0800
commite1a9f2099c2e683dffc4b898ce85ce935c4cb254 (patch)
tree14f8b080fb8515b81111dc269e37aa01f73b16fc /src/gmalloc.c
parent874c59a81b7ee12a739149c5229e6d3bbd463324 (diff)
downloademacs-e1a9f2099c2e683dffc4b898ce85ce935c4cb254.tar.gz
Pacify --enable-gcc-warnings when HYBRID_MALLOC
* src/buffer.c (init_buffer): * src/emacs.c (main): * src/xsmfns.c (smc_save_yourself_CB, x_session_initialize): Use emacs_get_current_dir_name, not get_current_dir_name. * src/conf_post.h (aligned_alloc) [HYBRID_MALLOC && emacs]: New macro. (HYBRID_GET_CURRENT_DIR_NAME, get_current_dir_name): Remove. * src/emacs.c: Include "sheap.h". (report_sheap_usage): Remove decl. (Fdump_emacs) [HYBRID_MALLOC]: Report usage directly. Don't assume ptrdiff_t can be printed as int. * src/gmalloc.c [HYBRID_MALLOC]: Include "sheap.h" rather than declaring its contents by hand. (get_current_dir_name, gget_current_dir_name) (hybrid_get_current_dir_name): Remove. (emacs_abort): Remove duplicate decl. (aligned_alloc): Undef, like malloc etc. (ALLOCATED_BEFORE_DUMPING): Now a static function, not a macro. Make it a bit more efficient. (malloc_find_object_address): Remove unused decl. (enum mcheck_status, mcheck, mprobe, mtrace, muntrace, struct mstats) (mstats, memory_warnings): Declare only if GC_MCHECK. * src/lisp.h (emacs_get_current_dir_name): New decl, replacing get_current_dir_name. * src/sheap.c: Include sheap.h first. (STATIC_HEAP_SIZE): Remove; now in sheap.h. (debug_sheap): Now static. (bss_sbrk_buffer_end): Remove; no longer used. (bss_sbrk_ptr): Now static and private. (bss_sbrk_did_unexec): Now bool. (BLOCKSIZE): Remove, to avoid GCC warning about its not being used. (bss_sbrk): Don't treat request_size 0 as special, since the code works without this being a special case. Avoid overflow if request size exceeds INT_MAX. (report_sheap_usage): Remove; now done in emacs.c. * src/sheap.h: New file. * src/sysdep.c (get_current_dir_name): Remove macro. Include "sheap.h". (emacs_get_current_dir_name): Rename function from get_current_dir_name. Handle HYBRID_MALLOC here; this is simpler. (Bug#22086)
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 30e01319e0e..4fd324686ba 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -28,11 +28,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#include <limits.h>
#include <stdint.h>
-
-#ifdef HYBRID_GET_CURRENT_DIR_NAME
-#undef get_current_dir_name
-#endif
-
#include <unistd.h>
#ifdef USE_PTHREAD
@@ -43,10 +38,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <w32heap.h> /* for sbrk */
#endif
-#ifdef emacs
-extern void emacs_abort (void);
-#endif
-
/* If HYBRID_MALLOC is defined, then temacs will use malloc,
realloc... as defined in this file (and renamed gmalloc,
grealloc... via the macros that follow). The dumped emacs,
@@ -63,6 +54,7 @@ extern void emacs_abort (void);
#undef malloc
#undef realloc
#undef calloc
+#undef aligned_alloc
#undef free
#define malloc gmalloc
#define realloc grealloc
@@ -71,13 +63,13 @@ extern void emacs_abort (void);
#define free gfree
#ifdef HYBRID_MALLOC
-extern void *bss_sbrk (ptrdiff_t size);
-extern int bss_sbrk_did_unexec;
-extern char bss_sbrk_buffer[];
-extern void *bss_sbrk_buffer_end;
-#define DUMPED bss_sbrk_did_unexec
-#define ALLOCATED_BEFORE_DUMPING(P) \
- ((P) < bss_sbrk_buffer_end && (P) >= (void *) bss_sbrk_buffer)
+# include "sheap.h"
+# define DUMPED bss_sbrk_did_unexec
+static bool
+ALLOCATED_BEFORE_DUMPING (char *p)
+{
+ return bss_sbrk_buffer <= p && p < bss_sbrk_buffer + STATIC_HEAP_SIZE;
+}
#endif
#ifdef __cplusplus
@@ -87,10 +79,6 @@ extern "C"
#include <stddef.h>
-#ifdef emacs
-extern void emacs_abort (void);
-#endif
-
/* Underlying allocation function; successive calls should
return contiguous pieces of memory. */
extern void *(*__morecore) (ptrdiff_t size);
@@ -255,10 +243,6 @@ extern int _malloc_thread_enabled_p;
#define UNLOCK_ALIGNED_BLOCKS()
#endif
-/* Given an address in the middle of a malloc'd object,
- return the address of the beginning of the object. */
-extern void *malloc_find_object_address (void *ptr);
-
/* If not NULL, this function is called after each time
`__morecore' is called to increase the data size. */
extern void (*__after_morecore_hook) (void);
@@ -279,6 +263,8 @@ extern void *(*__malloc_hook) (size_t size);
extern void *(*__realloc_hook) (void *ptr, size_t size);
extern void *(*__memalign_hook) (size_t size, size_t alignment);
+#ifdef GC_MCHECK
+
/* Return values for `mprobe': these are the kinds of inconsistencies that
`mcheck' enables detection of. */
enum mcheck_status
@@ -321,6 +307,8 @@ extern struct mstats mstats (void);
/* Call WARNFUN with a warning message when memory usage is high. */
extern void memory_warnings (void *start, void (*warnfun) (const char *));
+#endif
+
#undef extern
#ifdef __cplusplus
@@ -1797,7 +1785,7 @@ hybrid_aligned_alloc (size_t alignment, size_t size)
#endif
}
#endif
-
+
void *
hybrid_realloc (void *ptr, size_t size)
{
@@ -1825,19 +1813,6 @@ hybrid_realloc (void *ptr, size_t size)
return result;
}
-#ifdef HYBRID_GET_CURRENT_DIR_NAME
-/* Defined in sysdep.c. */
-char *gget_current_dir_name (void);
-
-char *
-hybrid_get_current_dir_name (void)
-{
- if (DUMPED)
- return get_current_dir_name ();
- return gget_current_dir_name ();
-}
-#endif
-
#else /* ! HYBRID_MALLOC */
void *