diff options
| author | Paul Eggert | 2016-01-30 14:20:57 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-30 15:26:07 -0800 |
| commit | e1a9f2099c2e683dffc4b898ce85ce935c4cb254 (patch) | |
| tree | 14f8b080fb8515b81111dc269e37aa01f73b16fc /src/gmalloc.c | |
| parent | 874c59a81b7ee12a739149c5229e6d3bbd463324 (diff) | |
| download | emacs-e1a9f2099c2e683dffc4b898ce85ce935c4cb254.tar.gz emacs-e1a9f2099c2e683dffc4b898ce85ce935c4cb254.zip | |
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.c | 51 |
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/>. | |||
| 28 | #include <string.h> | 28 | #include <string.h> |
| 29 | #include <limits.h> | 29 | #include <limits.h> |
| 30 | #include <stdint.h> | 30 | #include <stdint.h> |
| 31 | |||
| 32 | #ifdef HYBRID_GET_CURRENT_DIR_NAME | ||
| 33 | #undef get_current_dir_name | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #include <unistd.h> | 31 | #include <unistd.h> |
| 37 | 32 | ||
| 38 | #ifdef USE_PTHREAD | 33 | #ifdef USE_PTHREAD |
| @@ -43,10 +38,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | #include <w32heap.h> /* for sbrk */ | 38 | #include <w32heap.h> /* for sbrk */ |
| 44 | #endif | 39 | #endif |
| 45 | 40 | ||
| 46 | #ifdef emacs | ||
| 47 | extern void emacs_abort (void); | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /* If HYBRID_MALLOC is defined, then temacs will use malloc, | 41 | /* If HYBRID_MALLOC is defined, then temacs will use malloc, |
| 51 | realloc... as defined in this file (and renamed gmalloc, | 42 | realloc... as defined in this file (and renamed gmalloc, |
| 52 | grealloc... via the macros that follow). The dumped emacs, | 43 | grealloc... via the macros that follow). The dumped emacs, |
| @@ -63,6 +54,7 @@ extern void emacs_abort (void); | |||
| 63 | #undef malloc | 54 | #undef malloc |
| 64 | #undef realloc | 55 | #undef realloc |
| 65 | #undef calloc | 56 | #undef calloc |
| 57 | #undef aligned_alloc | ||
| 66 | #undef free | 58 | #undef free |
| 67 | #define malloc gmalloc | 59 | #define malloc gmalloc |
| 68 | #define realloc grealloc | 60 | #define realloc grealloc |
| @@ -71,13 +63,13 @@ extern void emacs_abort (void); | |||
| 71 | #define free gfree | 63 | #define free gfree |
| 72 | 64 | ||
| 73 | #ifdef HYBRID_MALLOC | 65 | #ifdef HYBRID_MALLOC |
| 74 | extern void *bss_sbrk (ptrdiff_t size); | 66 | # include "sheap.h" |
| 75 | extern int bss_sbrk_did_unexec; | 67 | # define DUMPED bss_sbrk_did_unexec |
| 76 | extern char bss_sbrk_buffer[]; | 68 | static bool |
| 77 | extern void *bss_sbrk_buffer_end; | 69 | ALLOCATED_BEFORE_DUMPING (char *p) |
| 78 | #define DUMPED bss_sbrk_did_unexec | 70 | { |
| 79 | #define ALLOCATED_BEFORE_DUMPING(P) \ | 71 | return bss_sbrk_buffer <= p && p < bss_sbrk_buffer + STATIC_HEAP_SIZE; |
| 80 | ((P) < bss_sbrk_buffer_end && (P) >= (void *) bss_sbrk_buffer) | 72 | } |
| 81 | #endif | 73 | #endif |
| 82 | 74 | ||
| 83 | #ifdef __cplusplus | 75 | #ifdef __cplusplus |
| @@ -87,10 +79,6 @@ extern "C" | |||
| 87 | 79 | ||
| 88 | #include <stddef.h> | 80 | #include <stddef.h> |
| 89 | 81 | ||
| 90 | #ifdef emacs | ||
| 91 | extern void emacs_abort (void); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | /* Underlying allocation function; successive calls should | 82 | /* Underlying allocation function; successive calls should |
| 95 | return contiguous pieces of memory. */ | 83 | return contiguous pieces of memory. */ |
| 96 | extern void *(*__morecore) (ptrdiff_t size); | 84 | extern void *(*__morecore) (ptrdiff_t size); |
| @@ -255,10 +243,6 @@ extern int _malloc_thread_enabled_p; | |||
| 255 | #define UNLOCK_ALIGNED_BLOCKS() | 243 | #define UNLOCK_ALIGNED_BLOCKS() |
| 256 | #endif | 244 | #endif |
| 257 | 245 | ||
| 258 | /* Given an address in the middle of a malloc'd object, | ||
| 259 | return the address of the beginning of the object. */ | ||
| 260 | extern void *malloc_find_object_address (void *ptr); | ||
| 261 | |||
| 262 | /* If not NULL, this function is called after each time | 246 | /* If not NULL, this function is called after each time |
| 263 | `__morecore' is called to increase the data size. */ | 247 | `__morecore' is called to increase the data size. */ |
| 264 | extern void (*__after_morecore_hook) (void); | 248 | extern void (*__after_morecore_hook) (void); |
| @@ -279,6 +263,8 @@ extern void *(*__malloc_hook) (size_t size); | |||
| 279 | extern void *(*__realloc_hook) (void *ptr, size_t size); | 263 | extern void *(*__realloc_hook) (void *ptr, size_t size); |
| 280 | extern void *(*__memalign_hook) (size_t size, size_t alignment); | 264 | extern void *(*__memalign_hook) (size_t size, size_t alignment); |
| 281 | 265 | ||
| 266 | #ifdef GC_MCHECK | ||
| 267 | |||
| 282 | /* Return values for `mprobe': these are the kinds of inconsistencies that | 268 | /* Return values for `mprobe': these are the kinds of inconsistencies that |
| 283 | `mcheck' enables detection of. */ | 269 | `mcheck' enables detection of. */ |
| 284 | enum mcheck_status | 270 | enum mcheck_status |
| @@ -321,6 +307,8 @@ extern struct mstats mstats (void); | |||
| 321 | /* Call WARNFUN with a warning message when memory usage is high. */ | 307 | /* Call WARNFUN with a warning message when memory usage is high. */ |
| 322 | extern void memory_warnings (void *start, void (*warnfun) (const char *)); | 308 | extern void memory_warnings (void *start, void (*warnfun) (const char *)); |
| 323 | 309 | ||
| 310 | #endif | ||
| 311 | |||
| 324 | #undef extern | 312 | #undef extern |
| 325 | 313 | ||
| 326 | #ifdef __cplusplus | 314 | #ifdef __cplusplus |
| @@ -1797,7 +1785,7 @@ hybrid_aligned_alloc (size_t alignment, size_t size) | |||
| 1797 | #endif | 1785 | #endif |
| 1798 | } | 1786 | } |
| 1799 | #endif | 1787 | #endif |
| 1800 | 1788 | ||
| 1801 | void * | 1789 | void * |
| 1802 | hybrid_realloc (void *ptr, size_t size) | 1790 | hybrid_realloc (void *ptr, size_t size) |
| 1803 | { | 1791 | { |
| @@ -1825,19 +1813,6 @@ hybrid_realloc (void *ptr, size_t size) | |||
| 1825 | return result; | 1813 | return result; |
| 1826 | } | 1814 | } |
| 1827 | 1815 | ||
| 1828 | #ifdef HYBRID_GET_CURRENT_DIR_NAME | ||
| 1829 | /* Defined in sysdep.c. */ | ||
| 1830 | char *gget_current_dir_name (void); | ||
| 1831 | |||
| 1832 | char * | ||
| 1833 | hybrid_get_current_dir_name (void) | ||
| 1834 | { | ||
| 1835 | if (DUMPED) | ||
| 1836 | return get_current_dir_name (); | ||
| 1837 | return gget_current_dir_name (); | ||
| 1838 | } | ||
| 1839 | #endif | ||
| 1840 | |||
| 1841 | #else /* ! HYBRID_MALLOC */ | 1816 | #else /* ! HYBRID_MALLOC */ |
| 1842 | 1817 | ||
| 1843 | void * | 1818 | void * |