diff options
| author | Paul Eggert | 2016-01-30 13:56:23 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-30 13:56:23 -0800 |
| commit | 99fa8c3dbf333f1e3fa7d6449d4b4428ce439ce1 (patch) | |
| tree | fc459c16ca5f7204aa5a21529f8a189bfb45f831 /src/emacs.c | |
| parent | 3005605776955593e0b416de9e1ebf158114343e (diff) | |
| parent | 875577bcc8d6139d61f91118d0907b847912b3e1 (diff) | |
| download | emacs-99fa8c3dbf333f1e3fa7d6449d4b4428ce439ce1.tar.gz emacs-99fa8c3dbf333f1e3fa7d6449d4b4428ce439ce1.zip | |
-
Diffstat (limited to 'src/emacs.c')
| -rw-r--r-- | src/emacs.c | 78 |
1 files changed, 5 insertions, 73 deletions
diff --git a/src/emacs.c b/src/emacs.c index 7c818f59c5c..fb6f896a639 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -133,20 +133,7 @@ bool might_dump; | |||
| 133 | extern void unexec_init_emacs_zone (void); | 133 | extern void unexec_init_emacs_zone (void); |
| 134 | #endif | 134 | #endif |
| 135 | 135 | ||
| 136 | #ifdef DOUG_LEA_MALLOC | ||
| 137 | /* Preserves a pointer to the memory allocated that copies that | ||
| 138 | static data inside glibc's malloc. */ | ||
| 139 | static void *malloc_state_ptr; | ||
| 140 | /* From glibc, a routine that returns a copy of the malloc internal state. */ | ||
| 141 | extern void *malloc_get_state (void); | ||
| 142 | /* From glibc, a routine that overwrites the malloc internal state. */ | ||
| 143 | extern int malloc_set_state (void *); | ||
| 144 | /* True if the MALLOC_CHECK_ environment variable was set while | ||
| 145 | dumping. Used to work around a bug in glibc's malloc. */ | ||
| 146 | static bool malloc_using_checking; | ||
| 147 | #elif defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC | ||
| 148 | extern void malloc_enable_thread (void); | 136 | extern void malloc_enable_thread (void); |
| 149 | #endif | ||
| 150 | 137 | ||
| 151 | /* If true, Emacs should not attempt to use a window-specific code, | 138 | /* If true, Emacs should not attempt to use a window-specific code, |
| 152 | but instead should use the virtual terminal under which it was started. */ | 139 | but instead should use the virtual terminal under which it was started. */ |
| @@ -165,11 +152,6 @@ bool display_arg; | |||
| 165 | Tells GC how to save a copy of the stack. */ | 152 | Tells GC how to save a copy of the stack. */ |
| 166 | char *stack_bottom; | 153 | char *stack_bottom; |
| 167 | 154 | ||
| 168 | #if defined (DOUG_LEA_MALLOC) || defined (GNU_LINUX) | ||
| 169 | /* The address where the heap starts (from the first sbrk (0) call). */ | ||
| 170 | static void *my_heap_start; | ||
| 171 | #endif | ||
| 172 | |||
| 173 | #ifdef GNU_LINUX | 155 | #ifdef GNU_LINUX |
| 174 | /* The gap between BSS end and heap start as far as we can tell. */ | 156 | /* The gap between BSS end and heap start as far as we can tell. */ |
| 175 | static uprintmax_t heap_bss_diff; | 157 | static uprintmax_t heap_bss_diff; |
| @@ -654,51 +636,6 @@ argmatch (char **argv, int argc, const char *sstr, const char *lstr, | |||
| 654 | } | 636 | } |
| 655 | } | 637 | } |
| 656 | 638 | ||
| 657 | #ifdef DOUG_LEA_MALLOC | ||
| 658 | |||
| 659 | /* malloc can be invoked even before main (e.g. by the dynamic | ||
| 660 | linker), so the dumped malloc state must be restored as early as | ||
| 661 | possible using this special hook. */ | ||
| 662 | |||
| 663 | static void | ||
| 664 | malloc_initialize_hook (void) | ||
| 665 | { | ||
| 666 | if (initialized) | ||
| 667 | { | ||
| 668 | if (!malloc_using_checking) | ||
| 669 | /* Work around a bug in glibc's malloc. MALLOC_CHECK_ must be | ||
| 670 | ignored if the heap to be restored was constructed without | ||
| 671 | malloc checking. Can't use unsetenv, since that calls malloc. */ | ||
| 672 | { | ||
| 673 | char **p; | ||
| 674 | |||
| 675 | for (p = environ; p && *p; p++) | ||
| 676 | if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0) | ||
| 677 | { | ||
| 678 | do | ||
| 679 | *p = p[1]; | ||
| 680 | while (*++p); | ||
| 681 | break; | ||
| 682 | } | ||
| 683 | } | ||
| 684 | |||
| 685 | malloc_set_state (malloc_state_ptr); | ||
| 686 | #ifndef XMALLOC_OVERRUN_CHECK | ||
| 687 | free (malloc_state_ptr); | ||
| 688 | #endif | ||
| 689 | } | ||
| 690 | else | ||
| 691 | { | ||
| 692 | if (my_heap_start == 0) | ||
| 693 | my_heap_start = sbrk (0); | ||
| 694 | malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; | ||
| 695 | } | ||
| 696 | } | ||
| 697 | |||
| 698 | void (*__malloc_initialize_hook) (void) EXTERNALLY_VISIBLE = malloc_initialize_hook; | ||
| 699 | |||
| 700 | #endif /* DOUG_LEA_MALLOC */ | ||
| 701 | |||
| 702 | /* Close standard output and standard error, reporting any write | 639 | /* Close standard output and standard error, reporting any write |
| 703 | errors as best we can. This is intended for use with atexit. */ | 640 | errors as best we can. This is intended for use with atexit. */ |
| 704 | static void | 641 | static void |
| @@ -746,10 +683,8 @@ main (int argc, char **argv) | |||
| 746 | #ifdef GNU_LINUX | 683 | #ifdef GNU_LINUX |
| 747 | if (!initialized) | 684 | if (!initialized) |
| 748 | { | 685 | { |
| 749 | if (my_heap_start == 0) | 686 | char *heap_start = my_heap_start (); |
| 750 | my_heap_start = sbrk (0); | 687 | heap_bss_diff = heap_start - max (my_endbss, my_endbss_static); |
| 751 | |||
| 752 | heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static); | ||
| 753 | } | 688 | } |
| 754 | #endif | 689 | #endif |
| 755 | 690 | ||
| @@ -2148,15 +2083,12 @@ You must run Emacs in batch mode in order to dump it. */) | |||
| 2148 | memory_warnings (my_edata, malloc_warning); | 2083 | memory_warnings (my_edata, malloc_warning); |
| 2149 | #endif /* not WINDOWSNT */ | 2084 | #endif /* not WINDOWSNT */ |
| 2150 | #endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ | 2085 | #endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ |
| 2151 | #ifdef DOUG_LEA_MALLOC | 2086 | |
| 2152 | malloc_state_ptr = malloc_get_state (); | 2087 | alloc_unexec_pre (); |
| 2153 | #endif | ||
| 2154 | 2088 | ||
| 2155 | unexec (SSDATA (filename), !NILP (symfile) ? SSDATA (symfile) : 0); | 2089 | unexec (SSDATA (filename), !NILP (symfile) ? SSDATA (symfile) : 0); |
| 2156 | 2090 | ||
| 2157 | #ifdef DOUG_LEA_MALLOC | 2091 | alloc_unexec_post (); |
| 2158 | free (malloc_state_ptr); | ||
| 2159 | #endif | ||
| 2160 | 2092 | ||
| 2161 | #ifdef WINDOWSNT | 2093 | #ifdef WINDOWSNT |
| 2162 | Vlibrary_cache = Qnil; | 2094 | Vlibrary_cache = Qnil; |