comparison src/emacs.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents e0db3c197671 838630c0734f
children 2a462149bd6a
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms. 1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms.
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994 2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Ben Wing. 5 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2010 Ben Wing.
6 6
7 This file is part of XEmacs. 7 This file is part of XEmacs.
8 8
9 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details. 17 for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with XEmacs; see the file COPYING. If not, write to 20 along with XEmacs; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor,
22 Boston, MA 02111-1307, USA. */ 22 Boston, MA 02111-1301, USA. */
23 23
24 /* Synched up with: Mule 2.0, FSF 19.28. */ 24 /* Synched up with: Mule 2.0, FSF 19.28. */
25 25
26 /* This file has been Mule-ized, Ben Wing, 10-7-04. */ 26 /* This file has been Mule-ized, Ben Wing, 10-7-04. */
27 27
389 redisplay.c (various scattered) 389 redisplay.c (various scattered)
390 regex.c (various scattered) 390 regex.c (various scattered)
391 sysdep.c (maybe; wait_for_termination) 391 sysdep.c (maybe; wait_for_termination)
392 unexec.c 392 unexec.c
393 unicode.c 393 unicode.c
394 xgccache.c (a bit) 394 gccache-x.c (a bit)
395 395
396 #### review .h files; write a perl program to look for long comments 396 #### review .h files; write a perl program to look for long comments
397 throughout the files, ignoring stuff inside of DEFUN's. 397 throughout the files, ignoring stuff inside of DEFUN's.
398 398
399 #### elsewhere? 399 #### elsewhere?
668 /* Nonzero means we're going down, so we better not run any hooks 668 /* Nonzero means we're going down, so we better not run any hooks
669 or do other non-essential stuff. */ 669 or do other non-essential stuff. */
670 int preparing_for_armageddon; 670 int preparing_for_armageddon;
671 671
672 /* Nonzero means we're in an unstable situation and need to skip 672 /* Nonzero means we're in an unstable situation and need to skip
673 i18n conversions and such. During printing we check for this, 673 internal->external conversions, QUIT checking and such. This gets set
674 and during conversion we abort if we see this. */ 674 during early startup, during shutdown, and when debug printing
675 (i.e. called from a debugger such as gdb to print Lisp objects or
676 backtraces). During printing we check for this, and during conversion
677 we abort if we see this. */
675 int inhibit_non_essential_conversion_operations; 678 int inhibit_non_essential_conversion_operations;
676 679
677 static JMP_BUF run_temacs_catch; 680 static JMP_BUF run_temacs_catch;
678 681
679 static int run_temacs_argc; 682 static int run_temacs_argc;
712 Lisp_Object fullpath; 715 Lisp_Object fullpath;
713 716
714 full_exe_path = mswindows_get_module_file_name (); 717 full_exe_path = mswindows_get_module_file_name ();
715 assert (full_exe_path); 718 assert (full_exe_path);
716 fullpath = build_tstr_string (full_exe_path); 719 fullpath = build_tstr_string (full_exe_path);
717 xfree (full_exe_path, Extbyte *); 720 xfree (full_exe_path);
718 result = Fcons (fullpath, result); 721 result = Fcons (fullpath, result);
719 } 722 }
720 else 723 else
721 #endif 724 #endif
722 result = Fcons (build_wext_string (argv[i], 725 result = Fcons (build_wext_string (argv[i],
745 748
746 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next)) 749 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
747 { 750 {
748 CHECK_STRING (XCAR (next)); 751 CHECK_STRING (XCAR (next));
749 752
750 LISP_STRING_TO_EXTERNAL_MALLOC (XCAR (next), (*argv) [i], 753 (*argv)[i] =
751 Qcommand_argument_encoding); 754 (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC
755 (XCAR (next), Qcommand_argument_encoding);
752 } 756 }
753 (*argv) [n] = 0; 757 (*argv) [n] = 0;
754 *argc = i; 758 *argc = i;
755 } 759 }
756 760
759 { 763 {
760 int elt = 0; 764 int elt = 0;
761 765
762 while (argv[elt]) 766 while (argv[elt])
763 { 767 {
764 xfree (argv[elt], Wexttext *); 768 xfree (argv[elt]);
765 elt++; 769 elt++;
766 } 770 }
767 xfree (argv, Wexttext **); 771 xfree (argv);
768 } 772 }
769 773
770 static void 774 static void
771 init_cmdargs (int argc, Wexttext **argv, int skip_args) 775 init_cmdargs (int argc, Wexttext **argv, int skip_args)
772 { 776 {
934 init_free_hook (); 938 init_free_hook ();
935 #endif 939 #endif
936 940
937 #define SHEBANG_PROGNAME_LENGTH \ 941 #define SHEBANG_PROGNAME_LENGTH \
938 (int)((sizeof (WEXTSTRING (SHEBANG_PROGNAME)) - sizeof (WEXTSTRING ("")))) 942 (int)((sizeof (WEXTSTRING (SHEBANG_PROGNAME)) - sizeof (WEXTSTRING (""))))
939 #define SHEBANG_EXE_PROGNAME_LENGTH \ 943 #define SHEBANG_EXE_PROGNAME_LENGTH \
940 (int)(sizeof (WEXTSTRING (SHEBANG_PROGNAME) WEXTSTRING(".exe")) \ 944 (int)(sizeof (WEXTSTRING (SHEBANG_PROGNAME) WEXTSTRING (".exe")) \
941 - sizeof (WEXTSTRING (""))) 945 - sizeof (WEXTSTRING ("")))
942 946
943 { 947 {
944 int progname_len = wext_strlen (argv[0]); 948 int progname_len = wext_strlen (argv[0]);
945 if (progname_len >= SHEBANG_PROGNAME_LENGTH) 949 if (progname_len >= SHEBANG_PROGNAME_LENGTH)
957 { 961 {
958 Wexttext **newarr = alloca_array (Wexttext *, argc + 2); 962 Wexttext **newarr = alloca_array (Wexttext *, argc + 2);
959 int j; 963 int j;
960 964
961 newarr[0] = argv[0]; 965 newarr[0] = argv[0];
962 newarr[1] = WEXTSTRING ("--script"); 966 newarr[1] = (Wexttext *) WEXTSTRING ("--script");
963 for (j = 1; j < argc; ++j) 967 for (j = 1; j < argc; ++j)
964 { 968 {
965 newarr[j + 1] = argv[j]; 969 newarr[j + 1] = argv[j];
966 } 970 }
967 argv = newarr; 971 argv = newarr;
1250 Wexttext **new_ = xnew_array (Wexttext *, argc + 2); 1254 Wexttext **new_ = xnew_array (Wexttext *, argc + 2);
1251 int j; 1255 int j;
1252 1256
1253 for (j = 0; j < count_before + 1; j++) 1257 for (j = 0; j < count_before + 1; j++)
1254 new_[j] = argv[j]; 1258 new_[j] = argv[j];
1255 new_[count_before + 1] = WEXTSTRING ("-d"); 1259 new_[count_before + 1] = (Wexttext *) WEXTSTRING ("-d");
1256 new_[count_before + 2] = dpy; 1260 new_[count_before + 2] = dpy;
1257 for (j = count_before + 2; j <argc; j++) 1261 for (j = count_before + 2; j <argc; j++)
1258 new_[j + 1] = argv[j]; 1262 new_[j + 1] = argv[j];
1259 argv = new_; 1263 argv = new_;
1260 argc++; 1264 argc++;
1261 } 1265 }
1262 /* Change --display to -d, when its arg is separate. */ 1266 /* Change --display to -d, when its arg is separate. */
1263 else if (dpy != 0 && skip_args > count_before 1267 else if (dpy != 0 && skip_args > count_before
1264 && argv[count_before + 1][1] == '-') 1268 && argv[count_before + 1][1] == '-')
1265 argv[count_before + 1] = WEXTSTRING ("-d"); 1269 argv[count_before + 1] = (Wexttext *) WEXTSTRING ("-d");
1266 1270
1267 /* Don't actually discard this arg. */ 1271 /* Don't actually discard this arg. */
1268 skip_args = count_before; 1272 skip_args = count_before;
1269 #endif /* HAVE_X_WINDOWS */ 1273 #endif /* HAVE_X_WINDOWS */
1270 } 1274 }
1639 #ifdef XIM_XLIB 1643 #ifdef XIM_XLIB
1640 syms_of_input_method_xlib (); 1644 syms_of_input_method_xlib ();
1641 #endif 1645 #endif
1642 #endif /* HAVE_XIM */ 1646 #endif /* HAVE_XIM */
1643 1647
1644 #ifdef USE_XFT 1648 #ifdef HAVE_XFT
1645 syms_of_font_mgr(); 1649 syms_of_font_mgr();
1646 #endif 1650 #endif
1647 1651
1648 #endif /* HAVE_X_WINDOWS */ 1652 #endif /* HAVE_X_WINDOWS */
1649 1653
1893 reinit_symbols_early (); 1897 reinit_symbols_early ();
1894 #ifndef NEW_GC 1898 #ifndef NEW_GC
1895 reinit_opaque_early (); 1899 reinit_opaque_early ();
1896 #endif /* not NEW_GC */ 1900 #endif /* not NEW_GC */
1897 reinit_eistring_early (); 1901 reinit_eistring_early ();
1902 #ifdef WITH_NUMBER_TYPES
1903 reinit_vars_of_number ();
1904 #endif
1898 1905
1899 reinit_console_type_create_stream (); 1906 reinit_console_type_create_stream ();
1900 #ifdef HAVE_TTY 1907 #ifdef HAVE_TTY
1901 reinit_console_type_create_tty (); 1908 reinit_console_type_create_tty ();
1902 #endif 1909 #endif
2005 the symbol isn't referenced anywhere else in the initialization 2012 the symbol isn't referenced anywhere else in the initialization
2006 code 2013 code
2007 -- Fset() on a symbol that is unbound 2014 -- Fset() on a symbol that is unbound
2008 -- Any of the object-creating functions in alloc.c: e.g. 2015 -- Any of the object-creating functions in alloc.c: e.g.
2009 - make_string() 2016 - make_string()
2010 - build_intstring() 2017 - build_istring()
2011 - build_string() 2018 - build_cistring()
2019 - build_ascstring()
2012 - make_vector() 2020 - make_vector()
2013 - make_int() 2021 - make_int()
2014 - make_char() 2022 - make_char()
2015 - make_extent() 2023 - make_extent()
2016 - ALLOC_LISP_OBJECT() 2024 - ALLOC_LISP_OBJECT()
2219 #endif 2227 #endif
2220 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_X_DIALOGS) || defined (HAVE_TOOLBARS) 2228 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_X_DIALOGS) || defined (HAVE_TOOLBARS)
2221 vars_of_gui_x (); 2229 vars_of_gui_x ();
2222 #endif 2230 #endif
2223 2231
2224 #ifdef USE_XFT 2232 #ifdef HAVE_XFT
2225 vars_of_font_mgr (); 2233 vars_of_font_mgr ();
2226 #endif 2234 #endif
2227 2235
2228 #endif /* HAVE_X_WINDOWS */ 2236 #endif /* HAVE_X_WINDOWS */
2229 2237
2290 ) 2298 )
2291 { 2299 {
2292 /* Now do additional vars_of_*() initialization that happens both 2300 /* Now do additional vars_of_*() initialization that happens both
2293 at dump time and after pdump load. */ 2301 at dump time and after pdump load. */
2294 reinit_vars_of_buffer (); 2302 reinit_vars_of_buffer ();
2303 reinit_vars_of_bytecode ();
2295 reinit_vars_of_console (); 2304 reinit_vars_of_console ();
2296 #ifdef DEBUG_XEMACS 2305 #ifdef DEBUG_XEMACS
2297 reinit_vars_of_debug (); 2306 reinit_vars_of_debug ();
2298 #endif 2307 #endif
2299 reinit_vars_of_device (); 2308 reinit_vars_of_device ();
2349 #endif 2358 #endif
2350 reinit_vars_of_select_x (); 2359 reinit_vars_of_select_x ();
2351 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_X_DIALOGS) || defined (HAVE_TOOLBARS) 2360 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_X_DIALOGS) || defined (HAVE_TOOLBARS)
2352 reinit_vars_of_gui_x (); 2361 reinit_vars_of_gui_x ();
2353 #endif 2362 #endif
2354 #ifdef USE_XFT 2363 #ifdef HAVE_XFT
2355 reinit_vars_of_font_mgr (); 2364 reinit_vars_of_font_mgr ();
2356 #endif 2365 #endif
2357 #endif /* HAVE_X_WINDOWS */ 2366 #endif /* HAVE_X_WINDOWS */
2358 2367
2359 #ifdef MULE 2368 #ifdef MULE
2409 possible that it could get changed to require being a 2418 possible that it could get changed to require being a
2410 complex_vars_of_(), for example if a charset appears anywhere, 2419 complex_vars_of_(), for example if a charset appears anywhere,
2411 then we suddenly have dependence on the previous call. */ 2420 then we suddenly have dependence on the previous call. */
2412 complex_vars_of_file_coding (); 2421 complex_vars_of_file_coding ();
2413 #ifdef WIN32_ANY 2422 #ifdef WIN32_ANY
2423 /* Define MS-Windows Unicode coding systems */
2414 complex_vars_of_intl_win32 (); 2424 complex_vars_of_intl_win32 ();
2415 #endif 2425 #endif
2426 /* Define UTF-8 coding system */
2427 complex_vars_of_unicode ();
2416 2428
2417 /* At this point we should be able to do conversion operations. 2429 /* At this point we should be able to do conversion operations.
2418 We have initialized things to the point that we can create Lisp 2430 We have initialized things to the point that we can create Lisp
2419 objects and we have defined the basic coding systems (in the 2431 objects and we have defined the basic coding systems (in the
2420 just-previous complex-vars calls). We will in fact do conversion 2432 just-previous complex-vars calls). We will in fact do conversion
2421 quite soon, e.g. in complex_vars_of_glyphs_x(). */ 2433 quite soon, e.g. in complex_vars_of_glyphs_x(). */
2422 inhibit_non_essential_conversion_operations = 0; 2434 inhibit_non_essential_conversion_operations = 0;
2423 2435
2424 #ifdef USE_XFT 2436 #ifdef HAVE_XFT
2425 /* This uses coding systems. Must be done before faces are init'ed. */ 2437 /* This uses coding systems. Must be done before faces are init'ed. */
2426 /* not in xft reloaded #3 */ 2438 /* not in xft reloaded #3 */
2427 complex_vars_of_font_mgr (); 2439 complex_vars_of_font_mgr ();
2428 #endif 2440 #endif
2429 2441
2624 { 2636 {
2625 Vinvocation_name = Fcar (Vcommand_line_args); 2637 Vinvocation_name = Fcar (Vcommand_line_args);
2626 if (XSTRING_DATA (Vinvocation_name)[0] == '-') 2638 if (XSTRING_DATA (Vinvocation_name)[0] == '-')
2627 { 2639 {
2628 /* XEmacs as a login shell, oh goody! */ 2640 /* XEmacs as a login shell, oh goody! */
2629 Vinvocation_name = build_intstring (egetenv ("SHELL")); 2641 Vinvocation_name = build_istring (egetenv ("SHELL"));
2630 } 2642 }
2631 Vinvocation_directory = Vinvocation_name; 2643 Vinvocation_directory = Vinvocation_name;
2632 2644
2633 if (!NILP (Ffile_name_directory (Vinvocation_name))) 2645 if (!NILP (Ffile_name_directory (Vinvocation_name)))
2634 { 2646 {
2910 for (i = 0; i < options[best]; i++) 2922 for (i = 0; i < options[best]; i++)
2911 argv[best + i + 1] = 0; 2923 argv[best + i + 1] = 0;
2912 } 2924 }
2913 2925
2914 memcpy (argv, new_argv, sizeof (Wexttext *) * argc); 2926 memcpy (argv, new_argv, sizeof (Wexttext *) * argc);
2915 xfree (new_argv, Wexttext **); 2927 xfree (new_argv);
2916 xfree (options, int *); 2928 xfree (options);
2917 xfree (priority, int *); 2929 xfree (priority);
2918 } 2930 }
2919 2931
2920 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* 2932 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
2921 True if running temacs. This means we are in the dumping stage. 2933 True if running temacs. This means we are in the dumping stage.
2922 This is false during normal execution of the `xemacs' program, and 2934 This is false during normal execution of the `xemacs' program, and
3000 invalid_operation ("I've lost my temacs-hood", Qunbound); 3012 invalid_operation ("I've lost my temacs-hood", Qunbound);
3001 3013
3002 run_temacs_argc = nargs + 1; 3014 run_temacs_argc = nargs + 1;
3003 run_temacs_argv = xnew_array (Wexttext *, nargs + 2); 3015 run_temacs_argv = xnew_array (Wexttext *, nargs + 2);
3004 3016
3005 LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args), 3017 run_temacs_argv[0] =
3006 run_temacs_argv[0], 3018 (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args),
3007 Qcommand_argument_encoding); 3019 Qcommand_argument_encoding);
3008 for (i = 0; i < nargs; i++) 3020 for (i = 0; i < nargs; i++)
3009 { 3021 {
3010 CHECK_STRING (args[i]); 3022 CHECK_STRING (args[i]);
3011 3023
3012 LISP_STRING_TO_EXTERNAL_MALLOC (args[i], run_temacs_argv[i + 1], 3024 run_temacs_argv[i + 1] =
3013 Qcommand_argument_encoding); 3025 (Wexttext *)
3026 LISP_STRING_TO_EXTERNAL_MALLOC (args[i], Qcommand_argument_encoding);
3014 } 3027 }
3015 run_temacs_argv[nargs + 1] = 0; 3028 run_temacs_argv[nargs + 1] = 0;
3016 3029
3017 catchlist = NULL; /* Important! Otherwise free_cons() calls in 3030 catchlist = NULL; /* Important! Otherwise free_cons() calls in
3018 condition_case_unwind() may lead to GC death. */ 3031 condition_case_unwind() may lead to GC death. */
3285 #else 3298 #else
3286 { 3299 {
3287 Extbyte *filename_ext; 3300 Extbyte *filename_ext;
3288 Extbyte *symfile_ext; 3301 Extbyte *symfile_ext;
3289 3302
3290 LISP_STRING_TO_EXTERNAL (filename, filename_ext, Qfile_name); 3303 LISP_PATHNAME_CONVERT_OUT (filename, filename_ext);
3291 3304
3292 if (STRINGP (symfile)) 3305 if (STRINGP (symfile))
3293 LISP_STRING_TO_EXTERNAL (symfile, symfile_ext, Qfile_name); 3306 LISP_PATHNAME_CONVERT_OUT (symfile, symfile_ext);
3294 else 3307 else
3295 symfile_ext = 0; 3308 symfile_ext = 0;
3296 3309
3297 # ifdef DOUG_LEA_MALLOC 3310 # ifdef DOUG_LEA_MALLOC
3298 malloc_state_ptr = malloc_get_state (); 3311 malloc_state_ptr = malloc_get_state ();
3319 3332
3320 /************************************************************************/ 3333 /************************************************************************/
3321 /* exiting XEmacs (intended or not) */ 3334 /* exiting XEmacs (intended or not) */
3322 /************************************************************************/ 3335 /************************************************************************/
3323 3336
3337 /* Do we need to pause with a message box so that messages can be read
3338 at shutdown? We do this is we have support for native Windows frames
3339 and if we are native Windows. The first part is because only when compiled
3340 for native Windows frames do we have Fmswindows_message_box(), and
3341 the second part is because we don't want to do this under Cygwin, where
3342 we have a Unix-like environment and a working stderr where the messages
3343 go. The two conditions sound somewhat redundant (maybe we could just
3344 use the second?) but they aren't completely: Theoretically (maybe with
3345 MinGW?) we could imagine compiling under native Windows as the OS
3346 but e.g. targetting only X Windows as the window system. --ben */
3347
3348 #if defined (HAVE_MS_WINDOWS) && defined (WIN32_NATIVE)
3349 # define NEED_WINDOWS_MESSAGE_PAUSE
3350 #endif
3351
3324 /* 3352 /*
3325 3353
3326 Info on intended/unintended exits: 3354 Info on intended/unintended exits:
3327 3355
3328 (Info-goto-node "(internals)Exiting") 3356 (Info-goto-node "(internals)Exiting")
3346 3374
3347 #ifdef WIN32_ANY 3375 #ifdef WIN32_ANY
3348 3376
3349 /* Return whether all bytes in the specified memory block can be read. */ 3377 /* Return whether all bytes in the specified memory block can be read. */
3350 int 3378 int
3351 debug_can_access_memory (void *ptr, Bytecount len) 3379 debug_can_access_memory (const void *ptr, Bytecount len)
3352 { 3380 {
3353 return !IsBadReadPtr (ptr, len); 3381 return !IsBadReadPtr (ptr, len);
3354 } 3382 }
3355 3383
3356 #else /* !WIN32_ANY */ 3384 #else /* !WIN32_ANY */
3365 EMACS_REESTABLISH_SIGNAL (signum, debug_memory_error); 3393 EMACS_REESTABLISH_SIGNAL (signum, debug_memory_error);
3366 EMACS_UNBLOCK_SIGNAL (signum); 3394 EMACS_UNBLOCK_SIGNAL (signum);
3367 LONGJMP (memory_error_jump, 1); 3395 LONGJMP (memory_error_jump, 1);
3368 } 3396 }
3369 3397
3398 /* Used in debug_can_access_memory(). Made into a global, externally
3399 accessible variable to make absolutely sure that no compiler will
3400 optimize away the memory-read function in debug_can_access_memory();
3401 see comments there. */
3402
3403 volatile int dcam_saveval;
3404
3370 /* Return whether all bytes in the specified memory block can be read. */ 3405 /* Return whether all bytes in the specified memory block can be read. */
3371 int 3406 int
3372 debug_can_access_memory (void *ptr, Bytecount len) 3407 debug_can_access_memory (const void *ptr, Bytecount len)
3373 { 3408 {
3374 /* Use volatile to protect variables from being clobbered by longjmp. */ 3409 /* Use volatile to protect variables from being clobbered by longjmp. */
3375 SIGTYPE (*volatile old_sigbus) (int); 3410 SIGTYPE (*volatile old_sigbus) (int);
3376 SIGTYPE (*volatile old_sigsegv) (int); 3411 SIGTYPE (*volatile old_sigsegv) (int);
3377 volatile int old_errno = errno; 3412 volatile int old_errno = errno;
3378 volatile int retval = 1; 3413 volatile int retval = 1;
3379 3414
3415 assert (len > 0);
3380 if (!SETJMP (memory_error_jump)) 3416 if (!SETJMP (memory_error_jump))
3381 { 3417 {
3382 old_sigbus = 3418 old_sigbus =
3383 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGBUS, debug_memory_error); 3419 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGBUS, debug_memory_error);
3384 old_sigsegv = 3420 old_sigsegv =
3385 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGSEGV, debug_memory_error); 3421 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGSEGV, debug_memory_error);
3386 3422
3423 /* We could just do memcmp (ptr, ptr, len), but we want to avoid any
3424 possibility that a super-optimizing compiler might optimize away such
3425 a call by concluding that its result is always 1. */
3387 if (len > 1) 3426 if (len > 1)
3388 /* If we can, try to avoid problems with super-optimizing compilers 3427 /* Instead, if length is > 1, do off-by-one comparison.
3389 that might decide that memcmp (ptr, ptr, len) can be optimized 3428 We save the value somewhere that is externally accessible to
3390 away since its result is always 1. */ 3429 make absolutely sure that a compiler won't optimize away the
3391 memcmp (ptr, (Rawbyte *) ptr + 1, len - 1); 3430 call by concluding that the return value isn't really used.
3431 */
3432 dcam_saveval = memcmp (ptr, (Rawbyte *) ptr + 1, len - 1);
3392 else 3433 else
3393 memcmp (ptr, ptr, len); 3434 {
3435 /* We can't do the off-by-one trick with only one byte, so instead,
3436 we compare to a fixed-sized buffer. */
3437 Rawbyte randval[1];
3438 randval[0] = 0;
3439 dcam_saveval = memcmp (randval, ptr, len);
3440 }
3394 } 3441 }
3395 else 3442 else
3396 retval = 0; 3443 retval = 0;
3397 EMACS_SIGNAL (SIGBUS, old_sigbus); 3444 EMACS_SIGNAL (SIGBUS, old_sigbus);
3398 EMACS_SIGNAL (SIGSEGV, old_sigsegv); 3445 EMACS_SIGNAL (SIGSEGV, old_sigsegv);
3434 dont_check_for_quit = 1; 3481 dont_check_for_quit = 1;
3435 Vinhibit_quit = Qt; 3482 Vinhibit_quit = Qt;
3436 Vquit_flag = Qnil; 3483 Vquit_flag = Qnil;
3437 } 3484 }
3438 3485
3439 #ifdef HAVE_MS_WINDOWS 3486 #ifdef NEED_WINDOWS_MESSAGE_PAUSE
3440 static void 3487 static void
3441 pause_so_user_can_read_messages (int allow_further) 3488 pause_so_user_can_read_messages (int allow_further)
3442 { 3489 {
3443 static int already_paused; 3490 static int already_paused;
3444 3491
3685 } 3732 }
3686 } 3733 }
3687 3734
3688 UNGCPRO; 3735 UNGCPRO;
3689 3736
3690 #ifdef HAVE_MS_WINDOWS 3737 #ifdef NEED_WINDOWS_MESSAGE_PAUSE
3691 pause_so_user_can_read_messages (1); 3738 pause_so_user_can_read_messages (1);
3692 #endif 3739 #endif
3693 3740
3694 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0); 3741 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0);
3695 3742
3721 popped up or somewhere else inside of an internal modal loop, we will 3768 popped up or somewhere else inside of an internal modal loop, we will
3722 get wedged when we output the "pause". (It seems that the two modal 3769 get wedged when we output the "pause". (It seems that the two modal
3723 loops will fight each other and the return key will never be passed to 3770 loops will fight each other and the return key will never be passed to
3724 the "pause" handler so that XEmacs's GPF handler can return, resignal 3771 the "pause" handler so that XEmacs's GPF handler can return, resignal
3725 the GPF, and properly go into the debugger.) */ 3772 the GPF, and properly go into the debugger.) */
3726 #if defined (ERROR_CHECK_TYPES) || defined (ERROR_CHECK_TEXT) || defined (ERROR_CHECK_GC) || defined (ERROR_CHECK_STRUCTURES) 3773 #ifdef ERROR_CHECK_ANY
3727 #define USER_IS_DEVELOPING_XEMACS 3774 #define USER_IS_DEVELOPING_XEMACS
3728 #endif 3775 #endif
3729 3776
3730 3777
3731 /* Handle bus errors, illegal instruction, etc: actual implementation. */ 3778 /* Handle bus errors, illegal instruction, etc: actual implementation. */
3777 sprintf (buf, "%s %d >&2", pstack, (int) getpid()); 3824 sprintf (buf, "%s %d >&2", pstack, (int) getpid());
3778 system (buf); 3825 system (buf);
3779 } 3826 }
3780 } 3827 }
3781 # endif 3828 # endif
3782 #if defined (HAVE_MS_WINDOWS) && !defined (USER_IS_DEVELOPING_XEMACS) 3829 #if defined (NEED_WINDOWS_MESSAGE_PAUSE) && !defined (USER_IS_DEVELOPING_XEMACS)
3783 pause_so_user_can_read_messages (0); 3830 pause_so_user_can_read_messages (0);
3784 #endif 3831 #endif
3785 } 3832 }
3786 } 3833 }
3787 3834
3936 return; 3983 return;
3937 3984
3938 /* We are extremely paranoid so we sensibly deal with recursive 3985 /* We are extremely paranoid so we sensibly deal with recursive
3939 assertion failures. */ 3986 assertion failures. */
3940 in_assert_failed++; 3987 in_assert_failed++;
3941 inhibit_non_essential_conversion_operations = 1; 3988 inhibit_non_essential_conversion_operations++;
3942 3989
3943 if (in_assert_failed >= 4) 3990 if (in_assert_failed >= 4)
3944 _exit (-1); 3991 _exit (-1);
3945 else if (in_assert_failed == 3) 3992 else if (in_assert_failed == 3)
3946 { 3993 {
4004 0); */ 4051 0); */
4005 #else 4052 #else
4006 really_abort (); 4053 really_abort ();
4007 #endif /* defined (_MSC_VER) || defined (CYGWIN) */ 4054 #endif /* defined (_MSC_VER) || defined (CYGWIN) */
4008 #endif /* !defined (ASSERTIONS_DONT_ABORT) */ 4055 #endif /* !defined (ASSERTIONS_DONT_ABORT) */
4009 inhibit_non_essential_conversion_operations = 0; 4056 inhibit_non_essential_conversion_operations--;
4010 in_assert_failed = 0; 4057 in_assert_failed--;
4011 } 4058 }
4012 4059
4013 /* -------------------------------------- */ 4060 /* -------------------------------------- */
4014 /* low-memory notification */ 4061 /* low-memory notification */
4015 /* -------------------------------------- */ 4062 /* -------------------------------------- */
4181 # define EMACS_CONFIGURATION "UNKNOWN" 4228 # define EMACS_CONFIGURATION "UNKNOWN"
4182 #endif 4229 #endif
4183 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /* 4230 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
4184 String naming the configuration XEmacs was built for. 4231 String naming the configuration XEmacs was built for.
4185 */ ); 4232 */ );
4186 Vsystem_configuration = build_string (EMACS_CONFIGURATION); 4233 Vsystem_configuration = build_ascstring (EMACS_CONFIGURATION);
4187 4234
4188 #ifndef EMACS_CONFIG_OPTIONS 4235 #ifndef EMACS_CONFIG_OPTIONS
4189 # define EMACS_CONFIG_OPTIONS "UNKNOWN" 4236 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
4190 #endif 4237 #endif
4191 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /* 4238 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
4192 String containing the configuration options XEmacs was built with. 4239 String containing the configuration options XEmacs was built with.
4193 */ ); 4240 */ );
4194 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS); 4241 Vsystem_configuration_options = build_ascstring (EMACS_CONFIG_OPTIONS);
4195 4242
4196 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /* 4243 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
4197 Major version number of this version of Emacs, as an integer. 4244 Major version number of this version of Emacs, as an integer.
4198 Warning: this variable did not exist in Emacs versions earlier than: 4245 Warning: this variable did not exist in Emacs versions earlier than:
4199 FSF Emacs: 19.23 4246 FSF Emacs: 19.23
4255 Codename of this version of Emacs (a string). 4302 Codename of this version of Emacs (a string).
4256 */ ); 4303 */ );
4257 #ifndef XEMACS_CODENAME 4304 #ifndef XEMACS_CODENAME
4258 #define XEMACS_CODENAME "Noname" 4305 #define XEMACS_CODENAME "Noname"
4259 #endif 4306 #endif
4260 Vxemacs_codename = build_string (XEMACS_CODENAME); 4307 Vxemacs_codename = build_ascstring (XEMACS_CODENAME);
4261 4308
4262 DEFVAR_LISP ("xemacs-extra-name", &Vxemacs_extra_name /* 4309 DEFVAR_LISP ("xemacs-extra-name", &Vxemacs_extra_name /*
4263 Arbitrary string to place in the version string after the codename. 4310 Arbitrary string to place in the version string after the codename.
4264 4311
4265 Appropriate surrounding whitespace will be added, but typically looks best 4312 Appropriate surrounding whitespace will be added, but typically looks best
4268 A standard use is to indicate the topmost hash id of the Mercurial 4315 A standard use is to indicate the topmost hash id of the Mercurial
4269 changeset from which XEmacs was compiled. Developers may also use it 4316 changeset from which XEmacs was compiled. Developers may also use it
4270 to indicate particular branches, etc. 4317 to indicate particular branches, etc.
4271 */ ); 4318 */ );
4272 #ifdef XEMACS_EXTRA_NAME 4319 #ifdef XEMACS_EXTRA_NAME
4273 Vxemacs_extra_name = build_string (XEMACS_EXTRA_NAME); 4320 Vxemacs_extra_name = build_ascstring (XEMACS_EXTRA_NAME);
4274 #endif 4321 #endif
4275 4322
4276 DEFVAR_LISP ("xemacs-release-date", &Vxemacs_release_date /* 4323 DEFVAR_LISP ("xemacs-release-date", &Vxemacs_release_date /*
4277 ISO 8601 format date string giving the date of latest release in series. 4324 ISO 8601 format date string giving the date of latest release in series.
4278 4325
4280 is (implicitly) UTC. Currently not included in the version string. 4327 is (implicitly) UTC. Currently not included in the version string.
4281 */ ); 4328 */ );
4282 #ifndef XEMACS_RELEASE_DATE 4329 #ifndef XEMACS_RELEASE_DATE
4283 #define XEMACS_RELEASE_DATE "2005-02-18 (defaulted in emacs.c)" 4330 #define XEMACS_RELEASE_DATE "2005-02-18 (defaulted in emacs.c)"
4284 #endif 4331 #endif
4285 Vxemacs_release_date = build_string (XEMACS_RELEASE_DATE); 4332 Vxemacs_release_date = build_ascstring (XEMACS_RELEASE_DATE);
4286 4333
4287 /* Lisp variables which contain command line flags. 4334 /* Lisp variables which contain command line flags.
4288 4335
4289 The portable dumper stomps on these; they must be saved and restored 4336 The portable dumper stomps on these; they must be saved and restored
4290 if they are processed before the call to pdump_load() in main_1(). 4337 if they are processed before the call to pdump_load() in main_1().
4449 DEFVAR_LISP ("emacs-program-name", &Vemacs_program_name /* 4496 DEFVAR_LISP ("emacs-program-name", &Vemacs_program_name /*
4450 *Name of the Emacs variant. 4497 *Name of the Emacs variant.
4451 For example, this may be \"xemacs\" or \"infodock\". 4498 For example, this may be \"xemacs\" or \"infodock\".
4452 This is mainly meant for use in path searching. 4499 This is mainly meant for use in path searching.
4453 */ ); 4500 */ );
4454 Vemacs_program_name = build_ext_string (PATH_PROGNAME, Qfile_name); 4501 Vemacs_program_name = build_extstring (PATH_PROGNAME, Qfile_name);
4455 4502
4456 DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /* 4503 DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /*
4457 *Version of the Emacs variant. 4504 *Version of the Emacs variant.
4458 This typically has the form NN.NN-bNN. 4505 This typically has the form NN.NN-bNN.
4459 This is mainly meant for use in path searching. 4506 This is mainly meant for use in path searching.
4460 */ ); 4507 */ );
4461 Vemacs_program_version = build_ext_string (PATH_VERSION, Qfile_name); 4508 Vemacs_program_version = build_extstring (PATH_VERSION, Qfile_name);
4462 4509
4463 DEFVAR_LISP ("exec-path", &Vexec_path /* 4510 DEFVAR_LISP ("exec-path", &Vexec_path /*
4464 *List of directories to search programs to run in subprocesses. 4511 *List of directories to search programs to run in subprocesses.
4465 Each element is a string (directory name) or nil (try default directory). 4512 Each element is a string (directory name) or nil (try default directory).
4466 */ ); 4513 */ );
4476 For internal use by the build procedure only. 4523 For internal use by the build procedure only.
4477 configure's idea of what `exec-directory' will be. 4524 configure's idea of what `exec-directory' will be.
4478 */ ); 4525 */ );
4479 #ifdef PATH_EXEC 4526 #ifdef PATH_EXEC
4480 Vconfigure_exec_directory = Ffile_name_as_directory 4527 Vconfigure_exec_directory = Ffile_name_as_directory
4481 (build_ext_string (PATH_EXEC, Qfile_name)); 4528 (build_extstring (PATH_EXEC, Qfile_name));
4482 #else 4529 #else
4483 Vconfigure_exec_directory = Qnil; 4530 Vconfigure_exec_directory = Qnil;
4484 #endif 4531 #endif
4485 4532
4486 DEFVAR_LISP ("lisp-directory", &Vlisp_directory /* 4533 DEFVAR_LISP ("lisp-directory", &Vlisp_directory /*
4492 For internal use by the build procedure only. 4539 For internal use by the build procedure only.
4493 configure's idea of what `lisp-directory' will be. 4540 configure's idea of what `lisp-directory' will be.
4494 */ ); 4541 */ );
4495 #ifdef PATH_LOADSEARCH 4542 #ifdef PATH_LOADSEARCH
4496 Vconfigure_lisp_directory = Ffile_name_as_directory 4543 Vconfigure_lisp_directory = Ffile_name_as_directory
4497 (build_ext_string (PATH_LOADSEARCH, Qfile_name)); 4544 (build_extstring (PATH_LOADSEARCH, Qfile_name));
4498 #else 4545 #else
4499 Vconfigure_lisp_directory = Qnil; 4546 Vconfigure_lisp_directory = Qnil;
4500 #endif 4547 #endif
4501 4548
4502 DEFVAR_LISP ("mule-lisp-directory", &Vmule_lisp_directory /* 4549 DEFVAR_LISP ("mule-lisp-directory", &Vmule_lisp_directory /*
4508 For internal use by the build procedure only. 4555 For internal use by the build procedure only.
4509 configure's idea of what `mule-lisp-directory' will be. 4556 configure's idea of what `mule-lisp-directory' will be.
4510 */ ); 4557 */ );
4511 #ifdef PATH_MULELOADSEARCH 4558 #ifdef PATH_MULELOADSEARCH
4512 Vconfigure_mule_lisp_directory = Ffile_name_as_directory 4559 Vconfigure_mule_lisp_directory = Ffile_name_as_directory
4513 (build_ext_string (PATH_MULELOADSEARCH, Qfile_name); 4560 (build_extstring (PATH_MULELOADSEARCH, Qfile_name);
4514 #else 4561 #else
4515 Vconfigure_mule_lisp_directory = Qnil; 4562 Vconfigure_mule_lisp_directory = Qnil;
4516 #endif 4563 #endif
4517 4564
4518 DEFVAR_LISP ("module-directory", &Vmodule_directory /* 4565 DEFVAR_LISP ("module-directory", &Vmodule_directory /*
4524 For internal use by the build procedure only. 4571 For internal use by the build procedure only.
4525 configure's idea of what `module-directory' will be. 4572 configure's idea of what `module-directory' will be.
4526 */ ); 4573 */ );
4527 #ifdef PATH_MODULESEARCH 4574 #ifdef PATH_MODULESEARCH
4528 Vconfigure_module_directory = Ffile_name_as_directory 4575 Vconfigure_module_directory = Ffile_name_as_directory
4529 (build_ext_string (PATH_MODULESEARCH, Qfile_name)); 4576 (build_extstring (PATH_MODULESEARCH, Qfile_name));
4530 #else 4577 #else
4531 Vconfigure_module_directory = Qnil; 4578 Vconfigure_module_directory = Qnil;
4532 #endif 4579 #endif
4533 4580
4534 DEFVAR_LISP ("configure-early-package-directories", &Vconfigure_early_package_directories /* 4581 DEFVAR_LISP ("configure-early-package-directories", &Vconfigure_early_package_directories /*
4584 For internal use by the build procedure only. 4631 For internal use by the build procedure only.
4585 configure's idea of what `data-directory' will be. 4632 configure's idea of what `data-directory' will be.
4586 */ ); 4633 */ );
4587 #ifdef PATH_DATA 4634 #ifdef PATH_DATA
4588 Vconfigure_data_directory = Ffile_name_as_directory 4635 Vconfigure_data_directory = Ffile_name_as_directory
4589 (build_ext_string (PATH_DATA, Qfile_name)); 4636 (build_extstring (PATH_DATA, Qfile_name));
4590 #else 4637 #else
4591 Vconfigure_data_directory = Qnil; 4638 Vconfigure_data_directory = Qnil;
4592 #endif 4639 #endif
4593 4640
4594 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /* 4641 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
4606 For internal use by the build procedure only. 4653 For internal use by the build procedure only.
4607 configure's idea of what `site-directory' will be. 4654 configure's idea of what `site-directory' will be.
4608 */ ); 4655 */ );
4609 #ifdef PATH_SITE 4656 #ifdef PATH_SITE
4610 Vconfigure_site_directory = Ffile_name_as_directory 4657 Vconfigure_site_directory = Ffile_name_as_directory
4611 (build_ext_string (PATH_SITE, Qfile_name)); 4658 (build_extstring (PATH_SITE, Qfile_name));
4612 #else 4659 #else
4613 Vconfigure_site_directory = Qnil; 4660 Vconfigure_site_directory = Qnil;
4614 #endif 4661 #endif
4615 4662
4616 DEFVAR_LISP ("site-module-directory", &Vsite_module_directory /* 4663 DEFVAR_LISP ("site-module-directory", &Vsite_module_directory /*
4622 For internal use by the build procedure only. 4669 For internal use by the build procedure only.
4623 configure's idea of what `site-directory' will be. 4670 configure's idea of what `site-directory' will be.
4624 */ ); 4671 */ );
4625 #ifdef PATH_SITE_MODULES 4672 #ifdef PATH_SITE_MODULES
4626 Vconfigure_site_module_directory = Ffile_name_as_directory 4673 Vconfigure_site_module_directory = Ffile_name_as_directory
4627 (build_ext_string (PATH_SITE_MODULES, Qfile_name)); 4674 (build_extstring (PATH_SITE_MODULES, Qfile_name));
4628 #else 4675 #else
4629 Vconfigure_site_module_directory = Qnil; 4676 Vconfigure_site_module_directory = Qnil;
4630 #endif 4677 #endif
4631 4678
4632 DEFVAR_LISP ("doc-directory", &Vdoc_directory /* 4679 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
4639 For internal use by the build procedure only. 4686 For internal use by the build procedure only.
4640 configure's idea of what `doc-directory' will be. 4687 configure's idea of what `doc-directory' will be.
4641 */ ); 4688 */ );
4642 #ifdef PATH_DOC 4689 #ifdef PATH_DOC
4643 Vconfigure_doc_directory = Ffile_name_as_directory 4690 Vconfigure_doc_directory = Ffile_name_as_directory
4644 (build_ext_string (PATH_DOC, Qfile_name)); 4691 (build_extstring (PATH_DOC, Qfile_name));
4645 #else 4692 #else
4646 Vconfigure_doc_directory = Qnil; 4693 Vconfigure_doc_directory = Qnil;
4647 #endif 4694 #endif
4648 4695
4649 DEFVAR_LISP ("configure-exec-prefix-directory", &Vconfigure_exec_prefix_directory /* 4696 DEFVAR_LISP ("configure-exec-prefix-directory", &Vconfigure_exec_prefix_directory /*
4650 For internal use by the build procedure only. 4697 For internal use by the build procedure only.
4651 configure's idea of what `exec-prefix-directory' will be. 4698 configure's idea of what `exec-prefix-directory' will be.
4652 */ ); 4699 */ );
4653 #ifdef PATH_EXEC_PREFIX 4700 #ifdef PATH_EXEC_PREFIX
4654 Vconfigure_exec_prefix_directory = Ffile_name_as_directory 4701 Vconfigure_exec_prefix_directory = Ffile_name_as_directory
4655 (build_ext_string (PATH_EXEC_PREFIX, Qfile_name)); 4702 (build_extstring (PATH_EXEC_PREFIX, Qfile_name));
4656 #else 4703 #else
4657 Vconfigure_exec_prefix_directory = Qnil; 4704 Vconfigure_exec_prefix_directory = Qnil;
4658 #endif 4705 #endif
4659 4706
4660 DEFVAR_LISP ("configure-prefix-directory", &Vconfigure_prefix_directory /* 4707 DEFVAR_LISP ("configure-prefix-directory", &Vconfigure_prefix_directory /*
4661 For internal use by the build procedure only. 4708 For internal use by the build procedure only.
4662 configure's idea of what `prefix-directory' will be. 4709 configure's idea of what `prefix-directory' will be.
4663 */ ); 4710 */ );
4664 #ifdef PATH_PREFIX 4711 #ifdef PATH_PREFIX
4665 Vconfigure_prefix_directory = Ffile_name_as_directory 4712 Vconfigure_prefix_directory = Ffile_name_as_directory
4666 (build_ext_string (PATH_PREFIX, Qfile_name)); 4713 (build_extstring (PATH_PREFIX, Qfile_name));
4667 #else 4714 #else
4668 Vconfigure_prefix_directory = Qnil; 4715 Vconfigure_prefix_directory = Qnil;
4669 #endif 4716 #endif
4670 4717
4671 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /* 4718 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
4674 Emacs's info files; the default value for Info-default-directory-list 4721 Emacs's info files; the default value for Info-default-directory-list
4675 includes this. 4722 includes this.
4676 */ ); 4723 */ );
4677 #ifdef PATH_INFO 4724 #ifdef PATH_INFO
4678 Vconfigure_info_directory = 4725 Vconfigure_info_directory =
4679 Ffile_name_as_directory (build_ext_string (PATH_INFO, Qfile_name)); 4726 Ffile_name_as_directory (build_extstring (PATH_INFO, Qfile_name));
4680 #else 4727 #else
4681 Vconfigure_info_directory = Qnil; 4728 Vconfigure_info_directory = Qnil;
4682 #endif 4729 #endif
4683 4730
4684 DEFVAR_LISP ("configure-info-path", &Vconfigure_info_path /* 4731 DEFVAR_LISP ("configure-info-path", &Vconfigure_info_path /*