diff options
author | Daniel Colascione <dancol@dancol.org> | 2012-09-17 04:07:36 -0800 |
---|---|---|
committer | Daniel Colascione <dancol@dancol.org> | 2012-09-17 04:07:36 -0800 |
commit | 2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch) | |
tree | 6dd6784d63e54cb18071df8e28fbdbc27d418728 /src | |
parent | f701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff) | |
parent | bb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff) | |
download | emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz |
Merge from trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/.gdbinit | 11 | ||||
-rw-r--r-- | src/ChangeLog | 924 | ||||
-rw-r--r-- | src/Makefile.in | 11 | ||||
-rw-r--r-- | src/alloc.c | 608 | ||||
-rw-r--r-- | src/atimer.c | 80 | ||||
-rw-r--r-- | src/bidi.c | 84 | ||||
-rw-r--r-- | src/blockinput.h | 16 | ||||
-rw-r--r-- | src/buffer.c | 98 | ||||
-rw-r--r-- | src/buffer.h | 11 | ||||
-rw-r--r-- | src/bytecode.c | 21 | ||||
-rw-r--r-- | src/callint.c | 1 | ||||
-rw-r--r-- | src/callproc.c | 30 | ||||
-rw-r--r-- | src/casefiddle.c | 2 | ||||
-rw-r--r-- | src/casetab.c | 2 | ||||
-rw-r--r-- | src/category.c | 1 | ||||
-rw-r--r-- | src/ccl.c | 1 | ||||
-rw-r--r-- | src/character.c | 3 | ||||
-rw-r--r-- | src/charset.c | 7 | ||||
-rw-r--r-- | src/chartab.c | 2 | ||||
-rw-r--r-- | src/cm.c | 3 | ||||
-rw-r--r-- | src/cmds.c | 2 | ||||
-rw-r--r-- | src/coding.c | 21 | ||||
-rw-r--r-- | src/composite.c | 1 | ||||
-rw-r--r-- | src/composite.h | 2 | ||||
-rw-r--r-- | src/conf_post.h | 27 | ||||
-rw-r--r-- | src/data.c | 112 | ||||
-rw-r--r-- | src/dbusbind.c | 2 | ||||
-rw-r--r-- | src/dired.c | 3 | ||||
-rw-r--r-- | src/dispextern.h | 6 | ||||
-rw-r--r-- | src/dispnew.c | 53 | ||||
-rw-r--r-- | src/doc.c | 2 | ||||
-rw-r--r-- | src/doprnt.c | 5 | ||||
-rw-r--r-- | src/dosfns.c | 2 | ||||
-rw-r--r-- | src/editfns.c | 17 | ||||
-rw-r--r-- | src/emacs.c | 235 | ||||
-rw-r--r-- | src/emacsgtkfixed.c | 9 | ||||
-rw-r--r-- | src/eval.c | 130 | ||||
-rw-r--r-- | src/fileio.c | 202 | ||||
-rw-r--r-- | src/filelock.c | 25 | ||||
-rw-r--r-- | src/firstfile.c | 5 | ||||
-rw-r--r-- | src/floatfns.c | 628 | ||||
-rw-r--r-- | src/fns.c | 122 | ||||
-rw-r--r-- | src/font.c | 109 | ||||
-rw-r--r-- | src/font.h | 46 | ||||
-rw-r--r-- | src/fontset.c | 29 | ||||
-rw-r--r-- | src/frame.c | 28 | ||||
-rw-r--r-- | src/frame.h | 5 | ||||
-rw-r--r-- | src/fringe.c | 10 | ||||
-rw-r--r-- | src/ftfont.c | 32 | ||||
-rw-r--r-- | src/ftxfont.c | 23 | ||||
-rw-r--r-- | src/gnutls.c | 1 | ||||
-rw-r--r-- | src/gtkutil.c | 30 | ||||
-rw-r--r-- | src/image.c | 231 | ||||
-rw-r--r-- | src/indent.c | 5 | ||||
-rw-r--r-- | src/insdel.c | 56 | ||||
-rw-r--r-- | src/intervals.c | 22 | ||||
-rw-r--r-- | src/keyboard.c | 321 | ||||
-rw-r--r-- | src/keyboard.h | 2 | ||||
-rw-r--r-- | src/keymap.c | 4 | ||||
-rw-r--r-- | src/lisp.h | 288 | ||||
-rw-r--r-- | src/lisp.mk | 1 | ||||
-rw-r--r-- | src/lread.c | 23 | ||||
-rw-r--r-- | src/macros.c | 2 | ||||
-rw-r--r-- | src/makefile.w32-in | 2 | ||||
-rw-r--r-- | src/marker.c | 28 | ||||
-rw-r--r-- | src/menu.c | 5 | ||||
-rw-r--r-- | src/minibuf.c | 6 | ||||
-rw-r--r-- | src/msdos.c | 30 | ||||
-rw-r--r-- | src/ns.mk | 39 | ||||
-rw-r--r-- | src/nsfns.m | 15 | ||||
-rw-r--r-- | src/nsfont.m | 16 | ||||
-rw-r--r-- | src/nsimage.m | 1 | ||||
-rw-r--r-- | src/nsmenu.m | 8 | ||||
-rw-r--r-- | src/nsselect.m | 1 | ||||
-rw-r--r-- | src/nsterm.h | 1 | ||||
-rw-r--r-- | src/nsterm.m | 459 | ||||
-rw-r--r-- | src/print.c | 12 | ||||
-rw-r--r-- | src/process.c | 399 | ||||
-rw-r--r-- | src/ralloc.c | 34 | ||||
-rw-r--r-- | src/regex.c | 7 | ||||
-rw-r--r-- | src/region-cache.c | 25 | ||||
-rw-r--r-- | src/scroll.c | 6 | ||||
-rw-r--r-- | src/search.c | 8 | ||||
-rw-r--r-- | src/sheap.c | 3 | ||||
-rw-r--r-- | src/sound.c | 40 | ||||
-rw-r--r-- | src/syntax.c | 12 | ||||
-rw-r--r-- | src/sysdep.c | 280 | ||||
-rw-r--r-- | src/syssignal.h | 99 | ||||
-rw-r--r-- | src/systty.h | 18 | ||||
-rw-r--r-- | src/term.c | 45 | ||||
-rw-r--r-- | src/termcap.c | 1 | ||||
-rw-r--r-- | src/termchar.h | 2 | ||||
-rw-r--r-- | src/terminal.c | 9 | ||||
-rw-r--r-- | src/terminfo.c | 3 | ||||
-rw-r--r-- | src/textprop.c | 5 | ||||
-rw-r--r-- | src/tparam.c | 4 | ||||
-rw-r--r-- | src/undo.c | 2 | ||||
-rw-r--r-- | src/unexaix.c | 1 | ||||
-rw-r--r-- | src/unexcoff.c | 1 | ||||
-rw-r--r-- | src/unexcw.c | 1 | ||||
-rw-r--r-- | src/unexsol.c | 1 | ||||
-rw-r--r-- | src/vm-limit.c | 1 | ||||
-rw-r--r-- | src/w16select.c | 1 | ||||
-rw-r--r-- | src/w32.c | 60 | ||||
-rw-r--r-- | src/w32console.c | 1 | ||||
-rw-r--r-- | src/w32fns.c | 27 | ||||
-rw-r--r-- | src/w32font.c | 12 | ||||
-rw-r--r-- | src/w32font.h | 2 | ||||
-rw-r--r-- | src/w32heap.c | 1 | ||||
-rw-r--r-- | src/w32inevt.c | 1 | ||||
-rw-r--r-- | src/w32menu.c | 2 | ||||
-rw-r--r-- | src/w32proc.c | 41 | ||||
-rw-r--r-- | src/w32reg.c | 1 | ||||
-rw-r--r-- | src/w32select.c | 3 | ||||
-rw-r--r-- | src/w32term.c | 19 | ||||
-rw-r--r-- | src/w32uniscribe.c | 7 | ||||
-rw-r--r-- | src/w32xfns.c | 3 | ||||
-rw-r--r-- | src/widget.c | 15 | ||||
-rw-r--r-- | src/window.c | 49 | ||||
-rw-r--r-- | src/window.h | 15 | ||||
-rw-r--r-- | src/xdisp.c | 107 | ||||
-rw-r--r-- | src/xfaces.c | 72 | ||||
-rw-r--r-- | src/xfns.c | 1 | ||||
-rw-r--r-- | src/xfont.c | 15 | ||||
-rw-r--r-- | src/xftfont.c | 33 | ||||
-rw-r--r-- | src/xgselect.c | 6 | ||||
-rw-r--r-- | src/xmenu.c | 32 | ||||
-rw-r--r-- | src/xml.c | 1 | ||||
-rw-r--r-- | src/xrdb.c | 1 | ||||
-rw-r--r-- | src/xselect.c | 7 | ||||
-rw-r--r-- | src/xsettings.c | 5 | ||||
-rw-r--r-- | src/xsmfns.c | 1 | ||||
-rw-r--r-- | src/xterm.c | 80 |
133 files changed, 3321 insertions, 3725 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index de980c6345f..79419f66ac1 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -1222,14 +1222,9 @@ if ($ptr != 0) set $tem = (struct Lisp_String *) $ptr set $tem = (char *) $tem->data - # Don't let abort actually run, as it will make stdio stop working and - # therefore the `pr' command above as well. - if $tem[0] == 'w' && $tem[1] == 'i' && $tem[2] == 'n' && $tem[3] == 'd' - # The windows-nt build replaces abort with its own function. - break w32_abort - else - break abort - end + # Don't let emacs_abort actually run, as it will make stdio stop + # working and therefore the 'pr' command above as well. + break emacs_abort end # x_error_quitter is defined only on X. But window-system is set up diff --git a/src/ChangeLog b/src/ChangeLog index 2ea13df1261..36df05c25ae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,901 @@ +2012-09-17 Eli Zaretskii <eliz@gnu.org> + + * w32term.c (w32_read_socket): Set pending_signals to 1, like + xterm.c does. Reported by Daniel Colascione <dancol@dancol.org>. + + * ralloc.c (r_alloc_init) [!SYSTEM_MALLOC]: Initialize + __malloc_extra_blocks to 32 instead of 64, like alloc.c did in + emacs_blocked_malloc, now deleted. + +2012-09-17 Paul Eggert <eggert@cs.ucla.edu> + + Remove no-longer-needed Solaris 2.4 vfork bug workaround. + The workaround was for improving performance on Solaris 2.4, but + is getting in the way now. Emacs will still work if someone is + still running Solaris 2.4 in a museum somewhere; Sun dropped + support for Solaris 2.4 in 2003. + * callproc.c (Fcall_process) [HAVE_WORKING_VFORK]: + * process.c (create_process) [HAVE_WORKING_VFORK]: + Omit now-unnecessary workaround for the Solaris 2.4 vfork bug, + since Emacs no longer uses vfork on that platform. + +2012-09-17 Glenn Morris <rgm@gnu.org> + + * emacs.c: Use COPYRIGHT. + +2012-09-16 Paul Eggert <eggert@cs.ucla.edu> + + Remove configure's --without-sync-input option (Bug#12450). + When auditing signal-handling in preparation for cleaning it up, + I found that SYNC_INPUT has race conditions and would be a real + pain to fix. Since it's an undocumented and deprecated + configure-time option, now seems like a good time to remove it. + Also see <http://bugs.gnu.org/11080#16>. + * alloc.c (_bytes_used, __malloc_extra_blocks, _malloc_internal) + (_free_internal) [!DOUG_LEA_MALLOC]: Remove decls. + (alloc_mutex) [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]: + (malloc_hysteresis): + (check_depth) [XMALLOC_OVERRUN_CHECK]: + (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): + (__malloc_hook, __realloc_hook, __free_hook, BYTES_USED) + (dont_register_blocks, bytes_used_when_reconsidered) + (bytes_used_when_full, emacs_blocked_free, emacs_blocked_malloc) + (emacs_blocked_realloc, reset_malloc_hooks, uninterrupt_malloc): + [!SYSTEM_MALLOC && !SYNC_INPUT]: + Remove. All uses removed. + (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): Use a different + implementation, one that depends on whether the new macro + XMALLOC_BLOCK_INPUT_CHECK is defined, not on whether SYNC_INPUT + is defined. + * atimer.c (run_timers, handle_alarm_signal): + * keyboard.c (pending_signal, poll_for_input_1, poll_for_input) + (handle_async_input, process_pending_signals) + (handle_input_available_signal, init_keyboard): + * nsterm.m (ns_read_socket): + * process.c (wait_reading_process_output): + * regex.c (immediate_quit, IMMEDIATE_QUIT_CHECK): + * sysdep.c (emacs_sigaction_init) [SA_RESTART]: + (emacs_write): + * xterm.c (XTread_socket): + Assume SYNC_INPUT. + * conf_post.h (SA_RESTART) [IRIX6_5]: Do not #undef. + * eval.c (handling_signal): Remove. All uses removed. + * lisp.h (ELSE_PENDING_SIGNALS): Remove. + All uses replaced with the SYNC_INPUT version. + (reset_malloc_hooks, uninterrupt_malloc, handling_signal): + Remove decls. + * sysdep.c, syssignal.h (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]: + Now static. + + * font.c (Ffont_shape_gstring): Remove unused local. + +2012-09-16 Glenn Morris <rgm@gnu.org> + + * Makefile.in (clean): No longer run nextstep's clean. + + * Makefile.in (ns_appdir, ns_appbindir, ns_appsrc): Remove variables. + (ns_frag): Remove. + (ns-app): Move here from ns.mk, and simplify. + (clean): Simplify nextstep entry. + * ns.mk: Remove file. + +2012-09-16 Kenichi Handa <handa@gnu.org> + + * font.c (Ffont_shape_gstring): Fix previous change; GLYPHs may + not covert the last few charactes. + +2012-09-16 Kenichi Handa <handa@gnu.org> + + * font.c (Ffont_shape_gstring): Don't adjust grapheme cluster + here, but just check the validity of glyphs in the glyph-string. + +2012-09-16 Martin Rudalics <rudalics@gmx.at> + + * window.c (Fwindow_parameter, Fset_window_parameter): Accept + any window as argument (Bug#12452). + +2012-09-16 Jan Djärv <jan.h.d@swipnet.se> + + * nsfns.m (Fx_open_connection): Move initialization of ns_*_types + to ns_term_init to avoid memory leak. + + * nsterm.m (ns_update_begin): Initialize bp after lcokFocus, use + explicit retain/release. + (ns_term_init): Only allow one display. Initialize outerpool and + ns_*_types. + +2012-09-15 Paul Eggert <eggert@cs.ucla.edu> + + Port _setjmp fix to POSIXish hosts as well as Microsoft. + * image.c (_setjmp) [!HAVE__SETJMP]: Restore definition, as + it's needed on POSIXish hosts that lack _setjmp. Attempt to solve + the Microsoft problem in a different way, by altering ../nt/config.nt. + +2012-09-15 Eli Zaretskii <eliz@gnu.org> + + * w32xfns.c: + * w32uniscribe.c: + * w32term.c: + * w32select.c: + * w32reg.c: + * w32proc.c: + * w32menu.c: + * w32inevt.c: + * w32heap.c: + * w32font.c: + * w32fns.c: + * w32console.c: + * w32.c: + * w16select.c: Remove inclusion of setjmp.h, as it is now included + by lisp.h. This completes removal of setjmp.h inclusion + erroneously announced in the previous commit. (Bug#12446) + + * lisp.h [!HAVE__SETJMP, !HAVE_SIGSETJMP]: Make the commentary + more accurate. + + * image.c (_setjmp) [!HAVE__SETJMP]: Define only if 'setjmp' is + not defined as a macro. The latter happens on MS-Windows. + (Bug#12446) + +2012-09-15 Paul Eggert <eggert@cs.ucla.edu> + + Port better to POSIX hosts lacking _setjmp (Bug#12446). + * lisp.h: Include <setjmp.h> here, since we use its symbols here. + Some instances of '#include <setjmp.h>' removed, if the + only reason for the instance was because "lisp.h" was included. + (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols. + Unless otherwise specified, replace all uses of jmp_buf, _setjmp, + and _longjmp with the new symbols. Emacs already uses _setjmp if + available, so this change affects only POSIXish hosts that have + sigsetjmp but not _setjmp, such as some versions of Solaris and + Unixware. (Also, POSIX-2008 marks _setjmp as obsolescent.) + * image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros. + (png_load_body) [HAVE_PNG]: + (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]: + (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]: + Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp, + since PNG requires jmp_buf. This is the only exception to the + general rule that we now use sys_setjmp and sys_longjmp. + This exception is OK since this code does not change the signal + mask or longjmp out of a signal handler. + +2012-09-14 Paul Eggert <eggert@cs.ucla.edu> + + * alloc.c [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]: + Include "syssignal.h", for 'main_thread'. + +2012-09-14 Dmitry Antipov <dmantipov@yandex.ru> + + Avoid out-of-range marker position (Bug#12426). + * insdel.c (replace_range, replace_range_2): Adjust + markers before overlays, as suggested by comments. + (insert_1_both, insert_from_buffer_1, adjust_after_replace): + Remove redundant check before calling offset_intervals. + +2012-09-14 Martin Rudalics <rudalics@gmx.at> + + * xdisp.c (Fformat_mode_line): Unconditionally save/restore + current buffer (Bug#12387). + +2012-09-14 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/alloc.$(O)): Update dependencies. + +2012-09-13 Paul Eggert <eggert@cs.ucla.edu> + + Use a more backwards-compatible timer format (Bug#12430). + * keyboard.c (decode_timer): Get PSECS from the 8th (origin-0) + vector element, not from the 4th, since PSECS is now at the end. + (Fcurrent_idle_time): Doc fix. + +2012-09-13 Dmitry Antipov <dmantipov@yandex.ru> + + Function to mark objects and remove killed buffers at once. + * alloc.c (discard_killed_buffers): Rename to ... + (mark_discard_killed buffers) ... new name. Add marking + of remaining objects. Fix comment. Adjust users. + (mark_object): Do not touch frame buffer lists here. + * frame.c (delete_frame): Reset frame buffer lists here. + +2012-09-13 Paul Eggert <eggert@cs.ucla.edu> + + Better workaround for GNOME bug when --enable-gcc-warnings. + * emacsgtkfixed.c (G_STATIC_ASSERT): Remove, undoing last change. + Instead, disable -Wunused-local-typedefs. See Dmitry Antipov in + <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00335.html>. + + Simplify SIGIO usage (Bug#12408). + The code that dealt with SIGIO was crufty and confusing, e.g., it + played tricks like "#undef SIGIO" but these tricks were not used + consistently. Simplify mostly by not #undeffing standard symbols, + e.g., use "defined USABLE_SIGIO" (our symbol, which we can define + or not as we please) rather than "defined SIGIO" (standard symbol + that we probably shouldn't #undef). + * conf_post.h [USG5_4]: Do not include <sys/wait.h> here. + Modules that need it can include it. + [USG5_4 && emacs]: Likewise, do not include the streams stuff here. + * dispextern.h (ignore_sigio): New decl. + * emacs.c (shut_down_emacs): Invoke unrequest_sigio + unconditionally, since it's now a no-op if !USABLE_SIGIO. + * emacs.c (shut_down_emacs): + * keyboard.c (kbd_buffer_store_event_hold): + Use ignore_sigio rather than invoking 'signal' directly. + * keyboard.c (USABLE_FIONREAD && USG5_4): Include <sys/filio.h>, + for FIONREAD. + (FIONREAD, SIGIO): Do not #undef. + (tty_read_avail_input): Use #error rather than a syntax error. + * process.c [USG5_4]: Include <sys/stream.h> and <sys/stropts.h>, + for I_PIPE, used by SETUP_SLAVE_PTY. + (DATAGRAM_SOCKETS): Simplify defn, based on USABLE_FIONREAD. + * sysdep.c (croak): Remove; no longer needed. This bit of + temporary code, with Fred N. Fish's comment that it's temporary, + has been in Emacs since at least 1992! + (init_sigio, reset_sigio, request_sigio, unrequest_sigio): + Arrange for them to be no-ops in all cases when ! USABLE_SIGIO. + * syssignal.h (croak): Remove decl. + (SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile. + * systty.h [!NO_TERMIO]: Do not include <termio.h>; no longer needed + now that we're termios-only. + (FIONREAD, ASYNC) [BROKEN_FIONREAD]: Do not #undef. + * term.c (dissociate_if_controlling_tty): Use #error rather than + a run-time error. + + Work around GCC and GNOME bugs when --enable-gcc-warnings. + * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify', + to work around GNOME bug 683906. + * image.c (jpeg_load_body) [HAVE_JPEG && lint]: Pacify gcc -Wclobber. + (struct my_jpeg_error_mgr) [HAVE_JPEG && lint]: New member fp. + This works around GCC bug 54561. + +2012-09-12 Paul Eggert <eggert@cs.ucla.edu> + + More fixes for 'volatile' and setjmp/longjmp. + * eval.c (Fdefvar, Fcondition_case): Remove unnecessary 'volatile's. + * image.c (struct png_load_context) [HAVE_PNG]: New type. + (png_load_body) [HAVE_PNG]: + (jpeg_load_body) [HAVE_JPEG]: + New function, with most of the old parent function's body. + (png_load) [HAVE_PNG]: + (jpeg_load) [HAVE_JPEG]: + Invoke the new function, to avoid longjmp munging our locals. + (struct my_jpeg_error_mgr) [HAVE_JPEG]: New members cinfo, failure_code. + (my_error_exit) [HAVE_JPEG]: Don't trust 'setjmp' to return 2 when + longjmp is passed 2, as the C standard doesn't guarantee this. + Instead, store the failure code into mgr->failure_code. + +2012-09-12 Stefan Monnier <monnier@iro.umontreal.ca> + + * keyboard.c (read_char, requeued_events_pending_p, Finput_pending_p) + (Fdiscard_input, quit_throw_to_read_char, init_keyboard) + (syms_of_keyboard): Remove support for unread-command-char. + +2012-09-12 Eli Zaretskii <eliz@gnu.org> + + * w32proc.c (sys_kill): If PID is our process ID and the signal is + SIGABRT, call emacs_abort. Avoids silently exiting upon assertion + violation. (Bug#12426) + +2012-09-12 Paul Eggert <eggert@cs.ucla.edu> + + * image.c (jpeg_memory_src): Don't assume string len fits in unsigned. + +2012-09-12 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c: Add `inhibit-debugger'. + (Qinhibit_debugger): New symbol. + (call_debugger): Bind it instead of Qdebug_on_error. + (maybe_call_debugger): Test Vinhibit_debugger. + (syms_of_eval): Define inhibit-debugger. + * xdisp.c (set_message): Don't bind Qinhibit_debug_on_message. + (syms_of_xdisp): Remove inhibit-debug-on-message. + +2012-09-11 Paul Eggert <eggert@cs.ucla.edu> + + Avoid _setjmp/_longjmp problems with local nonvolatile variables. + If a nonvolatile local variable is written before a _longjmp to + the frame containing the variable, and is read after the _longjmp, + the value read is indeterminate. Some local variables of type + 'struct handler' and 'struct catchtag' are used in this way, so + mark each of their slots as volatile if the slot can be set before + _longjmp and read afterwards. + * lisp.h (struct handler): var and chosen_clause are now volatile. + (struct catchtag): val, next, and pdlcount are now volatile. + + * bidi.c (bidi_push_it, bidi_pop_it): + * fns.c (copy_hash_table): + * image.c (define_image_type): + * keyboard.c (kbd_buffer_store_event_hold): + * process.c (Fprocess_send_eof): + * xfaces.c (x_create_gc) [HAVE_NS]: + * xgselect.c (xg_select): + Prefer assignment to memcpy when either will do. + + * alloc.c (discard_killed_buffers): Tune and simplify a bit. + Use pointer-to-a-pointer to simplify and avoid a NILP check each + time an item is removed. No need to mark this function 'inline'; + the compiler knows better than we do. + +2012-09-11 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_judge_scroll_bars): Pass NO to updateFrameSize. + (updateFrameSize:): Add delay parameter to updateFrameSize, send it + to change_frame_size (Bug#12388). + (windowDidResize:): Pass YES to updateFrameSize. + + * nsterm.h: Add delay parameter to updateFrameSize. + +2012-09-11 Dmitry Antipov <dmantipov@yandex.ru> + + Discard killed buffers from deleted window and frame objects. + This reduces an amount of references to killed buffers and + helps GC to reclaim them faster. + * alloc.c (discard_killed_buffers): New function. + (mark_object): Use it for deleted windows and frames. + (mark_object): If symbol's value is set up for a killed buffer + or deleted frame, restore it's global binding. + * data.c (swap_in_global_binding): Add GC notice. + (swap_in_symval_forwarding): Use convenient set_blv_where. + * window.c (wset_next_buffers, wset_prev_buffers): Move ... + * window.h: ... to here. + +2012-09-11 Dmitry Antipov <dmantipov@yandex.ru> + + Convenient macro to check whether the buffer is live. + * buffer.h (BUFFER_LIVE_P): New macro. + * alloc.c, buffer.c, editfns.c, insdel.c, lread.c, marker.c: + * minibuf.c, print.c, process.c, window.c, xdisp.c: Use it. + +2012-09-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * xdisp.c (right_overwritten, right_overwriting): Also handle gstring + composition cases (Bug#12364). + + * xterm.c (x_draw_glyph_string): Avoid overwriting inverted left + overhang of succeeding glyphs overlapping box cursor. + + * w32term.c (x_draw_glyph_string): Likewise. + +2012-09-11 Paul Eggert <eggert@cs.ucla.edu> + + Simplify, document, and port floating-point (Bug#12381). + The porting part of this patch fixes bugs on non-IEEE platforms + with frexp, ldexp, logb. + * data.c, lisp.h (Qdomain_error, Qsingularity_error, Qunderflow_error): + Now static. + * floatfns.c: Simplify discussion of functions that Emacs doesn't + support, by removing commented-out code and briefly listing the + C89 functions excluded. The commented-out stuff was confusing + maintenance, e.g., we thought we needed cbrt but it was commented out. + (logb): Remove decl; no longer needed. + (isfinite): New macro, if not already supplied. + (isnan): Don't replace any existing macro. + (Ffrexp, Fldexp): Define even if !HAVE_COPYSIGN, as frexp and ldexp + are present on all C89 platforms. + (Ffrexp): Do not special-case zero, as frexp does the right thing + for that case. + (Flogb): Do not use logb, as it doesn't have the desired meaning + on hosts that use non-base-2 floating point. Instead, stick with + frexp, which is C89 anyway. Do not pass an infinity or a NaN to + frexp, to avoid getting an unspecified result. + + * xdisp.c (Qinhibit_debug_on_message): Now static. + +2012-09-10 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_update_begin): Set clip path to whole view by using + NSBezierPath (Bug#12131). + +2012-09-10 Chong Yidong <cyd@gnu.org> + + * fns.c (Fdelq, Fdelete): Doc fix. + +2012-09-10 Paul Eggert <eggert@cs.ucla.edu> + + * lisp.h (XSETINT, XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL) + (XSETFLOAT, XSETMISC): Parenthesize macro bodies. + +2012-09-09 Stefan Monnier <monnier@iro.umontreal.ca> + + * lisp.h (make_lisp_ptr): New macro to replace XSET. + (XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL, XSETFLOAT, XSETMISC): + Use it. + +2012-09-09 Eli Zaretskii <eliz@gnu.org> + + * fringe.c (draw_fringe_bitmap_1): Don't reduce the width of the + left fringe if the window has a left margin. This avoids leaving + traces of the cursor because its leftmost pixel is not drawn over. + + * dispnew.c (update_window_line): When the left margin area of a + screen line is updated, set the redraw_fringe_bitmaps_p flag of + that screen line. (Bug#12277) + +2012-09-09 Paul Eggert <eggert@cs.ucla.edu> + + Assume C89 or later for math functions (Bug#12381). + This simplifies the code, and makes it a bit smaller and faster, + and (most important) makes it easier to clean up signal handling + since we can stop worring about floating-point exceptions in + library code. That was a problem before C89, but the problem + went away many years ago on all practical Emacs targets. + * data.c, image.c, lread.c, print.c: + Don't include <math.h>; no longer needed. + * data.c, floatfns.c (IEEE_FLOATING_POINT): Don't worry that it + might be autoconfigured, as that never happens. + * data.c (fmod): + * doprnt.c (DBL_MAX_10_EXP): + * print.c (DBL_DIG): + Remove. C89 or later always defines these. + * floatfns.c (HAVE_MATHERR, FLOAT_CHECK_ERRNO, FLOAT_CHECK_DOMAIN) + (in_float, float_error_arg, float_error_arg2, float_error_fn_name) + (arith_error, domain_error, domain_error2): + Remove all this pre-C89 cruft. Do not include <errno.h> as that's + no longer needed -- we simply return what C returns. All uses removed. + (IN_FLOAT, IN_FLOAT2): Remove. All uses replaced with + the wrapped code. + (FLOAT_TO_INT, FLOAT_TO_INT2, range_error, range_error2): + Remove. All uses expanded, as these macros are no longer used + more than once and are now more trouble than they're worth. + (Ftan): Use tan, not sin / cos. + (Flogb): Assume C89 frexp. + (fmod_float): Assume C89 fmod. + (matherr) [HAVE_MATHERR]: Remove; no longer needed. + (init_floatfns): Remove. All uses removed. + +2012-09-08 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_draw_fringe_bitmap, ns_dumpglyphs_image): Take back + compositeToPoint for OSX < 10.6 (Bug#12390). + +2012-09-08 Paul Eggert <eggert@cs.ucla.edu> + + * floatfns.c (Ftan): Use tan (x), not (sin (x) / cos (x)). + This produces more-accurate results. + +2012-09-08 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (updateFrameSize): Call setFrame: on the view when size + changes (Bug#12088). + +2012-09-08 Chong Yidong <cyd@gnu.org> + + * syntax.c (Fstring_to_syntax): Doc fix. + +2012-09-08 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_clip_to_row): Remove code that deals with drawing fringe + in the internal border. + (x_set_window_size): Remove static variables and their usage. + (ns_redraw_scroll_bars): Fix NSTRACE arg. + (ns_after_update_window_line, ns_draw_fringe_bitmap): Remove + fringe/internal border adjustment (Bug#11052). + (ns_draw_fringe_bitmap): Make code more like other terms (xterm.c). + (ns_draw_window_cursor): Remove fringe/internal border adjustment. + (ns_fix_rect_ibw): Remove. + (ns_get_glyph_string_clip_rect): Remove call to ns_fix_rect_ibw. + (ns_dumpglyphs_box_or_relief): Ditto. + (ns_maybe_dumpglyphs_background): Remove fringe/internal border + adjustment. + (ns_dumpglyphs_image): Ditto. + (ns_dumpglyphs_stretch): Fix coding style. Remove fringe/internal + border adjustment. + (ns_set_vertical_scroll_bar): Remove variables barOnVeryLeft/Right and + their usage. Add fringe_extended_p and its use as in other terms. + (ns_judge_scroll_bars): Code style fix. Call updateFrameSize if + scroll bar was removed. + (updateFrameSize): New function. + (windowDidResize): Move code to updateFrameSize and call it. + + * nsterm.h (EmacsView): Add updateFrameSize. + +2012-09-07 Chong Yidong <cyd@gnu.org> + + * textprop.c (Fget_text_property): Minor doc fix (Bug#12323). + + * data.c (Flocal_variable_if_set_p): Doc fix (Bug#10713). + +2012-09-07 Paul Eggert <eggert@cs.ucla.edu> + + More signal-handler cleanup (Bug#12327). + * emacs.c (main): Convert three 'signal' calls to 'sigaction' calls. + Problem introduced when merging patches. Noted by Eli Zaretskii in + <http://bugs.gnu.org/12327#67>. + * floatfns.c: Comment fix. + * lisp.h (force_auto_save_soon): Declare regardless of SIGDANGER. + SIGDANGER might not be in scope so "#ifdef SIGDANGER" is not right, + and anyway the declaration is harmless even if SIGDANGER is not defined. + * syssignal.h (SIGIO): Also #undef if (! defined FIONREAD || + defined BROKEN_FIONREAD). systty.h formerly did this, but other + source files not surprisingly expected syssignal.h to define, or + not define, SIGIO, and it's cleaner to do it that way, for consistency. + Include <sys/ioctl.h>, for FIONREAD. + * systty.h (SIGIO): Do not #undef here; it's now syssignal.h's job. + This eliminates a problem whereby other files mysteriously had + to include "syssignal.h" before including "systty.h" if they + wanted to use "#ifdef SIGIO". + +2012-09-07 Eli Zaretskii <eliz@gnu.org> + + * w32proc.c (sigaction): New function, emulates Posix 'sigaction'. + + * w32.c (sigemptyset): Empty the set. + (sigsetmask, sigmask, sigblock, sigunblock): Remove unused functions. + + * alloc.c [ENABLE_CHECKING]: Include signal.h, since we need SIGABRT. + +2012-09-07 Dmitry Antipov <dmantipov@yandex.ru> + + * alloc.c (mark_buffer): Revert unsafe marking optimization. + (mark_object): Likewise for frame objects. + +2012-09-07 Paul Eggert <eggert@cs.ucla.edu> + + * syssignal.h (handle_on_main_thread): Always declare, + even if FORWARD_SIGNAL_TO_MAIN_THREAD is not defined. + This ports to platforms without HAVE_PTHREAD. + +2012-09-06 Paul Eggert <eggert@cs.ucla.edu> + + Signal-handler cleanup (Bug#12327). + Emacs's signal handlers were written in the old 4.2BSD style with + sigblock and sigmask and so forth, and this led to some + inefficiencies and confusion. Rewrite these to use + pthread_sigmask etc. without copying signal sets around. Also, + get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and + 'signal', and instead use functions that do not attempt to take + over the system name space. This patch causes Emacs's text + segment to shrink by 0.7% on my platform, Fedora 17 x86-64. + * alloc.c, emacsgtkfixed.c, nsfns.m, widget.c, xmenu.c: + Do not include <signal.h> or "syssignal.h", as these + modules do not use signals. + * atimer.c, callproc.c, data.c, dispnew.c, emacs.c, floatfns.c: + * gtkutil.c, keyboard.c, process.c, sound.c, sysdep.c, term.c, xterm.c: + Do not include <signal.h>, as "syssignal.h" does that for us now. + * atimer.c (sigmask_atimers): New function. + (block_atimers, unblock_atimers): New functions, + replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS. + All uses replaced. + * conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>; + no longer needed here. + * emacs.c (main): Inspect existing signal handler with sigaction, + so that there's no need to block and unblock SIGHUP. + * sysdep.c (struct save_signal): New member 'action', replacing + old member 'handler'. + (save_signal_handlers, restore_signal_handlers): + Use sigaction instead of 'signal' to save and restore. + (get_set_sighandler, set_sighandler) [!WINDOWSNT]: + New function. All users of 'signal' modified to use set_sighandler + if they're writeonly, and to use sys_signal if they're read+write. + (emacs_sigaction_init, forwarded_signal): New functions. + (sys_signal): Remove. All uses replaced by calls to sigaction + and emacs_sigaction_init, or by direct calls to 'signal'. + (sys_sigmask) [!__GNUC__]: Remove; no longer needed. + (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove; + all uses replaced by pthread_sigmask etc. calls. + * syssignal.h: Include <signal.h>. + (emacs_sigaction_init, forwarded_signal): New decls. + (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t. + (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask. + (sigmask, sys_sigmask): Remove; no longer needed. + (sigpause): Remove. All uses replaced by its definiens, sigsuspend. + (sigblock, sigunblock, sigfree): + (sigsetmask) [!defined sigsetmask]: + Remove. All uses replaced by pthread_sigmask. + (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN) + no longer need to be replaced, and its typical old uses + are now done via emacs_sigaction_init and sigaction. + (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls. + (sys_sigdel): Remove; unused. + (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef. + +2012-09-06 Eli Zaretskii <eliz@gnu.org> + + * process.c (CAN_HANDLE_MULTIPLE_CHILDREN): Fix a typo that broke + SIGCHLD handling on systems that don't have WNOHANG. (Bug#12327) + +2012-09-06 Dmitry Antipov <dmantipov@yandex.ru> + + Explicitly mark buffer_defaults and buffer_local_symbols. + * alloc.c (Fgarbage_collect): Mark buffer_defaults and + mark_local_symbols here. + (mark_object): If GC_CHECK_MARKED_OBJECTS, simplify checking + since special buffers aren't marked here any more. + (allocate_buffer): Chain new buffer with all_buffers here... + * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): ...and + not here. + (Vbuffer_defaults, Vbuffer_local_symbols): Remove. + (syms_of_buffer): Remove staticpro of the above. + (init_buffer_once): Set names for buffer_defaults and + buffer_local_symbols. + +2012-09-06 Paul Eggert <eggert@cs.ucla.edu> + + Use bool for booleans in font-related modules. + * font.c (font_intern_prop, font_style_to_value) + (font_style_symbolic, font_parse_xlfd, font_parse_fcname) + (generate_otf_features, font_check_otf_features, font_check_otf) + (font_match_p, font_list_entities, font_at): + * fontset.c (fontset_id_valid_p, reorder_font_vector + (fontset_find_font, Fset_fontset_font) + (face_suitable_for_char_p) [0]: + * ftfont.c (fc_initialized, ftfont_get_open_type_spec) + (ftfont_open, ftfont_text_extents, ftfont_check_otf): + (m17n_flt_initialized, ftfont_shape_by_flt): + * ftxfont.c (ftxfont_draw_bitmap, ftxfont_draw): + * nsfont.m (nsfont_draw): + * w32font.c (w32font_draw): + * w32term.c (x_draw_glyphless_glyph_string_foreground): + Use bool for booleans. + * font.h: Adjust to above API changes. + (struct font, struct font_driver, struct font_driver_list): + Use bool for booleans. + (struct font): Remove useless member encoding_type. + All users removed. + * fontset.c, xftfont.c: Omit unnecessary static decls. + +2012-09-06 Dmitry Antipov <dmantipov@yandex.ru> + + * alloc.c (mark_object): Revert window marking code + since it's unsafe for the Fset_window_configuration. + +2012-09-05 Paul Eggert <eggert@cs.ucla.edu> + + Fix race conditions with signal handlers and errno (Bug#12327). + Be more systematic about preserving errno whenever a signal + handler returns, even if it's not in the main thread. Do this by + renaming signal handlers to distinguish between signal delivery + and signal handling. All uses changed. + * atimer.c (deliver_alarm_signal): Rename from alarm_signal_handler. + * data.c (deliver_arith_signal): Rename from arith_error. + * dispnew.c (deliver_window_change_signal): Rename from + window_change_signal. + * emacs.c (deliver_error_signal): Rename from fatal_error_signal. + (deliver_danger_signal) [SIGDANGER]: Rename from memory_warning_signal. + * keyboard.c (deliver_input_available_signal): Rename from + input_available_signal. + (deliver_user_signal): Rename from handle_user_signal. + (deliver_interrupt_signal): Rename from interrupt_signal. + * process.c (deliver_pipe_signal): Rename from send_process_trap. + (deliver_child_signal): Rename from sigchld_handler. + * atimer.c (handle_alarm_signal): + * data.c (handle_arith_signal): + * dispnew.c (handle_window_change_signal): + * emacs.c (handle_fatal_signal, handle_danger_signal): + * keyboard.c (handle_input_available_signal): + * keyboard.c (handle_user_signal, handle_interrupt_signal): + * process.c (handle_pipe_signal, handle_child_signal): + New functions, with the actual signal-handling code taken from the + original respective signal handlers, sans the sporadic attempts to + preserve errno, since that's now done by handle_on_main_thread. + * atimer.c (alarm_signal_handler): Remove unnecessary decl. + * emacs.c, floatfns.c, lisp.h: Remove unused FLOAT_CATCH_SIGKILL cruft. + * emacs.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]: + Move to sysdep.c. + (main) [FORWARD_SIGNAL_TO_MAIN_THREAD]: + Move initialization of main_thread to sysdep.c's init_signals. + * process.c (waitpid) [!WNOHANG]: #define to wait; that's good enough for + our usage, and simplifies the mainline code. + (record_child_status_change): New static function, as a helper + for handle_child_signal, and with most of the old child handler's + contents. + (CAN_HANDLE_MULTIPLE_CHILDREN): New constant. + (handle_child_signal): Use the above. + * sysdep.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]: + Moved here from emacs.c. + (init_signals) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Initialize it; + code moved here from emacs.c's main function. + * sysdep.c, syssignal.h (handle_on_main_thread): New function, + replacing the old SIGNAL_THREAD_CHECK. All uses changed. This + lets callers save and restore errno properly. + +2012-09-05 Dmitry Antipov <dmantipov@yandex.ru> + + Remove redundant or unused things here and there. + * lisp.h (CYCLE_CHECK, CHAR_TABLE_TRANSLATE): Remove. + * conf_post.h (RE_TRANSLATE): Use char_table_translate. + * editfns.c (Fcompare_buffer_substrings): Likewise. + * frame.h (struct terminal, struct font_driver_list): + Remove redundant declarations. + * window.h (Qleft, Qright): Likewise. + +2012-09-05 Dmitry Antipov <dmantipov@yandex.ru> + + Do not mark objects from deleted buffers, windows and frames. + * alloc.c (mark_buffer): Mark just the buffer if it is dead. + (mark_object): Likewise for windows and frames. + +2012-09-05 Dmitry Antipov <dmantipov@yandex.ru> + + * alloc.c (valid_lisp_object_p): Treat killed buffers, + buffer_defaults and buffer_local_symbols as valid objects. + Return special value to denote them. + +2012-09-05 Paul Eggert <eggert@cs.ucla.edu> + + * fileio.c, filelock.c, floatfns.c, fns.c: Use bool for boolean. + * fileio.c (auto_saving, auto_save_error_occurred, make_temp_name) + (Fexpand_file_name, barf_or_query_if_file_exists, Fcopy_file) + (file_name_absolute_p, Fsubstitute_in_file_name): + (check_executable, check_writable, Ffile_accessible_directory_p) + (Fset_file_selinux_context, Fdefault_file_modes) + (Finsert_file_contents, choose_write_coding_system) + (Fwrite_region, build_annotations, a_write, e_write) + (Fdo_auto_save): + * filelock.c (boot_time_initialized, get_boot_time) + (get_boot_time_1, lock_file_1, within_one_second): + * floatfns.c (in_float): + * fns.c (concat, internal_equal, Frequire, base64_encode_1) + (base64_decode_1, cmpfn_eql, cmpfn_user_defined) + (sweep_weak_table, sweep_weak_hash_tables, secure_hash): + * lisp.h (struct Lisp_Hash_Table.cmpfn): + * window.c (compare_window_configurations): + Use bool for booleans. + * fileio.c (auto_saving_dir_umask, auto_saving_mode_bits) + (Fdefault_file_modes): Now mode_t, not int, for modes. + (Fdo_auto_save): Set a boolean to 1 rather than using ++. + (internal_delete_file): Now returns void, not a (boolean) int, + since nobody was looking at the return value. + * lisp.h, window.h: Adjust to above API changes. + + * xdisp.c (set_message): Simplify and reindent last change. + +2012-09-05 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/sysdep.$(O)): Update dependencies. + +2012-09-04 Lars Ingebrigtsen <larsi@gnus.org> + + * eval.c (call_debugger): Make the function non-static so that we + can call it from set_message. + + * xdisp.c (set_message): Implement the new variable `debug-on-message'. + (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'. + +2012-09-04 Paul Eggert <eggert@cs.ucla.edu> + + Give more-useful info on a fatal error (Bug#12328). + * alloc.c [ENABLE_CHECKING]: Do not include <execinfo.h>. + (die) [ENABLE_CHECKING]: Call fatal_error_backtrace instead + of doing the work ourselves. + * emacs.c (fatal_error_signal): Let fatal_error_backtrace + do most of the work. + (fatal_error_backtrace): New function, taken from the guts + of the old fatal_error_signal, but with a new option to output + a backtrace. + (shut_down_emacs) [!DOS_NT]: Use strsignal to give more-useful + info about the signal than just its number. + * lisp.h (fatal_error_backtrace, emacs_backtrace): New decls. + * sysdep.c: Include <execinfo.h> + (emacs_backtrace): New function, taken partly from the previous + code of the 'die' function. + (emacs_abort): Call fatal_error_backtrace rather than abort. + +2012-09-04 Stefan Monnier <monnier@iro.umontreal.ca> + + * lread.c (readevalloop): Call internal-macroexpand-for-load to perform + eager (load-time) macro-expansion. + * lisp.mk (lisp): Add macroexp. + +2012-09-04 Paul Eggert <eggert@cs.ucla.edu> + + Simplify redefinition of 'abort' (Bug#12316). + Do not try to redefine the 'abort' function. Instead, redo + the code so that it calls 'emacs_abort' rather than 'abort'. + This removes the need for the NO_ABORT configure-time macro + and makes it easier to change the abort code to do a backtrace. + * .gdbinit: Just stop at emacs_abort, not at w32_abort or abort. + * emacs.c (abort) [!DOS_NT && !NO_ABORT]: + Remove; sysdep.c's emacs_abort now takes its place. + * lisp.h (emacs_abort): New decl. All calls from Emacs code to + 'abort' changed to use 'emacs_abort'. + * msdos.c (dos_abort) [defined abort]: Remove; not used. + (abort) [!defined abort]: Rename to ... + (emacs_abort): ... new name. + * sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking + the place of the old 'abort' in emacs.c. + * w32.c, w32fns.c (abort): Do not #undef. + * w32.c (emacs_abort): Rename from w32_abort. + +2012-09-04 Eli Zaretskii <eliz@gnu.org> + + * w32uniscribe.c (uniscribe_shape): Reverse the sign of + offsets[j].dv, since the y axis of the screen coordinates points + down, while the y axis of the font definition coordinates points + up. This fixes display of Arabic diacritics such as KASRA and + KASRATAN. (Bug#11860) + +2012-09-04 Paul Eggert <eggert@cs.ucla.edu> + + Be more systematic about _setjmp vs setjmp. + * alloc.c (test_setjmp, mark_stack): + * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]: + (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]: + (png_load, my_error_exit, jpeg_load): + * process.c (send_process_trap, send_process): + Uniformly prefer _setjmp and _longjmp to setjmp and longjmp. + The underscored versions are up to 30x faster on some hosts. + Formerly, the code used setjmp+longjmp sometimes and + _setjmp+_longjmp at other times, with no particular reason to + prefer setjmp+longjmp. + +2012-09-03 Paul Eggert <eggert@cs.ucla.edu> + + Fix minor problem found by static checking. + * buffer.c (Fdelete_all_overlays): Return nil. + +2012-09-03 Martin Rudalics <rudalics@gmx.at> + + * buffer.c (Fdelete_all_overlays): New function. + +2012-09-03 Chong Yidong <cyd@gnu.org> + + * gtkutil.c: Add extern decl for Qxft. + +2012-09-02 Paul Eggert <eggert@cs.ucla.edu> + + * emacs.c, eval.c: Use bool for boolean. + * emacs.c (initialized, inhibit_window_system, running_asynch_code): + (malloc_using_checking) [DOUG_LEA_MALLOC]: + (display_arg) [HAVE_X_WINDOWS || HAVE_NS]: + (noninteractive, no_site_lisp, fatal_error_in_progress, argmatch) + (main, decode_env_path, Fdaemon_initialized): + * eval.c (call_debugger, Finteractive_p, interactive_p): + (unwind_to_catch, Fsignal, wants_debugger, skip_debugger) + (maybe_call_debugger, Fbacktrace): + * process.c (read_process_output, exec_sentinel): + Use bool for booleans. + * emacs.c (shut_down_emacs): Omit unused boolean argument NO_X. + All callers changed. + * eval.c (interactive_p): Omit always-true boolean argument + EXCLUDE_SUBRS_P. All callers changed. + * dispextern.h, lisp.h: Reflect above API changes. + * firstfile.c (dummy): Use the address of 'main', whose signature + won't change, instead of the address of 'initialize', whose + signature just changed from int to bool. + * lisp.h (fatal_error_in_progress): New decl of boolean, moved here ... + * msdos.c (fatal_error_in_progress): ... from here. + * xdisp.c (redisplaying_p): Now a boolean. Set it to 1 instead + of incrementing it. + (redisplay_internal, unwind_redisplay): Simply clear + REDISPLAYING_P when unwinding, instead of saving its previous, + always-false value and then restoring it. + + Clean up some extern decls. + Mostly, this hoists extern decls out of .c files and into .h files. + That way, we're more likely to catch errors if the interfaces change. + * alloc.c [USE_GTK]: Include "gtkutil.h" so that we need not + declare xg_mark_data. + * dispextern.h (x_frame_parm_handlers): + * font.h (Qxft): + * lisp.h (Qlexical_binding, Qinternal_interpreter_environment) + (Qextra_light, Qlight, Qsemi_light, Qsemi_bold, Qbold, Qextra_bold) + (Qultra_bold, Qoblique, Qitalic): + Move extern decl here from .c file. + * alloc.c (xg_mark_data) [USE_GTK]: + * doc.c (Qclosure): + * eval.c (Qlexical_binding): + * fns.c (time) [!HAVE_UNISTD_H]: + * gtkutil.c (Qxft, Qnormal, Qextra_light, Qlight, Qsemi_light) + (Qsemi_bold, Qbold, Qextra_bold, Qultra_bold, Qoblique, Qitalic): + * image.c (Vlibrary_cache, QCloaded_from) [HAVE_NTGUI]: + * lread.c (Qinternal_interpreter_environment): + * minibuf.c (Qbuffer): + * process.c (QCfamily, QCfilter): + * widget.c (free_frame_faces): + * xfaces.c (free_frame_menubar) [USE_X_TOOLKIT]: + * xfont.c (x_clear_errors): + * xterm.c (x_frame_parm_handlers): + Remove now-redundant extern decls. + * keyboard.c, keyboard.h (ignore_mouse_drag_p) [USE_GTK || HAVE_NS]: + * xfaces.c (Qultra_light, Qreverse_oblique, Qreverse_italic): + Now static. + * xfaces.c: Remove unnecessary static decls. + * xterm.c (updating_frame): Remove decl of nonexistent object. + + * Makefile.in (gl-stamp): Don't scan $(SOME_MACHINE_OBJECTS) + when building globals.h, as the objects that are not built on + this host are not needed to compile C files on this host. + 2012-09-02 Jan Djärv <jan.h.d@swipnet.se> * gtkutil.h: Remove prototype for x_wm_set_size_hint. @@ -187,18 +1085,18 @@ 2012-08-28 Jan Djärv <jan.h.d@swipnet.se> * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize - button_values to NULL. Call setStykeMask so dialogs get a close button. + button_values to NULL. Call setStykeMask so dialogs get a close button. (windowShouldClose:): Set window_closed. (dealloc): New member, free button_values. - (process_dialog:): Make member function. Remove window argument, - replace window with self. Count buttons and allocate and store values + (process_dialog:): Make member function. Remove window argument, + replace window with self. Count buttons and allocate and store values in button_values. (addButton:value:row:): value is int with the name tag. Call setTag - with tag. Remove return self, declare return value as void. + with tag. Remove return self, declare return value as void. (addString:row:): Remove return self, declare return value as void. (addSplit): Remove return self, declare return value as void. (clicked:): Remove return self, declare return value as void. - Set dialog_return to button_values[seltag]. Code formatting change. + Set dialog_return to button_values[seltag]. Code formatting change. (initFromContents:isQuestion:): Adjust call to process_dialog. Code formatting change. (timeout_handler:): Set timer_fired to YES. @@ -533,7 +1431,7 @@ * fontset.c (FONTSET_ADD): Return void, not Lisp_Object. Otherwise, the compiler complains about (A?B:C) where B is void - and C is Lisp_Object. This fixes an incompatibility with Sun C 5.12. + and C is Lisp_Object. This fixes an incompatibility with Sun C 5.12. (fontset_add): Return void, for FONTSET_ADD. 2012-08-21 Paul Eggert <eggert@cs.ucla.edu> @@ -1049,7 +1947,7 @@ Start main loop and wait for application defined event. Inform select thread to stop selecting after main loop is exited. (ns_term_init): Create selfds pipe and set non-blocking. - Initialize select_mutex. Start the select thread (fd_handler). + Initialize select_mutex. Start the select thread (fd_handler). (fd_handler:): Loop forever, wait for info from the main thread to either start or stop selecting. When select returns, send and appdefined event. @@ -1181,7 +2079,7 @@ (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info if not present. (update_frame_tool_bar): Return early if data in xg_frame_tb_info - is up to date. Otherwise store new data. + is up to date. Otherwise store new data. (free_frame_tool_bar): Free xg_frame_tb_info if present. 2012-08-13 Dmitry Antipov <dmantipov@yandex.ru> @@ -1208,7 +2106,7 @@ 2012-08-11 Jan Djärv <jan.h.d@swipnet.se> * nsterm.m (not_in_argv): New function. - (application:openFile, application:openTempFile:): + (application:openFile, application:openTempFile:): (application:openFileWithoutUI:, application:openFiles:): Open file if not_in_argv returns non-zero (bug#12171). @@ -2395,7 +3293,7 @@ 2012-07-21 Jan Djärv <jan.h.d@swipnet.se> - * nsterm.m (accessibilityAttributeValue): New function. (Bug#11134). + * nsterm.m (accessibilityAttributeValue): New function. (Bug#11134). (conversationIdentifier): Return value is NSInteger. * nsterm.m (accessibilityAttributeValue): Surround with NS_IMPL_COCOA. @@ -4905,7 +5803,7 @@ * lisp.h (struct vectorlike_header): New field `nbytes', adjust comment accordingly. * alloc.c (enum mem_type): New type `MEM_TYPE_VECTOR_BLOCK' - to denote vector blocks. Adjust users (live_vector_p, + to denote vector blocks. Adjust users (live_vector_p, mark_maybe_pointer, valid_lisp_object_p) accordingly. (COMMON_MULTIPLE): Move outside #if USE_LSB_TAG. (VECTOR_BLOCK_SIZE, vroundup, VECTOR_BLOCK_BYTES), @@ -4919,7 +5817,7 @@ (allocate_vector_from_block, init_vectors, allocate_vector_from_block) (sweep_vectors): New functions. (allocate_vectorlike): Return `zero_vector' as the only vector of - 0 items. Allocate new vector from block if vector size is less than + 0 items. Allocate new vector from block if vector size is less than or equal to VBLOCK_BYTES_MAX. (Fgarbage_collect): Move all vector sweeping code to sweep_vectors. (init_alloc_once): Add call to init_vectors. @@ -5009,7 +5907,7 @@ change it's type from Lisp_Object to bitfield. Change type of 'force_start', 'optional_new_start', 'last_had_star', 'update_mode_line' and 'start_at_line_beg' - fields from Lisp_Object to bitfield. Adjust users accordingly. + fields from Lisp_Object to bitfield. Adjust users accordingly. 2012-05-31 Paul Eggert <eggert@cs.ucla.edu> diff --git a/src/Makefile.in b/src/Makefile.in index 847a5e58fd7..a31499e2767 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -252,9 +252,6 @@ MSDOS_OBJ = ## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. MSDOS_X_OBJ = -ns_appdir=@ns_appdir@ -ns_appbindir=@ns_appbindir@ -ns_appsrc=@ns_appsrc@ NS_OBJ=@NS_OBJ@ ## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS. NS_OBJC_OBJ=@NS_OBJC_OBJ@ @@ -453,7 +450,7 @@ GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m) gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) @rm -f gl-tmp - $(libsrc)/make-docfile -d $(srcdir) -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp + $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl-tmp $(srcdir)/../build-aux/move-if-change gl-tmp globals.h echo timestamp > $@ @@ -506,8 +503,9 @@ $(OLDXMENU): $(OLDXMENU_TARGET) doc.o: buildobj.h -## If HAVE_NS, some ns-specific rules (for OTHER_FILES) are inserted here. -@ns_frag@ +ns-app: emacs$(EXEEXT) + cd ../nextstep && $(MAKE) $(MFLAGS) all + .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean .PHONY: versionclean extraclean frc @@ -521,7 +519,6 @@ mostlyclean: clean: mostlyclean rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT) -rm -rf $(DEPDIR) - test "X$(ns_appdir)" = "X" || rm -rf $(ns_appdir) ## bootstrap-clean is used to clean up just before a bootstrap. ## It should remove all files generated during a compilation/bootstrap, diff --git a/src/alloc.c b/src/alloc.c index e8637471bc7..fb7d35b5590 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -24,9 +24,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <limits.h> /* For CHAR_BIT. */ -#include <setjmp.h> -#include <signal.h> +#ifdef ENABLE_CHECKING +#include <signal.h> /* For SIGABRT. */ +#endif #ifdef HAVE_PTHREAD #include <pthread.h> @@ -42,9 +43,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keyboard.h" #include "frame.h" #include "blockinput.h" -#include "syssignal.h" #include "termhooks.h" /* For struct terminal. */ -#include <setjmp.h> + #include <verify.h> /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. @@ -69,6 +69,9 @@ extern void *sbrk (); #include <fcntl.h> +#ifdef USE_GTK +# include "gtkutil.h" +#endif #ifdef WINDOWSNT #include "w32.h" #endif @@ -82,66 +85,8 @@ extern void *sbrk (); #define MMAP_MAX_AREAS 100000000 -#else /* not DOUG_LEA_MALLOC */ - -/* The following come from gmalloc.c. */ - -extern size_t _bytes_used; -extern size_t __malloc_extra_blocks; -extern void *_malloc_internal (size_t); -extern void _free_internal (void *); - #endif /* not DOUG_LEA_MALLOC */ -#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT -#ifdef HAVE_PTHREAD - -/* When GTK uses the file chooser dialog, different backends can be loaded - dynamically. One such a backend is the Gnome VFS backend that gets loaded - if you run Gnome. That backend creates several threads and also allocates - memory with malloc. - - Also, gconf and gsettings may create several threads. - - If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* - functions below are called from malloc, there is a chance that one - of these threads preempts the Emacs main thread and the hook variables - end up in an inconsistent state. So we have a mutex to prevent that (note - that the backend handles concurrent access to malloc within its own threads - but Emacs code running in the main thread is not included in that control). - - When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this - happens in one of the backend threads we will have two threads that tries - to run Emacs code at once, and the code is not prepared for that. - To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ - -static pthread_mutex_t alloc_mutex; - -#define BLOCK_INPUT_ALLOC \ - do \ - { \ - if (pthread_equal (pthread_self (), main_thread)) \ - BLOCK_INPUT; \ - pthread_mutex_lock (&alloc_mutex); \ - } \ - while (0) -#define UNBLOCK_INPUT_ALLOC \ - do \ - { \ - pthread_mutex_unlock (&alloc_mutex); \ - if (pthread_equal (pthread_self (), main_thread)) \ - UNBLOCK_INPUT; \ - } \ - while (0) - -#else /* ! defined HAVE_PTHREAD */ - -#define BLOCK_INPUT_ALLOC BLOCK_INPUT -#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT - -#endif /* ! defined HAVE_PTHREAD */ -#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ - /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer to a struct Lisp_String. */ @@ -200,10 +145,6 @@ static char *spare_memory[7]; #define SPARE_MEMORY (1 << 14) -/* Number of extra blocks malloc should get when it needs more core. */ - -static int malloc_hysteresis; - /* Initialize it to a nonzero value to force it into data space (rather than bss space). That way unexec will remap it into text space (pure), on some systems. We have not implemented the @@ -275,6 +216,7 @@ static void gc_sweep (void); static Lisp_Object make_pure_vector (ptrdiff_t); static void mark_glyph_matrix (struct glyph_matrix *); static void mark_face_cache (struct face_cache *); +static void mark_buffer (struct buffer *); #if !defined REL_ALLOC || defined SYSTEM_MALLOC static void refill_memory_reserve (void); @@ -407,12 +349,12 @@ static void mark_memory (void *, void *); static void mem_init (void); static struct mem_node *mem_insert (void *, void *, enum mem_type); static void mem_insert_fixup (struct mem_node *); -#endif static void mem_rotate_left (struct mem_node *); static void mem_rotate_right (struct mem_node *); static void mem_delete (struct mem_node *); static void mem_delete_fixup (struct mem_node *); static inline struct mem_node *mem_find (void *); +#endif #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS @@ -581,39 +523,17 @@ xmalloc_get_size (unsigned char *ptr) } -/* The call depth in overrun_check functions. For example, this might happen: - xmalloc() - overrun_check_malloc() - -> malloc -> (via hook)_-> emacs_blocked_malloc - -> overrun_check_malloc - call malloc (hooks are NULL, so real malloc is called). - malloc returns 10000. - add overhead, return 10016. - <- (back in overrun_check_malloc) - add overhead again, return 10032 - xmalloc returns 10032. - - (time passes). - - xfree(10032) - overrun_check_free(10032) - decrease overhead - free(10016) <- crash, because 10000 is the original pointer. */ - -static ptrdiff_t check_depth; - /* Like malloc, but wraps allocated block with header and trailer. */ static void * overrun_check_malloc (size_t size) { register unsigned char *val; - int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; - if (SIZE_MAX - overhead < size) - abort (); + if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size) + emacs_abort (); - val = malloc (size + overhead); - if (val && check_depth == 1) + val = malloc (size + XMALLOC_OVERRUN_CHECK_OVERHEAD); + if (val) { memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; @@ -621,7 +541,6 @@ overrun_check_malloc (size_t size) memcpy (val + size, xmalloc_overrun_check_trailer, XMALLOC_OVERRUN_CHECK_SIZE); } - --check_depth; return val; } @@ -633,12 +552,10 @@ static void * overrun_check_realloc (void *block, size_t size) { register unsigned char *val = (unsigned char *) block; - int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; - if (SIZE_MAX - overhead < size) - abort (); + if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size) + emacs_abort (); if (val - && check_depth == 1 && memcmp (xmalloc_overrun_check_header, val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, XMALLOC_OVERRUN_CHECK_SIZE) == 0) @@ -646,15 +563,15 @@ overrun_check_realloc (void *block, size_t size) size_t osize = xmalloc_get_size (val); if (memcmp (xmalloc_overrun_check_trailer, val + osize, XMALLOC_OVERRUN_CHECK_SIZE)) - abort (); + emacs_abort (); memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); } - val = realloc (val, size + overhead); + val = realloc (val, size + XMALLOC_OVERRUN_CHECK_OVERHEAD); - if (val && check_depth == 1) + if (val) { memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; @@ -662,7 +579,6 @@ overrun_check_realloc (void *block, size_t size) memcpy (val + size, xmalloc_overrun_check_trailer, XMALLOC_OVERRUN_CHECK_SIZE); } - --check_depth; return val; } @@ -673,9 +589,7 @@ overrun_check_free (void *block) { unsigned char *val = (unsigned char *) block; - ++check_depth; if (val - && check_depth == 1 && memcmp (xmalloc_overrun_check_header, val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, XMALLOC_OVERRUN_CHECK_SIZE) == 0) @@ -683,7 +597,7 @@ overrun_check_free (void *block) size_t osize = xmalloc_get_size (val); if (memcmp (xmalloc_overrun_check_trailer, val + osize, XMALLOC_OVERRUN_CHECK_SIZE)) - abort (); + emacs_abort (); #ifdef XMALLOC_CLEAR_FREE_MEMORY val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD); @@ -695,7 +609,6 @@ overrun_check_free (void *block) } free (val); - --check_depth; } #undef malloc @@ -706,14 +619,33 @@ overrun_check_free (void *block) #define free overrun_check_free #endif -#ifdef SYNC_INPUT -/* When using SYNC_INPUT, we don't call malloc from a signal handler, so - there's no need to block input around malloc. */ -#define MALLOC_BLOCK_INPUT ((void)0) -#define MALLOC_UNBLOCK_INPUT ((void)0) +/* If compiled with XMALLOC_BLOCK_INPUT_CHECK, define a symbol + BLOCK_INPUT_IN_MEMORY_ALLOCATORS that is visible to the debugger. + If that variable is set, block input while in one of Emacs's memory + allocation functions. There should be no need for this debugging + option, since signal handlers do not allocate memory, but Emacs + formerly allocated memory in signal handlers and this compile-time + option remains as a way to help debug the issue should it rear its + ugly head again. */ +#ifdef XMALLOC_BLOCK_INPUT_CHECK +bool block_input_in_memory_allocators EXTERNALLY_VISIBLE; +static void +malloc_block_input (void) +{ + if (block_input_in_memory_allocators) + BLOCK_INPUT; +} +static void +malloc_unblock_input (void) +{ + if (block_input_in_memory_allocators) + UNBLOCK_INPUT; +} +# define MALLOC_BLOCK_INPUT malloc_block_input () +# define MALLOC_UNBLOCK_INPUT malloc_unblock_input () #else -#define MALLOC_BLOCK_INPUT BLOCK_INPUT -#define MALLOC_UNBLOCK_INPUT UNBLOCK_INPUT +# define MALLOC_BLOCK_INPUT ((void) 0) +# define MALLOC_UNBLOCK_INPUT ((void) 0) #endif /* Like malloc but check for no memory and block interrupt input.. */ @@ -782,8 +714,7 @@ xfree (void *block) free (block); MALLOC_UNBLOCK_INPUT; /* We don't call refill_memory_reserve here - because that duplicates doing so in emacs_blocked_free - and the criterion should go there. */ + because in practice the call in r_alloc_free seems to suffice. */ } @@ -1210,256 +1141,6 @@ lisp_align_free (void *block) } -#ifndef SYSTEM_MALLOC - -/* Arranging to disable input signals while we're in malloc. - - This only works with GNU malloc. To help out systems which can't - use GNU malloc, all the calls to malloc, realloc, and free - elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT - pair; unfortunately, we have no idea what C library functions - might call malloc, so we can't really protect them unless you're - using GNU malloc. Fortunately, most of the major operating systems - can use GNU malloc. */ - -#ifndef SYNC_INPUT -/* When using SYNC_INPUT, we don't call malloc from a signal handler, so - there's no need to block input around malloc. */ - -#ifndef DOUG_LEA_MALLOC -extern void * (*__malloc_hook) (size_t, const void *); -extern void * (*__realloc_hook) (void *, size_t, const void *); -extern void (*__free_hook) (void *, const void *); -/* Else declared in malloc.h, perhaps with an extra arg. */ -#endif /* DOUG_LEA_MALLOC */ -static void * (*old_malloc_hook) (size_t, const void *); -static void * (*old_realloc_hook) (void *, size_t, const void*); -static void (*old_free_hook) (void*, const void*); - -#ifdef DOUG_LEA_MALLOC -# define BYTES_USED (mallinfo ().uordblks) -#else -# define BYTES_USED _bytes_used -#endif - -#ifdef GC_MALLOC_CHECK -static bool dont_register_blocks; -#endif - -static size_t bytes_used_when_reconsidered; - -/* Value of _bytes_used, when spare_memory was freed. */ - -static size_t bytes_used_when_full; - -/* This function is used as the hook for free to call. */ - -static void -emacs_blocked_free (void *ptr, const void *ptr2) -{ - BLOCK_INPUT_ALLOC; - -#ifdef GC_MALLOC_CHECK - if (ptr) - { - struct mem_node *m; - - m = mem_find (ptr); - if (m == MEM_NIL || m->start != ptr) - { - fprintf (stderr, - "Freeing `%p' which wasn't allocated with malloc\n", ptr); - abort (); - } - else - { - /* fprintf (stderr, "free %p...%p (%p)\n", m->start, m->end, ptr); */ - mem_delete (m); - } - } -#endif /* GC_MALLOC_CHECK */ - - __free_hook = old_free_hook; - free (ptr); - - /* If we released our reserve (due to running out of memory), - and we have a fair amount free once again, - try to set aside another reserve in case we run out once more. */ - if (! NILP (Vmemory_full) - /* Verify there is enough space that even with the malloc - hysteresis this call won't run out again. - The code here is correct as long as SPARE_MEMORY - is substantially larger than the block size malloc uses. */ - && (bytes_used_when_full - > ((bytes_used_when_reconsidered = BYTES_USED) - + max (malloc_hysteresis, 4) * SPARE_MEMORY))) - refill_memory_reserve (); - - __free_hook = emacs_blocked_free; - UNBLOCK_INPUT_ALLOC; -} - - -/* This function is the malloc hook that Emacs uses. */ - -static void * -emacs_blocked_malloc (size_t size, const void *ptr) -{ - void *value; - - BLOCK_INPUT_ALLOC; - __malloc_hook = old_malloc_hook; -#ifdef DOUG_LEA_MALLOC - /* Segfaults on my system. --lorentey */ - /* mallopt (M_TOP_PAD, malloc_hysteresis * 4096); */ -#else - __malloc_extra_blocks = malloc_hysteresis; -#endif - - value = malloc (size); - -#ifdef GC_MALLOC_CHECK - { - struct mem_node *m = mem_find (value); - if (m != MEM_NIL) - { - fprintf (stderr, "Malloc returned %p which is already in use\n", - value); - fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n", - m->start, m->end, (char *) m->end - (char *) m->start, - m->type); - abort (); - } - - if (!dont_register_blocks) - { - mem_insert (value, (char *) value + max (1, size), allocated_mem_type); - allocated_mem_type = MEM_TYPE_NON_LISP; - } - } -#endif /* GC_MALLOC_CHECK */ - - __malloc_hook = emacs_blocked_malloc; - UNBLOCK_INPUT_ALLOC; - - /* fprintf (stderr, "%p malloc\n", value); */ - return value; -} - - -/* This function is the realloc hook that Emacs uses. */ - -static void * -emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) -{ - void *value; - - BLOCK_INPUT_ALLOC; - __realloc_hook = old_realloc_hook; - -#ifdef GC_MALLOC_CHECK - if (ptr) - { - struct mem_node *m = mem_find (ptr); - if (m == MEM_NIL || m->start != ptr) - { - fprintf (stderr, - "Realloc of %p which wasn't allocated with malloc\n", - ptr); - abort (); - } - - mem_delete (m); - } - - /* fprintf (stderr, "%p -> realloc\n", ptr); */ - - /* Prevent malloc from registering blocks. */ - dont_register_blocks = 1; -#endif /* GC_MALLOC_CHECK */ - - value = realloc (ptr, size); - -#ifdef GC_MALLOC_CHECK - dont_register_blocks = 0; - - { - struct mem_node *m = mem_find (value); - if (m != MEM_NIL) - { - fprintf (stderr, "Realloc returns memory that is already in use\n"); - abort (); - } - - /* Can't handle zero size regions in the red-black tree. */ - mem_insert (value, (char *) value + max (size, 1), MEM_TYPE_NON_LISP); - } - - /* fprintf (stderr, "%p <- realloc\n", value); */ -#endif /* GC_MALLOC_CHECK */ - - __realloc_hook = emacs_blocked_realloc; - UNBLOCK_INPUT_ALLOC; - - return value; -} - - -#ifdef HAVE_PTHREAD -/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a - normal malloc. Some thread implementations need this as they call - malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then - calls malloc because it is the first call, and we have an endless loop. */ - -void -reset_malloc_hooks (void) -{ - __free_hook = old_free_hook; - __malloc_hook = old_malloc_hook; - __realloc_hook = old_realloc_hook; -} -#endif /* HAVE_PTHREAD */ - - -/* Called from main to set up malloc to use our hooks. */ - -void -uninterrupt_malloc (void) -{ -#ifdef HAVE_PTHREAD -#ifdef DOUG_LEA_MALLOC - pthread_mutexattr_t attr; - - /* GLIBC has a faster way to do this, but let's keep it portable. - This is according to the Single UNIX Specification. */ - pthread_mutexattr_init (&attr); - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init (&alloc_mutex, &attr); -#else /* !DOUG_LEA_MALLOC */ - /* Some systems such as Solaris 2.6 don't have a recursive mutex, - and the bundled gmalloc.c doesn't require it. */ - pthread_mutex_init (&alloc_mutex, NULL); -#endif /* !DOUG_LEA_MALLOC */ -#endif /* HAVE_PTHREAD */ - - if (__free_hook != emacs_blocked_free) - old_free_hook = __free_hook; - __free_hook = emacs_blocked_free; - - if (__malloc_hook != emacs_blocked_malloc) - old_malloc_hook = __malloc_hook; - __malloc_hook = emacs_blocked_malloc; - - if (__realloc_hook != emacs_blocked_realloc) - old_realloc_hook = __realloc_hook; - __realloc_hook = emacs_blocked_realloc; -} - -#endif /* not SYNC_INPUT */ -#endif /* not SYSTEM_MALLOC */ - - - /*********************************************************************** Interval Allocation ***********************************************************************/ @@ -1505,8 +1186,6 @@ make_interval (void) { INTERVAL val; - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; if (interval_free_list) @@ -1801,7 +1480,7 @@ string_bytes (struct Lisp_String *s) if (!PURE_POINTER_P (s) && s->data && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) - abort (); + emacs_abort (); return nbytes; } @@ -1875,7 +1554,7 @@ check_string_free_list (void) while (s != NULL) { if ((uintptr_t) s < 1024) - abort (); + emacs_abort (); s = NEXT_FREE_LISP_STRING (s); } } @@ -1890,8 +1569,6 @@ allocate_string (void) { struct Lisp_String *s; - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; /* If the free-list is empty, allocate a new string_block, and @@ -2104,7 +1781,7 @@ sweep_strings (void) back-pointer so that we know it's free. */ #ifdef GC_CHECK_STRING_BYTES if (string_bytes (s) != SDATA_NBYTES (data)) - abort (); + emacs_abort (); #else data->u.nbytes = STRING_BYTES (s); #endif @@ -2215,7 +1892,7 @@ compact_small_strings (void) /* Check that the string size recorded in the string is the same as the one recorded in the sdata structure. */ if (s && string_bytes (s) != SDATA_NBYTES (from)) - abort (); + emacs_abort (); #endif /* GC_CHECK_STRING_BYTES */ nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); @@ -2228,7 +1905,7 @@ compact_small_strings (void) if (memcmp (string_overrun_cookie, (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, GC_STRING_OVERRUN_COOKIE_SIZE)) - abort (); + emacs_abort (); #endif /* Non-NULL S means it's alive. Copy its data. */ @@ -2485,7 +2162,7 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes) struct Lisp_String *s; if (nchars < 0) - abort (); + emacs_abort (); if (!nbytes) return empty_multibyte_string; @@ -2583,8 +2260,6 @@ make_float (double float_value) { register Lisp_Object val; - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; if (float_free_list) @@ -2692,8 +2367,6 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, { register Lisp_Object val; - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; if (cons_free_list) @@ -2806,7 +2479,7 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...) else if (type == CONSTYPE_HEAP) val = Fcons (objp[i], val); else - abort (); + emacs_abort (); } return val; } @@ -3199,9 +2872,6 @@ allocate_vectorlike (ptrdiff_t len) MALLOC_BLOCK_INPUT; - /* This gets triggered by code which I haven't bothered to fix. --Stef */ - /* eassert (!handling_signal); */ - if (len == 0) p = XVECTOR (zero_vector); else @@ -3278,7 +2948,10 @@ allocate_buffer (void) XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) - header_size) / word_size); - /* Note that the fields of B are not initialized. */ + /* Put B on the chain of all buffers including killed ones. */ + b->header.next.buffer = all_buffers; + all_buffers = b; + /* Note that the rest fields of B are not initialized. */ return b; } @@ -3483,8 +3156,6 @@ Its value and function definition are void, and its property list is nil. */) CHECK_STRING (name); - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; if (symbol_free_list) @@ -3569,8 +3240,6 @@ allocate_misc (enum Lisp_Misc_Type type) { Lisp_Object val; - /* eassert (!handling_signal); */ - MALLOC_BLOCK_INPUT; if (marker_free_list) @@ -3674,7 +3343,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) struct Lisp_Marker *m; /* No dead buffers here. */ - eassert (!NILP (BVAR (buf, name))); + eassert (BUFFER_LIVE_P (buf)); /* Every character is at least one byte. */ eassert (charpos <= bytepos); @@ -3790,12 +3459,6 @@ memory_full (size_t nbytes) lisp_free (spare_memory[i]); spare_memory[i] = 0; } - - /* Record the space now used. When it decreases substantially, - we can refill the memory reserve. */ -#if !defined SYSTEM_MALLOC && !defined SYNC_INPUT - bytes_used_when_full = BYTES_USED; -#endif } /* This used to call error, but if we've run out of memory, we could @@ -3916,7 +3579,7 @@ mem_insert (void *start, void *end, enum mem_type type) while (c != MEM_NIL) { if (start >= c->start && start < c->end) - abort (); + emacs_abort (); parent = c; c = start < c->start ? c->left : c->right; } @@ -3933,9 +3596,9 @@ mem_insert (void *start, void *end, enum mem_type type) /* Create a new node. */ #ifdef GC_MALLOC_CHECK - x = _malloc_internal (sizeof *x); + x = malloc (sizeof *x); if (x == NULL) - abort (); + emacs_abort (); #else x = xmalloc (sizeof *x); #endif @@ -4157,7 +3820,7 @@ mem_delete (struct mem_node *z) mem_delete_fixup (x); #ifdef GC_MALLOC_CHECK - _free_internal (y); + free (y); #else xfree (y); #endif @@ -4610,7 +4273,7 @@ mark_maybe_pointer (void *p) break; default: - abort (); + emacs_abort (); } if (!NILP (obj)) @@ -4754,14 +4417,14 @@ test_setjmp (void) { char buf[10]; register int x; - jmp_buf jbuf; + sys_jmp_buf jbuf; /* Arrange for X to be put in a register. */ sprintf (buf, "1"); x = strlen (buf); x = 2 * x - 1; - setjmp (jbuf); + sys_setjmp (jbuf); if (longjmps_done == 1) { /* Came here after the longjmp at the end of the function. @@ -4786,7 +4449,7 @@ test_setjmp (void) ++longjmps_done; x = 2; if (longjmps_done == 1) - longjmp (jbuf, 1); + sys_longjmp (jbuf, 1); } #endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ @@ -4807,7 +4470,7 @@ check_gcpros (void) if (!survives_gc_p (p->var[i])) /* FIXME: It's not necessarily a bug. It might just be that the GCPRO is unnecessary or should release the object sooner. */ - abort (); + emacs_abort (); } #elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES @@ -4892,7 +4555,7 @@ mark_stack (void) /* jmp_buf may not be aligned enough on darwin-ppc64 */ union aligned_jmpbuf { Lisp_Object o; - jmp_buf j; + sys_jmp_buf j; } j; volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base; #endif @@ -4928,7 +4591,7 @@ mark_stack (void) } #endif /* GC_SETJMP_WORKS */ - setjmp (j.j); + sys_setjmp (j.j); end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; #endif /* not GC_SAVE_REGISTERS_ON_STACK */ #endif /* not HAVE___BUILTIN_UNWIND_INIT */ @@ -4978,7 +4641,8 @@ valid_pointer_p (void *p) #endif } -/* Return 1 if OBJ is a valid lisp object. +/* Return 2 if OBJ is a killed or special buffer object. + Return 1 if OBJ is a valid lisp object. Return 0 if OBJ is NOT a valid lisp object. Return -1 if we cannot validate OBJ. This function can be quite slow, @@ -4999,6 +4663,9 @@ valid_lisp_object_p (Lisp_Object obj) if (PURE_POINTER_P (p)) return 1; + if (p == &buffer_defaults || p == &buffer_local_symbols) + return 2; + #if !GC_MARK_STACK return valid_pointer_p (p); #else @@ -5024,7 +4691,7 @@ valid_lisp_object_p (Lisp_Object obj) return 0; case MEM_TYPE_BUFFER: - return live_buffer_p (m, p); + return live_buffer_p (m, p) ? 1 : 2; case MEM_TYPE_CONS: return live_cons_p (m, p); @@ -5348,7 +5015,7 @@ staticpro (Lisp_Object *varaddress) { staticvec[staticidx++] = varaddress; if (staticidx >= NSTATICS) - abort (); + emacs_abort (); } @@ -5403,7 +5070,7 @@ See Info node `(elisp)Garbage Collection'. */) Lisp_Object retval = Qnil; if (abort_on_gc) - abort (); + emacs_abort (); /* Can't GC if pure storage overflowed because we can't determine if something is a pure object or not. */ @@ -5466,6 +5133,9 @@ See Info node `(elisp)Garbage Collection'. */) /* Mark all the special slots that serve as the roots of accessibility. */ + mark_buffer (&buffer_defaults); + mark_buffer (&buffer_local_symbols); + for (i = 0; i < staticidx; i++) mark_object (*staticvec[i]); @@ -5478,10 +5148,7 @@ See Info node `(elisp)Garbage Collection'. */) mark_kboards (); #ifdef USE_GTK - { - extern void xg_mark_data (void); - xg_mark_data (); - } + xg_mark_data (); #endif #if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \ @@ -5853,6 +5520,32 @@ mark_buffer (struct buffer *buffer) mark_buffer (buffer->base_buffer); } +/* Remove killed buffers or items whose car is a killed buffer from + LIST, and mark other items. Return changed LIST, which is marked. */ + +static Lisp_Object +mark_discard_killed_buffers (Lisp_Object list) +{ + Lisp_Object tail, *prev = &list; + + for (tail = list; CONSP (tail) && !CONS_MARKED_P (XCONS (tail)); + tail = XCDR (tail)) + { + Lisp_Object tem = XCAR (tail); + if (CONSP (tem)) + tem = XCAR (tem); + if (BUFFERP (tem) && !BUFFER_LIVE_P (XBUFFER (tem))) + *prev = XCDR (tail); + else + { + CONS_MARK (XCONS (tail)); + mark_object (XCAR (tail)); + prev = &XCDR_AS_LVALUE (tail); + } + } + return list; +} + /* Determine type of generic Lisp_Object and mark it accordingly. */ void @@ -5887,7 +5580,7 @@ mark_object (Lisp_Object arg) do { \ m = mem_find (po); \ if (m == MEM_NIL) \ - abort (); \ + emacs_abort (); \ } while (0) /* Check that the object pointed to by PO is live, using predicate @@ -5895,7 +5588,7 @@ mark_object (Lisp_Object arg) #define CHECK_LIVE(LIVEP) \ do { \ if (!LIVEP (m, po)) \ - abort (); \ + emacs_abort (); \ } while (0) /* Check both of the above conditions. */ @@ -5940,10 +5633,8 @@ mark_object (Lisp_Object arg) #ifdef GC_CHECK_MARKED_OBJECTS m = mem_find (po); - if (m == MEM_NIL && !SUBRP (obj) - && po != &buffer_defaults - && po != &buffer_local_symbols) - abort (); + if (m == MEM_NIL && !SUBRP (obj)) + emacs_abort (); #endif /* GC_CHECK_MARKED_OBJECTS */ if (ptr->header.size & PSEUDOVECTOR_FLAG) @@ -5959,15 +5650,14 @@ mark_object (Lisp_Object arg) { case PVEC_BUFFER: #ifdef GC_CHECK_MARKED_OBJECTS - if (po != &buffer_defaults && po != &buffer_local_symbols) - { - struct buffer *b; - FOR_EACH_BUFFER (b) - if (b == po) - break; - if (b == NULL) - abort (); - } + { + struct buffer *b; + FOR_EACH_BUFFER (b) + if (b == po) + break; + if (b == NULL) + emacs_abort (); + } #endif /* GC_CHECK_MARKED_OBJECTS */ mark_buffer ((struct buffer *) ptr); break; @@ -5992,22 +5682,31 @@ mark_object (Lisp_Object arg) break; case PVEC_FRAME: - { - mark_vectorlike (ptr); - mark_face_cache (((struct frame *) ptr)->face_cache); - } + mark_vectorlike (ptr); + mark_face_cache (((struct frame *) ptr)->face_cache); break; case PVEC_WINDOW: { struct window *w = (struct window *) ptr; + bool leaf = NILP (w->hchild) && NILP (w->vchild); + + /* For live windows, Lisp code filters out killed buffers + from both buffer lists. For dead windows, we do it here + in attempt to help GC to reclaim killed buffers faster. */ + if (leaf && NILP (w->buffer)) + { + wset_prev_buffers + (w, mark_discard_killed_buffers (w->prev_buffers)); + wset_next_buffers + (w, mark_discard_killed_buffers (w->next_buffers)); + } mark_vectorlike (ptr); /* Mark glyphs for leaf windows. Marking window matrices is sufficient because frame matrices use the same glyph memory. */ - if (NILP (w->hchild) && NILP (w->vchild) - && w->current_matrix) + if (leaf && w->current_matrix) { mark_glyph_matrix (w->current_matrix); mark_glyph_matrix (w->desired_matrix); @@ -6042,7 +5741,7 @@ mark_object (Lisp_Object arg) break; case PVEC_FREE: - abort (); + emacs_abort (); default: mark_vectorlike (ptr); @@ -6074,10 +5773,14 @@ mark_object (Lisp_Object arg) case SYMBOL_LOCALIZED: { struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr); - /* If the value is forwarded to a buffer or keyboard field, - these are marked when we see the corresponding object. - And if it's forwarded to a C variable, either it's not - a Lisp_Object var, or it's staticpro'd already. */ + Lisp_Object where = blv->where; + /* If the value is set up for a killed buffer or deleted + frame, restore it's global binding. If the value is + forwarded to a C variable, either it's not a Lisp_Object + var, or it's staticpro'd already. */ + if ((BUFFERP (where) && !BUFFER_LIVE_P (XBUFFER (where))) + || (FRAMEP (where) && !FRAME_LIVE_P (XFRAME (where)))) + swap_in_global_binding (ptr); mark_object (blv->where); mark_object (blv->valcell); mark_object (blv->defcell); @@ -6089,7 +5792,7 @@ mark_object (Lisp_Object arg) And if it's forwarded to a C variable, either it's not a Lisp_Object var, or it's staticpro'd already. */ break; - default: abort (); + default: emacs_abort (); } if (!PURE_POINTER_P (XSTRING (ptr->name))) MARK_STRING (XSTRING (ptr->name)); @@ -6143,7 +5846,7 @@ mark_object (Lisp_Object arg) break; default: - abort (); + emacs_abort (); } break; @@ -6165,7 +5868,7 @@ mark_object (Lisp_Object arg) obj = ptr->u.cdr; cdr_count++; if (cdr_count == mark_object_loop_halt) - abort (); + emacs_abort (); goto loop; } @@ -6178,7 +5881,7 @@ mark_object (Lisp_Object arg) break; default: - abort (); + emacs_abort (); } #undef CHECK_LIVE @@ -6247,7 +5950,7 @@ survives_gc_p (Lisp_Object obj) break; default: - abort (); + emacs_abort (); } return survives_p || PURE_POINTER_P ((void *) XPNTR (obj)); @@ -6685,21 +6388,14 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) #ifdef ENABLE_CHECKING -# include <execinfo.h> - bool suppress_checking; void die (const char *msg, const char *file, int line) { - enum { NPOINTERS_MAX = 500 }; - void *buffer[NPOINTERS_MAX]; - int npointers; fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", file, line, msg); - npointers = backtrace (buffer, NPOINTERS_MAX); - backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); - abort (); + fatal_error_backtrace (SIGABRT, INT_MAX); } #endif @@ -6725,12 +6421,6 @@ init_alloc_once (void) init_strings (); init_vectors (); -#ifdef REL_ALLOC - malloc_hysteresis = 32; -#else - malloc_hysteresis = 0; -#endif - refill_memory_reserve (); gc_cons_threshold = GC_DEFAULT_THRESHOLD; } diff --git a/src/atimer.c b/src/atimer.c index eb3136ae55d..5dbd807872a 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -17,9 +17,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <signal.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "syssignal.h" #include "systime.h" @@ -41,7 +40,7 @@ static struct atimer *stopped_atimers; static struct atimer *atimers; -/* Non-zero means alarm_signal_handler has found ripe timers but +/* Non-zero means alarm signal handler has found ripe timers but interrupt_input_blocked was non-zero. In this case, timer functions are not called until the next UNBLOCK_INPUT because timer functions are expected to call X, and X cannot be assumed to be @@ -51,8 +50,24 @@ int pending_atimers; /* Block/unblock SIGALRM. */ -#define BLOCK_ATIMERS sigblock (sigmask (SIGALRM)) -#define UNBLOCK_ATIMERS sigunblock (sigmask (SIGALRM)) +static void +sigmask_atimers (int how) +{ + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGALRM); + pthread_sigmask (how, &blocked, 0); +} +static void +block_atimers (void) +{ + sigmask_atimers (SIG_BLOCK); +} +static void +unblock_atimers (void) +{ + sigmask_atimers (SIG_UNBLOCK); +} /* Function prototypes. */ @@ -60,8 +75,6 @@ static void set_alarm (void); static void schedule_atimer (struct atimer *); static struct atimer *append_atimer_lists (struct atimer *, struct atimer *); -static void alarm_signal_handler (int signo); - /* Start a new atimer of type TYPE. TIME specifies when the timer is ripe. FN is the function to call when the timer fires. @@ -111,7 +124,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, t->fn = fn; t->client_data = client_data; - BLOCK_ATIMERS; + block_atimers (); /* Compute the timer's expiration time. */ switch (type) @@ -132,7 +145,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, /* Insert the timer in the list of active atimers. */ schedule_atimer (t); - UNBLOCK_ATIMERS; + unblock_atimers (); /* Arrange for a SIGALRM at the time the next atimer is ripe. */ set_alarm (); @@ -148,7 +161,7 @@ cancel_atimer (struct atimer *timer) { int i; - BLOCK_ATIMERS; + block_atimers (); for (i = 0; i < 2; ++i) { @@ -175,7 +188,7 @@ cancel_atimer (struct atimer *timer) } } - UNBLOCK_ATIMERS; + unblock_atimers (); } @@ -206,7 +219,7 @@ append_atimer_lists (struct atimer *list_1, struct atimer *list_2) void stop_other_atimers (struct atimer *t) { - BLOCK_ATIMERS; + block_atimers (); if (t) { @@ -231,7 +244,7 @@ stop_other_atimers (struct atimer *t) stopped_atimers = append_atimer_lists (atimers, stopped_atimers); atimers = t; - UNBLOCK_ATIMERS; + unblock_atimers (); } @@ -246,7 +259,7 @@ run_all_atimers (void) struct atimer *t = atimers; struct atimer *next; - BLOCK_ATIMERS; + block_atimers (); atimers = stopped_atimers; stopped_atimers = NULL; @@ -257,7 +270,7 @@ run_all_atimers (void) t = next; } - UNBLOCK_ATIMERS; + unblock_atimers (); } } @@ -356,7 +369,6 @@ run_timers (void) if (! atimers) pending_atimers = 0; -#ifdef SYNC_INPUT if (pending_atimers) pending_signals = 1; else @@ -364,42 +376,36 @@ run_timers (void) pending_signals = interrupt_input_pending; set_alarm (); } -#else - if (! pending_atimers) - set_alarm (); -#endif } /* Signal handler for SIGALRM. SIGNO is the signal number, i.e. SIGALRM. */ -void -alarm_signal_handler (int signo) +static void +handle_alarm_signal (int sig) { -#ifndef SYNC_INPUT - SIGNAL_THREAD_CHECK (signo); -#endif - pending_atimers = 1; -#ifdef SYNC_INPUT pending_signals = 1; -#else - run_timers (); -#endif +} + +static void +deliver_alarm_signal (int sig) +{ + handle_on_main_thread (sig, handle_alarm_signal); } -/* Call alarm_signal_handler for pending timers. */ +/* Call alarm signal handler for pending timers. */ void do_pending_atimers (void) { if (pending_atimers) { - BLOCK_ATIMERS; + block_atimers (); run_timers (); - UNBLOCK_ATIMERS; + unblock_atimers (); } } @@ -412,7 +418,9 @@ turn_on_atimers (bool on) { if (on) { - signal (SIGALRM, alarm_signal_handler); + struct sigaction action; + emacs_sigaction_init (&action, deliver_alarm_signal); + sigaction (SIGALRM, &action, 0); set_alarm (); } else @@ -423,8 +431,10 @@ turn_on_atimers (bool on) void init_atimer (void) { + struct sigaction action; free_atimers = stopped_atimers = atimers = NULL; pending_atimers = 0; /* pending_signals is initialized in init_keyboard.*/ - signal (SIGALRM, alarm_signal_handler); + emacs_sigaction_init (&action, deliver_alarm_signal); + sigaction (SIGALRM, &action, 0); } diff --git a/src/bidi.c b/src/bidi.c index 6b3ac53d318..af0209565e2 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -56,7 +56,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -105,7 +104,7 @@ bidi_get_type (int ch, bidi_dir_t override) if (ch == BIDI_EOB) return NEUTRAL_B; if (ch < 0 || ch > MAX_CHAR) - abort (); + emacs_abort (); default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); /* Every valid character code, even those that are unassigned by the @@ -113,7 +112,7 @@ bidi_get_type (int ch, bidi_dir_t override) DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT (= zero) code from CHAR_TABLE_REF, that's a bug. */ if (default_type == UNKNOWN_BT) - abort (); + emacs_abort (); if (override == NEUTRAL_DIR) return default_type; @@ -141,7 +140,7 @@ bidi_get_type (int ch, bidi_dir_t override) else if (override == R2L) return STRONG_R; else - abort (); /* can't happen: handled above */ + emacs_abort (); /* can't happen: handled above */ } } } @@ -183,7 +182,7 @@ bidi_get_category (bidi_type_t type) case NEUTRAL_ON: return NEUTRAL; default: - abort (); + emacs_abort (); } } @@ -199,7 +198,7 @@ bidi_mirror_char (int c) if (c == BIDI_EOB) return c; if (c < 0 || c > MAX_CHAR) - abort (); + emacs_abort (); val = CHAR_TABLE_REF (bidi_mirror_table, c); if (INTEGERP (val)) @@ -215,7 +214,7 @@ bidi_mirror_char (int c) /* Minimal test we must do in optimized builds, to prevent weird crashes further down the road. */ if (v < 0 || v > MAX_CHAR) - abort (); + emacs_abort (); return v; } @@ -373,7 +372,7 @@ bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it) int current_scan_dir = bidi_it->scan_dir; if (idx < bidi_cache_start || idx >= bidi_cache_idx) - abort (); + emacs_abort (); bidi_copy_it (bidi_it, &bidi_cache[idx]); bidi_it->scan_dir = current_scan_dir; @@ -518,7 +517,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved) /* We should never cache on backward scans. */ if (bidi_it->scan_dir == -1) - abort (); + emacs_abort (); idx = bidi_cache_search (bidi_it->charpos, -1, 1); if (idx < 0) @@ -537,7 +536,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved) idx = bidi_cache_start; } if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); bidi_copy_it (&bidi_cache[idx], bidi_it); if (!resolved) bidi_cache[idx].resolved_level = -1; @@ -592,7 +591,7 @@ static inline int bidi_peek_at_next_level (struct bidi_it *bidi_it) { if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1) - abort (); + emacs_abort (); return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level; } @@ -612,7 +611,7 @@ bidi_push_it (struct bidi_it *bidi_it) /* Save the current iterator state in its entirety after the last used cache slot. */ bidi_cache_ensure_space (bidi_cache_idx); - memcpy (&bidi_cache[bidi_cache_idx++], bidi_it, sizeof (struct bidi_it)); + bidi_cache[bidi_cache_idx++] = *bidi_it; /* Push the current cache start onto the stack. */ eassert (bidi_cache_sp < IT_STACK_SIZE); @@ -629,18 +628,18 @@ void bidi_pop_it (struct bidi_it *bidi_it) { if (bidi_cache_start <= 0) - abort (); + emacs_abort (); /* Reset the next free cache slot index to what it was before the call to bidi_push_it. */ bidi_cache_idx = bidi_cache_start - 1; /* Restore the bidi iterator state saved in the cache. */ - memcpy (bidi_it, &bidi_cache[bidi_cache_idx], sizeof (struct bidi_it)); + *bidi_it = bidi_cache[bidi_cache_idx]; /* Pop the previous cache start from the stack. */ if (bidi_cache_sp <= 0) - abort (); + emacs_abort (); bidi_cache_start = bidi_cache_start_stack[--bidi_cache_sp]; /* Invalidate the last-used cache slot data. */ @@ -762,12 +761,12 @@ bidi_initialize (void) { bidi_type_table = uniprop_table (intern ("bidi-class")); if (NILP (bidi_type_table)) - abort (); + emacs_abort (); staticpro (&bidi_type_table); bidi_mirror_table = uniprop_table (intern ("mirroring")); if (NILP (bidi_mirror_table)) - abort (); + emacs_abort (); staticpro (&bidi_mirror_table); Qparagraph_start = intern ("paragraph-start"); @@ -885,7 +884,7 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg, else { if (!CHAR_HEAD_P (*p)) - abort (); + emacs_abort (); while (pos < end) { @@ -965,7 +964,7 @@ bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, /* We don't expect to find ourselves in the middle of a display property. Hopefully, it will never be needed. */ if (charpos > *disp_pos) - abort (); + emacs_abort (); /* Text covered by `display' properties and overlays with display properties or display strings is handled as a single character that represents the entire run of characters @@ -995,7 +994,7 @@ bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, } *nchars = disp_end_pos - *disp_pos; if (*nchars <= 0) - abort (); + emacs_abort (); if (string->s) *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos, disp_end_pos, string->unibyte); @@ -1160,7 +1159,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) dir = L2R; /* We should never be called at EOB or before BEGV. */ else if (bidi_it->charpos >= end || bytepos < begbyte) - abort (); + emacs_abort (); if (dir == L2R) { @@ -1298,7 +1297,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR); } else - abort (); + emacs_abort (); /* Contrary to UAX#9 clause P3, we only default the paragraph direction to L2R if we have no previous usable paragraph @@ -1325,7 +1324,7 @@ bidi_explicit_dir_char (int ch) bidi_type_t ch_type; if (!bidi_initialized) - abort (); + emacs_abort (); ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); return (ch_type == LRE || ch_type == LRO || ch_type == RLE || ch_type == RLO @@ -1378,10 +1377,10 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) /* Advance to the next character, skipping characters covered by display strings (nchars > 1). */ if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); bidi_it->charpos += bidi_it->nchars; if (bidi_it->ch_len == 0) - abort (); + emacs_abort (); bidi_it->bytepos += bidi_it->ch_len; } @@ -1581,7 +1580,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) } if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); if (level == prev_level) /* empty embedding */ saved_it.ignore_bn_limit = bidi_it->charpos + bidi_it->nchars; else /* this embedding is non-empty */ @@ -1644,7 +1643,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it) || type == RLE || type == RLO || type == PDF) - abort (); + emacs_abort (); if (new_level != prev_level || bidi_it->type == NEUTRAL_B) @@ -1685,7 +1684,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it) else if (bidi_it->sor == L2R) type = STRONG_L; else /* shouldn't happen! */ - abort (); + emacs_abort (); } if (type == WEAK_EN /* W2 */ && bidi_it->last_strong.type_after_w1 == STRONG_AL) @@ -1767,7 +1766,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it) : bidi_it->string.s); if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); next_char = (bidi_it->charpos + bidi_it->nchars >= eob ? BIDI_EOB @@ -1875,7 +1874,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it) || type == NEUTRAL_S || type == NEUTRAL_WS || type == NEUTRAL_ON)) - abort (); + emacs_abort (); if ((type != NEUTRAL_B /* Don't risk entering the long loop below if we are already at paragraph end. */ @@ -1930,7 +1929,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it) bidi_type_t next_type; if (bidi_it->scan_dir == -1) - abort (); + emacs_abort (); bidi_copy_it (&saved_it, bidi_it); /* Scan the text forward until we find the first non-neutral @@ -1979,7 +1978,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it) break; case WEAK_BN: if (!bidi_explicit_dir_char (bidi_it->ch)) - abort (); /* can't happen: BNs are skipped */ + emacs_abort (); /* can't happen: BNs are skipped */ /* FALLTHROUGH */ case NEUTRAL_B: /* Marched all the way to the end of this level run. @@ -1998,7 +1997,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it) } break; default: - abort (); + emacs_abort (); } type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type, next_type, current_level); @@ -2023,7 +2022,7 @@ bidi_type_of_next_char (struct bidi_it *bidi_it) /* This should always be called during a forward scan. */ if (bidi_it->scan_dir != 1) - abort (); + emacs_abort (); /* Reset the limit until which to ignore BNs if we step out of the area where we found only empty levels. */ @@ -2107,7 +2106,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) if (bidi_it->scan_dir > 0) { if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); next_char_pos = bidi_it->charpos + bidi_it->nchars; } else if (bidi_it->charpos >= bob) @@ -2143,7 +2142,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) if (bidi_it->scan_dir == -1) /* If we are going backwards, the iterator state is already cached from previous scans, and should be fully resolved. */ - abort (); + emacs_abort (); if (type == UNKNOWN_BT) type = bidi_type_of_next_char (bidi_it); @@ -2156,7 +2155,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) || (type == WEAK_BN && prev_level == level)) { if (bidi_it->next_for_neutral.type == UNKNOWN_BT) - abort (); + emacs_abort (); /* If the cached state shows a neutral character, it was not resolved by bidi_resolve_neutral, so do it now. */ @@ -2170,7 +2169,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) || type == WEAK_BN || type == WEAK_EN || type == WEAK_AN)) - abort (); + emacs_abort (); bidi_it->type = type; bidi_check_type (bidi_it->type); @@ -2192,7 +2191,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) int dpp = bidi_it->disp_prop; if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); do { ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs, fwp, &clen, &nc); @@ -2301,8 +2300,9 @@ bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, bool end_flag) { int new_level; + /* If we are at end of level, its edges must be cached. */ if (end_flag) - abort (); /* if we are at end of level, its edges must be cached */ + emacs_abort (); bidi_cache_iterator_state (bidi_it, 1); do { @@ -2320,7 +2320,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) struct gcpro gcpro1; if (bidi_it->charpos < 0 || bidi_it->bytepos < 0) - abort (); + emacs_abort (); if (bidi_it->scan_dir == 0) { @@ -2431,7 +2431,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars, bidi_it->bytepos + bidi_it->ch_len); if (bidi_it->nchars <= 0) - abort (); + emacs_abort (); if (sep_len >= 0) { bidi_it->new_paragraph = 1; diff --git a/src/blockinput.h b/src/blockinput.h index dc02919cf4f..7501bfc91a0 100644 --- a/src/blockinput.h +++ b/src/blockinput.h @@ -67,15 +67,10 @@ extern int pending_atimers; If doing signal-driven input, and a signal came in when input was blocked, reinvoke the signal handler now to deal with it. - We used to have two possible definitions of this macro - one for - when SIGIO was #defined, and one for when it wasn't; when SIGIO - wasn't #defined, we wouldn't bother to check if we should re-invoke - the signal handler. But that doesn't work very well; some of the - files which use this macro don't #include the right files to get - SIGIO. - - So, we always test interrupt_input_pending now; that's not too - expensive, and it'll never get set if we don't need to resignal. */ + Always test interrupt_input_pending; that's not too expensive, and + it'll never get set if we don't need to resignal. This is simpler + than dealing here with every configuration option that might affect + whether interrupt_input_pending can be nonzero. */ #define UNBLOCK_INPUT \ do \ @@ -89,7 +84,7 @@ extern int pending_atimers; do_pending_atimers (); \ } \ else if (interrupt_input_blocked < 0) \ - abort (); \ + emacs_abort (); \ } \ while (0) @@ -124,4 +119,3 @@ extern int pending_atimers; extern void reinvoke_input_signal (void); #endif /* EMACS_BLOCKINPUT_H */ - diff --git a/src/buffer.c b/src/buffer.c index 0e2e50d9f51..b020edb9962 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/param.h> #include <errno.h> #include <stdio.h> -#include <setjmp.h> #include <unistd.h> #include <verify.h> @@ -44,7 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keymap.h" #include "frame.h" -struct buffer *current_buffer; /* the current buffer */ +struct buffer *current_buffer; /* The current buffer. */ /* First buffer in chain of all buffers (in reverse order of creation). Threaded through ->header.next.buffer. */ @@ -60,10 +59,6 @@ struct buffer *all_buffers; struct buffer alignas (GCALIGNMENT) buffer_defaults; -/* A Lisp_Object pointer to the above, used for staticpro */ - -static Lisp_Object Vbuffer_defaults; - /* This structure marks which slots in a buffer have corresponding default values in buffer_defaults. Each such slot has a nonzero value in this structure. @@ -78,18 +73,15 @@ static Lisp_Object Vbuffer_defaults; and the corresponding slot in buffer_defaults is not used. If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is - zero, that is a bug */ + zero, that is a bug. */ struct buffer buffer_local_flags; /* This structure holds the names of symbols whose values may be - buffer-local. It is indexed and accessed in the same way as the above. */ + buffer-local. It is indexed and accessed in the same way as the above. */ struct buffer alignas (GCALIGNMENT) buffer_local_symbols; -/* A Lisp_Object pointer to the above, used for staticpro */ -static Lisp_Object Vbuffer_local_symbols; - /* Return the symbol of the per-buffer variable at offset OFFSET in the buffer structure. */ @@ -115,7 +107,7 @@ static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, static void swap_out_buffer_local_variables (struct buffer *b); static void reset_buffer_local_variables (struct buffer *, bool); -/* Alist of all buffer names vs the buffers. */ +/* Alist of all buffer names vs the buffers. */ /* This used to be a variable, but is no longer, to prevent lossage due to user rplac'ing this alist or its elements. */ Lisp_Object Vbuffer_alist; @@ -134,7 +126,7 @@ static Lisp_Object Qpermanent_local_hook; static Lisp_Object Qprotected_field; -static Lisp_Object QSFundamental; /* A string "Fundamental" */ +static Lisp_Object QSFundamental; /* A string "Fundamental". */ static Lisp_Object Qkill_buffer_hook; static Lisp_Object Qbuffer_list_update_hook; @@ -395,7 +387,7 @@ DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0, Value is nil if OBJECT is not a buffer or if it has been killed. */) (Lisp_Object object) { - return ((BUFFERP (object) && ! NILP (BVAR (XBUFFER (object), name))) + return ((BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object))) ? Qt : Qnil); } @@ -595,10 +587,6 @@ even if it is dead. The return value is never nil. */) bset_width_table (b, Qnil); b->prevent_redisplay_optimizations_p = 1; - /* Put this on the chain of all buffers including killed ones. */ - b->header.next.buffer = all_buffers; - all_buffers = b; - /* An ordinary buffer normally doesn't need markers to handle BEGV and ZV. */ bset_pt_marker (b, Qnil); @@ -787,7 +775,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) base_buffer = Fget_buffer (base_buffer); if (NILP (base_buffer)) error ("No such buffer: `%s'", SDATA (tem)); - if (NILP (BVAR (XBUFFER (base_buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (base_buffer))) error ("Base buffer has been killed"); if (SCHARS (name) == 0) @@ -819,10 +807,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */) b->width_run_cache = 0; bset_width_table (b, Qnil); - /* Put this on the chain of all buffers including killed ones. */ - b->header.next.buffer = all_buffers; - all_buffers = b; - name = Fcopy_sequence (name); set_string_intervals (name, NULL); bset_name (b, name); @@ -1242,7 +1226,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer) result = Fdefault_value (variable); break; } - default: abort (); + default: emacs_abort (); } return result; @@ -1568,7 +1552,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */) { buf = XCAR (tail); if (BUFFERP (buf) && !EQ (buf, buffer) - && !NILP (BVAR (XBUFFER (buf), name)) + && BUFFER_LIVE_P (XBUFFER (buf)) && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') /* If the frame has a buffer_predicate, disregard buffers that don't fit the predicate. */ @@ -1588,7 +1572,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */) { buf = Fcdr (XCAR (tail)); if (BUFFERP (buf) && !EQ (buf, buffer) - && !NILP (BVAR (XBUFFER (buf), name)) + && BUFFER_LIVE_P (XBUFFER (buf)) && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') /* If the frame has a buffer_predicate, disregard buffers that don't fit the predicate. */ @@ -1630,7 +1614,7 @@ other_buffer_safely (Lisp_Object buffer) { buf = Fcdr (XCAR (tail)); if (BUFFERP (buf) && !EQ (buf, buffer) - && !NILP (BVAR (XBUFFER (buf), name)) + && BUFFER_LIVE_P (XBUFFER (buf)) && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')) return buf; } @@ -1749,7 +1733,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) b = XBUFFER (buffer); /* Avoid trouble for buffer already dead. */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qnil; /* Query if the buffer is still modified. */ @@ -1785,7 +1769,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) } /* If the hooks have killed the buffer, exit now. */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qt; /* We have no more questions to ask. Verify that it is valid @@ -1817,7 +1801,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) UNGCPRO; /* Exit if we now have killed the base buffer (Bug#11665). */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qt; } @@ -1828,7 +1812,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) replace_buffer_in_windows (buffer); /* Exit if replacing the buffer in windows has killed our buffer. */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qt; /* Make this buffer not be current. Exit if it is the sole visible @@ -1861,7 +1845,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* Killing buffer processes may run sentinels which may have killed our buffer. */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qt; /* These may run Lisp code and into infinite loops (if someone @@ -1893,7 +1877,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) } /* Deleting an auto-save file could have killed our buffer. */ - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) return Qt; if (b->base_buffer) @@ -2062,7 +2046,7 @@ the current buffer's major mode. */) CHECK_BUFFER (buffer); - if (NILP (BVAR (XBUFFER (buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (buffer))) error ("Attempt to set major mode for a dead buffer"); if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) @@ -2198,7 +2182,7 @@ ends when the current command terminates. Use `switch-to-buffer' or buffer = Fget_buffer (buffer_or_name); if (NILP (buffer)) nsberror (buffer_or_name); - if (NILP (BVAR (XBUFFER (buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (buffer))) error ("Selecting deleted buffer"); set_buffer_internal (XBUFFER (buffer)); return buffer; @@ -2209,7 +2193,7 @@ ends when the current command terminates. Use `switch-to-buffer' or Lisp_Object set_buffer_if_live (Lisp_Object buffer) { - if (! NILP (BVAR (XBUFFER (buffer), name))) + if (BUFFER_LIVE_P (XBUFFER (buffer))) set_buffer_internal (XBUFFER (buffer)); return Qnil; } @@ -2304,7 +2288,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, CHECK_BUFFER (buffer); other_buffer = XBUFFER (buffer); - if (NILP (BVAR (other_buffer, name))) + if (!BUFFER_LIVE_P (other_buffer)) error ("Cannot swap a dead buffer's text"); /* Actually, it probably works just fine. @@ -2671,7 +2655,7 @@ current buffer is cleared. */) /* Make sure no markers were put on the chain while the chain value was incorrect. */ if (BUF_MARKERS (current_buffer)) - abort (); + emacs_abort (); BUF_MARKERS (current_buffer) = markers; @@ -2700,7 +2684,7 @@ current buffer is cleared. */) /* Copy this buffer's new multibyte status into all of its indirect buffers. */ FOR_EACH_BUFFER (other) - if (other->base_buffer == current_buffer && !NILP (BVAR (other, name))) + if (other->base_buffer == current_buffer && BUFFER_LIVE_P (other)) { BVAR (other, enable_multibyte_characters) = BVAR (current_buffer, enable_multibyte_characters); @@ -3413,7 +3397,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) } } if (p != overlay_str_buf + total) - abort (); + emacs_abort (); if (pstr) *pstr = overlay_str_buf; return total; @@ -4073,6 +4057,26 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, return unbind_to (count, Qnil); } + +DEFUN ("delete-all-overlays", Fdelete_all_overlays, Sdelete_all_overlays, 0, 1, 0, + doc: /* Delete all overlays of BUFFER. +BUFFER omitted or nil means delete all overlays of the current +buffer. */) + (Lisp_Object buffer) +{ + register struct buffer *buf; + + if (NILP (buffer)) + buf = current_buffer; + else + { + CHECK_BUFFER (buffer); + buf = XBUFFER (buffer); + } + + delete_all_overlays (buf); + return Qnil; +} /* Overlay dissection functions. */ @@ -4576,7 +4580,7 @@ buffer_slot_type_mismatch (Lisp_Object newval, int type) case_Lisp_Int: predicate = Qintegerp; break; case Lisp_String: predicate = Qstringp; break; case Lisp_Symbol: predicate = Qsymbolp; break; - default: abort (); + default: emacs_abort (); } wrong_type_argument (predicate, newval); @@ -5125,10 +5129,11 @@ init_buffer_once (void) buffer_local_symbols.indirections = 0; set_buffer_intervals (&buffer_defaults, NULL); set_buffer_intervals (&buffer_local_symbols, NULL); + /* This is not strictly necessary, but let's make them initialized. */ + bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*")); + bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*")); XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); - XSETBUFFER (Vbuffer_defaults, &buffer_defaults); XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); - XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols); /* Set up the default values of various buffer slots. */ /* Must do these before making the first buffer! */ @@ -5257,7 +5262,7 @@ init_buffer_once (void) /* Need more room? */ if (idx >= MAX_PER_BUFFER_VARS) - abort (); + emacs_abort (); last_per_buffer_idx = idx; Vbuffer_alist = Qnil; @@ -5398,7 +5403,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, if (PER_BUFFER_IDX (offset) == 0) /* Did a DEFVAR_PER_BUFFER without initializing the corresponding slot of buffer_local_flags */ - abort (); + emacs_abort (); } @@ -5410,8 +5415,6 @@ syms_of_buffer (void) last_overlay_modification_hooks = Fmake_vector (make_number (10), Qnil); - staticpro (&Vbuffer_defaults); - staticpro (&Vbuffer_local_symbols); staticpro (&Qfundamental_mode); staticpro (&Qmode_class); staticpro (&QSFundamental); @@ -6286,6 +6289,7 @@ and `bury-buffer-internal'. */); defsubr (&Soverlayp); defsubr (&Smake_overlay); defsubr (&Sdelete_overlay); + defsubr (&Sdelete_all_overlays); defsubr (&Smove_overlay); defsubr (&Soverlay_start); defsubr (&Soverlay_end); diff --git a/src/buffer.h b/src/buffer.h index 3acf1423816..d18ef30ea38 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -959,7 +959,10 @@ bset_width_table (struct buffer *b, Lisp_Object val) b->INTERNAL_FIELD (width_table) = val; } - +/* Convenient check whether buffer B is live. */ + +#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) + /* Chain of all buffers, including killed ones. */ extern struct buffer *all_buffers; @@ -1149,7 +1152,7 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) We assume you know which buffer it's pointing into. */ #define OVERLAY_POSITION(P) \ - (MARKERP (P) ? marker_position (P) : (abort (), 0)) + (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0)) /*********************************************************************** @@ -1189,7 +1192,7 @@ extern int last_per_buffer_idx; #define PER_BUFFER_VALUE_P(B, IDX) \ (((IDX) < 0 || IDX >= last_per_buffer_idx) \ - ? (abort (), 0) \ + ? (emacs_abort (), 0) \ : ((B)->local_flags[IDX] != 0)) /* Set whether per-buffer variable with index IDX has a buffer-local @@ -1198,7 +1201,7 @@ extern int last_per_buffer_idx; #define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ do { \ if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ - abort (); \ + emacs_abort (); \ (B)->local_flags[IDX] = (VAL); \ } while (0) diff --git a/src/bytecode.c b/src/bytecode.c index 40729cbd453..5f4fdcc5eff 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -33,7 +33,7 @@ by Hallvard: */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" @@ -435,7 +435,7 @@ unmark_byte_stack (void) #ifdef BYTE_CODE_SAFE #define CHECK_RANGE(ARG) \ - if (ARG >= bytestr_length) abort () + if (ARG >= bytestr_length) emacs_abort () #else /* not BYTE_CODE_SAFE */ @@ -458,7 +458,8 @@ unmark_byte_stack (void) Fsignal (Qquit, Qnil); \ AFTER_POTENTIAL_GC (); \ } \ - ELSE_PENDING_SIGNALS \ + else if (pending_signals) \ + process_pending_signals (); \ } while (0) @@ -508,7 +509,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, if (FRAME_X_P (f) && FRAME_FONT (f)->direction != 0 && FRAME_FONT (f)->direction != 1) - abort (); + emacs_abort (); } #endif @@ -600,9 +601,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { #ifdef BYTE_CODE_SAFE if (top > stacke) - abort (); + emacs_abort (); else if (top < stack.bottom - 1) - abort (); + emacs_abort (); #endif #ifdef BYTE_CODE_METER @@ -1875,7 +1876,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, /* Actually this is Bstack_ref with offset 0, but we use Bdup for that instead. */ /* CASE (Bstack_ref): */ - abort (); + emacs_abort (); /* Handy byte-codes for lexical binding. */ CASE (Bstack_ref1): @@ -1928,11 +1929,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #ifdef BYTE_CODE_SAFE if (op < Bconstant) { - abort (); + emacs_abort (); } if ((op -= Bconstant) >= const_length) { - abort (); + emacs_abort (); } PUSH (vectorp[op]); #else @@ -1951,7 +1952,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #ifdef BYTE_CODE_SAFE error ("binding stack not balanced (serious byte compiler bug)"); #else - abort (); + emacs_abort (); #endif return result; diff --git a/src/callint.c b/src/callint.c index b11545ddea2..c4c087e83d7 100644 --- a/src/callint.c +++ b/src/callint.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" diff --git a/src/callproc.c b/src/callproc.c index 2e9a8950700..2604d295f3e 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -19,10 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <signal.h> #include <errno.h> #include <stdio.h> -#include <setjmp.h> #include <sys/types.h> #include <unistd.h> @@ -498,17 +496,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) register char **save_environ = environ; register int fd1 = fd[1]; int fd_error = fd1; -#ifdef HAVE_WORKING_VFORK - sigset_t procmask; - sigset_t blocked; - struct sigaction sigpipe_action; -#endif if (fd_output >= 0) fd1 = fd_output; -#if 0 /* Some systems don't have sigblock. */ - mask = sigblock (sigmask (SIGCHLD)); -#endif /* Record that we're about to create a synchronous process. */ synch_process_alive = 1; @@ -592,17 +582,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) 0, current_dir); #else /* not WINDOWSNT */ -#ifdef HAVE_WORKING_VFORK - /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal', - this sets the parent's signal handlers as well as the child's. - So delay all interrupts whose handlers the child might munge, - and record the current handlers so they can be restored later. */ - sigemptyset (&blocked); - sigaddset (&blocked, SIGPIPE); - sigaction (SIGPIPE, 0, &sigpipe_action); - pthread_sigmask (SIG_BLOCK, &blocked, &procmask); -#endif - BLOCK_INPUT; /* vfork, and prevent local vars from being clobbered by the vfork. */ @@ -650,9 +629,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) /* GConf causes us to ignore SIGPIPE, make sure it is restored in the child. */ signal (SIGPIPE, SIG_DFL); -#ifdef HAVE_WORKING_VFORK - pthread_sigmask (SIG_SETMASK, &procmask, 0); -#endif child_setup (filefd, fd1, fd_error, (char **) new_argv, 0, current_dir); @@ -660,12 +636,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) UNBLOCK_INPUT; -#ifdef HAVE_WORKING_VFORK - /* Restore the signal state. */ - sigaction (SIGPIPE, &sigpipe_action, 0); - pthread_sigmask (SIG_SETMASK, &procmask, 0); -#endif - #endif /* not WINDOWSNT */ /* The MSDOS case did this already. */ diff --git a/src/casefiddle.c b/src/casefiddle.c index 1102054b153..e3654627576 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/casetab.c b/src/casetab.c index 3e22d0d0b77..a84bc9202d0 100644 --- a/src/casetab.c +++ b/src/casetab.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/category.c b/src/category.c index 80dc6938d8b..01a6f54ad17 100644 --- a/src/category.c +++ b/src/category.c @@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define CATEGORY_INLINE EXTERN_INLINE -#include <setjmp.h> #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/ccl.c b/src/ccl.c index dd37934451d..34cc1c98eea 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <limits.h> #include "lisp.h" diff --git a/src/character.c b/src/character.c index cfaaf8eeca9..def1ad090fd 100644 --- a/src/character.c +++ b/src/character.c @@ -36,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef emacs #include <sys/types.h> -#include <setjmp.h> #include <intprops.h> #include "lisp.h" #include "character.h" @@ -541,7 +540,7 @@ multibyte_chars_in_text (const unsigned char *ptr, ptrdiff_t nbytes) int len = MULTIBYTE_LENGTH (ptr, endp); if (len == 0) - abort (); + emacs_abort (); ptr += len; chars++; } diff --git a/src/charset.c b/src/charset.c index 0673790e91c..d8c38e5ea3b 100644 --- a/src/charset.c +++ b/src/charset.c @@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <limits.h> #include <sys/types.h> -#include <setjmp.h> #include <c-ctype.h> #include "lisp.h" #include "character.h" @@ -636,7 +635,7 @@ load_charset (struct charset *charset, int control_flag) else { if (! CHARSET_UNIFIED_P (charset)) - abort (); + emacs_abort (); map = CHARSET_UNIFY_MAP (charset); } if (STRINGP (map)) @@ -2025,10 +2024,10 @@ CH in the charset. */) c = XFASTINT (ch); charset = CHAR_CHARSET (c); if (! charset) - abort (); + emacs_abort (); code = ENCODE_CHAR (charset, c); if (code == CHARSET_INVALID_CODE (charset)) - abort (); + emacs_abort (); dimension = CHARSET_DIMENSION (charset); for (val = Qnil; dimension > 0; dimension--) { diff --git a/src/chartab.c b/src/chartab.c index c14df0ebac6..e864514e336 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "charset.h" @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "frame.h" @@ -119,7 +118,7 @@ cmcheckmagic (struct tty_display_info *tty) if (curX (tty) == FrameCols (tty)) { if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1) - abort (); + emacs_abort (); if (tty->termscript) putc ('\r', tty->termscript); putc ('\r', tty->output); diff --git a/src/cmds.c b/src/cmds.c index 90d3cd6dced..45f7df948ae 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "commands.h" #include "character.h" diff --git a/src/coding.c b/src/coding.c index 02e7b34695e..4b3d22f956c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -285,7 +285,6 @@ encode_coding_XXX (struct coding_system *coding) #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -2051,7 +2050,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, break; default: - abort (); + emacs_abort (); } CODING_DECODE_CHAR (coding, src, src_base, src_end, CHARSET_FROM_ID (charset_ID), code, c); @@ -2345,7 +2344,7 @@ decode_coding_emacs_mule (struct coding_system *coding) int i; if (charbuf_end - charbuf < cmp_status->length) - abort (); + emacs_abort (); for (i = 0; i < cmp_status->length; i++) *charbuf++ = cmp_status->carryover[i]; coding->annotated = 1; @@ -2619,7 +2618,7 @@ encode_coding_emacs_mule (struct coding_system *coding) preferred_charset_id = -1; break; default: - abort (); + emacs_abort (); } charbuf += -c - 1; continue; @@ -3482,7 +3481,7 @@ decode_coding_iso_2022 (struct coding_system *coding) if (cmp_status->state != COMPOSING_NO) { if (charbuf_end - charbuf < cmp_status->length) - abort (); + emacs_abort (); for (i = 0; i < cmp_status->length; i++) *charbuf++ = cmp_status->carryover[i]; coding->annotated = 1; @@ -3864,7 +3863,7 @@ decode_coding_iso_2022 (struct coding_system *coding) break; default: - abort (); + emacs_abort (); } if (cmp_status->state == COMPOSING_NO @@ -4419,7 +4418,7 @@ encode_coding_iso_2022 (struct coding_system *coding) preferred_charset_id = -1; break; default: - abort (); + emacs_abort (); } charbuf += -c - 1; continue; @@ -4933,7 +4932,7 @@ encode_coding_sjis (struct coding_system *coding) } } if (code == CHARSET_INVALID_CODE (charset)) - abort (); + emacs_abort (); if (charset == charset_kanji) { int c1, c2; @@ -5023,7 +5022,7 @@ encode_coding_big5 (struct coding_system *coding) } } if (code == CHARSET_INVALID_CODE (charset)) - abort (); + emacs_abort (); if (charset == charset_big5) { int c1, c2; @@ -7190,7 +7189,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, *buf++ = XINT (XCAR (components)); } else - abort (); + emacs_abort (); *head -= len; } } @@ -9428,7 +9427,7 @@ usage: (set-coding-system-priority &rest coding-systems) */) && changed[coding_priorities[j]]) j++; if (j == coding_category_max) - abort (); + emacs_abort (); priorities[i] = coding_priorities[j]; } diff --git a/src/composite.c b/src/composite.c index eddabb66d33..ae46df0a573 100644 --- a/src/composite.c +++ b/src/composite.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define COMPOSITE_INLINE EXTERN_INLINE -#include <setjmp.h> #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/composite.h b/src/composite.h index 68f5b27ee42..9462b932c66 100644 --- a/src/composite.h +++ b/src/composite.h @@ -113,7 +113,7 @@ extern Lisp_Object composition_temp; && (end - start) == COMPOSITION_LENGTH (prop)) /* Return the Nth glyph of composition specified by CMP. CMP is a - pointer to `struct composition'. */ + pointer to `struct composition'. */ #define COMPOSITION_GLYPH(cmp, n) \ XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \ ->key_and_value) \ diff --git a/src/conf_post.h b/src/conf_post.h index 8bd66be2c4d..53fc941f464 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -40,11 +40,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #endif -#ifdef SIGNAL_H_AHB -#undef SIGNAL_H_AHB -#include <signal.h> -#endif - /* This silences a few compilation warnings on FreeBSD. */ #ifdef BSD_SYSTEM_AHB #undef BSD_SYSTEM_AHB @@ -95,7 +90,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ char *_getpty(); #endif -#undef SA_RESTART /* not the same as defining BROKEN_SA_RESTART */ #endif /* IRIX6_5 */ #ifdef MSDOS @@ -138,22 +132,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ #endif #endif /* MSDOS */ -#ifdef USG5_4 -/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars. - But get <termio.h> first to make sure ttold.h doesn't interfere. */ -#include <sys/wait.h> - -#ifdef emacs -#include <sys/filio.h> -#include <termio.h> -#include <sys/ttold.h> -#include <signal.h> -#include <sys/stream.h> -#include <sys/stropts.h> -#include <sys/termios.h> -#endif -#endif /* USG5_4 */ - /* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs, SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ #ifdef HAVE_NS @@ -181,7 +159,7 @@ extern void _DebPrint (const char *fmt, ...); #ifdef emacs /* Don't do this for lib-src. */ /* Tell regex.c to use a type compatible with Emacs. */ #define RE_TRANSLATE_TYPE Lisp_Object -#define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C) +#define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C) #ifdef make_number /* If make_number is a macro, use it. */ #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0))) @@ -192,9 +170,6 @@ extern void _DebPrint (const char *fmt, ...); #endif #include <string.h> -/* If you think about removing the line below, note that the - MS-Windows build relies on it for declaration of 'environ' needed - by a few source files. */ #include <stdlib.h> #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ diff --git a/src/data.c b/src/data.c index d8b7f42ea3f..72d7c8ccf9a 100644 --- a/src/data.c +++ b/src/data.c @@ -19,9 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <signal.h> #include <stdio.h> -#include <setjmp.h> #include <intprops.h> @@ -37,17 +35,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keymap.h" #include <float.h> -/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ -#ifndef IEEE_FLOATING_POINT #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) #define IEEE_FLOATING_POINT 1 #else #define IEEE_FLOATING_POINT 0 #endif -#endif - -#include <math.h> Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; static Lisp_Object Qsubr; @@ -77,8 +70,8 @@ Lisp_Object Qchar_table_p, Qvector_or_char_table_p; Lisp_Object Qcdr; static Lisp_Object Qad_advice_info, Qad_activate_internal; -Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; -Lisp_Object Qoverflow_error, Qunderflow_error; +static Lisp_Object Qdomain_error, Qsingularity_error, Qunderflow_error; +Lisp_Object Qrange_error, Qoverflow_error; Lisp_Object Qfloatp; Lisp_Object Qnumberp, Qnumber_or_marker_p; @@ -108,7 +101,7 @@ wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) to try and do that by checking the tagbits, but nowadays all tagbits are potentially valid. */ /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit) - * abort (); */ + * emacs_abort (); */ xsignal2 (Qwrong_type_argument, predicate, value); } @@ -182,7 +175,7 @@ for example, (type-of 1) returns `integer'. */) case Lisp_Misc_Float: return Qfloat; } - abort (); + emacs_abort (); case Lisp_Vectorlike: if (WINDOW_CONFIGURATIONP (object)) @@ -217,7 +210,7 @@ for example, (type-of 1) returns `integer'. */) return Qfloat; default: - abort (); + emacs_abort (); } } @@ -551,7 +544,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, /* In set_internal, we un-forward vars when their value is set to Qunbound. */ return Qt; - default: abort (); + default: emacs_abort (); } return (EQ (valcontents, Qunbound) ? Qnil : Qt); @@ -864,7 +857,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents) don't think anything will break. --lorentey */ return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset + (char *)FRAME_KBOARD (SELECTED_FRAME ())); - default: abort (); + default: emacs_abort (); } } @@ -950,12 +943,14 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva break; default: - abort (); /* goto def; */ + emacs_abort (); /* goto def; */ } } -/* Set up SYMBOL to refer to its global binding. - This makes it safe to alter the status of other bindings. */ +/* Set up SYMBOL to refer to its global binding. This makes it safe + to alter the status of other bindings. BEWARE: this may be called + during the mark phase of GC, where we assume that Lisp_Object slots + of BLV are marked after this function has changed them. */ void swap_in_global_binding (struct Lisp_Symbol *symbol) @@ -1014,7 +1009,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ else { tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist)); - XSETBUFFER (blv->where, current_buffer); + set_blv_where (blv, Fcurrent_buffer ()); } } if (!(blv->found = !NILP (tem1))) @@ -1055,7 +1050,7 @@ find_symbol_value (Lisp_Object symbol) /* FALLTHROUGH */ case SYMBOL_FORWARDED: return do_symval_forwarding (SYMBOL_FWD (sym)); - default: abort (); + default: emacs_abort (); } } @@ -1168,7 +1163,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, the default binding is loaded, the loaded binding may be the wrong one. */ if (!EQ (blv->where, where) - /* Also unload a global binding (if the var is local_if_set). */ + /* Also unload a global binding (if the var is local_if_set). */ || (EQ (blv->valcell, blv->defcell))) { /* The currently loaded binding is not necessarily valid. @@ -1265,7 +1260,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, store_symval_forwarding (/* sym, */ innercontents, newval, buf); break; } - default: abort (); + default: emacs_abort (); } return; } @@ -1316,7 +1311,7 @@ default_value (Lisp_Object symbol) /* For other variables, get the current value. */ return do_symval_forwarding (valcontents); } - default: abort (); + default: emacs_abort (); } } @@ -1414,7 +1409,7 @@ for this variable. */) else return Fset (symbol, value); } - default: abort (); + default: emacs_abort (); } } @@ -1538,7 +1533,7 @@ The function `default-value' gets the default value and `set-default' sets it. else if (BUFFER_OBJFWDP (valcontents.fwd)) return variable; break; - default: abort (); + default: emacs_abort (); } if (sym->constant) @@ -1611,7 +1606,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); break; - default: abort (); + default: emacs_abort (); } if (sym->constant) @@ -1718,7 +1713,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) if (blv->frame_local) return variable; break; - default: abort (); + default: emacs_abort (); } /* Get rid of this buffer's alist element, if any. */ @@ -1800,7 +1795,7 @@ frame-local bindings). */) error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); break; - default: abort (); + default: emacs_abort (); } if (sym->constant) @@ -1877,18 +1872,18 @@ BUFFER defaults to the current buffer. */) } return Qnil; } - default: abort (); + default: emacs_abort (); } } DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1, 2, 0, - doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there. -More precisely, this means that setting the variable \(with `set' or`setq'), -while it does not have a `let'-style binding that was made in BUFFER, -will produce a buffer local binding. See Info node -`(elisp)Creating Buffer-Local'. -BUFFER defaults to the current buffer. */) + doc: /* Non-nil if VARIABLE is local in buffer BUFFER when set there. +BUFFER defaults to the current buffer. + +More precisely, return non-nil if either VARIABLE already has a local +value in BUFFER, or if VARIABLE is automatically buffer-local (see +`make-variable-buffer-local'). */) (register Lisp_Object variable, Lisp_Object buffer) { struct Lisp_Symbol *sym; @@ -1912,7 +1907,7 @@ BUFFER defaults to the current buffer. */) case SYMBOL_FORWARDED: /* All BUFFER_OBJFWD slots become local if they are set. */ return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); - default: abort (); + default: emacs_abort (); } } @@ -1956,7 +1951,7 @@ If the current binding is global (the default), the value is nil. */) return SYMBOL_BLV (sym)->where; else return Qnil; - default: abort (); + default: emacs_abort (); } } @@ -2272,7 +2267,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) return Qnil; default: - abort (); + emacs_abort (); } } @@ -2738,28 +2733,6 @@ Both must be integers or markers. */) return val; } -#ifndef HAVE_FMOD -double -fmod (double f1, double f2) -{ - double r = f1; - - if (f2 < 0.0) - f2 = -f2; - - /* If the magnitude of the result exceeds that of the divisor, or - the sign of the result does not agree with that of the dividend, - iterate with the reduced value. This does not yield a - particularly accurate result, but at least it will be in the - range promised by fmod. */ - do - r -= f2 * floor (r / f2); - while (f2 <= (r < 0 ? -r : r) || ((r < 0) != (f1 < 0) && ! isnan (r))); - - return r; -} -#endif /* ! HAVE_FMOD */ - DEFUN ("mod", Fmod, Smod, 2, 2, 0, doc: /* Return X modulo Y. The result falls between zero (inclusive) and Y (exclusive). @@ -3207,21 +3180,23 @@ syms_of_data (void) XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; } -#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD -_Noreturn -#endif -static void -arith_error (int signo) +static _Noreturn void +handle_arith_signal (int sig) { - sigsetmask (SIGEMPTYMASK); - - SIGNAL_THREAD_CHECK (signo); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); xsignal0 (Qarith_error); } +static void +deliver_arith_signal (int sig) +{ + handle_on_main_thread (sig, handle_arith_signal); +} + void init_data (void) { + struct sigaction action; /* Don't do this if just dumping out. We don't want to call `signal' in this case so that we don't have trouble with dumping @@ -3230,5 +3205,6 @@ init_data (void) if (!initialized) return; #endif /* CANNOT_DUMP */ - signal (SIGFPE, arith_error); + emacs_sigaction_init (&action, deliver_arith_signal); + sigaction (SIGFPE, &action, 0); } diff --git a/src/dbusbind.c b/src/dbusbind.c index 901820648cb..c2eefd605bb 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_DBUS #include <stdio.h> #include <dbus/dbus.h> -#include <setjmp.h> + #include "lisp.h" #include "frame.h" #include "termhooks.h" diff --git a/src/dired.c b/src/dired.c index fa293258107..3aa27ecf920 100644 --- a/src/dired.c +++ b/src/dired.c @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> -#include <setjmp.h> #ifdef HAVE_PWD_H #include <pwd.h> @@ -275,7 +274,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, /* Some bug somewhere. */ if (nchars > nbytes) - abort (); + emacs_abort (); STRING_SET_CHARS (fullname, nchars); if (nchars == nbytes) diff --git a/src/dispextern.h b/src/dispextern.h index 1aff547f187..5acfe6b5ca6 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3055,7 +3055,7 @@ void move_it_in_display_line (struct it *it, int in_display_vector_p (struct it *); int frame_mode_line_height (struct frame *); extern Lisp_Object Qtool_bar; -extern int redisplaying_p; +extern bool redisplaying_p; extern int help_echo_showing_p; extern int current_mode_line_height, current_header_line_height; extern Lisp_Object help_echo_string, help_echo_window; @@ -3193,6 +3193,7 @@ void unrequest_sigio (void); int tabs_safe_p (int); void init_baud_rate (int); void init_sigio (int); +void ignore_sigio (void); /* Defined in xfaces.c */ @@ -3251,9 +3252,12 @@ void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); extern Lisp_Object tip_frame; extern Window tip_window; +extern frame_parm_handler x_frame_parm_handlers[]; + extern void start_hourglass (void); extern void cancel_hourglass (void); extern int hourglass_shown_p; + struct atimer; /* Defined in atimer.h. */ /* If non-null, an asynchronous timer that, when it expires, displays an hourglass cursor on all frames. */ diff --git a/src/dispnew.c b/src/dispnew.c index cac4c2da4c4..5827316a7b7 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -21,9 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define DISPEXTERN_INLINE EXTERN_INLINE -#include <signal.h> #include <stdio.h> -#include <setjmp.h> #include <unistd.h> #include "lisp.h" @@ -297,7 +295,7 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history, void __executable_start (void) { - abort (); + emacs_abort (); } #endif @@ -347,7 +345,7 @@ free_glyph_matrix (struct glyph_matrix *matrix) /* Detect the case that more matrices are freed than were allocated. */ if (--glyph_matrix_count < 0) - abort (); + emacs_abort (); /* Free glyph memory if MATRIX owns it. */ if (matrix->pool == NULL) @@ -2339,9 +2337,9 @@ check_glyph_memory (void) /* Check that nothing is left allocated. */ if (glyph_matrix_count) - abort (); + emacs_abort (); if (glyph_pool_count) - abort (); + emacs_abort (); } @@ -3024,7 +3022,7 @@ check_matrix_pointers (struct glyph_matrix *window_matrix, { if (!glyph_row_slice_p (window_matrix->rows + i, frame_matrix->rows + j)) - abort (); + emacs_abort (); ++i, ++j; } } @@ -3453,7 +3451,7 @@ check_current_matrix_flags (struct window *w) if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb) last_seen_p = 1; else if (last_seen_p && row->enabled_p) - abort (); + emacs_abort (); } } @@ -3952,6 +3950,11 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p) { changed_p = 1; update_marginal_area (w, LEFT_MARGIN_AREA, vpos); + /* Setting this flag will ensure the vertical border, if + any, between this window and the one on its left will be + redrawn. This is necessary because updating the left + margin area can potentially draw over the border. */ + current_row->redraw_fringe_bitmaps_p = 1; } /* Update the display of the text area. */ @@ -4809,7 +4812,7 @@ scrolling (struct frame *frame) struct glyph_matrix *desired_matrix = frame->desired_matrix; if (!current_matrix) - abort (); + emacs_abort (); /* Compute hash codes of all the lines. Also calculate number of changed lines, number of unchanged lines at the beginning, and @@ -5477,7 +5480,7 @@ marginal_area_string (struct window *w, enum window_part part, else if (part == ON_RIGHT_MARGIN) area = RIGHT_MARGIN_AREA; else - abort (); + emacs_abort (); for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) @@ -5552,17 +5555,17 @@ marginal_area_string (struct window *w, enum window_part part, #ifdef SIGWINCH +static void deliver_window_change_signal (int); + static void -window_change_signal (int signalnum) /* If we don't have an argument, */ - /* some compilers complain in signal calls. */ +handle_window_change_signal (int sig) { int width, height; - int old_errno = errno; - struct tty_display_info *tty; - signal (SIGWINCH, window_change_signal); - SIGNAL_THREAD_CHECK (signalnum); + struct sigaction action; + emacs_sigaction_init (&action, deliver_window_change_signal); + sigaction (SIGWINCH, &action, 0); /* The frame size change obviously applies to a single termcap-controlled terminal, but we can't decide which. @@ -5591,8 +5594,12 @@ window_change_signal (int signalnum) /* If we don't have an argument, */ change_frame_size (XFRAME (frame), height, width, 0, 1, 0); } } +} - errno = old_errno; +static void +deliver_window_change_signal (int sig) +{ + handle_on_main_thread (sig, handle_window_change_signal); } #endif /* SIGWINCH */ @@ -5604,7 +5611,7 @@ window_change_signal (int signalnum) /* If we don't have an argument, */ void do_pending_window_change (bool safe) { - /* If window_change_signal should have run before, run it now. */ + /* If window change signal handler should have run before, run it now. */ if (redisplaying_p && !safe) return; @@ -5963,7 +5970,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display) wrong_type_argument (Qnumberp, timeout); -#ifdef SIGIO +#ifdef USABLE_SIGIO gobble_input (0); #endif @@ -6173,7 +6180,11 @@ init_display (void) #ifndef CANNOT_DUMP if (initialized) #endif /* CANNOT_DUMP */ - signal (SIGWINCH, window_change_signal); + { + struct sigaction action; + emacs_sigaction_init (&action, deliver_window_change_signal); + sigaction (SIGWINCH, &action, 0); + } #endif /* SIGWINCH */ /* If running as a daemon, no need to initialize any frames/terminal. */ @@ -6277,7 +6288,7 @@ init_display (void) /* Convert the initial frame to use the new display. */ if (f->output_method != output_initial) - abort (); + emacs_abort (); f->output_method = t->type; f->terminal = t; diff --git a/src/doc.c b/src/doc.c index b4eadfff875..d2d664df266 100644 --- a/src/doc.c +++ b/src/doc.c @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/file.h> /* Must be after sys/types.h for USG*/ -#include <setjmp.h> #include <fcntl.h> #include <unistd.h> @@ -37,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ Lisp_Object Qfunction_documentation; -extern Lisp_Object Qclosure; /* Buffer used for reading from documentation file. */ static char *get_doc_string_buffer; static ptrdiff_t get_doc_string_buffer_size; diff --git a/src/doprnt.c b/src/doprnt.c index b36e946005d..caa56d6ae88 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -102,7 +102,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <float.h> #include <unistd.h> #include <limits.h> @@ -114,10 +113,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ another macro. */ #include "character.h" -#ifndef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 /* IEEE double */ -#endif - /* Generate output from a format-spec FORMAT, terminated at position FORMAT_END. (*FORMAT_END is not part of the format, but must exist and be readable.) diff --git a/src/dosfns.c b/src/dosfns.c index 21676f4b4f5..3c649f4d534 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <dos.h> #undef gettime #undef settime -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/editfns.c b/src/editfns.c index a14e043c1bf..c6744648bc5 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <sys/types.h> #include <stdio.h> -#include <setjmp.h> #ifdef HAVE_PWD_H #include <pwd.h> @@ -2613,7 +2612,7 @@ They default to the values of (point-min) and (point-max) in BUFFER. */) if (NILP (buf)) nsberror (buffer); bp = XBUFFER (buf); - if (NILP (BVAR (bp, name))) + if (!BUFFER_LIVE_P (bp)) error ("Selecting deleted buffer"); if (NILP (start)) @@ -2677,7 +2676,7 @@ determines whether case is significant or ignored. */) if (NILP (buf1)) nsberror (buffer1); bp1 = XBUFFER (buf1); - if (NILP (BVAR (bp1, name))) + if (!BUFFER_LIVE_P (bp1)) error ("Selecting deleted buffer"); } @@ -2715,7 +2714,7 @@ determines whether case is significant or ignored. */) if (NILP (buf2)) nsberror (buffer2); bp2 = XBUFFER (buf2); - if (NILP (BVAR (bp2, name))) + if (!BUFFER_LIVE_P (bp2)) error ("Selecting deleted buffer"); } @@ -2783,8 +2782,8 @@ determines whether case is significant or ignored. */) if (!NILP (trt)) { - c1 = CHAR_TABLE_TRANSLATE (trt, c1); - c2 = CHAR_TABLE_TRANSLATE (trt, c2); + c1 = char_table_translate (trt, c1); + c2 = char_table_translate (trt, c2); } if (c1 < c2) return make_number (- 1 - chars); @@ -4263,7 +4262,7 @@ usage: (format STRING &rest OBJECTS) */) } if (bufsize < p - buf) - abort (); + emacs_abort (); if (maybe_combine_byte) nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf); @@ -4603,7 +4602,7 @@ Transposing beyond buffer boundaries is an error. */) len1_byte, end2, start2_byte + len2_byte) || count_combining_after (BYTE_POS_ADDR (start1_byte), len1_byte, end2, start2_byte + len2_byte)) - abort (); + emacs_abort (); } else { @@ -4615,7 +4614,7 @@ Transposing beyond buffer boundaries is an error. */) len2_byte, end1, start1_byte + len1_byte) || count_combining_after (BYTE_POS_ADDR (start1_byte), len1_byte, end2, start2_byte + len2_byte)) - abort (); + emacs_abort (); } #endif diff --git a/src/emacs.c b/src/emacs.c index 7b643f5226f..80d536a5c14 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -20,13 +20,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <signal.h> #include <errno.h> #include <stdio.h> #include <sys/types.h> #include <sys/file.h> -#include <setjmp.h> #include <unistd.h> #include "lisp.h" @@ -101,15 +99,15 @@ extern void moncontrol (int mode); #endif static const char emacs_version[] = VERSION; -static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc."; +static const char emacs_copyright[] = COPYRIGHT; /* Empty lisp strings. To avoid having to build any others. */ Lisp_Object empty_unibyte_string, empty_multibyte_string; -/* Set nonzero after Emacs has started up the first time. - Prevents reinitialization of the Lisp world and keymaps - on subsequent starts. */ -int initialized; +/* Set after Emacs has started up the first time. + Prevents reinitialization of the Lisp world and keymaps + on subsequent starts. */ +bool initialized; #ifdef DARWIN_OS extern void unexec_init_emacs_zone (void); @@ -123,9 +121,9 @@ static void *malloc_state_ptr; extern void *malloc_get_state (void); /* From glibc, a routine that overwrites the malloc internal state. */ extern int malloc_set_state (void*); -/* Non-zero if the MALLOC_CHECK_ environment variable was set while +/* True if the MALLOC_CHECK_ environment variable was set while dumping. Used to work around a bug in glibc's malloc. */ -static int malloc_using_checking; +static bool malloc_using_checking; #endif Lisp_Object Qfile_name_handler_alist; @@ -134,17 +132,17 @@ Lisp_Object Qrisky_local_variable; Lisp_Object Qkill_emacs; -/* If non-zero, Emacs should not attempt to use a window-specific code, +/* If true, 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; +bool inhibit_window_system; -/* If non-zero, a filter or a sentinel is running. Tested to save the match +/* If true, a filter or a sentinel is running. Tested to save the match data on the first attempt to change it inside asynchronous code. */ -int running_asynch_code; +bool running_asynch_code; #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) -/* If non-zero, -d was specified, meaning we're using some window system. */ -int display_arg; +/* If true, -d was specified, meaning we're using some window system. */ +bool display_arg; #endif /* An address near the bottom of the stack. @@ -177,11 +175,11 @@ static uprintmax_t heap_bss_diff; # define DAEMON_MUST_EXEC #endif -/* Nonzero means running Emacs without interactive terminal. */ -int noninteractive; +/* True means running Emacs without interactive terminal. */ +bool noninteractive; -/* Nonzero means remove site-lisp directories from load-path. */ -int no_site_lisp; +/* True means remove site-lisp directories from load-path. */ +bool no_site_lisp; /* Name for the server started by the daemon.*/ static char *daemon_name; @@ -299,16 +297,8 @@ section of the Emacs manual or the file BUGS.\n" /* Signal code for the fatal signal that was received. */ static int fatal_error_code; -/* Nonzero if handling a fatal error already. */ -int fatal_error_in_progress; - -#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD -/* When compiled with GTK and running under Gnome, - multiple threads may be created. Keep track of our main - thread to make sure signals are delivered to it (see syssignal.h). */ - -pthread_t main_thread; -#endif +/* True if handling a fatal error already. */ +bool fatal_error_in_progress; #ifdef HAVE_NS /* NS autrelease pool, for memory management. */ @@ -318,13 +308,23 @@ static void *ns_pool; /* Handle bus errors, invalid instruction, etc. */ -#ifndef FLOAT_CATCH_SIGILL -static -#endif -void -fatal_error_signal (int sig) +static void +handle_fatal_signal (int sig) +{ + fatal_error_backtrace (sig, 10); +} + +static void +deliver_fatal_signal (int sig) +{ + handle_on_main_thread (sig, handle_fatal_signal); +} + +/* Report a fatal error due to signal SIG, output a backtrace of at + most BACKTRACE_LIMIT lines, and exit. */ +_Noreturn void +fatal_error_backtrace (int sig, int backtrace_limit) { - SIGNAL_THREAD_CHECK (sig); fatal_error_code = sig; signal (sig, SIG_DFL); @@ -338,7 +338,8 @@ fatal_error_signal (int sig) if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) Fkill_emacs (make_number (sig)); - shut_down_emacs (sig, 0, Qnil); + shut_down_emacs (sig, Qnil); + emacs_backtrace (backtrace_limit); } /* Signal the same code; this time it will really be fatal. @@ -346,43 +347,44 @@ fatal_error_signal (int sig) going to send is probably blocked, so we have to unblock it if we want to really receive it. */ #ifndef MSDOS - sigunblock (sigmask (fatal_error_code)); + { + sigset_t unblocked; + sigemptyset (&unblocked); + sigaddset (&unblocked, fatal_error_code); + pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); + } #endif kill (getpid (), fatal_error_code); + + /* This shouldn't be executed, but it prevents a warning. */ + exit (1); } #ifdef SIGDANGER /* Handler for SIGDANGER. */ -void -memory_warning_signal (int sig) +static void deliver_danger_signal (int); + +static void +handle_danger_signal (int sig) { - signal (sig, memory_warning_signal); - SIGNAL_THREAD_CHECK (sig); + struct sigaction action; + emacs_sigaction_init (&action, deliver_danger_signal); + sigaction (sig, &action, 0); malloc_warning ("Operating system warns that virtual memory is running low.\n"); /* It might be unsafe to call do_auto_save now. */ force_auto_save_soon (); } -#endif - -/* We define abort, rather than using it from the library, - so that GDB can return from a breakpoint here. - MSDOS has its own definition in msdos.c. */ -#if ! defined (DOS_NT) && ! defined (NO_ABORT) - -void -abort (void) +static void +deliver_danger_signal (int sig) { - kill (getpid (), SIGABRT); - /* This shouldn't be executed, but it prevents a warning. */ - exit (1); + handle_on_main_thread (sig, handle_danger_signal); } #endif - /* Code for dealing with Lisp access to the Unix command line. */ @@ -595,7 +597,7 @@ DEFINE_DUMMY_FUNCTION (__main) Too bad we can't just use getopt for all of this, but we don't have enough information to do it right. */ -static int +static bool argmatch (char **argv, int argc, const char *sstr, const char *lstr, int minlen, char **valptr, int *skipptr) { @@ -702,18 +704,19 @@ main (int argc, char **argv) Lisp_Object dummy; #endif char stack_bottom_variable; - int do_initial_setlocale; + bool do_initial_setlocale; int skip_args = 0; #ifdef HAVE_SETRLIMIT struct rlimit rlim; #endif - int no_loadup = 0; + bool no_loadup = 0; char *junk = 0; char *dname_arg = 0; #ifdef DAEMON_MUST_EXEC char dname_arg2[80]; #endif /* DAEMON_MUST_EXEC */ char *ch_to_dir; + struct sigaction fatal_error_action; #if GC_MARK_STACK stack_base = &dummy; @@ -872,20 +875,12 @@ main (int argc, char **argv) /* Arrange to get warning messages as memory fills up. */ memory_warnings (0, malloc_warning); - /* Call malloc at least once, to run the initial __malloc_hook. + /* Call malloc at least once, to run malloc_initialize_hook. Also call realloc and free for consistency. */ free (realloc (malloc (4), 4)); -# ifndef SYNC_INPUT - /* Arrange to disable interrupt input inside malloc etc. */ - uninterrupt_malloc (); -# endif /* not SYNC_INPUT */ #endif /* not SYSTEM_MALLOC */ -#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD - main_thread = pthread_self (); -#endif /* FORWARD_SIGNAL_TO_MAIN_THREAD */ - #if defined (MSDOS) || defined (WINDOWSNT) /* We do all file input/output as binary files. When we need to translate newlines, we do that manually. */ @@ -1132,6 +1127,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem } init_signals (); + emacs_sigaction_init (&fatal_error_action, deliver_fatal_signal); /* Don't catch SIGHUP if dumping. */ if (1 @@ -1140,13 +1136,17 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif ) { - sigblock (sigmask (SIGHUP)); /* In --batch mode, don't catch SIGHUP if already ignored. That makes nohup work. */ - if (! noninteractive - || signal (SIGHUP, SIG_IGN) != SIG_IGN) - signal (SIGHUP, fatal_error_signal); - sigunblock (sigmask (SIGHUP)); + bool catch_SIGHUP = !noninteractive; + if (!catch_SIGHUP) + { + struct sigaction old_action; + sigaction (SIGHUP, 0, &old_action); + catch_SIGHUP = old_action.sa_handler != SIG_IGN; + } + if (catch_SIGHUP) + sigaction (SIGHUP, &fatal_error_action, 0); } if ( @@ -1160,9 +1160,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* Don't catch these signals in batch mode if dumping. On some machines, this sets static data that would make signal fail to work right when the dumped Emacs is run. */ - signal (SIGQUIT, fatal_error_signal); - signal (SIGILL, fatal_error_signal); - signal (SIGTRAP, fatal_error_signal); + sigaction (SIGQUIT, &fatal_error_action, 0); + sigaction (SIGILL, &fatal_error_action, 0); + sigaction (SIGTRAP, &fatal_error_action, 0); #ifdef SIGUSR1 add_user_signal (SIGUSR1, "sigusr1"); #endif @@ -1170,68 +1170,73 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem add_user_signal (SIGUSR2, "sigusr2"); #endif #ifdef SIGABRT - signal (SIGABRT, fatal_error_signal); + sigaction (SIGABRT, &fatal_error_action, 0); #endif #ifdef SIGHWE - signal (SIGHWE, fatal_error_signal); + sigaction (SIGHWE, &fatal_error_action, 0); #endif #ifdef SIGPRE - signal (SIGPRE, fatal_error_signal); + sigaction (SIGPRE, &fatal_error_action, 0); #endif #ifdef SIGORE - signal (SIGORE, fatal_error_signal); + sigaction (SIGORE, &fatal_error_action, 0); #endif #ifdef SIGUME - signal (SIGUME, fatal_error_signal); + sigaction (SIGUME, &fatal_error_action, 0); #endif #ifdef SIGDLK - signal (SIGDLK, fatal_error_signal); + sigaction (SIGDLK, &fatal_error_action, 0); #endif #ifdef SIGCPULIM - signal (SIGCPULIM, fatal_error_signal); + sigaction (SIGCPULIM, &fatal_error_action, 0); #endif #ifdef SIGIOT /* This is missing on some systems - OS/2, for example. */ - signal (SIGIOT, fatal_error_signal); + sigaction (SIGIOT, &fatal_error_action, 0); #endif #ifdef SIGEMT - signal (SIGEMT, fatal_error_signal); + sigaction (SIGEMT, &fatal_error_action, 0); #endif - signal (SIGFPE, fatal_error_signal); + sigaction (SIGFPE, &fatal_error_action, 0); #ifdef SIGBUS - signal (SIGBUS, fatal_error_signal); + sigaction (SIGBUS, &fatal_error_action, 0); #endif - signal (SIGSEGV, fatal_error_signal); + sigaction (SIGSEGV, &fatal_error_action, 0); #ifdef SIGSYS - signal (SIGSYS, fatal_error_signal); + sigaction (SIGSYS, &fatal_error_action, 0); #endif /* May need special treatment on MS-Windows. See http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html Please update the doc of kill-emacs, kill-emacs-hook, and NEWS if you change this. */ - if (noninteractive) signal (SIGINT, fatal_error_signal); - signal (SIGTERM, fatal_error_signal); + if (noninteractive) + sigaction (SIGINT, &fatal_error_action, 0); + sigaction (SIGTERM, &fatal_error_action, 0); #ifdef SIGXCPU - signal (SIGXCPU, fatal_error_signal); + sigaction (SIGXCPU, &fatal_error_action, 0); #endif #ifdef SIGXFSZ - signal (SIGXFSZ, fatal_error_signal); + sigaction (SIGXFSZ, &fatal_error_action, 0); #endif /* SIGXFSZ */ #ifdef SIGDANGER /* This just means available memory is getting low. */ - signal (SIGDANGER, memory_warning_signal); + { + struct sigaction action; + emacs_sigaction_init (&action, deliver_danger_signal); + sigaction (SIGDANGER, &action, 0); + } #endif #ifdef AIX /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */ - signal (SIGXCPU, fatal_error_signal); - signal (SIGIOINT, fatal_error_signal); - signal (SIGGRANT, fatal_error_signal); - signal (SIGRETRACT, fatal_error_signal); - signal (SIGSOUND, fatal_error_signal); - signal (SIGMSG, fatal_error_signal); + sigaction (SIGXCPU, &fatal_error_action, 0); + sigaction (SIGIOINT, &fatal_error_action, 0); + sigaction (SIGGRANT, &fatal_error_action, 0); + sigaction (SIGRETRACT, &fatal_error_action, 0); + sigaction (SIGSOUND, &fatal_error_action, 0); + sigaction (SIGMSG, &fatal_error_action, 0); #endif /* AIX */ } @@ -1607,7 +1612,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem init_fringe (); #endif /* HAVE_WINDOW_SYSTEM */ init_macros (); - init_floatfns (); init_window (); init_font (); @@ -1922,7 +1926,7 @@ sort_args (int argc, char **argv) } if (best < 0) - abort (); + emacs_abort (); /* Copy the highest priority remaining option, with its args, to NEW. Unless it is a duplicate of the previous one. */ @@ -1985,7 +1989,7 @@ all of which are called before Emacs is actually killed. */) x_clipboard_manager_save_all (); #endif - shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); + shut_down_emacs (0, STRINGP (arg) ? arg : Qnil); #ifdef HAVE_NS ns_release_autorelease_pool (ns_pool); @@ -2021,7 +2025,7 @@ all of which are called before Emacs is actually killed. */) and Fkill_emacs. */ void -shut_down_emacs (int sig, int no_x, Lisp_Object stuff) +shut_down_emacs (int sig, Lisp_Object stuff) { /* Prevent running of hooks from now on. */ Vrun_hooks = Qnil; @@ -2038,7 +2042,7 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff) { reset_all_sys_modes (); if (sig && sig != SIGTERM) - fprintf (stderr, "Fatal error (%d)", sig); + fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig)); } } #else @@ -2056,23 +2060,10 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff) unlock_all_files (); #endif -#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */ -#ifdef HAVE_X_WINDOWS - /* It's not safe to call intern here. Maybe we are crashing. */ - if (!noninteractive && SYMBOLP (Vinitial_window_system) - && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1 - && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x' - && ! no_x) - Fx_close_current_connection (); -#endif /* HAVE_X_WINDOWS */ -#endif - -#ifdef SIGIO /* There is a tendency for a SIGIO signal to arrive within exit, and cause a SIGHUP because the input descriptor is already closed. */ unrequest_sigio (); - signal (SIGIO, SIG_IGN); -#endif + ignore_sigio (); #ifdef WINDOWSNT term_ntproc (); @@ -2178,12 +2169,6 @@ You must run Emacs in batch mode in order to dump it. */) memory_warnings (my_edata, malloc_warning); } #endif /* not WINDOWSNT */ -#if defined (HAVE_PTHREAD) && !defined SYNC_INPUT - /* Pthread may call malloc before main, and then we will get an endless - loop, because pthread_self (see alloc.c) calls malloc the first time - it is called on some systems. */ - reset_malloc_hooks (); -#endif #endif /* not SYSTEM_MALLOC */ #ifdef DOUG_LEA_MALLOC malloc_state_ptr = malloc_get_state (); @@ -2258,7 +2243,7 @@ decode_env_path (const char *evarname, const char *defalt) const char *path, *p; Lisp_Object lpath, element, tem; #ifdef WINDOWSNT - int defaulted = 0; + bool defaulted = 0; const char *emacs_dir = egetenv ("emacs_dir"); static const char *emacs_dir_env = "%emacs_dir%/"; const size_t emacs_dir_len = strlen (emacs_dir_env); @@ -2354,7 +2339,7 @@ from the parent process and its tty file descriptors. */) (void) { int nfd; - int err = 0; + bool err = 0; if (!IS_DAEMON) error ("This function can only be called if emacs is run as a daemon"); diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index 1a62b59b7af..d10185072cc 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c @@ -21,13 +21,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include "emacsgtkfixed.h" -#include <signal.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "frame.h" #include "xterm.h" +/* Silence a bogus diagnostic; see GNOME bug 683906. */ +#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#endif + #define EMACS_TYPE_FIXED emacs_fixed_get_type () #define EMACS_FIXED(obj) \ G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed) diff --git a/src/eval.c b/src/eval.c index c56be10c5a0..1c565e233c6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <limits.h> -#include <setjmp.h> #include <stdio.h> #include "lisp.h" #include "blockinput.h" @@ -69,7 +68,7 @@ Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp; Lisp_Object Qinhibit_quit; Lisp_Object Qand_rest; static Lisp_Object Qand_optional; -static Lisp_Object Qdebug_on_error; +static Lisp_Object Qinhibit_debugger; static Lisp_Object Qdeclare; Lisp_Object Qinternal_interpreter_environment, Qclosure; @@ -118,12 +117,6 @@ static EMACS_INT when_entered_debugger; Lisp_Object Vsignaling_function; -/* Set to non-zero while processing X events. Checked in Feval to - make sure the Lisp interpreter isn't called from a signal handler, - which is unsafe because the interpreter isn't reentrant. */ - -int handling_signal; - /* If non-nil, Lisp code must not be run since some part of Emacs is in an inconsistent state. Currently, x-create-frame uses this to avoid triggering window-configuration-change-hook while the new @@ -131,7 +124,7 @@ int handling_signal; Lisp_Object inhibit_lisp_code; static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); -static int interactive_p (int); +static bool interactive_p (void); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); /* Functions to set Lisp_Object slots of struct specbinding. */ @@ -191,10 +184,10 @@ restore_stack_limits (Lisp_Object data) /* Call the Lisp debugger, giving it argument ARG. */ -static Lisp_Object +Lisp_Object call_debugger (Lisp_Object arg) { - int debug_while_redisplaying; + bool debug_while_redisplaying; ptrdiff_t count = SPECPDL_INDEX (); Lisp_Object val; EMACS_INT old_max = max_specpdl_size; @@ -229,7 +222,7 @@ call_debugger (Lisp_Object arg) specbind (intern ("debugger-may-continue"), debug_while_redisplaying ? Qnil : Qt); specbind (Qinhibit_redisplay, Qnil); - specbind (Qdebug_on_error, Qnil); + specbind (Qinhibit_debugger, Qt); #if 0 /* Binding this prevents execution of Lisp code during redisplay, which necessarily leads to display problems. */ @@ -525,7 +518,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii) use `called-interactively-p'. */) (void) { - return interactive_p (1) ? Qt : Qnil; + return interactive_p () ? Qt : Qnil; } @@ -550,19 +543,17 @@ non-nil unconditionally (\"p\" is a good way to do this), or via \(not (or executing-kbd-macro noninteractive)). */) (Lisp_Object kind) { - return ((INTERACTIVE || !EQ (kind, intern ("interactive"))) - && interactive_p (1)) ? Qt : Qnil; + return (((INTERACTIVE || !EQ (kind, intern ("interactive"))) + && interactive_p ()) + ? Qt : Qnil); } -/* Return 1 if function in which this appears was called using - call-interactively. +/* Return true if function in which this appears was called using + call-interactively and is not a built-in. */ - EXCLUDE_SUBRS_P non-zero means always return 0 if the function - called is a built-in. */ - -static int -interactive_p (int exclude_subrs_p) +static bool +interactive_p (void) { struct backtrace *btp; Lisp_Object fun; @@ -591,9 +582,9 @@ interactive_p (int exclude_subrs_p) /* `btp' now points at the frame of the innermost function that isn't a special form, ignoring frames for Finteractive_p and/or Fbytecode at the top. If this frame is for a built-in function - (such as load or eval-region) return nil. */ + (such as load or eval-region) return false. */ fun = Findirect_function (*btp->function, Qnil); - if (exclude_subrs_p && SUBRP (fun)) + if (SUBRP (fun)) return 0; /* `btp' points to the frame of a Lisp function that called interactive-p. @@ -709,7 +700,7 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) else { /* Check if there is really a global binding rather than just a let binding that shadows the global unboundness of the var. */ - volatile struct specbinding *pdl = specpdl_ptr; + struct specbinding *pdl = specpdl_ptr; while (pdl > specpdl) { if (EQ ((--pdl)->symbol, sym) && !pdl->func @@ -1074,7 +1065,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object catchlist = &c; /* Call FUNC. */ - if (! _setjmp (c.jmp)) + if (! sys_setjmp (c.jmp)) c.val = (*func) (arg); /* Throw works by a longjmp that comes right here. */ @@ -1101,7 +1092,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object static _Noreturn void unwind_to_catch (struct catchtag *catch, Lisp_Object value) { - int last_time; + bool last_time; /* Save the value in the tag. */ catch->val = value; @@ -1109,7 +1100,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) /* Restore certain special C variables. */ set_poll_suppress_count (catch->poll_suppress_count); UNBLOCK_INPUT_TO (catch->interrupt_input_blocked); - handling_signal = 0; immediate_quit = 0; do @@ -1142,7 +1132,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) backtrace_list = catch->backlist; lisp_eval_depth = catch->lisp_eval_depth; - _longjmp (catch->jmp, 1); + sys_longjmp (catch->jmp, 1); } DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, @@ -1206,12 +1196,9 @@ See also the function `signal' for more info. usage: (condition-case VAR BODYFORM &rest HANDLERS) */) (Lisp_Object args) { - register Lisp_Object bodyform, handlers; - volatile Lisp_Object var; - - var = Fcar (args); - bodyform = Fcar (Fcdr (args)); - handlers = Fcdr (Fcdr (args)); + Lisp_Object var = Fcar (args); + Lisp_Object bodyform = Fcar (Fcdr (args)); + Lisp_Object handlers = Fcdr (Fcdr (args)); return internal_lisp_condition_case (var, bodyform, handlers); } @@ -1251,7 +1238,7 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform, c.interrupt_input_blocked = interrupt_input_blocked; c.gcpro = gcprolist; c.byte_stack = byte_stack_list; - if (_setjmp (c.jmp)) + if (sys_setjmp (c.jmp)) { if (!NILP (h.var)) specbind (h.var, c.val); @@ -1306,7 +1293,7 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers, c.interrupt_input_blocked = interrupt_input_blocked; c.gcpro = gcprolist; c.byte_stack = byte_stack_list; - if (_setjmp (c.jmp)) + if (sys_setjmp (c.jmp)) { return (*hfun) (c.val); } @@ -1344,7 +1331,7 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg, c.interrupt_input_blocked = interrupt_input_blocked; c.gcpro = gcprolist; c.byte_stack = byte_stack_list; - if (_setjmp (c.jmp)) + if (sys_setjmp (c.jmp)) { return (*hfun) (c.val); } @@ -1386,7 +1373,7 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object), c.interrupt_input_blocked = interrupt_input_blocked; c.gcpro = gcprolist; c.byte_stack = byte_stack_list; - if (_setjmp (c.jmp)) + if (sys_setjmp (c.jmp)) { return (*hfun) (c.val); } @@ -1430,7 +1417,7 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), c.interrupt_input_blocked = interrupt_input_blocked; c.gcpro = gcprolist; c.byte_stack = byte_stack_list; - if (_setjmp (c.jmp)) + if (sys_setjmp (c.jmp)) { return (*hfun) (c.val, nargs, args); } @@ -1450,8 +1437,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); -static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, - Lisp_Object data); +static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, + Lisp_Object data); void process_quit_flag (void) @@ -1492,10 +1479,10 @@ See also the function `condition-case'. */) struct handler *h; struct backtrace *bp; - immediate_quit = handling_signal = 0; + immediate_quit = 0; abort_on_gc = 0; if (gc_in_progress || waiting_for_input) - abort (); + emacs_abort (); #if 0 /* rms: I don't know why this was here, but it is surely wrong for an error that is handled. */ @@ -1556,7 +1543,7 @@ See also the function `condition-case'. */) if requested". */ || EQ (h->handler, Qerror))) { - int debugger_called + bool debugger_called = maybe_call_debugger (conditions, error_symbol, data); /* We can't return values to code which signaled an error, but we can continue code which has signaled a quit. */ @@ -1592,7 +1579,7 @@ void xsignal (Lisp_Object error_symbol, Lisp_Object data) { Fsignal (error_symbol, data); - abort (); + emacs_abort (); } /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ @@ -1650,10 +1637,10 @@ signal_error (const char *s, Lisp_Object arg) } -/* Return nonzero if LIST is a non-nil atom or +/* Return true if LIST is a non-nil atom or a list containing one of CONDITIONS. */ -static int +static bool wants_debugger (Lisp_Object list, Lisp_Object conditions) { if (NILP (list)) @@ -1673,15 +1660,15 @@ wants_debugger (Lisp_Object list, Lisp_Object conditions) return 0; } -/* Return 1 if an error with condition-symbols CONDITIONS, +/* Return true if an error with condition-symbols CONDITIONS, and described by SIGNAL-DATA, should skip the debugger according to debugger-ignored-errors. */ -static int +static bool skip_debugger (Lisp_Object conditions, Lisp_Object data) { Lisp_Object tail; - int first_string = 1; + bool first_string = 1; Lisp_Object error_message; error_message = Qnil; @@ -1716,7 +1703,7 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data) = SIG is the error symbol, and DATA is the rest of the data. = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). This is for memory-full errors only. */ -static int +static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) { Lisp_Object combined_data; @@ -1727,6 +1714,7 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) /* Don't try to run the debugger with interrupts blocked. The editing loop would return anyway. */ ! INPUT_BLOCKED_P + && NILP (Vinhibit_debugger) /* Does user want to enter debugger for this kind of error? */ && (EQ (sig, Qquit) ? debug_on_quit @@ -2044,9 +2032,6 @@ eval_sub (Lisp_Object form) struct backtrace backtrace; struct gcpro gcpro1, gcpro2, gcpro3; - if (handling_signal) - abort (); - if (SYMBOLP (form)) { /* Look up its binding in the lexical environment. @@ -2209,7 +2194,7 @@ eval_sub (Lisp_Object form) is supported by this code. We need to either rewrite the subr to use a different argument protocol, or add more cases to this switch. */ - abort (); + emacs_abort (); } } } @@ -2232,7 +2217,6 @@ eval_sub (Lisp_Object form) if (EQ (funcar, Qmacro)) { ptrdiff_t count = SPECPDL_INDEX (); - extern Lisp_Object Qlexical_binding; Lisp_Object exp; /* Bind lexical-binding during expansion of the macro, so the macro can know reliably if the code it outputs will be @@ -2853,7 +2837,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) /* If a subr takes more than 8 arguments without using MANY or UNEVALLED, we need to extend this function to support it. Until this is done, there is no way to call the function. */ - abort (); + emacs_abort (); } } } @@ -2940,7 +2924,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, Lisp_Object val, syms_left, next, lexenv; ptrdiff_t count = SPECPDL_INDEX (); ptrdiff_t i; - int optional, rest; + bool optional, rest; if (CONSP (fun)) { @@ -2984,7 +2968,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, lexenv = Qnil; } else - abort (); + emacs_abort (); i = optional = rest = 0; for (; CONSP (syms_left); syms_left = XCDR (syms_left)) @@ -3110,8 +3094,6 @@ specbind (Lisp_Object symbol, Lisp_Object value) { struct Lisp_Symbol *sym; - eassert (!handling_signal); - CHECK_SYMBOL (symbol); sym = XSYMBOL (symbol); if (specpdl_ptr == specpdl + specpdl_size) @@ -3198,15 +3180,13 @@ specbind (Lisp_Object symbol, Lisp_Object value) set_internal (symbol, value, Qnil, 1); break; } - default: abort (); + default: emacs_abort (); } } void record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) { - eassert (!handling_signal); - if (specpdl_ptr == specpdl + specpdl_size) grow_specpdl (); specpdl_ptr->func = function; @@ -3343,13 +3323,13 @@ Output stream used is value of `standard-output'. */) write_string ("(", -1); if (backlist->nargs == MANY) { /* FIXME: Can this happen? */ - int i; - for (tail = *backlist->args, i = 0; - !NILP (tail); - tail = Fcdr (tail), i = 1) + bool later_arg = 0; + for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail)) { - if (i) write_string (" ", -1); + if (later_arg) + write_string (" ", -1); Fprin1 (Fcar (tail), Qnil); + later_arg = 1; } } else @@ -3470,7 +3450,7 @@ before making `inhibit-quit' nil. */); DEFSYM (Qinhibit_quit, "inhibit-quit"); DEFSYM (Qautoload, "autoload"); - DEFSYM (Qdebug_on_error, "debug-on-error"); + DEFSYM (Qinhibit_debugger, "inhibit-debugger"); DEFSYM (Qmacro, "macro"); DEFSYM (Qdeclare, "declare"); @@ -3485,6 +3465,12 @@ before making `inhibit-quit' nil. */); DEFSYM (Qclosure, "closure"); DEFSYM (Qdebug, "debug"); + DEFVAR_LISP ("inhibit-debugger", Vinhibit_debugger, + doc: /* Non-nil means never enter the debugger. +Normally set while the debugger is already active, to avoid recursive +invocations. */); + Vinhibit_debugger = Qnil; + DEFVAR_LISP ("debug-on-error", Vdebug_on_error, doc: /* Non-nil means enter debugger if an error is signaled. Does not apply to errors handled by `condition-case' or those @@ -3494,7 +3480,7 @@ if one of its condition symbols appears in the list. When you evaluate an expression interactively, this variable is temporarily non-nil if `eval-expression-debug-on-error' is non-nil. The command `toggle-debug-on-error' toggles this. -See also the variable `debug-on-quit'. */); +See also the variable `debug-on-quit' and `inhibit-debugger'. */); Vdebug_on_error = Qnil; DEFVAR_LISP ("debug-ignored-errors", Vdebug_ignored_errors, diff --git a/src/fileio.c b/src/fileio.c index 7466914af1c..ca71af7ed95 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> -#include <setjmp.h> #include <unistd.h> #ifdef HAVE_PWD_H @@ -85,18 +84,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "commands.h" -/* Nonzero during writing of auto-save files. */ -static int auto_saving; +/* True during writing of auto-save files. */ +static bool auto_saving; /* Nonzero umask during creation of auto-save directories. */ -static int auto_saving_dir_umask; +static mode_t auto_saving_dir_umask; /* Set by auto_save_1 to mode of original file so Fwrite_region will create a new file with the same mode as the original. */ -static int auto_save_mode_bits; +static mode_t auto_save_mode_bits; /* Set by auto_save_1 if an error occurred during the last auto-save. */ -static int auto_save_error_occurred; +static bool auto_save_error_occurred; /* The symbol bound to coding-system-for-read when insert-file-contents is called for recovering a file. This is not @@ -145,10 +144,10 @@ Lisp_Object Qfile_name_history; static Lisp_Object Qcar_less_than_car; -static int a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, - Lisp_Object *, struct coding_system *); -static int e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, - struct coding_system *); +static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, + Lisp_Object *, struct coding_system *); +static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, + struct coding_system *); void @@ -595,7 +594,7 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p; which has no existing file. To make this work, PREFIX should be an absolute file name. - BASE64_P non-zero means add the pid as 3 characters in base64 + BASE64_P means add the pid as 3 characters in base64 encoding. In this case, 6 characters will be added to PREFIX to form the file name. Otherwise, if Emacs is running on a system with long file names, add the pid as a decimal number. @@ -604,7 +603,7 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p; generated. */ Lisp_Object -make_temp_name (Lisp_Object prefix, int base64_p) +make_temp_name (Lisp_Object prefix, bool base64_p) { Lisp_Object val; int len, clen; @@ -761,8 +760,8 @@ filesystem tree, not (expand-file-name ".." dirname). */) struct passwd *pw; #ifdef DOS_NT int drive = 0; - int collapse_newdir = 1; - int is_escaped = 0; + bool collapse_newdir = 1; + bool is_escaped = 0; #endif /* DOS_NT */ ptrdiff_t length; Lisp_Object handler, result, handled_name; @@ -920,10 +919,9 @@ filesystem tree, not (expand-file-name ".." dirname). */) /* If it turns out that the filename we want to return is just a suffix of FILENAME, we don't need to go through and edit things; we just need to construct a new string using data - starting at the middle of FILENAME. If we set lose to a - non-zero value, that means we've discovered that we can't do - that cool trick. */ - int lose = 0; + starting at the middle of FILENAME. If we set LOSE, that + means we've discovered that we can't do that cool trick. */ + bool lose = 0; char *p = nm; while (*p) @@ -1294,7 +1292,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) #endif /* WINDOWSNT */ { - if (!drive) abort (); + if (!drive) emacs_abort (); target -= 2; target[0] = DRIVE_LETTER (drive); target[1] = ':'; @@ -1360,7 +1358,6 @@ See also the function `substitute-in-file-name'.") ptrdiff_t tlen; unsigned char *target; struct passwd *pw; - int lose; CHECK_STRING (name); nm = SDATA (name); @@ -1369,8 +1366,8 @@ See also the function `substitute-in-file-name'.") If no /./ or /../ we can return right away. */ if (nm[0] == '/') { + bool lose = 0; p = nm; - lose = 0; while (*p) { if (p[0] == '/' && p[1] == '/' @@ -1494,7 +1491,7 @@ See also the function `substitute-in-file-name'.") #endif /* If /~ or // appears, discard everything through first slash. */ -static int +static bool file_name_absolute_p (const char *filename) { return @@ -1560,12 +1557,10 @@ If `//' appears, everything up to and including the first of those `/' is discarded. */) (Lisp_Object filename) { - char *nm; - - register char *s, *p, *o, *x, *endp; + char *nm, *s, *p, *o, *x, *endp; char *target = NULL; int total = 0; - int substituted = 0; + bool substituted = 0; bool multibyte; char *xnm; Lisp_Object handler; @@ -1780,7 +1775,7 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) } /* Signal an error if the file ABSNAME already exists. - If INTERACTIVE is nonzero, ask the user whether to proceed, + If INTERACTIVE, ask the user whether to proceed, and bypass the error if the user says to go ahead. QUERYSTRING is a name for the action that is being considered to alter the file. @@ -1789,13 +1784,14 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) If the file does not exist, STATPTR->st_mode is set to 0. If STATPTR is null, we don't store into it. - If QUICK is nonzero, we ask for y or n, not yes or no. */ + If QUICK, ask for y or n, not yes or no. */ static void barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, - int interactive, struct stat *statptr, int quick) + bool interactive, struct stat *statptr, + bool quick) { - register Lisp_Object tem, encoded_filename; + Lisp_Object tem, encoded_filename; struct stat statbuf; struct gcpro gcpro1; @@ -1869,11 +1865,11 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) Lisp_Object handler; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; ptrdiff_t count = SPECPDL_INDEX (); - int input_file_statable_p; + bool input_file_statable_p; Lisp_Object encoded_file, encoded_newname; #if HAVE_LIBSELINUX security_context_t con; - int fail, conlength = 0; + int conlength = 0; #endif encoded_file = encoded_newname = Qnil; @@ -1988,7 +1984,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) S_IREAD | S_IWRITE); #else /* not MSDOS */ { - int new_mask = 0666; + mode_t new_mask = 0666; if (input_file_statable_p) { if (!NILP (preserve_uid_gid)) @@ -2018,7 +2014,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) owner and group. */ if (input_file_statable_p) { - int mode_mask = 07777; + mode_t mode_mask = 07777; if (!NILP (preserve_uid_gid)) { /* Attempt to change owner and group. If that doesn't work @@ -2041,7 +2037,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) if (conlength > 0) { /* Set the modified context back to the file. */ - fail = fsetfilecon (ofd, con); + bool fail = fsetfilecon (ofd, con) != 0; /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ if (fail && errno != ENOTSUP) report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); @@ -2184,17 +2180,14 @@ internal_delete_file_1 (Lisp_Object ignore) return Qt; } -/* Delete file FILENAME, returning 1 if successful and 0 if failed. +/* Delete file FILENAME. This ignores `delete-by-moving-to-trash'. */ -int +void internal_delete_file (Lisp_Object filename) { - Lisp_Object tem; - - tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, - Qt, internal_delete_file_1); - return NILP (tem); + internal_condition_case_2 (Fdelete_file, filename, Qnil, + Qt, internal_delete_file_1); } DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, @@ -2430,9 +2423,9 @@ On Unix, this is a name starting with a `/' or a `~'. */) return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil; } -/* Return nonzero if file FILENAME exists and can be executed. */ +/* Return true if file FILENAME exists and can be executed. */ -static int +static bool check_executable (char *filename) { #ifdef DOS_NT @@ -2452,9 +2445,9 @@ check_executable (char *filename) #endif /* not DOS_NT */ } -/* Return nonzero if file FILENAME exists and can be written. */ +/* Return true if file FILENAME exists and can be written. */ -static int +static bool check_writable (const char *filename) { #ifdef MSDOS @@ -2464,7 +2457,7 @@ check_writable (const char *filename) return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); #else /* not MSDOS */ #ifdef HAVE_EUIDACCESS - int res = (euidaccess (filename, 2) >= 0); + bool res = (euidaccess (filename, 2) >= 0); #ifdef CYGWIN /* euidaccess may have returned failure because Cygwin couldn't determine the file's UID or GID; if so, we return success. */ @@ -2732,7 +2725,7 @@ searchable directory. */) (Lisp_Object filename) { Lisp_Object handler; - int tem; + bool tem; struct gcpro gcpro1; /* If the file name has special constructs in it, @@ -2868,7 +2861,8 @@ compiled with SELinux support. */) Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context))); Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context)))); security_context_t con; - int fail, conlength; + bool fail; + int conlength; context_t parsed_con; #endif @@ -2912,8 +2906,9 @@ compiled with SELinux support. */) } /* Set the modified context back to the file. */ - fail = lsetfilecon (SSDATA (encoded_absname), - context_str (parsed_con)); + fail = (lsetfilecon (SSDATA (encoded_absname), + context_str (parsed_con)) + != 0); /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ if (fail && errno != ENOTSUP) report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); @@ -3004,7 +2999,7 @@ DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0, The value is an integer. */) (void) { - int realmask; + mode_t realmask; Lisp_Object value; BLOCK_INPUT; @@ -3246,29 +3241,29 @@ variable `last-coding-system-used' to the coding system actually used. */) struct stat st; int file_status; EMACS_TIME mtime; - register int fd; + int fd; ptrdiff_t inserted = 0; - int nochange = 0; - register ptrdiff_t how_much; + bool nochange = 0; + ptrdiff_t how_much; off_t beg_offset, end_offset; - register int unprocessed; + int unprocessed; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; Lisp_Object handler, val, insval, orig_filename, old_undo; Lisp_Object p; ptrdiff_t total = 0; - int not_regular = 0; + bool not_regular = 0; int save_errno = 0; char read_buf[READ_BUF_SIZE]; struct coding_system coding; char buffer[1 << 14]; - int replace_handled = 0; - int set_coding_system = 0; + bool replace_handled = 0; + bool set_coding_system = 0; Lisp_Object coding_system; - int read_quit = 0; + bool read_quit = 0; Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; - int we_locked_file = 0; - int deferred_remove_unwind_protect = 0; + bool we_locked_file = 0; + bool deferred_remove_unwind_protect = 0; if (current_buffer->base_buffer && ! NILP (visit)) error ("Cannot do file visiting in an indirect buffer"); @@ -3569,9 +3564,9 @@ variable `last-coding-system-used' to the coding system actually used. */) ptrdiff_t same_at_end = ZV_BYTE; ptrdiff_t overlap; /* There is still a possibility we will find the need to do code - conversion. If that happens, we set this variable to 1 to + conversion. If that happens, set this variable to give up on handling REPLACE in the optimized way. */ - int giveup_match_end = 0; + bool giveup_match_end = 0; if (beg_offset != 0) { @@ -4427,8 +4422,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file If it is not set locally, we anyway have to convert EOL format if the default value of `buffer-file-coding-system' tells that it is not Unix-like (LF only) format. */ - int using_default_coding = 0; - int force_raw_text = 0; + bool using_default_coding = 0; + bool force_raw_text = 0; val = BVAR (current_buffer, buffer_file_coding_system); if (NILP (val) @@ -4537,8 +4532,8 @@ This calls `write-region-annotate-functions' at the start, and `write-region-post-annotation-function' at the end. */) (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew) { - register int desc; - int failure; + int desc; + bool ok; int save_errno = 0; const char *fn; struct stat st; @@ -4548,8 +4543,8 @@ This calls `write-region-annotate-functions' at the start, and Lisp_Object visit_file; Lisp_Object annotations; Lisp_Object encoded_filename; - int visiting = (EQ (visit, Qt) || STRINGP (visit)); - int quietly = !NILP (visit); + bool visiting = (EQ (visit, Qt) || STRINGP (visit)); + bool quietly = !NILP (visit); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; struct buffer *given_buffer; struct coding_system coding; @@ -4713,37 +4708,27 @@ This calls `write-region-annotate-functions' at the start, and UNGCPRO; - failure = 0; immediate_quit = 1; if (STRINGP (start)) - { - failure = 0 > a_write (desc, start, 0, SCHARS (start), - &annotations, &coding); - save_errno = errno; - } + ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); else if (XINT (start) != XINT (end)) - { - failure = 0 > a_write (desc, Qnil, - XINT (start), XINT (end) - XINT (start), - &annotations, &coding); - save_errno = errno; - } + ok = a_write (desc, Qnil, XINT (start), XINT (end) - XINT (start), + &annotations, &coding); else { - /* If file was empty, still need to write the annotations */ + /* If file was empty, still need to write the annotations. */ coding.mode |= CODING_MODE_LAST_BLOCK; - failure = 0 > a_write (desc, Qnil, XINT (end), 0, &annotations, &coding); - save_errno = errno; + ok = a_write (desc, Qnil, XINT (end), 0, &annotations, &coding); } + save_errno = errno; - if (CODING_REQUIRE_FLUSHING (&coding) - && !(coding.mode & CODING_MODE_LAST_BLOCK) - && ! failure) + if (ok && CODING_REQUIRE_FLUSHING (&coding) + && !(coding.mode & CODING_MODE_LAST_BLOCK)) { /* We have to flush out a data. */ coding.mode |= CODING_MODE_LAST_BLOCK; - failure = 0 > e_write (desc, Qnil, 1, 1, &coding); + ok = e_write (desc, Qnil, 1, 1, &coding); save_errno = errno; } @@ -4760,13 +4745,13 @@ This calls `write-region-annotate-functions' at the start, and ignore EINVAL which happens when fsync is not supported on this file. */ if (errno != EINTR && errno != EINVAL) - failure = 1, save_errno = errno; + ok = 0, save_errno = errno; } #endif /* NFS can report a write failure now. */ if (emacs_close (desc) < 0) - failure = 1, save_errno = errno; + ok = 0, save_errno = errno; stat (fn, &st); @@ -4803,7 +4788,7 @@ This calls `write-region-annotate-functions' at the start, and current_buffer->modtime_size = st.st_size; } - if (failure) + if (! ok) error ("IO error writing %s: %s", SDATA (filename), emacs_strerror (save_errno)); @@ -4859,7 +4844,8 @@ build_annotations (Lisp_Object start, Lisp_Object end) Lisp_Object p, res; struct gcpro gcpro1, gcpro2; Lisp_Object original_buffer; - int i, used_global = 0; + int i; + bool used_global = 0; XSETBUFFER (original_buffer, current_buffer); @@ -4939,11 +4925,11 @@ build_annotations (Lisp_Object start, Lisp_Object end) We modify *ANNOT by discarding elements as we use them up. - The return value is negative in case of system call failure. */ + Return true if successful. */ -static int +static bool a_write (int desc, Lisp_Object string, ptrdiff_t pos, - register ptrdiff_t nchars, Lisp_Object *annot, + ptrdiff_t nchars, Lisp_Object *annot, struct coding_system *coding) { Lisp_Object tem; @@ -4965,29 +4951,29 @@ a_write (int desc, Lisp_Object string, ptrdiff_t pos, /* Output buffer text up to the next annotation's position. */ if (nextpos > pos) { - if (0 > e_write (desc, string, pos, nextpos, coding)) - return -1; + if (!e_write (desc, string, pos, nextpos, coding)) + return 0; pos = nextpos; } /* Output the annotation. */ tem = Fcdr (Fcar (*annot)); if (STRINGP (tem)) { - if (0 > e_write (desc, tem, 0, SCHARS (tem), coding)) - return -1; + if (!e_write (desc, tem, 0, SCHARS (tem), coding)) + return 0; } *annot = Fcdr (*annot); } - return 0; + return 1; } /* Write text in the range START and END into descriptor DESC, encoding them with coding system CODING. If STRING is nil, START and END are character positions of the current buffer, else they - are indexes to the string STRING. */ + are indexes to the string STRING. Return true if successful. */ -static int +static bool e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, struct coding_system *coding) { @@ -5056,12 +5042,12 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, coding->produced); if (coding->produced) - return -1; + return 0; } start += coding->consumed_char; } - return 0; + return 1; } DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, @@ -5300,12 +5286,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) { struct buffer *old = current_buffer, *b; Lisp_Object tail, buf, hook; - int auto_saved = 0; + bool auto_saved = 0; int do_handled_files; Lisp_Object oquit; FILE *stream = NULL; ptrdiff_t count = SPECPDL_INDEX (); - int orig_minibuffer_auto_raise = minibuffer_auto_raise; + bool orig_minibuffer_auto_raise = minibuffer_auto_raise; bool old_message_p = 0; struct gcpro gcpro1, gcpro2; @@ -5452,7 +5438,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) if (!auto_saved && NILP (no_message)) message1 ("Auto-saving..."); internal_condition_case (auto_save_1, Qt, auto_save_error); - auto_saved++; + auto_saved = 1; BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b); XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); set_buffer_internal (old); diff --git a/src/filelock.c b/src/filelock.c index d21d8e7ba02..17f3f253249 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/stat.h> #include <signal.h> #include <stdio.h> -#include <setjmp.h> #ifdef HAVE_PWD_H #include <pwd.h> @@ -100,10 +99,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Return the time of the last system boot. */ static time_t boot_time; -static int boot_time_initialized; +static bool boot_time_initialized; #ifdef BOOT_TIME -static void get_boot_time_1 (const char *, int); +static void get_boot_time_1 (const char *, bool); #endif static time_t @@ -170,7 +169,7 @@ get_boot_time (void) { char cmd_string[sizeof WTMP_FILE ".19.gz"]; Lisp_Object tempname, filename; - int delete_flag = 0; + bool delete_flag = 0; filename = Qnil; @@ -225,13 +224,13 @@ get_boot_time (void) If FILENAME is zero, use the same file as before; if no FILENAME has ever been specified, this is the utmp file. - Use the newest reboot record if NEWEST is nonzero, + Use the newest reboot record if NEWEST, the first reboot record otherwise. Ignore all reboot records on or before BOOT_TIME. Success is indicated by setting BOOT_TIME to a larger value. */ void -get_boot_time_1 (const char *filename, int newest) +get_boot_time_1 (const char *filename, bool newest) { struct utmp ut, *utp; int desc; @@ -331,11 +330,11 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn) } /* Lock the lock file named LFNAME. - If FORCE is nonzero, we do so even if it is already locked. - Return 1 if successful, 0 if not. */ + If FORCE, do so even if it is already locked. + Return true if successful. */ -static int -lock_file_1 (char *lfname, int force) +static bool +lock_file_1 (char *lfname, bool force) { int err; int symlink_errno; @@ -370,9 +369,9 @@ lock_file_1 (char *lfname, int force) return err == 0; } -/* Return 1 if times A and B are no more than one second apart. */ +/* Return true if times A and B are no more than one second apart. */ -static int +static bool within_one_second (time_t a, time_t b) { return (a - b >= -1 && a - b <= 1); @@ -491,7 +490,7 @@ current_lock_owner (lock_info_type *owner, char *lfname) static int lock_if_free (lock_info_type *clasher, register char *lfname) { - while (lock_file_1 (lfname, 0) == 0) + while (! lock_file_1 (lfname, 0)) { int locker; diff --git a/src/firstfile.c b/src/firstfile.c index 84511cfe0ad..444fb71b55d 100644 --- a/src/firstfile.c +++ b/src/firstfile.c @@ -27,7 +27,6 @@ static char _my_begbss[1]; char * my_begbss_static = _my_begbss; /* Add a dummy reference to ensure emacs.obj is linked in. */ -extern int initialized; -static int * dummy = &initialized; +extern int main (int, char **); +static int (*dummy) (int, char **) = main; #endif - diff --git a/src/floatfns.c b/src/floatfns.c index cad071f1e15..4fe209fcb61 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -22,171 +22,32 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* ANSI C requires only these float functions: - acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, - frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh. - - Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh. - Define HAVE_CBRT if you have cbrt. - Define HAVE_RINT if you have a working rint. - If you don't define these, then the appropriate routines will be simulated. - - Define HAVE_MATHERR if on a system supporting the SysV matherr callback. - (This should happen automatically.) - - Define FLOAT_CHECK_ERRNO if the float library routines set errno. - This has no effect if HAVE_MATHERR is defined. - - Define FLOAT_CATCH_SIGILL if the float library routines signal SIGILL. - (What systems actually do this? Please let us know.) - - Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by - either setting errno, or signaling SIGFPE/SIGILL. Otherwise, domain and - range checking will happen before calling the float routines. This has - no effect if HAVE_MATHERR is defined (since matherr will be called when - a domain error occurs.) +/* C89 requires only the following math.h functions, and Emacs omits + the starred functions since we haven't found a use for them: + acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod, + frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh. */ #include <config.h> -#include <signal.h> -#include <setjmp.h> + #include "lisp.h" #include "syssignal.h" #include <float.h> -/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ -#ifndef IEEE_FLOATING_POINT #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) #define IEEE_FLOATING_POINT 1 #else #define IEEE_FLOATING_POINT 0 #endif -#endif #include <math.h> -/* This declaration is omitted on some systems, like Ultrix. */ -#if !defined (HPUX) && defined (HAVE_LOGB) && !defined (logb) -extern double logb (double); -#endif /* not HPUX and HAVE_LOGB and no logb macro */ - -#if defined (DOMAIN) && defined (SING) && defined (OVERFLOW) - /* If those are defined, then this is probably a `matherr' machine. */ -# ifndef HAVE_MATHERR -# define HAVE_MATHERR -# endif -#endif - -#ifdef NO_MATHERR -#undef HAVE_MATHERR +#ifndef isfinite +# define isfinite(x) ((x) - (x) == 0) #endif - -#ifdef HAVE_MATHERR -# ifdef FLOAT_CHECK_ERRNO -# undef FLOAT_CHECK_ERRNO -# endif -# ifdef FLOAT_CHECK_DOMAIN -# undef FLOAT_CHECK_DOMAIN -# endif -#endif - -#ifndef NO_FLOAT_CHECK_ERRNO -#define FLOAT_CHECK_ERRNO -#endif - -#ifdef FLOAT_CHECK_ERRNO -# include <errno.h> -#endif - -#ifdef FLOAT_CATCH_SIGILL -static void float_error (); -#endif - -/* Nonzero while executing in floating point. - This tells float_error what to do. */ - -static int in_float; - -/* If an argument is out of range for a mathematical function, - here is the actual argument value to use in the error message. - These variables are used only across the floating point library call - so there is no need to staticpro them. */ - -static Lisp_Object float_error_arg, float_error_arg2; - -static const char *float_error_fn_name; - -/* Evaluate the floating point expression D, recording NUM - as the original argument for error messages. - D is normally an assignment expression. - Handle errors which may result in signals or may set errno. - - Note that float_error may be declared to return void, so you can't - just cast the zero after the colon to (void) to make the types - check properly. */ - -#ifdef FLOAT_CHECK_ERRNO -#define IN_FLOAT(d, name, num) \ - do { \ - float_error_arg = num; \ - float_error_fn_name = name; \ - in_float = 1; errno = 0; (d); in_float = 0; \ - switch (errno) { \ - case 0: break; \ - case EDOM: domain_error (float_error_fn_name, float_error_arg); \ - case ERANGE: range_error (float_error_fn_name, float_error_arg); \ - default: arith_error (float_error_fn_name, float_error_arg); \ - } \ - } while (0) -#define IN_FLOAT2(d, name, num, num2) \ - do { \ - float_error_arg = num; \ - float_error_arg2 = num2; \ - float_error_fn_name = name; \ - in_float = 1; errno = 0; (d); in_float = 0; \ - switch (errno) { \ - case 0: break; \ - case EDOM: domain_error (float_error_fn_name, float_error_arg); \ - case ERANGE: range_error (float_error_fn_name, float_error_arg); \ - default: arith_error (float_error_fn_name, float_error_arg); \ - } \ - } while (0) -#else -#define IN_FLOAT(d, name, num) (in_float = 1, (d), in_float = 0) -#define IN_FLOAT2(d, name, num, num2) (in_float = 1, (d), in_float = 0) -#endif - -/* Convert float to Lisp_Int if it fits, else signal a range error - using the given arguments. */ -#define FLOAT_TO_INT(x, i, name, num) \ - do \ - { \ - if (FIXNUM_OVERFLOW_P (x)) \ - range_error (name, num); \ - XSETINT (i, (EMACS_INT)(x)); \ - } \ - while (0) -#define FLOAT_TO_INT2(x, i, name, num1, num2) \ - do \ - { \ - if (FIXNUM_OVERFLOW_P (x)) \ - range_error2 (name, num1, num2); \ - XSETINT (i, (EMACS_INT)(x)); \ - } \ - while (0) - -#define arith_error(op,arg) \ - xsignal2 (Qarith_error, build_string ((op)), (arg)) -#define range_error(op,arg) \ - xsignal2 (Qrange_error, build_string ((op)), (arg)) -#define range_error2(op,a1,a2) \ - xsignal3 (Qrange_error, build_string ((op)), (a1), (a2)) -#define domain_error(op,arg) \ - xsignal2 (Qdomain_error, build_string ((op)), (arg)) -#ifdef FLOAT_CHECK_DOMAIN -#define domain_error2(op,a1,a2) \ - xsignal3 (Qdomain_error, build_string ((op)), (a1), (a2)) +#ifndef isnan +# define isnan(x) ((x) != (x)) #endif /* Extract a Lisp number as a `double', or signal an error. */ @@ -205,27 +66,19 @@ extract_float (Lisp_Object num) DEFUN ("acos", Facos, Sacos, 1, 1, 0, doc: /* Return the inverse cosine of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d > 1.0 || d < -1.0) - domain_error ("acos", arg); -#endif - IN_FLOAT (d = acos (d), "acos", arg); + d = acos (d); return make_float (d); } DEFUN ("asin", Fasin, Sasin, 1, 1, 0, doc: /* Return the inverse sine of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d > 1.0 || d < -1.0) - domain_error ("asin", arg); -#endif - IN_FLOAT (d = asin (d), "asin", arg); + d = asin (d); return make_float (d); } @@ -235,56 +88,47 @@ If only one argument Y is given, return the inverse tangent of Y. If two arguments Y and X are given, return the inverse tangent of Y divided by X, i.e. the angle in radians between the vector (X, Y) and the x-axis. */) - (register Lisp_Object y, Lisp_Object x) + (Lisp_Object y, Lisp_Object x) { double d = extract_float (y); if (NILP (x)) - IN_FLOAT (d = atan (d), "atan", y); + d = atan (d); else { double d2 = extract_float (x); - - IN_FLOAT2 (d = atan2 (d, d2), "atan", y, x); + d = atan2 (d, d2); } return make_float (d); } DEFUN ("cos", Fcos, Scos, 1, 1, 0, doc: /* Return the cosine of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = cos (d), "cos", arg); + d = cos (d); return make_float (d); } DEFUN ("sin", Fsin, Ssin, 1, 1, 0, doc: /* Return the sine of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = sin (d), "sin", arg); + d = sin (d); return make_float (d); } DEFUN ("tan", Ftan, Stan, 1, 1, 0, doc: /* Return the tangent of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - double c = cos (d); -#ifdef FLOAT_CHECK_DOMAIN - if (c == 0.0) - domain_error ("tan", arg); -#endif - IN_FLOAT (d = sin (d) / c, "tan", arg); + d = tan (d); return make_float (d); } -#undef isnan -#define isnan(x) ((x) != (x)) - DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, doc: /* Return non nil iff argument X is a NaN. */) (Lisp_Object x) @@ -309,6 +153,7 @@ Cause an error if X1 or X2 is not a float. */) return make_float (copysign (f1, f2)); } +#endif DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, doc: /* Get significand and exponent of a floating point number. @@ -323,15 +168,9 @@ If X is zero, both parts (SGNFCAND and EXP) are zero. */) (Lisp_Object x) { double f = XFLOATINT (x); - - if (f == 0.0) - return Fcons (make_float (0.0), make_number (0)); - else - { - int exponent; - double sgnfcand = frexp (f, &exponent); - return Fcons (make_float (sgnfcand), make_number (exponent)); - } + int exponent; + double sgnfcand = frexp (f, &exponent); + return Fcons (make_float (sgnfcand), make_number (exponent)); } DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, @@ -343,138 +182,19 @@ Returns the floating point value resulting from multiplying SGNFCAND CHECK_NUMBER (exponent); return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent))); } -#endif - -#if 0 /* Leave these out unless we find there's a reason for them. */ - -DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, - doc: /* Return the bessel function j0 of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = j0 (d), "bessel-j0", arg); - return make_float (d); -} - -DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0, - doc: /* Return the bessel function j1 of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = j1 (d), "bessel-j1", arg); - return make_float (d); -} - -DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0, - doc: /* Return the order N bessel function output jn of ARG. -The first arg (the order) is truncated to an integer. */) - (register Lisp_Object n, Lisp_Object arg) -{ - int i1 = extract_float (n); - double f2 = extract_float (arg); - - IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", n); - return make_float (f2); -} - -DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0, - doc: /* Return the bessel function y0 of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = y0 (d), "bessel-y0", arg); - return make_float (d); -} - -DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0, - doc: /* Return the bessel function y1 of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = y1 (d), "bessel-y0", arg); - return make_float (d); -} - -DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0, - doc: /* Return the order N bessel function output yn of ARG. -The first arg (the order) is truncated to an integer. */) - (register Lisp_Object n, Lisp_Object arg) -{ - int i1 = extract_float (n); - double f2 = extract_float (arg); - - IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", n); - return make_float (f2); -} - -#endif - -#if 0 /* Leave these out unless we see they are worth having. */ - -DEFUN ("erf", Ferf, Serf, 1, 1, 0, - doc: /* Return the mathematical error function of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = erf (d), "erf", arg); - return make_float (d); -} - -DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, - doc: /* Return the complementary error function of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = erfc (d), "erfc", arg); - return make_float (d); -} - -DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, - doc: /* Return the log gamma of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); - IN_FLOAT (d = lgamma (d), "log-gamma", arg); - return make_float (d); -} - -DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, - doc: /* Return the cube root of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef HAVE_CBRT - IN_FLOAT (d = cbrt (d), "cube-root", arg); -#else - if (d >= 0.0) - IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg); - else - IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg); -#endif - return make_float (d); -} - -#endif DEFUN ("exp", Fexp, Sexp, 1, 1, 0, doc: /* Return the exponential base e of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d > 709.7827) /* Assume IEEE doubles here */ - range_error ("exp", arg); - else if (d < -709.0) - return make_float (0.0); - else -#endif - IN_FLOAT (d = exp (d), "exp", arg); + d = exp (d); return make_float (d); } DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, doc: /* Return the exponential ARG1 ** ARG2. */) - (register Lisp_Object arg1, Lisp_Object arg2) + (Lisp_Object arg1, Lisp_Object arg2) { double f1, f2, f3; @@ -503,159 +223,48 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, } f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1); f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2); - /* Really should check for overflow, too */ - if (f1 == 0.0 && f2 == 0.0) - f1 = 1.0; -#ifdef FLOAT_CHECK_DOMAIN - else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor (f2))) - domain_error2 ("expt", arg1, arg2); -#endif - IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2); - /* Check for overflow in the result. */ - if (f1 != 0.0 && f3 == 0.0) - range_error ("expt", arg1); + f3 = pow (f1, f2); return make_float (f3); } DEFUN ("log", Flog, Slog, 1, 2, 0, doc: /* Return the natural logarithm of ARG. If the optional argument BASE is given, return log ARG using that base. */) - (register Lisp_Object arg, Lisp_Object base) + (Lisp_Object arg, Lisp_Object base) { double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d <= 0.0) - domain_error2 ("log", arg, base); -#endif if (NILP (base)) - IN_FLOAT (d = log (d), "log", arg); + d = log (d); else { double b = extract_float (base); -#ifdef FLOAT_CHECK_DOMAIN - if (b <= 0.0 || b == 1.0) - domain_error2 ("log", arg, base); -#endif if (b == 10.0) - IN_FLOAT2 (d = log10 (d), "log", arg, base); + d = log10 (d); else - IN_FLOAT2 (d = log (d) / log (b), "log", arg, base); + d = log (d) / log (b); } return make_float (d); } DEFUN ("log10", Flog10, Slog10, 1, 1, 0, doc: /* Return the logarithm base 10 of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d <= 0.0) - domain_error ("log10", arg); -#endif - IN_FLOAT (d = log10 (d), "log10", arg); + d = log10 (d); return make_float (d); } DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, doc: /* Return the square root of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d < 0.0) - domain_error ("sqrt", arg); -#endif - IN_FLOAT (d = sqrt (d), "sqrt", arg); - return make_float (d); -} - -#if 0 /* Not clearly worth adding. */ - -DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, - doc: /* Return the inverse hyperbolic cosine of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d < 1.0) - domain_error ("acosh", arg); -#endif -#ifdef HAVE_INVERSE_HYPERBOLIC - IN_FLOAT (d = acosh (d), "acosh", arg); -#else - IN_FLOAT (d = log (d + sqrt (d*d - 1.0)), "acosh", arg); -#endif - return make_float (d); -} - -DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, - doc: /* Return the inverse hyperbolic sine of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef HAVE_INVERSE_HYPERBOLIC - IN_FLOAT (d = asinh (d), "asinh", arg); -#else - IN_FLOAT (d = log (d + sqrt (d*d + 1.0)), "asinh", arg); -#endif - return make_float (d); -} - -DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, - doc: /* Return the inverse hyperbolic tangent of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d >= 1.0 || d <= -1.0) - domain_error ("atanh", arg); -#endif -#ifdef HAVE_INVERSE_HYPERBOLIC - IN_FLOAT (d = atanh (d), "atanh", arg); -#else - IN_FLOAT (d = 0.5 * log ((1.0 + d) / (1.0 - d)), "atanh", arg); -#endif - return make_float (d); -} - -DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, - doc: /* Return the hyperbolic cosine of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d > 710.0 || d < -710.0) - range_error ("cosh", arg); -#endif - IN_FLOAT (d = cosh (d), "cosh", arg); - return make_float (d); -} - -DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, - doc: /* Return the hyperbolic sine of ARG. */) - (register Lisp_Object arg) -{ - double d = extract_float (arg); -#ifdef FLOAT_CHECK_DOMAIN - if (d > 710.0 || d < -710.0) - range_error ("sinh", arg); -#endif - IN_FLOAT (d = sinh (d), "sinh", arg); - return make_float (d); -} - -DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, - doc: /* Return the hyperbolic tangent of ARG. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = tanh (d), "tanh", arg); + d = sqrt (d); return make_float (d); } -#endif DEFUN ("abs", Fabs, Sabs, 1, 1, 0, doc: /* Return the absolute value of ARG. */) @@ -694,38 +303,15 @@ This is the same as the exponent of a float. */) if (f == 0.0) value = MOST_NEGATIVE_FIXNUM; - else + else if (isfinite (f)) { -#ifdef HAVE_LOGB - IN_FLOAT (value = logb (f), "logb", arg); -#else -#ifdef HAVE_FREXP int ivalue; - IN_FLOAT (frexp (f, &ivalue), "logb", arg); + frexp (f, &ivalue); value = ivalue - 1; -#else - int i; - double d; - if (f < 0.0) - f = -f; - value = -1; - while (f < 0.5) - { - for (i = 1, d = 0.5; d * d >= f; i += i) - d *= d; - f /= d; - value -= i; - } - while (f >= 1.0) - { - for (i = 1, d = 2.0; d * d <= f; i += i) - d *= d; - f /= d; - value += i; - } -#endif -#endif } + else + value = MOST_POSITIVE_FIXNUM; + XSETINT (val, value); return val; } @@ -756,8 +342,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor, if (! IEEE_FLOATING_POINT && f2 == 0) xsignal0 (Qarith_error); - IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor); - FLOAT_TO_INT2 (f1, arg, name, arg, divisor); + f1 = (*double_round) (f1 / f2); + if (FIXNUM_OVERFLOW_P (f1)) + xsignal3 (Qrange_error, build_string (name), arg, divisor); + arg = make_number (f1); return arg; } @@ -773,10 +361,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor, if (FLOATP (arg)) { - double d; - - IN_FLOAT (d = (*double_round) (XFLOAT_DATA (arg)), name, arg); - FLOAT_TO_INT (d, arg, name, arg); + double d = (*double_round) (XFLOAT_DATA (arg)); + if (FIXNUM_OVERFLOW_P (d)) + xsignal2 (Qrange_error, build_string (name), arg); + arg = make_number (d); } return arg; @@ -893,125 +481,57 @@ fmod_float (Lisp_Object x, Lisp_Object y) f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x); f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y); - if (! IEEE_FLOATING_POINT && f2 == 0) - xsignal0 (Qarith_error); + f1 = fmod (f1, f2); /* If the "remainder" comes out with the wrong sign, fix it. */ - IN_FLOAT2 ((f1 = fmod (f1, f2), - f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1), - "mod", x, y); + if (f2 < 0 ? 0 < f1 : f1 < 0) + f1 += f2; + return make_float (f1); } -/* It's not clear these are worth adding. */ - DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0, doc: /* Return the smallest integer no less than ARG, as a float. \(Round toward +inf.\) */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = ceil (d), "fceiling", arg); + d = ceil (d); return make_float (d); } DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0, doc: /* Return the largest integer no greater than ARG, as a float. \(Round towards -inf.\) */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = floor (d), "ffloor", arg); + d = floor (d); return make_float (d); } DEFUN ("fround", Ffround, Sfround, 1, 1, 0, doc: /* Return the nearest integer to ARG, as a float. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); - IN_FLOAT (d = emacs_rint (d), "fround", arg); + d = emacs_rint (d); return make_float (d); } DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, doc: /* Truncate a floating point number to an integral float value. Rounds the value toward zero. */) - (register Lisp_Object arg) + (Lisp_Object arg) { double d = extract_float (arg); if (d >= 0.0) - IN_FLOAT (d = floor (d), "ftruncate", arg); + d = floor (d); else - IN_FLOAT (d = ceil (d), "ftruncate", arg); + d = ceil (d); return make_float (d); } -#ifdef FLOAT_CATCH_SIGILL -static void -float_error (int signo) -{ - if (! in_float) - fatal_error_signal (signo); - -#ifdef BSD_SYSTEM - sigsetmask (SIGEMPTYMASK); -#else - /* Must reestablish handler each time it is called. */ - signal (SIGILL, float_error); -#endif /* BSD_SYSTEM */ - - SIGNAL_THREAD_CHECK (signo); - in_float = 0; - - xsignal1 (Qarith_error, float_error_arg); -} - -/* Another idea was to replace the library function `infnan' - where SIGILL is signaled. */ - -#endif /* FLOAT_CATCH_SIGILL */ - -#ifdef HAVE_MATHERR -int -matherr (struct exception *x) -{ - Lisp_Object args; - const char *name = x->name; - - if (! in_float) - /* Not called from emacs-lisp float routines; do the default thing. */ - return 0; - if (!strcmp (x->name, "pow")) - name = "expt"; - - args - = Fcons (build_string (name), - Fcons (make_float (x->arg1), - ((!strcmp (name, "log") || !strcmp (name, "pow")) - ? Fcons (make_float (x->arg2), Qnil) - : Qnil))); - switch (x->type) - { - case DOMAIN: xsignal (Qdomain_error, args); break; - case SING: xsignal (Qsingularity_error, args); break; - case OVERFLOW: xsignal (Qoverflow_error, args); break; - case UNDERFLOW: xsignal (Qunderflow_error, args); break; - default: xsignal (Qarith_error, args); break; - } - return (1); /* don't set errno or print a message */ -} -#endif /* HAVE_MATHERR */ - -void -init_floatfns (void) -{ -#ifdef FLOAT_CATCH_SIGILL - signal (SIGILL, float_error); -#endif - in_float = 0; -} - void syms_of_floatfns (void) { @@ -1024,27 +544,9 @@ syms_of_floatfns (void) defsubr (&Sisnan); #ifdef HAVE_COPYSIGN defsubr (&Scopysign); +#endif defsubr (&Sfrexp); defsubr (&Sldexp); -#endif -#if 0 - defsubr (&Sacosh); - defsubr (&Sasinh); - defsubr (&Satanh); - defsubr (&Scosh); - defsubr (&Ssinh); - defsubr (&Stanh); - defsubr (&Sbessel_y0); - defsubr (&Sbessel_y1); - defsubr (&Sbessel_yn); - defsubr (&Sbessel_j0); - defsubr (&Sbessel_j1); - defsubr (&Sbessel_jn); - defsubr (&Serf); - defsubr (&Serfc); - defsubr (&Slog_gamma); - defsubr (&Scube_root); -#endif defsubr (&Sfceiling); defsubr (&Sffloor); defsubr (&Sfround); diff --git a/src/fns.c b/src/fns.c index 2dee8515799..42c4f817f29 100644 --- a/src/fns.c +++ b/src/fns.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <time.h> -#include <setjmp.h> #include <intprops.h> @@ -51,11 +50,7 @@ static Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper; static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512; -static int internal_equal (Lisp_Object , Lisp_Object, int, int); - -#ifndef HAVE_UNISTD_H -extern long time (); -#endif +static bool internal_equal (Lisp_Object, Lisp_Object, int, bool); DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, doc: /* Return the argument unchanged. */) @@ -356,7 +351,7 @@ Symbols are also allowed; their print names are used instead. */) } static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, - enum Lisp_Type target_type, int last_special); + enum Lisp_Type target_type, bool last_special); /* ARGSUSED */ Lisp_Object @@ -454,19 +449,19 @@ struct textprop_rec static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, - enum Lisp_Type target_type, int last_special) + enum Lisp_Type target_type, bool last_special) { Lisp_Object val; - register Lisp_Object tail; - register Lisp_Object this; + Lisp_Object tail; + Lisp_Object this; ptrdiff_t toindex; ptrdiff_t toindex_byte = 0; - register EMACS_INT result_len; - register EMACS_INT result_len_byte; + EMACS_INT result_len; + EMACS_INT result_len_byte; ptrdiff_t argnum; Lisp_Object last_tail; Lisp_Object prev; - int some_multibyte; + bool some_multibyte; /* When we make a multibyte string, we can't copy text properties while concatenating each string because the length of resulting string can't be decided until we finish the whole concatenation. @@ -1531,11 +1526,14 @@ The value is actually the first element of LIST whose cdr equals KEY. */) } DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0, - doc: /* Delete by side effect any occurrences of ELT as a member of LIST. -The modified LIST is returned. Comparison is done with `eq'. -If the first member of LIST is ELT, there is no way to remove it by side effect; -therefore, write `(setq foo (delq element foo))' -to be sure of changing the value of `foo'. */) + doc: /* Delete members of LIST which are `eq' to ELT, and return the result. +More precisely, this function skips any members `eq' to ELT at the +front of LIST, then removes members `eq' to ELT from the remaining +sublist by modifying its list structure, then returns the resulting +list. + +Write `(setq foo (delq element foo))' to be sure of correctly changing +the value of a list `foo'. */) (register Lisp_Object elt, Lisp_Object list) { register Lisp_Object tail, prev; @@ -1563,13 +1561,19 @@ to be sure of changing the value of `foo'. */) } DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0, - doc: /* Delete by side effect any occurrences of ELT as a member of SEQ. -SEQ must be a list, a vector, or a string. -The modified SEQ is returned. Comparison is done with `equal'. -If SEQ is not a list, or the first member of SEQ is ELT, deleting it -is not a side effect; it is simply using a different sequence. -Therefore, write `(setq foo (delete element foo))' -to be sure of changing the value of `foo'. */) + doc: /* Delete members of SEQ which are `equal' to ELT, and return the result. +SEQ must be a sequence (i.e. a list, a vector, or a string). +The return value is a sequence of the same type. + +If SEQ is a list, this behaves like `delq', except that it compares +with `equal' instead of `eq'. In particular, it may remove elements +by altering the list structure. + +If SEQ is not a list, deletion is never performed destructively; +instead this function creates and returns a new vector or string. + +Write `(setq foo (delete element foo))' to be sure of correctly +changing the value of a sequence `foo'. */) (Lisp_Object elt, Lisp_Object seq) { if (VECTORP (seq)) @@ -1992,10 +1996,10 @@ of strings. (`equal' ignores text properties.) */) /* DEPTH is current depth of recursion. Signal an error if it gets too deep. - PROPS, if non-nil, means compare string text properties too. */ + PROPS means compare string text properties too. */ -static int -internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int props) +static bool +internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props) { if (depth > 200) error ("Stack overflow in equal"); @@ -2593,9 +2597,9 @@ Normally the return value is FEATURE. The normal messages at start and end of loading FILENAME are suppressed. */) (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror) { - register Lisp_Object tem; + Lisp_Object tem; struct gcpro gcpro1, gcpro2; - int from_file = load_in_progress; + bool from_file = load_in_progress; CHECK_SYMBOL (feature); @@ -2921,8 +2925,8 @@ static const short base64_char_to_value[128] = base64 characters. */ -static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, int, int); -static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, int, +static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, bool, bool); +static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, bool, ptrdiff_t *); DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, @@ -2957,7 +2961,7 @@ into shorter lines. */) encoded, length, NILP (no_line_break), !NILP (BVAR (current_buffer, enable_multibyte_characters))); if (encoded_length > allength) - abort (); + emacs_abort (); if (encoded_length < 0) { @@ -3013,7 +3017,7 @@ into shorter lines. */) encoded, length, NILP (no_line_break), STRING_MULTIBYTE (string)); if (encoded_length > allength) - abort (); + emacs_abort (); if (encoded_length < 0) { @@ -3030,7 +3034,7 @@ into shorter lines. */) static ptrdiff_t base64_encode_1 (const char *from, char *to, ptrdiff_t length, - int line_break, int multibyte) + bool line_break, bool multibyte) { int counter = 0; ptrdiff_t i = 0; @@ -3137,7 +3141,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ ptrdiff_t old_pos = PT; ptrdiff_t decoded_length; ptrdiff_t inserted_chars; - int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); USE_SAFE_ALLOCA; validate_region (&beg, &end); @@ -3158,7 +3162,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ decoded, length, multibyte, &inserted_chars); if (decoded_length > allength) - abort (); + emacs_abort (); if (decoded_length < 0) { @@ -3208,7 +3212,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, decoded_length = base64_decode_1 (SSDATA (string), decoded, length, 0, NULL); if (decoded_length > length) - abort (); + emacs_abort (); else if (decoded_length >= 0) decoded_string = make_unibyte_string (decoded, decoded_length); else @@ -3222,13 +3226,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, } /* Base64-decode the data at FROM of LENGTH bytes into TO. If - MULTIBYTE is nonzero, the decoded result should be in multibyte + MULTIBYTE, the decoded result should be in multibyte form. If NCHARS_RETURN is not NULL, store the number of produced characters in *NCHARS_RETURN. */ static ptrdiff_t base64_decode_1 (const char *from, char *to, ptrdiff_t length, - int multibyte, ptrdiff_t *nchars_return) + bool multibyte, ptrdiff_t *nchars_return) { ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */ char *e = to; @@ -3344,7 +3348,7 @@ static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value; static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *); static void maybe_resize_hash_table (struct Lisp_Hash_Table *); -static int sweep_weak_table (struct Lisp_Hash_Table *, int); +static bool sweep_weak_table (struct Lisp_Hash_Table *, bool); @@ -3436,10 +3440,10 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max) ***********************************************************************/ /* Compare KEY1 which has hash code HASH1 and KEY2 with hash code - HASH2 in hash table H using `eql'. Value is non-zero if KEY1 and + HASH2 in hash table H using `eql'. Value is true if KEY1 and KEY2 are the same. */ -static int +static bool cmpfn_eql (struct Lisp_Hash_Table *h, Lisp_Object key1, EMACS_UINT hash1, Lisp_Object key2, EMACS_UINT hash2) @@ -3451,10 +3455,10 @@ cmpfn_eql (struct Lisp_Hash_Table *h, /* Compare KEY1 which has hash code HASH1 and KEY2 with hash code - HASH2 in hash table H using `equal'. Value is non-zero if KEY1 and + HASH2 in hash table H using `equal'. Value is true if KEY1 and KEY2 are the same. */ -static int +static bool cmpfn_equal (struct Lisp_Hash_Table *h, Lisp_Object key1, EMACS_UINT hash1, Lisp_Object key2, EMACS_UINT hash2) @@ -3464,10 +3468,10 @@ cmpfn_equal (struct Lisp_Hash_Table *h, /* Compare KEY1 which has hash code HASH1, and KEY2 with hash code - HASH2 in hash table H using H->user_cmp_function. Value is non-zero + HASH2 in hash table H using H->user_cmp_function. Value is true if KEY1 and KEY2 are the same. */ -static int +static bool cmpfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key1, EMACS_UINT hash1, Lisp_Object key2, EMACS_UINT hash2) @@ -3675,7 +3679,7 @@ copy_hash_table (struct Lisp_Hash_Table *h1) h2 = allocate_hash_table (); next = h2->header.next.vector; - memcpy (h2, h1, sizeof *h2); + *h2 = *h1; h2->header.next.vector = next; h2->key_and_value = Fcopy_sequence (h1->key_and_value); h2->hash = Fcopy_sequence (h1->hash); @@ -3927,16 +3931,16 @@ hash_clear (struct Lisp_Hash_Table *h) Weak Hash Tables ************************************************************************/ -/* Sweep weak hash table H. REMOVE_ENTRIES_P non-zero means remove +/* Sweep weak hash table H. REMOVE_ENTRIES_P means remove entries from the table that don't survive the current GC. - REMOVE_ENTRIES_P zero means mark entries that are in use. Value is - non-zero if anything was marked. */ + !REMOVE_ENTRIES_P means mark entries that are in use. Value is + true if anything was marked. */ -static int -sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) +static bool +sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p) { ptrdiff_t bucket, n; - int marked; + bool marked; n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; marked = 0; @@ -3953,7 +3957,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) ptrdiff_t i = XFASTINT (idx); bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); - int remove_p; + bool remove_p; if (EQ (h->weak, Qkey)) remove_p = !key_known_to_survive_p; @@ -3964,7 +3968,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) else if (EQ (h->weak, Qkey_and_value)) remove_p = !(key_known_to_survive_p && value_known_to_survive_p); else - abort (); + emacs_abort (); next = HASH_NEXT (h, i); @@ -4026,7 +4030,7 @@ void sweep_weak_hash_tables (void) { struct Lisp_Hash_Table *h, *used, *next; - int marked; + bool marked; /* Mark all keys and values that are in use. Keep on marking until there is no more change. This is necessary for cases like @@ -4260,7 +4264,7 @@ sxhash (Lisp_Object obj, int depth) break; default: - abort (); + emacs_abort (); } return hash; @@ -4678,7 +4682,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_ coding_system = Vcoding_system_for_write; else { - int force_raw_text = 0; + bool force_raw_text = 0; coding_system = BVAR (XBUFFER (object), buffer_file_coding_system); if (NILP (coding_system) diff --git a/src/font.c b/src/font.c index c775b56caa9..629e8bb977a 100644 --- a/src/font.c +++ b/src/font.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <float.h> #include <stdio.h> -#include <setjmp.h> #include <c-ctype.h> @@ -216,13 +215,12 @@ static int num_font_drivers; /* Return a Lispy value of a font property value at STR and LEN bytes. - If STR is "*", return nil. - If FORCE_SYMBOL is zero and all characters in STR are digits, - return an integer. Otherwise, return a symbol interned from - STR. */ + If STR is "*", return nil. If FORCE_SYMBOL, or if STR does not + consist entirely of one or more digits, return a symbol interned + from STR. Otherwise, return an integer. */ Lisp_Object -font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) +font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol) { ptrdiff_t i; Lisp_Object tem; @@ -306,7 +304,8 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec) VAL is an integer. */ int -font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror) +font_style_to_value (enum font_property_index prop, Lisp_Object val, + bool noerror) { Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); int len; @@ -385,7 +384,8 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror } Lisp_Object -font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face) +font_style_symbolic (Lisp_Object font, enum font_property_index prop, + bool for_face) { Lisp_Object val = AREF (font, prop); Lisp_Object table, elt; @@ -1101,7 +1101,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font) } else { - int wild_card_found = 0; + bool wild_card_found = 0; Lisp_Object prop[XLFD_LAST_INDEX]; if (FONT_ENTITY_P (font)) @@ -1337,7 +1337,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font) } else if (*p == '-') { - int decimal = 0, size_found = 1; + bool decimal = 0, size_found = 1; for (q = p + 1; *q && *q != ':'; q++) if (! c_isdigit (*q)) { @@ -1938,7 +1938,7 @@ generate_otf_features (Lisp_Object spec, char *features) { Lisp_Object val; char *p; - int asterisk; + bool asterisk; p = features; *p = '\0'; @@ -2302,11 +2302,12 @@ font_update_sort_order (int *order) } } -static int -font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table) +static bool +font_check_otf_features (Lisp_Object script, Lisp_Object langsys, + Lisp_Object features, Lisp_Object table) { Lisp_Object val; - int negative; + bool negative; table = assq_no_quit (script, table); if (NILP (table)) @@ -2342,7 +2343,7 @@ font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object fe /* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */ -static int +static bool font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) { Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil; @@ -2376,7 +2377,7 @@ font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) /* Check if FONT (font-entity or font-object) matches with the font specification SPEC. */ -int +bool font_match_p (Lisp_Object spec, Lisp_Object font) { Lisp_Object prop[FONT_SPEC_MAX], *props; @@ -2694,7 +2695,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec) Lisp_Object ftype, val; Lisp_Object list = Qnil; int size; - int need_filtering = 0; + bool need_filtering = 0; int i; eassert (FONT_SPEC_P (spec)); @@ -3036,15 +3037,14 @@ font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs, { Lisp_Object font_entity; Lisp_Object prefer; - int result, i; + int i; FRAME_PTR f = XFRAME (frame); if (NILP (XCDR (entities)) && ASIZE (XCAR (entities)) == 1) { font_entity = AREF (XCAR (entities), 0); - if (c < 0 - || (result = font_has_char (f, font_entity, c)) > 0) + if (c < 0 || font_has_char (f, font_entity, c) > 0) return font_entity; return Qnil; } @@ -3618,7 +3618,7 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w, Lisp_Object string) { FRAME_PTR f; - int multibyte; + bool multibyte; Lisp_Object font_object; multibyte = (NILP (string) @@ -4295,12 +4295,15 @@ to get the correct visual image of character sequences set in the header of the glyph-string. If the shaping was successful, the value is GSTRING itself or a newly -created glyph-string. Otherwise, the value is nil. */) +created glyph-string. Otherwise, the value is nil. + +See the documentation of `composition-get-gstring' for the format of +GSTRING. */) (Lisp_Object gstring) { struct font *font; Lisp_Object font_object, n, glyph; - ptrdiff_t i, j, from, to; + ptrdiff_t i, from, to; if (! composition_gstring_p (gstring)) signal_error ("Invalid glyph-string: ", gstring); @@ -4326,44 +4329,42 @@ created glyph-string. Otherwise, the value is nil. */) if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); + /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that + GLYPHS covers all characters (except for the last few ones) in + GSTRING. More formally, provided that NCHARS is the number of + characters in GSTRING and GLYPHS[i] is the ith glyph, FROM_IDX + and TO_IDX of each glyph must satisfy these conditions: + + GLYPHS[0].FROM_IDX == 0 + GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX + if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX) + ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster + GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX + else + ;; Be sure to cover all characters. + GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1 */ glyph = LGSTRING_GLYPH (gstring, 0); from = LGLYPH_FROM (glyph); to = LGLYPH_TO (glyph); - for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++) + if (from != 0 || to < from) + goto shaper_error; + for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++) { - Lisp_Object this = LGSTRING_GLYPH (gstring, i); - - if (NILP (this)) + glyph = LGSTRING_GLYPH (gstring, i); + if (NILP (glyph)) break; - if (NILP (LGLYPH_ADJUSTMENT (this))) - { - if (j < i - 1) - for (; j < i; j++) - { - glyph = LGSTRING_GLYPH (gstring, j); - LGLYPH_SET_FROM (glyph, from); - LGLYPH_SET_TO (glyph, to); - } - from = LGLYPH_FROM (this); - to = LGLYPH_TO (this); - j = i; - } - else - { - if (from > LGLYPH_FROM (this)) - from = LGLYPH_FROM (this); - if (to < LGLYPH_TO (this)) - to = LGLYPH_TO (this); - } + if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph) + && (LGLYPH_FROM (glyph) == from + ? LGLYPH_TO (glyph) == to + : LGLYPH_FROM (glyph) == to + 1))) + goto shaper_error; + from = LGLYPH_FROM (glyph); + to = LGLYPH_TO (glyph); } - if (j < i - 1) - for (; j < i; j++) - { - glyph = LGSTRING_GLYPH (gstring, j); - LGLYPH_SET_FROM (glyph, from); - LGLYPH_SET_TO (glyph, to); - } return composition_gstring_put_cache (gstring, XINT (n)); + + shaper_error: + return Qnil; } DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, diff --git a/src/font.h b/src/font.h index 5ed9affa9ef..71cb26ccfdc 100644 --- a/src/font.h +++ b/src/font.h @@ -320,19 +320,10 @@ struct font negative if that information is not in the font. */ int underline_position; - /* 1 if `vertical-centering-font-regexp' matches this font name. + /* True if `vertical-centering-font-regexp' matches this font name. In this case, we render characters at vertical center positions of lines. */ - int vertical_centering; - - /* Encoding type of the font. The value is one of - 0, 1, 2, or 3: - 0: code points 0x20..0x7F or 0x2020..0x7F7F are used - 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used - 2: code points 0x20A0..0x7FFF are used - 3: code points 0xA020..0xFF7F are used - If the member `font_encoder' is not NULL, this member is ignored. */ - unsigned char encoding_type; + bool vertical_centering; /* The baseline position of a font is normally `ascent' value of the font. However, there exist many fonts which don't set `ascent' to @@ -506,9 +497,9 @@ struct font_driver /* Symbol indicating the type of the font-driver. */ Lisp_Object type; - /* 1 iff the font's foundry, family, and adstyle names are case + /* True iff the font's foundry, family, and adstyle names are case sensitive. */ - int case_sensitive; + bool case_sensitive; /* Return a cache of font-entities on frame F. The cache must be a cons whose cdr part is the actual cache area. */ @@ -592,11 +583,11 @@ struct font_driver /* Optional. Draw glyphs between FROM and TO of S->char2b at (X Y) pixel - position of frame F with S->FACE and S->GC. If WITH_BACKGROUND - is nonzero, fill the background in advance. It is assured that - WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ + position of frame F with S->FACE and S->GC. If WITH_BACKGROUND, + fill the background in advance. It is assured that WITH_BACKGROUND + is false when (FROM > 0 || TO < S->nchars). */ int (*draw) (struct glyph_string *s, int from, int to, - int x, int y, int with_background); + int x, int y, bool with_background); /* Optional. Store bitmap data for glyph-code CODE of FONT in BITMAP. It is @@ -648,7 +639,7 @@ struct font_driver short, return -1. */ int (*otf_drive) (struct font *font, Lisp_Object features, Lisp_Object gstring_in, int from, int to, - Lisp_Object gstring_out, int idx, int alternate_subst); + Lisp_Object gstring_out, int idx, bool alternate_subst); /* Optional. Make the font driver ready for frame F. Usually this function @@ -699,9 +690,9 @@ struct font_driver Return non-zero if FONT_OBJECT can be used as a (cached) font for ENTITY on frame F. */ - int (*cached_font_ok) (struct frame *f, - Lisp_Object font_object, - Lisp_Object entity); + bool (*cached_font_ok) (struct frame *f, + Lisp_Object font_object, + Lisp_Object entity); }; @@ -711,9 +702,9 @@ struct font_driver struct font_driver_list { - /* 1 iff this driver is currently used. It is ignored in the global + /* True iff this driver is currently used. It is ignored in the global font driver list.*/ - int on; + bool on; /* Pointer to the font driver. */ struct font_driver *driver; /* Pointer to the next element of the chain. */ @@ -744,12 +735,12 @@ extern Lisp_Object find_font_encoding (Lisp_Object); extern int font_registry_charsets (Lisp_Object, struct charset **, struct charset **); extern int font_style_to_value (enum font_property_index prop, - Lisp_Object name, int noerror); + Lisp_Object name, bool noerror); extern Lisp_Object font_style_symbolic (Lisp_Object font, enum font_property_index prop, - int for_face); + bool for_face); -extern int font_match_p (Lisp_Object spec, Lisp_Object font); +extern bool font_match_p (Lisp_Object spec, Lisp_Object font); extern Lisp_Object font_list_entities (Lisp_Object frame, Lisp_Object spec); @@ -774,7 +765,7 @@ extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec); extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name); extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len, - int force_symbol); + bool force_symbol); extern void font_update_sort_order (int *order); extern void font_parse_family_registry (Lisp_Object family, @@ -817,6 +808,7 @@ extern struct font_driver xfont_driver; extern void syms_of_xfont (void); extern void syms_of_ftxfont (void); #ifdef HAVE_XFT +extern Lisp_Object Qxft; extern struct font_driver xftfont_driver; extern void syms_of_xftfont (void); #elif defined HAVE_FREETYPE diff --git a/src/fontset.c b/src/fontset.c index 783f99c210c..7295951bc21 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "blockinput.h" @@ -185,21 +184,12 @@ void (*check_window_system_func) (void); /* Prototype declarations for static functions. */ -static void fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); -static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *, - int, int); -static void reorder_font_vector (Lisp_Object, struct font *); -static Lisp_Object fontset_font (Lisp_Object, int, struct face *, int); static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object); -static Lisp_Object fontset_pattern_regexp (Lisp_Object); -static void accumulate_script_ranges (Lisp_Object, Lisp_Object, - Lisp_Object); -static void set_fontset_font (Lisp_Object, Lisp_Object); -/* Return 1 if ID is a valid fontset id, else return 0. +/* Return true if ID is a valid fontset id. Optimized away if ENABLE_CHECKING is not defined. */ -static int +static bool fontset_id_valid_p (int id) { return (id >= 0 && id < ASIZE (Vfontset_table) - 1); @@ -413,7 +403,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) Lisp_Object vec, font_object; int size; int i; - int score_changed = 0; + bool score_changed = 0; if (font) XSETFONT (font_object, font); @@ -544,10 +534,11 @@ fontset_get_font_group (Lisp_Object fontset, int c) ID is a charset-id that must be preferred, or -1 meaning no preference. - If FALLBACK is nonzero, search only fallback fonts. */ + If FALLBACK, search only fallback fonts. */ static Lisp_Object -fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback) +fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, + bool fallback) { Lisp_Object vec, font_group; int i, charset_matched = 0, found_index; @@ -919,11 +910,11 @@ free_face_fontset (FRAME_PTR f, struct face *face) #if 0 -/* Return 1 if FACE is suitable for displaying character C. - Otherwise return 0. Called from the macro FACE_SUITABLE_FOR_CHAR_P +/* Return true if FACE is suitable for displaying character C. + Called from the macro FACE_SUITABLE_FOR_CHAR_P when C is not an ASCII character. */ -int +bool face_suitable_for_char_p (struct face *face, int c) { Lisp_Object fontset, rfont_def; @@ -1470,7 +1461,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */) Lisp_Object range_list; struct charset *charset = NULL; Lisp_Object fontname; - int ascii_changed = 0; + bool ascii_changed = 0; fontset = check_fontset_name (name, &frame); diff --git a/src/frame.c b/src/frame.c index aa1508e6d28..73e46eff00f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <errno.h> #include <limits.h> -#include <setjmp.h> #include <c-ctype.h> @@ -214,7 +213,7 @@ See also `frame-live-p'. */) case output_ns: return Qns; default: - abort (); + emacs_abort (); } } @@ -620,7 +619,7 @@ affects all frames on the same terminal device. */) #ifdef MSDOS if (sf->output_method != output_msdos_raw && sf->output_method != output_termcap) - abort (); + emacs_abort (); #else /* not MSDOS */ #ifdef WINDOWSNT /* This should work now! */ @@ -767,7 +766,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor Lisp_Object focus; if (!FRAMEP (XCAR (tail))) - abort (); + emacs_abort (); focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); @@ -897,7 +896,7 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf) /* There must always be at least one frame in Vframe_list. */ if (! CONSP (Vframe_list)) - abort (); + emacs_abort (); /* If this frame is dead, it won't be in Vframe_list, and we'll loop forever. Forestall that. */ @@ -975,7 +974,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf) /* There must always be at least one frame in Vframe_list. */ if (! CONSP (Vframe_list)) - abort (); + emacs_abort (); prev = Qnil; for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) @@ -984,7 +983,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf) f = XCAR (tail); if (!FRAMEP (f)) - abort (); + emacs_abort (); if (EQ (frame, f) && !NILP (prev)) return prev; @@ -1299,6 +1298,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force) structures can still refer to it. */ fset_menu_bar_vector (f, Qnil); + /* If FRAME's buffer lists contains killed + buffers, this helps GC to reclaim them. */ + fset_buffer_list (f, Qnil); + fset_buried_buffer_list (f, Qnil); + free_font_driver_list (f); xfree (f->namebuf); xfree (f->decode_mode_spec_buffer); @@ -1385,7 +1389,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) this = XCAR (frames); if (!FRAMEP (this)) - abort (); + emacs_abort (); f1 = XFRAME (this); if (kb == FRAME_KBOARD (f1)) @@ -1421,7 +1425,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) this = XCAR (frames); if (!FRAMEP (this)) - abort (); + emacs_abort (); f1 = XFRAME (this); /* Consider only frames on the same kboard @@ -1447,7 +1451,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) that is prohibited at the top; you can't delete surrogate minibuffer frames. */ if (NILP (frame_with_minibuf)) - abort (); + emacs_abort (); kset_default_minibuffer_frame (kb, frame_with_minibuf); } @@ -2108,7 +2112,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) swap_in_global_binding (sym); break; } - default: abort (); + default: emacs_abort (); } } @@ -3835,7 +3839,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, } default: - abort (); + emacs_abort (); } } else diff --git a/src/frame.h b/src/frame.h index 2e0bcee432c..1184545d2e6 100644 --- a/src/frame.h +++ b/src/frame.h @@ -81,9 +81,6 @@ enum fullscreen_type #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) -struct terminal; - -struct font_driver_list; struct frame { @@ -981,7 +978,7 @@ extern Lisp_Object selected_frame; ((FRAMEP (selected_frame) \ && FRAME_LIVE_P (XFRAME (selected_frame))) \ ? XFRAME (selected_frame) \ - : (abort (), (struct frame *) 0)) + : (emacs_abort (), (struct frame *) 0)) /*********************************************************************** diff --git a/src/fringe.c b/src/fringe.c index 97d03a2bfae..6e6deeddb08 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -18,7 +18,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "frame.h" @@ -659,7 +658,14 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o { /* If W has a vertical border to its left, don't draw over it. */ wd -= ((!WINDOW_LEFTMOST_P (w) - && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) + && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) + /* But don't reduce the fringe width if the window + has a left margin, because that means we are not + in danger of drawing over the vertical border, + and OTOH leaving out that one pixel leaves behind + traces of the cursor, if it was in column zero + before drawing non-empty margin area. */ + && NILP (w->left_margin_cols)) ? 1 : 0); p.bx = x - wd; p.nx = wd; diff --git a/src/ftfont.c b/src/ftfont.c index e16f967f596..f07ad6f33c7 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -21,8 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> - #include <fontconfig/fontconfig.h> #include <fontconfig/fcfreetype.h> @@ -45,7 +43,7 @@ static Lisp_Object Qfreetype; static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; /* Flag to tell if FcInit is already called or not. */ -static int fc_initialized; +static bool fc_initialized; /* Handle to a FreeType library instance. */ static FT_Library ft_library; @@ -65,7 +63,7 @@ struct ftfont_info #ifdef HAVE_LIBOTF /* The following four members must be here in this order to be compatible with struct xftfont_info (in xftfont.c). */ - int maybe_otf; /* Flag to tell if this may be OTF or not. */ + bool maybe_otf; /* Flag to tell if this may be OTF or not. */ OTF *otf; #endif /* HAVE_LIBOTF */ FT_Size ft_size; @@ -543,9 +541,9 @@ struct font_driver ftfont_driver = /* We can't draw a text without device dependent functions. */ NULL, /* draw */ ftfont_get_bitmap, - NULL, /* get_bitmap */ NULL, /* free_bitmap */ NULL, /* get_outline */ + NULL, /* free_outline */ ftfont_anchor_point, #ifdef HAVE_LIBOTF ftfont_otf_capability, @@ -661,7 +659,8 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) { struct OpenTypeSpec *spec = malloc (sizeof *spec); Lisp_Object val; - int i, j, negative; + int i, j; + bool negative; if (! spec) return NULL; @@ -1185,7 +1184,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) FT_Size ft_size; FT_UInt size; Lisp_Object val, filename, idx, cache, font_object; - int scalable; + bool scalable; int spacing; char name[256]; int i, len; @@ -1243,7 +1242,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) ftfont_info->ft_size = ft_face->size; ftfont_info->index = XINT (idx); #ifdef HAVE_LIBOTF - ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; + ftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0; ftfont_info->otf = NULL; #endif /* HAVE_LIBOTF */ /* This means that there's no need of transformation. */ @@ -1392,7 +1391,8 @@ ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; int width = 0; - int i, first; + int i; + bool first; if (ftfont_info->ft_size != ft_face->size) FT_Activate_Size (ftfont_info->ft_size); @@ -1630,7 +1630,7 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring, FT_Glyph_Metrics *m; if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) - abort (); + emacs_abort (); m = &ft_face->glyph->metrics; if (flt_font_ft->matrix) { @@ -1682,10 +1682,12 @@ ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec) struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; OTF *otf = flt_font_ft->otf; OTF_Tag *tags; - int i, n, negative; + int i, n; + bool negative; if (FEATURE_ANY (0) && FEATURE_ANY (1)) - /* Return 1 iff any of GSUB or GPOS support the script (and language). */ + /* Return true iff any of GSUB or GPOS support the script (and + language). */ return (otf && (OTF_check_features (otf, 0, spec->script, spec->langsys, NULL, 0) > 0 @@ -2390,7 +2392,7 @@ ftfont_drive_otf (MFLTFont *font, MFLTOtfSpec *spec, MFLTGlyphString *in, static MFLTGlyphString gstring; -static int m17n_flt_initialized; +static bool m17n_flt_initialized; static Lisp_Object ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, @@ -2400,7 +2402,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, ptrdiff_t i; struct MFLTFontFT flt_font_ft; MFLT *flt = NULL; - int with_variation_selector = 0; + bool with_variation_selector = 0; if (! m17n_flt_initialized) { @@ -2421,7 +2423,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, break; c = LGLYPH_CHAR (g); if (CHAR_VARIATION_SELECTOR_P (c)) - with_variation_selector++; + with_variation_selector = 1; } len = i; diff --git a/src/ftxfont.c b/src/ftxfont.c index 6ebe0798b4e..466250bd43f 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <X11/Xlib.h> #include "lisp.h" @@ -43,14 +42,6 @@ static #endif struct font_driver ftxfont_driver; -/* Prototypes for helper function. */ -static GC *ftxfont_get_gcs (FRAME_PTR, unsigned long, unsigned long); -static int ftxfont_draw_bitmap (FRAME_PTR, GC, GC *, struct font *, - unsigned, int, int, XPoint *, int, int *, - int); -static void ftxfont_draw_background (FRAME_PTR, struct font *, GC, - int, int, int); - struct ftxfont_frame_data { /* Background and foreground colors. */ @@ -143,7 +134,9 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba } static int -ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font, unsigned int code, int x, int y, XPoint *p, int size, int *n, int flush) +ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font, + unsigned int code, int x, int y, XPoint *p, int size, + int *n, bool flush) { struct font_bitmap bitmap; unsigned char *b; @@ -232,13 +225,6 @@ ftxfont_draw_background (FRAME_PTR f, struct font *font, GC gc, int x, int y, XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground); } -/* Prototypes for font-driver methods. */ -static Lisp_Object ftxfont_list (Lisp_Object, Lisp_Object); -static Lisp_Object ftxfont_match (Lisp_Object, Lisp_Object); -static Lisp_Object ftxfont_open (FRAME_PTR, Lisp_Object, int); -static void ftxfont_close (FRAME_PTR, struct font *); -static int ftxfont_draw (struct glyph_string *, int, int, int, int, int); - static Lisp_Object ftxfont_list (Lisp_Object frame, Lisp_Object spec) { @@ -280,7 +266,8 @@ ftxfont_close (FRAME_PTR f, struct font *font) } static int -ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) +ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, + bool with_background) { FRAME_PTR f = s->f; struct face *face = s->face; diff --git a/src/gnutls.c b/src/gnutls.c index a2573f6bd99..1c4693aee32 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -18,7 +18,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <errno.h> -#include <setjmp.h> #include "lisp.h" #include "process.h" diff --git a/src/gtkutil.c b/src/gtkutil.c index 939e472d6d2..1eb4b2cabdf 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -21,9 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef USE_GTK #include <float.h> -#include <signal.h> #include <stdio.h> -#include <setjmp.h> #include <c-ctype.h> @@ -254,7 +252,7 @@ void free_widget_value (widget_value *wv) { if (wv->free_list) - abort (); + emacs_abort (); if (malloc_cpt > 25) { @@ -1979,7 +1977,10 @@ xg_get_file_name (FRAME_PTR f, /* I really don't know why this is needed, but without this the GLIBC add on library linuxthreads hangs when the Gnome file chooser backend creates threads. */ - sigblock (sigmask (__SIGRTMIN)); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, __SIGRTMIN); + pthread_sigmask (SIG_BLOCK, &blocked, 0); #endif /* HAVE_PTHREAD */ #ifdef HAVE_GTK_FILE_SELECTION_NEW @@ -2001,7 +2002,7 @@ xg_get_file_name (FRAME_PTR f, filesel_done = xg_dialog_run (f, w); #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) - sigunblock (sigmask (__SIGRTMIN)); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif if (filesel_done == GTK_RESPONSE_OK) @@ -2019,11 +2020,6 @@ xg_get_file_name (FRAME_PTR f, #if USE_NEW_GTK_FONT_CHOOSER -extern Lisp_Object Qxft, Qnormal; -extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold; -extern Lisp_Object Qbold, Qextra_bold, Qultra_bold; -extern Lisp_Object Qoblique, Qitalic; - #define XG_WEIGHT_TO_SYMBOL(w) \ (w <= PANGO_WEIGHT_THIN ? Qextra_light \ : w <= PANGO_WEIGHT_ULTRALIGHT ? Qlight \ @@ -2043,6 +2039,7 @@ extern Lisp_Object Qoblique, Qitalic; static char *x_last_font_name; +extern Lisp_Object Qxft; /* Pop up a GTK font selector and return the name of the font the user selects, as a C string. The returned font name follows GTK's own @@ -2061,7 +2058,10 @@ xg_get_font (FRAME_PTR f, const char *default_name) Lisp_Object font = Qnil; #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) - sigblock (sigmask (__SIGRTMIN)); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, __SIGRTMIN); + pthread_sigmask (SIG_BLOCK, &blocked, 0); #endif /* HAVE_PTHREAD */ w = gtk_font_chooser_dialog_new @@ -2090,7 +2090,7 @@ xg_get_font (FRAME_PTR f, const char *default_name) done = xg_dialog_run (f, w); #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) - sigunblock (sigmask (__SIGRTMIN)); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif if (done == GTK_RESPONSE_OK) @@ -3523,7 +3523,7 @@ xg_store_widget_in_map (GtkWidget *w) } /* Should never end up here */ - abort (); + emacs_abort (); } /* Remove pointer at IDX from id_to_widget. @@ -4091,7 +4091,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data) else { fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n"); - abort (); + emacs_abort (); } } else if (store_type == GTK_IMAGE_ICON_NAME) @@ -4106,7 +4106,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data) else { fprintf (stderr, "internal error: store_type is %d\n", store_type); - abort (); + emacs_abort (); } } if (wmenuimage) diff --git a/src/image.c b/src/image.c index b5a2e0328eb..a562868d94d 100644 --- a/src/image.c +++ b/src/image.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <math.h> #include <unistd.h> #ifdef HAVE_PNG @@ -575,7 +574,6 @@ static int x_build_heuristic_mask (struct frame *, struct image *, Lisp_Object); #ifdef WINDOWSNT extern Lisp_Object Vlibrary_cache; - #define CACHE_IMAGE_TYPE(type, status) \ do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) #else @@ -600,7 +598,7 @@ define_image_type (struct image_type *type, int loaded) /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. The initialized data segment is read-only. */ struct image_type *p = xmalloc (sizeof *p); - memcpy (p, type, sizeof *p); + *p = *type; p->next = image_types; image_types = p; success = Qt; @@ -847,7 +845,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, break; default: - abort (); + emacs_abort (); break; } @@ -5528,15 +5526,24 @@ init_png_functions (Lisp_Object libraries) #endif /* WINDOWSNT */ +/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp. + Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp + substitute may munge the signal mask, but that should be OK here. + MinGW (MS-Windows) uses _setjmp and defines setjmp to _setjmp in + the system header setjmp.h; don't mess up that. */ +#ifndef HAVE__SETJMP +# define _setjmp(j) setjmp (j) +# define _longjmp longjmp +#endif #if (PNG_LIBPNG_VER < 10500) -#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) +#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1)) #define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) #else /* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ #define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) #define PNG_JMPBUF(ptr) \ - (*fn_png_set_longjmp_fn ((ptr), longjmp, sizeof (jmp_buf))) + (*fn_png_set_longjmp_fn ((ptr), _longjmp, sizeof (jmp_buf))) #endif /* Error and warning handlers installed when the PNG library @@ -5605,20 +5612,31 @@ png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) /* Load PNG image IMG for use on frame F. Value is non-zero if successful. */ +struct png_load_context +{ + /* These are members so that longjmp doesn't munge local variables. */ + png_struct *png_ptr; + png_info *info_ptr; + png_info *end_info; + FILE *fp; + png_byte *pixels; + png_byte **rows; +}; + static int -png_load (struct frame *f, struct image *img) +png_load_body (struct frame *f, struct image *img, struct png_load_context *c) { Lisp_Object file, specified_file; Lisp_Object specified_data; int x, y; ptrdiff_t i; XImagePtr ximg, mask_img = NULL; - png_struct *png_ptr = NULL; + png_struct *png_ptr; png_info *info_ptr = NULL, *end_info = NULL; - FILE *volatile fp = NULL; + FILE *fp = NULL; png_byte sig[8]; - png_byte * volatile pixels = NULL; - png_byte ** volatile rows = NULL; + png_byte *pixels = NULL; + png_byte **rows = NULL; png_uint_32 width, height; int bit_depth, color_type, interlace_type; png_byte channels; @@ -5685,41 +5703,47 @@ png_load (struct frame *f, struct image *img) png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, my_png_error, my_png_warning); - if (!png_ptr) + if (png_ptr) { - if (fp) fclose (fp); - return 0; + info_ptr = fn_png_create_info_struct (png_ptr); + end_info = fn_png_create_info_struct (png_ptr); } - info_ptr = fn_png_create_info_struct (png_ptr); - if (!info_ptr) + c->png_ptr = png_ptr; + c->info_ptr = info_ptr; + c->end_info = end_info; + c->fp = fp; + c->pixels = pixels; + c->rows = rows; + + if (! (info_ptr && end_info)) { - fn_png_destroy_read_struct (&png_ptr, NULL, NULL); - if (fp) fclose (fp); - return 0; + fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); + png_ptr = 0; } - - end_info = fn_png_create_info_struct (png_ptr); - if (!end_info) + if (! png_ptr) { - fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); if (fp) fclose (fp); return 0; } /* Set error jump-back. We come back here when the PNG library detects an error. */ - if (setjmp (PNG_JMPBUF (png_ptr))) + if (_setjmp (PNG_JMPBUF (png_ptr))) { error: - if (png_ptr) - fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); - xfree (pixels); - xfree (rows); - if (fp) fclose (fp); + if (c->png_ptr) + fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); + xfree (c->pixels); + xfree (c->rows); + if (c->fp) + fclose (c->fp); return 0; } + /* Silence a bogus diagnostic; see GCC bug 54561. */ + IF_LINT (fp = c->fp); + /* Read image info. */ if (!NILP (specified_data)) fn_png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory); @@ -5835,8 +5859,8 @@ png_load (struct frame *f, struct image *img) if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes) memory_full (SIZE_MAX); - pixels = xmalloc (sizeof *pixels * row_bytes * height); - rows = xmalloc (height * sizeof *rows); + c->pixels = pixels = xmalloc (sizeof *pixels * row_bytes * height); + c->rows = rows = xmalloc (height * sizeof *rows); for (i = 0; i < height; ++i) rows[i] = pixels + i * row_bytes; @@ -5846,7 +5870,7 @@ png_load (struct frame *f, struct image *img) if (fp) { fclose (fp); - fp = NULL; + c->fp = NULL; } /* Create an image and pixmap serving as mask if the PNG image @@ -5921,7 +5945,7 @@ png_load (struct frame *f, struct image *img) #endif /* COLOR_TABLE_SUPPORT */ /* Clean up. */ - fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); + fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); xfree (rows); xfree (pixels); @@ -5950,6 +5974,13 @@ png_load (struct frame *f, struct image *img) return 1; } +static int +png_load (struct frame *f, struct image *img) +{ + struct png_load_context c; + return png_load_body (f, img, &c); +} + #else /* HAVE_PNG */ #ifdef HAVE_NS @@ -6125,7 +6156,20 @@ jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) struct my_jpeg_error_mgr { struct jpeg_error_mgr pub; - jmp_buf setjmp_buffer; + sys_jmp_buf setjmp_buffer; + + /* The remaining members are so that longjmp doesn't munge local + variables. */ + struct jpeg_decompress_struct cinfo; + enum + { + MY_JPEG_ERROR_EXIT, + MY_JPEG_INVALID_IMAGE_SIZE, + MY_JPEG_CANNOT_CREATE_X + } failure_code; +#ifdef lint + FILE *fp; +#endif }; @@ -6133,7 +6177,8 @@ static _Noreturn void my_error_exit (j_common_ptr cinfo) { struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; - longjmp (mgr->setjmp_buffer, 1); + mgr->failure_code = MY_JPEG_ERROR_EXIT; + sys_longjmp (mgr->setjmp_buffer, 1); } @@ -6201,7 +6246,7 @@ our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes) reading the image. */ static void -jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) +jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len) { struct jpeg_source_mgr *src; @@ -6339,17 +6384,15 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp) from the JPEG lib. */ static int -jpeg_load (struct frame *f, struct image *img) +jpeg_load_body (struct frame *f, struct image *img, + struct my_jpeg_error_mgr *mgr) { - struct jpeg_decompress_struct cinfo; - struct my_jpeg_error_mgr mgr; Lisp_Object file, specified_file; Lisp_Object specified_data; - FILE * volatile fp = NULL; + FILE *fp = NULL; JSAMPARRAY buffer; int row_stride, x, y; XImagePtr ximg = NULL; - int rc; unsigned long *colors; int width, height; @@ -6379,26 +6422,37 @@ jpeg_load (struct frame *f, struct image *img) return 0; } + IF_LINT (mgr->fp = fp); + /* Customize libjpeg's error handling to call my_error_exit when an error is detected. This function will perform a longjmp. */ - cinfo.err = fn_jpeg_std_error (&mgr.pub); - mgr.pub.error_exit = my_error_exit; - - if ((rc = setjmp (mgr.setjmp_buffer)) != 0) + mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub); + mgr->pub.error_exit = my_error_exit; + if (sys_setjmp (mgr->setjmp_buffer)) { - if (rc == 1) + switch (mgr->failure_code) { - /* Called from my_error_exit. Display a JPEG error. */ - char buf[JMSG_LENGTH_MAX]; - cinfo.err->format_message ((j_common_ptr) &cinfo, buf); - image_error ("Error reading JPEG image `%s': %s", img->spec, - build_string (buf)); + case MY_JPEG_ERROR_EXIT: + { + char buf[JMSG_LENGTH_MAX]; + mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf); + image_error ("Error reading JPEG image `%s': %s", img->spec, + build_string (buf)); + break; + } + + case MY_JPEG_INVALID_IMAGE_SIZE: + image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); + break; + + case MY_JPEG_CANNOT_CREATE_X: + break; } /* Close the input file and destroy the JPEG object. */ if (fp) - fclose ((FILE *) fp); - fn_jpeg_destroy_decompress (&cinfo); + fclose (fp); + fn_jpeg_destroy_decompress (&mgr->cinfo); /* If we already have an XImage, free that. */ x_destroy_x_image (ximg); @@ -6408,46 +6462,52 @@ jpeg_load (struct frame *f, struct image *img) return 0; } + /* Silence a bogus diagnostic; see GCC bug 54561. */ + IF_LINT (fp = mgr->fp); + /* Create the JPEG decompression object. Let it read from fp. Read the JPEG image header. */ - fn_jpeg_CreateDecompress (&cinfo, JPEG_LIB_VERSION, sizeof (cinfo)); + fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); if (NILP (specified_data)) - jpeg_file_src (&cinfo, (FILE *) fp); + jpeg_file_src (&mgr->cinfo, fp); else - jpeg_memory_src (&cinfo, SDATA (specified_data), + jpeg_memory_src (&mgr->cinfo, SDATA (specified_data), SBYTES (specified_data)); - fn_jpeg_read_header (&cinfo, 1); + fn_jpeg_read_header (&mgr->cinfo, 1); /* Customize decompression so that color quantization will be used. Start decompression. */ - cinfo.quantize_colors = 1; - fn_jpeg_start_decompress (&cinfo); - width = img->width = cinfo.output_width; - height = img->height = cinfo.output_height; + mgr->cinfo.quantize_colors = 1; + fn_jpeg_start_decompress (&mgr->cinfo); + width = img->width = mgr->cinfo.output_width; + height = img->height = mgr->cinfo.output_height; if (!check_image_size (f, width, height)) { - image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); - longjmp (mgr.setjmp_buffer, 2); + mgr->failure_code = MY_JPEG_INVALID_IMAGE_SIZE; + sys_longjmp (mgr->setjmp_buffer, 1); } /* Create X image and pixmap. */ if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) - longjmp (mgr.setjmp_buffer, 2); + { + mgr->failure_code = MY_JPEG_CANNOT_CREATE_X; + sys_longjmp (mgr->setjmp_buffer, 1); + } /* Allocate colors. When color quantization is used, - cinfo.actual_number_of_colors has been set with the number of - colors generated, and cinfo.colormap is a two-dimensional array - of color indices in the range 0..cinfo.actual_number_of_colors. + mgr->cinfo.actual_number_of_colors has been set with the number of + colors generated, and mgr->cinfo.colormap is a two-dimensional array + of color indices in the range 0..mgr->cinfo.actual_number_of_colors. No more than 255 colors will be generated. */ { int i, ir, ig, ib; - if (cinfo.out_color_components > 2) + if (mgr->cinfo.out_color_components > 2) ir = 0, ig = 1, ib = 2; - else if (cinfo.out_color_components > 1) + else if (mgr->cinfo.out_color_components > 1) ir = 0, ig = 1, ib = 0; else ir = 0, ig = 0, ib = 0; @@ -6457,15 +6517,15 @@ jpeg_load (struct frame *f, struct image *img) a default color, and we don't have to care about which colors can be freed safely, and which can't. */ init_color_table (); - colors = alloca (cinfo.actual_number_of_colors * sizeof *colors); + colors = alloca (mgr->cinfo.actual_number_of_colors * sizeof *colors); - for (i = 0; i < cinfo.actual_number_of_colors; ++i) + for (i = 0; i < mgr->cinfo.actual_number_of_colors; ++i) { /* Multiply RGB values with 255 because X expects RGB values in the range 0..0xffff. */ - int r = cinfo.colormap[ir][i] << 8; - int g = cinfo.colormap[ig][i] << 8; - int b = cinfo.colormap[ib][i] << 8; + int r = mgr->cinfo.colormap[ir][i] << 8; + int g = mgr->cinfo.colormap[ig][i] << 8; + int b = mgr->cinfo.colormap[ib][i] << 8; colors[i] = lookup_rgb_color (f, r, g, b); } @@ -6477,21 +6537,21 @@ jpeg_load (struct frame *f, struct image *img) } /* Read pixels. */ - row_stride = width * cinfo.output_components; - buffer = cinfo.mem->alloc_sarray ((j_common_ptr) &cinfo, JPOOL_IMAGE, - row_stride, 1); + row_stride = width * mgr->cinfo.output_components; + buffer = mgr->cinfo.mem->alloc_sarray ((j_common_ptr) &mgr->cinfo, + JPOOL_IMAGE, row_stride, 1); for (y = 0; y < height; ++y) { - fn_jpeg_read_scanlines (&cinfo, buffer, 1); - for (x = 0; x < cinfo.output_width; ++x) + fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1); + for (x = 0; x < mgr->cinfo.output_width; ++x) XPutPixel (ximg, x, y, colors[buffer[0][x]]); } /* Clean up. */ - fn_jpeg_finish_decompress (&cinfo); - fn_jpeg_destroy_decompress (&cinfo); + fn_jpeg_finish_decompress (&mgr->cinfo); + fn_jpeg_destroy_decompress (&mgr->cinfo); if (fp) - fclose ((FILE *) fp); + fclose (fp); /* Maybe fill in the background field while we have ximg handy. */ if (NILP (image_spec_value (img->spec, QCbackground, NULL))) @@ -6504,6 +6564,13 @@ jpeg_load (struct frame *f, struct image *img) return 1; } +static int +jpeg_load (struct frame *f, struct image *img) +{ + struct my_jpeg_error_mgr mgr; + return jpeg_load_body (f, img, &mgr); +} + #else /* HAVE_JPEG */ #ifdef HAVE_NS diff --git a/src/indent.c b/src/indent.c index 160b8c7479e..053643e6319 100644 --- a/src/indent.c +++ b/src/indent.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -122,7 +121,7 @@ disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *w int i; if (widthtab->header.size != 256) - abort (); + emacs_abort (); for (i = 0; i < 256; i++) if (character_width (i, disptab) @@ -144,7 +143,7 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab) bset_width_table (buf, Fmake_vector (make_number (256), make_number (0))); widthtab = XVECTOR (BVAR (buf, width_table)); if (widthtab->header.size != 256) - abort (); + emacs_abort (); for (i = 0; i < 256; i++) XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); diff --git a/src/insdel.c b/src/insdel.c index da258c19a1e..87010cd8251 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> #include <intprops.h> @@ -69,13 +68,13 @@ check_markers (void) for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) { if (tail->buffer->text != current_buffer->text) - abort (); + emacs_abort (); if (tail->charpos > Z) - abort (); + emacs_abort (); if (tail->bytepos > Z_BYTE) - abort (); + emacs_abort (); if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos))) - abort (); + emacs_abort (); } } @@ -808,7 +807,7 @@ insert_1_both (const char *string, #ifdef BYTE_COMBINING_DEBUG if (count_combining_before (string, nbytes, PT, PT_BYTE) || count_combining_after (string, nbytes, PT, PT_BYTE)) - abort (); + emacs_abort (); #endif /* Record deletion of the surrounding text that combines with @@ -840,8 +839,7 @@ insert_1_both (const char *string, PT + nchars, PT_BYTE + nbytes, before_markers); - if (buffer_intervals (current_buffer)) - offset_intervals (current_buffer, PT, nchars); + offset_intervals (current_buffer, PT, nchars); if (!inherit && buffer_intervals (current_buffer)) set_text_properties (make_number (PT), make_number (PT + nchars), @@ -943,7 +941,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, the text that has been stored by copy_text. */ if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) - abort (); + emacs_abort (); #endif record_insert (PT, nchars); @@ -1126,7 +1124,7 @@ insert_from_buffer_1 (struct buffer *buf, the text that has been stored by copy_text. */ if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) - abort (); + emacs_abort (); #endif record_insert (PT, nchars); @@ -1153,8 +1151,7 @@ insert_from_buffer_1 (struct buffer *buf, PT_BYTE + outgoing_nbytes, 0); - if (buffer_intervals (current_buffer)) - offset_intervals (current_buffer, PT, nchars); + offset_intervals (current_buffer, PT, nchars); /* Get the intervals for the part of the string we are inserting. */ intervals = buffer_intervals (buf); @@ -1187,7 +1184,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, #ifdef BYTE_COMBINING_DEBUG if (count_combining_before (GPT_ADDR, len_byte, from, from_byte) || count_combining_after (GPT_ADDR, len_byte, from, from_byte)) - abort (); + emacs_abort (); #endif if (STRINGP (prev_text)) @@ -1222,8 +1219,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, else if (len < nchars_del) adjust_overlays_for_delete (from, nchars_del - len); - if (buffer_intervals (current_buffer)) - offset_intervals (current_buffer, from, len - nchars_del); + offset_intervals (current_buffer, from, len - nchars_del); if (from < PT) adjust_point (len - nchars_del, len_byte - nbytes_del); @@ -1370,7 +1366,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, the text that has been stored by copy_text. */ if (count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte) || count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte)) - abort (); + emacs_abort (); #endif if (! EQ (BVAR (current_buffer, undo_list), Qt)) @@ -1394,16 +1390,16 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, eassert (GPT <= GPT_BYTE); - /* Adjust the overlay center as needed. This must be done after - adjusting the markers that bound the overlays. */ - adjust_overlays_for_delete (from, nchars_del); - adjust_overlays_for_insert (from, inschars); - /* Adjust markers for the deletion and the insertion. */ if (markers) adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, inschars, outgoing_insbytes); + /* Adjust the overlay center as needed. This must be done after + adjusting the markers that bound the overlays. */ + adjust_overlays_for_delete (from, nchars_del); + adjust_overlays_for_insert (from, inschars); + offset_intervals (current_buffer, from, inschars - nchars_del); /* Get the intervals for the part of the string we are inserting-- @@ -1496,7 +1492,7 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte, the text that has been stored by copy_text. */ if (count_combining_before (GPT_ADDR, insbytes, from, from_byte) || count_combining_after (GPT_ADDR, insbytes, from, from_byte)) - abort (); + emacs_abort (); #endif GAP_SIZE -= insbytes; @@ -1510,6 +1506,12 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte, eassert (GPT <= GPT_BYTE); + /* Adjust markers for the deletion and the insertion. */ + if (markers + && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes)) + adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, + inschars, insbytes); + /* Adjust the overlay center as needed. This must be done after adjusting the markers that bound the overlays. */ if (nchars_del != inschars) @@ -1518,12 +1520,6 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte, adjust_overlays_for_delete (from + inschars, nchars_del); } - /* Adjust markers for the deletion and the insertion. */ - if (markers - && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes)) - adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, - inschars, insbytes); - offset_intervals (current_buffer, from, inschars - nchars_del); /* Relocate point as if it were a marker. */ @@ -1704,7 +1700,7 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, #ifdef BYTE_COMBINING_DEBUG if (count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte), Z_BYTE - to_byte, from, from_byte)) - abort (); + emacs_abort (); #endif if (ret_string || ! EQ (BVAR (current_buffer, undo_list), Qt)) @@ -2107,7 +2103,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute, non-nil, and insertion calls a file handler (e.g. through lock_file) which scribbles into a temp file -- cyd */ if (!BUFFERP (combine_after_change_buffer) - || NILP (BVAR (XBUFFER (combine_after_change_buffer), name))) + || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer))) { combine_after_change_list = Qnil; return Qnil; diff --git a/src/intervals.c b/src/intervals.c index 49d61b2f9b0..584ee1e923d 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -41,7 +41,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define INTERVALS_INLINE EXTERN_INLINE -#include <setjmp.h> #include <intprops.h> #include "lisp.h" #include "intervals.h" @@ -199,13 +198,13 @@ intervals_equal (INTERVAL i0, INTERVAL i1) i0_sym = XCAR (i0_cdr); i0_cdr = XCDR (i0_cdr); if (!CONSP (i0_cdr)) - return 0; /* abort (); */ + return 0; i1_val = i1->plist; while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym)) { i1_val = XCDR (i1_val); if (!CONSP (i1_val)) - return 0; /* abort (); */ + return 0; i1_val = XCDR (i1_val); } @@ -223,7 +222,7 @@ intervals_equal (INTERVAL i0, INTERVAL i1) i1_cdr = XCDR (i1_cdr); if (!CONSP (i1_cdr)) - return 0; /* abort (); */ + return 0; i1_cdr = XCDR (i1_cdr); } @@ -674,8 +673,7 @@ find_interval (register INTERVAL tree, register ptrdiff_t position) eassert (relative_position <= TOTAL_LENGTH (tree)); - if (!handling_signal) - tree = balance_possible_root_interval (tree); + tree = balance_possible_root_interval (tree); while (1) { @@ -1253,7 +1251,7 @@ delete_interval (register INTERVAL i) else if (STRINGP (owner)) set_string_intervals (owner, parent); else - abort (); + emacs_abort (); return; } @@ -1408,7 +1406,7 @@ offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length) start, length); else { - IF_LINT (if (length < - TYPE_MAXIMUM (ptrdiff_t)) abort ();) + lint_assume (- TYPE_MAXIMUM (ptrdiff_t) <= length); adjust_intervals_for_deletion (buffer, start, -length); } } @@ -1468,7 +1466,7 @@ merge_interval_right (register INTERVAL i) /* This must be the rightmost or last interval and cannot be merged right. The caller should have known. */ - abort (); + emacs_abort (); } /* Merge interval I with its lexicographic predecessor. The resulting @@ -1524,7 +1522,7 @@ merge_interval_left (register INTERVAL i) /* This must be the leftmost or first interval and cannot be merged left. The caller should have known. */ - abort (); + emacs_abort (); } /* Create a copy of SOURCE but with the default value of UP. */ @@ -2170,7 +2168,7 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, else if (STRINGP (object)) i = find_interval (string_intervals (object), pos); else - abort (); + emacs_abort (); if (!i || (i->position + LENGTH (i) <= pos)) return 0; @@ -2209,7 +2207,7 @@ get_local_map (register ptrdiff_t position, register struct buffer *buffer, /* Perhaps we should just change `position' to the limit. */ if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) - abort (); + emacs_abort (); /* Ignore narrowing, so that a local map continues to be valid even if the visible region contains no characters and hence no properties. */ diff --git a/src/keyboard.c b/src/keyboard.c index 992d1a97b3c..451ffd9d600 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -21,9 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define KEYBOARD_INLINE EXTERN_INLINE -#include <signal.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "termchar.h" #include "termopts.h" @@ -57,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/ioctl.h> #endif /* not MSDOS */ +#if defined USABLE_FIONREAD && defined USG5_4 +# include <sys/filio.h> +#endif + #include "syssignal.h" #include <sys/types.h> @@ -81,9 +84,7 @@ int interrupt_input_pending; pending_atimers separately, to reduce code size. So, any code that changes interrupt_input_pending or pending_atimers should update this too. */ -#ifdef SYNC_INPUT int pending_signals; -#endif #define KBD_BUFFER_SIZE 4096 @@ -142,7 +143,7 @@ static ptrdiff_t before_command_echo_length; /* For longjmp to where kbd input is being done. */ -static jmp_buf getcjmp; +static sys_jmp_buf getcjmp; /* True while doing kbd input. */ int waiting_for_input; @@ -386,19 +387,6 @@ int interrupt_input; /* Nonzero while interrupts are temporarily deferred during redisplay. */ int interrupts_deferred; -/* Allow configure to inhibit use of FIONREAD. */ -#ifdef BROKEN_FIONREAD -#undef FIONREAD -#endif - -/* We are unable to use interrupts if FIONREAD is not available, - so flush SIGIO so we won't try. */ -#if !defined (FIONREAD) -#ifdef SIGIO -#undef SIGIO -#endif -#endif - /* If we support a window system, turn on the code to poll periodically to detect C-g. It isn't actually used when doing interrupt input. */ #if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) @@ -444,14 +432,13 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object, Lisp_Object *, ptrdiff_t); static Lisp_Object make_lispy_switch_frame (Lisp_Object); static int help_char_p (Lisp_Object); -static void save_getcjmp (jmp_buf); -static void restore_getcjmp (jmp_buf); +static void save_getcjmp (sys_jmp_buf); +static void restore_getcjmp (sys_jmp_buf); static Lisp_Object apply_modifiers (int, Lisp_Object); static void clear_event (struct input_event *); static Lisp_Object restore_kboard_configuration (Lisp_Object); -static void interrupt_signal (int signalnum); -#ifdef SIGIO -static void input_available_signal (int signo); +#ifdef USABLE_SIGIO +static void deliver_input_available_signal (int signo); #endif static void handle_interrupt (void); static _Noreturn void quit_throw_to_read_char (int); @@ -459,7 +446,7 @@ static void process_special_events (void); static void timer_start_idle (void); static void timer_stop_idle (void); static void timer_resume_idle (void); -static void handle_user_signal (int); +static void deliver_user_signal (int); static char *find_user_signal_name (int); static int store_user_signal_events (void); @@ -1023,7 +1010,7 @@ restore_kboard_configuration (Lisp_Object was_locked) pop_kboard (); /* The pop should not change the kboard. */ if (single_kboard && current_kboard != prev) - abort (); + emacs_abort (); } return Qnil; } @@ -1315,7 +1302,7 @@ usage: (track-mouse BODY...) */) If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement after resizing the tool-bar window. */ -#if !defined HAVE_WINDOW_SYSTEM +#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS static #endif int ignore_mouse_drag_p; @@ -2021,17 +2008,9 @@ static struct atimer *poll_timer; void poll_for_input_1 (void) { -/* Tell ns_read_socket() it is being called asynchronously so it can avoid - doing anything dangerous. */ -#ifdef HAVE_NS - ++handling_signal; -#endif if (interrupt_input_blocked == 0 && !waiting_for_input) read_avail_input (0); -#ifdef HAVE_NS - --handling_signal; -#endif } /* Timer callback function for poll_timer. TIMER is equal to @@ -2042,12 +2021,8 @@ poll_for_input (struct atimer *timer) { if (poll_suppress_count == 0) { -#ifdef SYNC_INPUT interrupt_input_pending = 1; pending_signals = 1; -#else - poll_for_input_1 (); -#endif } } @@ -2326,8 +2301,8 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, { volatile Lisp_Object c; ptrdiff_t jmpcount; - jmp_buf local_getcjmp; - jmp_buf save_jump; + sys_jmp_buf local_getcjmp; + sys_jmp_buf save_jump; volatile int key_already_recorded = 0; Lisp_Object tem, save; volatile Lisp_Object previous_echo_area_message; @@ -2368,15 +2343,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, goto reread_first; } - if (unread_command_char != -1) - { - XSETINT (c, unread_command_char); - unread_command_char = -1; - - reread = 1; - goto reread_first; - } - if (CONSP (Vunread_command_events)) { int was_disabled = 0; @@ -2561,7 +2527,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) /* Don't bring up a menu if we already have another event. */ && NILP (Vunread_command_events) - && unread_command_char < 0 && !detect_input_pending_run_timers (0)) { c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); @@ -2583,7 +2548,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, it *must not* be in effect when we call redisplay. */ jmpcount = SPECPDL_INDEX (); - if (_setjmp (local_getcjmp)) + if (sys_setjmp (local_getcjmp)) { /* Handle quits while reading the keyboard. */ /* We must have saved the outer value of getcjmp here, @@ -2605,13 +2570,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, Lisp_Object last = KVAR (kb, kbd_queue); /* We shouldn't get here if we were in single-kboard mode! */ if (single_kboard) - abort (); + emacs_abort (); if (CONSP (last)) { while (CONSP (XCDR (last))) last = XCDR (last); if (!NILP (XCDR (last))) - abort (); + emacs_abort (); } if (!CONSP (last)) kset_kbd_queue (kb, Fcons (c, Qnil)); @@ -2697,8 +2662,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, && !EQ (XCAR (prev_event), Qmenu_bar) && !EQ (XCAR (prev_event), Qtool_bar) /* Don't bring up a menu if we already have another event. */ - && NILP (Vunread_command_events) - && unread_command_char < 0) + && NILP (Vunread_command_events)) { c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); @@ -2784,7 +2748,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, if (current_kboard->kbd_queue_has_data) { if (!CONSP (KVAR (current_kboard, kbd_queue))) - abort (); + emacs_abort (); c = XCAR (KVAR (current_kboard, kbd_queue)); kset_kbd_queue (current_kboard, XCDR (KVAR (current_kboard, kbd_queue))); @@ -2851,7 +2815,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, while (CONSP (XCDR (last))) last = XCDR (last); if (!NILP (XCDR (last))) - abort (); + emacs_abort (); } if (!CONSP (last)) kset_kbd_queue (kb, Fcons (c, Qnil)); @@ -3416,13 +3380,13 @@ record_char (Lisp_Object c) See read_process_output. */ static void -save_getcjmp (jmp_buf temp) +save_getcjmp (sys_jmp_buf temp) { memcpy (temp, getcjmp, sizeof getcjmp); } static void -restore_getcjmp (jmp_buf temp) +restore_getcjmp (sys_jmp_buf temp) { memcpy (getcjmp, temp, sizeof getcjmp); } @@ -3560,7 +3524,7 @@ kbd_buffer_store_event_hold (register struct input_event *event, struct input_event *hold_quit) { if (event->kind == NO_EVENT) - abort (); + emacs_abort (); if (hold_quit && hold_quit->kind != NO_EVENT) return; @@ -3604,7 +3568,7 @@ kbd_buffer_store_event_hold (register struct input_event *event, if (hold_quit) { - memcpy (hold_quit, event, sizeof (*event)); + *hold_quit = *event; return; } @@ -3659,10 +3623,8 @@ kbd_buffer_store_event_hold (register struct input_event *event, /* Don't read keyboard input until we have processed kbd_buffer. This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ hold_keyboard_input (); -#ifdef SIGIO if (!noninteractive) - signal (SIGIO, SIG_IGN); -#endif + ignore_sigio (); stop_polling (); } #endif /* subprocesses */ @@ -3681,7 +3643,7 @@ kbd_buffer_store_event_hold (register struct input_event *event, if (immediate_quit && NILP (Vinhibit_quit)) { immediate_quit = 0; - sigfree (); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); QUIT; } } @@ -3831,10 +3793,14 @@ kbd_buffer_get_event (KBOARD **kbp, /* Start reading input again because we have processed enough to be able to accept new events again. */ unhold_keyboard_input (); -#ifdef SIGIO +#ifdef USABLE_SIGIO if (!noninteractive) - signal (SIGIO, input_available_signal); -#endif /* SIGIO */ + { + struct sigaction action; + emacs_sigaction_init (&action, deliver_input_available_signal); + sigaction (SIGIO, &action, 0); + } +#endif start_polling (); } #endif /* subprocesses */ @@ -3876,10 +3842,9 @@ kbd_buffer_get_event (KBOARD **kbp, /* One way or another, wait until input is available; then, if interrupt handlers have not read it, read it now. */ -/* Note SIGIO has been undef'd if FIONREAD is missing. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO gobble_input (0); -#endif /* SIGIO */ +#endif if (kbd_fetch_ptr != kbd_store_ptr) break; #if defined (HAVE_MOUSE) || defined (HAVE_GPM) @@ -3955,7 +3920,7 @@ kbd_buffer_get_event (KBOARD **kbp, #else /* We're getting selection request events, but we don't have a window system. */ - abort (); + emacs_abort (); #endif } @@ -4131,7 +4096,7 @@ kbd_buffer_get_event (KBOARD **kbp, *used_mouse_menu = 1; #endif #ifdef HAVE_NS - /* certain system events are non-key events */ + /* Certain system events are non-key events. */ if (used_mouse_menu && event->kind == NS_NONKEY_EVENT) *used_mouse_menu = 1; @@ -4159,7 +4124,7 @@ kbd_buffer_get_event (KBOARD **kbp, so x remains nil. */ x = Qnil; - /* XXX Can f or mouse_position_hook be NULL here? */ + /* XXX Can f or mouse_position_hook be NULL here? */ if (f && FRAME_TERMINAL (f)->mouse_position_hook) (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window, &part, &x, &y, &t); @@ -4192,7 +4157,7 @@ kbd_buffer_get_event (KBOARD **kbp, else /* We were promised by the above while loop that there was something for us to read! */ - abort (); + emacs_abort (); input_pending = readable_events (0); @@ -4261,7 +4226,7 @@ process_special_events (void) #else /* We're getting selection request events, but we don't have a window system. */ - abort (); + emacs_abort (); #endif } } @@ -4351,7 +4316,7 @@ decode_timer (Lisp_Object timer, EMACS_TIME *result) if (! NILP (vector[0])) return 0; - return decode_time_components (vector[1], vector[2], vector[3], vector[4], + return decode_time_components (vector[1], vector[2], vector[3], vector[8], result, 0); } @@ -4553,7 +4518,7 @@ in the same style as (current-time). The value when Emacs is not idle is nil. -NSEC is a multiple of the system clock resolution. */) +PSEC is a multiple of the system clock resolution. */) (void) { if (EMACS_TIME_VALID_P (timer_idleness_start_time)) @@ -5614,7 +5579,7 @@ make_lispy_event (struct input_event *event) else if (FRAMEP (event->frame_or_window)) f = XFRAME (event->frame_or_window); else - abort (); + emacs_abort (); if (FRAME_WINDOW_P (f)) fuzz = double_click_fuzz; @@ -5721,7 +5686,7 @@ make_lispy_event (struct input_event *event) else /* Every mouse event should either have the down_modifier or the up_modifier set. */ - abort (); + emacs_abort (); { /* Get the symbol we should use for the mouse click. */ @@ -5782,7 +5747,7 @@ make_lispy_event (struct input_event *event) else if (FRAMEP (event->frame_or_window)) fr = XFRAME (event->frame_or_window); else - abort (); + emacs_abort (); fuzz = FRAME_WINDOW_P (fr) ? double_click_fuzz : double_click_fuzz / 8; @@ -5802,7 +5767,7 @@ make_lispy_event (struct input_event *event) else /* Every wheel event should either have the down_modifier or the up_modifier set. */ - abort (); + emacs_abort (); if (event->kind == HORIZ_WHEEL_EVENT) symbol_num += 2; @@ -5971,7 +5936,7 @@ make_lispy_event (struct input_event *event) { char *name = find_user_signal_name (event->code); if (!name) - abort (); + emacs_abort (); return intern (name); } @@ -6052,7 +6017,7 @@ make_lispy_event (struct input_event *event) /* The 'kind' field of the event is something we don't recognize. */ default: - abort (); + emacs_abort (); } } @@ -6229,7 +6194,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_ /* Only the event queue may use the `up' modifier; it should always be turned into a click or drag event before presented to lisp code. */ if (modifiers & up_modifier) - abort (); + emacs_abort (); if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } @@ -6324,7 +6289,7 @@ parse_modifiers (Lisp_Object symbol) Qnil); if (modifiers & ~INTMASK) - abort (); + emacs_abort (); XSETFASTINT (mask, modifiers); elements = Fcons (unmodified, Fcons (mask, Qnil)); @@ -6778,13 +6743,15 @@ get_input_pending (int *addr, int flags) void gobble_input (int expected) { -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { - SIGMASKTYPE mask; - mask = sigblock (sigmask (SIGIO)); + sigset_t blocked, procmask; + sigemptyset (&blocked); + sigaddset (&blocked, SIGIO); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); read_avail_input (expected); - sigsetmask (mask); + pthread_sigmask (SIG_SETMASK, &procmask, 0); } else #ifdef POLL_FOR_INPUT @@ -6793,10 +6760,12 @@ gobble_input (int expected) it's always set. */ if (!interrupt_input && poll_suppress_count == 0) { - SIGMASKTYPE mask; - mask = sigblock (sigmask (SIGALRM)); + sigset_t blocked, procmask; + sigemptyset (&blocked); + sigaddset (&blocked, SIGALRM); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); read_avail_input (expected); - sigsetmask (mask); + pthread_sigmask (SIG_SETMASK, &procmask, 0); } else #endif @@ -6829,13 +6798,15 @@ record_asynch_buffer_change (void) return; /* Make sure no interrupt happens while storing the event. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { - SIGMASKTYPE mask; - mask = sigblock (sigmask (SIGIO)); + sigset_t blocked, procmask; + sigemptyset (&blocked); + sigaddset (&blocked, SIGIO); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); kbd_buffer_store_event (&event); - sigsetmask (mask); + pthread_sigmask (SIG_SETMASK, &procmask, 0); } else #endif @@ -7001,7 +6972,7 @@ tty_read_avail_input (struct terminal *terminal, if (terminal->type != output_termcap && terminal->type != output_msdos_raw) - abort (); + emacs_abort (); /* XXX I think the following code should be moved to separate hook functions in system-dependent files. */ @@ -7053,7 +7024,7 @@ tty_read_avail_input (struct terminal *terminal, #endif /* HAVE_GPM */ /* Determine how many characters we should *try* to read. */ -#ifdef FIONREAD +#ifdef USABLE_FIONREAD /* Find out how much input is available. */ if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) { @@ -7066,14 +7037,12 @@ tty_read_avail_input (struct terminal *terminal, return 0; if (n_to_read > sizeof cbuf) n_to_read = sizeof cbuf; -#else /* no FIONREAD */ -#if defined (USG) || defined (CYGWIN) +#elif defined USG || defined CYGWIN /* Read some input if available, but don't wait. */ n_to_read = sizeof cbuf; fcntl (fileno (tty->input), F_SETFL, O_NDELAY); #else - you lose; -#endif +# error "Cannot read without possibly delaying" #endif #ifdef subprocesses @@ -7122,7 +7091,7 @@ tty_read_avail_input (struct terminal *terminal, #endif ); -#ifndef FIONREAD +#ifndef USABLE_FIONREAD #if defined (USG) || defined (CYGWIN) fcntl (fileno (tty->input), F_SETFL, 0); #endif /* USG or CYGWIN */ @@ -7193,19 +7162,12 @@ tty_read_avail_input (struct terminal *terminal, return nread; } -#if defined SYNC_INPUT || defined SIGIO static void handle_async_input (void) { interrupt_input_pending = 0; -#ifdef SYNC_INPUT pending_signals = pending_atimers; -#endif -/* Tell ns_read_socket() it is being called asynchronously so it can avoid - doing anything dangerous. */ -#ifdef HAVE_NS - ++handling_signal; -#endif + while (1) { int nread; @@ -7216,13 +7178,8 @@ handle_async_input (void) if (nread <= 0) break; } -#ifdef HAVE_NS - --handling_signal; -#endif } -#endif /* SYNC_INPUT || SIGIO */ -#ifdef SYNC_INPUT void process_pending_signals (void) { @@ -7230,33 +7187,25 @@ process_pending_signals (void) handle_async_input (); do_pending_atimers (); } -#endif -#ifdef SIGIO /* for entire page */ -/* Note SIGIO has been undef'd if FIONREAD is missing. */ +#ifdef USABLE_SIGIO static void -input_available_signal (int signo) +handle_input_available_signal (int sig) { - /* Must preserve main program's value of errno. */ - int old_errno = errno; - SIGNAL_THREAD_CHECK (signo); - -#ifdef SYNC_INPUT interrupt_input_pending = 1; pending_signals = 1; -#endif if (input_available_clear_time) *input_available_clear_time = make_emacs_time (0, 0); +} -#ifndef SYNC_INPUT - handle_async_input (); -#endif - - errno = old_errno; +static void +deliver_input_available_signal (int sig) +{ + handle_on_main_thread (sig, handle_input_available_signal); } -#endif /* SIGIO */ +#endif /* USABLE_SIGIO */ /* Send ourselves a SIGIO. @@ -7267,7 +7216,7 @@ input_available_signal (int signo) void reinvoke_input_signal (void) { -#ifdef SIGIO +#ifdef USABLE_SIGIO handle_async_input (); #endif } @@ -7296,6 +7245,7 @@ static struct user_signal_info *user_signals = NULL; void add_user_signal (int sig, const char *name) { + struct sigaction action; struct user_signal_info *p; for (p = user_signals; p; p = p->next) @@ -7310,18 +7260,16 @@ add_user_signal (int sig, const char *name) p->next = user_signals; user_signals = p; - signal (sig, handle_user_signal); + emacs_sigaction_init (&action, deliver_user_signal); + sigaction (sig, &action, 0); } static void handle_user_signal (int sig) { - int old_errno = errno; struct user_signal_info *p; const char *special_event_name = NULL; - SIGNAL_THREAD_CHECK (sig); - if (SYMBOLP (Vdebug_on_event)) special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event)); @@ -7342,7 +7290,7 @@ handle_user_signal (int sig) } p->npending++; -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) kill (getpid (), SIGIO); else @@ -7355,8 +7303,12 @@ handle_user_signal (int sig) } break; } +} - errno = old_errno; +static void +deliver_user_signal (int sig) +{ + handle_on_main_thread (sig, handle_user_signal); } static char * @@ -7381,7 +7333,7 @@ store_user_signal_events (void) for (p = user_signals; p; p = p->next) if (p->npending > 0) { - SIGMASKTYPE mask; + sigset_t blocked, procmask; if (nstored == 0) { @@ -7391,7 +7343,10 @@ store_user_signal_events (void) } nstored += p->npending; - mask = sigblock (sigmask (p->sig)); + sigemptyset (&blocked); + sigaddset (&blocked, p->sig); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); + do { buf.code = p->sig; @@ -7399,7 +7354,8 @@ store_user_signal_events (void) p->npending--; } while (p->npending > 0); - sigsetmask (mask); + + pthread_sigmask (SIG_SETMASK, &procmask, 0); } return nstored; @@ -10438,7 +10394,7 @@ clear_input_pending (void) int requeued_events_pending_p (void) { - return (!NILP (Vunread_command_events) || unread_command_char != -1); + return (!NILP (Vunread_command_events)); } @@ -10448,7 +10404,7 @@ Actually, the value is nil only if we can be sure that no input is available; if there is a doubt, the value is t. */) (void) { - if (!NILP (Vunread_command_events) || unread_command_char != -1 + if (!NILP (Vunread_command_events) || !NILP (Vunread_post_input_method_events) || !NILP (Vunread_input_method_events)) return (Qt); @@ -10636,7 +10592,6 @@ Also end any kbd macro being defined. */) update_mode_lines++; Vunread_command_events = Qnil; - unread_command_char = -1; discard_tty_input (); @@ -10776,17 +10731,10 @@ clear_waiting_for_input (void) Otherwise, tell QUIT to kill Emacs. */ static void -interrupt_signal (int signalnum) /* If we don't have an argument, some */ - /* compilers complain in signal calls. */ +handle_interrupt_signal (int sig) { - /* Must preserve main program's value of errno. */ - int old_errno = errno; - struct terminal *terminal; - - SIGNAL_THREAD_CHECK (signalnum); - /* See if we have an active terminal on our controlling tty. */ - terminal = get_named_tty ("/dev/tty"); + struct terminal *terminal = get_named_tty ("/dev/tty"); if (!terminal) { /* If there are no frames there, let's pretend that we are a @@ -10807,10 +10755,15 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */ handle_interrupt (); } +} - errno = old_errno; +static void +deliver_interrupt_signal (int sig) +{ + handle_on_main_thread (sig, handle_interrupt_signal); } + /* If Emacs is stuck because `inhibit-quit' is true, then keep track of the number of times C-g has been requested. If C-g is pressed enough times, then quit anyway. See bug#6585. */ @@ -10840,7 +10793,10 @@ handle_interrupt (void) /* If SIGINT isn't blocked, don't let us be interrupted by another SIGINT, it might be harmful due to non-reentrancy in I/O functions. */ - sigblock (sigmask (SIGINT)); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGINT); + pthread_sigmask (SIG_BLOCK, &blocked, 0); fflush (stdout); reset_all_sys_modes (); @@ -10902,7 +10858,7 @@ handle_interrupt (void) #endif /* not MSDOS */ fflush (stdout); if (((c = getchar ()) & ~040) == 'Y') - abort (); + emacs_abort (); while (c != '\n') c = getchar (); #ifdef MSDOS printf ("\r\nContinuing...\r\n"); @@ -10911,7 +10867,7 @@ handle_interrupt (void) #endif /* not MSDOS */ fflush (stdout); init_all_sys_modes (); - sigfree (); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); } else { @@ -10924,7 +10880,7 @@ handle_interrupt (void) struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; immediate_quit = 0; - sigfree (); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); saved = gl_state; GCPRO4 (saved.object, saved.global_code, saved.current_syntax_table, saved.old_prop); @@ -10969,13 +10925,12 @@ quit_throw_to_read_char (int from_signal) if (!from_signal && EQ (Vquit_flag, Qkill_emacs)) Fkill_emacs (Qnil); - sigfree (); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); /* Prevent another signal from doing this before we finish. */ clear_waiting_for_input (); input_pending = 0; Vunread_command_events = Qnil; - unread_command_char = -1; #if 0 /* Currently, sit_for is called from read_char without turning off polling. And that can call set_waiting_for_input. @@ -10983,7 +10938,7 @@ quit_throw_to_read_char (int from_signal) #ifdef POLL_FOR_INPUT /* May be > 1 if in recursive minibuffer. */ if (poll_suppress_count == 0) - abort (); + emacs_abort (); #endif #endif if (FRAMEP (internal_last_event_frame) @@ -10991,7 +10946,7 @@ quit_throw_to_read_char (int from_signal) do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 0, 0, Qnil); - _longjmp (getcjmp, 1); + sys_longjmp (getcjmp, 1); } DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, @@ -11004,8 +10959,7 @@ See also `current-input-mode'. */) (Lisp_Object interrupt) { int new_interrupt_input; -#ifdef SIGIO -/* Note SIGIO has been undef'd if FIONREAD is missing. */ +#ifdef USABLE_SIGIO #ifdef HAVE_X_WINDOWS if (x_display_list != NULL) { @@ -11016,9 +10970,9 @@ See also `current-input-mode'. */) else #endif /* HAVE_X_WINDOWS */ new_interrupt_input = !NILP (interrupt); -#else /* not SIGIO */ +#else /* not USABLE_SIGIO */ new_interrupt_input = 0; -#endif /* not SIGIO */ +#endif /* not USABLE_SIGIO */ if (new_interrupt_input != interrupt_input) { @@ -11341,7 +11295,7 @@ delete_kboard (KBOARD *kb) for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard) if (*kbp == NULL) - abort (); + emacs_abort (); *kbp = kb->next_kboard; /* Prevent a dangling reference to KB. */ @@ -11352,7 +11306,7 @@ delete_kboard (KBOARD *kb) current_kboard = FRAME_KBOARD (XFRAME (selected_frame)); single_kboard = 0; if (current_kboard == kb) - abort (); + emacs_abort (); } wipe_kboard (kb); @@ -11362,12 +11316,11 @@ delete_kboard (KBOARD *kb) void init_keyboard (void) { - /* This is correct before outermost invocation of the editor loop */ + /* This is correct before outermost invocation of the editor loop. */ command_loop_level = -1; immediate_quit = 0; quit_char = Ctl ('g'); Vunread_command_events = Qnil; - unread_command_char = -1; timer_idleness_start_time = invalid_emacs_time (); total_keys = 0; recent_keys_index = 0; @@ -11379,9 +11332,7 @@ init_keyboard (void) input_pending = 0; interrupt_input_blocked = 0; interrupt_input_pending = 0; -#ifdef SYNC_INPUT pending_signals = 0; -#endif /* This means that command_loop_1 won't try to select anything the first time through. */ @@ -11404,18 +11355,23 @@ init_keyboard (void) SIGINT. There is special code in interrupt_signal to exit Emacs on SIGINT when there are no termcap frames on the controlling terminal. */ - signal (SIGINT, interrupt_signal); + struct sigaction action; + emacs_sigaction_init (&action, deliver_interrupt_signal); + sigaction (SIGINT, &action, 0); #ifndef DOS_NT /* For systems with SysV TERMIO, C-g is set up for both SIGINT and SIGQUIT and we can't tell which one it will give us. */ - signal (SIGQUIT, interrupt_signal); + sigaction (SIGQUIT, &action, 0); #endif /* not DOS_NT */ } -/* Note SIGIO has been undef'd if FIONREAD is missing. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO if (!noninteractive) - signal (SIGIO, input_available_signal); -#endif /* SIGIO */ + { + struct sigaction action; + emacs_sigaction_init (&action, deliver_input_available_signal); + sigaction (SIGIO, &action, 0); + } +#endif /* Use interrupt input by default, if it works and noninterrupt input has deficiencies. */ @@ -11426,7 +11382,7 @@ init_keyboard (void) interrupt_input = 0; #endif - sigfree (); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); dribble = 0; if (keyboard_init_hook) @@ -11694,9 +11650,6 @@ as they will already have been added once as they were read for the first time. An element of the form (t . EVENT) forces EVENT to be added to that list. */); Vunread_command_events = Qnil; - DEFVAR_INT ("unread-command-char", unread_command_char, - doc: /* If not -1, an object to be read as next command input event. */); - DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events, doc: /* List of events to be processed as input by input methods. These events are processed before `unread-command-events' diff --git a/src/keyboard.h b/src/keyboard.h index 69fa533fd03..3939747abf4 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -469,7 +469,7 @@ extern int waiting_for_input; happens. */ extern EMACS_TIME *input_available_clear_time; -#if defined HAVE_WINDOW_SYSTEM +#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS extern int ignore_mouse_drag_p; #endif diff --git a/src/keymap.c b/src/keymap.c index 85c384b8180..66fb52061f9 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -40,7 +40,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "commands.h" #include "character.h" @@ -2923,7 +2923,7 @@ You type Translation\n\ char *title, *p; if (!SYMBOLP (modes[i])) - abort (); + emacs_abort (); p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); *p++ = '\f'; diff --git a/src/lisp.h b/src/lisp.h index b906e4a1dfd..3a473a60b48 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef EMACS_LISP_H #define EMACS_LISP_H +#include <setjmp.h> #include <stdalign.h> #include <stdarg.h> #include <stdbool.h> @@ -325,7 +326,7 @@ enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 1 }; typedef EMACS_INT Lisp_Object; #define XLI(o) (o) #define XIL(i) (i) -#define LISP_MAKE_RVALUE(o) (0+(o)) +#define LISP_MAKE_RVALUE(o) (0 + (o)) #define LISP_INITIALLY_ZERO 0 enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 }; #endif /* CHECK_LISP_OBJECT_TYPE */ @@ -417,9 +418,9 @@ enum lsb_bits #define XINT(a) (XLI (a) >> INTTYPEBITS) #define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS) #define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS) -#define XSET(var, type, ptr) \ +#define make_lisp_ptr(ptr, type) \ (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \ - (var) = XIL ((type) | (intptr_t) (ptr))) + XIL ((type) | (intptr_t) (ptr))) #define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK)) #define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type))) @@ -444,13 +445,13 @@ static EMACS_INT const VALMASK #define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK)) #define make_number(N) XIL ((EMACS_INT) (N) & INTMASK) -#define XSET(var, type, ptr) \ - ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ - + ((intptr_t) (ptr) & VALMASK))) +#define make_lisp_ptr(ptr, type) \ + (XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ + + ((intptr_t) (ptr) & VALMASK))) #if DATA_SEG_BITS /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers - which were stored in a Lisp_Object */ + which were stored in a Lisp_Object. */ #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) #else #define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK)) @@ -554,16 +555,16 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) /* Construct a Lisp_Object from a value or address. */ -#define XSETINT(a, b) (a) = make_number (b) -#define XSETCONS(a, b) XSET (a, Lisp_Cons, b) -#define XSETVECTOR(a, b) XSET (a, Lisp_Vectorlike, b) -#define XSETSTRING(a, b) XSET (a, Lisp_String, b) -#define XSETSYMBOL(a, b) XSET (a, Lisp_Symbol, b) -#define XSETFLOAT(a, b) XSET (a, Lisp_Float, b) +#define XSETINT(a, b) ((a) = make_number (b)) +#define XSETCONS(a, b) ((a) = make_lisp_ptr (b, Lisp_Cons)) +#define XSETVECTOR(a, b) ((a) = make_lisp_ptr (b, Lisp_Vectorlike)) +#define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String)) +#define XSETSYMBOL(a, b) ((a) = make_lisp_ptr (b, Lisp_Symbol)) +#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float)) /* Misc types. */ -#define XSETMISC(a, b) XSET (a, Lisp_Misc, b) +#define XSETMISC(a, b) ((a) = make_lisp_ptr (b, Lisp_Misc)) #define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker) /* Pseudovector types. */ @@ -909,14 +910,6 @@ enum (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \ : char_table_ref ((CT), (IDX))) -/* Almost equivalent to Faref (CT, IDX). However, if the result is - not a character, return IDX. - - For these characters, do not check validity of CT - and do not follow parent. */ -#define CHAR_TABLE_TRANSLATE(CT, IDX) \ - char_table_translate (CT, IDX) - /* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and 8-bit European characters. Do not check validity of CT. */ #define CHAR_TABLE_SET(CT, IDX, VAL) \ @@ -1205,9 +1198,9 @@ struct Lisp_Hash_Table struct Lisp_Hash_Table *next_weak; /* C function to compare two keys. */ - int (*cmpfn) (struct Lisp_Hash_Table *, - Lisp_Object, EMACS_UINT, - Lisp_Object, EMACS_UINT); + bool (*cmpfn) (struct Lisp_Hash_Table *, + Lisp_Object, EMACS_UINT, + Lisp_Object, EMACS_UINT); /* C function to compute hash code. */ EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object); @@ -1627,7 +1620,7 @@ typedef struct { int mouse_face_image_state; } Mouse_HLInfo; -/* Data type checking */ +/* Data type checking. */ #define NILP(x) EQ (x, Qnil) @@ -1971,7 +1964,25 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); static struct Lisp_Kboard_Objfwd ko_fwd; \ defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ } while (0) - + +/* Save and restore the instruction and environment pointers, + without affecting the signal mask. */ + +#ifdef HAVE__SETJMP +typedef jmp_buf sys_jmp_buf; +# define sys_setjmp(j) _setjmp (j) +# define sys_longjmp(j, v) _longjmp (j, v) +#elif defined HAVE_SIGSETJMP +typedef sigjmp_buf sys_jmp_buf; +# define sys_setjmp(j) sigsetjmp (j, 0) +# define sys_longjmp(j, v) siglongjmp (j, v) +#else +/* A platform that uses neither _longjmp nor siglongjmp; assume + longjmp does not affect the sigmask. */ +typedef jmp_buf sys_jmp_buf; +# define sys_setjmp(j) setjmp (j) +# define sys_longjmp(j, v) longjmp (j, v) +#endif /* Structure for recording Lisp call stack for backtrace purposes. */ @@ -2000,7 +2011,7 @@ struct specbinding { Lisp_Object symbol, old_value; specbinding_func func; - Lisp_Object unused; /* Dividing by 16 is faster than by 12 */ + Lisp_Object unused; /* Dividing by 16 is faster than by 12. */ }; extern struct specbinding *specpdl; @@ -2009,7 +2020,10 @@ extern ptrdiff_t specpdl_size; #define SPECPDL_INDEX() (specpdl_ptr - specpdl) -/* Everything needed to describe an active condition case. */ +/* Everything needed to describe an active condition case. + + Members are volatile if their values need to survive _longjmp when + a 'struct handler' is a local variable. */ struct handler { /* The handler clauses and variable from the condition-case form. */ @@ -2020,10 +2034,12 @@ struct handler error: handle all conditions, and errors can run the debugger or display a backtrace. */ Lisp_Object handler; - Lisp_Object var; + + Lisp_Object volatile var; + /* Fsignal stores here the condition-case clause that applies, and Fcondition_case thus knows which clause to run. */ - Lisp_Object chosen_clause; + Lisp_Object volatile chosen_clause; /* Used to effect the longjump out to the handler. */ struct catchtag *tag; @@ -2049,19 +2065,21 @@ struct handler of the catch form. All the other members are concerned with restoring the interpreter - state. */ + state. + Members are volatile if their values need to survive _longjmp when + a 'struct catchtag' is a local variable. */ struct catchtag { Lisp_Object tag; - Lisp_Object val; - struct catchtag *next; + Lisp_Object volatile val; + struct catchtag *volatile next; struct gcpro *gcpro; - jmp_buf jmp; + sys_jmp_buf jmp; struct backtrace *backlist; struct handler *handlerlist; EMACS_INT lisp_eval_depth; - ptrdiff_t pdlcount; + ptrdiff_t volatile pdlcount; int poll_suppress_count; int interrupt_input_blocked; struct byte_stack *byte_stack; @@ -2089,22 +2107,16 @@ extern char *stack_bottom; If quit-flag is set to `kill-emacs' the SIGINT handler has received a request to exit Emacs when it is safe to do. */ -#ifdef SYNC_INPUT extern void process_pending_signals (void); extern int pending_signals; -#define ELSE_PENDING_SIGNALS \ - else if (pending_signals) \ - process_pending_signals (); -#else /* not SYNC_INPUT */ -#define ELSE_PENDING_SIGNALS -#endif /* not SYNC_INPUT */ extern void process_quit_flag (void); #define QUIT \ do { \ if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ process_quit_flag (); \ - ELSE_PENDING_SIGNALS \ + else if (pending_signals) \ + process_pending_signals (); \ } while (0) @@ -2288,7 +2300,7 @@ extern int gcpro_level; #define UNGCPRO \ ((--gcpro_level != gcpro1.level) \ - ? (abort (), 0) \ + ? (emacs_abort (), 0) \ : ((gcprolist = gcpro1.next), 0)) #endif /* DEBUG_GCPRO */ @@ -2567,8 +2579,7 @@ extern Lisp_Object Qchar_table_p, Qvector_or_char_table_p; extern Lisp_Object Qcdr; -extern Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; -extern Lisp_Object Qoverflow_error, Qunderflow_error; +extern Lisp_Object Qrange_error, Qoverflow_error; extern Lisp_Object Qfloatp; extern Lisp_Object Qnumberp, Qnumber_or_marker_p; @@ -2579,10 +2590,10 @@ extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST; -/* Defined in frame.c */ +/* Defined in frame.c. */ extern Lisp_Object Qframep; -/* Defined in data.c */ +/* Defined in data.c. */ extern Lisp_Object indirect_function (Lisp_Object); extern Lisp_Object find_symbol_value (Lisp_Object); @@ -2629,7 +2640,7 @@ extern void swap_in_global_binding (struct Lisp_Symbol *); extern void syms_of_cmds (void); extern void keys_of_cmds (void); -/* Defined in coding.c */ +/* Defined in coding.c. */ extern Lisp_Object Qcharset; extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, ptrdiff_t, bool, bool, Lisp_Object); @@ -2637,7 +2648,7 @@ extern void init_coding (void); extern void init_coding_once (void); extern void syms_of_coding (void); -/* Defined in character.c */ +/* Defined in character.c. */ EXFUN (Fmax_char, 0) ATTRIBUTE_CONST; extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t); extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t); @@ -2645,21 +2656,21 @@ extern int multibyte_char_to_unibyte (int) ATTRIBUTE_CONST; extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST; extern void syms_of_character (void); -/* Defined in charset.c */ +/* Defined in charset.c. */ extern void init_charset (void); extern void init_charset_once (void); extern void syms_of_charset (void); /* Structure forward declarations. */ struct charset; -/* Defined in composite.c */ +/* Defined in composite.c. */ extern void syms_of_composite (void); -/* Defined in syntax.c */ +/* Defined in syntax.c. */ extern void init_syntax_once (void); extern void syms_of_syntax (void); -/* Defined in fns.c */ +/* Defined in fns.c. */ extern Lisp_Object QCrehash_size, QCrehash_threshold; enum { NEXT_ALMOST_PRIME_LIMIT = 11 }; EXFUN (Fidentity, 1) ATTRIBUTE_CONST; @@ -2693,13 +2704,12 @@ extern Lisp_Object string_to_multibyte (Lisp_Object); extern Lisp_Object string_make_unibyte (Lisp_Object); extern void syms_of_fns (void); -/* Defined in floatfns.c */ +/* Defined in floatfns.c. */ extern double extract_float (Lisp_Object); -extern void init_floatfns (void); extern void syms_of_floatfns (void); extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); -/* Defined in fringe.c */ +/* Defined in fringe.c. */ extern void syms_of_fringe (void); extern void init_fringe (void); #ifdef HAVE_WINDOW_SYSTEM @@ -2707,13 +2717,13 @@ extern void mark_fringe_data (void); extern void init_fringe_once (void); #endif /* HAVE_WINDOW_SYSTEM */ -/* Defined in image.c */ +/* Defined in image.c. */ extern Lisp_Object QCascent, QCmargin, QCrelief; extern Lisp_Object QCconversion; extern int x_bitmap_mask (struct frame *, ptrdiff_t); extern void syms_of_image (void); -/* Defined in insdel.c */ +/* Defined in insdel.c. */ extern Lisp_Object Qinhibit_modification_hooks; extern void move_gap (ptrdiff_t); extern void move_gap_both (ptrdiff_t, ptrdiff_t); @@ -2759,7 +2769,7 @@ extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, const char *, ptrdiff_t, ptrdiff_t, bool); extern void syms_of_insdel (void); -/* Defined in dispnew.c */ +/* Defined in dispnew.c. */ #if (defined PROFILING \ && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) _Noreturn void __executable_start (void); @@ -2770,7 +2780,7 @@ extern Lisp_Object sit_for (Lisp_Object, bool, int); extern void init_display (void); extern void syms_of_display (void); -/* Defined in xdisp.c */ +/* Defined in xdisp.c. */ extern Lisp_Object Qinhibit_point_motion_hooks; extern Lisp_Object Qinhibit_redisplay, Qdisplay; extern Lisp_Object Qmenu_bar_update_hook; @@ -2821,17 +2831,15 @@ extern Lisp_Object safe_eval (Lisp_Object); extern int pos_visible_p (struct window *, ptrdiff_t, int *, int *, int *, int *, int *, int *); -/* Defined in xsettings.c */ +/* Defined in xsettings.c. */ extern void syms_of_xsettings (void); /* Defined in vm-limit.c. */ extern void memory_warnings (void *, void (*warnfun) (const char *)); -/* Defined in alloc.c */ +/* Defined in alloc.c. */ extern void check_pure_size (void); extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); -extern void reset_malloc_hooks (void); -extern void uninterrupt_malloc (void); extern void malloc_warning (const char *); extern _Noreturn void memory_full (size_t); extern _Noreturn void buffer_memory_full (ptrdiff_t); @@ -2930,7 +2938,7 @@ extern void check_cons_list (void); #endif #ifdef REL_ALLOC -/* Defined in ralloc.c */ +/* Defined in ralloc.c. */ extern void *r_alloc (void **, size_t); extern void r_alloc_free (void **); extern void *r_re_alloc (void **, size_t); @@ -2938,7 +2946,7 @@ extern void r_alloc_reset_variable (void **, void **); extern void r_alloc_inhibit_buffer_relocation (int); #endif -/* Defined in chartab.c */ +/* Defined in chartab.c. */ extern Lisp_Object copy_char_table (Lisp_Object); extern Lisp_Object char_table_ref (Lisp_Object, int); extern Lisp_Object char_table_ref_and_range (Lisp_Object, int, @@ -2956,7 +2964,7 @@ extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Ob extern Lisp_Object uniprop_table (Lisp_Object); extern void syms_of_chartab (void); -/* Defined in print.c */ +/* Defined in print.c. */ extern Lisp_Object Vprin1_to_string_buffer; extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE; extern Lisp_Object Qstandard_output; @@ -2973,7 +2981,7 @@ enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 }; extern int float_to_string (char *, double); extern void syms_of_print (void); -/* Defined in doprnt.c */ +/* Defined in doprnt.c. */ extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *, va_list); extern ptrdiff_t esprintf (char *, char const *, ...) @@ -2988,6 +2996,7 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t, /* Defined in lread.c. */ extern Lisp_Object Qvariable_documentation, Qstandard_input; extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; +extern Lisp_Object Qlexical_binding; extern Lisp_Object check_obarray (Lisp_Object); extern Lisp_Object intern_1 (const char *, ptrdiff_t); extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); @@ -3021,12 +3030,11 @@ intern_c_string (const char *str) /* Defined in eval.c. */ extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; -extern Lisp_Object Qinhibit_quit, Qclosure; +extern Lisp_Object Qinhibit_quit, Qinternal_interpreter_environment, Qclosure; extern Lisp_Object Qand_rest; extern Lisp_Object Vautoload_queue; extern Lisp_Object Vsignaling_function; extern Lisp_Object inhibit_lisp_code; -extern int handling_signal; #if BYTE_MARK_STACK extern struct catchtag *catchlist; extern struct handler *handlerlist; @@ -3075,6 +3083,7 @@ extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); extern _Noreturn void verror (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0); extern Lisp_Object un_autoload (Lisp_Object); +extern Lisp_Object call_debugger (Lisp_Object arg); extern void init_eval_once (void); extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); @@ -3137,7 +3146,7 @@ extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t); extern void syms_of_marker (void); -/* Defined in fileio.c */ +/* Defined in fileio.c. */ extern Lisp_Object Qfile_error; extern Lisp_Object Qfile_exists_p; @@ -3145,16 +3154,16 @@ extern Lisp_Object Qfile_directory_p; extern Lisp_Object Qinsert_file_contents; extern Lisp_Object Qfile_name_history; extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); -EXFUN (Fread_file_name, 6); /* not a normal DEFUN */ +EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ extern Lisp_Object close_file_unwind (Lisp_Object); extern Lisp_Object restore_point_unwind (Lisp_Object); extern _Noreturn void report_file_error (const char *, Lisp_Object); -extern int internal_delete_file (Lisp_Object); +extern void internal_delete_file (Lisp_Object); extern void syms_of_fileio (void); -extern Lisp_Object make_temp_name (Lisp_Object, int); +extern Lisp_Object make_temp_name (Lisp_Object, bool); extern Lisp_Object Qdelete_file; -/* Defined in search.c */ +/* Defined in search.c. */ extern void shrink_regexp_cache (void); extern void restore_search_regs (void); extern void record_unwind_save_match_data (void); @@ -3227,9 +3236,7 @@ extern void cmd_error_internal (Lisp_Object, const char *); extern Lisp_Object command_loop_1 (void); extern Lisp_Object recursive_edit_1 (void); extern void record_auto_save (void); -#ifdef SIGDANGER extern void force_auto_save_soon (void); -#endif extern void init_keyboard (void); extern void syms_of_keyboard (void); extern void keys_of_keyboard (void); @@ -3257,14 +3264,12 @@ extern void syms_of_frame (void); extern char **initial_argv; extern int initial_argc; #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) -extern int display_arg; +extern bool display_arg; #endif extern Lisp_Object decode_env_path (const char *, const char *); extern Lisp_Object empty_unibyte_string, empty_multibyte_string; extern Lisp_Object Qfile_name_handler_alist; -#ifdef FLOAT_CATCH_SIGILL -extern void fatal_error_signal (int); -#endif +extern _Noreturn void fatal_error_backtrace (int, int); extern Lisp_Object Qkill_emacs; #if HAVE_SETLOCALE void fixup_locale (void); @@ -3276,22 +3281,26 @@ void synchronize_system_time_locale (void); #define synchronize_system_messages_locale() #define synchronize_system_time_locale() #endif -void shut_down_emacs (int, int, Lisp_Object); -/* Nonzero means don't do interactive redisplay and don't change tty modes. */ -extern int noninteractive; +extern void shut_down_emacs (int, Lisp_Object); -/* Nonzero means remove site-lisp directories from load-path. */ -extern int no_site_lisp; +/* True means don't do interactive redisplay and don't change tty modes. */ +extern bool noninteractive; + +/* True means remove site-lisp directories from load-path. */ +extern bool no_site_lisp; /* Pipe used to send exit notification to the daemon parent at startup. */ extern int daemon_pipe[2]; #define IS_DAEMON (daemon_pipe[1] != 0) -/* Nonzero means don't do use window-system-specific display code. */ -extern int inhibit_window_system; -/* Nonzero means that a filter or a sentinel is running. */ -extern int running_asynch_code; +/* True if handling a fatal error already. */ +extern bool fatal_error_in_progress; + +/* True means don't do use window-system-specific display code. */ +extern bool inhibit_window_system; +/* True means that a filter or a sentinel is running. */ +extern bool running_asynch_code; /* Defined in process.c. */ extern Lisp_Object QCtype, Qlocal; @@ -3329,14 +3338,14 @@ extern void init_callproc (void); extern void set_initial_environment (void); extern void syms_of_callproc (void); -/* Defined in doc.c */ +/* Defined in doc.c. */ extern Lisp_Object Qfunction_documentation; extern Lisp_Object read_doc_string (Lisp_Object); extern Lisp_Object get_doc_string (Lisp_Object, bool, bool); extern void syms_of_doc (void); extern int read_bytecode_char (bool); -/* Defined in bytecode.c */ +/* Defined in bytecode.c. */ extern Lisp_Object Qbytecode; extern void syms_of_bytecode (void); extern struct byte_stack *byte_stack_list; @@ -3347,12 +3356,12 @@ extern void unmark_byte_stack (void); extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); -/* Defined in macros.c */ +/* Defined in macros.c. */ extern Lisp_Object Qexecute_kbd_macro; extern void init_macros (void); extern void syms_of_macros (void); -/* Defined in undo.c */ +/* Defined in undo.c. */ extern Lisp_Object Qapply; extern Lisp_Object Qinhibit_read_only; extern void truncate_undo_list (struct buffer *); @@ -3365,7 +3374,7 @@ extern void record_property_change (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, Lisp_Object); extern void syms_of_undo (void); -/* Defined in textprop.c */ +/* Defined in textprop.c. */ extern Lisp_Object Qfont, Qmouse_face; extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks; extern Lisp_Object Qfront_sticky, Qrear_nonsticky; @@ -3373,19 +3382,19 @@ extern Lisp_Object Qminibuffer_prompt; extern void report_interval_modification (Lisp_Object, Lisp_Object); -/* Defined in menu.c */ +/* Defined in menu.c. */ extern void syms_of_menu (void); -/* Defined in xmenu.c */ +/* Defined in xmenu.c. */ extern void syms_of_xmenu (void); -/* Defined in termchar.h */ +/* Defined in termchar.h. */ struct tty_display_info; -/* Defined in termhooks.h */ +/* Defined in termhooks.h. */ struct terminal; -/* Defined in sysdep.c */ +/* Defined in sysdep.c. */ #ifndef HAVE_GET_CURRENT_DIR_NAME extern char *get_current_dir_name (void); #endif @@ -3407,6 +3416,8 @@ extern int set_window_size (int, int, int); extern EMACS_INT get_random (void); extern void seed_random (void *, ptrdiff_t); extern void init_random (void); +extern void emacs_backtrace (int); +extern _Noreturn void emacs_abort (void) NO_INLINE; extern int emacs_open (const char *, int, int); extern int emacs_close (int); extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); @@ -3420,45 +3431,45 @@ extern void unlock_file (Lisp_Object); extern void unlock_buffer (struct buffer *); extern void syms_of_filelock (void); -/* Defined in sound.c */ +/* Defined in sound.c. */ extern void syms_of_sound (void); -/* Defined in category.c */ +/* Defined in category.c. */ extern void init_category_once (void); extern Lisp_Object char_category_set (int); extern void syms_of_category (void); -/* Defined in ccl.c */ +/* Defined in ccl.c. */ extern void syms_of_ccl (void); -/* Defined in dired.c */ +/* Defined in dired.c. */ extern void syms_of_dired (void); extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, bool, Lisp_Object); -/* Defined in term.c */ +/* Defined in term.c. */ extern int *char_ins_del_vector; extern void syms_of_term (void); extern _Noreturn void fatal (const char *msgid, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); -/* Defined in terminal.c */ +/* Defined in terminal.c. */ extern void syms_of_terminal (void); -/* Defined in font.c */ +/* Defined in font.c. */ extern void syms_of_font (void); extern void init_font (void); #ifdef HAVE_WINDOW_SYSTEM -/* Defined in fontset.c */ +/* Defined in fontset.c. */ extern void syms_of_fontset (void); -/* Defined in xfns.c, w32fns.c, or macfns.c */ +/* Defined in xfns.c, w32fns.c, or macfns.c. */ extern Lisp_Object Qfont_param; #endif -/* Defined in xfaces.c */ +/* Defined in xfaces.c. */ extern Lisp_Object Qdefault, Qtool_bar, Qfringe; extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; extern Lisp_Object Qmode_line_inactive; @@ -3466,31 +3477,34 @@ extern Lisp_Object Qface; extern Lisp_Object Qnormal; extern Lisp_Object QCfamily, QCweight, QCslant; extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground; +extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold; +extern Lisp_Object Qbold, Qextra_bold, Qultra_bold; +extern Lisp_Object Qoblique, Qitalic; extern Lisp_Object Vface_alternative_font_family_alist; extern Lisp_Object Vface_alternative_font_registry_alist; extern void syms_of_xfaces (void); #ifdef HAVE_X_WINDOWS -/* Defined in xfns.c */ +/* Defined in xfns.c. */ extern void syms_of_xfns (void); -/* Defined in xsmfns.c */ +/* Defined in xsmfns.c. */ extern void syms_of_xsmfns (void); -/* Defined in xselect.c */ +/* Defined in xselect.c. */ extern void syms_of_xselect (void); -/* Defined in xterm.c */ +/* Defined in xterm.c. */ extern void syms_of_xterm (void); #endif /* HAVE_X_WINDOWS */ #ifdef HAVE_WINDOW_SYSTEM -/* Defined in xterm.c, nsterm.m, w32term.c */ +/* Defined in xterm.c, nsterm.m, w32term.c. */ extern char *x_get_keysym_name (int); #endif /* HAVE_WINDOW_SYSTEM */ #ifdef HAVE_LIBXML2 -/* Defined in xml.c */ +/* Defined in xml.c. */ extern void syms_of_xml (void); extern void xml_cleanup_parser (void); #endif @@ -3501,20 +3515,20 @@ extern int have_menus_p (void); #endif #ifdef HAVE_DBUS -/* Defined in dbusbind.c */ +/* Defined in dbusbind.c. */ void syms_of_dbusbind (void); #endif #ifdef DOS_NT -/* Defined in msdos.c, w32.c */ +/* Defined in msdos.c, w32.c. */ extern char *emacs_root_dir (void); #endif /* DOS_NT */ -/* Nonzero means Emacs has already been initialized. +/* True means Emacs has already been initialized. Used during startup to detect startup of dumped Emacs. */ -extern int initialized; +extern bool initialized; -extern int immediate_quit; /* Nonzero means ^G can quit instantly */ +extern int immediate_quit; /* Nonzero means ^G can quit instantly. */ extern void *xmalloc (size_t); extern void *xzalloc (size_t); @@ -3544,36 +3558,10 @@ extern void init_system_name (void); #define make_fixnum_or_float(val) \ (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val)) - -/* Checks the `cycle check' variable CHECK to see if it indicates that - EL is part of a cycle; CHECK must be either Qnil or a value returned - by an earlier use of CYCLE_CHECK. SUSPICIOUS is the number of - elements after which a cycle might be suspected; after that many - elements, this macro begins consing in order to keep more precise - track of elements. - - Returns nil if a cycle was detected, otherwise a new value for CHECK - that includes EL. - - CHECK is evaluated multiple times, EL and SUSPICIOUS 0 or 1 times, so - the caller should make sure that's ok. */ - -#define CYCLE_CHECK(check, el, suspicious) \ - (NILP (check) \ - ? make_number (0) \ - : (INTEGERP (check) \ - ? (XFASTINT (check) < (suspicious) \ - ? make_number (XFASTINT (check) + 1) \ - : Fcons (el, Qnil)) \ - : (!NILP (Fmemq ((el), (check))) \ - ? Qnil \ - : Fcons ((el), (check))))) - - /* SAFE_ALLOCA normally allocates memory on the stack, but if size is larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ -enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; +enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; extern Lisp_Object safe_alloca_unwind (Lisp_Object); extern void *record_xmalloc (size_t); diff --git a/src/lisp.mk b/src/lisp.mk index 162d8819917..3d60e07dea3 100644 --- a/src/lisp.mk +++ b/src/lisp.mk @@ -65,6 +65,7 @@ lisp = \ $(lispsource)/format.elc \ $(lispsource)/bindings.elc \ $(lispsource)/files.elc \ + $(lispsource)/emacs-lisp/macroexp.elc \ $(lispsource)/cus-face.elc \ $(lispsource)/faces.elc \ $(lispsource)/button.elc \ diff --git a/src/lread.c b/src/lread.c index aa3e0cfc5b8..08d5f97292b 100644 --- a/src/lread.c +++ b/src/lread.c @@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/file.h> #include <errno.h> #include <limits.h> /* For CHAR_BIT. */ -#include <setjmp.h> #include <stat-time.h> #include "lisp.h" #include "intervals.h" @@ -50,7 +49,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #include <unistd.h> -#include <math.h> #ifdef HAVE_SETLOCALE #include <locale.h> @@ -89,8 +87,6 @@ static Lisp_Object Qget_emacs_mule_file_char; static Lisp_Object Qload_force_doc_strings; -extern Lisp_Object Qinternal_interpreter_environment; - static Lisp_Object Qload_in_progress; /* The association list of objects read with the #n=object form. @@ -1682,6 +1678,17 @@ readevalloop (Lisp_Object readcharfun, int whole_buffer = 0; /* 1 on the first time around. */ int first_sexp = 1; + Lisp_Object macroexpand = intern ("internal-macroexpand-for-load"); + + if (NILP (Ffboundp (macroexpand)) + /* Don't macroexpand in .elc files, since it should have been done + already. We actually don't know whether we're in a .elc file or not, + so we use circumstancial evidence: .el files normally go through + Vload_source_file_function -> load-with-code-conversion + -> eval-buffer. */ + || EQ (readcharfun, Qget_file_char) + || EQ (readcharfun, Qget_emacs_mule_file_char)) + macroexpand = Qnil; if (MARKERP (readcharfun)) { @@ -1696,7 +1703,7 @@ readevalloop (Lisp_Object readcharfun, /* We assume START is nil when input is not from a buffer. */ if (! NILP (start) && !b) - abort (); + emacs_abort (); specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */ specbind (Qcurrent_load_list, Qnil); @@ -1726,7 +1733,7 @@ readevalloop (Lisp_Object readcharfun, { ptrdiff_t count1 = SPECPDL_INDEX (); - if (b != 0 && NILP (BVAR (b, name))) + if (b != 0 && !BUFFER_LIVE_P (b)) error ("Reading from killed buffer"); if (!NILP (start)) @@ -1811,6 +1818,8 @@ readevalloop (Lisp_Object readcharfun, unbind_to (count1, Qnil); /* Now eval what we just read. */ + if (!NILP (macroexpand)) + val = call1 (macroexpand, val); val = eval_sub (val); if (printflag) @@ -3673,7 +3682,7 @@ intern_c_string_1 (const char *str, ptrdiff_t len) /* Creating a non-pure string from a string literal not implemented yet. We could just use make_string here and live with the extra copy. */ - abort (); + emacs_abort (); return Fintern (make_pure_c_string (str, len), obarray); } diff --git a/src/macros.c b/src/macros.c index e81068181b9..a507f12e343 100644 --- a/src/macros.c +++ b/src/macros.c @@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "macros.h" #include "commands.h" diff --git a/src/makefile.w32-in b/src/makefile.w32-in index a8dcf5f2ae8..24ecb2676da 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in @@ -482,7 +482,6 @@ WINDOW_H = $(SRC)/window.h \ $(BLD)/alloc.$(O) : \ $(SRC)/alloc.c \ $(SRC)/puresize.h \ - $(SRC)/syssignal.h \ $(SRC)/w32.h \ $(NT_INC)/unistd.h \ $(GNU_LIB)/verify.h \ @@ -1365,6 +1364,7 @@ $(BLD)/sysdep.$(O) : \ $(NT_INC)/sys/stat.h \ $(NT_INC)/unistd.h \ $(GNU_LIB)/allocator.h \ + $(GNU_LIB)/execinfo.h \ $(GNU_LIB)/ignore-value.h \ $(GNU_LIB)/utimens.h \ $(BLOCKINPUT_H) \ diff --git a/src/marker.c b/src/marker.c index 4ea06c7cd57..0c4e8cb3b55 100644 --- a/src/marker.c +++ b/src/marker.c @@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" @@ -59,7 +59,7 @@ byte_char_debug_check (struct buffer *b, ptrdiff_t charpos, ptrdiff_t bytepos) bytepos - BUF_BEG_BYTE (b)); if (charpos - 1 != nchars) - abort (); + emacs_abort (); } #else /* not MARKER_DEBUG */ @@ -67,7 +67,7 @@ byte_char_debug_check (struct buffer *b, ptrdiff_t charpos, ptrdiff_t bytepos) #define byte_char_debug_check(b, charpos, bytepos) do { } while (0) #endif /* MARKER_DEBUG */ - + void clear_charpos_cache (struct buffer *b) { @@ -142,7 +142,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) ptrdiff_t best_below, best_below_byte; if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) - abort (); + emacs_abort (); best_above = BUF_Z (b); best_above_byte = BUF_Z_BYTE (b); @@ -296,7 +296,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) ptrdiff_t best_below, best_below_byte; if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) - abort (); + emacs_abort (); best_above = BUF_Z (b); best_above_byte = BUF_Z_BYTE (b); @@ -407,7 +407,7 @@ Returns nil if MARKER points into a dead buffer. */) does not preserve the buffer from being GC'd (it's weak), so markers have to be unlinked from their buffer as soon as the buffer is killed. */ - eassert (!NILP (BVAR (XBUFFER (buf), name))); + eassert (BUFFER_LIVE_P (XBUFFER (buf))); return buf; } return Qnil; @@ -462,13 +462,13 @@ live_buffer (Lisp_Object buffer) if (NILP (buffer)) { b = current_buffer; - eassert (!NILP (BVAR (b, name))); + eassert (BUFFER_LIVE_P (b)); } else { CHECK_BUFFER (buffer); b = XBUFFER (buffer); - if (NILP (BVAR (b, name))) + if (!BUFFER_LIVE_P (b)) b = NULL; } return b; @@ -506,7 +506,7 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position, else { register ptrdiff_t charpos, bytepos; - + CHECK_NUMBER_COERCE_MARKER (position); charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), XINT (position), @@ -570,8 +570,8 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, if (b) { - attach_marker - (m, b, + attach_marker + (m, b, clip_to_bounds (BUF_BEGV (b), charpos, BUF_ZV (b)), clip_to_bounds (BUF_BEGV_BYTE (b), bytepos, BUF_ZV_BYTE (b))); } @@ -595,7 +595,7 @@ unchain_marker (register struct Lisp_Marker *marker) register struct Lisp_Marker *tail, **prev; /* No dead buffers here. */ - eassert (!NILP (BVAR (b, name))); + eassert (BUFFER_LIVE_P (b)); marker->buffer = NULL; prev = &BUF_MARKERS (b); @@ -605,12 +605,12 @@ unchain_marker (register struct Lisp_Marker *marker) { if (*prev == BUF_MARKERS (b)) { - /* Deleting first marker from the buffer's chain. Crash + /* Deleting first marker from the buffer's chain. Crash if new first marker in chain does not say it belongs to the same buffer, or at least that they have the same base buffer. */ if (tail->next && b->text != tail->next->buffer->text) - abort (); + emacs_abort (); } *prev = tail->next; /* We have removed the marker from the chain; diff --git a/src/menu.c b/src/menu.c index 336e1a9e31d..31b96cf4405 100644 --- a/src/menu.c +++ b/src/menu.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <limits.h> /* for INT_MAX */ #include "lisp.h" @@ -737,7 +736,7 @@ digest_single_submenu (int start, int end, int top_level_items) /* All items should be contained in panes. */ if (panes_seen == 0) - abort (); + emacs_abort (); item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); @@ -811,7 +810,7 @@ digest_single_submenu (int start, int end, int top_level_items) else if (EQ (type, QCtoggle)) wv->button_type = BUTTON_TYPE_TOGGLE; else - abort (); + emacs_abort (); wv->selected = !NILP (selected); if (! STRINGP (help)) diff --git a/src/minibuf.c b/src/minibuf.c index 41cc48017eb..8a1e0ddde86 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <errno.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "commands.h" @@ -110,7 +109,7 @@ choose_minibuf_frame (void) /* I don't think that any frames may validly have a null minibuffer window anymore. */ if (NILP (sf->minibuffer_window)) - abort (); + emacs_abort (); /* Under X, we come here with minibuf_window being the minibuffer window of the unused termcap window created in @@ -798,7 +797,7 @@ get_minibuffer (EMACS_INT depth) Vminibuffer_list = nconc2 (Vminibuffer_list, tail); } buf = Fcar (tail); - if (NILP (buf) || NILP (BVAR (XBUFFER (buf), name))) + if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf))) { buf = Fget_buffer_create (make_formatted_string (name, " *Minibuf-%"pI"d*", depth)); @@ -1860,7 +1859,6 @@ the values STRING, PREDICATE and `lambda'. */) } static Lisp_Object Qmetadata; -extern Lisp_Object Qbuffer; DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0, doc: /* Perform completion on buffer names. diff --git a/src/msdos.c b/src/msdos.c index a214456d104..ed5d3240aa1 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -796,7 +796,7 @@ IT_set_face (int face) /* The default face for the frame should always be realized and cached. */ if (!fp) - abort (); + emacs_abort (); } screen_face = face; fg = fp->foreground; @@ -1029,7 +1029,6 @@ IT_clear_end_of_line (struct frame *f, int first_unused) { char *spaces, *sp; int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); - extern int fatal_error_in_progress; struct tty_display_info *tty = FRAME_TTY (f); if (new_pos_X >= first_unused || fatal_error_in_progress) @@ -1394,7 +1393,7 @@ IT_insert_glyphs (struct frame *f, struct glyph *start, int len) static void IT_delete_glyphs (struct frame *f, int n) { - abort (); + emacs_abort (); } /* set-window-configuration on window.c needs this. */ @@ -3014,7 +3013,7 @@ XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable) const char *p; if (!enable) - abort (); + emacs_abort (); IT_menu_make_room (menu); menu->submenu[menu->count] = IT_menu_create (); @@ -4120,7 +4119,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, FD_ZERO (efds); if (nfds != 1) - abort (); + emacs_abort (); /* If we are looking only for the terminal, with no timeout, just read it and wait -- that's more efficient. */ @@ -4215,26 +4214,8 @@ init_gettimeofday (void) } #endif -#ifdef abort -#undef abort void -dos_abort (char *file, int line) -{ - char buffer1[200], buffer2[400]; - int i, j; - - sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); - for (i = j = 0; buffer1[i]; i++) { - buffer2[j++] = buffer1[i]; - buffer2[j++] = 0x70; - } - dosmemput (buffer2, j, (int)ScreenPrimary); - ScreenSetCursor (2, 0); - abort (); -} -#else -void -abort (void) +emacs_abort (void) { dos_ttcooked (); ScreenSetCursor (10, 0); @@ -4250,7 +4231,6 @@ abort (void) #endif /* __DJGPP_MINOR__ >= 2 */ exit (2); } -#endif void syms_of_msdos (void) diff --git a/src/ns.mk b/src/ns.mk deleted file mode 100644 index 77fbf5845d9..00000000000 --- a/src/ns.mk +++ /dev/null @@ -1,39 +0,0 @@ -### autodeps.mk --- src/Makefile fragment for GNU Emacs - -## Copyright (C) 2008-2012 Free Software Foundation, Inc. - -## This file is part of GNU Emacs. - -## GNU Emacs is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## GNU Emacs is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. - -### Commentary: - -## This is inserted in src/Makefile if HAVE_NS. - -## The only reason this is in a separate file is because $ns_appdir, -## which appears as a target, is empty on non-NS builds. Some makes -## do not like empty targets, even if they are never used. - -${ns_appdir}: ${ns_appsrc} - rm -fr ${ns_appdir} - ${MKDIR_P} ${ns_appdir} - ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - ) - -${ns_appbindir}/Emacs: emacs${EXEEXT} - ${MKDIR_P} ${ns_appbindir} - cp -f emacs${EXEEXT} ${ns_appbindir}/Emacs - -ns-app: ${ns_appdir} ${ns_appbindir}/Emacs - -### ns.mk ends here diff --git a/src/nsfns.m b/src/nsfns.m index e8b5d22077a..072005d2d3d 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -30,9 +30,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) interpretation of even the system includes. */ #include <config.h> -#include <signal.h> #include <math.h> -#include <setjmp.h> #include <c-strcase.h> #include "lisp.h" @@ -1798,19 +1796,6 @@ terminate Emacs if we can't open the connection. SSDATA (display)); } - /* Register our external input/output types, used for determining - applicable services and also drag/drop eligibility. */ - ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; - ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] - retain]; - ns_drag_types = [[NSArray arrayWithObjects: - NSStringPboardType, - NSTabularTextPboardType, - NSFilenamesPboardType, - NSURLPboardType, - NSColorPboardType, - NSFontPboardType, nil] retain]; - return Qnil; } diff --git a/src/nsfont.m b/src/nsfont.m index 412a6777c64..eba1eb04765 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -23,7 +23,6 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "dispextern.h" @@ -625,7 +624,7 @@ static unsigned int nsfont_encode_char (struct font *font, int c); static int nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics); static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, - int with_background); + bool with_background); struct font_driver nsfont_driver = { @@ -833,7 +832,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) font = (struct font *) font_info; font->pixel_size = [sfont pointSize]; font->driver = &nsfont_driver; - font->encoding_type = FONT_ENCODING_NOT_DECIDED; font->encoding_charset = -1; font->repertory_charset = -1; font->default_ascent = 0; @@ -1042,12 +1040,12 @@ nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs, /* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel - position of frame F with S->FACE and S->GC. If WITH_BACKGROUND - is nonzero, fill the background in advance. It is assured that - WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ + position of frame F with S->FACE and S->GC. If WITH_BACKGROUND, + fill the background in advance. It is assured that WITH_BACKGROUND + is false when (FROM > 0 || TO < S->nchars). */ static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, - int with_background) + bool with_background) /* NOTE: focus and clip must be set also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ { @@ -1330,7 +1328,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); if (!unichars || !(font_info->glyphs[block])) - abort (); + emacs_abort (); /* create a string containing all Unicode characters in this block */ for (idx = block<<8, i = 0; i < 0x100; idx++, i++) @@ -1405,7 +1403,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); if (!(font_info->metrics[block])) - abort (); + emacs_abort (); metrics = font_info->metrics[block]; for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) diff --git a/src/nsimage.m b/src/nsimage.m index 8a8a3ddaae4..668664c7a20 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -28,7 +28,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "dispextern.h" diff --git a/src/nsmenu.m b/src/nsmenu.m index 9e290486213..907d3eac622 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -24,7 +24,6 @@ Carbon version by Yamamoto Mitsuharu. */ /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "window.h" @@ -589,10 +588,7 @@ extern NSString *NSMenuDidBeginTrackingNotification; From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the key press case, NSMenuPropertyItemImage (e.g.) won't be set. */ - if (trackingMenu == 0 - /* Also, don't try this if from an event picked up asynchronously, - as lots of lisp evaluation happens in ns_update_menubar. */ - || handling_signal != 0) + if (trackingMenu == 0) return; /*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ ns_update_menubar (frame, 1, self); @@ -948,7 +944,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, else if (EQ (type, QCradio)) wv->button_type = BUTTON_TYPE_RADIO; else - abort (); + emacs_abort (); wv->selected = !NILP (selected); diff --git a/src/nsselect.m b/src/nsselect.m index e0bbfe58636..95bc1a95957 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -28,7 +28,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "nsterm.h" diff --git a/src/nsterm.h b/src/nsterm.h index f0cae193005..f3adab883a1 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -103,6 +103,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - (void) setWindowClosing: (BOOL)closing; - (EmacsToolbar *) toolbar; - (void) deleteWorkingText; +- (void) updateFrameSize: (BOOL) delay; #ifdef NS_IMPL_GNUSTEP /* Not declared, but useful. */ diff --git a/src/nsterm.m b/src/nsterm.m index c892a5486a7..0b26508dbd0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -35,7 +35,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) #include <time.h> #include <signal.h> #include <unistd.h> -#include <setjmp.h> #include <c-ctype.h> #include <c-strcase.h> @@ -627,6 +626,8 @@ ns_update_begin (struct frame *f) -------------------------------------------------------------------------- */ { NSView *view = FRAME_NS_VIEW (f); + NSRect r = [view frame]; + NSBezierPath *bp; NSTRACE (ns_update_begin); ns_update_auto_hide_menu_bar (); @@ -634,6 +635,14 @@ ns_update_begin (struct frame *f) ns_updating_frame = f; [view lockFocus]; + /* drawRect may have been called for say the minibuffer, and then clip path + is for the minibuffer. But the display engine may draw more because + we have set the frame as garbaged. So reset clip path to the whole + view. */ + bp = [[NSBezierPath bezierPathWithRect: r] retain]; + [bp setClip]; + [bp release]; + #ifdef NS_IMPL_GNUSTEP uRect = NSMakeRect (0, 0, 0, 0); #endif @@ -650,7 +659,6 @@ ns_update_window_begin (struct window *w) struct frame *f = XFRAME (WINDOW_FRAME (w)); Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); NSTRACE (ns_update_window_begin); - updated_window = w; set_output_cursor (&w->cursor); @@ -871,25 +879,12 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, int area, BOOL gc) window_box (w, area, &window_x, &window_y, &window_width, 0); - clip_rect.origin.x = window_x - FRAME_INTERNAL_BORDER_WIDTH (f); + clip_rect.origin.x = window_x; clip_rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y)); clip_rect.origin.y = max (clip_rect.origin.y, window_y); - clip_rect.size.width = window_width + 2 * FRAME_INTERNAL_BORDER_WIDTH (f); + clip_rect.size.width = window_width; clip_rect.size.height = row->visible_height; - /* allow a full-height row at the top when requested - (used to draw fringe all the way through internal border area) */ - if (gc && clip_rect.origin.y < 5) - { - clip_rect.origin.y -= FRAME_INTERNAL_BORDER_WIDTH (f); - clip_rect.size.height += FRAME_INTERNAL_BORDER_WIDTH (f); - } - - /* likewise at bottom */ - if (gc && - FRAME_PIXEL_HEIGHT (f) - (clip_rect.origin.y + clip_rect.size.height) < 5) - clip_rect.size.height += FRAME_INTERNAL_BORDER_WIDTH (f); - ns_focus (f, &clip_rect, 1); } @@ -1237,18 +1232,10 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) NSRect wr = [window frame]; int tb = FRAME_EXTERNAL_TOOL_BAR (f); int pixelwidth, pixelheight; - static int oldRows, oldCols, oldFontWidth, oldFontHeight; - static int oldTB; - static struct frame *oldF; NSTRACE (x_set_window_size); - if (view == nil || - (f == oldF - && rows == oldRows && cols == oldCols - && oldFontWidth == FRAME_COLUMN_WIDTH (f) - && oldFontHeight == FRAME_LINE_HEIGHT (f) - && oldTB == tb)) + if (view == nil) return; /*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */ @@ -1256,12 +1243,6 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) BLOCK_INPUT; check_frame_size (f, &rows, &cols); - oldF = f; - oldRows = rows; - oldCols = cols; - oldFontWidth = FRAME_COLUMN_WIDTH (f); - oldFontHeight = FRAME_LINE_HEIGHT (f); - oldTB = tb; f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); compute_fringe_widths (f, 0); @@ -1939,7 +1920,7 @@ ns_redraw_scroll_bars (struct frame *f) int i; id view; NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; - NSTRACE (ns_judge_scroll_bars); + NSTRACE (ns_redraw_scroll_bars); for (i =[subviews count]-1; i >= 0; i--) { view = [subviews objectAtIndex: i]; @@ -2125,9 +2106,9 @@ ns_after_update_window_line (struct glyph_row *desired_row) desired_row->redraw_fringe_bitmaps_p = 1; /* When a window has disappeared, make sure that no rest of - full-width rows stays visible in the internal border. - Under NS this is drawn inside the fringes. */ + full-width rows stays visible in the internal border. */ if (windows_or_buffers_changed + && desired_row->full_width_p && (f = XFRAME (w->frame), width = FRAME_INTERNAL_BORDER_WIDTH (f), width != 0) @@ -2136,24 +2117,11 @@ ns_after_update_window_line (struct glyph_row *desired_row) { int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); - /* Internal border is drawn below the tool bar. */ - if (WINDOWP (f->tool_bar_window) - && w == XWINDOW (f->tool_bar_window)) - y -= width; - /* end copy from other terms */ - BLOCK_INPUT; - if (!desired_row->full_width_p) - { - int x1 = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w) - + WINDOW_LEFT_FRINGE_WIDTH (w); - int x2 = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w) - + FRAME_PIXEL_WIDTH (f) - NS_SCROLL_BAR_WIDTH (f) - - WINDOW_RIGHT_FRINGE_WIDTH (w) - - FRAME_INTERNAL_BORDER_WIDTH (f); - ns_clear_frame_area (f, x1, y, width, height); - ns_clear_frame_area (f, x2, y, width, height); - } + ns_clear_frame_area (f, 0, y, width, height); + ns_clear_frame_area (f, + FRAME_PIXEL_WIDTH (f) - width, + y, width, height); UNBLOCK_INPUT; } } @@ -2238,17 +2206,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, int rowY; static EmacsImage **bimgs = NULL; static int nBimgs = 0; - /* NS-specific: move internal border inside fringe */ - int x = p->bx < 0 ? p->x : p->bx; - int wd = p->bx < 0 ? p->wd : p->nx; - BOOL fringeOnVeryLeft - = x - WINDOW_LEFT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w) - - FRAME_INTERNAL_BORDER_WIDTH (f) < 10; - BOOL fringeOnVeryRight - = FRAME_PIXEL_WIDTH (f) - x - wd - FRAME_INTERNAL_BORDER_WIDTH (f) - - WINDOW_RIGHT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w) < 10; - int xAdjust = FRAME_INTERNAL_BORDER_WIDTH (f) * - (fringeOnVeryLeft ? -1 : (fringeOnVeryRight ? 1 : 0)); /* grow bimgs if needed */ if (nBimgs < max_used_fringe_bitmap) @@ -2263,22 +2220,68 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); ns_clip_to_row (w, row, -1, YES); - if (p->bx >= 0 && !p->overlay_p) + if (!p->overlay_p) { - int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ? - -FRAME_INTERNAL_BORDER_WIDTH (f) : 0; - int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ? - FRAME_INTERNAL_BORDER_WIDTH (f) : 0 - + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0); - NSRect r = NSMakeRect (p->bx+xAdjust, p->by+yAdjust, p->nx, p->ny+yIncr); - NSRectClip (r); - [ns_lookup_indexed_color(face->background, f) set]; - NSRectFill (r); + int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny; + + /* If the fringe is adjacent to the left (right) scroll bar of a + leftmost (rightmost, respectively) window, then extend its + background to the gap between the fringe and the bar. */ + if ((WINDOW_LEFTMOST_P (w) + && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)) + || (WINDOW_RIGHTMOST_P (w) + && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))) + { + int sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w); + + if (sb_width > 0) + { + int bar_area_x = WINDOW_SCROLL_BAR_AREA_X (w); + int bar_area_width = (WINDOW_CONFIG_SCROLL_BAR_COLS (w) + * FRAME_COLUMN_WIDTH (f)); + + if (bx < 0) + { + /* Bitmap fills the fringe. */ + if (bar_area_x + bar_area_width == p->x) + bx = bar_area_x + sb_width; + else if (p->x + p->wd == bar_area_x) + bx = bar_area_x; + if (bx >= 0) + { + int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w); + + nx = bar_area_width - sb_width; + by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, + row->y)); + ny = row->visible_height; + } + } + else + { + if (bar_area_x + bar_area_width == bx) + { + bx = bar_area_x + sb_width; + nx += bar_area_width - sb_width; + } + else if (bx + nx == bar_area_x) + nx += bar_area_width - sb_width; + } + } + } + + if (bx >= 0 && nx > 0) + { + NSRect r = NSMakeRect (bx, by, nx, ny); + NSRectClip (r); + [ns_lookup_indexed_color (face->background, f) set]; + NSRectFill (r); + } } if (p->which) { - NSRect r = NSMakeRect (p->x+xAdjust, p->y, p->wd, p->h); + NSRect r = NSMakeRect (p->x, p->y, p->wd, p->h); EmacsImage *img = bimgs[p->which - 1]; if (!img) @@ -2288,7 +2291,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, int i; unsigned char *cbits = xmalloc (len); - for (i =0; i<len; i++) + for (i = 0; i < len; i++) cbits[i] = ~(bits[i] & 0xff); img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h flip: NO]; @@ -2302,12 +2305,20 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, [ns_lookup_indexed_color(face->background, f) set]; NSRectFill (r); [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)]; +#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 [img drawInRect: r fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0 respectFlipped: YES hints: nil]; +#else + { + NSPoint pt = r.origin; + pt.y += p->h; + [img compositeToPoint: pt operation: NSCompositeSourceOver]; + } +#endif } ns_unfocus (f); } @@ -2386,14 +2397,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, r.size.height = h; r.size.width = w->phys_cursor_width; - /* FIXME: if we overwrite the internal border area, it does not get erased; - fix by truncating cursor, but better would be to erase properly */ - overspill = r.origin.x + r.size.width - - WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w) - - WINDOW_TOTAL_FRINGE_WIDTH (w) - FRAME_INTERNAL_BORDER_WIDTH (f)); - if (overspill > 0) - r.size.width -= overspill; - /* TODO: only needed in rare cases with last-resort font in HELLO.. should we do this more efficiently? */ ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */ @@ -2517,31 +2520,6 @@ hide_hourglass (void) ========================================================================== */ - -static inline NSRect -ns_fix_rect_ibw (NSRect r, int fibw, int frame_pixel_width) -/* -------------------------------------------------------------------------- - Under NS we draw internal borders inside fringes, and want full-width - rendering to go all the way to edge. This function makes that correction. - -------------------------------------------------------------------------- */ -{ - if (r.origin.y <= fibw+1) - { - r.size.height += r.origin.y; - r.origin.y = 0; - } - if (r.origin.x <= fibw+1) - { - r.size.width += r.origin.x; - r.origin.x = 0; - } - if (frame_pixel_width - (r.origin.x+r.size.width) <= fibw+1) - r.size.width += fibw; - - return r; -} - - static int ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) /* -------------------------------------------------------------------------- @@ -2551,14 +2529,6 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) -------------------------------------------------------------------------- */ { int n = get_glyph_string_clip_rects (s, nr, 2); - if (s->row->full_width_p) - { - *nr = ns_fix_rect_ibw (*nr, FRAME_INTERNAL_BORDER_WIDTH (s->f), - FRAME_PIXEL_WIDTH (s->f)); - if (n == 2) - *nr = ns_fix_rect_ibw (*(nr+1), FRAME_INTERNAL_BORDER_WIDTH (s->f), - FRAME_PIXEL_WIDTH (s->f)); - } return n; } @@ -2883,11 +2853,6 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s) r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height); - /* expand full-width row over internal borders */ - if (s->row->full_width_p) - r = ns_fix_rect_ibw (r, FRAME_INTERNAL_BORDER_WIDTH (s->f), - FRAME_PIXEL_WIDTH (s->f)); - /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */ if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color) { @@ -2943,26 +2908,6 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p) NSRect r = NSMakeRect (s->x, s->y + box_line_width, s->background_width, s->height-2*box_line_width); - - /* expand full-width row over internal borders */ - if (s->row->full_width_p) - { - int fibw = FRAME_INTERNAL_BORDER_WIDTH (s->f); - if (r.origin.y <= fibw+1 + box_line_width) - { - r.size.height += r.origin.y; - r.origin.y = 0; - } - if (r.origin.x <= fibw+1) - { - r.size.width += 2*r.origin.x; - r.origin.x = 0; - } - if (FRAME_PIXEL_WIDTH (s->f) - (r.origin.x + r.size.width) - <= fibw+1) - r.size.width += fibw; - } - NSRectFill (r); } @@ -3028,34 +2973,23 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r) br = NSMakeRect (x, y, s->slice.width, s->slice.height); } - /* expand full-width row over internal borders */ - if (s->row->full_width_p) - { - int fibw = FRAME_INTERNAL_BORDER_WIDTH (s->f); - if (br.origin.y <= fibw+1 + box_line_vwidth) - { - br.size.height += br.origin.y; - br.origin.y = 0; - } - if (br.origin.x <= fibw+1 + box_line_vwidth) - { - br.size.width += br.origin.x; - br.origin.x = 0; - } - if (FRAME_PIXEL_WIDTH (s->f) - (br.origin.x + br.size.width) <= fibw+1) - br.size.width += fibw; - } - NSRectFill (br); /* Draw the image.. do we need to draw placeholder if img ==nil? */ if (img != nil) + { +#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 [img drawInRect: br - fromRect: NSZeroRect + fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0 respectFlipped: YES hints: nil]; +#else + [img compositeToPoint: NSMakePoint (x, y + s->slice.height) + operation: NSCompositeSourceOver]; +#endif + } if (s->hl == DRAW_CURSOR) { @@ -3143,7 +3077,7 @@ ns_dumpglyphs_stretch (struct glyph_string *s) bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f); fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); - for (i=0; i<n; i++) + for (i = 0; i < n; ++i) { if (!s->row->full_width_p) { @@ -3173,13 +3107,6 @@ ns_dumpglyphs_stretch (struct glyph_string *s) r[i].size.height = min (s->height, s->row->visible_height); } - /* expand full-width rows over internal borders */ - else - { - r[i] = ns_fix_rect_ibw (r[i], FRAME_INTERNAL_BORDER_WIDTH (s->f), - FRAME_PIXEL_WIDTH (s->f)); - } - [bgCol set]; /* NOTE: under NS this is NOT used to draw cursors, but we must avoid @@ -3340,7 +3267,7 @@ ns_draw_glyph_string (struct glyph_string *s) break; default: - abort (); + emacs_abort (); } /* Draw box if not done already. */ @@ -3428,16 +3355,12 @@ ns_read_socket (struct terminal *terminal, int expected, if (interrupt_input_blocked) { interrupt_input_pending = 1; -#ifdef SYNC_INPUT pending_signals = 1; -#endif return -1; } interrupt_input_pending = 0; -#ifdef SYNC_INPUT pending_signals = pending_atimers; -#endif BLOCK_INPUT; n_emacs_events_pending = 0; @@ -3475,7 +3398,7 @@ ns_read_socket (struct terminal *terminal, int expected, if (++apploopnr != 1) { - abort (); + emacs_abort (); } [NSApp run]; --apploopnr; @@ -3515,7 +3438,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, [outerpool release]; outerpool = [[NSAutoreleasePool alloc] init]; - + send_appdefined = YES; if (nr > 0) { @@ -3568,7 +3491,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, emacs_event = &event; if (++apploopnr != 1) { - abort(); + emacs_abort (); } [NSApp run]; --apploopnr; @@ -3586,7 +3509,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, { int t; if ([ev type] != NSApplicationDefined) - abort (); + emacs_abort (); t = [ev data1]; last_appdefined_event = 0; @@ -3639,9 +3562,9 @@ ns_set_vertical_scroll_bar (struct window *window, struct frame *f = XFRAME (WINDOW_FRAME (window)); EmacsView *view = FRAME_NS_VIEW (f); int window_y, window_height; - BOOL barOnVeryLeft, barOnVeryRight; int top, left, height, width, sb_width, sb_left; EmacsScroller *bar; + BOOL fringe_extended_p; /* optimization; display engine sends WAY too many of these.. */ if (!NILP (window->vertical_scroll_bar)) @@ -3668,26 +3591,27 @@ ns_set_vertical_scroll_bar (struct window *window, width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f); left = WINDOW_SCROLL_BAR_AREA_X (window); - if (top < 5) /* top scrollbar adjustment */ - { - top -= FRAME_INTERNAL_BORDER_WIDTH (f); - height += FRAME_INTERNAL_BORDER_WIDTH (f); - } - /* allow for displaying a skinnier scrollbar than char area allotted */ sb_width = (WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) > 0) ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) : width; - - barOnVeryLeft = left < 5; - barOnVeryRight = FRAME_PIXEL_WIDTH (f) - left - width < 5; - sb_left = left + FRAME_INTERNAL_BORDER_WIDTH (f) - * (barOnVeryLeft ? -1 : (barOnVeryRight ? 1 : 0)); + sb_left = left; r = NSMakeRect (sb_left, top, sb_width, height); /* the parent view is flipped, so we need to flip y value */ v = [view frame]; r.origin.y = (v.size.height - r.size.height - r.origin.y); + if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (window)) + fringe_extended_p = (WINDOW_LEFTMOST_P (window) + && WINDOW_LEFT_FRINGE_WIDTH (window) + && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window) + || WINDOW_LEFT_MARGIN_COLS (window) == 0)); + else + fringe_extended_p = (WINDOW_RIGHTMOST_P (window) + && WINDOW_RIGHT_FRINGE_WIDTH (window) + && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window) + || WINDOW_RIGHT_MARGIN_COLS (window) == 0)); + XSETWINDOW (win, window); BLOCK_INPUT; @@ -3707,7 +3631,14 @@ ns_set_vertical_scroll_bar (struct window *window, if (NILP (window->vertical_scroll_bar)) { - ns_clear_frame_area (f, sb_left, top, width, height); + if (width > 0 && height > 0) + { + if (fringe_extended_p) + ns_clear_frame_area (f, sb_left, top, sb_width, height); + else + ns_clear_frame_area (f, left, top, width, height); + } + bar = [[EmacsScroller alloc] initFrame: r window: win]; wset_vertical_scroll_bar (window, make_save_value (bar, 0)); } @@ -3778,14 +3709,21 @@ ns_judge_scroll_bars (struct frame *f) { int i; id view; - NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; + EmacsView *eview = FRAME_NS_VIEW (f); + NSArray *subviews = [[eview superview] subviews]; + BOOL removed = NO; + NSTRACE (ns_judge_scroll_bars); - for (i =[subviews count]-1; i >= 0; i--) + for (i = [subviews count]-1; i >= 0; --i) { view = [subviews objectAtIndex: i]; if (![view isKindOfClass: [EmacsScroller class]]) continue; [view judge]; + removed = YES; } + + if (removed) + [eview updateFrameSize: NO]; } @@ -4035,33 +3973,34 @@ ns_term_init (Lisp_Object display_name) static int ns_initialized = 0; Lisp_Object tmp; + if (ns_initialized) return x_display_list; + ns_initialized = 1; + NSTRACE (ns_term_init); + [outerpool release]; + outerpool = [[NSAutoreleasePool alloc] init]; + /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */ /*GSDebugAllocationActive (YES); */ BLOCK_INPUT; - handling_signal = 0; - if (!ns_initialized) - { - baud_rate = 38400; - Fset_input_interrupt_mode (Qnil); + baud_rate = 38400; + Fset_input_interrupt_mode (Qnil); - if (selfds[0] == -1) + if (selfds[0] == -1) + { + if (pipe (selfds) == -1) { - if (pipe (selfds) == -1) - { - fprintf (stderr, "Failed to create pipe: %s\n", - emacs_strerror (errno)); - abort (); - } - - fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); - FD_ZERO (&select_readfds); - FD_ZERO (&select_writefds); - pthread_mutex_init (&select_mutex, NULL); + fprintf (stderr, "Failed to create pipe: %s\n", + emacs_strerror (errno)); + emacs_abort (); } - ns_initialized = 1; + + fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); + FD_ZERO (&select_readfds); + FD_ZERO (&select_writefds); + pthread_mutex_init (&select_mutex, NULL); } ns_pending_files = [[NSMutableArray alloc] init]; @@ -4252,6 +4191,20 @@ ns_term_init (Lisp_Object display_name) } #endif /* MAC OS X menu setup */ + /* Register our external input/output types, used for determining + applicable services and also drag/drop eligibility. */ + ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; + ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] + retain]; + ns_drag_types = [[NSArray arrayWithObjects: + NSStringPboardType, + NSTabularTextPboardType, + NSFilenamesPboardType, + NSURLPboardType, + NSColorPboardType, + NSFontPboardType, nil] retain]; + + [NSApp run]; ns_do_open_file = YES; return dpyinfo; @@ -4273,7 +4226,7 @@ ns_term_shutdown (int sig) } else // force a stack trace to happen { - abort(); + emacs_abort (); } } @@ -4534,10 +4487,10 @@ not_in_argv (NSString *arg) /* Don't open files from the command line unconditionally, Cocoa parses the command line wrong, --option value tries to open value if --option is the last option. */ - while ((file = [files nextObject]) != nil) + while ((file = [files nextObject]) != nil) if (ns_do_open_file || not_in_argv (file)) [ns_pending_files addObject: file]; - + [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; } @@ -4604,7 +4557,7 @@ not_in_argv (NSString *arg) /* NSTRACE (fd_handler); */ - for (;;) + for (;;) { [pool release]; pool = [[NSAutoreleasePool alloc] init]; @@ -4889,7 +4842,7 @@ not_in_argv (NSString *arg) is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask; is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask); - + if (is_right_key) emacs_event->modifiers |= parse_solitary_modifier (EQ (ns_right_command_modifier, Qleft) @@ -5420,6 +5373,50 @@ not_in_argv (NSString *arg) return NO; } +- (void) updateFrameSize: (BOOL) delay; +{ + NSWindow *window = [self window]; + NSRect wr = [window frame]; +#ifdef NS_IMPL_GNUSTEP + int extra = 3; +#else + int extra = 0; +#endif + + int oldc = cols, oldr = rows; + int oldw = FRAME_PIXEL_WIDTH (emacsframe), + oldh = FRAME_PIXEL_HEIGHT (emacsframe); + int neww, newh; + + cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + extra); + + if (cols < MINWIDTH) + cols = MINWIDTH; + + rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES + (emacsframe, wr.size.height + - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + extra + - FRAME_TOOLBAR_HEIGHT (emacsframe)); + + if (rows < MINHEIGHT) + rows = MINHEIGHT; + + neww = (int)wr.size.width - emacsframe->border_width; + newh = ((int)wr.size.height + - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + - FRAME_TOOLBAR_HEIGHT (emacsframe)); + + if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) + { + NSView *view = FRAME_NS_VIEW (emacsframe); + FRAME_PIXEL_WIDTH (emacsframe) = neww; + FRAME_PIXEL_HEIGHT (emacsframe) = newh; + change_frame_size (emacsframe, rows, cols, 0, delay, 0); + SET_FRAME_GARBAGED (emacsframe); + cancel_mouse_face (emacsframe); + [view setFrame: NSMakeRect (0, 0, neww, newh)]; + } +} - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize /* normalize frame to gridded text size */ @@ -5517,16 +5514,7 @@ not_in_argv (NSString *arg) x_set_window_size (emacsframe, 0, cols, rows); else { - NSWindow *window = [self window]; - NSRect wr = [window frame]; - FRAME_PIXEL_WIDTH (emacsframe) = (int)wr.size.width - - emacsframe->border_width; - FRAME_PIXEL_HEIGHT (emacsframe) = (int)wr.size.height - - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) - - FRAME_TOOLBAR_HEIGHT (emacsframe); - change_frame_size (emacsframe, rows, cols, 0, 0, 1); - SET_FRAME_GARBAGED (emacsframe); - cancel_mouse_face (emacsframe); + [self updateFrameSize: YES]; } } #endif @@ -5853,7 +5841,7 @@ not_in_argv (NSString *arg) NSTRACE (menuDown); if (context_menu_value == -1) context_menu_value = [sender tag]; - else + else { NSInteger tag = [sender tag]; find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used, @@ -6180,7 +6168,7 @@ not_in_argv (NSString *arg) Lisp_Object str = Qnil; struct frame *f = SELECTED_FRAME (); struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); - + if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) return NSAccessibilityTextFieldRole; @@ -6193,13 +6181,13 @@ not_in_argv (NSString *arg) { if (! NILP (BVAR (curbuf, mark_active))) str = ns_get_local_selection (QPRIMARY, QUTF8_STRING); - + if (NILP (str)) { ptrdiff_t start_byte = BUF_BEGV_BYTE (curbuf); ptrdiff_t byte_range = BUF_ZV_BYTE (curbuf) - start_byte; ptrdiff_t range = BUF_ZV (curbuf) - BUF_BEGV (curbuf); - + if (! NILP (BVAR (curbuf, enable_multibyte_characters))) str = make_uninit_multibyte_string (range, byte_range); else @@ -6209,9 +6197,9 @@ not_in_argv (NSString *arg) memcpy (SDATA (str), BYTE_POS_ADDR (start_byte), byte_range); } } - - - if (! NILP (str)) + + + if (! NILP (str)) { if (CONSP (str) && SYMBOLP (XCAR (str))) { @@ -6226,7 +6214,7 @@ not_in_argv (NSString *arg) return nsStr; } } - + return [super accessibilityAttributeValue:attribute]; } #endif /* NS_IMPL_COCOA */ @@ -6242,7 +6230,10 @@ not_in_argv (NSString *arg) NSTRACE (constrainFrameRect); if (nr_screens == 1) - return [super constrainFrameRect:frameRect toScreen:screen]; + { + NSRect r = [super constrainFrameRect:frameRect toScreen:screen]; + return r; + } if (f->output_data.ns->dont_constrain || ns_menu_bar_should_be_hidden ()) diff --git a/src/print.c b/src/print.c index 52c07c79122..aae13bb6764 100644 --- a/src/print.c +++ b/src/print.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" @@ -45,15 +45,9 @@ static Lisp_Object Qtemp_buffer_setup_hook; static Lisp_Object Qfloat_output_format; -#include <math.h> #include <float.h> #include <ftoastr.h> -/* Default to values appropriate for IEEE floating point. */ -#ifndef DBL_DIG -#define DBL_DIG 15 -#endif - /* Avoid actual stack overflow in print. */ static ptrdiff_t print_depth; @@ -1879,7 +1873,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag } else if (BUFFERP (obj)) { - if (NILP (BVAR (XBUFFER (obj), name))) + if (!BUFFER_LIVE_P (XBUFFER (obj))) strout ("#<killed buffer>", -1, -1, printcharfun); else if (escapeflag) { @@ -2060,7 +2054,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag { int len; /* We're in trouble if this happens! - Probably should just abort () */ + Probably should just emacs_abort (). */ strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); if (MISCP (obj)) len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); diff --git a/src/process.c b/src/process.c index b45ba733636..6f48463b85b 100644 --- a/src/process.c +++ b/src/process.c @@ -23,15 +23,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define PROCESS_INLINE EXTERN_INLINE -#include <signal.h> #include <stdio.h> #include <errno.h> -#include <setjmp.h> #include <sys/types.h> /* Some typedefs are used in sys/file.h. */ #include <sys/file.h> #include <sys/stat.h> -#include <setjmp.h> - #include <unistd.h> #include <fcntl.h> @@ -76,6 +72,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <bsdtty.h> #endif +#ifdef USG5_4 +# include <sys/stream.h> +# include <sys/stropts.h> +#endif + #ifdef HAVE_RES_INIT #include <netinet/in.h> #include <arpa/nameser.h> @@ -124,6 +125,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "xgselect.h" #endif +#ifndef WNOHANG +# undef waitpid +# define waitpid(pid, status, options) wait (status) +#endif +#ifndef WUNTRACED +# define WUNTRACED 0 +#endif + /* Work around GCC 4.7.0 bug with strict overflow checking; see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. These lines can be removed once the GCC bug is fixed. */ @@ -165,16 +174,6 @@ static Lisp_Object QClocal, QCremote, QCcoding; static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; static Lisp_Object QCsentinel, QClog, QCoptions, QCplist; static Lisp_Object Qlast_nonmenu_event; -/* QCfamily is declared and initialized in xfaces.c, - QCfilter in keyboard.c. */ -extern Lisp_Object QCfamily, QCfilter; - -/* Qexit is declared and initialized in eval.c. */ - -/* QCfamily is defined in xfaces.c. */ -extern Lisp_Object QCfamily; -/* QCfilter is defined in keyboard.c. */ -extern Lisp_Object QCfilter; #define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) #define NETCONN1_P(p) (EQ (p->type, Qnetwork)) @@ -215,17 +214,13 @@ static EMACS_INT update_tick; "non-destructive" select. So we require either native select, or emulation of select using FIONREAD. */ -#ifdef BROKEN_DATAGRAM_SOCKETS -#undef DATAGRAM_SOCKETS -#else -#ifndef DATAGRAM_SOCKETS -#if defined (HAVE_SELECT) || defined (FIONREAD) -#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) -#define DATAGRAM_SOCKETS -#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */ -#endif /* HAVE_SELECT || FIONREAD */ -#endif /* DATAGRAM_SOCKETS */ -#endif /* BROKEN_DATAGRAM_SOCKETS */ +#ifndef BROKEN_DATAGRAM_SOCKETS +# if defined HAVE_SELECT || defined USABLE_FIONREAD +# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE +# define DATAGRAM_SOCKETS +# endif +# endif +#endif #if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS # define HAVE_SEQPACKET @@ -254,7 +249,7 @@ static int process_output_skip; #endif static void create_process (Lisp_Object, char **, Lisp_Object); -#ifdef SIGIO +#ifdef USABLE_SIGIO static int keyboard_bit_set (SELECT_TYPE *); #endif static void deactivate_process (Lisp_Object); @@ -811,7 +806,7 @@ get_process (register Lisp_Object name) #ifdef SIGCHLD /* Fdelete_process promises to immediately forget about the process, but in reality, Emacs needs to remember those processes until they have been - treated by sigchld_handler; otherwise this handler would consider the + treated by the SIGCHLD handler; otherwise this handler would consider the process as being synchronous and say that the synchronous process is dead. */ static Lisp_Object deleted_pid_list; @@ -859,7 +854,8 @@ nil, indicating the current buffer's process. */) #endif { Fkill_process (process, Qnil); - /* Do this now, since remove_process will make sigchld_handler do nothing. */ + /* Do this now, since remove_process will make the + SIGCHLD handler do nothing. */ pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil))); p->tick = ++process_tick; status_notify (p); @@ -1587,7 +1583,7 @@ static Lisp_Object start_process_unwind (Lisp_Object proc) { if (!PROCESSP (proc)) - abort (); + emacs_abort (); /* Was PROC started successfully? -2 is used for a pty with no process, eg for gdb. */ @@ -1613,15 +1609,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) int wait_child_setup[2]; #endif - sigset_t procmask; - sigset_t blocked; - struct sigaction sigint_action; - struct sigaction sigquit_action; - struct sigaction sigpipe_action; -#ifdef AIX - struct sigaction sighup_action; +#ifdef SIGCHLD + sigset_t blocked, procmask; #endif - /* Use volatile to protect variables from being clobbered by longjmp. */ + /* Use volatile to protect variables from being clobbered by vfork. */ volatile int forkin, forkout; volatile int pty_flag = 0; @@ -1713,32 +1704,20 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) XPROCESS (process)->pty_flag = pty_flag; pset_status (XPROCESS (process), Qrun); +#ifdef SIGCHLD /* Delay interrupts until we have a chance to store the new fork's pid in its process structure */ sigemptyset (&blocked); -#ifdef SIGCHLD sigaddset (&blocked, SIGCHLD); -#endif -#ifdef HAVE_WORKING_VFORK - /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal', - this sets the parent's signal handlers as well as the child's. - So delay all interrupts whose handlers the child might munge, - and record the current handlers so they can be restored later. */ - sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action ); - sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action); - sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action); -#ifdef AIX - sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action ); -#endif -#endif /* HAVE_WORKING_VFORK */ pthread_sigmask (SIG_BLOCK, &blocked, &procmask); +#endif FD_SET (inchannel, &input_wait_mask); FD_SET (inchannel, &non_keyboard_wait_mask); if (inchannel > max_process_desc) max_process_desc = inchannel; - /* Until we store the proper pid, enable sigchld_handler + /* Until we store the proper pid, enable the SIGCHLD handler to recognize an unknown pid as standing for this process. It is very important not to let this `marker' value stay in the table after this function has returned; if it does @@ -1766,12 +1745,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) int xforkin = forkin; int xforkout = forkout; -#if 0 /* This was probably a mistake--it duplicates code later on, - but fails to handle all the cases. */ - /* Make sure SIGCHLD is not blocked in the child. */ - sigsetmask (SIGEMPTYMASK); -#endif - /* Make the pty be the controlling terminal of the process. */ #ifdef HAVE_PTYS /* First, disconnect its current controlling terminal. */ @@ -1890,8 +1863,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) in the child. */ signal (SIGPIPE, SIG_DFL); +#ifdef SIGCHLD /* Stop blocking signals in the child. */ pthread_sigmask (SIG_SETMASK, &procmask, 0); +#endif if (pty_flag) child_setup_tty (xforkout); @@ -1970,19 +1945,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) #endif } - /* Restore the signal state whether vfork succeeded or not. - (We will signal an error, below, if it failed.) */ -#ifdef HAVE_WORKING_VFORK - /* Restore the parent's signal handlers. */ - sigaction (SIGINT, &sigint_action, 0); - sigaction (SIGQUIT, &sigquit_action, 0); - sigaction (SIGPIPE, &sigpipe_action, 0); -#ifdef AIX - sigaction (SIGHUP, &sighup_action, 0); -#endif -#endif /* HAVE_WORKING_VFORK */ +#ifdef SIGCHLD /* Stop blocking signals in the parent. */ pthread_sigmask (SIG_SETMASK, &procmask, 0); +#endif /* Now generate the error if vfork failed. */ if (pid < 0) @@ -2560,7 +2526,7 @@ static Lisp_Object make_serial_process_unwind (Lisp_Object proc) { if (!PROCESSP (proc)) - abort (); + emacs_abort (); remove_process (proc); return Qnil; } @@ -3397,7 +3363,7 @@ usage: (make-network-process &rest ARGS) */) if (socktype == SOCK_DGRAM) { if (datagram_address[s].sa) - abort (); + emacs_abort (); datagram_address[s].sa = xmalloc (lres->ai_addrlen); datagram_address[s].len = lres->ai_addrlen; if (is_server) @@ -3983,7 +3949,7 @@ deactivate_process (Lisp_Object proc) FD_CLR (inchannel, &connect_wait_mask); FD_CLR (inchannel, &write_mask); if (--num_pending_connects < 0) - abort (); + emacs_abort (); } #endif if (inchannel == max_process_desc) @@ -4406,10 +4372,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, Otherwise, do pending quit if requested. */ if (read_kbd >= 0) QUIT; -#ifdef SYNC_INPUT else process_pending_signals (); -#endif /* Exit now if the cell we're waiting for became non-nil. */ if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) @@ -4763,7 +4727,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, Cleanup occurs c/o status_notify after SIGCLD. */ no_avail = 1; /* Cannot depend on values returned */ #else - abort (); + emacs_abort (); #endif } else @@ -4846,7 +4810,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) break; -#ifdef SIGIO +#ifdef USABLE_SIGIO /* If we think we have keyboard input waiting, but didn't get SIGIO, go read it. This can happen with X on BSD after logging out. In that case, there really is no input and no SIGIO, @@ -4967,8 +4931,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (p->pid == -2) { - /* If the EIO occurs on a pty, sigchld_handler's - waitpid() will not find the process object to + /* If the EIO occurs on a pty, the SIGCHLD handler's + waitpid call will not find the process object to delete. Do it here. */ p->tick = ++process_tick; pset_status (p, Qfailed); @@ -5004,7 +4968,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, FD_CLR (channel, &connect_wait_mask); FD_CLR (channel, &write_mask); if (--num_pending_connects < 0) - abort (); + emacs_abort (); proc = chan_process[channel]; if (NILP (proc)) @@ -5205,7 +5169,7 @@ read_process_output (Lisp_Object proc, register int channel) if (!NILP (outstream)) { Lisp_Object text; - int outer_running_asynch_code = running_asynch_code; + bool outer_running_asynch_code = running_asynch_code; int waiting = waiting_for_user_input_p; /* No need to gcpro these, because all we do with them later @@ -5308,7 +5272,7 @@ read_process_output (Lisp_Object proc, register int channel) } /* If no filter, write into buffer if it isn't dead. */ - else if (!NILP (p->buffer) && !NILP (BVAR (XBUFFER (p->buffer), name))) + else if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) { Lisp_Object old_read_only; ptrdiff_t old_begv, old_zv; @@ -5430,19 +5394,23 @@ read_process_output (Lisp_Object proc, register int channel) /* Sending data to subprocess */ -static jmp_buf send_process_frame; +static sys_jmp_buf send_process_frame; static Lisp_Object process_sent_to; -#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD -static _Noreturn void send_process_trap (int); -#endif +static _Noreturn void +handle_pipe_signal (int sig) +{ + sigset_t unblocked; + sigemptyset (&unblocked); + sigaddset (&unblocked, SIGPIPE); + pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); + sys_longjmp (send_process_frame, 1); +} static void -send_process_trap (int ignore) +deliver_pipe_signal (int sig) { - SIGNAL_THREAD_CHECK (SIGPIPE); - sigunblock (sigmask (SIGPIPE)); - longjmp (send_process_frame, 1); + handle_on_main_thread (sig, handle_pipe_signal); } /* In send_process, when a write fails temporarily, @@ -5535,7 +5503,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, struct Lisp_Process *p = XPROCESS (proc); ssize_t rv; struct coding_system *coding; - void (*volatile old_sigpipe) (int); + struct sigaction old_sigpipe_action; if (p->raw_status_new) update_status (p); @@ -5645,7 +5613,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, CFLAGS="-g -O": The value of the parameter `proc' is clobbered when returning with longjmp despite being declared volatile. */ - if (!setjmp (send_process_frame)) + if (!sys_setjmp (send_process_frame)) { p = XPROCESS (proc); /* Repair any setjmp clobbering. */ process_sent_to = proc; @@ -5674,7 +5642,9 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, /* Send this batch, using one or more write calls. */ ptrdiff_t written = 0; int outfd = p->outfd; - old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap); + struct sigaction action; + emacs_sigaction_init (&action, deliver_pipe_signal); + sigaction (SIGPIPE, &action, &old_sigpipe_action); #ifdef DATAGRAM_SOCKETS if (DATAGRAM_CHAN_P (outfd)) { @@ -5685,7 +5655,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, written = rv; else if (errno == EMSGSIZE) { - signal (SIGPIPE, old_sigpipe); + sigaction (SIGPIPE, &old_sigpipe_action, 0); report_file_error ("sending datagram", Fcons (proc, Qnil)); } @@ -5710,7 +5680,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, } #endif } - signal (SIGPIPE, old_sigpipe); + sigaction (SIGPIPE, &old_sigpipe_action, 0); if (rv < 0) { @@ -5770,7 +5740,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, } else { - signal (SIGPIPE, old_sigpipe); + sigaction (SIGPIPE, &old_sigpipe_action, 0); proc = process_sent_to; p = XPROCESS (proc); p->raw_status_new = 0; @@ -6365,15 +6335,14 @@ process has been transmitted to the serial port. */) #endif /* not HAVE_SHUTDOWN */ new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); if (new_outfd < 0) - abort (); + emacs_abort (); old_outfd = XPROCESS (proc)->outfd; if (!proc_encode_coding_system[new_outfd]) proc_encode_coding_system[new_outfd] = xmalloc (sizeof (struct coding_system)); - memcpy (proc_encode_coding_system[new_outfd], - proc_encode_coding_system[old_outfd], - sizeof (struct coding_system)); + *proc_encode_coding_system[new_outfd] + = *proc_encode_coding_system[old_outfd]; memset (proc_encode_coding_system[old_outfd], 0, sizeof (struct coding_system)); @@ -6408,143 +6377,135 @@ process has been transmitted to the serial port. */) indirectly; if it does, that is a bug */ #ifdef SIGCHLD -static void -sigchld_handler (int signo) + +/* Record one child's changed status. Return true if a child was found. */ +static bool +record_child_status_change (void) { - int old_errno = errno; Lisp_Object proc; struct Lisp_Process *p; + pid_t pid; + int w; + Lisp_Object tail; - SIGNAL_THREAD_CHECK (signo); - - while (1) - { - pid_t pid; - int w; - Lisp_Object tail; - -#ifdef WNOHANG -#ifndef WUNTRACED -#define WUNTRACED 0 -#endif /* no WUNTRACED */ - /* Keep trying to get a status until we get a definitive result. */ - do - { - errno = 0; - pid = waitpid (-1, &w, WNOHANG | WUNTRACED); - } - while (pid < 0 && errno == EINTR); - - if (pid <= 0) - { - /* PID == 0 means no processes found, PID == -1 means a real - failure. We have done all our job, so return. */ + do + pid = waitpid (-1, &w, WNOHANG | WUNTRACED); + while (pid < 0 && errno == EINTR); - errno = old_errno; - return; - } -#else - pid = wait (&w); -#endif /* no WNOHANG */ + /* PID == 0 means no processes found, PID == -1 means a real failure. + Either way, we have done all our job. */ + if (pid <= 0) + return false; - /* Find the process that signaled us, and record its status. */ + /* Find the process that signaled us, and record its status. */ - /* The process can have been deleted by Fdelete_process. */ - for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) + /* The process can have been deleted by Fdelete_process. */ + for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) + { + Lisp_Object xpid = XCAR (tail); + if ((INTEGERP (xpid) && pid == XINT (xpid)) + || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid))) { - Lisp_Object xpid = XCAR (tail); - if ((INTEGERP (xpid) && pid == XINT (xpid)) - || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid))) - { - XSETCAR (tail, Qnil); - goto sigchld_end_of_loop; - } + XSETCAR (tail, Qnil); + return true; } + } - /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ + /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ + p = 0; + for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) + { + proc = XCDR (XCAR (tail)); + p = XPROCESS (proc); + if (EQ (p->type, Qreal) && p->pid == pid) + break; p = 0; - for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) - { - proc = XCDR (XCAR (tail)); - p = XPROCESS (proc); - if (EQ (p->type, Qreal) && p->pid == pid) - break; - p = 0; - } - - /* Look for an asynchronous process whose pid hasn't been filled - in yet. */ - if (p == 0) - for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) - { - proc = XCDR (XCAR (tail)); - p = XPROCESS (proc); - if (p->pid == -1) - break; - p = 0; - } - - /* Change the status of the process that was found. */ - if (p != 0) - { - int clear_desc_flag = 0; + } - p->tick = ++process_tick; - p->raw_status = w; - p->raw_status_new = 1; + /* Look for an asynchronous process whose pid hasn't been filled + in yet. */ + if (! p) + for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) + { + proc = XCDR (XCAR (tail)); + p = XPROCESS (proc); + if (p->pid == -1) + break; + p = 0; + } - /* If process has terminated, stop waiting for its output. */ - if ((WIFSIGNALED (w) || WIFEXITED (w)) - && p->infd >= 0) - clear_desc_flag = 1; + /* Change the status of the process that was found. */ + if (p) + { + int clear_desc_flag = 0; - /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ - if (clear_desc_flag) - { - FD_CLR (p->infd, &input_wait_mask); - FD_CLR (p->infd, &non_keyboard_wait_mask); - } + p->tick = ++process_tick; + p->raw_status = w; + p->raw_status_new = 1; - /* Tell wait_reading_process_output that it needs to wake up and - look around. */ - if (input_available_clear_time) - *input_available_clear_time = make_emacs_time (0, 0); - } + /* If process has terminated, stop waiting for its output. */ + if ((WIFSIGNALED (w) || WIFEXITED (w)) + && p->infd >= 0) + clear_desc_flag = 1; - /* There was no asynchronous process found for that pid: we have - a synchronous process. */ - else + /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ + if (clear_desc_flag) { - synch_process_alive = 0; - - /* Report the status of the synchronous process. */ - if (WIFEXITED (w)) - synch_process_retcode = WEXITSTATUS (w); - else if (WIFSIGNALED (w)) - synch_process_termsig = WTERMSIG (w); - - /* Tell wait_reading_process_output that it needs to wake up and - look around. */ - if (input_available_clear_time) - *input_available_clear_time = make_emacs_time (0, 0); + FD_CLR (p->infd, &input_wait_mask); + FD_CLR (p->infd, &non_keyboard_wait_mask); } - sigchld_end_of_loop: - ; + /* Tell wait_reading_process_output that it needs to wake up and + look around. */ + if (input_available_clear_time) + *input_available_clear_time = make_emacs_time (0, 0); + } + /* There was no asynchronous process found for that pid: we have + a synchronous process. */ + else + { + synch_process_alive = 0; + + /* Report the status of the synchronous process. */ + if (WIFEXITED (w)) + synch_process_retcode = WEXITSTATUS (w); + else if (WIFSIGNALED (w)) + synch_process_termsig = WTERMSIG (w); + + /* Tell wait_reading_process_output that it needs to wake up and + look around. */ + if (input_available_clear_time) + *input_available_clear_time = make_emacs_time (0, 0); + } + + return true; +} - /* On some systems, we must return right away. - If any more processes want to signal us, we will - get another signal. - Otherwise (on systems that have WNOHANG), loop around - to use up all the processes that have something to tell us. */ +/* On some systems, the SIGCHLD handler must return right away. If + any more processes want to signal us, we will get another signal. + Otherwise, loop around to use up all the processes that have + something to tell us. */ #if (defined WINDOWSNT \ || (defined USG && !defined GNU_LINUX \ && !(defined HPUX && defined WNOHANG))) - errno = old_errno; - return; -#endif /* USG, but not HPUX with WNOHANG */ - } +enum { CAN_HANDLE_MULTIPLE_CHILDREN = 0 }; +#else +enum { CAN_HANDLE_MULTIPLE_CHILDREN = 1 }; +#endif + +static void +handle_child_signal (int sig) +{ + while (record_child_status_change () && CAN_HANDLE_MULTIPLE_CHILDREN) + continue; } + +static void +deliver_child_signal (int sig) +{ + handle_on_main_thread (sig, handle_child_signal); +} + #endif /* SIGCHLD */ @@ -6569,9 +6530,9 @@ static void exec_sentinel (Lisp_Object proc, Lisp_Object reason) { Lisp_Object sentinel, odeactivate; - register struct Lisp_Process *p = XPROCESS (proc); + struct Lisp_Process *p = XPROCESS (proc); ptrdiff_t count = SPECPDL_INDEX (); - int outer_running_asynch_code = running_asynch_code; + bool outer_running_asynch_code = running_asynch_code; int waiting = waiting_for_user_input_p; if (inhibit_sentinels) @@ -6734,7 +6695,7 @@ status_notify (struct Lisp_Process *deleting_process) /* Avoid error if buffer is deleted (probably that's why the process is dead, too) */ - if (NILP (BVAR (XBUFFER (buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (buffer))) continue; Fset_buffer (buffer); @@ -6866,7 +6827,7 @@ delete_gpm_wait_descriptor (int desc) # endif -# ifdef SIGIO +# ifdef USABLE_SIGIO /* Return nonzero if *MASK has a bit set that corresponds to one of the keyboard input descriptors. */ @@ -7398,7 +7359,11 @@ init_process_emacs (void) #ifndef CANNOT_DUMP if (! noninteractive || initialized) #endif - signal (SIGCHLD, sigchld_handler); + { + struct sigaction action; + emacs_sigaction_init (&action, deliver_child_signal); + sigaction (SIGCHLD, &action, 0); + } #endif FD_ZERO (&input_wait_mask); diff --git a/src/ralloc.c b/src/ralloc.c index 3877e21d4f6..9a4b1ada229 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -25,7 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef emacs #include <config.h> -#include <setjmp.h> + #include "lisp.h" /* Needed for VALBITS. */ #include "blockinput.h" @@ -237,7 +237,7 @@ obtain (POINTER address, SIZE size) } if (! heap) - abort (); + emacs_abort (); /* If we can't fit SIZE bytes in that heap, try successive later heaps. */ @@ -330,7 +330,7 @@ relinquish (void) /* This heap should have no blocs in it. */ if (last_heap->first_bloc != NIL_BLOC || last_heap->last_bloc != NIL_BLOC) - abort (); + emacs_abort (); /* Return the last heap, with its header, to the system. */ excess = (char *)last_heap->end - (char *)last_heap->start; @@ -355,7 +355,7 @@ relinquish (void) which returns the entire last heap to the system, seems unlikely to trigger this mode of failure. */ if (last_heap->end != (*real_morecore) (0)) - abort (); + emacs_abort (); } } } @@ -452,7 +452,7 @@ relocate_blocs (bloc_ptr bloc, heap_ptr heap, POINTER address) /* No need to ever call this if arena is frozen, bug somewhere! */ if (r_alloc_freeze_level) - abort (); + emacs_abort (); while (b) { @@ -576,7 +576,7 @@ resize_bloc (bloc_ptr bloc, SIZE size) /* No need to ever call this if arena is frozen, bug somewhere! */ if (r_alloc_freeze_level) - abort (); + emacs_abort (); if (bloc == NIL_BLOC || size == bloc->size) return 1; @@ -588,7 +588,7 @@ resize_bloc (bloc_ptr bloc, SIZE size) } if (heap == NIL_HEAP) - abort (); + emacs_abort (); old_size = bloc->size; bloc->size = size; @@ -937,7 +937,7 @@ r_alloc_free (register POINTER *ptr) dead_bloc = find_bloc (ptr); if (dead_bloc == NIL_BLOC) - abort (); /* Double free? PTR not originally used to allocate? */ + emacs_abort (); /* Double free? PTR not originally used to allocate? */ free_bloc (dead_bloc); *ptr = 0; @@ -979,7 +979,7 @@ r_re_alloc (POINTER *ptr, SIZE size) bloc = find_bloc (ptr); if (bloc == NIL_BLOC) - abort (); /* Already freed? PTR not originally used to allocate? */ + emacs_abort (); /* Already freed? PTR not originally used to allocate? */ if (size < bloc->size) { @@ -1152,7 +1152,7 @@ r_alloc_reset_variable (POINTER *old, POINTER *new) } if (bloc == NIL_BLOC || bloc->variable != old) - abort (); /* Already freed? OLD not originally used to allocate? */ + emacs_abort (); /* Already freed? OLD not originally used to allocate? */ /* Update variable to point to the new location. */ bloc->variable = new; @@ -1193,7 +1193,7 @@ r_alloc_init (void) first_heap->start = first_heap->bloc_start = virtual_break_value = break_value = (*real_morecore) (0); if (break_value == NIL) - abort (); + emacs_abort (); extra_bytes = ROUNDUP (50000); #endif @@ -1204,9 +1204,15 @@ r_alloc_init (void) UNBLOCK_INPUT; #else #ifndef SYSTEM_MALLOC - /* Give GNU malloc's morecore some hysteresis - so that we move all the relocatable blocks much less often. */ - __malloc_extra_blocks = 64; + /* Give GNU malloc's morecore some hysteresis so that we move all + the relocatable blocks much less often. The number used to be + 64, but alloc.c would override that with 32 in code that was + removed when SYNC_INPUT became the only input handling mode. + That code was conditioned on !DOUG_LEA_MALLOC, so the call to + mallopt above is left unchanged. (Actually, I think there's no + system nowadays that uses DOUG_LEA_MALLOC and also uses + REL_ALLOC.) */ + __malloc_extra_blocks = 32; #endif #endif diff --git a/src/regex.c b/src/regex.c index 472ef727979..17562043df1 100644 --- a/src/regex.c +++ b/src/regex.c @@ -126,7 +126,6 @@ that make sense only in Emacs. */ #ifdef emacs -# include <setjmp.h> # include "lisp.h" # include "character.h" # include "buffer.h" @@ -1832,9 +1831,9 @@ typedef struct /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) -/* Explicit quit checking is only used on NTemacs and whenever we - use polling to process input events. */ -#if defined emacs && (defined WINDOWSNT || defined SYNC_INPUT) && defined QUIT +/* Explicit quit checking is needed for Emacs, which uses polling to + process input events. */ +#ifdef emacs extern int immediate_quit; # define IMMEDIATE_QUIT_CHECK \ do { \ diff --git a/src/region-cache.c b/src/region-cache.c index d2bba8c11b2..832f4bfd214 100644 --- a/src/region-cache.c +++ b/src/region-cache.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -194,7 +193,7 @@ find_cache_boundary (struct region_cache *c, ptrdiff_t pos) if (BOUNDARY_POS (c, low) > pos || (low + 1 < c->cache_len && BOUNDARY_POS (c, low + 1) <= pos)) - abort (); + emacs_abort (); return low; } @@ -217,12 +216,12 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size) if (pos < 0 || pos > c->cache_len) - abort (); + emacs_abort (); /* We mustn't ever try to put the gap before the dummy start boundary. That must always be start-relative. */ if (pos == 0) - abort (); + emacs_abort (); /* Need we move the gap right? */ while (gap_start < pos) @@ -291,24 +290,24 @@ insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos, { /* i must be a valid cache index. */ if (i < 0 || i > c->cache_len) - abort (); + emacs_abort (); /* We must never want to insert something before the dummy first boundary. */ if (i == 0) - abort (); + emacs_abort (); /* We must only be inserting things in order. */ if (! (BOUNDARY_POS (c, i - 1) < pos && (i == c->cache_len || pos < BOUNDARY_POS (c, i)))) - abort (); + emacs_abort (); /* The value must be different from the ones around it. However, we temporarily create boundaries that establish the same value as the subsequent boundary, so we're not going to flag that case. */ if (BOUNDARY_VALUE (c, i - 1) == value) - abort (); + emacs_abort (); move_cache_gap (c, i, 1); @@ -331,16 +330,16 @@ delete_cache_boundaries (struct region_cache *c, /* Gotta be in range. */ if (start < 0 || end > c->cache_len) - abort (); + emacs_abort (); /* Gotta be in order. */ if (start > end) - abort (); + emacs_abort (); /* Can't delete the dummy entry. */ if (start == 0 && end >= 1) - abort (); + emacs_abort (); /* Minimize gap motion. If we're deleting nothing, do nothing. */ if (len == 0) @@ -380,10 +379,10 @@ set_cache_region (struct region_cache *c, ptrdiff_t start, ptrdiff_t end, int value) { if (start > end) - abort (); + emacs_abort (); if (start < c->buffer_beg || end > c->buffer_end) - abort (); + emacs_abort (); /* Eliminate this case; then we can assume that start and end-1 are both the locations of real characters in the buffer. */ diff --git a/src/scroll.c b/src/scroll.c index 78ebe65bdcc..71ce43b2e48 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "termchar.h" #include "dispextern.h" @@ -195,13 +195,13 @@ calculate_scrolling (FRAME_PTR frame, { cost = p1->writecost + first_insert_cost[i]; if ((int) p1->insertcount > i) - abort (); + emacs_abort (); cost1 = p1->insertcost + next_insert_cost[i - p1->insertcount]; } p->insertcost = min (cost, cost1) + draw_cost[i] + extra_cost; p->insertcount = (cost < cost1) ? 1 : p1->insertcount + 1; if ((int) p->insertcount > i) - abort (); + emacs_abort (); /* Calculate the cost if we do a delete line after outputting this line. diff --git a/src/search.c b/src/search.c index 0b4f635066c..99fd7971e4c 100644 --- a/src/search.c +++ b/src/search.c @@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "syntax.h" #include "category.h" @@ -1009,7 +1009,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, if (!EQ (noerror, Qt)) { if (lim < BEGV || lim > ZV) - abort (); + emacs_abort (); SET_PT_BOTH (lim, lim_byte); return Qnil; #if 0 /* This would be clean, but maybe programs depend on @@ -1022,7 +1022,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, } if (np < BEGV || np > ZV) - abort (); + emacs_abort (); SET_PT (np); @@ -2770,7 +2770,7 @@ Return value is undefined if the last search failed. */) } else /* last_thing_searched must always be Qt, a buffer, or Qnil. */ - abort (); + emacs_abort (); len = 2 * i + 2; } diff --git a/src/sheap.c b/src/sheap.c index 3ae14b5daec..f6022ea3ce7 100644 --- a/src/sheap.c +++ b/src/sheap.c @@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include <unistd.h> @@ -93,4 +93,3 @@ report_sheap_usage (int die_if_pure_storage_exceeded) bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE); message ("%s", buf); } - diff --git a/src/sound.c b/src/sound.c index 403f08240ce..0ee85312fd3 100644 --- a/src/sound.c +++ b/src/sound.c @@ -44,11 +44,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <sys/types.h> #include <errno.h> -#include <setjmp.h> + #include "lisp.h" #include "dispextern.h" #include "atimer.h" -#include <signal.h> #include "syssignal.h" /* END: Common Includes */ @@ -315,8 +314,13 @@ sound_perror (const char *msg) int saved_errno = errno; turn_on_atimers (1); -#ifdef SIGIO - sigunblock (sigmask (SIGIO)); +#ifdef USABLE_SIGIO + { + sigset_t unblocked; + sigemptyset (&unblocked); + sigaddset (&unblocked, SIGIO); + pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); + } #endif if (saved_errno != 0) error ("%s: %s", msg, strerror (saved_errno)); @@ -728,6 +732,9 @@ static void vox_configure (struct sound_device *sd) { int val; +#ifdef USABLE_SIGIO + sigset_t blocked; +#endif eassert (sd->fd >= 0); @@ -735,8 +742,10 @@ vox_configure (struct sound_device *sd) interrupted by a signal. Block the ones we know to cause troubles. */ turn_on_atimers (0); -#ifdef SIGIO - sigblock (sigmask (SIGIO)); +#ifdef USABLE_SIGIO + sigemptyset (&blocked); + sigaddset (&blocked, SIGIO); + pthread_sigmask (SIG_BLOCK, &blocked, 0); #endif val = sd->format; @@ -769,8 +778,8 @@ vox_configure (struct sound_device *sd) } turn_on_atimers (1); -#ifdef SIGIO - sigunblock (sigmask (SIGIO)); +#ifdef USABLE_SIGIO + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif } @@ -785,8 +794,11 @@ vox_close (struct sound_device *sd) /* On GNU/Linux, it seems that the device driver doesn't like to be interrupted by a signal. Block the ones we know to cause troubles. */ -#ifdef SIGIO - sigblock (sigmask (SIGIO)); +#ifdef USABLE_SIGIO + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGIO); + pthread_sigmask (SIG_BLOCK, &blocked, 0); #endif turn_on_atimers (0); @@ -794,8 +806,8 @@ vox_close (struct sound_device *sd) ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); turn_on_atimers (1); -#ifdef SIGIO - sigunblock (sigmask (SIGIO)); +#ifdef USABLE_SIGIO + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif /* Close the device. */ @@ -843,7 +855,7 @@ vox_choose_format (struct sound_device *sd, struct sound *s) } } else - abort (); + emacs_abort (); } @@ -1138,7 +1150,7 @@ alsa_choose_format (struct sound_device *sd, struct sound *s) } } else - abort (); + emacs_abort (); } diff --git a/src/syntax.c b/src/syntax.c index f995b8f2cac..91ef4e66663 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <sys/types.h> -#include <setjmp.h> + #include "lisp.h" #include "commands.h" #include "character.h" @@ -921,11 +921,11 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, } DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0, - doc: /* Convert a syntax specification STRING into syntax cell form. -STRING should be a string as it is allowed as argument of -`modify-syntax-entry'. Value is the equivalent cons cell -\(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table' -text property. */) + doc: /* Convert a syntax descriptor STRING into a raw syntax descriptor. +STRING should be a string of the form allowed as argument of +`modify-syntax-entry'. The return value is a raw syntax descriptor: a +cons cell \(CODE . MATCHING-CHAR) which can be used, for example, as +the value of a `syntax-table' text property. */) (Lisp_Object string) { register const unsigned char *p; diff --git a/src/sysdep.c b/src/sysdep.c index b84e6a4ea3a..dbfd9efc7d4 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -21,9 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define SYSTIME_INLINE EXTERN_INLINE -#include <signal.h> +#include <execinfo.h> #include <stdio.h> -#include <setjmp.h> #ifdef HAVE_PWD_H #include <pwd.h> #include <grp.h> @@ -107,9 +106,6 @@ extern char *getwd (char *); static int emacs_get_tty (int, struct emacs_tty *); static int emacs_set_tty (int, struct emacs_tty *, int); -#if defined TIOCNOTTY || defined USG5 || defined CYGWIN -static _Noreturn void croak (char *); -#endif /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ #ifndef ULLONG_MAX @@ -302,27 +298,34 @@ wait_for_termination_1 (pid_t pid, int interruptible) termination of subprocesses, perhaps involving a kernel bug too, but no idea what it is. Just as a hunch we signal SIGCHLD to see if that causes the problem to go away or get worse. */ - sigsetmask (sigmask (SIGCHLD)); + sigset_t sigchild_mask; + sigemptyset (&sigchild_mask); + sigaddset (&sigchild_mask, SIGCHLD); + pthread_sigmask (SIG_SETMASK, &sigchild_mask, 0); + if (0 > kill (pid, 0)) { - sigsetmask (SIGEMPTYMASK); + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); kill (getpid (), SIGCHLD); break; } if (wait_debugging) sleep (1); else - sigpause (SIGEMPTYMASK); + sigsuspend (&empty_mask); #else /* not BSD_SYSTEM, and not HPUX version >= 6 */ #ifdef WINDOWSNT wait (0); break; #else /* not WINDOWSNT */ - sigblock (sigmask (SIGCHLD)); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGCHLD); + pthread_sigmask (SIG_BLOCK, &blocked, 0); errno = 0; if (kill (pid, 0) == -1 && errno == ESRCH) { - sigunblock (sigmask (SIGCHLD)); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); break; } @@ -456,11 +459,11 @@ child_setup_tty (int out) #endif /* not MSDOS */ -/* Record a signal code and the handler for it. */ +/* Record a signal code and the action for it. */ struct save_signal { int code; - void (*handler) (int); + struct sigaction action; }; static void save_signal_handlers (struct save_signal *); @@ -506,7 +509,7 @@ sys_subshell (void) saved_handlers[0].code = SIGINT; saved_handlers[1].code = SIGQUIT; saved_handlers[2].code = SIGTERM; -#ifdef SIGIO +#ifdef USABLE_SIGIO saved_handlers[3].code = SIGIO; saved_handlers[4].code = 0; #else @@ -618,8 +621,9 @@ save_signal_handlers (struct save_signal *saved_handlers) { while (saved_handlers->code) { - saved_handlers->handler - = (void (*) (int)) signal (saved_handlers->code, SIG_IGN); + struct sigaction action; + emacs_sigaction_init (&action, SIG_IGN); + sigaction (saved_handlers->code, &action, &saved_handlers->action); saved_handlers++; } } @@ -629,118 +633,80 @@ restore_signal_handlers (struct save_signal *saved_handlers) { while (saved_handlers->code) { - signal (saved_handlers->code, saved_handlers->handler); + sigaction (saved_handlers->code, &saved_handlers->action, 0); saved_handlers++; } } -#ifndef SIGIO -/* If SIGIO is broken, don't do anything. */ -void -init_sigio (int fd) -{ -} - -static void -reset_sigio (int fd) -{ -} - -void -request_sigio (void) -{ -} - -void -unrequest_sigio (void) -{ -} - -#else -#ifdef F_SETFL - +#ifdef USABLE_SIGIO static int old_fcntl_flags[MAXDESC]; +#endif void init_sigio (int fd) { -#ifdef FASYNC +#ifdef USABLE_SIGIO old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); -#endif interrupts_deferred = 0; +#endif } static void reset_sigio (int fd) { -#ifdef FASYNC +#ifdef USABLE_SIGIO fcntl (fd, F_SETFL, old_fcntl_flags[fd]); #endif } -#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ -/* XXX Uhm, FASYNC is not used anymore here. */ -/* XXX Yeah, but you need it for SIGIO, don't you? */ - void request_sigio (void) { +#ifdef USABLE_SIGIO + sigset_t unblocked; + if (noninteractive) return; -#ifdef SIGWINCH - sigunblock (sigmask (SIGWINCH)); -#endif - sigunblock (sigmask (SIGIO)); + sigemptyset (&unblocked); +# ifdef SIGWINCH + sigaddset (&unblocked, SIGWINCH); +# endif + sigaddset (&unblocked, SIGIO); + pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); interrupts_deferred = 0; +#endif } void unrequest_sigio (void) { - if (noninteractive) - return; +#ifdef USABLE_SIGIO + sigset_t blocked; -#if 0 /* XXX What's wrong with blocking SIGIO under X? */ - if (x_display_list) + if (noninteractive) return; -#endif -#ifdef SIGWINCH - sigblock (sigmask (SIGWINCH)); -#endif - sigblock (sigmask (SIGIO)); + sigemptyset (&blocked); +# ifdef SIGWINCH + sigaddset (&blocked, SIGWINCH); +# endif + sigaddset (&blocked, SIGIO); + pthread_sigmask (SIG_BLOCK, &blocked, 0); interrupts_deferred = 1; -} - -#else /* no FASYNC */ -#ifndef MSDOS - -void -request_sigio (void) -{ - if (noninteractive || read_socket_hook) - return; - - croak ("request_sigio"); +#endif } void -unrequest_sigio (void) +ignore_sigio (void) { - if (noninteractive || read_socket_hook) - return; - - croak ("unrequest_sigio"); +#ifdef USABLE_SIGIO + signal (SIGIO, SIG_IGN); +#endif } -#endif /* MSDOS */ -#endif /* FASYNC */ -#endif /* F_SETFL */ -#endif /* SIGIO */ - /* Getting and setting emacs_tty structures. */ @@ -1470,86 +1436,64 @@ init_system_name (void) } } -/* POSIX signals support - DJB */ -/* Anyone with POSIX signals should have ANSI C declarations */ - sigset_t empty_mask; -#ifndef WINDOWSNT - -signal_handler_t -sys_signal (int signal_number, signal_handler_t action) +/* Store into *ACTION a signal action suitable for Emacs, with handler + HANDLER. */ +void +emacs_sigaction_init (struct sigaction *action, signal_handler_t handler) { - struct sigaction new_action, old_action; - sigemptyset (&new_action.sa_mask); - new_action.sa_handler = action; - new_action.sa_flags = 0; + sigemptyset (&action->sa_mask); + action->sa_handler = handler; + action->sa_flags = 0; #if defined (SA_RESTART) - /* Emacs mostly works better with restartable system services. If this - flag exists, we probably want to turn it on here. - However, on some systems (only hpux11 at present) this resets the - timeout of `select' which means that `select' never finishes if - it keeps getting signals. - We define BROKEN_SA_RESTART on those systems. */ - /* It's not clear why the comment above says "mostly works better". --Stef - When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll + /* SA_RESTART causes interruptible functions with timeouts (e.g., + 'select') to reset their timeout on some platforms (e.g., + HP-UX 11), which is not what we want. Also, when Emacs is + interactive, we don't want SA_RESTART because we need to poll for pending input so we need long-running syscalls to be interrupted after a signal that sets the interrupt_input_pending flag. */ /* Non-interactive keyboard input goes through stdio, where we always want restartable system calls. */ -# if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT) if (noninteractive) -# endif - new_action.sa_flags = SA_RESTART; + action->sa_flags = SA_RESTART; #endif - sigaction (signal_number, &new_action, &old_action); - return (old_action.sa_handler); } -#endif /* WINDOWSNT */ - -#ifndef __GNUC__ -/* If we're compiling with GCC, we don't need this function, since it - can be written as a macro. */ -sigset_t -sys_sigmask (int sig) -{ - sigset_t mask; - sigemptyset (&mask); - sigaddset (&mask, sig); - return mask; -} +#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD +static pthread_t main_thread; #endif -/* I'd like to have these guys return pointers to the mask storage in here, - but there'd be trouble if the code was saving multiple masks. I'll be - safe and pass the structure. It normally won't be more than 2 bytes - anyhow. - DJB */ - -sigset_t -sys_sigblock (sigset_t new_mask) +/* If we are on the main thread, handle the signal SIG with HANDLER. + Otherwise, redirect the signal to the main thread, blocking it from + this thread. POSIX says any thread can receive a signal that is + associated with a process, process group, or asynchronous event. + On GNU/Linux that is not true, but for other systems (FreeBSD at + least) it is. */ +void +handle_on_main_thread (int sig, signal_handler_t handler) { - sigset_t old_mask; - pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); - return (old_mask); -} + /* Preserve errno, to avoid race conditions with signal handlers that + might change errno. Races can occur even in single-threaded hosts. */ + int old_errno = errno; -sigset_t -sys_sigunblock (sigset_t new_mask) -{ - sigset_t old_mask; - pthread_sigmask (SIG_UNBLOCK, &new_mask, &old_mask); - return (old_mask); -} + bool on_main_thread = true; +#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD + if (! pthread_equal (pthread_self (), main_thread)) + { + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, sig); + pthread_sigmask (SIG_BLOCK, &blocked, 0); + pthread_kill (main_thread, sig); + on_main_thread = false; + } +#endif + if (on_main_thread) + handler (sig); -sigset_t -sys_sigsetmask (sigset_t new_mask) -{ - sigset_t old_mask; - pthread_sigmask (SIG_SETMASK, &new_mask, &old_mask); - return (old_mask); + errno = old_errno; } - #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST static char *my_sys_siglist[NSIG]; @@ -1564,6 +1508,10 @@ init_signals (void) { sigemptyset (&empty_mask); +#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD + main_thread = pthread_self (); +#endif + #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST if (! initialized) { @@ -1856,6 +1804,33 @@ snprintf (char *buf, size_t bufsize, char const *format, ...) } #endif +/* If a backtrace is available, output the top lines of it to stderr. + Do not output more than BACKTRACE_LIMIT or BACKTRACE_LIMIT_MAX lines. + This function may be called from a signal handler, so it should + not invoke async-unsafe functions like malloc. */ +void +emacs_backtrace (int backtrace_limit) +{ + enum { BACKTRACE_LIMIT_MAX = 500 }; + void *buffer[BACKTRACE_LIMIT_MAX + 1]; + int bounded_limit = min (backtrace_limit, BACKTRACE_LIMIT_MAX); + int npointers = backtrace (buffer, bounded_limit + 1); + if (npointers) + ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12)); + backtrace_symbols_fd (buffer, bounded_limit, STDERR_FILENO); + if (bounded_limit < npointers) + ignore_value (write (STDERR_FILENO, "...\n", 4)); +} + +#ifndef HAVE_NTGUI +/* Using emacs_abort lets GDB return from a breakpoint here. */ +void +emacs_abort (void) +{ + fatal_error_backtrace (SIGABRT, 10); +} +#endif + int emacs_open (const char *path, int oflag, int mode) { @@ -1933,11 +1908,9 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte) { if (errno == EINTR) { -#ifdef SYNC_INPUT /* I originally used `QUIT' but that might causes files to be truncated if you hit C-g in the middle of it. --Stef */ process_pending_signals (); -#endif continue; } else @@ -2020,19 +1993,6 @@ getwd (char *pathname) } #endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ - -/* - * This function will go away as soon as all the stubs fixed. (fnf) - */ - -void -croak (char *badfunc) -{ - printf ("%s not yet implemented\r\n", badfunc); - reset_all_sys_modes (); - exit (1); -} - #endif /* USG */ /* Directory routines for systems that don't have them. */ diff --git a/src/syssignal.h b/src/syssignal.h index 71151ed4c6a..e309e6725b7 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -17,6 +17,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ +#include <signal.h> + extern void init_signals (void); #ifdef HAVE_PTHREAD @@ -26,83 +28,14 @@ extern void init_signals (void); #define FORWARD_SIGNAL_TO_MAIN_THREAD #endif -/* Don't #include <signal.h>. That header should always be #included - before "config.h", because some configuration files (like s/hpux.h) - indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file - #includes <signal.h>, then that will re-#define SIGIO and confuse - things. */ -/* XXX This is not correct anymore, there is a BROKEN_SIGIO macro. */ - -#define SIGMASKTYPE sigset_t - -#define SIGEMPTYMASK (empty_mask) extern sigset_t empty_mask; -/* POSIX pretty much destroys any possibility of writing sigmask as a - macro in standard C. We always define our own version because the - predefined macro in Glibc 2.1 is only provided for compatibility for old - programs that use int as signal mask type. */ -#undef sigmask -#ifdef __GNUC__ -#define sigmask(SIG) \ - ({ \ - sigset_t _mask; \ - sigemptyset (&_mask); \ - sigaddset (&_mask, SIG); \ - _mask; \ - }) -#else /* ! defined (__GNUC__) */ -extern sigset_t sys_sigmask (); -#define sigmask(SIG) (sys_sigmask (SIG)) -#endif /* ! defined (__GNUC__) */ - -#undef sigpause -#define sigpause(MASK) sigsuspend (&(MASK)) - -#define sigblock(SIG) sys_sigblock (SIG) -#define sigunblock(SIG) sys_sigunblock (SIG) -#ifndef sigsetmask -#define sigsetmask(SIG) sys_sigsetmask (SIG) -#endif -#undef signal -#define signal(SIG,ACT) sys_signal(SIG,ACT) - -/* Whether this is what all systems want or not, this is what - appears to be assumed in the source, for example data.c:arith_error. */ typedef void (*signal_handler_t) (int); -signal_handler_t sys_signal (int signal_number, signal_handler_t action); -sigset_t sys_sigblock (sigset_t new_mask); -sigset_t sys_sigunblock (sigset_t new_mask); -sigset_t sys_sigsetmask (sigset_t new_mask); -#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN) -_Noreturn void croak (char *); -#endif - -#define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG) - -#define sigfree() sigsetmask (SIGEMPTYMASK) - -#if defined (SIGIO) && defined (BROKEN_SIGIO) -# undef SIGIO -#endif -/* These are only used by AIX */ -#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) -#undef SIGPOLL -#endif -#if defined (SIGAIO) && defined (BROKEN_SIGAIO) -#undef SIGAIO -#endif -#if defined (SIGPTY) && defined (BROKEN_SIGPTY) -#undef SIGPTY -#endif - +extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); -/* FIXME? Emacs only defines NSIG_MINIMUM on some platforms? */ #if NSIG < NSIG_MINIMUM -# ifdef NSIG -# undef NSIG -# endif +# undef NSIG # define NSIG NSIG_MINIMUM #endif @@ -131,26 +64,4 @@ _Noreturn void croak (char *); char *strsignal (int); #endif -#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD -extern pthread_t main_thread; -#define SIGNAL_THREAD_CHECK(signo) \ - do { \ - if (!pthread_equal (pthread_self (), main_thread)) \ - { \ - /* POSIX says any thread can receive the signal. On GNU/Linux \ - that is not true, but for other systems (FreeBSD at least) \ - it is. So direct the signal to the correct thread and block \ - it from this thread. */ \ - sigset_t new_mask; \ - \ - sigemptyset (&new_mask); \ - sigaddset (&new_mask, signo); \ - pthread_sigmask (SIG_BLOCK, &new_mask, 0); \ - pthread_kill (main_thread, signo); \ - return; \ - } \ - } while (0) - -#else /* not FORWARD_SIGNAL_TO_MAIN_THREAD */ -#define SIGNAL_THREAD_CHECK(signo) -#endif /* not FORWARD_SIGNAL_TO_MAIN_THREAD */ +void handle_on_main_thread (int, signal_handler_t); diff --git a/src/systty.h b/src/systty.h index ae98f123f2a..b7f36c6c259 100644 --- a/src/systty.h +++ b/src/systty.h @@ -17,10 +17,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Include the proper files. */ + #ifndef DOS_NT -#ifndef NO_TERMIO -#include <termio.h> -#endif /* not NO_TERMIO */ #include <termios.h> #include <fcntl.h> #endif /* not DOS_NT */ @@ -39,20 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> -/* Special cases - inhibiting the use of certain features. */ - -/* Allow configure to inhibit use of FIONREAD. */ -#ifdef BROKEN_FIONREAD -#undef FIONREAD -#undef ASYNC -#endif - -/* Interrupt input is not used if there is no FIONREAD. */ -#ifndef FIONREAD -#undef SIGIO -#endif - - /* Try to establish the correct character to disable terminal functions in a system-independent manner. Note that USG (at least) define _POSIX_VDISABLE as 0! */ diff --git a/src/term.c b/src/term.c index f1a09b39cf9..f4117d67dec 100644 --- a/src/term.c +++ b/src/term.c @@ -25,8 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/file.h> #include <sys/time.h> #include <unistd.h> -#include <signal.h> -#include <setjmp.h> #include "lisp.h" #include "termchar.h" @@ -1498,7 +1496,7 @@ append_glyph (struct it *it) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } else @@ -1695,7 +1693,7 @@ append_composite_glyph (struct it *it) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } else @@ -1780,7 +1778,7 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } else @@ -2250,7 +2248,7 @@ get_named_tty (const char *name) struct terminal *t; if (!name) - abort (); + emacs_abort (); for (t = terminal_list; t; t = t->next_terminal) { @@ -2798,7 +2796,7 @@ create_tty_output (struct frame *f) struct tty_output *t = xzalloc (sizeof *t); if (! FRAME_TERMCAP_P (f)) - abort (); + emacs_abort (); t->display_info = FRAME_TERMINAL (f)->display_info.tty; @@ -2811,7 +2809,7 @@ static void tty_free_frame_resources (struct frame *f) { if (! FRAME_TERMCAP_P (f)) - abort (); + emacs_abort (); if (FRAME_FACE_CACHE (f)) free_frame_faces (f); @@ -2827,7 +2825,7 @@ static void tty_free_frame_resources (struct frame *f) { if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f)) - abort (); + emacs_abort (); if (FRAME_FACE_CACHE (f)) free_frame_faces (f); @@ -2932,7 +2930,10 @@ dissociate_if_controlling_tty (int fd) no_controlling_tty = 1; #else #ifdef TIOCNOTTY /* Try BSD ioctls. */ - sigblock (sigmask (SIGTTOU)); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGTTOU); + pthread_sigmask (SIG_BLOCK, &blocked, 0); fd = emacs_open (DEV_TTY, O_RDWR, 0); if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1) { @@ -2940,10 +2941,9 @@ dissociate_if_controlling_tty (int fd) } if (fd != -1) emacs_close (fd); - sigunblock (sigmask (SIGTTOU)); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #else - /* Unknown system. */ - croak (); +# error "Unknown system." #endif /* ! TIOCNOTTY */ #endif /* ! USG */ } @@ -3074,9 +3074,14 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) /* On some systems, tgetent tries to access the controlling terminal. */ - sigblock (sigmask (SIGTTOU)); - status = tgetent (tty->termcap_term_buffer, terminal_type); - sigunblock (sigmask (SIGTTOU)); + { + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGTTOU); + pthread_sigmask (SIG_BLOCK, &blocked, 0); + status = tgetent (tty->termcap_term_buffer, terminal_type); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); + } if (status < 0) { @@ -3108,7 +3113,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ #ifndef TERMINFO if (strlen (tty->termcap_term_buffer) >= buffer_size) - abort (); + emacs_abort (); buffer_size = strlen (tty->termcap_term_buffer); #endif tty->termcap_strings_buffer = area = xmalloc (buffer_size); @@ -3467,7 +3472,7 @@ maybe_fatal (int must_succeed, struct terminal *terminal, verror (str1, ap); va_end (ap); - abort (); + emacs_abort (); } void @@ -3494,7 +3499,7 @@ delete_tty (struct terminal *terminal) return; if (terminal->type != output_termcap) - abort (); + emacs_abort (); tty = terminal->display_info.tty; @@ -3508,7 +3513,7 @@ delete_tty (struct terminal *terminal) if (! p) /* This should not happen. */ - abort (); + emacs_abort (); p->next = tty->next; tty->next = 0; diff --git a/src/termcap.c b/src/termcap.c index d1b05e8df94..e494cd113d9 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -19,7 +19,6 @@ Boston, MA 02110-1301, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ #include <config.h> -#include <setjmp.h> #include <sys/file.h> #include <fcntl.h> #include <unistd.h> diff --git a/src/termchar.h b/src/termchar.h index 102fe45350e..5c57593c04f 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -207,6 +207,6 @@ extern struct tty_display_info *tty_list; (((f)->output_method == output_termcap \ || (f)->output_method == output_msdos_raw) \ ? (f)->terminal->display_info.tty \ - : (abort (), (struct tty_display_info *) 0)) + : (emacs_abort (), (struct tty_display_info *) 0)) #define CURTTY() FRAME_TTY (SELECTED_FRAME()) diff --git a/src/terminal.c b/src/terminal.c index d94164a4e40..719c2a36111 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define TERMHOOKS_INLINE EXTERN_INLINE #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "frame.h" @@ -294,7 +293,7 @@ delete_terminal (struct terminal *terminal) for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal) if (! *tp) - abort (); + emacs_abort (); *tp = terminal->next_terminal; xfree (terminal->keyboard_coding); @@ -411,7 +410,7 @@ possible return values. */) case output_ns: return Qns; default: - abort (); + emacs_abort (); } } @@ -519,7 +518,7 @@ struct terminal * init_initial_terminal (void) { if (initialized || terminal_list || tty_list) - abort (); + emacs_abort (); initial_terminal = create_terminal (); initial_terminal->type = output_initial; @@ -538,7 +537,7 @@ static void delete_initial_terminal (struct terminal *terminal) { if (terminal != initial_terminal) - abort (); + emacs_abort (); delete_terminal (terminal); initial_terminal = NULL; diff --git a/src/terminfo.c b/src/terminfo.c index dce7af77bcf..124c452a4a9 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include "tparam.h" -#include <setjmp.h> #include "lisp.h" /* Define these variables that serve as global parameters to termcap, @@ -46,7 +45,7 @@ tparam (const char *string, char *outstring, int len, /* Emacs always should pass a null OUTSTRING and zero LEN. */ if (outstring || len) - abort (); + emacs_abort (); temp = tparm (string, arg1, arg2, arg3, arg4); return xstrdup (temp); diff --git a/src/textprop.c b/src/textprop.c index b6895fc426a..872912ea706 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "intervals.h" #include "character.h" @@ -556,7 +556,8 @@ If POSITION is at the end of OBJECT, the value is nil. */) DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0, doc: /* Return the value of POSITION's property PROP, in OBJECT. -OBJECT is optional and defaults to the current buffer. +OBJECT should be a buffer or a string; if omitted or nil, it defaults +to the current buffer. If POSITION is at the end of OBJECT, the value is nil. */) (Lisp_Object position, Lisp_Object prop, Lisp_Object object) { diff --git a/src/tparam.c b/src/tparam.c index 9492d9dee36..164f61d471b 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -19,7 +19,7 @@ Boston, MA 02110-1301, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" /* for xmalloc */ #include "tparam.h" @@ -247,7 +247,7 @@ tparam1 (const char *string, char *outstring, int len, break; default: - abort (); + emacs_abort (); } } else diff --git a/src/undo.c b/src/undo.c index 9cd1d5f9f67..e878ef4dcf9 100644 --- a/src/undo.c +++ b/src/undo.c @@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> + #include "lisp.h" #include "character.h" #include "buffer.h" diff --git a/src/unexaix.c b/src/unexaix.c index c09156296f7..c01a22a79f6 100644 --- a/src/unexaix.c +++ b/src/unexaix.c @@ -89,7 +89,6 @@ static int adjust_lnnoptrs (int, int, const char *); static int pagemask; -#include <setjmp.h> #include "lisp.h" static void diff --git a/src/unexcoff.c b/src/unexcoff.c index e83042a379d..966dd58cb6e 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -120,7 +120,6 @@ static int pagemask; #define ADDR_CORRECT(x) ((char *)(x) - (char*)0) -#include <setjmp.h> #include "lisp.h" static void diff --git a/src/unexcw.c b/src/unexcw.c index eae534cf4dd..96c4b4a9aec 100644 --- a/src/unexcw.c +++ b/src/unexcw.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include "unexec.h" -#include <setjmp.h> #include <lisp.h> #include <stdio.h> #include <fcntl.h> diff --git a/src/unexsol.c b/src/unexsol.c index 336f3b4faea..470206d5838 100644 --- a/src/unexsol.c +++ b/src/unexsol.c @@ -4,7 +4,6 @@ #include "unexec.h" #include <dlfcn.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" diff --git a/src/vm-limit.c b/src/vm-limit.c index cf697b56fdf..8de0acd1bb2 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> #include <unistd.h> /* for 'environ', on AIX */ #include "lisp.h" #include "mem-limits.h" diff --git a/src/w16select.c b/src/w16select.c index 2026de7421d..a3f6f1fb9ae 100644 --- a/src/w16select.c +++ b/src/w16select.c @@ -31,7 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <dpmi.h> #include <go32.h> #include <sys/farptr.h> -#include <setjmp.h> #include "lisp.h" #include "dispextern.h" /* frame.h seems to want this */ #include "frame.h" /* Need this to get the X window of selected_frame */ diff --git a/src/w32.c b/src/w32.c index d779d740724..d79065e76e0 100644 --- a/src/w32.c +++ b/src/w32.c @@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/time.h> #include <sys/utime.h> #include <math.h> -#include <setjmp.h> #include <time.h> /* must include CRT headers *before* config.h */ @@ -1256,9 +1255,9 @@ init_user_info (void) /* Ensure HOME and SHELL are defined. */ if (getenv ("HOME") == NULL) - abort (); + emacs_abort (); if (getenv ("SHELL") == NULL) - abort (); + emacs_abort (); /* Set dir and shell from environment variables. */ strcpy (dflt_passwd.pw_dir, getenv ("HOME")); @@ -1513,34 +1512,10 @@ is_unc_volume (const char *filename) } /* Routines that are no-ops on NT but are defined to get Emacs to compile. */ - -int -sigsetmask (int signal_mask) -{ - return 0; -} - -int -sigmask (int sig) -{ - return 0; -} - -int -sigblock (int sig) -{ - return 0; -} - -int -sigunblock (int sig) -{ - return 0; -} - int sigemptyset (sigset_t *set) { + *set = 0; return 0; } @@ -1771,9 +1746,9 @@ init_environment (char ** argv) char modname[MAX_PATH]; if (!GetModuleFileName (NULL, modname, MAX_PATH)) - abort (); + emacs_abort (); if ((p = strrchr (modname, '\\')) == NULL) - abort (); + emacs_abort (); *p = 0; if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0) @@ -1885,13 +1860,13 @@ init_environment (char ** argv) /* FIXME: Do we need to resolve possible symlinks in startup_dir? Does it matter anywhere in Emacs? */ if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) - abort (); + emacs_abort (); { static char modname[MAX_PATH]; if (!GetModuleFileName (NULL, modname, MAX_PATH)) - abort (); + emacs_abort (); argv[0] = modname; } @@ -1913,7 +1888,7 @@ emacs_root_dir (void) p = getenv ("emacs_dir"); if (p == NULL) - abort (); + emacs_abort (); strcpy (root_dir, p); root_dir[parse_root (root_dir, NULL)] = '\0'; dostounix_filename (root_dir); @@ -3270,7 +3245,7 @@ generate_inode_val (const char * name) doesn't resolve aliasing due to subst commands, or recognize hard links. */ if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH)) - abort (); + emacs_abort (); parse_root (fullname, &p); /* Normal W32 filesystems are still case insensitive. */ @@ -5570,7 +5545,7 @@ socket_to_fd (SOCKET s) if (fd_info[ fd ].cp != NULL) { DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd)); - abort (); + emacs_abort (); } fd_info[ fd ].cp = cp; @@ -5949,7 +5924,7 @@ sys_close (int fd) { if (fd_info[fd].flags & FILE_SOCKET) { - if (winsock_lib == NULL) abort (); + if (winsock_lib == NULL) emacs_abort (); pfn_shutdown (SOCK_HANDLE (fd), 2); rc = pfn_closesocket (SOCK_HANDLE (fd)); @@ -6067,7 +6042,7 @@ _sys_read_ahead (int fd) || (fd_info[fd].flags & FILE_READ) == 0) { DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe, serial port, or socket!\n", fd)); - abort (); + emacs_abort (); } cp->status = STATUS_READ_IN_PROGRESS; @@ -6203,7 +6178,7 @@ sys_read (int fd, char * buffer, unsigned int count) /* re-read CR carried over from last read */ if (fd_info[fd].flags & FILE_LAST_CR) { - if (fd_info[fd].flags & FILE_BINARY) abort (); + if (fd_info[fd].flags & FILE_BINARY) emacs_abort (); *buffer++ = 0x0d; count--; nchars++; @@ -6306,7 +6281,7 @@ sys_read (int fd, char * buffer, unsigned int count) } else /* FILE_SOCKET */ { - if (winsock_lib == NULL) abort (); + if (winsock_lib == NULL) emacs_abort (); /* do the equivalent of a non-blocking read */ pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting); @@ -6457,7 +6432,7 @@ sys_write (int fd, const void * buffer, unsigned int count) else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock = 0; - if (winsock_lib == NULL) abort (); + if (winsock_lib == NULL) emacs_abort (); /* TODO: implement select() properly so non-blocking I/O works. */ /* For now, make sure the write blocks. */ @@ -6623,8 +6598,7 @@ check_windows_init_file (void) buffer, "Emacs Abort Dialog", MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); - /* Use the low-level Emacs abort. */ -#undef abort + /* Use the low-level system abort. */ abort (); } else @@ -6756,7 +6730,7 @@ shutdown_handler (DWORD type) || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */ { /* Shut down cleanly, making sure autosave files are up to date. */ - shut_down_emacs (0, 0, Qnil); + shut_down_emacs (0, Qnil); } /* Allow other handlers to handle this signal. */ diff --git a/src/w32console.c b/src/w32console.c index 76b7bb0b451..5a44d3748a2 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <windows.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" diff --git a/src/w32fns.c b/src/w32fns.c index aa7d6c7a0ea..cd48ae65e32 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <limits.h> #include <errno.h> #include <math.h> -#include <setjmp.h> #include "lisp.h" #include "w32term.h" @@ -2368,7 +2367,7 @@ w32_msg_pump (deferred_msg * msg_buf) CoInitialize (NULL); w32_createwindow ((struct frame *) msg.wParam); if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) - abort (); + emacs_abort (); break; case WM_EMACS_SETLOCALE: SetThreadLocale (msg.wParam); @@ -2378,7 +2377,7 @@ w32_msg_pump (deferred_msg * msg_buf) result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0); if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, result, 0)) - abort (); + emacs_abort (); break; case WM_EMACS_REGISTER_HOT_KEY: focus_window = GetFocus (); @@ -2399,7 +2398,7 @@ w32_msg_pump (deferred_msg * msg_buf) GC. */ XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil); if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) - abort (); + emacs_abort (); break; case WM_EMACS_TOGGLE_LOCK_KEY: { @@ -2431,7 +2430,7 @@ w32_msg_pump (deferred_msg * msg_buf) } if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, cur_state, 0)) - abort (); + emacs_abort (); } break; #ifdef MSG_DEBUG @@ -2486,11 +2485,11 @@ send_deferred_msg (deferred_msg * msg_buf, { /* Only input thread can send deferred messages. */ if (GetCurrentThreadId () != dwWindowsThreadId) - abort (); + emacs_abort (); /* It is an error to send a message that is already deferred. */ if (find_deferred_msg (hwnd, msg) != NULL) - abort (); + emacs_abort (); /* Enforced synchronization is not needed because this is the only function that alters deferred_msg_head, and the following critical @@ -2563,7 +2562,7 @@ w32_msg_worker (void *arg) PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) - abort (); + emacs_abort (); memset (&dummy_buf, 0, sizeof (dummy_buf)); dummy_buf.w32msg.msg.hwnd = NULL; @@ -3224,7 +3223,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) msg = WM_MBUTTONUP; button_state &= ~MMOUSE; - if (button_state) abort (); + if (button_state) emacs_abort (); } else return 0; @@ -3455,7 +3454,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Detect if message has already been deferred; in this case we cannot return any sensible value to ignore this. */ if (find_deferred_msg (hwnd, msg) != NULL) - abort (); + emacs_abort (); menubar_in_use = 1; @@ -3930,7 +3929,7 @@ my_create_window (struct frame * f) MSG msg; if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0)) - abort (); + emacs_abort (); GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); } @@ -6490,7 +6489,7 @@ w32_parse_hot_key (Lisp_Object key) lisp_modifiers = XINT (Fcar (Fcdr (c))); c = Fcar (c); if (!SYMBOLP (c)) - abort (); + emacs_abort (); vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c))); } else if (INTEGERP (c)) @@ -7685,10 +7684,8 @@ globals_of_w32fns (void) syms_of_w32uniscribe (); } -#undef abort - void -w32_abort (void) +emacs_abort (void) { int button; button = MessageBox (NULL, diff --git a/src/w32font.c b/src/w32font.c index c135d061e7d..d7d25d89939 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <math.h> #include <ctype.h> #include <commdlg.h> -#include <setjmp.h> #include "lisp.h" #include "w32term.h" @@ -636,9 +635,9 @@ w32font_text_extents (struct font *font, unsigned *code, /* w32 implementation of draw for font backend. Optional. Draw glyphs between FROM and TO of S->char2b at (X Y) pixel - position of frame F with S->FACE and S->GC. If WITH_BACKGROUND - is nonzero, fill the background in advance. It is assured that - WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). + position of frame F with S->FACE and S->GC. If WITH_BACKGROUND, + fill the background in advance. It is assured that WITH_BACKGROUND + is false when (FROM > 0 || TO < S->nchars). TODO: Currently this assumes that the colors and fonts are already set in the DC. This seems to be true now, but maybe only due to @@ -648,7 +647,7 @@ w32font_text_extents (struct font *font, unsigned *code, int w32font_draw (struct glyph_string *s, int from, int to, - int x, int y, int with_background) + int x, int y, bool with_background) { UINT options; HRGN orig_clip = NULL; @@ -805,7 +804,7 @@ static int w32font_otf_drive (struct font *font, Lisp_Object features, Lisp_Object gstring_in, int from, int to, Lisp_Object gstring_out, int idx, - int alternate_subst); + bool alternate_subst); */ /* Internal implementation of w32font_list. @@ -988,7 +987,6 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth; font->vertical_centering = 0; - font->encoding_type = 0; font->baseline_offset = 0; font->relative_compose = 0; font->default_ascent = w32_font->metrics.tmAscent; diff --git a/src/w32font.h b/src/w32font.h index a29ddbe778c..8fa00a9b524 100644 --- a/src/w32font.h +++ b/src/w32font.h @@ -77,7 +77,7 @@ int w32font_has_char (Lisp_Object entity, int c); int w32font_text_extents (struct font *font, unsigned *code, int nglyphs, struct font_metrics *metrics); int w32font_draw (struct glyph_string *s, int from, int to, - int x, int y, int with_background); + int x, int y, bool with_background); int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec); diff --git a/src/w32heap.c b/src/w32heap.c index f0753404792..e7d4c29e043 100644 --- a/src/w32heap.c +++ b/src/w32heap.c @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include "w32heap.h" #include "lisp.h" /* for VALMASK */ diff --git a/src/w32inevt.c b/src/w32inevt.c index ca97fed1fe6..a036fcbefe1 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <windows.h> -#include <setjmp.h> #ifndef MOUSE_MOVED #define MOUSE_MOVED 1 diff --git a/src/w32menu.c b/src/w32menu.c index 886fd55bbe9..4d820471f17 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -835,7 +835,7 @@ w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, else if (EQ (type, QCradio)) wv->button_type = BUTTON_TYPE_RADIO; else - abort (); + emacs_abort (); wv->selected = !NILP (selected); diff --git a/src/w32proc.c b/src/w32proc.c index 0cc62aebca0..27d93e4a7b4 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <signal.h> #include <sys/file.h> -#include <setjmp.h> /* must include CRT headers *before* config.h */ #include <config.h> @@ -89,6 +88,29 @@ sys_signal (int sig, signal_handler handler) return old; } +/* Emulate sigaction. */ +int +sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +{ + signal_handler old; + + if (sig != SIGCHLD) + { + errno = EINVAL; + return -1; + } + old = sig_handlers[sig]; + if (act) + sig_handlers[sig] = act->sa_handler; + if (oact) + { + oact->sa_handler = old; + oact->sa_flags = 0; + oact->sa_mask = empty_mask; + } + return 0; +} + /* Defined in <process.h> which conflicts with the local copy */ #define _P_NOWAIT 1 @@ -162,7 +184,7 @@ delete_child (child_process *cp) /* Should not be deleting a child that is still needed. */ for (i = 0; i < MAXDESC; i++) if (fd_info[i].cp == cp) - abort (); + emacs_abort (); if (!CHILD_ACTIVE (cp)) return; @@ -302,7 +324,7 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app, DWORD flags; char dir[ MAXPATHLEN ]; - if (cp == NULL) abort (); + if (cp == NULL) emacs_abort (); memset (&start, 0, sizeof (start)); start.cb = sizeof (start); @@ -391,7 +413,7 @@ register_child (int pid, int fd) if (fd_info[fd].cp != NULL) { DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd)); - abort (); + emacs_abort (); } fd_info[fd].cp = cp; @@ -445,7 +467,7 @@ sys_wait (int *status) /* We want to wait for a specific child */ wait_hnd[nh] = dead_child->procinfo.hProcess; cps[nh] = dead_child; - if (!wait_hnd[nh]) abort (); + if (!wait_hnd[nh]) emacs_abort (); nh++; active = 0; goto get_result; @@ -493,7 +515,7 @@ sys_wait (int *status) active -= WAIT_ABANDONED_0; } else - abort (); + emacs_abort (); get_result: if (!GetExitCodeProcess (wait_hnd[active], &retval)) @@ -1175,7 +1197,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, #endif wait_hnd[nh] = cp->char_avail; fdindex[nh] = i; - if (!wait_hnd[nh]) abort (); + if (!wait_hnd[nh]) emacs_abort (); nh++; #ifdef FULL_DEBUG DebPrint (("select waiting on child %d fd %d\n", @@ -1262,7 +1284,7 @@ count_children: active -= WAIT_ABANDONED_0; } else - abort (); + emacs_abort (); /* Loop over all handles after active (now officially documented as being the first signaled handle in the array). We do this to @@ -1392,6 +1414,9 @@ sys_kill (int pid, int sig) int need_to_free = 0; int rc = 0; + if (pid == getpid () && sig == SIGABRT) + emacs_abort (); + /* Only handle signals that will result in the process dying */ if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) { diff --git a/src/w32reg.c b/src/w32reg.c index 9c727ae5ab7..8a6a3c853b1 100644 --- a/src/w32reg.c +++ b/src/w32reg.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Written by Kevin Gallo */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "w32term.h" #include "blockinput.h" diff --git a/src/w32select.c b/src/w32select.c index 6b855b43a35..b616f232eea 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -73,7 +73,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ */ #include <config.h> -#include <setjmp.h> #include "lisp.h" #include "w32term.h" /* for all of the w32 includes */ #include "w32heap.h" /* os_subtype */ @@ -399,7 +398,7 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg) BLOCK_INPUT; - /* Fsignal calls abort() if it sees that waiting_for_input is + /* Fsignal calls emacs_abort () if it sees that waiting_for_input is set. */ owfi = waiting_for_input; waiting_for_input = 0; diff --git a/src/w32term.c b/src/w32term.c index 0dffcd0bf0a..af075955e2c 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <signal.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "blockinput.h" #include "w32term.h" @@ -2440,7 +2439,7 @@ x_draw_glyph_string (struct glyph_string *s) break; default: - abort (); + emacs_abort (); } if (!s->for_overlaps) @@ -2605,6 +2604,7 @@ x_draw_glyph_string (struct glyph_string *s) w32_set_clip_rectangle (next->hdc, NULL); next->hl = save; next->num_clips = 0; + next->clip_head = s->next; } } } @@ -2640,7 +2640,7 @@ x_delete_glyphs (struct frame *f, register int n) if (! FRAME_W32_P (f)) return; - abort (); + emacs_abort (); } @@ -2723,7 +2723,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n) if (! FRAME_W32_P (f)) return; - abort (); + emacs_abort (); } @@ -3445,7 +3445,7 @@ x_window_to_scroll_bar (Window window_id) frame = XCAR (tail); /* All elements of Vframe_list should be frames. */ if (! FRAMEP (frame)) - abort (); + emacs_abort (); /* Scan this frame's scroll bar list for a scroll bar with the right window ID. */ @@ -3868,7 +3868,7 @@ w32_redeem_scroll_bar (struct window *window) /* We can't redeem this window's scroll bar if it doesn't have one. */ if (NILP (window->vertical_scroll_bar)) - abort (); + emacs_abort (); bar = XSCROLL_BAR (window->vertical_scroll_bar); @@ -3887,7 +3887,7 @@ w32_redeem_scroll_bar (struct window *window) else /* If its prev pointer is nil, it must be at the front of one or the other! */ - abort (); + emacs_abort (); } else XSCROLL_BAR (bar->prev)->next = bar->next; @@ -3942,7 +3942,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, struct input_event *emacs_event) { if (! WINDOWP (bar->window)) - abort (); + emacs_abort (); emacs_event->kind = SCROLL_BAR_CLICK_EVENT; emacs_event->code = 0; @@ -4177,6 +4177,7 @@ w32_read_socket (struct terminal *terminal, int expected, if (interrupt_input_blocked) { interrupt_input_pending = 1; + pending_signals = 1; return -1; } @@ -5255,7 +5256,7 @@ w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, break; default: - abort (); + emacs_abort (); } } } diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index bc45e2c648c..5d160b9d42f 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define _WIN32_WINNT 0x500 #include <windows.h> #include <usp10.h> -#include <setjmp.h> #include "lisp.h" #include "w32term.h" @@ -454,7 +453,11 @@ uniscribe_shape (Lisp_Object lgstring) } else ASET (vec, 0, make_number (offsets[j].du + adj_offset)); - ASET (vec, 1, make_number (offsets[j].dv)); + /* In the font definition coordinate system, the + Y coordinate points up, while in our screen + coordinates Y grows downwards. So we need to + reverse the sign of Y-OFFSET here. */ + ASET (vec, 1, make_number (-offsets[j].dv)); /* Based on what ftfont.c does... */ ASET (vec, 2, make_number (advances[j])); LGLYPH_SET_ADJUSTMENT (lglyph, vec); diff --git a/src/w32xfns.c b/src/w32xfns.c index dfafb0ac742..1a67b018dd5 100644 --- a/src/w32xfns.c +++ b/src/w32xfns.c @@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <signal.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "keyboard.h" @@ -131,7 +130,7 @@ get_frame_dc (FRAME_PTR f) HDC hdc; if (f->output_method != output_w32) - abort (); + emacs_abort (); enter_crit (); diff --git a/src/widget.c b/src/widget.c index b94c30f4e9c..fd5ad167125 100644 --- a/src/widget.c +++ b/src/widget.c @@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> + #include "lisp.h" #include "xterm.h" @@ -50,9 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <X11/ShellP.h> #include "../lwlib/lwlib.h" -#include <signal.h> -#include "syssignal.h" - #include "character.h" #include "font.h" @@ -226,7 +223,7 @@ get_wm_shell (Widget w) static void mark_shell_size_user_specified (Widget wmshell) { - if (! XtIsWMShell (wmshell)) abort (); + if (! XtIsWMShell (wmshell)) emacs_abort (); /* This is kind of sleazy, but I can't see how else to tell it to make it mark the WM_SIZE_HINTS size as user specified when appropriate. */ ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; @@ -290,7 +287,7 @@ set_frame_size (EmacsFrame ew) Widget wmshell = get_wm_shell ((Widget) ew); /* Each Emacs shell is now independent and top-level. */ - if (! XtIsSubclass (wmshell, shellWidgetClass)) abort (); + if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort (); /* We don't need this for the moment. The geometry is computed in xfns.c. */ @@ -671,16 +668,14 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs update_wm_hints (ew); } -extern void free_frame_faces (struct frame *); - static void EmacsFrameDestroy (Widget widget) { EmacsFrame ew = (EmacsFrame) widget; struct frame* s = ew->emacs_frame.frame; - if (! s) abort (); - if (! s->output_data.x) abort (); + if (! s) emacs_abort (); + if (! s->output_data.x) emacs_abort (); BLOCK_INPUT; x_free_gcs (s); diff --git a/src/window.c b/src/window.c index 117e86065e3..114bd28c310 100644 --- a/src/window.c +++ b/src/window.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define WINDOW_INLINE EXTERN_INLINE #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -176,11 +175,6 @@ wset_new_total (struct window *w, Lisp_Object val) w->new_total = val; } static inline void -wset_next_buffers (struct window *w, Lisp_Object val) -{ - w->next_buffers = val; -} -static inline void wset_normal_cols (struct window *w, Lisp_Object val) { w->normal_cols = val; @@ -201,11 +195,6 @@ wset_pointm (struct window *w, Lisp_Object val) w->pointm = val; } static inline void -wset_prev_buffers (struct window *w, Lisp_Object val) -{ - w->prev_buffers = val; -} -static inline void wset_right_fringe_width (struct window *w, Lisp_Object val) { w->right_fringe_width = val; @@ -386,7 +375,7 @@ the first window of that frame. */) else if (! NILP (XWINDOW (window)->vchild)) window = XWINDOW (window)->vchild; else - abort (); + emacs_abort (); } return window; @@ -1289,7 +1278,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\ return Qnil; default: - abort (); + emacs_abort (); } } @@ -1866,23 +1855,23 @@ return value is a list of elements of the form (PARAMETER . VALUE). */) DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 2, 2, 0, doc: /* Return WINDOW's value for PARAMETER. -WINDOW must be a valid window and defaults to the selected one. */) +WINDOW can be any window and defaults to the selected one. */) (Lisp_Object window, Lisp_Object parameter) { Lisp_Object result; - result = Fassq (parameter, decode_valid_window (window)->window_parameters); + result = Fassq (parameter, decode_any_window (window)->window_parameters); return CDR_SAFE (result); } DEFUN ("set-window-parameter", Fset_window_parameter, Sset_window_parameter, 3, 3, 0, doc: /* Set WINDOW's value of PARAMETER to VALUE. -WINDOW must be a valid window and defaults to the selected one. +WINDOW can be any window and defaults to the selected one. Return VALUE. */) (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) { - register struct window *w = decode_valid_window (window); + register struct window *w = decode_any_window (window); Lisp_Object old_alist_elt; old_alist_elt = Fassq (parameter, w->window_parameters); @@ -1948,7 +1937,7 @@ unshow_buffer (register struct window *w) buf = w->buffer; b = XBUFFER (buf); if (b != XMARKER (w->pointm)->buffer) - abort (); + emacs_abort (); #if 0 if (w == XWINDOW (selected_window) @@ -2668,8 +2657,8 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame /* Check for a window that has a killed buffer. */ case CHECK_ALL_WINDOWS: if (! NILP (w->buffer) - && NILP (BVAR (XBUFFER (w->buffer), name))) - abort (); + && !BUFFER_LIVE_P (XBUFFER (w->buffer))) + emacs_abort (); break; case WINDOW_LOOP_UNUSED: @@ -3273,7 +3262,7 @@ This function runs `window-scroll-functions' before running XSETWINDOW (window, w); buffer = Fget_buffer (buffer_or_name); CHECK_BUFFER (buffer); - if (NILP (BVAR (XBUFFER (buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (buffer))) error ("Attempt to display deleted buffer"); tem = w->buffer; @@ -3338,7 +3327,7 @@ displaying that buffer. */) if (STRINGP (object)) object = Fget_buffer (object); - if (BUFFERP (object) && !NILP (BVAR (XBUFFER (object), name))) + if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object))) { /* Walk all windows looking for buffer, and force update of each of those windows. */ @@ -5549,7 +5538,7 @@ the return value is nil. Otherwise the value is t. */) saved_windows = XVECTOR (data->saved_windows); new_current_buffer = data->current_buffer; - if (NILP (BVAR (XBUFFER (new_current_buffer), name))) + if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer))) new_current_buffer = Qnil; else { @@ -5624,7 +5613,7 @@ the return value is nil. Otherwise the value is t. */) w = XWINDOW (window); if (!NILP (w->buffer) && !EQ (w->buffer, p->buffer) - && !NILP (BVAR (XBUFFER (p->buffer), name))) + && BUFFER_LIVE_P (XBUFFER (p->buffer))) /* If a window we restore gets another buffer, record the window's old buffer. */ call1 (Qrecord_window_buffer, window); @@ -5774,7 +5763,7 @@ the return value is nil. Otherwise the value is t. */) if (NILP (p->buffer)) /* An internal window. */ wset_buffer (w, p->buffer); - else if (!NILP (BVAR (XBUFFER (p->buffer), name))) + else if (BUFFER_LIVE_P (XBUFFER (p->buffer))) /* If saved buffer is alive, install it. */ { wset_buffer (w, p->buffer); @@ -5793,7 +5782,7 @@ the return value is nil. Otherwise the value is t. */) Fgoto_char (w->pointm); } else if (!NILP (w->buffer) - && !NILP (BVAR (XBUFFER (w->buffer), name))) + && BUFFER_LIVE_P (XBUFFER (w->buffer))) /* Keep window's old buffer; make sure the markers are real. */ { @@ -6576,15 +6565,17 @@ freeze_window_starts (struct frame *f, int freeze_p) /* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 describe the same state of affairs. This is used by Fequal. - ignore_positions non-zero means ignore non-matching scroll positions + IGNORE_POSITIONS means ignore non-matching scroll positions and the like. This ignores a couple of things like the dedication status of window, combination_limit and the like. This might have to be fixed. */ -int -compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions) +bool +compare_window_configurations (Lisp_Object configuration1, + Lisp_Object configuration2, + bool ignore_positions) { register struct save_window_data *d1, *d2; struct Lisp_Vector *sws1, *sws2; diff --git a/src/window.h b/src/window.h index dfb88b2cf3c..62ae43a999d 100644 --- a/src/window.h +++ b/src/window.h @@ -27,8 +27,6 @@ INLINE_HEADER_BEGIN # define WINDOW_INLINE INLINE #endif -extern Lisp_Object Qleft, Qright; - /* Windows are allocated as if they were vectors, but then the Lisp data type is changed to Lisp_Window. They are garbage collected along with the vectors. @@ -416,7 +414,16 @@ wset_window_end_vpos (struct window *w, Lisp_Object val) { w->window_end_vpos = val; } - +WINDOW_INLINE void +wset_prev_buffers (struct window *w, Lisp_Object val) +{ + w->prev_buffers = val; +} +WINDOW_INLINE void +wset_next_buffers (struct window *w, Lisp_Object val) +{ + w->next_buffers = val; +} /* 1 if W is a minibuffer window. */ @@ -973,7 +980,7 @@ extern Lisp_Object Qwindowp, Qwindow_live_p; extern Lisp_Object Vwindow_list; extern struct window *decode_live_window (Lisp_Object); -extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); +extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); extern void mark_window_cursors_off (struct window *); extern int window_internal_height (struct window *); extern int window_body_cols (struct window *w); diff --git a/src/xdisp.c b/src/xdisp.c index 9b9b91a8905..1f6a60c0b87 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -273,7 +273,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <limits.h> -#include <setjmp.h> #include "lisp.h" #include "keyboard.h" @@ -768,9 +767,9 @@ static int clear_image_cache_count; static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 }; #endif -/* Non-zero while redisplay_internal is in progress. */ +/* True while redisplay_internal is in progress. */ -int redisplaying_p; +bool redisplaying_p; static Lisp_Object Qinhibit_free_realized_faces; static Lisp_Object Qmode_line_default_help_echo; @@ -3666,7 +3665,7 @@ handle_fontified_prop (struct it *it) } /* There isn't much we can reasonably do to protect against misbehaving fontification, but here's a fig leaf. */ - else if (!NILP (BVAR (obuf, name))) + else if (BUFFER_LIVE_P (obuf)) set_buffer_internal_1 (obuf); /* The fontification code may have added/removed text. @@ -7306,7 +7305,7 @@ set_iterator_to_next (struct it *it, int reseat_p) default: /* There are no other methods defined, so this should be a bug. */ - abort (); + emacs_abort (); } eassert (it->method != GET_FROM_STRING @@ -7761,7 +7760,7 @@ compute_stop_pos_backwards (struct it *it) compute_stop_pos (it); /* We must advance forward, right? */ if (it->stop_charpos <= charpos) - abort (); + emacs_abort (); } while (charpos > BEGV && it->stop_charpos >= it->end_charpos); @@ -7810,7 +7809,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos) compute_stop_pos (it); /* We must advance forward, right? */ if (it->stop_charpos <= it->prev_stop) - abort (); + emacs_abort (); charpos = it->stop_charpos; } while (charpos <= where_we_are); @@ -8898,7 +8897,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos break; default: - abort (); + emacs_abort (); } /* Reset/increment for the next run. */ @@ -9291,12 +9290,6 @@ add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2) struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; USE_SAFE_ALLOCA; - /* Do nothing if called asynchronously. Inserting text into - a buffer may call after-change-functions and alike and - that would means running Lisp asynchronously. */ - if (handling_signal) - return; - fmt = msg = Qnil; GCPRO4 (fmt, msg, arg1, arg2); @@ -9909,7 +9902,7 @@ ensure_echo_area_buffers (void) for (i = 0; i < 2; ++i) if (!BUFFERP (echo_buffer[i]) - || NILP (BVAR (XBUFFER (echo_buffer[i]), name))) + || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i]))) { char name[30]; Lisp_Object old_buffer; @@ -10532,7 +10525,7 @@ void check_message_stack (void) { if (!NILP (Vmessage_stack)) - abort (); + emacs_abort (); } @@ -10571,7 +10564,6 @@ truncate_message_1 (ptrdiff_t nchars, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4 return 0; } - /* Set the current message to a substring of S or STRING. If STRING is a Lisp string, set the message to the first NBYTES @@ -10598,6 +10590,10 @@ set_message (const char *s, Lisp_Object string, (intptr_t) s, string, nbytes, multibyte_p); message_buf_print = 0; help_echo_showing_p = 0; + + if (STRINGP (Vdebug_on_message) + && fast_string_match (Vdebug_on_message, string) >= 0) + call_debugger (list2 (Qerror, string)); } @@ -12789,7 +12785,7 @@ overlay_arrow_at_row (struct it *it, struct glyph_row *row) return make_number (fringe_bitmap); } #endif - return make_number (-1); /* Use default arrow bitmap */ + return make_number (-1); /* Use default arrow bitmap. */ } return overlay_arrow_string_or_property (var); } @@ -12966,12 +12962,11 @@ redisplay_internal (void) if (redisplaying_p) return; - /* Record a function that resets redisplaying_p to its old value + /* Record a function that clears redisplaying_p when we leave this function. */ count = SPECPDL_INDEX (); - record_unwind_protect (unwind_redisplay, - Fcons (make_number (redisplaying_p), selected_frame)); - ++redisplaying_p; + record_unwind_protect (unwind_redisplay, selected_frame); + redisplaying_p = 1; specbind (Qinhibit_free_realized_faces, Qnil); { @@ -13709,21 +13704,15 @@ redisplay_preserve_echo_area (int from_where) } -/* Function registered with record_unwind_protect in - redisplay_internal. Reset redisplaying_p to the value it had - before redisplay_internal was called, and clear - prevent_freeing_realized_faces_p. It also selects the previously +/* Function registered with record_unwind_protect in redisplay_internal. + Clear redisplaying_p. Also, select the previously selected frame, unless it has been deleted (by an X connection failure during redisplay, for example). */ static Lisp_Object -unwind_redisplay (Lisp_Object val) +unwind_redisplay (Lisp_Object old_frame) { - Lisp_Object old_redisplaying_p, old_frame; - - old_redisplaying_p = XCAR (val); - redisplaying_p = XFASTINT (old_redisplaying_p); - old_frame = XCDR (val); + redisplaying_p = 0; if (! EQ (old_frame, selected_frame) && FRAME_LIVE_P (XFRAME (old_frame))) select_frame_for_redisplay (old_frame); @@ -14422,7 +14411,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) { if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]) - abort (); + emacs_abort (); x += g->pixel_width; } } @@ -14543,7 +14532,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp) SET_MARKER_FROM_TEXT_POS (w->start, startp); if (current_buffer != XBUFFER (w->buffer)) - abort (); + emacs_abort (); if (!NILP (Vwindow_scroll_functions)) { @@ -15512,9 +15501,9 @@ redisplay_window (Lisp_Object window, int just_this_one_p) /* Some sanity checks. */ CHECK_WINDOW_END (w); if (Z == Z_BYTE && CHARPOS (opoint) != BYTEPOS (opoint)) - abort (); + emacs_abort (); if (BYTEPOS (opoint) < CHARPOS (opoint)) - abort (); + emacs_abort (); /* If %c is in mode line, update it if needed. */ if (!NILP (w->column_number_displayed) @@ -15726,7 +15715,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) goto try_to_scroll; default: - abort (); + emacs_abort (); } } /* If current starting point was originally the beginning of a line @@ -15889,7 +15878,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) break; default: - abort (); + emacs_abort (); } } @@ -17337,7 +17326,7 @@ try_window_id (struct window *w) if (row) set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); else - abort (); + emacs_abort (); return 1; } } @@ -17381,7 +17370,7 @@ try_window_id (struct window *w) if (row) set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); else - abort (); + emacs_abort (); return 2; } } @@ -17870,7 +17859,7 @@ try_window_id (struct window *w) IF_DEBUG (debug_method_add (w, "C")); } else - abort (); + emacs_abort (); IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos); debug_end_vpos = XFASTINT (w->window_end_vpos)); @@ -19247,7 +19236,7 @@ find_row_edges (struct it *it, struct glyph_row *row, /* A line that is entirely from a string/image/stretch... */ row->maxpos = row->minpos; else - abort (); + emacs_abort (); } else row->maxpos = it->current.pos; @@ -20088,7 +20077,7 @@ See also `bidi-paragraph-direction'. */) return Qright_to_left; break; default: - abort (); + emacs_abort (); } } } @@ -21043,8 +21032,7 @@ are the selected window and the WINDOW's buffer). */) : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID : DEFAULT_FACE_ID; - if (XBUFFER (buffer) != current_buffer) - old_buffer = current_buffer; + old_buffer = current_buffer; /* Save things including mode_line_proptrans_alist, and set that to nil so that we don't alter the outer value. */ @@ -21055,8 +21043,7 @@ are the selected window and the WINDOW's buffer). */) mode_line_proptrans_alist = Qnil; Fselect_window (window, Qt); - if (old_buffer) - set_buffer_internal_1 (XBUFFER (buffer)); + set_buffer_internal_1 (XBUFFER (buffer)); init_iterator (&it, w, -1, -1, NULL, face_id); @@ -22001,7 +21988,7 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st { /* Glyph is off the left margin of the display area. Should not happen. */ - abort (); + emacs_abort (); } row->ascent = max (row->ascent, it->max_ascent); @@ -23046,7 +23033,8 @@ right_overwritten (struct glyph_string *s) { int x = 0, i; struct glyph *glyphs = s->row->glyphs[s->area]; - int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); + int first = (s->first_glyph - glyphs + + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars)); int end = s->row->used[s->area]; for (i = first; i < end && s->right_overhang > x; ++i) @@ -23069,7 +23057,8 @@ right_overwriting (struct glyph_string *s) int i, k, x; int end = s->row->used[s->area]; struct glyph *glyphs = s->row->glyphs[s->area]; - int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); + int first = (s->first_glyph - glyphs + + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars)); k = -1; x = 0; @@ -23366,7 +23355,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) break; \ \ default: \ - abort (); \ + emacs_abort (); \ } \ \ if (s) \ @@ -23707,7 +23696,7 @@ append_glyph (struct it *it) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } else @@ -23781,7 +23770,7 @@ append_composite_glyph (struct it *it) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } ++it->glyph_row->used[area]; @@ -23960,7 +23949,7 @@ produce_image_glyph (struct it *it) { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } ++it->glyph_row->used[area]; @@ -24021,7 +24010,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object, { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } else @@ -24276,7 +24265,7 @@ produce_special_glyphs (struct it *it, enum display_element_type what) } } else - abort (); + emacs_abort (); #ifdef HAVE_WINDOW_SYSTEM /* On a GUI frame, when the right fringe (left fringe for R2L rows) @@ -24473,7 +24462,7 @@ append_glyphless_glyph (struct it *it, int face_id, int for_no_font, int len, { glyph->resolved_level = it->bidi_it.resolved_level; if ((it->bidi_it.type & 7) != it->bidi_it.type) - abort (); + emacs_abort (); glyph->bidi_type = it->bidi_it.type; } ++it->glyph_row->used[area]; @@ -29306,6 +29295,10 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil); Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0), Qempty_box); + + DEFVAR_LISP ("debug-on-message", Vdebug_on_message, + doc: /* If non-nil, debug if a message matching this regexp is displayed. */); + Vdebug_on_message = Qnil; } diff --git a/src/xfaces.c b/src/xfaces.c index 67e9c2c37c6..51e568547ee 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -204,7 +204,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> /* This needs to be before termchar.h */ -#include <setjmp.h> #include "lisp.h" #include "character.h" @@ -315,9 +314,10 @@ static Lisp_Object QCfontset; Lisp_Object Qnormal; Lisp_Object Qbold; static Lisp_Object Qline, Qwave; -Lisp_Object Qultra_light, Qextra_light, Qlight; +static Lisp_Object Qultra_light, Qreverse_oblique, Qreverse_italic; +Lisp_Object Qextra_light, Qlight; Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; -Lisp_Object Qoblique, Qreverse_oblique, Qreverse_italic; +Lisp_Object Qoblique; Lisp_Object Qitalic; static Lisp_Object Qultra_condensed, Qextra_condensed; Lisp_Object Qcondensed; @@ -452,18 +452,7 @@ static int menu_face_changed_default; struct table_entry; struct named_merge_point; -static void map_tty_color (struct frame *, struct face *, - enum lface_attribute_index, int *); -static Lisp_Object resolve_face_name (Lisp_Object, int); static void set_font_frame_param (Lisp_Object, Lisp_Object); -static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *, - int, struct named_merge_point *); -static ptrdiff_t load_pixmap (struct frame *, Lisp_Object, - unsigned *, unsigned *); -static struct frame *frame_or_selected_frame (Lisp_Object, int); -static void load_face_colors (struct frame *, struct face *, Lisp_Object *); -static void free_face_colors (struct frame *, struct face *); -static int face_color_gray_p (struct frame *, const char *); static struct face *realize_face (struct face_cache *, Lisp_Object *, int); static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, @@ -473,38 +462,11 @@ static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); static int realize_basic_faces (struct frame *); static int realize_default_face (struct frame *); static void realize_named_face (struct frame *, Lisp_Object, int); -static int lface_fully_specified_p (Lisp_Object *); -static int lface_equal_p (Lisp_Object *, Lisp_Object *); -static unsigned hash_string_case_insensitive (Lisp_Object); -static unsigned lface_hash (Lisp_Object *); -static int lface_same_font_attributes_p (Lisp_Object *, Lisp_Object *); static struct face_cache *make_face_cache (struct frame *); static void clear_face_gcs (struct face_cache *); static void free_face_cache (struct face_cache *); -static int face_fontset (Lisp_Object *); -static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*, - struct named_merge_point *); static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, int, struct named_merge_point *); -static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object, - int); -static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int); -static struct face *make_realized_face (Lisp_Object *); -static void cache_face (struct face_cache *, struct face *, unsigned); -static void uncache_face (struct face_cache *, struct face *); - -#ifdef HAVE_WINDOW_SYSTEM - -static GC x_create_gc (struct frame *, unsigned long, XGCValues *); -static void x_free_gc (struct frame *, GC); - -#ifdef USE_X_TOOLKIT -static void x_update_menu_appearance (struct frame *); - -extern void free_frame_menubar (struct frame *); -#endif /* USE_X_TOOLKIT */ - -#endif /* HAVE_WINDOW_SYSTEM */ /*********************************************************************** @@ -547,7 +509,7 @@ unregister_color (unsigned long pixel) if (color_count[pixel] > 0) --color_count[pixel]; else - abort (); + emacs_abort (); } @@ -698,7 +660,7 @@ x_create_gc (struct frame *f, XGCValues *xgcv) { GC gc = xmalloc (sizeof *gc); - memcpy (gc, xgcv, sizeof (XGCValues)); + *gc = *xgcv; return gc; } @@ -764,7 +726,7 @@ init_frame_faces (struct frame *f) if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) #endif if (!realize_basic_faces (f)) - abort (); + emacs_abort (); } @@ -808,7 +770,7 @@ recompute_basic_faces (struct frame *f) { clear_face_cache (0); if (!realize_basic_faces (f)) - abort (); + emacs_abort (); } } @@ -1145,7 +1107,7 @@ defined_color (struct frame *f, const char *color_name, XColor *color_def, return ns_defined_color (f, color_name, color_def, alloc, 1); #endif else - abort (); + emacs_abort (); } @@ -1341,7 +1303,7 @@ load_color (struct frame *f, struct face *face, Lisp_Object name, break; default: - abort (); + emacs_abort (); } } #ifdef GLYPH_DEBUG @@ -4585,7 +4547,7 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, int signal_p) return -1; default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); if (default_face == NULL) - abort (); /* realize_basic_faces must have set it up */ + emacs_abort (); /* realize_basic_faces must have set it up */ } if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) @@ -4628,7 +4590,7 @@ lookup_basic_face (struct frame *f, int face_id) case MENU_FACE_ID: name = Qmenu; break; default: - abort (); /* the caller is supposed to pass us a basic face id */ + emacs_abort (); /* the caller is supposed to pass us a basic face id */ } /* Do a quick scan through Vface_remapping_alist, and return immediately @@ -4749,7 +4711,7 @@ lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id, struct face *default_face = FACE_FROM_ID (f, face_id); if (!default_face) - abort (); + emacs_abort (); if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) return -1; @@ -5139,7 +5101,7 @@ face for italic. */) error ("Cannot realize default face"); def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); if (def_face == NULL) - abort (); /* realize_basic_faces must have set it up */ + emacs_abort (); /* realize_basic_faces must have set it up */ } /* Dispatch to the appropriate handler. */ @@ -5424,7 +5386,7 @@ realize_default_face (struct frame *f) else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg)); else - abort (); + emacs_abort (); } if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) @@ -5439,7 +5401,7 @@ realize_default_face (struct frame *f) else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg)); else - abort (); + emacs_abort (); } if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) @@ -5539,7 +5501,7 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id) face = make_realized_face (attrs); } else - abort (); + emacs_abort (); /* Insert the new face. */ cache_face (cache, face, lface_hash (attrs)); @@ -5634,7 +5596,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs) if (default_face) fontset = default_face->fontset; if (fontset == -1) - abort (); + emacs_abort (); } if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX])) attrs[LFACE_FONT_INDEX] diff --git a/src/xfns.c b/src/xfns.c index 90b54d12345..8304a3df04f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <math.h> -#include <setjmp.h> #include <unistd.h> /* This makes the fields of a Display accessible, in Xlib header files. */ diff --git a/src/xfont.c b/src/xfont.c index cbb24622ae9..1f2fd13f1b7 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <X11/Xlib.h> #include "lisp.h" @@ -46,7 +45,6 @@ struct xfont_info }; /* Prototypes of support functions. */ -extern void x_clear_errors (Display *); static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); @@ -127,7 +125,7 @@ static int xfont_has_char (Lisp_Object, int); static unsigned xfont_encode_char (struct font *, int); static int xfont_text_extents (struct font *, unsigned *, int, struct font_metrics *); -static int xfont_draw (struct glyph_string *, int, int, int, int, int); +static int xfont_draw (struct glyph_string *, int, int, int, int, bool); static int xfont_check (FRAME_PTR, struct font *); struct font_driver xfont_driver = @@ -218,9 +216,9 @@ xfont_encode_coding_xlfd (char *xlfd) /* Check if CHARS (cons or vector) is supported by XFONT whose encoding charset is ENCODING (XFONT is NULL) or by a font whose registry corresponds to ENCODING and REPERTORY. - Return 1 if supported, return 0 otherwise. */ + Return true if supported. */ -static int +static bool xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, struct charset *encoding, struct charset *repertory) { @@ -1020,7 +1018,8 @@ xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct f } static int -xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) +xfont_draw (struct glyph_string *s, int from, int to, int x, int y, + bool with_background) { XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; int len = to - from; @@ -1041,7 +1040,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_bac for (i = 0; i < len ; i++) str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); BLOCK_INPUT; - if (with_background > 0) + if (with_background) { if (s->padding_p) for (i = 0; i < len; i++) @@ -1067,7 +1066,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_bac } BLOCK_INPUT; - if (with_background > 0) + if (with_background) { if (s->padding_p) for (i = 0; i < len; i++) diff --git a/src/xftfont.c b/src/xftfont.c index 5e60ab0c4d3..9f52eb8b233 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <setjmp.h> #include <X11/Xlib.h> #include <X11/Xft/Xft.h> @@ -52,7 +51,7 @@ struct xftfont_info /* The following five members must be here in this order to be compatible with struct ftfont_info (in ftfont.c). */ #ifdef HAVE_LIBOTF - int maybe_otf; /* Flag to tell if this may be OTF or not. */ + bool maybe_otf; /* Flag to tell if this may be OTF or not. */ OTF *otf; #endif /* HAVE_LIBOTF */ FT_Size ft_size; @@ -92,7 +91,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info * else { XGCValues xgcv; - int fg_done = 0, bg_done = 0; + bool fg_done = 0, bg_done = 0; BLOCK_INPUT; XGetGCValues (FRAME_X_DISPLAY (f), gc, @@ -111,7 +110,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info * *bg = xftface_info->xft_fg, bg_done = 1; } - if (fg_done + bg_done < 2) + if (! (fg_done & bg_done)) { XColor colors[2]; @@ -137,19 +136,6 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info * } -static Lisp_Object xftfont_list (Lisp_Object, Lisp_Object); -static Lisp_Object xftfont_match (Lisp_Object, Lisp_Object); -static Lisp_Object xftfont_open (FRAME_PTR, Lisp_Object, int); -static void xftfont_close (FRAME_PTR, struct font *); -static int xftfont_prepare_face (FRAME_PTR, struct face *); -static void xftfont_done_face (FRAME_PTR, struct face *); -static int xftfont_has_char (Lisp_Object, int); -static unsigned xftfont_encode_char (struct font *, int); -static int xftfont_text_extents (struct font *, unsigned *, int, - struct font_metrics *); -static int xftfont_draw (struct glyph_string *, int, int, int, int, int); -static int xftfont_end_for_frame (FRAME_PTR f); - struct font_driver xftfont_driver; static Lisp_Object @@ -470,7 +456,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) font->underline_thickness = 0; } #ifdef HAVE_LIBOTF - xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; + xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0; xftfont_info->otf = NULL; #endif /* HAVE_LIBOTF */ xftfont_info->ft_size = ft_face->size; @@ -630,7 +616,8 @@ xftfont_get_xft_draw (FRAME_PTR f) } static int -xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) +xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, + bool with_background) { FRAME_PTR f = s->f; struct face *face = s->face; @@ -711,15 +698,17 @@ xftfont_end_for_frame (FRAME_PTR f) return 0; } -static int -xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity) +static bool +xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, + Lisp_Object entity) { struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object); FcPattern *oldpat = info->xftfont->pattern; Display *display = FRAME_X_DISPLAY (f); FcPattern *pat = FcPatternCreate (); FcBool b1, b2; - int ok = 0, i1, i2, r1, r2; + bool ok = 0; + int i1, i2, r1, r2; xftfont_add_rendering_parameters (pat, entity); XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); diff --git a/src/xgselect.c b/src/xgselect.c index 0c00d815820..c161564a322 100644 --- a/src/xgselect.c +++ b/src/xgselect.c @@ -19,14 +19,12 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */ #include <config.h> -#include <setjmp.h> #include "xgselect.h" #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) #include <glib.h> #include <errno.h> -#include <setjmp.h> #include "xterm.h" int @@ -49,9 +47,9 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, && g_main_context_pending (context = g_main_context_default ()))) return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); - if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); + if (rfds) all_rfds = *rfds; else FD_ZERO (&all_rfds); - if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); + if (wfds) all_wfds = *wfds; else FD_ZERO (&all_wfds); n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, diff --git a/src/xmenu.c b/src/xmenu.c index 54a7849218a..d03a4bc974b 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -32,13 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#if 0 /* Why was this included? And without syssignal.h? */ -/* On 4.3 this loses if it comes after xterm.h. */ -#include <signal.h> -#endif - #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "keyboard.h" @@ -169,7 +163,7 @@ mouse_position_for_popup (FRAME_PTR f, int *x, int *y) int dummy; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); BLOCK_INPUT; @@ -636,7 +630,7 @@ void x_activate_menubar (FRAME_PTR f) { if (! FRAME_X_P (f)) - abort (); + emacs_abort (); if (!f->output_data.x->saved_menu_event->type) return; @@ -852,7 +846,7 @@ update_frame_menubar (FRAME_PTR f) int columns, rows; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); x = f->output_data.x; @@ -940,7 +934,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) int *submenu_top_level_items, *submenu_n_panes; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); menubar_widget = f->output_data.x->menubar_widget; @@ -1299,7 +1293,7 @@ free_frame_menubar (FRAME_PTR f) Widget menubar_widget; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); menubar_widget = f->output_data.x->menubar_widget; @@ -1450,7 +1444,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, #endif if (! FRAME_X_P (f)) - abort (); + emacs_abort (); xg_crazy_callback_abort = 1; menu = xg_create_widget ("popup", first_wv->name, f, first_wv, @@ -1557,7 +1551,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, Widget menu; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); #ifdef USE_LUCID apply_systemfont_to_menu (f, f->output_data.x->widget); @@ -1646,7 +1640,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, ptrdiff_t specpdl_count = SPECPDL_INDEX (); if (! FRAME_X_P (f)) - abort (); + emacs_abort (); *error_name = NULL; @@ -1792,7 +1786,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, else if (EQ (type, QCradio)) wv->button_type = BUTTON_TYPE_RADIO; else - abort (); + emacs_abort (); wv->selected = !NILP (selected); @@ -1930,7 +1924,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv) GtkWidget *menu; if (! FRAME_X_P (f)) - abort (); + emacs_abort (); menu = xg_create_widget ("dialog", first_wv->name, f, first_wv, G_CALLBACK (dialog_selection_callback), @@ -1977,7 +1971,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv) LWLIB_ID dialog_id; if (!FRAME_X_P (f)) - abort (); + emacs_abort (); dialog_id = widget_id_tick++; #ifdef USE_LUCID @@ -2036,7 +2030,7 @@ xdialog_show (FRAME_PTR f, ptrdiff_t specpdl_count = SPECPDL_INDEX (); if (! FRAME_X_P (f)) - abort (); + emacs_abort (); *error_name = NULL; @@ -2301,7 +2295,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, ptrdiff_t specpdl_count = SPECPDL_INDEX (); if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f)) - abort (); + emacs_abort (); *error_name = 0; if (menu_items_n_panes == 0) diff --git a/src/xml.c b/src/xml.c index 7bc6130b8b1..b668525cf26 100644 --- a/src/xml.c +++ b/src/xml.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_LIBXML2 -#include <setjmp.h> #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/HTMLparser.h> diff --git a/src/xrdb.c b/src/xrdb.c index 624bafa5e92..73672c9617c 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <epaths.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" diff --git a/src/xselect.c b/src/xselect.c index 463bd6e37b0..ab199e0b9b9 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <limits.h> #include <stdio.h> /* termhooks.h needs this */ -#include <setjmp.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -193,7 +192,7 @@ static void x_start_queuing_selection_requests (void) { if (x_queue_selection_requests) - abort (); + emacs_abort (); x_queue_selection_requests++; TRACE1 ("x_start_queuing_selection_requests %d", x_queue_selection_requests); @@ -245,7 +244,7 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym) if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; - if (!SYMBOLP (sym)) abort (); + if (!SYMBOLP (sym)) emacs_abort (); TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); BLOCK_INPUT; @@ -1138,7 +1137,7 @@ wait_for_property_change (struct prop_location *location) ptrdiff_t count = SPECPDL_INDEX (); if (property_change_reply_object) - abort (); + emacs_abort (); /* Make sure to do unexpect_property_change if we quit or err. */ record_unwind_protect (wait_for_property_change_unwind, diff --git a/src/xsettings.c b/src/xsettings.c index a28d75d9422..58c84495489 100644 --- a/src/xsettings.c +++ b/src/xsettings.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <float.h> #include <limits.h> -#include <setjmp.h> #include <fcntl.h> #include "lisp.h" #include "xterm.h" @@ -711,12 +710,12 @@ apply_xft_settings (struct x_display_info *dpyinfo, if (send_event_p) store_config_changed_event (Qfont_render, XCAR (dpyinfo->name_list_element)); - Vxft_settings + Vxft_settings = make_formatted_string (buf, format, oldsettings.aa, oldsettings.hinting, oldsettings.rgba, oldsettings.lcdfilter, oldsettings.hintstyle, oldsettings.dpi); - + } else FcPatternDestroy (pat); diff --git a/src/xsmfns.c b/src/xsmfns.c index cddbb2aae86..8067899f931 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -29,7 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <sys/param.h> #include <stdio.h> -#include <setjmp.h> #include "lisp.h" #include "systime.h" diff --git a/src/xterm.c b/src/xterm.c index 7e61cc4d8ea..9ab53dc087a 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -21,17 +21,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Xt features made by Fred Pierresteguy. */ #include <config.h> -#include <signal.h> #include <stdio.h> -#include <setjmp.h> #ifdef HAVE_X_WINDOWS #include "lisp.h" #include "blockinput.h" - -/* Need syssignal.h for various externs and definitions that may be required - by some configurations for calls to signal later in this source file. */ #include "syssignal.h" /* This may include sys/types.h, and that somehow loses @@ -51,7 +46,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <errno.h> -#include <setjmp.h> #include <sys/stat.h> /* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */ /* #include <sys/param.h> */ @@ -165,13 +159,6 @@ struct x_display_info *x_display_list; Lisp_Object x_display_name_list; -/* Frame being updated by update_frame. This is declared in term.c. - This is set by update_begin and looked at by all the XT functions. - It is zero while not inside an update. In that case, the XT - functions assume that `selected_frame' is the frame to apply to. */ - -extern struct frame *updating_frame; - /* This is a frame waiting to be auto-raised, within XTread_socket. */ static struct frame *pending_autoraise_frame; @@ -1474,7 +1461,7 @@ x_frame_of_widget (Widget widget) && f->output_data.x->widget == widget) return f; - abort (); + emacs_abort (); } /* Allocate a color which is lighter or darker than *PIXEL by FACTOR @@ -2703,7 +2690,7 @@ x_draw_underwave (struct glyph_string *s) y2 += dy; if (INT_MAX - dx < xmax) - abort (); + emacs_abort (); while (x1 <= xmax) { @@ -2812,7 +2799,7 @@ x_draw_glyph_string (struct glyph_string *s) break; default: - abort (); + emacs_abort (); } if (!s->for_overlaps) @@ -2986,6 +2973,7 @@ x_draw_glyph_string (struct glyph_string *s) XSetClipMask (next->display, next->gc, None); next->hl = save; next->num_clips = 0; + next->clip_head = s->next; } } } @@ -3012,7 +3000,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, static void x_delete_glyphs (struct frame *f, register int n) { - abort (); + emacs_abort (); } @@ -3285,7 +3273,7 @@ XTset_terminal_window (struct frame *f, int n) static void x_ins_del_lines (struct frame *f, int vpos, int n) { - abort (); + emacs_abort (); } @@ -4122,7 +4110,7 @@ x_window_to_scroll_bar (Display *display, Window window_id) frame = XCAR (tail); /* All elements of Vframe_list should be frames. */ if (! FRAMEP (frame)) - abort (); + emacs_abort (); if (! FRAME_X_P (XFRAME (frame))) continue; @@ -5441,7 +5429,7 @@ XTredeem_scroll_bar (struct window *window) /* We can't redeem this window's scroll bar if it doesn't have one. */ if (NILP (window->vertical_scroll_bar)) - abort (); + emacs_abort (); bar = XSCROLL_BAR (window->vertical_scroll_bar); @@ -5460,7 +5448,7 @@ XTredeem_scroll_bar (struct window *window) else /* If its prev pointer is nil, it must be at the front of one or the other! */ - abort (); + emacs_abort (); } else XSCROLL_BAR (bar->prev)->next = bar->next; @@ -5558,7 +5546,7 @@ static void x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) { if (! WINDOWP (bar->window)) - abort (); + emacs_abort (); emacs_event->kind = SCROLL_BAR_CLICK_EVENT; emacs_event->code = event->xbutton.button - Button1; @@ -6464,7 +6452,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, } else if (status_return != XLookupKeySym && status_return != XLookupBoth) - abort (); + emacs_abort (); } else nbytes = XLookupString (&event.xkey, (char *) copy_bufptr, @@ -7141,25 +7129,17 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold if (interrupt_input_blocked) { interrupt_input_pending = 1; -#ifdef SYNC_INPUT pending_signals = 1; -#endif return -1; } interrupt_input_pending = 0; -#ifdef SYNC_INPUT pending_signals = pending_atimers; -#endif BLOCK_INPUT; /* So people can tell when we have read the available input. */ input_signal_count++; -#ifndef SYNC_INPUT - ++handling_signal; -#endif - /* For debugging, this gives a way to fake an I/O error. */ if (terminal->display_info.x == XTread_socket_fake_io_error) { @@ -7248,9 +7228,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold pending_autoraise_frame = 0; } -#ifndef SYNC_INPUT - --handling_signal; -#endif UNBLOCK_INPUT; return count; @@ -7503,7 +7480,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int break; default: - abort (); + emacs_abort (); } } @@ -7773,7 +7750,9 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */ #ifdef USG /* USG systems forget handlers when they are used; must reestablish each time */ - signal (signalnum, x_connection_signal); + struct sigaction action; + emacs_sigaction_init (&action, x_connection_signal); + sigaction (signalnum, &action, 0); #endif /* USG */ } @@ -7798,7 +7777,6 @@ x_connection_closed (Display *dpy, const char *error_message) error_msg = alloca (strlen (error_message) + 1); strcpy (error_msg, error_message); - handling_signal = 0; /* Inhibit redisplay while frames are being deleted. */ specbind (Qinhibit_redisplay, Qt); @@ -7850,13 +7828,13 @@ x_connection_closed (Display *dpy, const char *error_message) (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once, the resulting Glib error message loop filled a user's disk. To avoid this, kill Emacs unconditionally on disconnect. */ - shut_down_emacs (0, 0, Qnil); + shut_down_emacs (0, Qnil); fprintf (stderr, "%s\n\ When compiled with GTK, Emacs cannot recover from X disconnects.\n\ This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ For details, see etc/PROBLEMS.\n", error_msg); - abort (); + emacs_abort (); #endif /* USE_GTK */ /* Indicate that this display is dead. */ @@ -7866,7 +7844,7 @@ For details, see etc/PROBLEMS.\n", dpyinfo->terminal->reference_count--; if (dpyinfo->reference_count != 0) /* We have just closed all frames on this display. */ - abort (); + emacs_abort (); { Lisp_Object tmp; @@ -7883,10 +7861,15 @@ For details, see etc/PROBLEMS.\n", } /* Ordinary stack unwind doesn't deal with these. */ -#ifdef SIGIO - sigunblock (sigmask (SIGIO)); + { + sigset_t unblocked; + sigemptyset (&unblocked); +#ifdef USABLE_SIGIO + sigaddset (&unblocked, SIGIO); #endif - sigunblock (sigmask (SIGALRM)); + sigaddset (&unblocked, SIGALRM); + pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); + } TOTALLY_UNBLOCK_INPUT; unbind_to (idx, Qnil); @@ -10424,10 +10407,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) fcntl (connection, F_SETOWN, getpid ()); #endif /* ! defined (F_SETOWN) */ -#ifdef SIGIO if (interrupt_input) init_sigio (connection); -#endif /* ! defined (SIGIO) */ #ifdef USE_LUCID { @@ -10443,7 +10424,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) to.addr = (XPointer)&font; x_catch_errors (dpy); if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) - abort (); + emacs_abort (); if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); x_uncatch_errors (); @@ -10609,8 +10590,6 @@ x_activate_timeout_atimer (void) /* Set up use of X before we make the first connection. */ -extern frame_parm_handler x_frame_parm_handlers[]; - static struct redisplay_interface x_redisplay_interface = { x_frame_parm_handlers, @@ -10768,6 +10747,8 @@ x_create_terminal (struct x_display_info *dpyinfo) void x_initialize (void) { + struct sigaction action; + baud_rate = 19200; x_noop_count = 0; @@ -10814,7 +10795,8 @@ x_initialize (void) XSetErrorHandler (x_error_handler); XSetIOErrorHandler (x_io_error_quitter); - signal (SIGPIPE, x_connection_signal); + emacs_sigaction_init (&action, x_connection_signal); + sigaction (SIGPIPE, &action, 0); } |