From 3b69e02a248c8b46223d5a9cecfb2494992e5fbe Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Feb 2019 13:03:18 -0800 Subject: [PATCH] Rename CANNOT_DUMP to HAVE_UNEXEC * configure.ac (CANNOT_DUMP): Remove. All uses removed, or changed to the negative of with_unexec. (HAVE_UNEXEC): New macro. All uses of CANNOT_DUMP changed to the negative of this macro. --- configure.ac | 37 +++++++++++++++++-------------------- etc/DEBUG | 2 +- lisp/loadup.el | 3 +-- src/alloc.c | 12 ++++++------ src/conf_post.h | 10 ++++------ src/emacs.c | 44 +++++++++++++++++++++----------------------- src/image.c | 2 +- src/lastfile.c | 2 +- src/lisp.h | 32 ++++++++++++++++---------------- src/term.c | 3 ++- src/timefns.c | 4 ++-- src/unexcoff.c | 4 ++-- src/w32heap.c | 8 ++++---- 13 files changed, 78 insertions(+), 85 deletions(-) diff --git a/configure.ac b/configure.ac index 40be0859aa..ff745eca1a 100644 --- a/configure.ac +++ b/configure.ac @@ -382,15 +382,8 @@ AC_DEFUN AC_DEFINE(HAVE_PDUMPER, 1, [Define to build with portable dumper support]) fi -if test "$with_unexec" = "yes"; then - CANNOT_DUMP=no -else - CANNOT_DUMP=yes -fi - DUMPING=$with_dumping AC_SUBST(DUMPING) -AC_SUBST(CANNOT_DUMP) dnl FIXME currently it is not the last. dnl This should be the last --with option, because --with-x is @@ -1314,7 +1307,7 @@ AC_DEFUN PAXCTL_dumped= PAXCTL_notdumped= -if test "$CANNOT_DUMP" = "no" && test $opsys = gnu-linux; then +if test $with_unexec = yes && test $opsys = gnu-linux; then if test "${SETFATTR+set}" != set; then AC_CACHE_CHECK([for setfattr], [emacs_cv_prog_setfattr], @@ -1434,7 +1427,7 @@ AC_DEFUN fi AC_CACHE_CHECK([for -znocombreloc], [emacs_cv_znocombreloc], - [if test "$CANNOT_DUMP" = "yes"; then + [if test $with_unexec = no; then emacs_cv_znocombreloc='not needed' else save_LDFLAGS=$LDFLAGS @@ -1465,13 +1458,16 @@ AC_DEFUN [emacs_cv_sanitize_address=yes], [emacs_cv_sanitize_address=no])]) -if test "$CANNOT_DUMP" = "yes"; then - AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs should not support unexec.]) -elif test "$emacs_cv_sanitize_address" = yes; then - AC_MSG_WARN([[Addresses are sanitized; suggest CANNOT_DUMP=yes]]) +if test $with_unexec = yes; then + AC_DEFINE([HAVE_UNEXEC], 1, [Define if Emacs supports unexec.]) + if test "$emacs_cv_sanitize_address" = yes; then + AC_MSG_WARN([[Addresses are sanitized; suggest --without-unexec]]) + fi fi -UNEXEC_OBJ=unexelf.o + +UNEXEC_OBJ= +test $with_unexec = yes && case "$opsys" in # MSDOS uses unexcoff.o aix4-2) @@ -1499,8 +1495,10 @@ AC_DEFUN # not been tested, so for now this change is for Solaris 10 or newer. UNEXEC_OBJ=unexsol.o ;; + *) + UNEXEC_OBJ=unexelf.o + ;; esac -test "$CANNOT_DUMP" = "yes" && UNEXEC_OBJ= LD_SWITCH_SYSTEM= test "$with_unexec" = no || case "$opsys" in @@ -1551,7 +1549,7 @@ AC_DEFUN C_SWITCH_MACHINE= -test "$CANNOT_DUMP" = yes || +test $with_unexec = yes && case $canonical in alpha*) AC_CHECK_DECL([__ELF__]) @@ -2310,7 +2308,7 @@ AC_DEFUN hybrid_malloc= system_malloc=yes -test "$CANNOT_DUMP" = yes || +test $with_unexec = yes && case "$opsys" in ## darwin ld insists on the use of malloc routines in the System framework. darwin | mingw32 | nacl | sol2-10) ;; @@ -5440,7 +5438,7 @@ AC_DEFUN AC_CACHE_CHECK( [for $CC option to disable position independent executables], [emacs_cv_prog_cc_no_pie], - [if test "$CANNOT_DUMP" = yes; then + [if test $with_unexec = no; then emacs_cv_prog_cc_no_pie='not needed' else emacs_save_c_werror_flag=$ac_c_werror_flag @@ -5552,10 +5550,9 @@ AC_DEFUN for opt in XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS \ GCONF GSETTINGS GLIB NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT \ LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT OLDXMENU X11 XDBE XIM \ - NS MODULES THREADS XWIDGETS LIBSYSTEMD JSON CANNOT_DUMP LCMS2 GMP; do + NS MODULES THREADS XWIDGETS LIBSYSTEMD JSON LCMS2 GMP; do case $opt in - CANNOT_DUMP) eval val=\${$opt} ;; GLIB) val=${emacs_cv_links_glib} ;; NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;; TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;; diff --git a/etc/DEBUG b/etc/DEBUG index 21097ccdf4..d401d0be90 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -936,7 +936,7 @@ its own versions, and because the dumping process might be incompatible with the way these packages use to track allocated memory. Here are some of the changes you might find necessary: - - Edit configure, to set system_malloc and CANNOT_DUMP to "yes". + - Make sure unexec is disabled, e.g., './configure --without-unexec'. - Configure with a different --prefix= option. If you use GCC, version 2.7.2 is preferred, as some malloc debugging packages diff --git a/lisp/loadup.el b/lisp/loadup.el index 747476c506..67e8aa7d40 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -526,8 +526,7 @@ t)))) (kill-emacs))) -;; For machines with CANNOT_DUMP defined in config.h, -;; this file must be loaded each time Emacs is run. +;; This file must be loaded each time Emacs is run from scratch, e.g., temacs. ;; So run the startup code now. First, remove `-l loadup' from args. (if (and (member (nth 1 command-line-args) '("-l" "--load")) diff --git a/src/alloc.c b/src/alloc.c index 5ea466beca..a0d0a61134 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -168,7 +168,7 @@ voidfuncptr __MALLOC_HOOK_VOLATILE __malloc_initialize_hook EXTERNALLY_VISIBLE #endif -#if defined DOUG_LEA_MALLOC || !defined CANNOT_DUMP +#if defined DOUG_LEA_MALLOC || defined HAVE_UNEXEC /* Allocator-related actions to do just before and after unexec. */ @@ -502,11 +502,11 @@ static struct mem_node *mem_find (void *); #endif /* Addresses of staticpro'd variables. Initialize it to a nonzero - value if we might dump; otherwise some compilers put it into + value if we might unexec; otherwise some compilers put it into BSS. */ Lisp_Object *staticvec[NSTATICS] -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC = {&Vpurify_flag} #endif ; @@ -1192,9 +1192,9 @@ verify (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. Aligned allocation is incompatible with unexmacosx.c, so don't use - it on Darwin unless CANNOT_DUMP. */ + it on Darwin if HAVE_UNEXEC. */ -#if !defined DARWIN_OS || defined CANNOT_DUMP +#if ! (defined DARWIN_OS && defined HAVE_UNEXEC) # if (defined HAVE_ALIGNED_ALLOC \ || (defined HYBRID_MALLOC \ ? defined HAVE_POSIX_MEMALIGN \ @@ -5390,7 +5390,7 @@ pure_alloc (size_t size, int type) } -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC /* Print a warning if PURESIZE is too small. */ diff --git a/src/conf_post.h b/src/conf_post.h index 125dbf0152..f8254cfa9d 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -92,13 +92,11 @@ typedef bool bool_bf; # define ADDRESS_SANITIZER false #endif -#ifdef DARWIN_OS -#if defined emacs && !defined CANNOT_DUMP -#define malloc unexec_malloc -#define realloc unexec_realloc -#define free unexec_free +#if defined DARWIN_OS && defined emacs && defined HAVE_UNEXEC +# define malloc unexec_malloc +# define realloc unexec_realloc +# define free unexec_free #endif -#endif /* DARWIN_OS */ /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use gmalloc before dumping and the system malloc after dumping. diff --git a/src/emacs.c b/src/emacs.c index d6b8a87c72..ff814a149b 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -149,7 +149,7 @@ bool running_asynch_code; bool display_arg; #endif -#if defined GNU_LINUX && !defined CANNOT_DUMP +#if defined GNU_LINUX && defined HAVE_UNEXEC /* The gap between BSS end and heap start as far as we can tell. */ static uprintmax_t heap_bss_diff; #endif @@ -868,7 +868,7 @@ main (int argc, char **argv) can set heap flags properly if we're going to unexec. */ if (!initialized && temacs) { -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC if (strcmp (temacs, "dump") == 0 || strcmp (temacs, "bootstrap") == 0) gflags.will_dump_with_unexec_ = true; @@ -878,7 +878,7 @@ main (int argc, char **argv) strcmp (temacs, "pbootstrap") == 0) gflags.will_dump_with_pdumper_ = true; #endif -#if defined (HAVE_PDUMPER) || !defined (CANNOT_DUMP) +#if defined HAVE_PDUMPER || defined HAVE_UNEXEC if (strcmp (temacs, "bootstrap") == 0 || strcmp (temacs, "pbootstrap") == 0) gflags.will_bootstrap_ = true; @@ -904,7 +904,7 @@ main (int argc, char **argv) #endif } -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC if (!will_dump_with_unexec_p ()) gflags.will_not_unexec_ = true; #endif @@ -953,7 +953,7 @@ main (int argc, char **argv) argc = maybe_disable_address_randomization ( will_dump_with_unexec_p (), argc, argv); -#if defined (GNU_LINUX) && !defined (CANNOT_DUMP) +#if defined GNU_LINUX && defined HAVE_UNEXEC if (!initialized) { char *heap_start = my_heap_start (); @@ -967,7 +967,7 @@ main (int argc, char **argv) #endif /* If using unexmacosx.c (set by s/darwin.h), we must do this. */ -#if defined DARWIN_OS && !defined CANNOT_DUMP +#if defined DARWIN_OS && defined HAVE_UNEXEC if (!initialized) unexec_init_emacs_zone (); #endif @@ -1445,7 +1445,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* Call syms_of_keyboard before init_window_once because keyboard sets up symbols that include some face names that the X support will want to use. This can happen when - CANNOT_DUMP is defined. */ + Emacs starts up from scratch (e.g., temacs). */ syms_of_keyboard (); /* Called before syms_of_fileio, because it sets up Qerror_condition. */ @@ -2378,7 +2378,7 @@ shut_down_emacs (int sig, Lisp_Object stuff) -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC #include "unexec.h" @@ -2405,10 +2405,10 @@ You must run Emacs in batch mode in order to dump it. */) if (definitely_will_not_unexec_p ()) error ("This Emacs instance was not started in temacs mode"); -#if defined GNU_LINUX && !defined CANNOT_DUMP +# if defined GNU_LINUX && defined HAVE_UNEXEC /* Warn if the gap between BSS end and heap start is larger than this. */ -# define MAX_HEAP_BSS_DIFF (1024*1024) +# define MAX_HEAP_BSS_DIFF (1024 * 1024) if (heap_bss_diff > MAX_HEAP_BSS_DIFF) { @@ -2421,7 +2421,7 @@ You must run Emacs in batch mode in order to dump it. */) fprintf (stderr, "exec-shield in etc/PROBLEMS for more information.\n"); fprintf (stderr, "**************************************************\n"); } -#endif /* GNU_LINUX */ +# endif /* Bind `command-line-processed' to nil before dumping, so that the dumped Emacs will process its command line @@ -2445,7 +2445,7 @@ You must run Emacs in batch mode in order to dump it. */) tem = Vpurify_flag; Vpurify_flag = Qnil; -#ifdef HYBRID_MALLOC +# ifdef HYBRID_MALLOC { static char const fmt[] = "%d of %d static heap bytes used"; char buf[sizeof fmt + 2 * (INT_STRLEN_BOUND (int) - 2)]; @@ -2454,18 +2454,16 @@ You must run Emacs in batch mode in order to dump it. */) /* Don't log messages, because at this point buffers cannot be created. */ message1_nolog (buf); } -#endif +# endif fflush_unlocked (stdout); /* Tell malloc where start of impure now is. */ /* Also arrange for warnings when nearly out of space. */ -#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC -#ifndef WINDOWSNT +# if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC && !defined WINDOWSNT /* On Windows, this was done before dumping, and that once suffices. Meanwhile, my_edata is not valid on Windows. */ memory_warnings (my_edata, malloc_warning); -#endif /* not WINDOWSNT */ -#endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ +# endif struct gflags old_gflags = gflags; gflags.will_dump_ = false; @@ -2480,19 +2478,19 @@ You must run Emacs in batch mode in order to dump it. */) gflags = old_gflags; -#ifdef WINDOWSNT +# ifdef WINDOWSNT Vlibrary_cache = Qnil; -#endif -#ifdef HAVE_WINDOW_SYSTEM +# endif +# ifdef HAVE_WINDOW_SYSTEM reset_image_types (); -#endif +# endif Vpurify_flag = tem; return unbind_to (count, Qnil); } -#endif /* not CANNOT_DUMP */ +#endif #if HAVE_SETLOCALE @@ -2781,7 +2779,7 @@ syms_of_emacs (void) DEFSYM (Qkill_emacs, "kill-emacs"); DEFSYM (Qkill_emacs_hook, "kill-emacs-hook"); -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC defsubr (&Sdump_emacs); #endif diff --git a/src/image.c b/src/image.c index 2014860581..57bbf3cdb9 100644 --- a/src/image.c +++ b/src/image.c @@ -10003,7 +10003,7 @@ lookup_image_type (Lisp_Object type) return NULL; } -#if !defined CANNOT_DUMP && defined HAVE_WINDOW_SYSTEM +#if defined HAVE_UNEXEC && defined HAVE_WINDOW_SYSTEM /* Reset image_types before dumping. Called from Fdump_emacs. */ diff --git a/src/lastfile.c b/src/lastfile.c index 706f667dbb..bcaf105a51 100644 --- a/src/lastfile.c +++ b/src/lastfile.c @@ -43,7 +43,7 @@ along with GNU Emacs. If not, see . */ char my_edata[] = "End of Emacs initialized data"; #endif -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC /* Help unexec locate the end of the .bss area used by Emacs (which isn't always a separate section in NT executables). */ diff --git a/src/lisp.h b/src/lisp.h index 5a0de4b12c..3b481089cf 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -633,11 +633,11 @@ extern bool initialized; extern struct gflags { /* True means this Emacs instance was born to dump. */ -#if defined (HAVE_PDUMPER) || !defined (CANNOT_DUMP) +#if defined HAVE_PDUMPER || defined HAVE_UNEXEC bool will_dump_ : 1; bool will_bootstrap_ : 1; #endif -#if defined (HAVE_PDUMPER) +#ifdef HAVE_PDUMPER /* Set in an Emacs process that will likely dump with pdumper; all Emacs processes may dump with pdumper, however. */ bool will_dump_with_pdumper_ : 1; @@ -645,7 +645,7 @@ extern struct gflags { dump. */ bool dumped_with_pdumper_ : 1; #endif -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC bool will_dump_with_unexec_ : 1; /* Set in an Emacs process that has been restored from an unexec dump. */ @@ -658,7 +658,7 @@ extern struct gflags { INLINE bool will_dump_p (void) { -#if HAVE_PDUMPER || !defined (CANNOT_DUMP) +#if HAVE_PDUMPER || defined HAVE_UNEXEC return gflags.will_dump_; #else return false; @@ -668,7 +668,7 @@ will_dump_p (void) INLINE bool will_bootstrap_p (void) { -#if HAVE_PDUMPER || !defined (CANNOT_DUMP) +#if HAVE_PDUMPER || defined HAVE_UNEXEC return gflags.will_bootstrap_; #else return false; @@ -698,20 +698,20 @@ dumped_with_pdumper_p (void) INLINE bool will_dump_with_unexec_p (void) { -#ifdef CANNOT_DUMP - return false; -#else +#ifdef HAVE_UNEXEC return gflags.will_dump_with_unexec_; +#else + return false; #endif } INLINE bool dumped_with_unexec_p (void) { -#ifdef CANNOT_DUMP - return false; -#else +#ifdef HAVE_UNEXEC return gflags.dumped_with_unexec_; +#else + return false; #endif } @@ -721,10 +721,10 @@ dumped_with_unexec_p (void) INLINE bool definitely_will_not_unexec_p (void) { -#ifdef CANNOT_DUMP - return true; -#else +#ifdef HAVE_UNEXEC return gflags.will_not_unexec_; +#else + return true; #endif } @@ -3032,7 +3032,7 @@ CHECK_INTEGER (Lisp_Object x) /* If we're not dumping using the legacy dumper and we might be using the portable dumper, try to bunch all the subr structures together for more efficient dump loading. */ -#ifdef CANNOT_DUMP +#ifndef HAVE_UNEXEC # ifdef DARWIN_OS # define SUBR_SECTION_ATTRIBUTE ATTRIBUTE_SECTION ("__DATA,subrs") # else @@ -4135,7 +4135,7 @@ Lisp_Object backtrace_top_function (void); extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); /* Defined in unexmacosx.c. */ -#if defined DARWIN_OS && !defined CANNOT_DUMP +#if defined DARWIN_OS && defined HAVE_UNEXEC extern void unexec_init_emacs_zone (void); extern void *unexec_malloc (size_t); extern void *unexec_realloc (void *, size_t); diff --git a/src/term.c b/src/term.c index c5a1fb99a1..7255f561e2 100644 --- a/src/term.c +++ b/src/term.c @@ -1350,7 +1350,8 @@ term_get_fkeys_1 (void) char **address = term_get_fkeys_address; KBOARD *kboard = term_get_fkeys_kboard; - /* This can happen if CANNOT_DUMP or with strange options. */ + /* This can happen if Emacs is starting up from scratch, or with + strange options. */ if (!KEYMAPP (KVAR (kboard, Vinput_decode_map))) kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil)); diff --git a/src/timefns.c b/src/timefns.c index ce1f4d3f5a..7e061228e2 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -294,7 +294,7 @@ tzlookup (Lisp_Object zone, bool settz) void init_timefns (void) { -#ifndef CANNOT_DUMP +#ifdef HAVE_UNEXEC /* A valid but unlikely setting for the TZ environment variable. It is OK (though a bit slower) if the user chooses this value. */ static char dump_tz_string[] = "TZ=UtC0"; @@ -311,7 +311,7 @@ init_timefns (void) char *tz = getenv ("TZ"); -#if !defined CANNOT_DUMP +#ifdef HAVE_UNEXEC /* If the execution TZ happens to be the same as the dump TZ, change it to some other value and then change it back, to force the underlying implementation to reload the TZ info. diff --git a/src/unexcoff.c b/src/unexcoff.c index 6e90c0628d..220ce709df 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -56,7 +56,7 @@ along with GNU Emacs. If not, see . */ #define PERROR(file) report_error (file, new) -#ifndef CANNOT_DUMP /* all rest of file! */ +#ifdef HAVE_UNEXEC /* all rest of file! */ #ifdef HAVE_COFF_H #include @@ -538,4 +538,4 @@ unexec (const char *new_name, const char *a_name) emacs_close (a_out); } -#endif /* not CANNOT_DUMP */ +#endif /* HAVE_UNEXEC */ diff --git a/src/w32heap.c b/src/w32heap.c index 8a2c1b5877..9a59a1f075 100644 --- a/src/w32heap.c +++ b/src/w32heap.c @@ -115,9 +115,9 @@ typedef struct _RTL_HEAP_PARAMETERS { than half of the size stated below. It would be nice to find a way to build only the first bootstrap-emacs.exe with the large size, and reset that to a lower value afterwards. */ -#ifdef CANNOT_DUMP -/* We don't use dumped_data[] when CANNOT_DUMP, so define to a small - size that won't matter. */ +#ifndef HAVE_UNEXEC +/* We don't use dumped_data[], so define to a small size that won't + matter. */ # define DUMPED_HEAP_SIZE 10 #else # if defined _WIN64 || defined WIDE_EMACS_INT @@ -597,7 +597,7 @@ free_after_dump_9x (void *ptr) } } -#if !defined (CANNOT_DUMP) && defined (ENABLE_CHECKING) +#if defined HAVE_UNEXEC && defined ENABLE_CHECKING void report_temacs_memory_usage (void) { -- 2.20.1