comparison src/emacs.c @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents f0df5f687c15
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 /* Fully extensible Emacs, running on Unix, intended for GNU. 1 /* Fully extensible Emacs, running on Unix, intended for GNU.
2 Copyright (C) 1985,86,87,93,94,95,97,98,1999,2001,2002 2 Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999,
3 Free Software Foundation, Inc. 3 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to 18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02111-1307, USA. */ 20 Boston, MA 02110-1301, USA. */
21 21
22 22
23 #include <config.h> 23 #include <config.h>
24 #include <signal.h> 24 #include <signal.h>
25 #include <errno.h> 25 #include <errno.h>
38 38
39 #ifdef BSD_SYSTEM 39 #ifdef BSD_SYSTEM
40 #include <sys/ioctl.h> 40 #include <sys/ioctl.h>
41 #endif 41 #endif
42 42
43 #ifdef WINDOWSNT
44 #include <fcntl.h>
45 #include <windows.h> /* just for w32.h */
46 #include "w32.h"
47 #include "w32heap.h" /* for prototype of sbrk */
48 #endif
49
43 #include "lisp.h" 50 #include "lisp.h"
44 #include "commands.h" 51 #include "commands.h"
45 #include "intervals.h" 52 #include "intervals.h"
46 #include "buffer.h" 53 #include "buffer.h"
54 #include "window.h"
47 55
48 #include "systty.h" 56 #include "systty.h"
49 #include "blockinput.h" 57 #include "blockinput.h"
50 #include "syssignal.h" 58 #include "syssignal.h"
51 #include "process.h" 59 #include "process.h"
60 #ifdef HAVE_SETRLIMIT 68 #ifdef HAVE_SETRLIMIT
61 #include <sys/time.h> 69 #include <sys/time.h>
62 #include <sys/resource.h> 70 #include <sys/resource.h>
63 #endif 71 #endif
64 72
73 #ifdef HAVE_PERSONALITY_LINUX32
74 #include <sys/personality.h>
75 #endif
76
65 #ifndef O_RDWR 77 #ifndef O_RDWR
66 #define O_RDWR 2 78 #define O_RDWR 2
67 #endif 79 #endif
68 80
69 #ifdef HAVE_SETPGID 81 #ifdef HAVE_SETPGID
79 extern char *index P_ ((const char *, int)); 91 extern char *index P_ ((const char *, int));
80 #endif 92 #endif
81 93
82 /* Make these values available in GDB, which doesn't see macros. */ 94 /* Make these values available in GDB, which doesn't see macros. */
83 95
96 #ifdef USE_LSB_TAG
97 int gdb_use_lsb = 1;
98 #else
99 int gdb_use_lsb = 0;
100 #endif
101 #ifdef NO_UNION_TYPE
102 int gdb_use_union = 0;
103 #else
104 int gdb_use_union = 1;
105 #endif
84 EMACS_INT gdb_valbits = VALBITS; 106 EMACS_INT gdb_valbits = VALBITS;
85 EMACS_INT gdb_gctypebits = GCTYPEBITS; 107 EMACS_INT gdb_gctypebits = GCTYPEBITS;
86 EMACS_INT gdb_emacs_intbits = sizeof (EMACS_INT) * BITS_PER_CHAR;
87 #ifdef DATA_SEG_BITS 108 #ifdef DATA_SEG_BITS
88 EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS; 109 EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS;
89 #else 110 #else
90 EMACS_INT gdb_data_seg_bits = 0; 111 EMACS_INT gdb_data_seg_bits = 0;
91 #endif 112 #endif
92 EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG; 113 EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
114 EMACS_INT gdb_array_mark_flag = ARRAY_MARK_FLAG;
115 /* GDB might say "No enum type named pvec_type" if we don't have at
116 least one symbol with that type, and then xbacktrace could fail. */
117 enum pvec_type gdb_pvec_type = PVEC_TYPE_MASK;
93 118
94 /* Command line args from shell, as list of strings. */ 119 /* Command line args from shell, as list of strings. */
95 Lisp_Object Vcommand_line_args; 120 Lisp_Object Vcommand_line_args;
96 121
97 /* The name under which Emacs was invoked, with any leading directory 122 /* The name under which Emacs was invoked, with any leading directory
108 /* Hook run by `kill-emacs' before it does really anything. */ 133 /* Hook run by `kill-emacs' before it does really anything. */
109 Lisp_Object Vkill_emacs_hook; 134 Lisp_Object Vkill_emacs_hook;
110 135
111 /* An empty lisp string. To avoid having to build any other. */ 136 /* An empty lisp string. To avoid having to build any other. */
112 Lisp_Object empty_string; 137 Lisp_Object empty_string;
113
114 #ifdef SIGUSR1
115 /* Hooks for signal USR1 and USR2 handling. */
116 Lisp_Object Vsignal_USR1_hook;
117 #ifdef SIGUSR2
118 Lisp_Object Vsignal_USR2_hook;
119 #endif
120 #endif
121 138
122 /* Search path separator. */ 139 /* Search path separator. */
123 Lisp_Object Vpath_separator; 140 Lisp_Object Vpath_separator;
124 141
125 /* Set nonzero after Emacs has started up the first time. 142 /* Set nonzero after Emacs has started up the first time.
132 static data inside glibc's malloc. */ 149 static data inside glibc's malloc. */
133 void *malloc_state_ptr; 150 void *malloc_state_ptr;
134 /* From glibc, a routine that returns a copy of the malloc internal state. */ 151 /* From glibc, a routine that returns a copy of the malloc internal state. */
135 extern void *malloc_get_state (); 152 extern void *malloc_get_state ();
136 /* From glibc, a routine that overwrites the malloc internal state. */ 153 /* From glibc, a routine that overwrites the malloc internal state. */
137 extern void malloc_set_state (); 154 extern int malloc_set_state ();
138 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while 155 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
139 dumping. Used to work around a bug in glibc's malloc. */ 156 dumping. Used to work around a bug in glibc's malloc. */
140 int malloc_using_checking; 157 int malloc_using_checking;
141 #endif 158 #endif
142 159
183 200
184 /* An address near the bottom of the stack. 201 /* An address near the bottom of the stack.
185 Tells GC how to save a copy of the stack. */ 202 Tells GC how to save a copy of the stack. */
186 char *stack_bottom; 203 char *stack_bottom;
187 204
205 /* The address where the heap starts (from the first sbrk (0) call). */
206 static void *my_heap_start;
207
208 /* The gap between BSS end and heap start as far as we can tell. */
209 static unsigned long heap_bss_diff;
210
211 /* If the gap between BSS end and heap start is larger than this we try to
212 work around it, and if that fails, output a warning in dump-emacs. */
213 #define MAX_HEAP_BSS_DIFF (1024*1024)
214
215
188 #ifdef HAVE_WINDOW_SYSTEM 216 #ifdef HAVE_WINDOW_SYSTEM
189 extern Lisp_Object Vwindow_system; 217 extern Lisp_Object Vwindow_system;
190 #endif /* HAVE_WINDOW_SYSTEM */ 218 #endif /* HAVE_WINDOW_SYSTEM */
191 219
192 extern Lisp_Object Vauto_save_list_file_name; 220 extern Lisp_Object Vauto_save_list_file_name;
193 221
222 extern Lisp_Object Vinhibit_redisplay;
223
194 #ifdef USG_SHARED_LIBRARIES 224 #ifdef USG_SHARED_LIBRARIES
195 /* If nonzero, this is the place to put the end of the writable segment 225 /* If nonzero, this is the place to put the end of the writable segment
196 at startup. */ 226 at startup. */
197 227
198 unsigned int bss_end = 0; 228 unsigned int bss_end = 0;
213 int initial_argc; 243 int initial_argc;
214 244
215 static void sort_args (); 245 static void sort_args ();
216 void syms_of_emacs (); 246 void syms_of_emacs ();
217 247
248 /* MSVC needs each string be shorter than 2048 bytes, so the usage
249 strings below are split to not overflow this limit. */
218 #define USAGE1 "\ 250 #define USAGE1 "\
219 Usage: %s [OPTION-OR-FILENAME]...\n\ 251 Usage: %s [OPTION-OR-FILENAME]...\n\
220 \n\ 252 \n\
221 Run Emacs, the extensible, customizable, self-documenting real-time\n\ 253 Run Emacs, the extensible, customizable, self-documenting real-time\n\
222 display editor. The recommended way to start Emacs for normal editing\n\ 254 display editor. The recommended way to start Emacs for normal editing\n\
223 is with no options at all.\n\ 255 is with no options at all.\n\
224 \n\ 256 \n\
225 Run M-x info RET m emacs RET m command arguments RET inside Emacs to\n\ 257 Run M-x info RET m emacs RET m emacs invocation RET inside Emacs to\n\
226 read the main documentation for these command-line arguments.\n\ 258 read the main documentation for these command-line arguments.\n\
227 \n\ 259 \n\
228 Initialization options:\n\ 260 Initialization options:\n\
229 \n\ 261 \n\
230 --batch do not do interactive display; implies -q\n\ 262 --batch do not do interactive display; implies -q\n\
231 --script FILE run FILE as an Emacs Lisp script.\n\ 263 --debug-init enable Emacs Lisp debugger for init file\n\
232 --debug-init enable Emacs Lisp debugger during init file\n\ 264 --display, -d DISPLAY use X server DISPLAY\n\
233 --help display this help message and exit\n\ 265 --multibyte, --no-unibyte inhibit the effect of EMACS_UNIBYTE\n\
234 --multibyte, --no-unibyte run Emacs in multibyte mode\n\ 266 --no-desktop do not load a saved desktop\n\
235 --no-init-file, -q load neither ~/.emacs nor default.el\n\ 267 --no-init-file, -q load neither ~/.emacs nor default.el\n\
236 --no-shared-memory, -nl do not use shared memory\n\ 268 --no-shared-memory, -nl do not use shared memory\n\
237 --no-site-file do not load site-start.el\n\ 269 --no-site-file do not load site-start.el\n\
238 --no-splash do not display a splash screen on startup\n\ 270 --no-splash do not display a splash screen on startup\n\
239 --no-window-system, -nw don't communicate with X, ignoring $DISPLAY\n\ 271 --no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\
240 --terminal, -t DEVICE use DEVICE for terminal I/O\n\ 272 --quick, -Q equivalent to -q --no-site-file --no-splash\n\
273 --script FILE run FILE as an Emacs Lisp script\n\
274 --terminal, -t DEVICE use DEVICE for terminal I/O\n\
241 --unibyte, --no-multibyte run Emacs in unibyte mode\n\ 275 --unibyte, --no-multibyte run Emacs in unibyte mode\n\
242 --user, -u USER load ~USER/.emacs instead of your own\n\ 276 --user, -u USER load ~USER/.emacs instead of your own\n\
243 --version display version information and exit\n\ 277 \n%s"
244 \n\ 278
279 #define USAGE2 "\
245 Action options:\n\ 280 Action options:\n\
246 \n\ 281 \n\
247 FILE visit FILE using find-file\n\ 282 FILE visit FILE using find-file\n\
248 +LINE FILE visit FILE using find-file, then go to line LINE\n\ 283 +LINE FILE visit FILE using find-file, then go to line LINE\n\
249 +LINE:COLUMN FILE visit FILE using find-file, then go to line LINE,\n\ 284 +LINE:COLUMN FILE visit FILE using find-file, then go to line LINE,\n\
250 column COLUMN\n\ 285 column COLUMN\n\
251 --directory, -L DIR add DIR to variable load-path\n\ 286 --directory, -L DIR add DIR to variable load-path\n\
252 --eval EXPR evaluate Emacs Lisp expression EXPR\n\ 287 --eval EXPR evaluate Emacs Lisp expression EXPR\n\
253 --execute EXPR evaluate Emacs Lisp expression EXPR\n\ 288 --execute EXPR evaluate Emacs Lisp expression EXPR\n\
254 --find-file FILE visit FILE\n\ 289 --file FILE visit FILE using find-file\n\
255 --funcall, -f FUNC call Emacs function FUNC with no arguments\n\ 290 --find-file FILE visit FILE using find-file\n\
256 --insert FILE insert contents of FILE into current buffer\n\ 291 --funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
257 --kill exit without asking for confirmation\n\ 292 --insert FILE insert contents of FILE into current buffer\n\
258 --load, -l FILE load FILE of Emacs Lisp code using the load function\n\ 293 --kill exit without asking for confirmation\n\
259 --visit FILE visit FILE\n\ 294 --load, -l FILE load Emacs Lisp FILE using the load function\n\
295 --visit FILE visit FILE using find-file\n\
260 \n" 296 \n"
261 297
262 #define USAGE2 "\ 298 #define USAGE3 "\
263 Display options:\n\ 299 Display options:\n\
264 \n\ 300 \n\
265 --background-color, -bg COLOR window background color\n\ 301 --background-color, -bg COLOR window background color\n\
266 --border-color, -bd COLOR main border color\n\ 302 --basic-display, -D disable many display features;\n\
267 --border-width, -bw WIDTH width of main border\n\ 303 used for debugging Emacs\n\
268 --color=MODE color mode for character terminals;\n\ 304 --border-color, -bd COLOR main border color\n\
269 MODE defaults to `auto', and can also\n\ 305 --border-width, -bw WIDTH width of main border\n\
270 be `never', `auto', `always',\n\ 306 --color, --color=MODE color mode for character terminals;\n\
271 or a mode name like `ansi8'\n\ 307 MODE defaults to `auto', and can also\n\
272 --cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\ 308 be `never', `auto', `always',\n\
273 --display, -d DISPLAY use X server DISPLAY\n\ 309 or a mode name like `ansi8'\n\
274 --font, -fn FONT default font; must be fixed-width\n\ 310 --cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\
275 --foreground-color, -fg COLOR window foreground color\n\ 311 --font, -fn FONT default font; must be fixed-width\n\
276 --fullscreen, -fs make first frame fullscreen\n\ 312 --foreground-color, -fg COLOR window foreground color\n\
277 --fullwidth, -fw make the first frame wide as the screen\n\ 313 --fullheight, -fh make the first frame high as the screen\n\
278 --fullheight, -fh make the first frame high as the screen\n\ 314 --fullscreen, -fs make first frame fullscreen\n\
279 --geometry, -g GEOMETRY window geometry\n\ 315 --fullwidth, -fw make the first frame wide as the screen\n\
280 --iconic start Emacs in iconified state\n\ 316 --geometry, -g GEOMETRY window geometry\n\
281 --icon-type, -i use picture of gnu for Emacs icon\n\ 317 --no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
282 --internal-border, -ib WIDTH width between text and main border\n\ 318 --iconic start Emacs in iconified state\n\
283 --line-spacing, -lsp PIXELS additional space to put between lines\n\ 319 --internal-border, -ib WIDTH width between text and main border\n\
284 --mouse-color, -ms COLOR mouse cursor color in Emacs window\n\ 320 --line-spacing, -lsp PIXELS additional space to put between lines\n\
285 --name NAME title of main Emacs window\n\ 321 --mouse-color, -ms COLOR mouse cursor color in Emacs window\n\
286 --reverse-video, -r, -rv switch foreground and background\n\ 322 --name NAME title for initial Emacs frame\n\
287 --title, -T, -wn TITLE title for Emacs windows\n\ 323 --no-blinking-cursor, -nbc disable blinking cursor\n\
288 --vertical-scroll-bars, -vb enable vertical scroll bars\n\ 324 --reverse-video, -r, -rv switch foreground and background\n\
289 --xrm XRESOURCES set additional X resources\n\ 325 --title, -T TITLE title for initial Emacs frame\n\
290 \n\ 326 --vertical-scroll-bars, -vb enable vertical scroll bars\n\
327 --xrm XRESOURCES set additional X resources\n\
328 --help display this help and exit\n\
329 --version output version information and exit\n\
330 \n"
331
332 #define USAGE4 "\
291 You can generally also specify long option names with a single -; for\n\ 333 You can generally also specify long option names with a single -; for\n\
292 example, -batch as well as --batch. You can use any unambiguous\n\ 334 example, -batch as well as --batch. You can use any unambiguous\n\
293 abbreviation for a --option.\n\ 335 abbreviation for a --option.\n\
294 \n\ 336 \n\
295 Various environment variables and window system resources also affect\n\ 337 Various environment variables and window system resources also affect\n\
296 Emacs' operation. See the main documentation.\n\ 338 Emacs' operation. See the main documentation.\n\
297 \n" 339 \n\
298
299 #define USAGE3 "\
300 Report bugs to %s. First, please see the Bugs\n\ 340 Report bugs to %s. First, please see the Bugs\n\
301 section of the Emacs manual or the file BUGS.\n" 341 section of the Emacs manual or the file BUGS.\n"
302 342
303 343
304 /* Signal code for the fatal signal that was received. */ 344 /* Signal code for the fatal signal that was received. */
309 349
310 /* If non-null, call this function from fatal_error_signal before 350 /* If non-null, call this function from fatal_error_signal before
311 committing suicide. */ 351 committing suicide. */
312 352
313 void (*fatal_error_signal_hook) P_ ((void)); 353 void (*fatal_error_signal_hook) P_ ((void));
354
355 #ifdef HAVE_GTK_AND_PTHREAD
356 /* When compiled with GTK and running under Gnome, multiple threads meay be
357 created. Keep track of our main thread to make sure signals are delivered
358 to it (see syssignal.h). */
359
360 pthread_t main_thread;
361 #endif
314 362
315 363
316 #ifdef SIGUSR1 364 #ifdef SIGUSR1
317 SIGTYPE 365 SIGTYPE
318 handle_USR1_signal (sig) 366 handle_USR1_signal (sig)
319 int sig; 367 int sig;
320 { 368 {
321 struct input_event buf; 369 struct input_event buf;
322 370
371 SIGNAL_THREAD_CHECK (sig);
323 bzero (&buf, sizeof buf); 372 bzero (&buf, sizeof buf);
324 buf.kind = USER_SIGNAL_EVENT; 373 buf.kind = USER_SIGNAL_EVENT;
325 buf.frame_or_window = selected_frame; 374 buf.frame_or_window = selected_frame;
326 375
327 kbd_buffer_store_event (&buf); 376 kbd_buffer_store_event (&buf);
333 handle_USR2_signal (sig) 382 handle_USR2_signal (sig)
334 int sig; 383 int sig;
335 { 384 {
336 struct input_event buf; 385 struct input_event buf;
337 386
387 SIGNAL_THREAD_CHECK (sig);
338 bzero (&buf, sizeof buf); 388 bzero (&buf, sizeof buf);
339 buf.kind = USER_SIGNAL_EVENT; 389 buf.kind = USER_SIGNAL_EVENT;
340 buf.code = 1; 390 buf.code = 1;
341 buf.frame_or_window = selected_frame; 391 buf.frame_or_window = selected_frame;
342 392
347 /* Handle bus errors, invalid instruction, etc. */ 397 /* Handle bus errors, invalid instruction, etc. */
348 SIGTYPE 398 SIGTYPE
349 fatal_error_signal (sig) 399 fatal_error_signal (sig)
350 int sig; 400 int sig;
351 { 401 {
402 SIGNAL_THREAD_CHECK (sig);
352 fatal_error_code = sig; 403 fatal_error_code = sig;
353 signal (sig, SIG_DFL); 404 signal (sig, SIG_DFL);
354 405
355 TOTALLY_UNBLOCK_INPUT; 406 TOTALLY_UNBLOCK_INPUT;
356 407
386 SIGTYPE 437 SIGTYPE
387 memory_warning_signal (sig) 438 memory_warning_signal (sig)
388 int sig; 439 int sig;
389 { 440 {
390 signal (sig, memory_warning_signal); 441 signal (sig, memory_warning_signal);
442 SIGNAL_THREAD_CHECK (sig);
391 443
392 malloc_warning ("Operating system warns that virtual memory is running low.\n"); 444 malloc_warning ("Operating system warns that virtual memory is running low.\n");
393 445
394 /* It might be unsafe to call do_auto_save now. */ 446 /* It might be unsafe to call do_auto_save now. */
395 force_auto_save_soon (); 447 force_auto_save_soon ();
548 Vcommand_line_args = Qnil; 600 Vcommand_line_args = Qnil;
549 601
550 for (i = argc - 1; i >= 0; i--) 602 for (i = argc - 1; i >= 0; i--)
551 { 603 {
552 if (i == 0 || i > skip_args) 604 if (i == 0 || i > skip_args)
605 /* For the moment, we keep arguments as is in unibyte strings.
606 They are decoded in the function command-line after we know
607 locale-coding-system. */
553 Vcommand_line_args 608 Vcommand_line_args
554 = Fcons (build_string (argv[i]), Vcommand_line_args); 609 = Fcons (make_unibyte_string (argv[i], strlen (argv[i])),
610 Vcommand_line_args);
555 } 611 }
556 612
557 unbind_to (count, Qnil); 613 unbind_to (count, Qnil);
558 } 614 }
559 615
599 {} 655 {}
600 void __do_global_ctors_aux () 656 void __do_global_ctors_aux ()
601 {} 657 {}
602 void __do_global_dtors () 658 void __do_global_dtors ()
603 {} 659 {}
604 /* Linux has a bug in its library; avoid an error. */ 660 /* GNU/Linux has a bug in its library; avoid an error. */
605 #ifndef GNU_LINUX 661 #ifndef GNU_LINUX
606 char * __CTOR_LIST__[2] = { (char *) (-1), 0 }; 662 char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
607 #endif 663 #endif
608 char * __DTOR_LIST__[2] = { (char *) (-1), 0 }; 664 char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
609 #endif /* GCC_CTORS_IN_LIBC */ 665 #endif /* GCC_CTORS_IN_LIBC */
712 break; 768 break;
713 } 769 }
714 } 770 }
715 771
716 malloc_set_state (malloc_state_ptr); 772 malloc_set_state (malloc_state_ptr);
773 #ifndef XMALLOC_OVERRUN_CHECK
717 free (malloc_state_ptr); 774 free (malloc_state_ptr);
775 #endif
718 } 776 }
719 else 777 else
720 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; 778 {
779 if (my_heap_start == 0)
780 my_heap_start = sbrk (0);
781 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
782 }
721 } 783 }
722 784
723 void (*__malloc_initialize_hook) () = malloc_initialize_hook; 785 void (*__malloc_initialize_hook) () = malloc_initialize_hook;
724 786
725 #endif /* DOUG_LEA_MALLOC */ 787 #endif /* DOUG_LEA_MALLOC */
790 852
791 #if GC_MARK_STACK 853 #if GC_MARK_STACK
792 extern Lisp_Object *stack_base; 854 extern Lisp_Object *stack_base;
793 stack_base = &dummy; 855 stack_base = &dummy;
794 #endif 856 #endif
857
858 if (!initialized)
859 {
860 extern char my_endbss[];
861 extern char *my_endbss_static;
862
863 if (my_heap_start == 0)
864 my_heap_start = sbrk (0);
865
866 heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static);
867 }
795 868
796 #ifdef LINUX_SBRK_BUG 869 #ifdef LINUX_SBRK_BUG
797 __sbrk (1); 870 __sbrk (1);
798 #endif 871 #endif
799 872
824 exit (1); 897 exit (1);
825 } 898 }
826 else 899 else
827 { 900 {
828 printf ("GNU Emacs %s\n", SDATA (tem)); 901 printf ("GNU Emacs %s\n", SDATA (tem));
829 printf ("Copyright (C) 2002 Free Software Foundation, Inc.\n"); 902 printf ("Copyright (C) 2006 Free Software Foundation, Inc.\n");
830 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n"); 903 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
831 printf ("You may redistribute copies of Emacs\n"); 904 printf ("You may redistribute copies of Emacs\n");
832 printf ("under the terms of the GNU General Public License.\n"); 905 printf ("under the terms of the GNU General Public License.\n");
833 printf ("For more information about these matters, "); 906 printf ("For more information about these matters, ");
834 printf ("see the file named COPYING.\n"); 907 printf ("see the file named COPYING.\n");
835 exit (0); 908 exit (0);
836 } 909 }
837 } 910 }
911
912 #ifdef HAVE_PERSONALITY_LINUX32
913 /* See if there is a gap between the end of BSS and the heap.
914 In that case, set personality and exec ourself again. */
915 if (!initialized
916 && (strcmp (argv[argc-1], "dump") == 0
917 || strcmp (argv[argc-1], "bootstrap") == 0)
918 && heap_bss_diff > MAX_HEAP_BSS_DIFF)
919 {
920 if (! getenv ("EMACS_HEAP_EXEC"))
921 {
922 /* Set this so we only do this once. */
923 putenv("EMACS_HEAP_EXEC=true");
924
925 /* A flag to turn off address randomization which is introduced
926 in linux kernel shipped with fedora core 4 */
927 #define ADD_NO_RANDOMIZE 0x0040000
928 personality (PER_LINUX32 | ADD_NO_RANDOMIZE);
929 #undef ADD_NO_RANDOMIZE
930
931 execvp (argv[0], argv);
932
933 /* If the exec fails, try to dump anyway. */
934 perror ("execvp");
935 }
936 }
937 #endif /* HAVE_PERSONALITY_LINUX32 */
938
838 939
839 /* Map in shared memory, if we are using that. */ 940 /* Map in shared memory, if we are using that. */
840 #ifdef HAVE_SHM 941 #ifdef HAVE_SHM
841 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) 942 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
842 { 943 {
862 } 963 }
863 #endif /* NeXT */ 964 #endif /* NeXT */
864 965
865 #ifdef MAC_OSX 966 #ifdef MAC_OSX
866 /* Skip process serial number passed in the form -psn_x_y as 967 /* Skip process serial number passed in the form -psn_x_y as
867 command-line argument. */ 968 command-line argument. The WindowServer adds this option when
969 Emacs is invoked from the Finder or by the `open' command. In
970 these cases, the working directory becomes `/', so we change it
971 to the user's home directory. */
868 if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0) 972 if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0)
869 skip_args++; 973 {
974 chdir (getenv ("HOME"));
975 skip_args++;
976 }
870 #endif /* MAC_OSX */ 977 #endif /* MAC_OSX */
871 978
872 #ifdef VMS 979 #ifdef VMS
873 /* If -map specified, map the data file in. */ 980 /* If -map specified, map the data file in. */
874 { 981 {
875 char *file; 982 char *file;
876 if (argmatch (argv, argc, "-map", "--map-data", 3, &mapin_file, &skip_args)) 983 if (argmatch (argv, argc, "-map", "--map-data", 3, &file, &skip_args))
877 mapin_data (file); 984 mapin_data (file);
878 } 985 }
879 986
880 #ifdef LINK_CRTL_SHARE 987 #ifdef LINK_CRTL_SHARE
881 #ifdef SHARABLE_LIB_BUG 988 #ifdef SHARABLE_LIB_BUG
901 && (!noninteractive || initialized) 1008 && (!noninteractive || initialized)
902 #endif 1009 #endif
903 && !getrlimit (RLIMIT_STACK, &rlim)) 1010 && !getrlimit (RLIMIT_STACK, &rlim))
904 { 1011 {
905 long newlim; 1012 long newlim;
906 extern int re_max_failures; 1013 extern size_t re_max_failures;
907 /* Approximate the amount regex.c needs per unit of re_max_failures. */ 1014 /* Approximate the amount regex.c needs per unit of re_max_failures. */
908 int ratio = 20 * sizeof (char *); 1015 int ratio = 20 * sizeof (char *);
909 /* Then add 33% to cover the size of the smaller stacks that regex.c 1016 /* Then add 33% to cover the size of the smaller stacks that regex.c
910 successively allocates and discards, on its way to the maximum. */ 1017 successively allocates and discards, on its way to the maximum. */
911 ratio += ratio / 3; 1018 ratio += ratio / 3;
948 1055
949 /* Call malloc at least once, to run the initial __malloc_hook. 1056 /* Call malloc at least once, to run the initial __malloc_hook.
950 Also call realloc and free for consistency. */ 1057 Also call realloc and free for consistency. */
951 free (realloc (malloc (4), 4)); 1058 free (realloc (malloc (4), 4));
952 1059
1060 # ifndef SYNC_INPUT
953 /* Arrange to disable interrupt input inside malloc etc. */ 1061 /* Arrange to disable interrupt input inside malloc etc. */
954 uninterrupt_malloc (); 1062 uninterrupt_malloc ();
1063 # endif /* not SYNC_INPUT */
955 #endif /* not SYSTEM_MALLOC */ 1064 #endif /* not SYSTEM_MALLOC */
956 1065
957 #ifdef MSDOS 1066 #ifdef HAVE_GTK_AND_PTHREAD
1067 main_thread = pthread_self ();
1068 #endif /* HAVE_GTK_AND_PTHREAD */
1069
1070 #if defined (MSDOS) || defined (WINDOWSNT)
958 /* We do all file input/output as binary files. When we need to translate 1071 /* We do all file input/output as binary files. When we need to translate
959 newlines, we do that manually. */ 1072 newlines, we do that manually. */
960 _fmode = O_BINARY; 1073 _fmode = O_BINARY;
961 1074 #endif /* MSDOS || WINDOWSNT */
1075
1076 #ifdef MSDOS
962 #if __DJGPP__ >= 2 1077 #if __DJGPP__ >= 2
963 if (!isatty (fileno (stdin))) 1078 if (!isatty (fileno (stdin)))
964 setmode (fileno (stdin), O_BINARY); 1079 setmode (fileno (stdin), O_BINARY);
965 if (!isatty (fileno (stdout))) 1080 if (!isatty (fileno (stdout)))
966 { 1081 {
1038 inhibit_window_system = 1; 1153 inhibit_window_system = 1;
1039 1154
1040 /* Handle the -batch switch, which means don't do interactive display. */ 1155 /* Handle the -batch switch, which means don't do interactive display. */
1041 noninteractive = 0; 1156 noninteractive = 0;
1042 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args)) 1157 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
1043 noninteractive = 1; 1158 {
1159 noninteractive = 1;
1160 Vundo_outer_limit = Qnil;
1161 }
1044 if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args)) 1162 if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args))
1045 { 1163 {
1046 noninteractive = 1; /* Set batch mode. */ 1164 noninteractive = 1; /* Set batch mode. */
1047 /* Convert --script to -l, un-skip it, and sort again so that -l will be 1165 /* Convert --script to --scriptload, un-skip it, and sort again
1048 handled in proper sequence. */ 1166 so that it will be handled in proper sequence. */
1049 argv[skip_args - 1] = "-l"; 1167 argv[skip_args - 1] = "-scriptload";
1050 skip_args -= 2; 1168 skip_args -= 2;
1051 sort_args (argc, argv); 1169 sort_args (argc, argv);
1052 } 1170 }
1053 1171
1054 /* Handle the --help option, which gives a usage message. */ 1172 /* Handle the --help option, which gives a usage message. */
1055 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args)) 1173 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
1056 { 1174 {
1057 printf (USAGE1, argv[0]); 1175 printf (USAGE1, argv[0], USAGE2);
1058 printf (USAGE2); 1176 printf (USAGE3);
1059 printf (USAGE3, bug_reporting_address ()); 1177 printf (USAGE4, bug_reporting_address ());
1060 exit (0); 1178 exit (0);
1061 } 1179 }
1062 1180
1063 if (! noninteractive) 1181 if (! noninteractive)
1064 { 1182 {
1208 #ifdef MAC_OS8 1326 #ifdef MAC_OS8
1209 /* init_window_once calls make_terminal_frame which on Mac OS 1327 /* init_window_once calls make_terminal_frame which on Mac OS
1210 creates a full-fledge output_mac type frame. This does not 1328 creates a full-fledge output_mac type frame. This does not
1211 work correctly before syms_of_textprop, syms_of_macfns, 1329 work correctly before syms_of_textprop, syms_of_macfns,
1212 syms_of_ccl, syms_of_fontset, syms_of_xterm, syms_of_search, 1330 syms_of_ccl, syms_of_fontset, syms_of_xterm, syms_of_search,
1213 syms_of_frame, mac_initialize, and init_keyboard have already 1331 syms_of_frame, mac_term_init, and init_keyboard have already
1214 been called. */ 1332 been called. */
1215 syms_of_textprop (); 1333 syms_of_textprop ();
1216 syms_of_macfns (); 1334 syms_of_macfns ();
1217 syms_of_ccl (); 1335 syms_of_ccl ();
1218 syms_of_fontset (); 1336 syms_of_fontset ();
1219 syms_of_macterm (); 1337 syms_of_macterm ();
1220 syms_of_macmenu (); 1338 syms_of_macmenu ();
1339 syms_of_macselect ();
1221 syms_of_data (); 1340 syms_of_data ();
1222 syms_of_search (); 1341 syms_of_search ();
1223 syms_of_frame (); 1342 syms_of_frame ();
1224 1343
1225 mac_initialize (); 1344 init_atimer ();
1345 mac_term_init (build_string ("Mac"), NULL, NULL);
1226 init_keyboard (); 1346 init_keyboard ();
1227 #endif 1347 #endif
1228 1348
1229 init_window_once (); /* Init the window system. */ 1349 init_window_once (); /* Init the window system. */
1230 init_fileio_once (); /* Must precede any path manipulation. */ 1350 init_fileio_once (); /* Must precede any path manipulation. */
1351 #ifdef HAVE_WINDOW_SYSTEM
1352 init_fringe_once (); /* Swap bitmaps if necessary. */
1353 #endif /* HAVE_WINDOW_SYSTEM */
1231 } 1354 }
1232 1355
1233 init_alloc (); 1356 init_alloc ();
1234 1357
1235 if (do_initial_setlocale) 1358 if (do_initial_setlocale)
1242 init_eval (); 1365 init_eval ();
1243 init_data (); 1366 init_data ();
1244 #ifdef CLASH_DETECTION 1367 #ifdef CLASH_DETECTION
1245 init_filelock (); 1368 init_filelock ();
1246 #endif 1369 #endif
1370 #ifndef MAC_OS8
1247 init_atimer (); 1371 init_atimer ();
1372 #endif
1248 running_asynch_code = 0; 1373 running_asynch_code = 0;
1249 1374
1250 /* Handle --unibyte and the EMACS_UNIBYTE envvar, 1375 /* Handle --unibyte and the EMACS_UNIBYTE envvar,
1251 but not while dumping. */ 1376 but not while dumping. */
1252 if (1) 1377 if (1)
1379 /* Initialize environment from registry settings. */ 1504 /* Initialize environment from registry settings. */
1380 init_environment (argv); 1505 init_environment (argv);
1381 init_ntproc (); /* must precede init_editfns. */ 1506 init_ntproc (); /* must precede init_editfns. */
1382 #endif 1507 #endif
1383 1508
1384 #ifdef HAVE_CARBON 1509 #if defined (MAC_OSX) && defined (HAVE_CARBON)
1385 if (initialized) 1510 if (initialized)
1386 init_mac_osx_environment (); 1511 init_mac_osx_environment ();
1387 #endif 1512 #endif
1388 1513
1389 /* egetenv is a pretty low-level facility, which may get called in 1514 /* egetenv is a pretty low-level facility, which may get called in
1490 #ifdef WINDOWSNT 1615 #ifdef WINDOWSNT
1491 syms_of_ntproc (); 1616 syms_of_ntproc ();
1492 #endif /* WINDOWSNT */ 1617 #endif /* WINDOWSNT */
1493 syms_of_window (); 1618 syms_of_window ();
1494 syms_of_xdisp (); 1619 syms_of_xdisp ();
1620 #ifdef HAVE_WINDOW_SYSTEM
1621 syms_of_fringe ();
1622 syms_of_image ();
1623 #endif /* HAVE_WINDOW_SYSTEM */
1495 #ifdef HAVE_X_WINDOWS 1624 #ifdef HAVE_X_WINDOWS
1496 syms_of_xterm (); 1625 syms_of_xterm ();
1497 syms_of_xfns (); 1626 syms_of_xfns ();
1498 syms_of_fontset (); 1627 syms_of_fontset ();
1499 #ifdef HAVE_X_SM 1628 #ifdef HAVE_X_SM
1517 syms_of_w32select (); 1646 syms_of_w32select ();
1518 syms_of_w32menu (); 1647 syms_of_w32menu ();
1519 syms_of_fontset (); 1648 syms_of_fontset ();
1520 #endif /* HAVE_NTGUI */ 1649 #endif /* HAVE_NTGUI */
1521 1650
1522 #ifdef HAVE_CARBON 1651 #if defined (MAC_OSX) && defined (HAVE_CARBON)
1523 syms_of_macterm (); 1652 syms_of_macterm ();
1524 syms_of_macfns (); 1653 syms_of_macfns ();
1525 syms_of_macmenu (); 1654 syms_of_macmenu ();
1655 syms_of_macselect ();
1526 syms_of_fontset (); 1656 syms_of_fontset ();
1527 #endif /* HAVE_CARBON */ 1657 #endif /* MAC_OSX && HAVE_CARBON */
1528 1658
1529 #ifdef SYMS_SYSTEM 1659 #ifdef SYMS_SYSTEM
1530 SYMS_SYSTEM; 1660 SYMS_SYSTEM;
1531 #endif 1661 #endif
1532 1662
1540 keys_of_keyboard (); 1670 keys_of_keyboard ();
1541 keys_of_keymap (); 1671 keys_of_keymap ();
1542 keys_of_minibuf (); 1672 keys_of_minibuf ();
1543 keys_of_window (); 1673 keys_of_window ();
1544 } 1674 }
1545 else 1675 else
1546 { 1676 {
1547 /* 1677 /* Initialization that must be done even if the global variable
1548 Initialization that must be done even if the global variable 1678 initialized is non zero. */
1549 initialized is non zero
1550 */
1551 #ifdef HAVE_NTGUI 1679 #ifdef HAVE_NTGUI
1552 globals_of_w32fns (); 1680 globals_of_w32fns ();
1553 globals_of_w32menu (); 1681 globals_of_w32menu ();
1554 #endif /* end #ifdef HAVE_NTGUI */ 1682 globals_of_w32select ();
1683 #endif /* HAVE_NTGUI */
1555 } 1684 }
1556 1685
1557 if (!noninteractive) 1686 if (!noninteractive)
1558 { 1687 {
1559 #ifdef VMS 1688 #ifdef VMS
1567 #endif 1696 #endif
1568 #ifdef VMS 1697 #ifdef VMS
1569 init_vmsproc (); /* And this too. */ 1698 init_vmsproc (); /* And this too. */
1570 #endif /* VMS */ 1699 #endif /* VMS */
1571 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.). */ 1700 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.). */
1572 #if defined (HAVE_X_WINDOWS) || defined (WINDOWSNT)
1573 init_xfns ();
1574 #endif /* HAVE_X_WINDOWS */
1575 init_fns (); 1701 init_fns ();
1576 init_xdisp (); 1702 init_xdisp ();
1703 #ifdef HAVE_WINDOW_SYSTEM
1704 init_fringe ();
1705 init_image ();
1706 #endif /* HAVE_WINDOW_SYSTEM */
1577 init_macros (); 1707 init_macros ();
1578 init_editfns (); 1708 init_editfns ();
1579 init_floatfns (); 1709 init_floatfns ();
1580 #ifdef VMS 1710 #ifdef VMS
1581 init_vmsfns (); 1711 init_vmsfns ();
1696 { "-nl", "--no-loadup", 70, 0 }, 1826 { "-nl", "--no-loadup", 70, 0 },
1697 /* -d must come last before the options handled in startup.el. */ 1827 /* -d must come last before the options handled in startup.el. */
1698 { "-d", "--display", 60, 1 }, 1828 { "-d", "--display", 60, 1 },
1699 { "-display", 0, 60, 1 }, 1829 { "-display", 0, 60, 1 },
1700 /* Now for the options handled in startup.el. */ 1830 /* Now for the options handled in startup.el. */
1831 { "-Q", "--quick", 55, 0 },
1832 { "-quick", 0, 55, 0 },
1701 { "-q", "--no-init-file", 50, 0 }, 1833 { "-q", "--no-init-file", 50, 0 },
1702 { "-no-init-file", 0, 50, 0 }, 1834 { "-no-init-file", 0, 50, 0 },
1703 { "-no-site-file", "--no-site-file", 40, 0 }, 1835 { "-no-site-file", "--no-site-file", 40, 0 },
1704 { "-no-splash", "--no-splash", 40, 0 }, 1836 { "-no-splash", "--no-splash", 40, 0 },
1705 { "-u", "--user", 30, 1 }, 1837 { "-u", "--user", 30, 1 },
1706 { "-user", 0, 30, 1 }, 1838 { "-user", 0, 30, 1 },
1707 { "-debug-init", "--debug-init", 20, 0 }, 1839 { "-debug-init", "--debug-init", 20, 0 },
1708 { "-i", "--icon-type", 15, 0 }, 1840 { "-nbi", "--no-bitmap-icon", 15, 0 },
1709 { "-itype", 0, 15, 0 },
1710 { "-iconic", "--iconic", 15, 0 }, 1841 { "-iconic", "--iconic", 15, 0 },
1842 { "-D", "--basic-display", 12, 0},
1843 { "-basic-display", 0, 12, 0},
1711 { "-bg", "--background-color", 10, 1 }, 1844 { "-bg", "--background-color", 10, 1 },
1712 { "-background", 0, 10, 1 }, 1845 { "-background", 0, 10, 1 },
1713 { "-fg", "--foreground-color", 10, 1 }, 1846 { "-fg", "--foreground-color", 10, 1 },
1714 { "-foreground", 0, 10, 1 }, 1847 { "-foreground", 0, 10, 1 },
1715 { "-bd", "--border-color", 10, 1 }, 1848 { "-bd", "--border-color", 10, 1 },
1716 { "-bw", "--border-width", 10, 1 }, 1849 { "-bw", "--border-width", 10, 1 },
1717 { "-ib", "--internal-border", 10, 1 }, 1850 { "-ib", "--internal-border", 10, 1 },
1718 { "-ms", "--mouse-color", 10, 1 }, 1851 { "-ms", "--mouse-color", 10, 1 },
1719 { "-cr", "--cursor-color", 10, 1 }, 1852 { "-cr", "--cursor-color", 10, 1 },
1853 { "-nbc", "--no-blinking-cursor", 10, 0 },
1720 { "-fn", "--font", 10, 1 }, 1854 { "-fn", "--font", 10, 1 },
1721 { "-font", 0, 10, 1 }, 1855 { "-font", 0, 10, 1 },
1722 { "-fs", "--fullscreen", 10, 0 }, 1856 { "-fs", "--fullscreen", 10, 0 },
1723 { "-fw", "--fullwidth", 10, 0 }, 1857 { "-fw", "--fullwidth", 10, 0 },
1724 { "-fh", "--fullheight", 10, 0 }, 1858 { "-fh", "--fullheight", 10, 0 },
1738 so they are not reordered with respect to those. */ 1872 so they are not reordered with respect to those. */
1739 { "-L", "--directory", 0, 1 }, 1873 { "-L", "--directory", 0, 1 },
1740 { "-directory", 0, 0, 1 }, 1874 { "-directory", 0, 0, 1 },
1741 { "-l", "--load", 0, 1 }, 1875 { "-l", "--load", 0, 1 },
1742 { "-load", 0, 0, 1 }, 1876 { "-load", 0, 0, 1 },
1877 { "-scriptload", "--scriptload", 0, 1 },
1743 { "-f", "--funcall", 0, 1 }, 1878 { "-f", "--funcall", 0, 1 },
1744 { "-funcall", 0, 0, 1 }, 1879 { "-funcall", 0, 0, 1 },
1745 { "-eval", "--eval", 0, 1 }, 1880 { "-eval", "--eval", 0, 1 },
1746 { "-execute", "--execute", 0, 1 }, 1881 { "-execute", "--execute", 0, 1 },
1747 { "-find-file", "--find-file", 0, 1 }, 1882 { "-find-file", "--find-file", 0, 1 },
1901 while (to < argc) 2036 while (to < argc)
1902 new[to++] = 0; 2037 new[to++] = 0;
1903 2038
1904 bcopy (new, argv, sizeof (char *) * argc); 2039 bcopy (new, argv, sizeof (char *) * argc);
1905 2040
1906 free (options); 2041 xfree (options);
1907 free (new); 2042 xfree (new);
1908 free (priority); 2043 xfree (priority);
1909 } 2044 }
1910 2045
1911 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", 2046 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
1912 doc: /* Exit the Emacs job and kill it. 2047 doc: /* Exit the Emacs job and kill it.
1913 If ARG is an integer, return ARG as the exit program code. 2048 If ARG is an integer, return ARG as the exit program code.
1943 kill it because we are exiting Emacs deliberately (not crashing). 2078 kill it because we are exiting Emacs deliberately (not crashing).
1944 Do it after shut_down_emacs, which does an auto-save. */ 2079 Do it after shut_down_emacs, which does an auto-save. */
1945 if (STRINGP (Vauto_save_list_file_name)) 2080 if (STRINGP (Vauto_save_list_file_name))
1946 unlink (SDATA (Vauto_save_list_file_name)); 2081 unlink (SDATA (Vauto_save_list_file_name));
1947 2082
1948 exit (INTEGERP (arg) ? XINT (arg) 2083 exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS);
1949 #ifdef VMS
1950 : 1
1951 #else
1952 : 0
1953 #endif
1954 );
1955 /* NOTREACHED */ 2084 /* NOTREACHED */
2085 return Qnil;
1956 } 2086 }
1957 2087
1958 2088
1959 /* Perform an orderly shutdown of Emacs. Autosave any modified 2089 /* Perform an orderly shutdown of Emacs. Autosave any modified
1960 buffers, kill any child processes, clean up the terminal modes (if 2090 buffers, kill any child processes, clean up the terminal modes (if
1973 Lisp_Object stuff; 2103 Lisp_Object stuff;
1974 { 2104 {
1975 /* Prevent running of hooks from now on. */ 2105 /* Prevent running of hooks from now on. */
1976 Vrun_hooks = Qnil; 2106 Vrun_hooks = Qnil;
1977 2107
2108 /* Don't update display from now on. */
2109 Vinhibit_redisplay = Qt;
2110
1978 /* If we are controlling the terminal, reset terminal modes. */ 2111 /* If we are controlling the terminal, reset terminal modes. */
1979 #ifdef EMACS_HAVE_TTY_PGRP 2112 #ifdef EMACS_HAVE_TTY_PGRP
1980 { 2113 {
1981 int pgrp = EMACS_GETPGRP (0); 2114 int pgrp = EMACS_GETPGRP (0);
1982 2115
1985 && tpgrp == pgrp) 2118 && tpgrp == pgrp)
1986 { 2119 {
1987 fflush (stdout); 2120 fflush (stdout);
1988 reset_sys_modes (); 2121 reset_sys_modes ();
1989 if (sig && sig != SIGTERM) 2122 if (sig && sig != SIGTERM)
1990 fprintf (stderr, "Fatal error (%d).", sig); 2123 fprintf (stderr, "Fatal error (%d)", sig);
1991 } 2124 }
1992 } 2125 }
1993 #else 2126 #else
1994 fflush (stdout); 2127 fflush (stdout);
1995 reset_sys_modes (); 2128 reset_sys_modes ();
2096 2229
2097 check_pure_size (); 2230 check_pure_size ();
2098 2231
2099 if (! noninteractive) 2232 if (! noninteractive)
2100 error ("Dumping Emacs works only in batch mode"); 2233 error ("Dumping Emacs works only in batch mode");
2234
2235 #ifdef __linux__
2236 if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
2237 {
2238 fprintf (stderr, "**************************************************\n");
2239 fprintf (stderr, "Warning: Your system has a gap between BSS and the\n");
2240 fprintf (stderr, "heap (%lu byte). This usually means that exec-shield\n",
2241 heap_bss_diff);
2242 fprintf (stderr, "or something similar is in effect. The dump may\n");
2243 fprintf (stderr, "fail because of this. See the section about \n");
2244 fprintf (stderr, "exec-shield in etc/PROBLEMS for more information.\n");
2245 fprintf (stderr, "**************************************************\n");
2246 }
2247 #endif /* __linux__ */
2101 2248
2102 /* Bind `command-line-processed' to nil before dumping, 2249 /* Bind `command-line-processed' to nil before dumping,
2103 so that the dumped Emacs will process its command line 2250 so that the dumped Emacs will process its command line
2104 and set up to work with X windows if appropriate. */ 2251 and set up to work with X windows if appropriate. */
2105 symbol = intern ("command-line-processed"); 2252 symbol = intern ("command-line-processed");
2136 /* On Windows, this was done before dumping, and that once suffices. 2283 /* On Windows, this was done before dumping, and that once suffices.
2137 Meanwhile, my_edata is not valid on Windows. */ 2284 Meanwhile, my_edata is not valid on Windows. */
2138 memory_warnings (my_edata, malloc_warning); 2285 memory_warnings (my_edata, malloc_warning);
2139 #endif /* not WINDOWSNT */ 2286 #endif /* not WINDOWSNT */
2140 #endif 2287 #endif
2288 #if !defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT
2289 /* Pthread may call malloc before main, and then we will get an endless
2290 loop, because pthread_self (see alloc.c) calls malloc the first time
2291 it is called on some systems. */
2292 reset_malloc_hooks ();
2293 #endif
2141 #ifdef DOUG_LEA_MALLOC 2294 #ifdef DOUG_LEA_MALLOC
2142 malloc_state_ptr = malloc_get_state (); 2295 malloc_state_ptr = malloc_get_state ();
2143 #endif 2296 #endif
2144 2297
2145 #ifdef USE_MMAP_FOR_BUFFERS 2298 #ifdef USE_MMAP_FOR_BUFFERS
2184 { 2337 {
2185 if (! EQ (*plocale, desired_locale)) 2338 if (! EQ (*plocale, desired_locale))
2186 { 2339 {
2187 *plocale = desired_locale; 2340 *plocale = desired_locale;
2188 setlocale (category, (STRINGP (desired_locale) 2341 setlocale (category, (STRINGP (desired_locale)
2189 ? (char *)(SDATA (desired_locale)) 2342 ? (char *) SDATA (desired_locale)
2190 : "")); 2343 : ""));
2191 } 2344 }
2192 } 2345 }
2193 2346
2194 /* Set system time locale to match Vsystem_time_locale, if possible. */ 2347 /* Set system time locale to match Vsystem_time_locale, if possible. */
2301 DEFVAR_LISP ("command-line-args", &Vcommand_line_args, 2454 DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
2302 doc: /* Args passed by shell to Emacs, as a list of strings. 2455 doc: /* Args passed by shell to Emacs, as a list of strings.
2303 Many arguments are deleted from the list as they are processed. */); 2456 Many arguments are deleted from the list as they are processed. */);
2304 2457
2305 DEFVAR_LISP ("system-type", &Vsystem_type, 2458 DEFVAR_LISP ("system-type", &Vsystem_type,
2306 doc: /* Value is symbol indicating type of operating system you are using. */); 2459 doc: /* Value is symbol indicating type of operating system you are using.
2460 Special values:
2461 `gnu/linux' compiled for a GNU/Linux system.
2462 `darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...).
2463 `macos' compiled for Mac OS 9.
2464 `ms-dos' compiled as an MS-DOS application.
2465 `windows-nt' compiled as a native W32 application.
2466 `cygwin' compiled using the Cygwin library.
2467 `vax-vms' or `axp-vms': compiled for a (Open)VMS system.
2468 Anything else indicates some sort of Unix system. */);
2307 Vsystem_type = intern (SYSTEM_TYPE); 2469 Vsystem_type = intern (SYSTEM_TYPE);
2308 2470
2309 DEFVAR_LISP ("system-configuration", &Vsystem_configuration, 2471 DEFVAR_LISP ("system-configuration", &Vsystem_configuration,
2310 doc: /* Value is string indicating configuration Emacs was built for. 2472 doc: /* Value is string indicating configuration Emacs was built for.
2311 On MS-Windows, the value reflects the OS flavor and version on which 2473 On MS-Windows, the value reflects the OS flavor and version on which
2329 The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */); 2491 The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */);
2330 Vkill_emacs_hook = Qnil; 2492 Vkill_emacs_hook = Qnil;
2331 2493
2332 empty_string = build_string (""); 2494 empty_string = build_string ("");
2333 staticpro (&empty_string); 2495 staticpro (&empty_string);
2334
2335 #ifdef SIGUSR1
2336 DEFVAR_LISP ("signal-USR1-hook", &Vsignal_USR1_hook,
2337 doc: /* Hook to be run whenever emacs receives a USR1 signal. */);
2338 Vsignal_USR1_hook = Qnil;
2339 #ifdef SIGUSR2
2340 DEFVAR_LISP ("signal-USR2-hook", &Vsignal_USR2_hook,
2341 doc: /* Hook to be run whenever emacs receives a USR2 signal. */);
2342 Vsignal_USR2_hook = Qnil;
2343 #endif
2344 #endif
2345
2346 2496
2347 DEFVAR_INT ("emacs-priority", &emacs_priority, 2497 DEFVAR_INT ("emacs-priority", &emacs_priority,
2348 doc: /* Priority for Emacs to run at. 2498 doc: /* Priority for Emacs to run at.
2349 This value is effective only if set before Emacs is dumped, 2499 This value is effective only if set before Emacs is dumped,
2350 and only if the Emacs executable is installed with setuid to permit 2500 and only if the Emacs executable is installed with setuid to permit
2390 2540
2391 DEFVAR_LISP ("previous-system-time-locale", &Vprevious_system_time_locale, 2541 DEFVAR_LISP ("previous-system-time-locale", &Vprevious_system_time_locale,
2392 doc: /* Most recently used system locale for time. */); 2542 doc: /* Most recently used system locale for time. */);
2393 Vprevious_system_time_locale = Qnil; 2543 Vprevious_system_time_locale = Qnil;
2394 } 2544 }
2545
2546 /* arch-tag: 7bfd356a-c720-4612-8ab6-aa4222931c2e
2547 (do not change this comment) */