* emacs.c (setpgrp): Remove definition, unused.
[bpt/emacs.git] / src / emacs.c
index 0f7aa94..72e280c 100644 (file)
@@ -1,6 +1,6 @@
 /* Fully extensible Emacs, running on Unix, intended for GNU.
 
-Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2011
+Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2012
   Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -45,6 +45,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "commands.h"
 #include "intervals.h"
+#include "character.h"
 #include "buffer.h"
 #include "window.h"
 
@@ -65,6 +66,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "nsterm.h"
 #endif
 
+#if (defined PROFILING \
+     && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
+# include <sys/gmon.h>
+extern void moncontrol (int mode);
+#endif
+
 #ifdef HAVE_X_WINDOWS
 #include "xterm.h"
 #endif
@@ -82,39 +89,28 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/personality.h>
 #endif
 
-#ifdef HAVE_LIBXML2
-#include <libxml/parser.h>
-#endif
-
 #ifndef O_RDWR
 #define O_RDWR 2
 #endif
 
-#ifdef HAVE_SETPGID
-#if !defined (USG)
-#undef setpgrp
-#define setpgrp setpgid
-#endif
-#endif
-
 static const char emacs_version[] = VERSION;
-static const char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc.";
+static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc.";
 
 /* Make these values available in GDB, which doesn't see macros.  */
 
-#ifdef USE_LSB_TAG
+#if USE_LSB_TAG
 int gdb_use_lsb EXTERNALLY_VISIBLE = 1;
 #else
 int gdb_use_lsb EXTERNALLY_VISIBLE = 0;
 #endif
-#ifndef USE_LISP_UNION_TYPE
-int gdb_use_union EXTERNALLY_VISIBLE  = 0;
+#ifndef CHECK_LISP_OBJECT_TYPE
+int gdb_use_struct EXTERNALLY_VISIBLE = 0;
 #else
-int gdb_use_union EXTERNALLY_VISIBLE = 1;
+int gdb_use_struct EXTERNALLY_VISIBLE = 1;
 #endif
 int gdb_valbits EXTERNALLY_VISIBLE = VALBITS;
 int gdb_gctypebits EXTERNALLY_VISIBLE = GCTYPEBITS;
-#if defined (DATA_SEG_BITS) && ! defined (USE_LSB_TAG)
+#if defined DATA_SEG_BITS && !USE_LSB_TAG
 uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = DATA_SEG_BITS;
 #else
 uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = 0;
@@ -154,6 +150,8 @@ Lisp_Object Qfile_name_handler_alist;
 
 Lisp_Object Qrisky_local_variable;
 
+Lisp_Object Qkill_emacs;
+
 /* If non-zero, Emacs should not attempt to use a window-specific code,
    but instead should use the virtual terminal under which it was started.  */
 int inhibit_window_system;
@@ -319,6 +317,12 @@ static void (*fatal_error_signal_hook) (void);
 pthread_t main_thread;
 #endif
 
+#ifdef HAVE_NS
+/* NS autrelease pool, for memory management.  */
+static void *ns_pool;
+#endif
+
+
 
 /* Handle bus errors, invalid instruction, etc.  */
 #ifndef FLOAT_CATCH_SIGILL
@@ -949,7 +953,7 @@ main (int argc, char **argv)
     }
 
   /* Command line option --no-windows is deprecated and thus not mentioned
-     in the manual and usage informations.  */
+     in the manual and usage information.  */
   if (argmatch (argv, argc, "-nw", "--no-window-system", 6, NULL, &skip_args)
       || argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
     inhibit_window_system = 1;
@@ -1316,7 +1320,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
     = argmatch (argv, argc, "-nsl", "--no-site-lisp", 11, NULL, &skip_args);
 
 #ifdef HAVE_NS
-  ns_alloc_autorelease_pool ();
+  ns_pool = ns_alloc_autorelease_pool ();
   if (!noninteractive)
     {
 #ifdef NS_IMPL_COCOA
@@ -1402,7 +1406,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
 #endif
 
   /* argmatch must not be used after here,
-     except when bulding temacs
+     except when building temacs
      because the -d argument has not been skipped in skip_args.  */
 
 #ifdef MSDOS
@@ -1591,6 +1595,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
       /* Initialization that must be done even if the global variable
         initialized is non zero.  */
 #ifdef HAVE_NTGUI
+      globals_of_w32font ();
       globals_of_w32fns ();
       globals_of_w32menu ();
       globals_of_w32select ();
@@ -1659,32 +1664,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
 #ifdef PROFILING
   if (initialized)
     {
-      extern void _mcleanup ();
 #ifdef __MINGW32__
       extern unsigned char etext asm ("etext");
 #else
       extern char etext;
 #endif
-#ifdef HAVE___EXECUTABLE_START
-      /* This symbol is defined by GNU ld to the start of the text
-        segment.  */
-      extern char __executable_start[];
-#else
-      extern void safe_bcopy ();
-#endif
 
       atexit (_mcleanup);
-#ifdef HAVE___EXECUTABLE_START
-      monstartup (__executable_start, &etext);
-#else
-      /* This uses safe_bcopy because that function comes first in the
-        Emacs executable.  It might be better to use something that
-        gives the start of the text segment, but start_of_text is not
-        defined on all systems now.  */
-      /* FIXME: Does not work on architectures with function
-        descriptors.  */
-      monstartup (safe_bcopy, &etext);
-#endif
+      monstartup ((uintptr_t) __executable_start, (uintptr_t) &etext);
     }
   else
     moncontrol (0);
@@ -2012,6 +1999,10 @@ all of which are called before Emacs is actually killed.  */)
 
   shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
 
+#ifdef HAVE_NS
+  ns_release_autorelease_pool (ns_pool);
+#endif
+
   /* If we have an auto-save list file,
      kill it because we are exiting Emacs deliberately (not crashing).
      Do it after shut_down_emacs, which does an auto-save.  */
@@ -2116,7 +2107,7 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
 #endif
 
 #ifdef HAVE_LIBXML2
-  xmlCleanupParser ();
+  xml_cleanup_parser ();
 #endif
 }
 
@@ -2398,6 +2389,7 @@ syms_of_emacs (void)
 {
   DEFSYM (Qfile_name_handler_alist, "file-name-handler-alist");
   DEFSYM (Qrisky_local_variable, "risky-local-variable");
+  DEFSYM (Qkill_emacs, "kill-emacs");
 
 #ifndef CANNOT_DUMP
   defsubr (&Sdump_emacs);
@@ -2471,9 +2463,11 @@ The value is nil if that directory's name is not known.  */);
 
   DEFVAR_LISP ("installation-directory", Vinstallation_directory,
               doc: /* A directory within which to look for the `lib-src' and `etc' directories.
-This is non-nil when we can't find those directories in their standard
-installed locations, but we can find them near where the Emacs executable
-was found.  */);
+In an installed Emacs, this is normally nil.  It is non-nil if
+both `lib-src' (on MS-DOS, `info') and `etc' directories are found
+within the variable `invocation-directory' or its parent.  For example,
+this is the case when running an uninstalled Emacs executable from its
+build directory.  */);
   Vinstallation_directory = Qnil;
 
   DEFVAR_LISP ("system-messages-locale", Vsystem_messages_locale,