diff options
| author | Paul Eggert | 2016-01-30 14:20:57 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-30 15:26:07 -0800 |
| commit | e4cd4a76a621927bc155a18353ef7fd09133887d (patch) | |
| tree | bdc6224d8cf108d37b82763dcfd629dea1c886e8 /src | |
| parent | e1a9f2099c2e683dffc4b898ce85ce935c4cb254 (diff) | |
| download | emacs-e4cd4a76a621927bc155a18353ef7fd09133887d.tar.gz emacs-e4cd4a76a621927bc155a18353ef7fd09133887d.zip | |
* src/alloc.c: Include "sheap.h".
(alloc_unexec_pre, alloc_unexec_post) [HYBRID_MALLOC]:
Set and clear bss_sbrk_did_unexec, on all platforms not just Cygwin.
* src/lisp.h (alloc_unexec_pre, alloc_unexec_post) [!DOUG_LEA_MALLOC]:
Declare unconditionally.
* src/unexcw.c, src/unexelf.c (bss_sbrk_did_unexec): Remove decl.
(unexec): Don’t set or clear bss_sbrk_did_unexec;
the caller now does this.
(Bug#22086)
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 37 | ||||
| -rw-r--r-- | src/lisp.h | 5 | ||||
| -rw-r--r-- | src/unexcw.c | 4 | ||||
| -rw-r--r-- | src/unexelf.c | 8 |
4 files changed, 25 insertions, 29 deletions
diff --git a/src/alloc.c b/src/alloc.c index d379761c168..617148e85e5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -35,6 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 35 | #include "dispextern.h" | 35 | #include "dispextern.h" |
| 36 | #include "intervals.h" | 36 | #include "intervals.h" |
| 37 | #include "puresize.h" | 37 | #include "puresize.h" |
| 38 | #include "sheap.h" | ||
| 38 | #include "systime.h" | 39 | #include "systime.h" |
| 39 | #include "character.h" | 40 | #include "character.h" |
| 40 | #include "buffer.h" | 41 | #include "buffer.h" |
| @@ -117,18 +118,6 @@ my_heap_start (void) | |||
| 117 | inside glibc's malloc. */ | 118 | inside glibc's malloc. */ |
| 118 | static void *malloc_state_ptr; | 119 | static void *malloc_state_ptr; |
| 119 | 120 | ||
| 120 | /* Get and free this pointer; useful around unexec. */ | ||
| 121 | void | ||
| 122 | alloc_unexec_pre (void) | ||
| 123 | { | ||
| 124 | malloc_state_ptr = malloc_get_state (); | ||
| 125 | } | ||
| 126 | void | ||
| 127 | alloc_unexec_post (void) | ||
| 128 | { | ||
| 129 | free (malloc_state_ptr); | ||
| 130 | } | ||
| 131 | |||
| 132 | /* Restore the dumped malloc state. Because malloc can be invoked | 121 | /* Restore the dumped malloc state. Because malloc can be invoked |
| 133 | even before main (e.g. by the dynamic linker), the dumped malloc | 122 | even before main (e.g. by the dynamic linker), the dumped malloc |
| 134 | state must be restored as early as possible using this special hook. */ | 123 | state must be restored as early as possible using this special hook. */ |
| @@ -177,6 +166,30 @@ voidfuncptr __MALLOC_HOOK_VOLATILE __malloc_initialize_hook | |||
| 177 | 166 | ||
| 178 | #endif | 167 | #endif |
| 179 | 168 | ||
| 169 | /* Allocator-related actions to do just before and after unexec. */ | ||
| 170 | |||
| 171 | void | ||
| 172 | alloc_unexec_pre (void) | ||
| 173 | { | ||
| 174 | #ifdef DOUG_LEA_MALLOC | ||
| 175 | malloc_state_ptr = malloc_get_state (); | ||
| 176 | #endif | ||
| 177 | #ifdef HYBRID_MALLOC | ||
| 178 | bss_sbrk_did_unexec = true; | ||
| 179 | #endif | ||
| 180 | } | ||
| 181 | |||
| 182 | void | ||
| 183 | alloc_unexec_post (void) | ||
| 184 | { | ||
| 185 | #ifdef DOUG_LEA_MALLOC | ||
| 186 | free (malloc_state_ptr); | ||
| 187 | #endif | ||
| 188 | #ifdef HYBRID_MALLOC | ||
| 189 | bss_sbrk_did_unexec = false; | ||
| 190 | #endif | ||
| 191 | } | ||
| 192 | |||
| 180 | /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer | 193 | /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer |
| 181 | to a struct Lisp_String. */ | 194 | to a struct Lisp_String. */ |
| 182 | 195 | ||
diff --git a/src/lisp.h b/src/lisp.h index 53f123df973..3c8e3ddb137 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3602,13 +3602,8 @@ extern void mark_object (Lisp_Object); | |||
| 3602 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC | 3602 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 3603 | extern void refill_memory_reserve (void); | 3603 | extern void refill_memory_reserve (void); |
| 3604 | #endif | 3604 | #endif |
| 3605 | #ifdef DOUG_LEA_MALLOC | ||
| 3606 | extern void alloc_unexec_pre (void); | 3605 | extern void alloc_unexec_pre (void); |
| 3607 | extern void alloc_unexec_post (void); | 3606 | extern void alloc_unexec_post (void); |
| 3608 | #else | ||
| 3609 | INLINE void alloc_unexec_pre (void) {} | ||
| 3610 | INLINE void alloc_unexec_post (void) {} | ||
| 3611 | #endif | ||
| 3612 | extern const char *pending_malloc_warning; | 3607 | extern const char *pending_malloc_warning; |
| 3613 | extern Lisp_Object zero_vector; | 3608 | extern Lisp_Object zero_vector; |
| 3614 | extern Lisp_Object *stack_base; | 3609 | extern Lisp_Object *stack_base; |
diff --git a/src/unexcw.c b/src/unexcw.c index e4aa3565688..6ebd8c6f83b 100644 --- a/src/unexcw.c +++ b/src/unexcw.c | |||
| @@ -30,8 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 30 | 30 | ||
| 31 | #define DOTEXE ".exe" | 31 | #define DOTEXE ".exe" |
| 32 | 32 | ||
| 33 | extern int bss_sbrk_did_unexec; | ||
| 34 | |||
| 35 | /* | 33 | /* |
| 36 | ** header for Windows executable files | 34 | ** header for Windows executable files |
| 37 | */ | 35 | */ |
| @@ -298,9 +296,7 @@ unexec (const char *outfile, const char *infile) | |||
| 298 | ret = emacs_close (fd_in); | 296 | ret = emacs_close (fd_in); |
| 299 | assert (ret == 0); | 297 | assert (ret == 0); |
| 300 | 298 | ||
| 301 | bss_sbrk_did_unexec = 1; | ||
| 302 | fixup_executable (fd_out); | 299 | fixup_executable (fd_out); |
| 303 | bss_sbrk_did_unexec = 0; | ||
| 304 | 300 | ||
| 305 | ret = emacs_close (fd_out); | 301 | ret = emacs_close (fd_out); |
| 306 | assert (ret == 0); | 302 | assert (ret == 0); |
diff --git a/src/unexelf.c b/src/unexelf.c index 3dc0456d9b6..e90199472ed 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -211,10 +211,6 @@ entry_address (void *section_h, ptrdiff_t idx, ptrdiff_t entsize) | |||
| 211 | 211 | ||
| 212 | typedef unsigned char byte; | 212 | typedef unsigned char byte; |
| 213 | 213 | ||
| 214 | #ifdef HYBRID_MALLOC | ||
| 215 | extern int bss_sbrk_did_unexec; | ||
| 216 | #endif | ||
| 217 | |||
| 218 | /* **************************************************************** | 214 | /* **************************************************************** |
| 219 | * unexec | 215 | * unexec |
| 220 | * | 216 | * |
| @@ -231,10 +227,6 @@ unexec (const char *new_name, const char *old_name) | |||
| 231 | off_t new_file_size; | 227 | off_t new_file_size; |
| 232 | void *new_break; | 228 | void *new_break; |
| 233 | 229 | ||
| 234 | #ifdef HYBRID_MALLOC | ||
| 235 | bss_sbrk_did_unexec = 1; | ||
| 236 | #endif | ||
| 237 | |||
| 238 | /* Pointers to the base of the image of the two files. */ | 230 | /* Pointers to the base of the image of the two files. */ |
| 239 | caddr_t old_base, new_base; | 231 | caddr_t old_base, new_base; |
| 240 | 232 | ||