#include <setjmp.h>
#include <unistd.h>
+#include "lisp.h"
+
#ifdef WINDOWSNT
#include <fcntl.h>
#include <windows.h> /* just for w32.h */
#include <GNUstepBase/GSConfig.h>
#endif
-#include "lisp.h"
#include "commands.h"
#include "intervals.h"
#include "buffer.h"
#include "nsterm.h"
#endif
+#ifdef HAVE_X_WINDOWS
+#include "xterm.h"
+#endif
+
#ifdef HAVE_SETLOCALE
#include <locale.h>
#endif
on subsequent starts. */
int initialized;
+#ifdef DARWIN_OS
+extern void unexec_init_emacs_zone (void);
+#endif
+
#ifdef DOUG_LEA_MALLOC
/* Preserves a pointer to the memory allocated that copies that
static data inside glibc's malloc. */
/* The address where the heap starts (from the first sbrk (0) call). */
static void *my_heap_start;
+#ifdef GNU_LINUX
/* The gap between BSS end and heap start as far as we can tell. */
-static unsigned long heap_bss_diff;
+static uprintmax_t heap_bss_diff;
+#endif
/* Nonzero means running Emacs without interactive terminal. */
int noninteractive;
/* Handler for SIGDANGER. */
void
-memory_warning_signal (sig)
- int sig;
+memory_warning_signal (int sig)
{
signal (sig, memory_warning_signal);
SIGNAL_THREAD_CHECK (sig);
int minlen, char **valptr, int *skipptr)
{
char *p = NULL;
- int arglen;
+ ptrdiff_t arglen;
char *arg;
/* Don't access argv[argc]; give up in advance. */
}
}
-void (*__malloc_initialize_hook) (void) = malloc_initialize_hook;
+void (*__malloc_initialize_hook) (void) EXTERNALLY_VISIBLE = malloc_initialize_hook;
#endif /* DOUG_LEA_MALLOC */
setenv ("G_SLICE", "always-malloc", 1);
#endif
+#ifdef GNU_LINUX
if (!initialized)
{
extern char my_endbss[];
heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static);
}
+#endif
#ifdef RUN_TIME_REMAP
if (initialized)
}
#ifndef NS_IMPL_COCOA
+#ifdef USE_GTK
+ fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
+Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\
+Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n");
+#endif
f = fork ();
#else /* NS_IMPL_COCOA */
/* Under Cocoa we must do fork+exec as CoreFoundation lib fails in
dname_arg2[0] = '\0';
sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
dname_arg2);
- dname_arg = strlen (dname_arg2) ? dname_arg2 : NULL;
+ dname_arg = *dname_arg2 ? dname_arg2 : NULL;
}
#endif /* NS_IMPL_COCOA */
syms_of_callproc ();
/* egetenv is a pretty low-level facility, which may get called in
many circumstances; it seems flimsy to put off initializing it
- until calling init_callproc. */
- set_initial_environment ();
+ until calling init_callproc. Do not do it when dumping. */
+ if (initialized || ((strcmp (argv[argc-1], "dump") != 0
+ && strcmp (argv[argc-1], "bootstrap") != 0)))
+ set_initial_environment ();
+
/* AIX crashes are reported in system versions 3.2.3 and 3.2.4
if this is not done. Do it after set_global_environment so that we
don't pollute Vglobal_environment. */
priority[from] = 0;
if (argv[from][0] == '-')
{
- int match, thislen;
- char *equals;
+ int match;
/* If we have found "--", don't consider
any more arguments as options. */
>= 0 (the table index of the match) if just one match so far. */
if (argv[from][1] == '-')
{
+ char const *equals = strchr (argv[from], '=');
+ ptrdiff_t thislen =
+ equals ? equals - argv[from] : strlen (argv[from]);
+
match = -1;
- thislen = strlen (argv[from]);
- equals = strchr (argv[from], '=');
- if (equals != 0)
- thislen = equals - argv[from];
for (i = 0;
i < sizeof (standard_args) / sizeof (standard_args[0]); i++)
UNGCPRO;
+#ifdef HAVE_X_WINDOWS
+ /* Transfer any clipboards we own to the clipboard manager. */
+ x_clipboard_manager_save_all ();
+#endif
+
shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
/* If we have an auto-save list file,
{
fprintf (stderr, "**************************************************\n");
fprintf (stderr, "Warning: Your system has a gap between BSS and the\n");
- fprintf (stderr, "heap (%lu bytes). This usually means that exec-shield\n",
+ fprintf (stderr, "heap (%"pMu" bytes). This usually means that exec-shield\n",
heap_bss_diff);
fprintf (stderr, "or something similar is in effect. The dump may\n");
fprintf (stderr, "fail because of this. See the section about\n");
void
syms_of_emacs (void)
{
- Qfile_name_handler_alist = intern_c_string ("file-name-handler-alist");
- staticpro (&Qfile_name_handler_alist);
- Qrisky_local_variable = intern_c_string ("risky-local-variable");
- staticpro (&Qrisky_local_variable);
+ DEFSYM (Qfile_name_handler_alist, "file-name-handler-alist");
+ DEFSYM (Qrisky_local_variable, "risky-local-variable");
#ifndef CANNOT_DUMP
defsubr (&Sdump_emacs);