summaryrefslogtreecommitdiff
path: root/src/emacs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emacs.c')
-rw-r--r--src/emacs.c80
1 files changed, 73 insertions, 7 deletions
diff --git a/src/emacs.c b/src/emacs.c
index c99b007ea78..4734faf33c2 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -109,6 +109,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "getpagesize.h"
#include "gnutls.h"
+#ifdef HAVE_HAIKU
+#include <kernel/OS.h>
+#endif
+
#ifdef PROFILING
# include <sys/gmon.h>
extern void moncontrol (int mode);
@@ -133,6 +137,7 @@ extern char etext;
#endif
#include "pdumper.h"
+#include "fingerprint.h"
#include "epaths.h"
static const char emacs_version[] = PACKAGE_VERSION;
@@ -255,11 +260,12 @@ Initialization options:\n\
#ifdef HAVE_PDUMPER
"\
--dump-file FILE read dumped state from FILE\n\
+--fingerprint output fingerprint and exit\n\
",
#endif
#if SECCOMP_USABLE
"\
---sandbox=FILE read Seccomp BPF filter from FILE\n\
+--seccomp=FILE read Seccomp BPF filter from FILE\n\
"
#endif
"\
@@ -830,6 +836,8 @@ load_pdump (int argc, char **argv)
const char *const suffix = ".pdmp";
int result;
char *emacs_executable = argv[0];
+ ptrdiff_t hexbuf_size;
+ char *hexbuf;
const char *strip_suffix =
#if defined DOS_NT || defined CYGWIN
".exe"
@@ -924,12 +932,18 @@ load_pdump (int argc, char **argv)
path_exec = ns_relocate (path_exec);
#endif
- /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in
- "emacs.pdmp" so that the Emacs binary still works if the user
- copies and renames it. */
+ /* Look for "emacs-FINGERPRINT.pdmp" in PATH_EXEC. We hardcode
+ "emacs" in "emacs-FINGERPRINT.pdmp" so that the Emacs binary
+ still works if the user copies and renames it. */
+ hexbuf_size = 2 * sizeof fingerprint;
+ hexbuf = xmalloc (hexbuf_size + 1);
+ hexbuf_digest (hexbuf, (char *) fingerprint, sizeof fingerprint);
+ hexbuf[hexbuf_size] = '\0';
needed = (strlen (path_exec)
+ 1
+ strlen (argv0_base)
+ + 1
+ + strlen (hexbuf)
+ strlen (suffix)
+ 1);
if (bufsize < needed)
@@ -937,8 +951,8 @@ load_pdump (int argc, char **argv)
xfree (dump_file);
dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1);
}
- sprintf (dump_file, "%s%c%s%s",
- path_exec, DIRECTORY_SEP, argv0_base, suffix);
+ sprintf (dump_file, "%s%c%s-%s%s",
+ path_exec, DIRECTORY_SEP, argv0_base, hexbuf, suffix);
#if !defined (NS_SELF_CONTAINED)
/* Assume the Emacs binary lives in a sibling directory as set up by
the default installation configuration. */
@@ -1420,6 +1434,24 @@ main (int argc, char **argv)
exit (0);
}
+#ifdef HAVE_PDUMPER
+ if (argmatch (argv, argc, "-fingerprint", "--fingerprint", 4,
+ NULL, &skip_args))
+ {
+ if (initialized)
+ {
+ dump_fingerprint (stdout, "",
+ (unsigned char *) fingerprint);
+ exit (0);
+ }
+ else
+ {
+ fputs ("Not initialized\n", stderr);
+ exit (1);
+ }
+ }
+#endif
+
emacs_wd = emacs_get_current_dir_name ();
#ifdef HAVE_PDUMPER
if (dumped_with_pdumper_p ())
@@ -1877,7 +1909,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
init_bignum ();
init_threads ();
init_eval ();
- init_atimer ();
running_asynch_code = 0;
init_random ();
@@ -2039,6 +2070,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
if (!will_dump_p ())
set_initial_environment ();
+ /* Has to run after the environment is set up. */
+ init_atimer ();
+
#ifdef WINDOWSNT
globals_of_w32 ();
#ifdef HAVE_W32NOTIFY
@@ -2210,6 +2244,18 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_fontset ();
#endif /* HAVE_NS */
+#ifdef HAVE_HAIKU
+ syms_of_haikuterm ();
+ syms_of_haikufns ();
+ syms_of_haikumenu ();
+ syms_of_haikufont ();
+ syms_of_haikuselect ();
+#ifdef HAVE_NATIVE_IMAGE_API
+ syms_of_haikuimage ();
+#endif
+ syms_of_fontset ();
+#endif /* HAVE_HAIKU */
+
syms_of_gnutls ();
#ifdef HAVE_INOTIFY
@@ -2264,6 +2310,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#if defined WINDOWSNT || defined HAVE_NTGUI
globals_of_w32select ();
#endif
+
+#ifdef HAVE_HAIKU
+ init_haiku_select ();
+#endif
}
init_charset ();
@@ -2349,6 +2399,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
if (dump_mode)
Vdump_mode = build_string (dump_mode);
+#ifdef HAVE_PDUMPER
+ /* Allow code to be run (mostly useful after redumping). */
+ safe_run_hooks (Qafter_pdump_load_hook);
+#endif
+
/* Enter editor command loop. This never returns. */
set_initial_minibuffer_mode ();
Frecursive_edit ();
@@ -2371,6 +2426,9 @@ struct standard_args
static const struct standard_args standard_args[] =
{
{ "-version", "--version", 150, 0 },
+#ifdef HAVE_PDUMPER
+ { "-fingerprint", "--fingerprint", 140, 0 },
+#endif
{ "-chdir", "--chdir", 130, 1 },
{ "-t", "--terminal", 120, 1 },
{ "-nw", "--no-window-system", 110, 0 },
@@ -2734,6 +2792,9 @@ shut_down_emacs (int sig, Lisp_Object stuff)
/* Don't update display from now on. */
Vinhibit_redisplay = Qt;
+#ifdef HAVE_HAIKU
+ be_app_quit ();
+#endif
/* If we are controlling the terminal, reset terminal modes. */
#ifndef DOS_NT
pid_t tpgrp = tcgetpgrp (STDIN_FILENO);
@@ -2743,6 +2804,10 @@ shut_down_emacs (int sig, Lisp_Object stuff)
if (sig && sig != SIGTERM)
{
static char const fmt[] = "Fatal error %d: %n%s\n";
+#ifdef HAVE_HAIKU
+ if (haiku_debug_on_fatal_error)
+ debugger ("Fatal error in Emacs");
+#endif
char buf[max ((sizeof fmt - sizeof "%d%n%s\n"
+ INT_STRLEN_BOUND (int) + 1),
min (PIPE_BUF, MAX_ALLOCA))];
@@ -3235,6 +3300,7 @@ Special values:
`ms-dos' compiled as an MS-DOS application.
`windows-nt' compiled as a native W32 application.
`cygwin' compiled using the Cygwin library.
+ `haiku' compiled for a Haiku system.
Anything else (in Emacs 26, the possibilities are: aix, berkeley-unix,
hpux, usg-unix-v) indicates some sort of Unix system. */);
Vsystem_type = intern_c_string (SYSTEM_TYPE);