#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
#ifdef DOUG_LEA_MALLOC
/* Preserves a pointer to the memory allocated that copies that
static data inside glibc's malloc. */
-void *malloc_state_ptr;
+static void *malloc_state_ptr;
/* From glibc, a routine that returns a copy of the malloc internal state. */
extern void *malloc_get_state (void);
/* From glibc, a routine that overwrites the malloc internal state. */
extern int malloc_set_state (void*);
/* Non-zero if the MALLOC_CHECK_ environment variable was set while
dumping. Used to work around a bug in glibc's malloc. */
-int malloc_using_checking;
+static int malloc_using_checking;
#endif
Lisp_Object Qfile_name_handler_alist;
/* The gap between BSS end and heap start as far as we can tell. */
static unsigned long heap_bss_diff;
-/* If the gap between BSS end and heap start is larger than this
- output a warning in dump-emacs. */
-#define MAX_HEAP_BSS_DIFF (1024*1024)
-
/* Nonzero means running Emacs without interactive terminal. */
int noninteractive;
int initial_argc;
static void sort_args (int argc, char **argv);
-void syms_of_emacs (void);
+static void syms_of_emacs (void);
/* MSVC needs each string be shorter than 2048 bytes, so the usage
strings below are split to not overflow this limit. */
\f
/* Signal code for the fatal signal that was received. */
-int fatal_error_code;
+static int fatal_error_code;
/* Nonzero if handling a fatal error already. */
int fatal_error_in_progress;
/* If non-null, call this function from fatal_error_signal before
committing suicide. */
-void (*fatal_error_signal_hook) (void);
+static void (*fatal_error_signal_hook) (void);
#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
/* When compiled with GTK and running under Gnome,
/* Handle bus errors, invalid instruction, etc. */
-SIGTYPE
+#ifndef FLOAT_CATCH_SIGILL
+static
+#endif
+void
fatal_error_signal (int sig)
{
SIGNAL_THREAD_CHECK (sig);
#ifdef SIGDANGER
/* Handler for SIGDANGER. */
-SIGTYPE
+void
memory_warning_signal (sig)
int sig;
{
/* Define a dummy function F. Declare F too, to pacify gcc
-Wmissing-prototypes. */
-#define DEFINE_DUMMY_FUNCTION(f) void f (void); void f (void) {}
+#define DEFINE_DUMMY_FUNCTION(f) \
+ void f (void) EXTERNALLY_VISIBLE; void f (void) {}
#ifndef GCC_CTORS_IN_LIBC
DEFINE_DUMMY_FUNCTION (__do_global_ctors)
DEFINE_DUMMY_FUNCTION (__do_global_dtors)
/* GNU/Linux has a bug in its library; avoid an error. */
#ifndef GNU_LINUX
-char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
+char * __CTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
#endif
-char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
+char * __DTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
#endif /* GCC_CTORS_IN_LIBC */
DEFINE_DUMMY_FUNCTION (__main)
#endif /* __GNUC__ */
int nargs;
};
-const struct standard_args standard_args[] =
+static const struct standard_args standard_args[] =
{
{ "-version", "--version", 150, 0 },
{ "-chdir", "--chdir", 130, 1 },
(Lisp_Object arg)
{
struct gcpro gcpro1;
+ Lisp_Object hook;
GCPRO1 (arg);
if (feof (stdin))
arg = Qt;
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("kill-emacs-hook"));
+ hook = intern ("kill-emacs-hook");
+ Frun_hooks (1, &hook);
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,
You must run Emacs in batch mode in order to dump it. */)
(Lisp_Object filename, Lisp_Object symfile)
{
- extern char my_edata[];
Lisp_Object tem;
Lisp_Object symbol;
int count = SPECPDL_INDEX ();
error ("Dumping Emacs works only in batch mode");
#ifdef GNU_LINUX
+
+ /* Warn if the gap between BSS end and heap start is larger than this. */
+# define MAX_HEAP_BSS_DIFF (1024*1024)
+
if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
{
fprintf (stderr, "**************************************************\n");
#ifndef 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);
+ {
+ extern char my_edata[];
+ memory_warnings (my_edata, malloc_warning);
+ }
#endif /* not WINDOWSNT */
#if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT
/* Pthread may call malloc before main, and then we will get an endless
(void)
{
int nfd;
+ int err = 0;
if (!IS_DAEMON)
error ("This function can only be called if emacs is run as a daemon");
/* Get rid of stdin, stdout and stderr. */
nfd = open ("/dev/null", O_RDWR);
- dup2 (nfd, 0);
- dup2 (nfd, 1);
- dup2 (nfd, 2);
- close (nfd);
+ err |= nfd < 0;
+ err |= dup2 (nfd, 0) < 0;
+ err |= dup2 (nfd, 1) < 0;
+ err |= dup2 (nfd, 2) < 0;
+ err |= close (nfd) != 0;
/* Closing the pipe will notify the parent that it can exit.
FIXME: In case some other process inherited the pipe, closing it here
Instead, we should probably close the pipe in start-process and
call-process to make sure the pipe is never inherited by
subprocesses. */
- write (daemon_pipe[1], "\n", 1);
- close (daemon_pipe[1]);
+ err |= write (daemon_pipe[1], "\n", 1) < 0;
+ err |= close (daemon_pipe[1]) != 0;
/* Set it to an invalid value so we know we've already run this function. */
daemon_pipe[1] = -1;
+
+ if (err)
+ error ("I/O error during daemon initialization");
return Qt;
}