aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 04:07:36 -0800
committerDaniel Colascione2012-09-17 04:07:36 -0800
commit2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch)
tree6dd6784d63e54cb18071df8e28fbdbc27d418728 /src
parentf701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff)
parentbb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff)
downloademacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz
emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.zip
Merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit11
-rw-r--r--src/ChangeLog924
-rw-r--r--src/Makefile.in11
-rw-r--r--src/alloc.c608
-rw-r--r--src/atimer.c80
-rw-r--r--src/bidi.c84
-rw-r--r--src/blockinput.h16
-rw-r--r--src/buffer.c98
-rw-r--r--src/buffer.h11
-rw-r--r--src/bytecode.c21
-rw-r--r--src/callint.c1
-rw-r--r--src/callproc.c30
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/casetab.c2
-rw-r--r--src/category.c1
-rw-r--r--src/ccl.c1
-rw-r--r--src/character.c3
-rw-r--r--src/charset.c7
-rw-r--r--src/chartab.c2
-rw-r--r--src/cm.c3
-rw-r--r--src/cmds.c2
-rw-r--r--src/coding.c21
-rw-r--r--src/composite.c1
-rw-r--r--src/composite.h2
-rw-r--r--src/conf_post.h27
-rw-r--r--src/data.c112
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/dired.c3
-rw-r--r--src/dispextern.h6
-rw-r--r--src/dispnew.c53
-rw-r--r--src/doc.c2
-rw-r--r--src/doprnt.c5
-rw-r--r--src/dosfns.c2
-rw-r--r--src/editfns.c17
-rw-r--r--src/emacs.c235
-rw-r--r--src/emacsgtkfixed.c9
-rw-r--r--src/eval.c130
-rw-r--r--src/fileio.c202
-rw-r--r--src/filelock.c25
-rw-r--r--src/firstfile.c5
-rw-r--r--src/floatfns.c628
-rw-r--r--src/fns.c122
-rw-r--r--src/font.c109
-rw-r--r--src/font.h46
-rw-r--r--src/fontset.c29
-rw-r--r--src/frame.c28
-rw-r--r--src/frame.h5
-rw-r--r--src/fringe.c10
-rw-r--r--src/ftfont.c32
-rw-r--r--src/ftxfont.c23
-rw-r--r--src/gnutls.c1
-rw-r--r--src/gtkutil.c30
-rw-r--r--src/image.c231
-rw-r--r--src/indent.c5
-rw-r--r--src/insdel.c56
-rw-r--r--src/intervals.c22
-rw-r--r--src/keyboard.c321
-rw-r--r--src/keyboard.h2
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h288
-rw-r--r--src/lisp.mk1
-rw-r--r--src/lread.c23
-rw-r--r--src/macros.c2
-rw-r--r--src/makefile.w32-in2
-rw-r--r--src/marker.c28
-rw-r--r--src/menu.c5
-rw-r--r--src/minibuf.c6
-rw-r--r--src/msdos.c30
-rw-r--r--src/ns.mk39
-rw-r--r--src/nsfns.m15
-rw-r--r--src/nsfont.m16
-rw-r--r--src/nsimage.m1
-rw-r--r--src/nsmenu.m8
-rw-r--r--src/nsselect.m1
-rw-r--r--src/nsterm.h1
-rw-r--r--src/nsterm.m459
-rw-r--r--src/print.c12
-rw-r--r--src/process.c399
-rw-r--r--src/ralloc.c34
-rw-r--r--src/regex.c7
-rw-r--r--src/region-cache.c25
-rw-r--r--src/scroll.c6
-rw-r--r--src/search.c8
-rw-r--r--src/sheap.c3
-rw-r--r--src/sound.c40
-rw-r--r--src/syntax.c12
-rw-r--r--src/sysdep.c280
-rw-r--r--src/syssignal.h99
-rw-r--r--src/systty.h18
-rw-r--r--src/term.c45
-rw-r--r--src/termcap.c1
-rw-r--r--src/termchar.h2
-rw-r--r--src/terminal.c9
-rw-r--r--src/terminfo.c3
-rw-r--r--src/textprop.c5
-rw-r--r--src/tparam.c4
-rw-r--r--src/undo.c2
-rw-r--r--src/unexaix.c1
-rw-r--r--src/unexcoff.c1
-rw-r--r--src/unexcw.c1
-rw-r--r--src/unexsol.c1
-rw-r--r--src/vm-limit.c1
-rw-r--r--src/w16select.c1
-rw-r--r--src/w32.c60
-rw-r--r--src/w32console.c1
-rw-r--r--src/w32fns.c27
-rw-r--r--src/w32font.c12
-rw-r--r--src/w32font.h2
-rw-r--r--src/w32heap.c1
-rw-r--r--src/w32inevt.c1
-rw-r--r--src/w32menu.c2
-rw-r--r--src/w32proc.c41
-rw-r--r--src/w32reg.c1
-rw-r--r--src/w32select.c3
-rw-r--r--src/w32term.c19
-rw-r--r--src/w32uniscribe.c7
-rw-r--r--src/w32xfns.c3
-rw-r--r--src/widget.c15
-rw-r--r--src/window.c49
-rw-r--r--src/window.h15
-rw-r--r--src/xdisp.c107
-rw-r--r--src/xfaces.c72
-rw-r--r--src/xfns.c1
-rw-r--r--src/xfont.c15
-rw-r--r--src/xftfont.c33
-rw-r--r--src/xgselect.c6
-rw-r--r--src/xmenu.c32
-rw-r--r--src/xml.c1
-rw-r--r--src/xrdb.c1
-rw-r--r--src/xselect.c7
-rw-r--r--src/xsettings.c5
-rw-r--r--src/xsmfns.c1
-rw-r--r--src/xterm.c80
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)
1222 set $tem = (struct Lisp_String *) $ptr 1222 set $tem = (struct Lisp_String *) $ptr
1223 set $tem = (char *) $tem->data 1223 set $tem = (char *) $tem->data
1224 1224
1225 # Don't let abort actually run, as it will make stdio stop working and 1225 # Don't let emacs_abort actually run, as it will make stdio stop
1226 # therefore the `pr' command above as well. 1226 # working and therefore the 'pr' command above as well.
1227 if $tem[0] == 'w' && $tem[1] == 'i' && $tem[2] == 'n' && $tem[3] == 'd' 1227 break emacs_abort
1228 # The windows-nt build replaces abort with its own function.
1229 break w32_abort
1230 else
1231 break abort
1232 end
1233end 1228end
1234 1229
1235# x_error_quitter is defined only on X. But window-system is set up 1230# 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 @@
12012-09-17 Eli Zaretskii <eliz@gnu.org>
2
3 * w32term.c (w32_read_socket): Set pending_signals to 1, like
4 xterm.c does. Reported by Daniel Colascione <dancol@dancol.org>.
5
6 * ralloc.c (r_alloc_init) [!SYSTEM_MALLOC]: Initialize
7 __malloc_extra_blocks to 32 instead of 64, like alloc.c did in
8 emacs_blocked_malloc, now deleted.
9
102012-09-17 Paul Eggert <eggert@cs.ucla.edu>
11
12 Remove no-longer-needed Solaris 2.4 vfork bug workaround.
13 The workaround was for improving performance on Solaris 2.4, but
14 is getting in the way now. Emacs will still work if someone is
15 still running Solaris 2.4 in a museum somewhere; Sun dropped
16 support for Solaris 2.4 in 2003.
17 * callproc.c (Fcall_process) [HAVE_WORKING_VFORK]:
18 * process.c (create_process) [HAVE_WORKING_VFORK]:
19 Omit now-unnecessary workaround for the Solaris 2.4 vfork bug,
20 since Emacs no longer uses vfork on that platform.
21
222012-09-17 Glenn Morris <rgm@gnu.org>
23
24 * emacs.c: Use COPYRIGHT.
25
262012-09-16 Paul Eggert <eggert@cs.ucla.edu>
27
28 Remove configure's --without-sync-input option (Bug#12450).
29 When auditing signal-handling in preparation for cleaning it up,
30 I found that SYNC_INPUT has race conditions and would be a real
31 pain to fix. Since it's an undocumented and deprecated
32 configure-time option, now seems like a good time to remove it.
33 Also see <http://bugs.gnu.org/11080#16>.
34 * alloc.c (_bytes_used, __malloc_extra_blocks, _malloc_internal)
35 (_free_internal) [!DOUG_LEA_MALLOC]: Remove decls.
36 (alloc_mutex) [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]:
37 (malloc_hysteresis):
38 (check_depth) [XMALLOC_OVERRUN_CHECK]:
39 (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT):
40 (__malloc_hook, __realloc_hook, __free_hook, BYTES_USED)
41 (dont_register_blocks, bytes_used_when_reconsidered)
42 (bytes_used_when_full, emacs_blocked_free, emacs_blocked_malloc)
43 (emacs_blocked_realloc, reset_malloc_hooks, uninterrupt_malloc):
44 [!SYSTEM_MALLOC && !SYNC_INPUT]:
45 Remove. All uses removed.
46 (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): Use a different
47 implementation, one that depends on whether the new macro
48 XMALLOC_BLOCK_INPUT_CHECK is defined, not on whether SYNC_INPUT
49 is defined.
50 * atimer.c (run_timers, handle_alarm_signal):
51 * keyboard.c (pending_signal, poll_for_input_1, poll_for_input)
52 (handle_async_input, process_pending_signals)
53 (handle_input_available_signal, init_keyboard):
54 * nsterm.m (ns_read_socket):
55 * process.c (wait_reading_process_output):
56 * regex.c (immediate_quit, IMMEDIATE_QUIT_CHECK):
57 * sysdep.c (emacs_sigaction_init) [SA_RESTART]:
58 (emacs_write):
59 * xterm.c (XTread_socket):
60 Assume SYNC_INPUT.
61 * conf_post.h (SA_RESTART) [IRIX6_5]: Do not #undef.
62 * eval.c (handling_signal): Remove. All uses removed.
63 * lisp.h (ELSE_PENDING_SIGNALS): Remove.
64 All uses replaced with the SYNC_INPUT version.
65 (reset_malloc_hooks, uninterrupt_malloc, handling_signal):
66 Remove decls.
67 * sysdep.c, syssignal.h (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
68 Now static.
69
70 * font.c (Ffont_shape_gstring): Remove unused local.
71
722012-09-16 Glenn Morris <rgm@gnu.org>
73
74 * Makefile.in (clean): No longer run nextstep's clean.
75
76 * Makefile.in (ns_appdir, ns_appbindir, ns_appsrc): Remove variables.
77 (ns_frag): Remove.
78 (ns-app): Move here from ns.mk, and simplify.
79 (clean): Simplify nextstep entry.
80 * ns.mk: Remove file.
81
822012-09-16 Kenichi Handa <handa@gnu.org>
83
84 * font.c (Ffont_shape_gstring): Fix previous change; GLYPHs may
85 not covert the last few charactes.
86
872012-09-16 Kenichi Handa <handa@gnu.org>
88
89 * font.c (Ffont_shape_gstring): Don't adjust grapheme cluster
90 here, but just check the validity of glyphs in the glyph-string.
91
922012-09-16 Martin Rudalics <rudalics@gmx.at>
93
94 * window.c (Fwindow_parameter, Fset_window_parameter): Accept
95 any window as argument (Bug#12452).
96
972012-09-16 Jan Djärv <jan.h.d@swipnet.se>
98
99 * nsfns.m (Fx_open_connection): Move initialization of ns_*_types
100 to ns_term_init to avoid memory leak.
101
102 * nsterm.m (ns_update_begin): Initialize bp after lcokFocus, use
103 explicit retain/release.
104 (ns_term_init): Only allow one display. Initialize outerpool and
105 ns_*_types.
106
1072012-09-15 Paul Eggert <eggert@cs.ucla.edu>
108
109 Port _setjmp fix to POSIXish hosts as well as Microsoft.
110 * image.c (_setjmp) [!HAVE__SETJMP]: Restore definition, as
111 it's needed on POSIXish hosts that lack _setjmp. Attempt to solve
112 the Microsoft problem in a different way, by altering ../nt/config.nt.
113
1142012-09-15 Eli Zaretskii <eliz@gnu.org>
115
116 * w32xfns.c:
117 * w32uniscribe.c:
118 * w32term.c:
119 * w32select.c:
120 * w32reg.c:
121 * w32proc.c:
122 * w32menu.c:
123 * w32inevt.c:
124 * w32heap.c:
125 * w32font.c:
126 * w32fns.c:
127 * w32console.c:
128 * w32.c:
129 * w16select.c: Remove inclusion of setjmp.h, as it is now included
130 by lisp.h. This completes removal of setjmp.h inclusion
131 erroneously announced in the previous commit. (Bug#12446)
132
133 * lisp.h [!HAVE__SETJMP, !HAVE_SIGSETJMP]: Make the commentary
134 more accurate.
135
136 * image.c (_setjmp) [!HAVE__SETJMP]: Define only if 'setjmp' is
137 not defined as a macro. The latter happens on MS-Windows.
138 (Bug#12446)
139
1402012-09-15 Paul Eggert <eggert@cs.ucla.edu>
141
142 Port better to POSIX hosts lacking _setjmp (Bug#12446).
143 * lisp.h: Include <setjmp.h> here, since we use its symbols here.
144 Some instances of '#include <setjmp.h>' removed, if the
145 only reason for the instance was because "lisp.h" was included.
146 (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols.
147 Unless otherwise specified, replace all uses of jmp_buf, _setjmp,
148 and _longjmp with the new symbols. Emacs already uses _setjmp if
149 available, so this change affects only POSIXish hosts that have
150 sigsetjmp but not _setjmp, such as some versions of Solaris and
151 Unixware. (Also, POSIX-2008 marks _setjmp as obsolescent.)
152 * image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros.
153 (png_load_body) [HAVE_PNG]:
154 (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]:
155 (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]:
156 Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp,
157 since PNG requires jmp_buf. This is the only exception to the
158 general rule that we now use sys_setjmp and sys_longjmp.
159 This exception is OK since this code does not change the signal
160 mask or longjmp out of a signal handler.
161
1622012-09-14 Paul Eggert <eggert@cs.ucla.edu>
163
164 * alloc.c [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]:
165 Include "syssignal.h", for 'main_thread'.
166
1672012-09-14 Dmitry Antipov <dmantipov@yandex.ru>
168
169 Avoid out-of-range marker position (Bug#12426).
170 * insdel.c (replace_range, replace_range_2): Adjust
171 markers before overlays, as suggested by comments.
172 (insert_1_both, insert_from_buffer_1, adjust_after_replace):
173 Remove redundant check before calling offset_intervals.
174
1752012-09-14 Martin Rudalics <rudalics@gmx.at>
176
177 * xdisp.c (Fformat_mode_line): Unconditionally save/restore
178 current buffer (Bug#12387).
179
1802012-09-14 Juanma Barranquero <lekktu@gmail.com>
181
182 * makefile.w32-in ($(BLD)/alloc.$(O)): Update dependencies.
183
1842012-09-13 Paul Eggert <eggert@cs.ucla.edu>
185
186 Use a more backwards-compatible timer format (Bug#12430).
187 * keyboard.c (decode_timer): Get PSECS from the 8th (origin-0)
188 vector element, not from the 4th, since PSECS is now at the end.
189 (Fcurrent_idle_time): Doc fix.
190
1912012-09-13 Dmitry Antipov <dmantipov@yandex.ru>
192
193 Function to mark objects and remove killed buffers at once.
194 * alloc.c (discard_killed_buffers): Rename to ...
195 (mark_discard_killed buffers) ... new name. Add marking
196 of remaining objects. Fix comment. Adjust users.
197 (mark_object): Do not touch frame buffer lists here.
198 * frame.c (delete_frame): Reset frame buffer lists here.
199
2002012-09-13 Paul Eggert <eggert@cs.ucla.edu>
201
202 Better workaround for GNOME bug when --enable-gcc-warnings.
203 * emacsgtkfixed.c (G_STATIC_ASSERT): Remove, undoing last change.
204 Instead, disable -Wunused-local-typedefs. See Dmitry Antipov in
205 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00335.html>.
206
207 Simplify SIGIO usage (Bug#12408).
208 The code that dealt with SIGIO was crufty and confusing, e.g., it
209 played tricks like "#undef SIGIO" but these tricks were not used
210 consistently. Simplify mostly by not #undeffing standard symbols,
211 e.g., use "defined USABLE_SIGIO" (our symbol, which we can define
212 or not as we please) rather than "defined SIGIO" (standard symbol
213 that we probably shouldn't #undef).
214 * conf_post.h [USG5_4]: Do not include <sys/wait.h> here.
215 Modules that need it can include it.
216 [USG5_4 && emacs]: Likewise, do not include the streams stuff here.
217 * dispextern.h (ignore_sigio): New decl.
218 * emacs.c (shut_down_emacs): Invoke unrequest_sigio
219 unconditionally, since it's now a no-op if !USABLE_SIGIO.
220 * emacs.c (shut_down_emacs):
221 * keyboard.c (kbd_buffer_store_event_hold):
222 Use ignore_sigio rather than invoking 'signal' directly.
223 * keyboard.c (USABLE_FIONREAD && USG5_4): Include <sys/filio.h>,
224 for FIONREAD.
225 (FIONREAD, SIGIO): Do not #undef.
226 (tty_read_avail_input): Use #error rather than a syntax error.
227 * process.c [USG5_4]: Include <sys/stream.h> and <sys/stropts.h>,
228 for I_PIPE, used by SETUP_SLAVE_PTY.
229 (DATAGRAM_SOCKETS): Simplify defn, based on USABLE_FIONREAD.
230 * sysdep.c (croak): Remove; no longer needed. This bit of
231 temporary code, with Fred N. Fish's comment that it's temporary,
232 has been in Emacs since at least 1992!
233 (init_sigio, reset_sigio, request_sigio, unrequest_sigio):
234 Arrange for them to be no-ops in all cases when ! USABLE_SIGIO.
235 * syssignal.h (croak): Remove decl.
236 (SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile.
237 * systty.h [!NO_TERMIO]: Do not include <termio.h>; no longer needed
238 now that we're termios-only.
239 (FIONREAD, ASYNC) [BROKEN_FIONREAD]: Do not #undef.
240 * term.c (dissociate_if_controlling_tty): Use #error rather than
241 a run-time error.
242
243 Work around GCC and GNOME bugs when --enable-gcc-warnings.
244 * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify',
245 to work around GNOME bug 683906.
246 * image.c (jpeg_load_body) [HAVE_JPEG && lint]: Pacify gcc -Wclobber.
247 (struct my_jpeg_error_mgr) [HAVE_JPEG && lint]: New member fp.
248 This works around GCC bug 54561.
249
2502012-09-12 Paul Eggert <eggert@cs.ucla.edu>
251
252 More fixes for 'volatile' and setjmp/longjmp.
253 * eval.c (Fdefvar, Fcondition_case): Remove unnecessary 'volatile's.
254 * image.c (struct png_load_context) [HAVE_PNG]: New type.
255 (png_load_body) [HAVE_PNG]:
256 (jpeg_load_body) [HAVE_JPEG]:
257 New function, with most of the old parent function's body.
258 (png_load) [HAVE_PNG]:
259 (jpeg_load) [HAVE_JPEG]:
260 Invoke the new function, to avoid longjmp munging our locals.
261 (struct my_jpeg_error_mgr) [HAVE_JPEG]: New members cinfo, failure_code.
262 (my_error_exit) [HAVE_JPEG]: Don't trust 'setjmp' to return 2 when
263 longjmp is passed 2, as the C standard doesn't guarantee this.
264 Instead, store the failure code into mgr->failure_code.
265
2662012-09-12 Stefan Monnier <monnier@iro.umontreal.ca>
267
268 * keyboard.c (read_char, requeued_events_pending_p, Finput_pending_p)
269 (Fdiscard_input, quit_throw_to_read_char, init_keyboard)
270 (syms_of_keyboard): Remove support for unread-command-char.
271
2722012-09-12 Eli Zaretskii <eliz@gnu.org>
273
274 * w32proc.c (sys_kill): If PID is our process ID and the signal is
275 SIGABRT, call emacs_abort. Avoids silently exiting upon assertion
276 violation. (Bug#12426)
277
2782012-09-12 Paul Eggert <eggert@cs.ucla.edu>
279
280 * image.c (jpeg_memory_src): Don't assume string len fits in unsigned.
281
2822012-09-12 Stefan Monnier <monnier@iro.umontreal.ca>
283
284 * eval.c: Add `inhibit-debugger'.
285 (Qinhibit_debugger): New symbol.
286 (call_debugger): Bind it instead of Qdebug_on_error.
287 (maybe_call_debugger): Test Vinhibit_debugger.
288 (syms_of_eval): Define inhibit-debugger.
289 * xdisp.c (set_message): Don't bind Qinhibit_debug_on_message.
290 (syms_of_xdisp): Remove inhibit-debug-on-message.
291
2922012-09-11 Paul Eggert <eggert@cs.ucla.edu>
293
294 Avoid _setjmp/_longjmp problems with local nonvolatile variables.
295 If a nonvolatile local variable is written before a _longjmp to
296 the frame containing the variable, and is read after the _longjmp,
297 the value read is indeterminate. Some local variables of type
298 'struct handler' and 'struct catchtag' are used in this way, so
299 mark each of their slots as volatile if the slot can be set before
300 _longjmp and read afterwards.
301 * lisp.h (struct handler): var and chosen_clause are now volatile.
302 (struct catchtag): val, next, and pdlcount are now volatile.
303
304 * bidi.c (bidi_push_it, bidi_pop_it):
305 * fns.c (copy_hash_table):
306 * image.c (define_image_type):
307 * keyboard.c (kbd_buffer_store_event_hold):
308 * process.c (Fprocess_send_eof):
309 * xfaces.c (x_create_gc) [HAVE_NS]:
310 * xgselect.c (xg_select):
311 Prefer assignment to memcpy when either will do.
312
313 * alloc.c (discard_killed_buffers): Tune and simplify a bit.
314 Use pointer-to-a-pointer to simplify and avoid a NILP check each
315 time an item is removed. No need to mark this function 'inline';
316 the compiler knows better than we do.
317
3182012-09-11 Jan Djärv <jan.h.d@swipnet.se>
319
320 * nsterm.m (ns_judge_scroll_bars): Pass NO to updateFrameSize.
321 (updateFrameSize:): Add delay parameter to updateFrameSize, send it
322 to change_frame_size (Bug#12388).
323 (windowDidResize:): Pass YES to updateFrameSize.
324
325 * nsterm.h: Add delay parameter to updateFrameSize.
326
3272012-09-11 Dmitry Antipov <dmantipov@yandex.ru>
328
329 Discard killed buffers from deleted window and frame objects.
330 This reduces an amount of references to killed buffers and
331 helps GC to reclaim them faster.
332 * alloc.c (discard_killed_buffers): New function.
333 (mark_object): Use it for deleted windows and frames.
334 (mark_object): If symbol's value is set up for a killed buffer
335 or deleted frame, restore it's global binding.
336 * data.c (swap_in_global_binding): Add GC notice.
337 (swap_in_symval_forwarding): Use convenient set_blv_where.
338 * window.c (wset_next_buffers, wset_prev_buffers): Move ...
339 * window.h: ... to here.
340
3412012-09-11 Dmitry Antipov <dmantipov@yandex.ru>
342
343 Convenient macro to check whether the buffer is live.
344 * buffer.h (BUFFER_LIVE_P): New macro.
345 * alloc.c, buffer.c, editfns.c, insdel.c, lread.c, marker.c:
346 * minibuf.c, print.c, process.c, window.c, xdisp.c: Use it.
347
3482012-09-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
349
350 * xdisp.c (right_overwritten, right_overwriting): Also handle gstring
351 composition cases (Bug#12364).
352
353 * xterm.c (x_draw_glyph_string): Avoid overwriting inverted left
354 overhang of succeeding glyphs overlapping box cursor.
355
356 * w32term.c (x_draw_glyph_string): Likewise.
357
3582012-09-11 Paul Eggert <eggert@cs.ucla.edu>
359
360 Simplify, document, and port floating-point (Bug#12381).
361 The porting part of this patch fixes bugs on non-IEEE platforms
362 with frexp, ldexp, logb.
363 * data.c, lisp.h (Qdomain_error, Qsingularity_error, Qunderflow_error):
364 Now static.
365 * floatfns.c: Simplify discussion of functions that Emacs doesn't
366 support, by removing commented-out code and briefly listing the
367 C89 functions excluded. The commented-out stuff was confusing
368 maintenance, e.g., we thought we needed cbrt but it was commented out.
369 (logb): Remove decl; no longer needed.
370 (isfinite): New macro, if not already supplied.
371 (isnan): Don't replace any existing macro.
372 (Ffrexp, Fldexp): Define even if !HAVE_COPYSIGN, as frexp and ldexp
373 are present on all C89 platforms.
374 (Ffrexp): Do not special-case zero, as frexp does the right thing
375 for that case.
376 (Flogb): Do not use logb, as it doesn't have the desired meaning
377 on hosts that use non-base-2 floating point. Instead, stick with
378 frexp, which is C89 anyway. Do not pass an infinity or a NaN to
379 frexp, to avoid getting an unspecified result.
380
381 * xdisp.c (Qinhibit_debug_on_message): Now static.
382
3832012-09-10 Jan Djärv <jan.h.d@swipnet.se>
384
385 * nsterm.m (ns_update_begin): Set clip path to whole view by using
386 NSBezierPath (Bug#12131).
387
3882012-09-10 Chong Yidong <cyd@gnu.org>
389
390 * fns.c (Fdelq, Fdelete): Doc fix.
391
3922012-09-10 Paul Eggert <eggert@cs.ucla.edu>
393
394 * lisp.h (XSETINT, XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL)
395 (XSETFLOAT, XSETMISC): Parenthesize macro bodies.
396
3972012-09-09 Stefan Monnier <monnier@iro.umontreal.ca>
398
399 * lisp.h (make_lisp_ptr): New macro to replace XSET.
400 (XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL, XSETFLOAT, XSETMISC):
401 Use it.
402
4032012-09-09 Eli Zaretskii <eliz@gnu.org>
404
405 * fringe.c (draw_fringe_bitmap_1): Don't reduce the width of the
406 left fringe if the window has a left margin. This avoids leaving
407 traces of the cursor because its leftmost pixel is not drawn over.
408
409 * dispnew.c (update_window_line): When the left margin area of a
410 screen line is updated, set the redraw_fringe_bitmaps_p flag of
411 that screen line. (Bug#12277)
412
4132012-09-09 Paul Eggert <eggert@cs.ucla.edu>
414
415 Assume C89 or later for math functions (Bug#12381).
416 This simplifies the code, and makes it a bit smaller and faster,
417 and (most important) makes it easier to clean up signal handling
418 since we can stop worring about floating-point exceptions in
419 library code. That was a problem before C89, but the problem
420 went away many years ago on all practical Emacs targets.
421 * data.c, image.c, lread.c, print.c:
422 Don't include <math.h>; no longer needed.
423 * data.c, floatfns.c (IEEE_FLOATING_POINT): Don't worry that it
424 might be autoconfigured, as that never happens.
425 * data.c (fmod):
426 * doprnt.c (DBL_MAX_10_EXP):
427 * print.c (DBL_DIG):
428 Remove. C89 or later always defines these.
429 * floatfns.c (HAVE_MATHERR, FLOAT_CHECK_ERRNO, FLOAT_CHECK_DOMAIN)
430 (in_float, float_error_arg, float_error_arg2, float_error_fn_name)
431 (arith_error, domain_error, domain_error2):
432 Remove all this pre-C89 cruft. Do not include <errno.h> as that's
433 no longer needed -- we simply return what C returns. All uses removed.
434 (IN_FLOAT, IN_FLOAT2): Remove. All uses replaced with
435 the wrapped code.
436 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error, range_error2):
437 Remove. All uses expanded, as these macros are no longer used
438 more than once and are now more trouble than they're worth.
439 (Ftan): Use tan, not sin / cos.
440 (Flogb): Assume C89 frexp.
441 (fmod_float): Assume C89 fmod.
442 (matherr) [HAVE_MATHERR]: Remove; no longer needed.
443 (init_floatfns): Remove. All uses removed.
444
4452012-09-08 Jan Djärv <jan.h.d@swipnet.se>
446
447 * nsterm.m (ns_draw_fringe_bitmap, ns_dumpglyphs_image): Take back
448 compositeToPoint for OSX < 10.6 (Bug#12390).
449
4502012-09-08 Paul Eggert <eggert@cs.ucla.edu>
451
452 * floatfns.c (Ftan): Use tan (x), not (sin (x) / cos (x)).
453 This produces more-accurate results.
454
4552012-09-08 Jan Djärv <jan.h.d@swipnet.se>
456
457 * nsterm.m (updateFrameSize): Call setFrame: on the view when size
458 changes (Bug#12088).
459
4602012-09-08 Chong Yidong <cyd@gnu.org>
461
462 * syntax.c (Fstring_to_syntax): Doc fix.
463
4642012-09-08 Jan Djärv <jan.h.d@swipnet.se>
465
466 * nsterm.m (ns_clip_to_row): Remove code that deals with drawing fringe
467 in the internal border.
468 (x_set_window_size): Remove static variables and their usage.
469 (ns_redraw_scroll_bars): Fix NSTRACE arg.
470 (ns_after_update_window_line, ns_draw_fringe_bitmap): Remove
471 fringe/internal border adjustment (Bug#11052).
472 (ns_draw_fringe_bitmap): Make code more like other terms (xterm.c).
473 (ns_draw_window_cursor): Remove fringe/internal border adjustment.
474 (ns_fix_rect_ibw): Remove.
475 (ns_get_glyph_string_clip_rect): Remove call to ns_fix_rect_ibw.
476 (ns_dumpglyphs_box_or_relief): Ditto.
477 (ns_maybe_dumpglyphs_background): Remove fringe/internal border
478 adjustment.
479 (ns_dumpglyphs_image): Ditto.
480 (ns_dumpglyphs_stretch): Fix coding style. Remove fringe/internal
481 border adjustment.
482 (ns_set_vertical_scroll_bar): Remove variables barOnVeryLeft/Right and
483 their usage. Add fringe_extended_p and its use as in other terms.
484 (ns_judge_scroll_bars): Code style fix. Call updateFrameSize if
485 scroll bar was removed.
486 (updateFrameSize): New function.
487 (windowDidResize): Move code to updateFrameSize and call it.
488
489 * nsterm.h (EmacsView): Add updateFrameSize.
490
4912012-09-07 Chong Yidong <cyd@gnu.org>
492
493 * textprop.c (Fget_text_property): Minor doc fix (Bug#12323).
494
495 * data.c (Flocal_variable_if_set_p): Doc fix (Bug#10713).
496
4972012-09-07 Paul Eggert <eggert@cs.ucla.edu>
498
499 More signal-handler cleanup (Bug#12327).
500 * emacs.c (main): Convert three 'signal' calls to 'sigaction' calls.
501 Problem introduced when merging patches. Noted by Eli Zaretskii in
502 <http://bugs.gnu.org/12327#67>.
503 * floatfns.c: Comment fix.
504 * lisp.h (force_auto_save_soon): Declare regardless of SIGDANGER.
505 SIGDANGER might not be in scope so "#ifdef SIGDANGER" is not right,
506 and anyway the declaration is harmless even if SIGDANGER is not defined.
507 * syssignal.h (SIGIO): Also #undef if (! defined FIONREAD ||
508 defined BROKEN_FIONREAD). systty.h formerly did this, but other
509 source files not surprisingly expected syssignal.h to define, or
510 not define, SIGIO, and it's cleaner to do it that way, for consistency.
511 Include <sys/ioctl.h>, for FIONREAD.
512 * systty.h (SIGIO): Do not #undef here; it's now syssignal.h's job.
513 This eliminates a problem whereby other files mysteriously had
514 to include "syssignal.h" before including "systty.h" if they
515 wanted to use "#ifdef SIGIO".
516
5172012-09-07 Eli Zaretskii <eliz@gnu.org>
518
519 * w32proc.c (sigaction): New function, emulates Posix 'sigaction'.
520
521 * w32.c (sigemptyset): Empty the set.
522 (sigsetmask, sigmask, sigblock, sigunblock): Remove unused functions.
523
524 * alloc.c [ENABLE_CHECKING]: Include signal.h, since we need SIGABRT.
525
5262012-09-07 Dmitry Antipov <dmantipov@yandex.ru>
527
528 * alloc.c (mark_buffer): Revert unsafe marking optimization.
529 (mark_object): Likewise for frame objects.
530
5312012-09-07 Paul Eggert <eggert@cs.ucla.edu>
532
533 * syssignal.h (handle_on_main_thread): Always declare,
534 even if FORWARD_SIGNAL_TO_MAIN_THREAD is not defined.
535 This ports to platforms without HAVE_PTHREAD.
536
5372012-09-06 Paul Eggert <eggert@cs.ucla.edu>
538
539 Signal-handler cleanup (Bug#12327).
540 Emacs's signal handlers were written in the old 4.2BSD style with
541 sigblock and sigmask and so forth, and this led to some
542 inefficiencies and confusion. Rewrite these to use
543 pthread_sigmask etc. without copying signal sets around. Also,
544 get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and
545 'signal', and instead use functions that do not attempt to take
546 over the system name space. This patch causes Emacs's text
547 segment to shrink by 0.7% on my platform, Fedora 17 x86-64.
548 * alloc.c, emacsgtkfixed.c, nsfns.m, widget.c, xmenu.c:
549 Do not include <signal.h> or "syssignal.h", as these
550 modules do not use signals.
551 * atimer.c, callproc.c, data.c, dispnew.c, emacs.c, floatfns.c:
552 * gtkutil.c, keyboard.c, process.c, sound.c, sysdep.c, term.c, xterm.c:
553 Do not include <signal.h>, as "syssignal.h" does that for us now.
554 * atimer.c (sigmask_atimers): New function.
555 (block_atimers, unblock_atimers): New functions,
556 replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS.
557 All uses replaced.
558 * conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>;
559 no longer needed here.
560 * emacs.c (main): Inspect existing signal handler with sigaction,
561 so that there's no need to block and unblock SIGHUP.
562 * sysdep.c (struct save_signal): New member 'action', replacing
563 old member 'handler'.
564 (save_signal_handlers, restore_signal_handlers):
565 Use sigaction instead of 'signal' to save and restore.
566 (get_set_sighandler, set_sighandler) [!WINDOWSNT]:
567 New function. All users of 'signal' modified to use set_sighandler
568 if they're writeonly, and to use sys_signal if they're read+write.
569 (emacs_sigaction_init, forwarded_signal): New functions.
570 (sys_signal): Remove. All uses replaced by calls to sigaction
571 and emacs_sigaction_init, or by direct calls to 'signal'.
572 (sys_sigmask) [!__GNUC__]: Remove; no longer needed.
573 (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove;
574 all uses replaced by pthread_sigmask etc. calls.
575 * syssignal.h: Include <signal.h>.
576 (emacs_sigaction_init, forwarded_signal): New decls.
577 (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t.
578 (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask.
579 (sigmask, sys_sigmask): Remove; no longer needed.
580 (sigpause): Remove. All uses replaced by its definiens, sigsuspend.
581 (sigblock, sigunblock, sigfree):
582 (sigsetmask) [!defined sigsetmask]:
583 Remove. All uses replaced by pthread_sigmask.
584 (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN)
585 no longer need to be replaced, and its typical old uses
586 are now done via emacs_sigaction_init and sigaction.
587 (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls.
588 (sys_sigdel): Remove; unused.
589 (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef.
590
5912012-09-06 Eli Zaretskii <eliz@gnu.org>
592
593 * process.c (CAN_HANDLE_MULTIPLE_CHILDREN): Fix a typo that broke
594 SIGCHLD handling on systems that don't have WNOHANG. (Bug#12327)
595
5962012-09-06 Dmitry Antipov <dmantipov@yandex.ru>
597
598 Explicitly mark buffer_defaults and buffer_local_symbols.
599 * alloc.c (Fgarbage_collect): Mark buffer_defaults and
600 mark_local_symbols here.
601 (mark_object): If GC_CHECK_MARKED_OBJECTS, simplify checking
602 since special buffers aren't marked here any more.
603 (allocate_buffer): Chain new buffer with all_buffers here...
604 * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): ...and
605 not here.
606 (Vbuffer_defaults, Vbuffer_local_symbols): Remove.
607 (syms_of_buffer): Remove staticpro of the above.
608 (init_buffer_once): Set names for buffer_defaults and
609 buffer_local_symbols.
610
6112012-09-06 Paul Eggert <eggert@cs.ucla.edu>
612
613 Use bool for booleans in font-related modules.
614 * font.c (font_intern_prop, font_style_to_value)
615 (font_style_symbolic, font_parse_xlfd, font_parse_fcname)
616 (generate_otf_features, font_check_otf_features, font_check_otf)
617 (font_match_p, font_list_entities, font_at):
618 * fontset.c (fontset_id_valid_p, reorder_font_vector
619 (fontset_find_font, Fset_fontset_font)
620 (face_suitable_for_char_p) [0]:
621 * ftfont.c (fc_initialized, ftfont_get_open_type_spec)
622 (ftfont_open, ftfont_text_extents, ftfont_check_otf):
623 (m17n_flt_initialized, ftfont_shape_by_flt):
624 * ftxfont.c (ftxfont_draw_bitmap, ftxfont_draw):
625 * nsfont.m (nsfont_draw):
626 * w32font.c (w32font_draw):
627 * w32term.c (x_draw_glyphless_glyph_string_foreground):
628 Use bool for booleans.
629 * font.h: Adjust to above API changes.
630 (struct font, struct font_driver, struct font_driver_list):
631 Use bool for booleans.
632 (struct font): Remove useless member encoding_type.
633 All users removed.
634 * fontset.c, xftfont.c: Omit unnecessary static decls.
635
6362012-09-06 Dmitry Antipov <dmantipov@yandex.ru>
637
638 * alloc.c (mark_object): Revert window marking code
639 since it's unsafe for the Fset_window_configuration.
640
6412012-09-05 Paul Eggert <eggert@cs.ucla.edu>
642
643 Fix race conditions with signal handlers and errno (Bug#12327).
644 Be more systematic about preserving errno whenever a signal
645 handler returns, even if it's not in the main thread. Do this by
646 renaming signal handlers to distinguish between signal delivery
647 and signal handling. All uses changed.
648 * atimer.c (deliver_alarm_signal): Rename from alarm_signal_handler.
649 * data.c (deliver_arith_signal): Rename from arith_error.
650 * dispnew.c (deliver_window_change_signal): Rename from
651 window_change_signal.
652 * emacs.c (deliver_error_signal): Rename from fatal_error_signal.
653 (deliver_danger_signal) [SIGDANGER]: Rename from memory_warning_signal.
654 * keyboard.c (deliver_input_available_signal): Rename from
655 input_available_signal.
656 (deliver_user_signal): Rename from handle_user_signal.
657 (deliver_interrupt_signal): Rename from interrupt_signal.
658 * process.c (deliver_pipe_signal): Rename from send_process_trap.
659 (deliver_child_signal): Rename from sigchld_handler.
660 * atimer.c (handle_alarm_signal):
661 * data.c (handle_arith_signal):
662 * dispnew.c (handle_window_change_signal):
663 * emacs.c (handle_fatal_signal, handle_danger_signal):
664 * keyboard.c (handle_input_available_signal):
665 * keyboard.c (handle_user_signal, handle_interrupt_signal):
666 * process.c (handle_pipe_signal, handle_child_signal):
667 New functions, with the actual signal-handling code taken from the
668 original respective signal handlers, sans the sporadic attempts to
669 preserve errno, since that's now done by handle_on_main_thread.
670 * atimer.c (alarm_signal_handler): Remove unnecessary decl.
671 * emacs.c, floatfns.c, lisp.h: Remove unused FLOAT_CATCH_SIGKILL cruft.
672 * emacs.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
673 Move to sysdep.c.
674 (main) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
675 Move initialization of main_thread to sysdep.c's init_signals.
676 * process.c (waitpid) [!WNOHANG]: #define to wait; that's good enough for
677 our usage, and simplifies the mainline code.
678 (record_child_status_change): New static function, as a helper
679 for handle_child_signal, and with most of the old child handler's
680 contents.
681 (CAN_HANDLE_MULTIPLE_CHILDREN): New constant.
682 (handle_child_signal): Use the above.
683 * sysdep.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
684 Moved here from emacs.c.
685 (init_signals) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Initialize it;
686 code moved here from emacs.c's main function.
687 * sysdep.c, syssignal.h (handle_on_main_thread): New function,
688 replacing the old SIGNAL_THREAD_CHECK. All uses changed. This
689 lets callers save and restore errno properly.
690
6912012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
692
693 Remove redundant or unused things here and there.
694 * lisp.h (CYCLE_CHECK, CHAR_TABLE_TRANSLATE): Remove.
695 * conf_post.h (RE_TRANSLATE): Use char_table_translate.
696 * editfns.c (Fcompare_buffer_substrings): Likewise.
697 * frame.h (struct terminal, struct font_driver_list):
698 Remove redundant declarations.
699 * window.h (Qleft, Qright): Likewise.
700
7012012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
702
703 Do not mark objects from deleted buffers, windows and frames.
704 * alloc.c (mark_buffer): Mark just the buffer if it is dead.
705 (mark_object): Likewise for windows and frames.
706
7072012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
708
709 * alloc.c (valid_lisp_object_p): Treat killed buffers,
710 buffer_defaults and buffer_local_symbols as valid objects.
711 Return special value to denote them.
712
7132012-09-05 Paul Eggert <eggert@cs.ucla.edu>
714
715 * fileio.c, filelock.c, floatfns.c, fns.c: Use bool for boolean.
716 * fileio.c (auto_saving, auto_save_error_occurred, make_temp_name)
717 (Fexpand_file_name, barf_or_query_if_file_exists, Fcopy_file)
718 (file_name_absolute_p, Fsubstitute_in_file_name):
719 (check_executable, check_writable, Ffile_accessible_directory_p)
720 (Fset_file_selinux_context, Fdefault_file_modes)
721 (Finsert_file_contents, choose_write_coding_system)
722 (Fwrite_region, build_annotations, a_write, e_write)
723 (Fdo_auto_save):
724 * filelock.c (boot_time_initialized, get_boot_time)
725 (get_boot_time_1, lock_file_1, within_one_second):
726 * floatfns.c (in_float):
727 * fns.c (concat, internal_equal, Frequire, base64_encode_1)
728 (base64_decode_1, cmpfn_eql, cmpfn_user_defined)
729 (sweep_weak_table, sweep_weak_hash_tables, secure_hash):
730 * lisp.h (struct Lisp_Hash_Table.cmpfn):
731 * window.c (compare_window_configurations):
732 Use bool for booleans.
733 * fileio.c (auto_saving_dir_umask, auto_saving_mode_bits)
734 (Fdefault_file_modes): Now mode_t, not int, for modes.
735 (Fdo_auto_save): Set a boolean to 1 rather than using ++.
736 (internal_delete_file): Now returns void, not a (boolean) int,
737 since nobody was looking at the return value.
738 * lisp.h, window.h: Adjust to above API changes.
739
740 * xdisp.c (set_message): Simplify and reindent last change.
741
7422012-09-05 Juanma Barranquero <lekktu@gmail.com>
743
744 * makefile.w32-in ($(BLD)/sysdep.$(O)): Update dependencies.
745
7462012-09-04 Lars Ingebrigtsen <larsi@gnus.org>
747
748 * eval.c (call_debugger): Make the function non-static so that we
749 can call it from set_message.
750
751 * xdisp.c (set_message): Implement the new variable `debug-on-message'.
752 (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'.
753
7542012-09-04 Paul Eggert <eggert@cs.ucla.edu>
755
756 Give more-useful info on a fatal error (Bug#12328).
757 * alloc.c [ENABLE_CHECKING]: Do not include <execinfo.h>.
758 (die) [ENABLE_CHECKING]: Call fatal_error_backtrace instead
759 of doing the work ourselves.
760 * emacs.c (fatal_error_signal): Let fatal_error_backtrace
761 do most of the work.
762 (fatal_error_backtrace): New function, taken from the guts
763 of the old fatal_error_signal, but with a new option to output
764 a backtrace.
765 (shut_down_emacs) [!DOS_NT]: Use strsignal to give more-useful
766 info about the signal than just its number.
767 * lisp.h (fatal_error_backtrace, emacs_backtrace): New decls.
768 * sysdep.c: Include <execinfo.h>
769 (emacs_backtrace): New function, taken partly from the previous
770 code of the 'die' function.
771 (emacs_abort): Call fatal_error_backtrace rather than abort.
772
7732012-09-04 Stefan Monnier <monnier@iro.umontreal.ca>
774
775 * lread.c (readevalloop): Call internal-macroexpand-for-load to perform
776 eager (load-time) macro-expansion.
777 * lisp.mk (lisp): Add macroexp.
778
7792012-09-04 Paul Eggert <eggert@cs.ucla.edu>
780
781 Simplify redefinition of 'abort' (Bug#12316).
782 Do not try to redefine the 'abort' function. Instead, redo
783 the code so that it calls 'emacs_abort' rather than 'abort'.
784 This removes the need for the NO_ABORT configure-time macro
785 and makes it easier to change the abort code to do a backtrace.
786 * .gdbinit: Just stop at emacs_abort, not at w32_abort or abort.
787 * emacs.c (abort) [!DOS_NT && !NO_ABORT]:
788 Remove; sysdep.c's emacs_abort now takes its place.
789 * lisp.h (emacs_abort): New decl. All calls from Emacs code to
790 'abort' changed to use 'emacs_abort'.
791 * msdos.c (dos_abort) [defined abort]: Remove; not used.
792 (abort) [!defined abort]: Rename to ...
793 (emacs_abort): ... new name.
794 * sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking
795 the place of the old 'abort' in emacs.c.
796 * w32.c, w32fns.c (abort): Do not #undef.
797 * w32.c (emacs_abort): Rename from w32_abort.
798
7992012-09-04 Eli Zaretskii <eliz@gnu.org>
800
801 * w32uniscribe.c (uniscribe_shape): Reverse the sign of
802 offsets[j].dv, since the y axis of the screen coordinates points
803 down, while the y axis of the font definition coordinates points
804 up. This fixes display of Arabic diacritics such as KASRA and
805 KASRATAN. (Bug#11860)
806
8072012-09-04 Paul Eggert <eggert@cs.ucla.edu>
808
809 Be more systematic about _setjmp vs setjmp.
810 * alloc.c (test_setjmp, mark_stack):
811 * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]:
812 (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]:
813 (png_load, my_error_exit, jpeg_load):
814 * process.c (send_process_trap, send_process):
815 Uniformly prefer _setjmp and _longjmp to setjmp and longjmp.
816 The underscored versions are up to 30x faster on some hosts.
817 Formerly, the code used setjmp+longjmp sometimes and
818 _setjmp+_longjmp at other times, with no particular reason to
819 prefer setjmp+longjmp.
820
8212012-09-03 Paul Eggert <eggert@cs.ucla.edu>
822
823 Fix minor problem found by static checking.
824 * buffer.c (Fdelete_all_overlays): Return nil.
825
8262012-09-03 Martin Rudalics <rudalics@gmx.at>
827
828 * buffer.c (Fdelete_all_overlays): New function.
829
8302012-09-03 Chong Yidong <cyd@gnu.org>
831
832 * gtkutil.c: Add extern decl for Qxft.
833
8342012-09-02 Paul Eggert <eggert@cs.ucla.edu>
835
836 * emacs.c, eval.c: Use bool for boolean.
837 * emacs.c (initialized, inhibit_window_system, running_asynch_code):
838 (malloc_using_checking) [DOUG_LEA_MALLOC]:
839 (display_arg) [HAVE_X_WINDOWS || HAVE_NS]:
840 (noninteractive, no_site_lisp, fatal_error_in_progress, argmatch)
841 (main, decode_env_path, Fdaemon_initialized):
842 * eval.c (call_debugger, Finteractive_p, interactive_p):
843 (unwind_to_catch, Fsignal, wants_debugger, skip_debugger)
844 (maybe_call_debugger, Fbacktrace):
845 * process.c (read_process_output, exec_sentinel):
846 Use bool for booleans.
847 * emacs.c (shut_down_emacs): Omit unused boolean argument NO_X.
848 All callers changed.
849 * eval.c (interactive_p): Omit always-true boolean argument
850 EXCLUDE_SUBRS_P. All callers changed.
851 * dispextern.h, lisp.h: Reflect above API changes.
852 * firstfile.c (dummy): Use the address of 'main', whose signature
853 won't change, instead of the address of 'initialize', whose
854 signature just changed from int to bool.
855 * lisp.h (fatal_error_in_progress): New decl of boolean, moved here ...
856 * msdos.c (fatal_error_in_progress): ... from here.
857 * xdisp.c (redisplaying_p): Now a boolean. Set it to 1 instead
858 of incrementing it.
859 (redisplay_internal, unwind_redisplay): Simply clear
860 REDISPLAYING_P when unwinding, instead of saving its previous,
861 always-false value and then restoring it.
862
863 Clean up some extern decls.
864 Mostly, this hoists extern decls out of .c files and into .h files.
865 That way, we're more likely to catch errors if the interfaces change.
866 * alloc.c [USE_GTK]: Include "gtkutil.h" so that we need not
867 declare xg_mark_data.
868 * dispextern.h (x_frame_parm_handlers):
869 * font.h (Qxft):
870 * lisp.h (Qlexical_binding, Qinternal_interpreter_environment)
871 (Qextra_light, Qlight, Qsemi_light, Qsemi_bold, Qbold, Qextra_bold)
872 (Qultra_bold, Qoblique, Qitalic):
873 Move extern decl here from .c file.
874 * alloc.c (xg_mark_data) [USE_GTK]:
875 * doc.c (Qclosure):
876 * eval.c (Qlexical_binding):
877 * fns.c (time) [!HAVE_UNISTD_H]:
878 * gtkutil.c (Qxft, Qnormal, Qextra_light, Qlight, Qsemi_light)
879 (Qsemi_bold, Qbold, Qextra_bold, Qultra_bold, Qoblique, Qitalic):
880 * image.c (Vlibrary_cache, QCloaded_from) [HAVE_NTGUI]:
881 * lread.c (Qinternal_interpreter_environment):
882 * minibuf.c (Qbuffer):
883 * process.c (QCfamily, QCfilter):
884 * widget.c (free_frame_faces):
885 * xfaces.c (free_frame_menubar) [USE_X_TOOLKIT]:
886 * xfont.c (x_clear_errors):
887 * xterm.c (x_frame_parm_handlers):
888 Remove now-redundant extern decls.
889 * keyboard.c, keyboard.h (ignore_mouse_drag_p) [USE_GTK || HAVE_NS]:
890 * xfaces.c (Qultra_light, Qreverse_oblique, Qreverse_italic):
891 Now static.
892 * xfaces.c: Remove unnecessary static decls.
893 * xterm.c (updating_frame): Remove decl of nonexistent object.
894
895 * Makefile.in (gl-stamp): Don't scan $(SOME_MACHINE_OBJECTS)
896 when building globals.h, as the objects that are not built on
897 this host are not needed to compile C files on this host.
898
12012-09-02 Jan Djärv <jan.h.d@swipnet.se> 8992012-09-02 Jan Djärv <jan.h.d@swipnet.se>
2 900
3 * gtkutil.h: Remove prototype for x_wm_set_size_hint. 901 * gtkutil.h: Remove prototype for x_wm_set_size_hint.
@@ -187,18 +1085,18 @@
1872012-08-28 Jan Djärv <jan.h.d@swipnet.se> 10852012-08-28 Jan Djärv <jan.h.d@swipnet.se>
188 1086
189 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize 1087 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize
190 button_values to NULL. Call setStykeMask so dialogs get a close button. 1088 button_values to NULL. Call setStykeMask so dialogs get a close button.
191 (windowShouldClose:): Set window_closed. 1089 (windowShouldClose:): Set window_closed.
192 (dealloc): New member, free button_values. 1090 (dealloc): New member, free button_values.
193 (process_dialog:): Make member function. Remove window argument, 1091 (process_dialog:): Make member function. Remove window argument,
194 replace window with self. Count buttons and allocate and store values 1092 replace window with self. Count buttons and allocate and store values
195 in button_values. 1093 in button_values.
196 (addButton:value:row:): value is int with the name tag. Call setTag 1094 (addButton:value:row:): value is int with the name tag. Call setTag
197 with tag. Remove return self, declare return value as void. 1095 with tag. Remove return self, declare return value as void.
198 (addString:row:): Remove return self, declare return value as void. 1096 (addString:row:): Remove return self, declare return value as void.
199 (addSplit): Remove return self, declare return value as void. 1097 (addSplit): Remove return self, declare return value as void.
200 (clicked:): Remove return self, declare return value as void. 1098 (clicked:): Remove return self, declare return value as void.
201 Set dialog_return to button_values[seltag]. Code formatting change. 1099 Set dialog_return to button_values[seltag]. Code formatting change.
202 (initFromContents:isQuestion:): Adjust call to process_dialog. 1100 (initFromContents:isQuestion:): Adjust call to process_dialog.
203 Code formatting change. 1101 Code formatting change.
204 (timeout_handler:): Set timer_fired to YES. 1102 (timeout_handler:): Set timer_fired to YES.
@@ -533,7 +1431,7 @@
533 1431
534 * fontset.c (FONTSET_ADD): Return void, not Lisp_Object. 1432 * fontset.c (FONTSET_ADD): Return void, not Lisp_Object.
535 Otherwise, the compiler complains about (A?B:C) where B is void 1433 Otherwise, the compiler complains about (A?B:C) where B is void
536 and C is Lisp_Object. This fixes an incompatibility with Sun C 5.12. 1434 and C is Lisp_Object. This fixes an incompatibility with Sun C 5.12.
537 (fontset_add): Return void, for FONTSET_ADD. 1435 (fontset_add): Return void, for FONTSET_ADD.
538 1436
5392012-08-21 Paul Eggert <eggert@cs.ucla.edu> 14372012-08-21 Paul Eggert <eggert@cs.ucla.edu>
@@ -1049,7 +1947,7 @@
1049 Start main loop and wait for application defined event. 1947 Start main loop and wait for application defined event.
1050 Inform select thread to stop selecting after main loop is exited. 1948 Inform select thread to stop selecting after main loop is exited.
1051 (ns_term_init): Create selfds pipe and set non-blocking. 1949 (ns_term_init): Create selfds pipe and set non-blocking.
1052 Initialize select_mutex. Start the select thread (fd_handler). 1950 Initialize select_mutex. Start the select thread (fd_handler).
1053 (fd_handler:): Loop forever, wait for info from the main thread 1951 (fd_handler:): Loop forever, wait for info from the main thread
1054 to either start or stop selecting. When select returns, send 1952 to either start or stop selecting. When select returns, send
1055 and appdefined event. 1953 and appdefined event.
@@ -1181,7 +2079,7 @@
1181 (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info 2079 (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info
1182 if not present. 2080 if not present.
1183 (update_frame_tool_bar): Return early if data in xg_frame_tb_info 2081 (update_frame_tool_bar): Return early if data in xg_frame_tb_info
1184 is up to date. Otherwise store new data. 2082 is up to date. Otherwise store new data.
1185 (free_frame_tool_bar): Free xg_frame_tb_info if present. 2083 (free_frame_tool_bar): Free xg_frame_tb_info if present.
1186 2084
11872012-08-13 Dmitry Antipov <dmantipov@yandex.ru> 20852012-08-13 Dmitry Antipov <dmantipov@yandex.ru>
@@ -1208,7 +2106,7 @@
12082012-08-11 Jan Djärv <jan.h.d@swipnet.se> 21062012-08-11 Jan Djärv <jan.h.d@swipnet.se>
1209 2107
1210 * nsterm.m (not_in_argv): New function. 2108 * nsterm.m (not_in_argv): New function.
1211 (application:openFile, application:openTempFile:): 2109 (application:openFile, application:openTempFile:):
1212 (application:openFileWithoutUI:, application:openFiles:): Open file 2110 (application:openFileWithoutUI:, application:openFiles:): Open file
1213 if not_in_argv returns non-zero (bug#12171). 2111 if not_in_argv returns non-zero (bug#12171).
1214 2112
@@ -2395,7 +3293,7 @@
2395 3293
23962012-07-21 Jan Djärv <jan.h.d@swipnet.se> 32942012-07-21 Jan Djärv <jan.h.d@swipnet.se>
2397 3295
2398 * nsterm.m (accessibilityAttributeValue): New function. (Bug#11134). 3296 * nsterm.m (accessibilityAttributeValue): New function. (Bug#11134).
2399 (conversationIdentifier): Return value is NSInteger. 3297 (conversationIdentifier): Return value is NSInteger.
2400 * nsterm.m (accessibilityAttributeValue): Surround with NS_IMPL_COCOA. 3298 * nsterm.m (accessibilityAttributeValue): Surround with NS_IMPL_COCOA.
2401 3299
@@ -4905,7 +5803,7 @@
4905 * lisp.h (struct vectorlike_header): New field `nbytes', 5803 * lisp.h (struct vectorlike_header): New field `nbytes',
4906 adjust comment accordingly. 5804 adjust comment accordingly.
4907 * alloc.c (enum mem_type): New type `MEM_TYPE_VECTOR_BLOCK' 5805 * alloc.c (enum mem_type): New type `MEM_TYPE_VECTOR_BLOCK'
4908 to denote vector blocks. Adjust users (live_vector_p, 5806 to denote vector blocks. Adjust users (live_vector_p,
4909 mark_maybe_pointer, valid_lisp_object_p) accordingly. 5807 mark_maybe_pointer, valid_lisp_object_p) accordingly.
4910 (COMMON_MULTIPLE): Move outside #if USE_LSB_TAG. 5808 (COMMON_MULTIPLE): Move outside #if USE_LSB_TAG.
4911 (VECTOR_BLOCK_SIZE, vroundup, VECTOR_BLOCK_BYTES), 5809 (VECTOR_BLOCK_SIZE, vroundup, VECTOR_BLOCK_BYTES),
@@ -4919,7 +5817,7 @@
4919 (allocate_vector_from_block, init_vectors, allocate_vector_from_block) 5817 (allocate_vector_from_block, init_vectors, allocate_vector_from_block)
4920 (sweep_vectors): New functions. 5818 (sweep_vectors): New functions.
4921 (allocate_vectorlike): Return `zero_vector' as the only vector of 5819 (allocate_vectorlike): Return `zero_vector' as the only vector of
4922 0 items. Allocate new vector from block if vector size is less than 5820 0 items. Allocate new vector from block if vector size is less than
4923 or equal to VBLOCK_BYTES_MAX. 5821 or equal to VBLOCK_BYTES_MAX.
4924 (Fgarbage_collect): Move all vector sweeping code to sweep_vectors. 5822 (Fgarbage_collect): Move all vector sweeping code to sweep_vectors.
4925 (init_alloc_once): Add call to init_vectors. 5823 (init_alloc_once): Add call to init_vectors.
@@ -5009,7 +5907,7 @@
5009 change it's type from Lisp_Object to bitfield. 5907 change it's type from Lisp_Object to bitfield.
5010 Change type of 'force_start', 'optional_new_start', 5908 Change type of 'force_start', 'optional_new_start',
5011 'last_had_star', 'update_mode_line' and 'start_at_line_beg' 5909 'last_had_star', 'update_mode_line' and 'start_at_line_beg'
5012 fields from Lisp_Object to bitfield. Adjust users accordingly. 5910 fields from Lisp_Object to bitfield. Adjust users accordingly.
5013 5911
50142012-05-31 Paul Eggert <eggert@cs.ucla.edu> 59122012-05-31 Paul Eggert <eggert@cs.ucla.edu>
5015 5913
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 =
252## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. 252## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS.
253MSDOS_X_OBJ = 253MSDOS_X_OBJ =
254 254
255ns_appdir=@ns_appdir@
256ns_appbindir=@ns_appbindir@
257ns_appsrc=@ns_appsrc@
258NS_OBJ=@NS_OBJ@ 255NS_OBJ=@NS_OBJ@
259## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS. 256## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS.
260NS_OBJC_OBJ=@NS_OBJC_OBJ@ 257NS_OBJC_OBJ=@NS_OBJC_OBJ@
@@ -453,7 +450,7 @@ GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m)
453 450
454gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) 451gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
455 @rm -f gl-tmp 452 @rm -f gl-tmp
456 $(libsrc)/make-docfile -d $(srcdir) -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp 453 $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl-tmp
457 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h 454 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h
458 echo timestamp > $@ 455 echo timestamp > $@
459 456
@@ -506,8 +503,9 @@ $(OLDXMENU): $(OLDXMENU_TARGET)
506doc.o: buildobj.h 503doc.o: buildobj.h
507 504
508 505
509## If HAVE_NS, some ns-specific rules (for OTHER_FILES) are inserted here. 506ns-app: emacs$(EXEEXT)
510@ns_frag@ 507 cd ../nextstep && $(MAKE) $(MFLAGS) all
508
511 509
512.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean 510.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
513.PHONY: versionclean extraclean frc 511.PHONY: versionclean extraclean frc
@@ -521,7 +519,6 @@ mostlyclean:
521clean: mostlyclean 519clean: mostlyclean
522 rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT) 520 rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT)
523 -rm -rf $(DEPDIR) 521 -rm -rf $(DEPDIR)
524 test "X$(ns_appdir)" = "X" || rm -rf $(ns_appdir)
525 522
526## bootstrap-clean is used to clean up just before a bootstrap. 523## bootstrap-clean is used to clean up just before a bootstrap.
527## It should remove all files generated during a compilation/bootstrap, 524## 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/>. */
24 24
25#include <stdio.h> 25#include <stdio.h>
26#include <limits.h> /* For CHAR_BIT. */ 26#include <limits.h> /* For CHAR_BIT. */
27#include <setjmp.h>
28 27
29#include <signal.h> 28#ifdef ENABLE_CHECKING
29#include <signal.h> /* For SIGABRT. */
30#endif
30 31
31#ifdef HAVE_PTHREAD 32#ifdef HAVE_PTHREAD
32#include <pthread.h> 33#include <pthread.h>
@@ -42,9 +43,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#include "keyboard.h" 43#include "keyboard.h"
43#include "frame.h" 44#include "frame.h"
44#include "blockinput.h" 45#include "blockinput.h"
45#include "syssignal.h"
46#include "termhooks.h" /* For struct terminal. */ 46#include "termhooks.h" /* For struct terminal. */
47#include <setjmp.h> 47
48#include <verify.h> 48#include <verify.h>
49 49
50/* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. 50/* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects.
@@ -69,6 +69,9 @@ extern void *sbrk ();
69 69
70#include <fcntl.h> 70#include <fcntl.h>
71 71
72#ifdef USE_GTK
73# include "gtkutil.h"
74#endif
72#ifdef WINDOWSNT 75#ifdef WINDOWSNT
73#include "w32.h" 76#include "w32.h"
74#endif 77#endif
@@ -82,66 +85,8 @@ extern void *sbrk ();
82 85
83#define MMAP_MAX_AREAS 100000000 86#define MMAP_MAX_AREAS 100000000
84 87
85#else /* not DOUG_LEA_MALLOC */
86
87/* The following come from gmalloc.c. */
88
89extern size_t _bytes_used;
90extern size_t __malloc_extra_blocks;
91extern void *_malloc_internal (size_t);
92extern void _free_internal (void *);
93
94#endif /* not DOUG_LEA_MALLOC */ 88#endif /* not DOUG_LEA_MALLOC */
95 89
96#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT
97#ifdef HAVE_PTHREAD
98
99/* When GTK uses the file chooser dialog, different backends can be loaded
100 dynamically. One such a backend is the Gnome VFS backend that gets loaded
101 if you run Gnome. That backend creates several threads and also allocates
102 memory with malloc.
103
104 Also, gconf and gsettings may create several threads.
105
106 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
107 functions below are called from malloc, there is a chance that one
108 of these threads preempts the Emacs main thread and the hook variables
109 end up in an inconsistent state. So we have a mutex to prevent that (note
110 that the backend handles concurrent access to malloc within its own threads
111 but Emacs code running in the main thread is not included in that control).
112
113 When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this
114 happens in one of the backend threads we will have two threads that tries
115 to run Emacs code at once, and the code is not prepared for that.
116 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */
117
118static pthread_mutex_t alloc_mutex;
119
120#define BLOCK_INPUT_ALLOC \
121 do \
122 { \
123 if (pthread_equal (pthread_self (), main_thread)) \
124 BLOCK_INPUT; \
125 pthread_mutex_lock (&alloc_mutex); \
126 } \
127 while (0)
128#define UNBLOCK_INPUT_ALLOC \
129 do \
130 { \
131 pthread_mutex_unlock (&alloc_mutex); \
132 if (pthread_equal (pthread_self (), main_thread)) \
133 UNBLOCK_INPUT; \
134 } \
135 while (0)
136
137#else /* ! defined HAVE_PTHREAD */
138
139#define BLOCK_INPUT_ALLOC BLOCK_INPUT
140#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
141
142#endif /* ! defined HAVE_PTHREAD */
143#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */
144
145/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer 90/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer
146 to a struct Lisp_String. */ 91 to a struct Lisp_String. */
147 92
@@ -200,10 +145,6 @@ static char *spare_memory[7];
200 145
201#define SPARE_MEMORY (1 << 14) 146#define SPARE_MEMORY (1 << 14)
202 147
203/* Number of extra blocks malloc should get when it needs more core. */
204
205static int malloc_hysteresis;
206
207/* Initialize it to a nonzero value to force it into data space 148/* Initialize it to a nonzero value to force it into data space
208 (rather than bss space). That way unexec will remap it into text 149 (rather than bss space). That way unexec will remap it into text
209 space (pure), on some systems. We have not implemented the 150 space (pure), on some systems. We have not implemented the
@@ -275,6 +216,7 @@ static void gc_sweep (void);
275static Lisp_Object make_pure_vector (ptrdiff_t); 216static Lisp_Object make_pure_vector (ptrdiff_t);
276static void mark_glyph_matrix (struct glyph_matrix *); 217static void mark_glyph_matrix (struct glyph_matrix *);
277static void mark_face_cache (struct face_cache *); 218static void mark_face_cache (struct face_cache *);
219static void mark_buffer (struct buffer *);
278 220
279#if !defined REL_ALLOC || defined SYSTEM_MALLOC 221#if !defined REL_ALLOC || defined SYSTEM_MALLOC
280static void refill_memory_reserve (void); 222static void refill_memory_reserve (void);
@@ -407,12 +349,12 @@ static void mark_memory (void *, void *);
407static void mem_init (void); 349static void mem_init (void);
408static struct mem_node *mem_insert (void *, void *, enum mem_type); 350static struct mem_node *mem_insert (void *, void *, enum mem_type);
409static void mem_insert_fixup (struct mem_node *); 351static void mem_insert_fixup (struct mem_node *);
410#endif
411static void mem_rotate_left (struct mem_node *); 352static void mem_rotate_left (struct mem_node *);
412static void mem_rotate_right (struct mem_node *); 353static void mem_rotate_right (struct mem_node *);
413static void mem_delete (struct mem_node *); 354static void mem_delete (struct mem_node *);
414static void mem_delete_fixup (struct mem_node *); 355static void mem_delete_fixup (struct mem_node *);
415static inline struct mem_node *mem_find (void *); 356static inline struct mem_node *mem_find (void *);
357#endif
416 358
417 359
418#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS 360#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
@@ -581,39 +523,17 @@ xmalloc_get_size (unsigned char *ptr)
581} 523}
582 524
583 525
584/* The call depth in overrun_check functions. For example, this might happen:
585 xmalloc()
586 overrun_check_malloc()
587 -> malloc -> (via hook)_-> emacs_blocked_malloc
588 -> overrun_check_malloc
589 call malloc (hooks are NULL, so real malloc is called).
590 malloc returns 10000.
591 add overhead, return 10016.
592 <- (back in overrun_check_malloc)
593 add overhead again, return 10032
594 xmalloc returns 10032.
595
596 (time passes).
597
598 xfree(10032)
599 overrun_check_free(10032)
600 decrease overhead
601 free(10016) <- crash, because 10000 is the original pointer. */
602
603static ptrdiff_t check_depth;
604
605/* Like malloc, but wraps allocated block with header and trailer. */ 526/* Like malloc, but wraps allocated block with header and trailer. */
606 527
607static void * 528static void *
608overrun_check_malloc (size_t size) 529overrun_check_malloc (size_t size)
609{ 530{
610 register unsigned char *val; 531 register unsigned char *val;
611 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; 532 if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size)
612 if (SIZE_MAX - overhead < size) 533 emacs_abort ();
613 abort ();
614 534
615 val = malloc (size + overhead); 535 val = malloc (size + XMALLOC_OVERRUN_CHECK_OVERHEAD);
616 if (val && check_depth == 1) 536 if (val)
617 { 537 {
618 memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); 538 memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE);
619 val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 539 val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
@@ -621,7 +541,6 @@ overrun_check_malloc (size_t size)
621 memcpy (val + size, xmalloc_overrun_check_trailer, 541 memcpy (val + size, xmalloc_overrun_check_trailer,
622 XMALLOC_OVERRUN_CHECK_SIZE); 542 XMALLOC_OVERRUN_CHECK_SIZE);
623 } 543 }
624 --check_depth;
625 return val; 544 return val;
626} 545}
627 546
@@ -633,12 +552,10 @@ static void *
633overrun_check_realloc (void *block, size_t size) 552overrun_check_realloc (void *block, size_t size)
634{ 553{
635 register unsigned char *val = (unsigned char *) block; 554 register unsigned char *val = (unsigned char *) block;
636 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; 555 if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size)
637 if (SIZE_MAX - overhead < size) 556 emacs_abort ();
638 abort ();
639 557
640 if (val 558 if (val
641 && check_depth == 1
642 && memcmp (xmalloc_overrun_check_header, 559 && memcmp (xmalloc_overrun_check_header,
643 val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, 560 val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE,
644 XMALLOC_OVERRUN_CHECK_SIZE) == 0) 561 XMALLOC_OVERRUN_CHECK_SIZE) == 0)
@@ -646,15 +563,15 @@ overrun_check_realloc (void *block, size_t size)
646 size_t osize = xmalloc_get_size (val); 563 size_t osize = xmalloc_get_size (val);
647 if (memcmp (xmalloc_overrun_check_trailer, val + osize, 564 if (memcmp (xmalloc_overrun_check_trailer, val + osize,
648 XMALLOC_OVERRUN_CHECK_SIZE)) 565 XMALLOC_OVERRUN_CHECK_SIZE))
649 abort (); 566 emacs_abort ();
650 memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); 567 memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
651 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 568 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
652 memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); 569 memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE);
653 } 570 }
654 571
655 val = realloc (val, size + overhead); 572 val = realloc (val, size + XMALLOC_OVERRUN_CHECK_OVERHEAD);
656 573
657 if (val && check_depth == 1) 574 if (val)
658 { 575 {
659 memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); 576 memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE);
660 val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 577 val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
@@ -662,7 +579,6 @@ overrun_check_realloc (void *block, size_t size)
662 memcpy (val + size, xmalloc_overrun_check_trailer, 579 memcpy (val + size, xmalloc_overrun_check_trailer,
663 XMALLOC_OVERRUN_CHECK_SIZE); 580 XMALLOC_OVERRUN_CHECK_SIZE);
664 } 581 }
665 --check_depth;
666 return val; 582 return val;
667} 583}
668 584
@@ -673,9 +589,7 @@ overrun_check_free (void *block)
673{ 589{
674 unsigned char *val = (unsigned char *) block; 590 unsigned char *val = (unsigned char *) block;
675 591
676 ++check_depth;
677 if (val 592 if (val
678 && check_depth == 1
679 && memcmp (xmalloc_overrun_check_header, 593 && memcmp (xmalloc_overrun_check_header,
680 val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, 594 val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE,
681 XMALLOC_OVERRUN_CHECK_SIZE) == 0) 595 XMALLOC_OVERRUN_CHECK_SIZE) == 0)
@@ -683,7 +597,7 @@ overrun_check_free (void *block)
683 size_t osize = xmalloc_get_size (val); 597 size_t osize = xmalloc_get_size (val);
684 if (memcmp (xmalloc_overrun_check_trailer, val + osize, 598 if (memcmp (xmalloc_overrun_check_trailer, val + osize,
685 XMALLOC_OVERRUN_CHECK_SIZE)) 599 XMALLOC_OVERRUN_CHECK_SIZE))
686 abort (); 600 emacs_abort ();
687#ifdef XMALLOC_CLEAR_FREE_MEMORY 601#ifdef XMALLOC_CLEAR_FREE_MEMORY
688 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 602 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
689 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD); 603 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD);
@@ -695,7 +609,6 @@ overrun_check_free (void *block)
695 } 609 }
696 610
697 free (val); 611 free (val);
698 --check_depth;
699} 612}
700 613
701#undef malloc 614#undef malloc
@@ -706,14 +619,33 @@ overrun_check_free (void *block)
706#define free overrun_check_free 619#define free overrun_check_free
707#endif 620#endif
708 621
709#ifdef SYNC_INPUT 622/* If compiled with XMALLOC_BLOCK_INPUT_CHECK, define a symbol
710/* When using SYNC_INPUT, we don't call malloc from a signal handler, so 623 BLOCK_INPUT_IN_MEMORY_ALLOCATORS that is visible to the debugger.
711 there's no need to block input around malloc. */ 624 If that variable is set, block input while in one of Emacs's memory
712#define MALLOC_BLOCK_INPUT ((void)0) 625 allocation functions. There should be no need for this debugging
713#define MALLOC_UNBLOCK_INPUT ((void)0) 626 option, since signal handlers do not allocate memory, but Emacs
627 formerly allocated memory in signal handlers and this compile-time
628 option remains as a way to help debug the issue should it rear its
629 ugly head again. */
630#ifdef XMALLOC_BLOCK_INPUT_CHECK
631bool block_input_in_memory_allocators EXTERNALLY_VISIBLE;
632static void
633malloc_block_input (void)
634{
635 if (block_input_in_memory_allocators)
636 BLOCK_INPUT;
637}
638static void
639malloc_unblock_input (void)
640{
641 if (block_input_in_memory_allocators)
642 UNBLOCK_INPUT;
643}
644# define MALLOC_BLOCK_INPUT malloc_block_input ()
645# define MALLOC_UNBLOCK_INPUT malloc_unblock_input ()
714#else 646#else
715#define MALLOC_BLOCK_INPUT BLOCK_INPUT 647# define MALLOC_BLOCK_INPUT ((void) 0)
716#define MALLOC_UNBLOCK_INPUT UNBLOCK_INPUT 648# define MALLOC_UNBLOCK_INPUT ((void) 0)
717#endif 649#endif
718 650
719/* Like malloc but check for no memory and block interrupt input.. */ 651/* Like malloc but check for no memory and block interrupt input.. */
@@ -782,8 +714,7 @@ xfree (void *block)
782 free (block); 714 free (block);
783 MALLOC_UNBLOCK_INPUT; 715 MALLOC_UNBLOCK_INPUT;
784 /* We don't call refill_memory_reserve here 716 /* We don't call refill_memory_reserve here
785 because that duplicates doing so in emacs_blocked_free 717 because in practice the call in r_alloc_free seems to suffice. */
786 and the criterion should go there. */
787} 718}
788 719
789 720
@@ -1210,256 +1141,6 @@ lisp_align_free (void *block)
1210} 1141}
1211 1142
1212 1143
1213#ifndef SYSTEM_MALLOC
1214
1215/* Arranging to disable input signals while we're in malloc.
1216
1217 This only works with GNU malloc. To help out systems which can't
1218 use GNU malloc, all the calls to malloc, realloc, and free
1219 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT
1220 pair; unfortunately, we have no idea what C library functions
1221 might call malloc, so we can't really protect them unless you're
1222 using GNU malloc. Fortunately, most of the major operating systems
1223 can use GNU malloc. */
1224
1225#ifndef SYNC_INPUT
1226/* When using SYNC_INPUT, we don't call malloc from a signal handler, so
1227 there's no need to block input around malloc. */
1228
1229#ifndef DOUG_LEA_MALLOC
1230extern void * (*__malloc_hook) (size_t, const void *);
1231extern void * (*__realloc_hook) (void *, size_t, const void *);
1232extern void (*__free_hook) (void *, const void *);
1233/* Else declared in malloc.h, perhaps with an extra arg. */
1234#endif /* DOUG_LEA_MALLOC */
1235static void * (*old_malloc_hook) (size_t, const void *);
1236static void * (*old_realloc_hook) (void *, size_t, const void*);
1237static void (*old_free_hook) (void*, const void*);
1238
1239#ifdef DOUG_LEA_MALLOC
1240# define BYTES_USED (mallinfo ().uordblks)
1241#else
1242# define BYTES_USED _bytes_used
1243#endif
1244
1245#ifdef GC_MALLOC_CHECK
1246static bool dont_register_blocks;
1247#endif
1248
1249static size_t bytes_used_when_reconsidered;
1250
1251/* Value of _bytes_used, when spare_memory was freed. */
1252
1253static size_t bytes_used_when_full;
1254
1255/* This function is used as the hook for free to call. */
1256
1257static void
1258emacs_blocked_free (void *ptr, const void *ptr2)
1259{
1260 BLOCK_INPUT_ALLOC;
1261
1262#ifdef GC_MALLOC_CHECK
1263 if (ptr)
1264 {
1265 struct mem_node *m;
1266
1267 m = mem_find (ptr);
1268 if (m == MEM_NIL || m->start != ptr)
1269 {
1270 fprintf (stderr,
1271 "Freeing `%p' which wasn't allocated with malloc\n", ptr);
1272 abort ();
1273 }
1274 else
1275 {
1276 /* fprintf (stderr, "free %p...%p (%p)\n", m->start, m->end, ptr); */
1277 mem_delete (m);
1278 }
1279 }
1280#endif /* GC_MALLOC_CHECK */
1281
1282 __free_hook = old_free_hook;
1283 free (ptr);
1284
1285 /* If we released our reserve (due to running out of memory),
1286 and we have a fair amount free once again,
1287 try to set aside another reserve in case we run out once more. */
1288 if (! NILP (Vmemory_full)
1289 /* Verify there is enough space that even with the malloc
1290 hysteresis this call won't run out again.
1291 The code here is correct as long as SPARE_MEMORY
1292 is substantially larger than the block size malloc uses. */
1293 && (bytes_used_when_full
1294 > ((bytes_used_when_reconsidered = BYTES_USED)
1295 + max (malloc_hysteresis, 4) * SPARE_MEMORY)))
1296 refill_memory_reserve ();
1297
1298 __free_hook = emacs_blocked_free;
1299 UNBLOCK_INPUT_ALLOC;
1300}
1301
1302
1303/* This function is the malloc hook that Emacs uses. */
1304
1305static void *
1306emacs_blocked_malloc (size_t size, const void *ptr)
1307{
1308 void *value;
1309
1310 BLOCK_INPUT_ALLOC;
1311 __malloc_hook = old_malloc_hook;
1312#ifdef DOUG_LEA_MALLOC
1313 /* Segfaults on my system. --lorentey */
1314 /* mallopt (M_TOP_PAD, malloc_hysteresis * 4096); */
1315#else
1316 __malloc_extra_blocks = malloc_hysteresis;
1317#endif
1318
1319 value = malloc (size);
1320
1321#ifdef GC_MALLOC_CHECK
1322 {
1323 struct mem_node *m = mem_find (value);
1324 if (m != MEM_NIL)
1325 {
1326 fprintf (stderr, "Malloc returned %p which is already in use\n",
1327 value);
1328 fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n",
1329 m->start, m->end, (char *) m->end - (char *) m->start,
1330 m->type);
1331 abort ();
1332 }
1333
1334 if (!dont_register_blocks)
1335 {
1336 mem_insert (value, (char *) value + max (1, size), allocated_mem_type);
1337 allocated_mem_type = MEM_TYPE_NON_LISP;
1338 }
1339 }
1340#endif /* GC_MALLOC_CHECK */
1341
1342 __malloc_hook = emacs_blocked_malloc;
1343 UNBLOCK_INPUT_ALLOC;
1344
1345 /* fprintf (stderr, "%p malloc\n", value); */
1346 return value;
1347}
1348
1349
1350/* This function is the realloc hook that Emacs uses. */
1351
1352static void *
1353emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
1354{
1355 void *value;
1356
1357 BLOCK_INPUT_ALLOC;
1358 __realloc_hook = old_realloc_hook;
1359
1360#ifdef GC_MALLOC_CHECK
1361 if (ptr)
1362 {
1363 struct mem_node *m = mem_find (ptr);
1364 if (m == MEM_NIL || m->start != ptr)
1365 {
1366 fprintf (stderr,
1367 "Realloc of %p which wasn't allocated with malloc\n",
1368 ptr);
1369 abort ();
1370 }
1371
1372 mem_delete (m);
1373 }
1374
1375 /* fprintf (stderr, "%p -> realloc\n", ptr); */
1376
1377 /* Prevent malloc from registering blocks. */
1378 dont_register_blocks = 1;
1379#endif /* GC_MALLOC_CHECK */
1380
1381 value = realloc (ptr, size);
1382
1383#ifdef GC_MALLOC_CHECK
1384 dont_register_blocks = 0;
1385
1386 {
1387 struct mem_node *m = mem_find (value);
1388 if (m != MEM_NIL)
1389 {
1390 fprintf (stderr, "Realloc returns memory that is already in use\n");
1391 abort ();
1392 }
1393
1394 /* Can't handle zero size regions in the red-black tree. */
1395 mem_insert (value, (char *) value + max (size, 1), MEM_TYPE_NON_LISP);
1396 }
1397
1398 /* fprintf (stderr, "%p <- realloc\n", value); */
1399#endif /* GC_MALLOC_CHECK */
1400
1401 __realloc_hook = emacs_blocked_realloc;
1402 UNBLOCK_INPUT_ALLOC;
1403
1404 return value;
1405}
1406
1407
1408#ifdef HAVE_PTHREAD
1409/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
1410 normal malloc. Some thread implementations need this as they call
1411 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
1412 calls malloc because it is the first call, and we have an endless loop. */
1413
1414void
1415reset_malloc_hooks (void)
1416{
1417 __free_hook = old_free_hook;
1418 __malloc_hook = old_malloc_hook;
1419 __realloc_hook = old_realloc_hook;
1420}
1421#endif /* HAVE_PTHREAD */
1422
1423
1424/* Called from main to set up malloc to use our hooks. */
1425
1426void
1427uninterrupt_malloc (void)
1428{
1429#ifdef HAVE_PTHREAD
1430#ifdef DOUG_LEA_MALLOC
1431 pthread_mutexattr_t attr;
1432
1433 /* GLIBC has a faster way to do this, but let's keep it portable.
1434 This is according to the Single UNIX Specification. */
1435 pthread_mutexattr_init (&attr);
1436 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
1437 pthread_mutex_init (&alloc_mutex, &attr);
1438#else /* !DOUG_LEA_MALLOC */
1439 /* Some systems such as Solaris 2.6 don't have a recursive mutex,
1440 and the bundled gmalloc.c doesn't require it. */
1441 pthread_mutex_init (&alloc_mutex, NULL);
1442#endif /* !DOUG_LEA_MALLOC */
1443#endif /* HAVE_PTHREAD */
1444
1445 if (__free_hook != emacs_blocked_free)
1446 old_free_hook = __free_hook;
1447 __free_hook = emacs_blocked_free;
1448
1449 if (__malloc_hook != emacs_blocked_malloc)
1450 old_malloc_hook = __malloc_hook;
1451 __malloc_hook = emacs_blocked_malloc;
1452
1453 if (__realloc_hook != emacs_blocked_realloc)
1454 old_realloc_hook = __realloc_hook;
1455 __realloc_hook = emacs_blocked_realloc;
1456}
1457
1458#endif /* not SYNC_INPUT */
1459#endif /* not SYSTEM_MALLOC */
1460
1461
1462
1463/*********************************************************************** 1144/***********************************************************************
1464 Interval Allocation 1145 Interval Allocation
1465 ***********************************************************************/ 1146 ***********************************************************************/
@@ -1505,8 +1186,6 @@ make_interval (void)
1505{ 1186{
1506 INTERVAL val; 1187 INTERVAL val;
1507 1188
1508 /* eassert (!handling_signal); */
1509
1510 MALLOC_BLOCK_INPUT; 1189 MALLOC_BLOCK_INPUT;
1511 1190
1512 if (interval_free_list) 1191 if (interval_free_list)
@@ -1801,7 +1480,7 @@ string_bytes (struct Lisp_String *s)
1801 if (!PURE_POINTER_P (s) 1480 if (!PURE_POINTER_P (s)
1802 && s->data 1481 && s->data
1803 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) 1482 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
1804 abort (); 1483 emacs_abort ();
1805 return nbytes; 1484 return nbytes;
1806} 1485}
1807 1486
@@ -1875,7 +1554,7 @@ check_string_free_list (void)
1875 while (s != NULL) 1554 while (s != NULL)
1876 { 1555 {
1877 if ((uintptr_t) s < 1024) 1556 if ((uintptr_t) s < 1024)
1878 abort (); 1557 emacs_abort ();
1879 s = NEXT_FREE_LISP_STRING (s); 1558 s = NEXT_FREE_LISP_STRING (s);
1880 } 1559 }
1881} 1560}
@@ -1890,8 +1569,6 @@ allocate_string (void)
1890{ 1569{
1891 struct Lisp_String *s; 1570 struct Lisp_String *s;
1892 1571
1893 /* eassert (!handling_signal); */
1894
1895 MALLOC_BLOCK_INPUT; 1572 MALLOC_BLOCK_INPUT;
1896 1573
1897 /* If the free-list is empty, allocate a new string_block, and 1574 /* If the free-list is empty, allocate a new string_block, and
@@ -2104,7 +1781,7 @@ sweep_strings (void)
2104 back-pointer so that we know it's free. */ 1781 back-pointer so that we know it's free. */
2105#ifdef GC_CHECK_STRING_BYTES 1782#ifdef GC_CHECK_STRING_BYTES
2106 if (string_bytes (s) != SDATA_NBYTES (data)) 1783 if (string_bytes (s) != SDATA_NBYTES (data))
2107 abort (); 1784 emacs_abort ();
2108#else 1785#else
2109 data->u.nbytes = STRING_BYTES (s); 1786 data->u.nbytes = STRING_BYTES (s);
2110#endif 1787#endif
@@ -2215,7 +1892,7 @@ compact_small_strings (void)
2215 /* Check that the string size recorded in the string is the 1892 /* Check that the string size recorded in the string is the
2216 same as the one recorded in the sdata structure. */ 1893 same as the one recorded in the sdata structure. */
2217 if (s && string_bytes (s) != SDATA_NBYTES (from)) 1894 if (s && string_bytes (s) != SDATA_NBYTES (from))
2218 abort (); 1895 emacs_abort ();
2219#endif /* GC_CHECK_STRING_BYTES */ 1896#endif /* GC_CHECK_STRING_BYTES */
2220 1897
2221 nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); 1898 nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from);
@@ -2228,7 +1905,7 @@ compact_small_strings (void)
2228 if (memcmp (string_overrun_cookie, 1905 if (memcmp (string_overrun_cookie,
2229 (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, 1906 (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE,
2230 GC_STRING_OVERRUN_COOKIE_SIZE)) 1907 GC_STRING_OVERRUN_COOKIE_SIZE))
2231 abort (); 1908 emacs_abort ();
2232#endif 1909#endif
2233 1910
2234 /* Non-NULL S means it's alive. Copy its data. */ 1911 /* Non-NULL S means it's alive. Copy its data. */
@@ -2485,7 +2162,7 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
2485 struct Lisp_String *s; 2162 struct Lisp_String *s;
2486 2163
2487 if (nchars < 0) 2164 if (nchars < 0)
2488 abort (); 2165 emacs_abort ();
2489 if (!nbytes) 2166 if (!nbytes)
2490 return empty_multibyte_string; 2167 return empty_multibyte_string;
2491 2168
@@ -2583,8 +2260,6 @@ make_float (double float_value)
2583{ 2260{
2584 register Lisp_Object val; 2261 register Lisp_Object val;
2585 2262
2586 /* eassert (!handling_signal); */
2587
2588 MALLOC_BLOCK_INPUT; 2263 MALLOC_BLOCK_INPUT;
2589 2264
2590 if (float_free_list) 2265 if (float_free_list)
@@ -2692,8 +2367,6 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2692{ 2367{
2693 register Lisp_Object val; 2368 register Lisp_Object val;
2694 2369
2695 /* eassert (!handling_signal); */
2696
2697 MALLOC_BLOCK_INPUT; 2370 MALLOC_BLOCK_INPUT;
2698 2371
2699 if (cons_free_list) 2372 if (cons_free_list)
@@ -2806,7 +2479,7 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
2806 else if (type == CONSTYPE_HEAP) 2479 else if (type == CONSTYPE_HEAP)
2807 val = Fcons (objp[i], val); 2480 val = Fcons (objp[i], val);
2808 else 2481 else
2809 abort (); 2482 emacs_abort ();
2810 } 2483 }
2811 return val; 2484 return val;
2812} 2485}
@@ -3199,9 +2872,6 @@ allocate_vectorlike (ptrdiff_t len)
3199 2872
3200 MALLOC_BLOCK_INPUT; 2873 MALLOC_BLOCK_INPUT;
3201 2874
3202 /* This gets triggered by code which I haven't bothered to fix. --Stef */
3203 /* eassert (!handling_signal); */
3204
3205 if (len == 0) 2875 if (len == 0)
3206 p = XVECTOR (zero_vector); 2876 p = XVECTOR (zero_vector);
3207 else 2877 else
@@ -3278,7 +2948,10 @@ allocate_buffer (void)
3278 2948
3279 XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) 2949 XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text)
3280 - header_size) / word_size); 2950 - header_size) / word_size);
3281 /* Note that the fields of B are not initialized. */ 2951 /* Put B on the chain of all buffers including killed ones. */
2952 b->header.next.buffer = all_buffers;
2953 all_buffers = b;
2954 /* Note that the rest fields of B are not initialized. */
3282 return b; 2955 return b;
3283} 2956}
3284 2957
@@ -3483,8 +3156,6 @@ Its value and function definition are void, and its property list is nil. */)
3483 3156
3484 CHECK_STRING (name); 3157 CHECK_STRING (name);
3485 3158
3486 /* eassert (!handling_signal); */
3487
3488 MALLOC_BLOCK_INPUT; 3159 MALLOC_BLOCK_INPUT;
3489 3160
3490 if (symbol_free_list) 3161 if (symbol_free_list)
@@ -3569,8 +3240,6 @@ allocate_misc (enum Lisp_Misc_Type type)
3569{ 3240{
3570 Lisp_Object val; 3241 Lisp_Object val;
3571 3242
3572 /* eassert (!handling_signal); */
3573
3574 MALLOC_BLOCK_INPUT; 3243 MALLOC_BLOCK_INPUT;
3575 3244
3576 if (marker_free_list) 3245 if (marker_free_list)
@@ -3674,7 +3343,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos)
3674 struct Lisp_Marker *m; 3343 struct Lisp_Marker *m;
3675 3344
3676 /* No dead buffers here. */ 3345 /* No dead buffers here. */
3677 eassert (!NILP (BVAR (buf, name))); 3346 eassert (BUFFER_LIVE_P (buf));
3678 3347
3679 /* Every character is at least one byte. */ 3348 /* Every character is at least one byte. */
3680 eassert (charpos <= bytepos); 3349 eassert (charpos <= bytepos);
@@ -3790,12 +3459,6 @@ memory_full (size_t nbytes)
3790 lisp_free (spare_memory[i]); 3459 lisp_free (spare_memory[i]);
3791 spare_memory[i] = 0; 3460 spare_memory[i] = 0;
3792 } 3461 }
3793
3794 /* Record the space now used. When it decreases substantially,
3795 we can refill the memory reserve. */
3796#if !defined SYSTEM_MALLOC && !defined SYNC_INPUT
3797 bytes_used_when_full = BYTES_USED;
3798#endif
3799 } 3462 }
3800 3463
3801 /* This used to call error, but if we've run out of memory, we could 3464 /* 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)
3916 while (c != MEM_NIL) 3579 while (c != MEM_NIL)
3917 { 3580 {
3918 if (start >= c->start && start < c->end) 3581 if (start >= c->start && start < c->end)
3919 abort (); 3582 emacs_abort ();
3920 parent = c; 3583 parent = c;
3921 c = start < c->start ? c->left : c->right; 3584 c = start < c->start ? c->left : c->right;
3922 } 3585 }
@@ -3933,9 +3596,9 @@ mem_insert (void *start, void *end, enum mem_type type)
3933 3596
3934 /* Create a new node. */ 3597 /* Create a new node. */
3935#ifdef GC_MALLOC_CHECK 3598#ifdef GC_MALLOC_CHECK
3936 x = _malloc_internal (sizeof *x); 3599 x = malloc (sizeof *x);
3937 if (x == NULL) 3600 if (x == NULL)
3938 abort (); 3601 emacs_abort ();
3939#else 3602#else
3940 x = xmalloc (sizeof *x); 3603 x = xmalloc (sizeof *x);
3941#endif 3604#endif
@@ -4157,7 +3820,7 @@ mem_delete (struct mem_node *z)
4157 mem_delete_fixup (x); 3820 mem_delete_fixup (x);
4158 3821
4159#ifdef GC_MALLOC_CHECK 3822#ifdef GC_MALLOC_CHECK
4160 _free_internal (y); 3823 free (y);
4161#else 3824#else
4162 xfree (y); 3825 xfree (y);
4163#endif 3826#endif
@@ -4610,7 +4273,7 @@ mark_maybe_pointer (void *p)
4610 break; 4273 break;
4611 4274
4612 default: 4275 default:
4613 abort (); 4276 emacs_abort ();
4614 } 4277 }
4615 4278
4616 if (!NILP (obj)) 4279 if (!NILP (obj))
@@ -4754,14 +4417,14 @@ test_setjmp (void)
4754{ 4417{
4755 char buf[10]; 4418 char buf[10];
4756 register int x; 4419 register int x;
4757 jmp_buf jbuf; 4420 sys_jmp_buf jbuf;
4758 4421
4759 /* Arrange for X to be put in a register. */ 4422 /* Arrange for X to be put in a register. */
4760 sprintf (buf, "1"); 4423 sprintf (buf, "1");
4761 x = strlen (buf); 4424 x = strlen (buf);
4762 x = 2 * x - 1; 4425 x = 2 * x - 1;
4763 4426
4764 setjmp (jbuf); 4427 sys_setjmp (jbuf);
4765 if (longjmps_done == 1) 4428 if (longjmps_done == 1)
4766 { 4429 {
4767 /* Came here after the longjmp at the end of the function. 4430 /* Came here after the longjmp at the end of the function.
@@ -4786,7 +4449,7 @@ test_setjmp (void)
4786 ++longjmps_done; 4449 ++longjmps_done;
4787 x = 2; 4450 x = 2;
4788 if (longjmps_done == 1) 4451 if (longjmps_done == 1)
4789 longjmp (jbuf, 1); 4452 sys_longjmp (jbuf, 1);
4790} 4453}
4791 4454
4792#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ 4455#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */
@@ -4807,7 +4470,7 @@ check_gcpros (void)
4807 if (!survives_gc_p (p->var[i])) 4470 if (!survives_gc_p (p->var[i]))
4808 /* FIXME: It's not necessarily a bug. It might just be that the 4471 /* FIXME: It's not necessarily a bug. It might just be that the
4809 GCPRO is unnecessary or should release the object sooner. */ 4472 GCPRO is unnecessary or should release the object sooner. */
4810 abort (); 4473 emacs_abort ();
4811} 4474}
4812 4475
4813#elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 4476#elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
@@ -4892,7 +4555,7 @@ mark_stack (void)
4892 /* jmp_buf may not be aligned enough on darwin-ppc64 */ 4555 /* jmp_buf may not be aligned enough on darwin-ppc64 */
4893 union aligned_jmpbuf { 4556 union aligned_jmpbuf {
4894 Lisp_Object o; 4557 Lisp_Object o;
4895 jmp_buf j; 4558 sys_jmp_buf j;
4896 } j; 4559 } j;
4897 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base; 4560 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base;
4898#endif 4561#endif
@@ -4928,7 +4591,7 @@ mark_stack (void)
4928 } 4591 }
4929#endif /* GC_SETJMP_WORKS */ 4592#endif /* GC_SETJMP_WORKS */
4930 4593
4931 setjmp (j.j); 4594 sys_setjmp (j.j);
4932 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4595 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4933#endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4596#endif /* not GC_SAVE_REGISTERS_ON_STACK */
4934#endif /* not HAVE___BUILTIN_UNWIND_INIT */ 4597#endif /* not HAVE___BUILTIN_UNWIND_INIT */
@@ -4978,7 +4641,8 @@ valid_pointer_p (void *p)
4978#endif 4641#endif
4979} 4642}
4980 4643
4981/* Return 1 if OBJ is a valid lisp object. 4644/* Return 2 if OBJ is a killed or special buffer object.
4645 Return 1 if OBJ is a valid lisp object.
4982 Return 0 if OBJ is NOT a valid lisp object. 4646 Return 0 if OBJ is NOT a valid lisp object.
4983 Return -1 if we cannot validate OBJ. 4647 Return -1 if we cannot validate OBJ.
4984 This function can be quite slow, 4648 This function can be quite slow,
@@ -4999,6 +4663,9 @@ valid_lisp_object_p (Lisp_Object obj)
4999 if (PURE_POINTER_P (p)) 4663 if (PURE_POINTER_P (p))
5000 return 1; 4664 return 1;
5001 4665
4666 if (p == &buffer_defaults || p == &buffer_local_symbols)
4667 return 2;
4668
5002#if !GC_MARK_STACK 4669#if !GC_MARK_STACK
5003 return valid_pointer_p (p); 4670 return valid_pointer_p (p);
5004#else 4671#else
@@ -5024,7 +4691,7 @@ valid_lisp_object_p (Lisp_Object obj)
5024 return 0; 4691 return 0;
5025 4692
5026 case MEM_TYPE_BUFFER: 4693 case MEM_TYPE_BUFFER:
5027 return live_buffer_p (m, p); 4694 return live_buffer_p (m, p) ? 1 : 2;
5028 4695
5029 case MEM_TYPE_CONS: 4696 case MEM_TYPE_CONS:
5030 return live_cons_p (m, p); 4697 return live_cons_p (m, p);
@@ -5348,7 +5015,7 @@ staticpro (Lisp_Object *varaddress)
5348{ 5015{
5349 staticvec[staticidx++] = varaddress; 5016 staticvec[staticidx++] = varaddress;
5350 if (staticidx >= NSTATICS) 5017 if (staticidx >= NSTATICS)
5351 abort (); 5018 emacs_abort ();
5352} 5019}
5353 5020
5354 5021
@@ -5403,7 +5070,7 @@ See Info node `(elisp)Garbage Collection'. */)
5403 Lisp_Object retval = Qnil; 5070 Lisp_Object retval = Qnil;
5404 5071
5405 if (abort_on_gc) 5072 if (abort_on_gc)
5406 abort (); 5073 emacs_abort ();
5407 5074
5408 /* Can't GC if pure storage overflowed because we can't determine 5075 /* Can't GC if pure storage overflowed because we can't determine
5409 if something is a pure object or not. */ 5076 if something is a pure object or not. */
@@ -5466,6 +5133,9 @@ See Info node `(elisp)Garbage Collection'. */)
5466 5133
5467 /* Mark all the special slots that serve as the roots of accessibility. */ 5134 /* Mark all the special slots that serve as the roots of accessibility. */
5468 5135
5136 mark_buffer (&buffer_defaults);
5137 mark_buffer (&buffer_local_symbols);
5138
5469 for (i = 0; i < staticidx; i++) 5139 for (i = 0; i < staticidx; i++)
5470 mark_object (*staticvec[i]); 5140 mark_object (*staticvec[i]);
5471 5141
@@ -5478,10 +5148,7 @@ See Info node `(elisp)Garbage Collection'. */)
5478 mark_kboards (); 5148 mark_kboards ();
5479 5149
5480#ifdef USE_GTK 5150#ifdef USE_GTK
5481 { 5151 xg_mark_data ();
5482 extern void xg_mark_data (void);
5483 xg_mark_data ();
5484 }
5485#endif 5152#endif
5486 5153
5487#if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \ 5154#if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \
@@ -5853,6 +5520,32 @@ mark_buffer (struct buffer *buffer)
5853 mark_buffer (buffer->base_buffer); 5520 mark_buffer (buffer->base_buffer);
5854} 5521}
5855 5522
5523/* Remove killed buffers or items whose car is a killed buffer from
5524 LIST, and mark other items. Return changed LIST, which is marked. */
5525
5526static Lisp_Object
5527mark_discard_killed_buffers (Lisp_Object list)
5528{
5529 Lisp_Object tail, *prev = &list;
5530
5531 for (tail = list; CONSP (tail) && !CONS_MARKED_P (XCONS (tail));
5532 tail = XCDR (tail))
5533 {
5534 Lisp_Object tem = XCAR (tail);
5535 if (CONSP (tem))
5536 tem = XCAR (tem);
5537 if (BUFFERP (tem) && !BUFFER_LIVE_P (XBUFFER (tem)))
5538 *prev = XCDR (tail);
5539 else
5540 {
5541 CONS_MARK (XCONS (tail));
5542 mark_object (XCAR (tail));
5543 prev = &XCDR_AS_LVALUE (tail);
5544 }
5545 }
5546 return list;
5547}
5548
5856/* Determine type of generic Lisp_Object and mark it accordingly. */ 5549/* Determine type of generic Lisp_Object and mark it accordingly. */
5857 5550
5858void 5551void
@@ -5887,7 +5580,7 @@ mark_object (Lisp_Object arg)
5887 do { \ 5580 do { \
5888 m = mem_find (po); \ 5581 m = mem_find (po); \
5889 if (m == MEM_NIL) \ 5582 if (m == MEM_NIL) \
5890 abort (); \ 5583 emacs_abort (); \
5891 } while (0) 5584 } while (0)
5892 5585
5893 /* Check that the object pointed to by PO is live, using predicate 5586 /* Check that the object pointed to by PO is live, using predicate
@@ -5895,7 +5588,7 @@ mark_object (Lisp_Object arg)
5895#define CHECK_LIVE(LIVEP) \ 5588#define CHECK_LIVE(LIVEP) \
5896 do { \ 5589 do { \
5897 if (!LIVEP (m, po)) \ 5590 if (!LIVEP (m, po)) \
5898 abort (); \ 5591 emacs_abort (); \
5899 } while (0) 5592 } while (0)
5900 5593
5901 /* Check both of the above conditions. */ 5594 /* Check both of the above conditions. */
@@ -5940,10 +5633,8 @@ mark_object (Lisp_Object arg)
5940 5633
5941#ifdef GC_CHECK_MARKED_OBJECTS 5634#ifdef GC_CHECK_MARKED_OBJECTS
5942 m = mem_find (po); 5635 m = mem_find (po);
5943 if (m == MEM_NIL && !SUBRP (obj) 5636 if (m == MEM_NIL && !SUBRP (obj))
5944 && po != &buffer_defaults 5637 emacs_abort ();
5945 && po != &buffer_local_symbols)
5946 abort ();
5947#endif /* GC_CHECK_MARKED_OBJECTS */ 5638#endif /* GC_CHECK_MARKED_OBJECTS */
5948 5639
5949 if (ptr->header.size & PSEUDOVECTOR_FLAG) 5640 if (ptr->header.size & PSEUDOVECTOR_FLAG)
@@ -5959,15 +5650,14 @@ mark_object (Lisp_Object arg)
5959 { 5650 {
5960 case PVEC_BUFFER: 5651 case PVEC_BUFFER:
5961#ifdef GC_CHECK_MARKED_OBJECTS 5652#ifdef GC_CHECK_MARKED_OBJECTS
5962 if (po != &buffer_defaults && po != &buffer_local_symbols) 5653 {
5963 { 5654 struct buffer *b;
5964 struct buffer *b; 5655 FOR_EACH_BUFFER (b)
5965 FOR_EACH_BUFFER (b) 5656 if (b == po)
5966 if (b == po) 5657 break;
5967 break; 5658 if (b == NULL)
5968 if (b == NULL) 5659 emacs_abort ();
5969 abort (); 5660 }
5970 }
5971#endif /* GC_CHECK_MARKED_OBJECTS */ 5661#endif /* GC_CHECK_MARKED_OBJECTS */
5972 mark_buffer ((struct buffer *) ptr); 5662 mark_buffer ((struct buffer *) ptr);
5973 break; 5663 break;
@@ -5992,22 +5682,31 @@ mark_object (Lisp_Object arg)
5992 break; 5682 break;
5993 5683
5994 case PVEC_FRAME: 5684 case PVEC_FRAME:
5995 { 5685 mark_vectorlike (ptr);
5996 mark_vectorlike (ptr); 5686 mark_face_cache (((struct frame *) ptr)->face_cache);
5997 mark_face_cache (((struct frame *) ptr)->face_cache);
5998 }
5999 break; 5687 break;
6000 5688
6001 case PVEC_WINDOW: 5689 case PVEC_WINDOW:
6002 { 5690 {
6003 struct window *w = (struct window *) ptr; 5691 struct window *w = (struct window *) ptr;
5692 bool leaf = NILP (w->hchild) && NILP (w->vchild);
5693
5694 /* For live windows, Lisp code filters out killed buffers
5695 from both buffer lists. For dead windows, we do it here
5696 in attempt to help GC to reclaim killed buffers faster. */
5697 if (leaf && NILP (w->buffer))
5698 {
5699 wset_prev_buffers
5700 (w, mark_discard_killed_buffers (w->prev_buffers));
5701 wset_next_buffers
5702 (w, mark_discard_killed_buffers (w->next_buffers));
5703 }
6004 5704
6005 mark_vectorlike (ptr); 5705 mark_vectorlike (ptr);
6006 /* Mark glyphs for leaf windows. Marking window 5706 /* Mark glyphs for leaf windows. Marking window
6007 matrices is sufficient because frame matrices 5707 matrices is sufficient because frame matrices
6008 use the same glyph memory. */ 5708 use the same glyph memory. */
6009 if (NILP (w->hchild) && NILP (w->vchild) 5709 if (leaf && w->current_matrix)
6010 && w->current_matrix)
6011 { 5710 {
6012 mark_glyph_matrix (w->current_matrix); 5711 mark_glyph_matrix (w->current_matrix);
6013 mark_glyph_matrix (w->desired_matrix); 5712 mark_glyph_matrix (w->desired_matrix);
@@ -6042,7 +5741,7 @@ mark_object (Lisp_Object arg)
6042 break; 5741 break;
6043 5742
6044 case PVEC_FREE: 5743 case PVEC_FREE:
6045 abort (); 5744 emacs_abort ();
6046 5745
6047 default: 5746 default:
6048 mark_vectorlike (ptr); 5747 mark_vectorlike (ptr);
@@ -6074,10 +5773,14 @@ mark_object (Lisp_Object arg)
6074 case SYMBOL_LOCALIZED: 5773 case SYMBOL_LOCALIZED:
6075 { 5774 {
6076 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr); 5775 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr);
6077 /* If the value is forwarded to a buffer or keyboard field, 5776 Lisp_Object where = blv->where;
6078 these are marked when we see the corresponding object. 5777 /* If the value is set up for a killed buffer or deleted
6079 And if it's forwarded to a C variable, either it's not 5778 frame, restore it's global binding. If the value is
6080 a Lisp_Object var, or it's staticpro'd already. */ 5779 forwarded to a C variable, either it's not a Lisp_Object
5780 var, or it's staticpro'd already. */
5781 if ((BUFFERP (where) && !BUFFER_LIVE_P (XBUFFER (where)))
5782 || (FRAMEP (where) && !FRAME_LIVE_P (XFRAME (where))))
5783 swap_in_global_binding (ptr);
6081 mark_object (blv->where); 5784 mark_object (blv->where);
6082 mark_object (blv->valcell); 5785 mark_object (blv->valcell);
6083 mark_object (blv->defcell); 5786 mark_object (blv->defcell);
@@ -6089,7 +5792,7 @@ mark_object (Lisp_Object arg)
6089 And if it's forwarded to a C variable, either it's not 5792 And if it's forwarded to a C variable, either it's not
6090 a Lisp_Object var, or it's staticpro'd already. */ 5793 a Lisp_Object var, or it's staticpro'd already. */
6091 break; 5794 break;
6092 default: abort (); 5795 default: emacs_abort ();
6093 } 5796 }
6094 if (!PURE_POINTER_P (XSTRING (ptr->name))) 5797 if (!PURE_POINTER_P (XSTRING (ptr->name)))
6095 MARK_STRING (XSTRING (ptr->name)); 5798 MARK_STRING (XSTRING (ptr->name));
@@ -6143,7 +5846,7 @@ mark_object (Lisp_Object arg)
6143 break; 5846 break;
6144 5847
6145 default: 5848 default:
6146 abort (); 5849 emacs_abort ();
6147 } 5850 }
6148 break; 5851 break;
6149 5852
@@ -6165,7 +5868,7 @@ mark_object (Lisp_Object arg)
6165 obj = ptr->u.cdr; 5868 obj = ptr->u.cdr;
6166 cdr_count++; 5869 cdr_count++;
6167 if (cdr_count == mark_object_loop_halt) 5870 if (cdr_count == mark_object_loop_halt)
6168 abort (); 5871 emacs_abort ();
6169 goto loop; 5872 goto loop;
6170 } 5873 }
6171 5874
@@ -6178,7 +5881,7 @@ mark_object (Lisp_Object arg)
6178 break; 5881 break;
6179 5882
6180 default: 5883 default:
6181 abort (); 5884 emacs_abort ();
6182 } 5885 }
6183 5886
6184#undef CHECK_LIVE 5887#undef CHECK_LIVE
@@ -6247,7 +5950,7 @@ survives_gc_p (Lisp_Object obj)
6247 break; 5950 break;
6248 5951
6249 default: 5952 default:
6250 abort (); 5953 emacs_abort ();
6251 } 5954 }
6252 5955
6253 return survives_p || PURE_POINTER_P ((void *) XPNTR (obj)); 5956 return survives_p || PURE_POINTER_P ((void *) XPNTR (obj));
@@ -6685,21 +6388,14 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6685 6388
6686#ifdef ENABLE_CHECKING 6389#ifdef ENABLE_CHECKING
6687 6390
6688# include <execinfo.h>
6689
6690bool suppress_checking; 6391bool suppress_checking;
6691 6392
6692void 6393void
6693die (const char *msg, const char *file, int line) 6394die (const char *msg, const char *file, int line)
6694{ 6395{
6695 enum { NPOINTERS_MAX = 500 };
6696 void *buffer[NPOINTERS_MAX];
6697 int npointers;
6698 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", 6396 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6699 file, line, msg); 6397 file, line, msg);
6700 npointers = backtrace (buffer, NPOINTERS_MAX); 6398 fatal_error_backtrace (SIGABRT, INT_MAX);
6701 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
6702 abort ();
6703} 6399}
6704#endif 6400#endif
6705 6401
@@ -6725,12 +6421,6 @@ init_alloc_once (void)
6725 init_strings (); 6421 init_strings ();
6726 init_vectors (); 6422 init_vectors ();
6727 6423
6728#ifdef REL_ALLOC
6729 malloc_hysteresis = 32;
6730#else
6731 malloc_hysteresis = 0;
6732#endif
6733
6734 refill_memory_reserve (); 6424 refill_memory_reserve ();
6735 gc_cons_threshold = GC_DEFAULT_THRESHOLD; 6425 gc_cons_threshold = GC_DEFAULT_THRESHOLD;
6736} 6426}
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
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <signal.h>
21#include <stdio.h> 20#include <stdio.h>
22#include <setjmp.h> 21
23#include "lisp.h" 22#include "lisp.h"
24#include "syssignal.h" 23#include "syssignal.h"
25#include "systime.h" 24#include "systime.h"
@@ -41,7 +40,7 @@ static struct atimer *stopped_atimers;
41 40
42static struct atimer *atimers; 41static struct atimer *atimers;
43 42
44/* Non-zero means alarm_signal_handler has found ripe timers but 43/* Non-zero means alarm signal handler has found ripe timers but
45 interrupt_input_blocked was non-zero. In this case, timer 44 interrupt_input_blocked was non-zero. In this case, timer
46 functions are not called until the next UNBLOCK_INPUT because timer 45 functions are not called until the next UNBLOCK_INPUT because timer
47 functions are expected to call X, and X cannot be assumed to be 46 functions are expected to call X, and X cannot be assumed to be
@@ -51,8 +50,24 @@ int pending_atimers;
51 50
52/* Block/unblock SIGALRM. */ 51/* Block/unblock SIGALRM. */
53 52
54#define BLOCK_ATIMERS sigblock (sigmask (SIGALRM)) 53static void
55#define UNBLOCK_ATIMERS sigunblock (sigmask (SIGALRM)) 54sigmask_atimers (int how)
55{
56 sigset_t blocked;
57 sigemptyset (&blocked);
58 sigaddset (&blocked, SIGALRM);
59 pthread_sigmask (how, &blocked, 0);
60}
61static void
62block_atimers (void)
63{
64 sigmask_atimers (SIG_BLOCK);
65}
66static void
67unblock_atimers (void)
68{
69 sigmask_atimers (SIG_UNBLOCK);
70}
56 71
57/* Function prototypes. */ 72/* Function prototypes. */
58 73
@@ -60,8 +75,6 @@ static void set_alarm (void);
60static void schedule_atimer (struct atimer *); 75static void schedule_atimer (struct atimer *);
61static struct atimer *append_atimer_lists (struct atimer *, 76static struct atimer *append_atimer_lists (struct atimer *,
62 struct atimer *); 77 struct atimer *);
63static void alarm_signal_handler (int signo);
64
65 78
66/* Start a new atimer of type TYPE. TIME specifies when the timer is 79/* Start a new atimer of type TYPE. TIME specifies when the timer is
67 ripe. FN is the function to call when the timer fires. 80 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,
111 t->fn = fn; 124 t->fn = fn;
112 t->client_data = client_data; 125 t->client_data = client_data;
113 126
114 BLOCK_ATIMERS; 127 block_atimers ();
115 128
116 /* Compute the timer's expiration time. */ 129 /* Compute the timer's expiration time. */
117 switch (type) 130 switch (type)
@@ -132,7 +145,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn,
132 145
133 /* Insert the timer in the list of active atimers. */ 146 /* Insert the timer in the list of active atimers. */
134 schedule_atimer (t); 147 schedule_atimer (t);
135 UNBLOCK_ATIMERS; 148 unblock_atimers ();
136 149
137 /* Arrange for a SIGALRM at the time the next atimer is ripe. */ 150 /* Arrange for a SIGALRM at the time the next atimer is ripe. */
138 set_alarm (); 151 set_alarm ();
@@ -148,7 +161,7 @@ cancel_atimer (struct atimer *timer)
148{ 161{
149 int i; 162 int i;
150 163
151 BLOCK_ATIMERS; 164 block_atimers ();
152 165
153 for (i = 0; i < 2; ++i) 166 for (i = 0; i < 2; ++i)
154 { 167 {
@@ -175,7 +188,7 @@ cancel_atimer (struct atimer *timer)
175 } 188 }
176 } 189 }
177 190
178 UNBLOCK_ATIMERS; 191 unblock_atimers ();
179} 192}
180 193
181 194
@@ -206,7 +219,7 @@ append_atimer_lists (struct atimer *list_1, struct atimer *list_2)
206void 219void
207stop_other_atimers (struct atimer *t) 220stop_other_atimers (struct atimer *t)
208{ 221{
209 BLOCK_ATIMERS; 222 block_atimers ();
210 223
211 if (t) 224 if (t)
212 { 225 {
@@ -231,7 +244,7 @@ stop_other_atimers (struct atimer *t)
231 244
232 stopped_atimers = append_atimer_lists (atimers, stopped_atimers); 245 stopped_atimers = append_atimer_lists (atimers, stopped_atimers);
233 atimers = t; 246 atimers = t;
234 UNBLOCK_ATIMERS; 247 unblock_atimers ();
235} 248}
236 249
237 250
@@ -246,7 +259,7 @@ run_all_atimers (void)
246 struct atimer *t = atimers; 259 struct atimer *t = atimers;
247 struct atimer *next; 260 struct atimer *next;
248 261
249 BLOCK_ATIMERS; 262 block_atimers ();
250 atimers = stopped_atimers; 263 atimers = stopped_atimers;
251 stopped_atimers = NULL; 264 stopped_atimers = NULL;
252 265
@@ -257,7 +270,7 @@ run_all_atimers (void)
257 t = next; 270 t = next;
258 } 271 }
259 272
260 UNBLOCK_ATIMERS; 273 unblock_atimers ();
261 } 274 }
262} 275}
263 276
@@ -356,7 +369,6 @@ run_timers (void)
356 if (! atimers) 369 if (! atimers)
357 pending_atimers = 0; 370 pending_atimers = 0;
358 371
359#ifdef SYNC_INPUT
360 if (pending_atimers) 372 if (pending_atimers)
361 pending_signals = 1; 373 pending_signals = 1;
362 else 374 else
@@ -364,42 +376,36 @@ run_timers (void)
364 pending_signals = interrupt_input_pending; 376 pending_signals = interrupt_input_pending;
365 set_alarm (); 377 set_alarm ();
366 } 378 }
367#else
368 if (! pending_atimers)
369 set_alarm ();
370#endif
371} 379}
372 380
373 381
374/* Signal handler for SIGALRM. SIGNO is the signal number, i.e. 382/* Signal handler for SIGALRM. SIGNO is the signal number, i.e.
375 SIGALRM. */ 383 SIGALRM. */
376 384
377void 385static void
378alarm_signal_handler (int signo) 386handle_alarm_signal (int sig)
379{ 387{
380#ifndef SYNC_INPUT
381 SIGNAL_THREAD_CHECK (signo);
382#endif
383
384 pending_atimers = 1; 388 pending_atimers = 1;
385#ifdef SYNC_INPUT
386 pending_signals = 1; 389 pending_signals = 1;
387#else 390}
388 run_timers (); 391
389#endif 392static void
393deliver_alarm_signal (int sig)
394{
395 handle_on_main_thread (sig, handle_alarm_signal);
390} 396}
391 397
392 398
393/* Call alarm_signal_handler for pending timers. */ 399/* Call alarm signal handler for pending timers. */
394 400
395void 401void
396do_pending_atimers (void) 402do_pending_atimers (void)
397{ 403{
398 if (pending_atimers) 404 if (pending_atimers)
399 { 405 {
400 BLOCK_ATIMERS; 406 block_atimers ();
401 run_timers (); 407 run_timers ();
402 UNBLOCK_ATIMERS; 408 unblock_atimers ();
403 } 409 }
404} 410}
405 411
@@ -412,7 +418,9 @@ turn_on_atimers (bool on)
412{ 418{
413 if (on) 419 if (on)
414 { 420 {
415 signal (SIGALRM, alarm_signal_handler); 421 struct sigaction action;
422 emacs_sigaction_init (&action, deliver_alarm_signal);
423 sigaction (SIGALRM, &action, 0);
416 set_alarm (); 424 set_alarm ();
417 } 425 }
418 else 426 else
@@ -423,8 +431,10 @@ turn_on_atimers (bool on)
423void 431void
424init_atimer (void) 432init_atimer (void)
425{ 433{
434 struct sigaction action;
426 free_atimers = stopped_atimers = atimers = NULL; 435 free_atimers = stopped_atimers = atimers = NULL;
427 pending_atimers = 0; 436 pending_atimers = 0;
428 /* pending_signals is initialized in init_keyboard.*/ 437 /* pending_signals is initialized in init_keyboard.*/
429 signal (SIGALRM, alarm_signal_handler); 438 emacs_sigaction_init (&action, deliver_alarm_signal);
439 sigaction (SIGALRM, &action, 0);
430} 440}
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/>. */
56 56
57#include <config.h> 57#include <config.h>
58#include <stdio.h> 58#include <stdio.h>
59#include <setjmp.h>
60 59
61#include "lisp.h" 60#include "lisp.h"
62#include "character.h" 61#include "character.h"
@@ -105,7 +104,7 @@ bidi_get_type (int ch, bidi_dir_t override)
105 if (ch == BIDI_EOB) 104 if (ch == BIDI_EOB)
106 return NEUTRAL_B; 105 return NEUTRAL_B;
107 if (ch < 0 || ch > MAX_CHAR) 106 if (ch < 0 || ch > MAX_CHAR)
108 abort (); 107 emacs_abort ();
109 108
110 default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); 109 default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch));
111 /* Every valid character code, even those that are unassigned by the 110 /* Every valid character code, even those that are unassigned by the
@@ -113,7 +112,7 @@ bidi_get_type (int ch, bidi_dir_t override)
113 DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT 112 DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT
114 (= zero) code from CHAR_TABLE_REF, that's a bug. */ 113 (= zero) code from CHAR_TABLE_REF, that's a bug. */
115 if (default_type == UNKNOWN_BT) 114 if (default_type == UNKNOWN_BT)
116 abort (); 115 emacs_abort ();
117 116
118 if (override == NEUTRAL_DIR) 117 if (override == NEUTRAL_DIR)
119 return default_type; 118 return default_type;
@@ -141,7 +140,7 @@ bidi_get_type (int ch, bidi_dir_t override)
141 else if (override == R2L) 140 else if (override == R2L)
142 return STRONG_R; 141 return STRONG_R;
143 else 142 else
144 abort (); /* can't happen: handled above */ 143 emacs_abort (); /* can't happen: handled above */
145 } 144 }
146 } 145 }
147} 146}
@@ -183,7 +182,7 @@ bidi_get_category (bidi_type_t type)
183 case NEUTRAL_ON: 182 case NEUTRAL_ON:
184 return NEUTRAL; 183 return NEUTRAL;
185 default: 184 default:
186 abort (); 185 emacs_abort ();
187 } 186 }
188} 187}
189 188
@@ -199,7 +198,7 @@ bidi_mirror_char (int c)
199 if (c == BIDI_EOB) 198 if (c == BIDI_EOB)
200 return c; 199 return c;
201 if (c < 0 || c > MAX_CHAR) 200 if (c < 0 || c > MAX_CHAR)
202 abort (); 201 emacs_abort ();
203 202
204 val = CHAR_TABLE_REF (bidi_mirror_table, c); 203 val = CHAR_TABLE_REF (bidi_mirror_table, c);
205 if (INTEGERP (val)) 204 if (INTEGERP (val))
@@ -215,7 +214,7 @@ bidi_mirror_char (int c)
215 /* Minimal test we must do in optimized builds, to prevent weird 214 /* Minimal test we must do in optimized builds, to prevent weird
216 crashes further down the road. */ 215 crashes further down the road. */
217 if (v < 0 || v > MAX_CHAR) 216 if (v < 0 || v > MAX_CHAR)
218 abort (); 217 emacs_abort ();
219 218
220 return v; 219 return v;
221 } 220 }
@@ -373,7 +372,7 @@ bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it)
373 int current_scan_dir = bidi_it->scan_dir; 372 int current_scan_dir = bidi_it->scan_dir;
374 373
375 if (idx < bidi_cache_start || idx >= bidi_cache_idx) 374 if (idx < bidi_cache_start || idx >= bidi_cache_idx)
376 abort (); 375 emacs_abort ();
377 376
378 bidi_copy_it (bidi_it, &bidi_cache[idx]); 377 bidi_copy_it (bidi_it, &bidi_cache[idx]);
379 bidi_it->scan_dir = current_scan_dir; 378 bidi_it->scan_dir = current_scan_dir;
@@ -518,7 +517,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
518 517
519 /* We should never cache on backward scans. */ 518 /* We should never cache on backward scans. */
520 if (bidi_it->scan_dir == -1) 519 if (bidi_it->scan_dir == -1)
521 abort (); 520 emacs_abort ();
522 idx = bidi_cache_search (bidi_it->charpos, -1, 1); 521 idx = bidi_cache_search (bidi_it->charpos, -1, 1);
523 522
524 if (idx < 0) 523 if (idx < 0)
@@ -537,7 +536,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
537 idx = bidi_cache_start; 536 idx = bidi_cache_start;
538 } 537 }
539 if (bidi_it->nchars <= 0) 538 if (bidi_it->nchars <= 0)
540 abort (); 539 emacs_abort ();
541 bidi_copy_it (&bidi_cache[idx], bidi_it); 540 bidi_copy_it (&bidi_cache[idx], bidi_it);
542 if (!resolved) 541 if (!resolved)
543 bidi_cache[idx].resolved_level = -1; 542 bidi_cache[idx].resolved_level = -1;
@@ -592,7 +591,7 @@ static inline int
592bidi_peek_at_next_level (struct bidi_it *bidi_it) 591bidi_peek_at_next_level (struct bidi_it *bidi_it)
593{ 592{
594 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1) 593 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1)
595 abort (); 594 emacs_abort ();
596 return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level; 595 return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level;
597} 596}
598 597
@@ -612,7 +611,7 @@ bidi_push_it (struct bidi_it *bidi_it)
612 /* Save the current iterator state in its entirety after the last 611 /* Save the current iterator state in its entirety after the last
613 used cache slot. */ 612 used cache slot. */
614 bidi_cache_ensure_space (bidi_cache_idx); 613 bidi_cache_ensure_space (bidi_cache_idx);
615 memcpy (&bidi_cache[bidi_cache_idx++], bidi_it, sizeof (struct bidi_it)); 614 bidi_cache[bidi_cache_idx++] = *bidi_it;
616 615
617 /* Push the current cache start onto the stack. */ 616 /* Push the current cache start onto the stack. */
618 eassert (bidi_cache_sp < IT_STACK_SIZE); 617 eassert (bidi_cache_sp < IT_STACK_SIZE);
@@ -629,18 +628,18 @@ void
629bidi_pop_it (struct bidi_it *bidi_it) 628bidi_pop_it (struct bidi_it *bidi_it)
630{ 629{
631 if (bidi_cache_start <= 0) 630 if (bidi_cache_start <= 0)
632 abort (); 631 emacs_abort ();
633 632
634 /* Reset the next free cache slot index to what it was before the 633 /* Reset the next free cache slot index to what it was before the
635 call to bidi_push_it. */ 634 call to bidi_push_it. */
636 bidi_cache_idx = bidi_cache_start - 1; 635 bidi_cache_idx = bidi_cache_start - 1;
637 636
638 /* Restore the bidi iterator state saved in the cache. */ 637 /* Restore the bidi iterator state saved in the cache. */
639 memcpy (bidi_it, &bidi_cache[bidi_cache_idx], sizeof (struct bidi_it)); 638 *bidi_it = bidi_cache[bidi_cache_idx];
640 639
641 /* Pop the previous cache start from the stack. */ 640 /* Pop the previous cache start from the stack. */
642 if (bidi_cache_sp <= 0) 641 if (bidi_cache_sp <= 0)
643 abort (); 642 emacs_abort ();
644 bidi_cache_start = bidi_cache_start_stack[--bidi_cache_sp]; 643 bidi_cache_start = bidi_cache_start_stack[--bidi_cache_sp];
645 644
646 /* Invalidate the last-used cache slot data. */ 645 /* Invalidate the last-used cache slot data. */
@@ -762,12 +761,12 @@ bidi_initialize (void)
762{ 761{
763 bidi_type_table = uniprop_table (intern ("bidi-class")); 762 bidi_type_table = uniprop_table (intern ("bidi-class"));
764 if (NILP (bidi_type_table)) 763 if (NILP (bidi_type_table))
765 abort (); 764 emacs_abort ();
766 staticpro (&bidi_type_table); 765 staticpro (&bidi_type_table);
767 766
768 bidi_mirror_table = uniprop_table (intern ("mirroring")); 767 bidi_mirror_table = uniprop_table (intern ("mirroring"));
769 if (NILP (bidi_mirror_table)) 768 if (NILP (bidi_mirror_table))
770 abort (); 769 emacs_abort ();
771 staticpro (&bidi_mirror_table); 770 staticpro (&bidi_mirror_table);
772 771
773 Qparagraph_start = intern ("paragraph-start"); 772 Qparagraph_start = intern ("paragraph-start");
@@ -885,7 +884,7 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
885 else 884 else
886 { 885 {
887 if (!CHAR_HEAD_P (*p)) 886 if (!CHAR_HEAD_P (*p))
888 abort (); 887 emacs_abort ();
889 888
890 while (pos < end) 889 while (pos < end)
891 { 890 {
@@ -965,7 +964,7 @@ bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos,
965 /* We don't expect to find ourselves in the middle of a display 964 /* We don't expect to find ourselves in the middle of a display
966 property. Hopefully, it will never be needed. */ 965 property. Hopefully, it will never be needed. */
967 if (charpos > *disp_pos) 966 if (charpos > *disp_pos)
968 abort (); 967 emacs_abort ();
969 /* Text covered by `display' properties and overlays with 968 /* Text covered by `display' properties and overlays with
970 display properties or display strings is handled as a single 969 display properties or display strings is handled as a single
971 character that represents the entire run of characters 970 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,
995 } 994 }
996 *nchars = disp_end_pos - *disp_pos; 995 *nchars = disp_end_pos - *disp_pos;
997 if (*nchars <= 0) 996 if (*nchars <= 0)
998 abort (); 997 emacs_abort ();
999 if (string->s) 998 if (string->s)
1000 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos, 999 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos,
1001 disp_end_pos, string->unibyte); 1000 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)
1160 dir = L2R; 1159 dir = L2R;
1161 /* We should never be called at EOB or before BEGV. */ 1160 /* We should never be called at EOB or before BEGV. */
1162 else if (bidi_it->charpos >= end || bytepos < begbyte) 1161 else if (bidi_it->charpos >= end || bytepos < begbyte)
1163 abort (); 1162 emacs_abort ();
1164 1163
1165 if (dir == L2R) 1164 if (dir == L2R)
1166 { 1165 {
@@ -1298,7 +1297,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p)
1298 && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR); 1297 && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR);
1299 } 1298 }
1300 else 1299 else
1301 abort (); 1300 emacs_abort ();
1302 1301
1303 /* Contrary to UAX#9 clause P3, we only default the paragraph 1302 /* Contrary to UAX#9 clause P3, we only default the paragraph
1304 direction to L2R if we have no previous usable paragraph 1303 direction to L2R if we have no previous usable paragraph
@@ -1325,7 +1324,7 @@ bidi_explicit_dir_char (int ch)
1325 bidi_type_t ch_type; 1324 bidi_type_t ch_type;
1326 1325
1327 if (!bidi_initialized) 1326 if (!bidi_initialized)
1328 abort (); 1327 emacs_abort ();
1329 ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); 1328 ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch));
1330 return (ch_type == LRE || ch_type == LRO 1329 return (ch_type == LRE || ch_type == LRO
1331 || ch_type == RLE || ch_type == RLO 1330 || ch_type == RLE || ch_type == RLO
@@ -1378,10 +1377,10 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1378 /* Advance to the next character, skipping characters covered by 1377 /* Advance to the next character, skipping characters covered by
1379 display strings (nchars > 1). */ 1378 display strings (nchars > 1). */
1380 if (bidi_it->nchars <= 0) 1379 if (bidi_it->nchars <= 0)
1381 abort (); 1380 emacs_abort ();
1382 bidi_it->charpos += bidi_it->nchars; 1381 bidi_it->charpos += bidi_it->nchars;
1383 if (bidi_it->ch_len == 0) 1382 if (bidi_it->ch_len == 0)
1384 abort (); 1383 emacs_abort ();
1385 bidi_it->bytepos += bidi_it->ch_len; 1384 bidi_it->bytepos += bidi_it->ch_len;
1386 } 1385 }
1387 1386
@@ -1581,7 +1580,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
1581 } 1580 }
1582 1581
1583 if (bidi_it->nchars <= 0) 1582 if (bidi_it->nchars <= 0)
1584 abort (); 1583 emacs_abort ();
1585 if (level == prev_level) /* empty embedding */ 1584 if (level == prev_level) /* empty embedding */
1586 saved_it.ignore_bn_limit = bidi_it->charpos + bidi_it->nchars; 1585 saved_it.ignore_bn_limit = bidi_it->charpos + bidi_it->nchars;
1587 else /* this embedding is non-empty */ 1586 else /* this embedding is non-empty */
@@ -1644,7 +1643,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1644 || type == RLE 1643 || type == RLE
1645 || type == RLO 1644 || type == RLO
1646 || type == PDF) 1645 || type == PDF)
1647 abort (); 1646 emacs_abort ();
1648 1647
1649 if (new_level != prev_level 1648 if (new_level != prev_level
1650 || bidi_it->type == NEUTRAL_B) 1649 || bidi_it->type == NEUTRAL_B)
@@ -1685,7 +1684,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1685 else if (bidi_it->sor == L2R) 1684 else if (bidi_it->sor == L2R)
1686 type = STRONG_L; 1685 type = STRONG_L;
1687 else /* shouldn't happen! */ 1686 else /* shouldn't happen! */
1688 abort (); 1687 emacs_abort ();
1689 } 1688 }
1690 if (type == WEAK_EN /* W2 */ 1689 if (type == WEAK_EN /* W2 */
1691 && bidi_it->last_strong.type_after_w1 == STRONG_AL) 1690 && bidi_it->last_strong.type_after_w1 == STRONG_AL)
@@ -1767,7 +1766,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1767 : bidi_it->string.s); 1766 : bidi_it->string.s);
1768 1767
1769 if (bidi_it->nchars <= 0) 1768 if (bidi_it->nchars <= 0)
1770 abort (); 1769 emacs_abort ();
1771 next_char 1770 next_char
1772 = (bidi_it->charpos + bidi_it->nchars >= eob 1771 = (bidi_it->charpos + bidi_it->nchars >= eob
1773 ? BIDI_EOB 1772 ? BIDI_EOB
@@ -1875,7 +1874,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1875 || type == NEUTRAL_S 1874 || type == NEUTRAL_S
1876 || type == NEUTRAL_WS 1875 || type == NEUTRAL_WS
1877 || type == NEUTRAL_ON)) 1876 || type == NEUTRAL_ON))
1878 abort (); 1877 emacs_abort ();
1879 1878
1880 if ((type != NEUTRAL_B /* Don't risk entering the long loop below if 1879 if ((type != NEUTRAL_B /* Don't risk entering the long loop below if
1881 we are already at paragraph end. */ 1880 we are already at paragraph end. */
@@ -1930,7 +1929,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1930 bidi_type_t next_type; 1929 bidi_type_t next_type;
1931 1930
1932 if (bidi_it->scan_dir == -1) 1931 if (bidi_it->scan_dir == -1)
1933 abort (); 1932 emacs_abort ();
1934 1933
1935 bidi_copy_it (&saved_it, bidi_it); 1934 bidi_copy_it (&saved_it, bidi_it);
1936 /* Scan the text forward until we find the first non-neutral 1935 /* Scan the text forward until we find the first non-neutral
@@ -1979,7 +1978,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1979 break; 1978 break;
1980 case WEAK_BN: 1979 case WEAK_BN:
1981 if (!bidi_explicit_dir_char (bidi_it->ch)) 1980 if (!bidi_explicit_dir_char (bidi_it->ch))
1982 abort (); /* can't happen: BNs are skipped */ 1981 emacs_abort (); /* can't happen: BNs are skipped */
1983 /* FALLTHROUGH */ 1982 /* FALLTHROUGH */
1984 case NEUTRAL_B: 1983 case NEUTRAL_B:
1985 /* Marched all the way to the end of this level run. 1984 /* Marched all the way to the end of this level run.
@@ -1998,7 +1997,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1998 } 1997 }
1999 break; 1998 break;
2000 default: 1999 default:
2001 abort (); 2000 emacs_abort ();
2002 } 2001 }
2003 type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type, 2002 type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type,
2004 next_type, current_level); 2003 next_type, current_level);
@@ -2023,7 +2022,7 @@ bidi_type_of_next_char (struct bidi_it *bidi_it)
2023 2022
2024 /* This should always be called during a forward scan. */ 2023 /* This should always be called during a forward scan. */
2025 if (bidi_it->scan_dir != 1) 2024 if (bidi_it->scan_dir != 1)
2026 abort (); 2025 emacs_abort ();
2027 2026
2028 /* Reset the limit until which to ignore BNs if we step out of the 2027 /* Reset the limit until which to ignore BNs if we step out of the
2029 area where we found only empty levels. */ 2028 area where we found only empty levels. */
@@ -2107,7 +2106,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2107 if (bidi_it->scan_dir > 0) 2106 if (bidi_it->scan_dir > 0)
2108 { 2107 {
2109 if (bidi_it->nchars <= 0) 2108 if (bidi_it->nchars <= 0)
2110 abort (); 2109 emacs_abort ();
2111 next_char_pos = bidi_it->charpos + bidi_it->nchars; 2110 next_char_pos = bidi_it->charpos + bidi_it->nchars;
2112 } 2111 }
2113 else if (bidi_it->charpos >= bob) 2112 else if (bidi_it->charpos >= bob)
@@ -2143,7 +2142,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2143 if (bidi_it->scan_dir == -1) 2142 if (bidi_it->scan_dir == -1)
2144 /* If we are going backwards, the iterator state is already cached 2143 /* If we are going backwards, the iterator state is already cached
2145 from previous scans, and should be fully resolved. */ 2144 from previous scans, and should be fully resolved. */
2146 abort (); 2145 emacs_abort ();
2147 2146
2148 if (type == UNKNOWN_BT) 2147 if (type == UNKNOWN_BT)
2149 type = bidi_type_of_next_char (bidi_it); 2148 type = bidi_type_of_next_char (bidi_it);
@@ -2156,7 +2155,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2156 || (type == WEAK_BN && prev_level == level)) 2155 || (type == WEAK_BN && prev_level == level))
2157 { 2156 {
2158 if (bidi_it->next_for_neutral.type == UNKNOWN_BT) 2157 if (bidi_it->next_for_neutral.type == UNKNOWN_BT)
2159 abort (); 2158 emacs_abort ();
2160 2159
2161 /* If the cached state shows a neutral character, it was not 2160 /* If the cached state shows a neutral character, it was not
2162 resolved by bidi_resolve_neutral, so do it now. */ 2161 resolved by bidi_resolve_neutral, so do it now. */
@@ -2170,7 +2169,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2170 || type == WEAK_BN 2169 || type == WEAK_BN
2171 || type == WEAK_EN 2170 || type == WEAK_EN
2172 || type == WEAK_AN)) 2171 || type == WEAK_AN))
2173 abort (); 2172 emacs_abort ();
2174 bidi_it->type = type; 2173 bidi_it->type = type;
2175 bidi_check_type (bidi_it->type); 2174 bidi_check_type (bidi_it->type);
2176 2175
@@ -2192,7 +2191,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2192 int dpp = bidi_it->disp_prop; 2191 int dpp = bidi_it->disp_prop;
2193 2192
2194 if (bidi_it->nchars <= 0) 2193 if (bidi_it->nchars <= 0)
2195 abort (); 2194 emacs_abort ();
2196 do { 2195 do {
2197 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs, 2196 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs,
2198 fwp, &clen, &nc); 2197 fwp, &clen, &nc);
@@ -2301,8 +2300,9 @@ bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, bool end_flag)
2301 { 2300 {
2302 int new_level; 2301 int new_level;
2303 2302
2303 /* If we are at end of level, its edges must be cached. */
2304 if (end_flag) 2304 if (end_flag)
2305 abort (); /* if we are at end of level, its edges must be cached */ 2305 emacs_abort ();
2306 2306
2307 bidi_cache_iterator_state (bidi_it, 1); 2307 bidi_cache_iterator_state (bidi_it, 1);
2308 do { 2308 do {
@@ -2320,7 +2320,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2320 struct gcpro gcpro1; 2320 struct gcpro gcpro1;
2321 2321
2322 if (bidi_it->charpos < 0 || bidi_it->bytepos < 0) 2322 if (bidi_it->charpos < 0 || bidi_it->bytepos < 0)
2323 abort (); 2323 emacs_abort ();
2324 2324
2325 if (bidi_it->scan_dir == 0) 2325 if (bidi_it->scan_dir == 0)
2326 { 2326 {
@@ -2431,7 +2431,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2431 = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars, 2431 = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars,
2432 bidi_it->bytepos + bidi_it->ch_len); 2432 bidi_it->bytepos + bidi_it->ch_len);
2433 if (bidi_it->nchars <= 0) 2433 if (bidi_it->nchars <= 0)
2434 abort (); 2434 emacs_abort ();
2435 if (sep_len >= 0) 2435 if (sep_len >= 0)
2436 { 2436 {
2437 bidi_it->new_paragraph = 1; 2437 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;
67 If doing signal-driven input, and a signal came in when input was 67 If doing signal-driven input, and a signal came in when input was
68 blocked, reinvoke the signal handler now to deal with it. 68 blocked, reinvoke the signal handler now to deal with it.
69 69
70 We used to have two possible definitions of this macro - one for 70 Always test interrupt_input_pending; that's not too expensive, and
71 when SIGIO was #defined, and one for when it wasn't; when SIGIO 71 it'll never get set if we don't need to resignal. This is simpler
72 wasn't #defined, we wouldn't bother to check if we should re-invoke 72 than dealing here with every configuration option that might affect
73 the signal handler. But that doesn't work very well; some of the 73 whether interrupt_input_pending can be nonzero. */
74 files which use this macro don't #include the right files to get
75 SIGIO.
76
77 So, we always test interrupt_input_pending now; that's not too
78 expensive, and it'll never get set if we don't need to resignal. */
79 74
80#define UNBLOCK_INPUT \ 75#define UNBLOCK_INPUT \
81 do \ 76 do \
@@ -89,7 +84,7 @@ extern int pending_atimers;
89 do_pending_atimers (); \ 84 do_pending_atimers (); \
90 } \ 85 } \
91 else if (interrupt_input_blocked < 0) \ 86 else if (interrupt_input_blocked < 0) \
92 abort (); \ 87 emacs_abort (); \
93 } \ 88 } \
94 while (0) 89 while (0)
95 90
@@ -124,4 +119,3 @@ extern int pending_atimers;
124extern void reinvoke_input_signal (void); 119extern void reinvoke_input_signal (void);
125 120
126#endif /* EMACS_BLOCKINPUT_H */ 121#endif /* EMACS_BLOCKINPUT_H */
127
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/>. */
26#include <sys/param.h> 26#include <sys/param.h>
27#include <errno.h> 27#include <errno.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30#include <unistd.h> 29#include <unistd.h>
31 30
32#include <verify.h> 31#include <verify.h>
@@ -44,7 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "keymap.h" 43#include "keymap.h"
45#include "frame.h" 44#include "frame.h"
46 45
47struct buffer *current_buffer; /* the current buffer */ 46struct buffer *current_buffer; /* The current buffer. */
48 47
49/* First buffer in chain of all buffers (in reverse order of creation). 48/* First buffer in chain of all buffers (in reverse order of creation).
50 Threaded through ->header.next.buffer. */ 49 Threaded through ->header.next.buffer. */
@@ -60,10 +59,6 @@ struct buffer *all_buffers;
60 59
61struct buffer alignas (GCALIGNMENT) buffer_defaults; 60struct buffer alignas (GCALIGNMENT) buffer_defaults;
62 61
63/* A Lisp_Object pointer to the above, used for staticpro */
64
65static Lisp_Object Vbuffer_defaults;
66
67/* This structure marks which slots in a buffer have corresponding 62/* This structure marks which slots in a buffer have corresponding
68 default values in buffer_defaults. 63 default values in buffer_defaults.
69 Each such slot has a nonzero value in this structure. 64 Each such slot has a nonzero value in this structure.
@@ -78,18 +73,15 @@ static Lisp_Object Vbuffer_defaults;
78 and the corresponding slot in buffer_defaults is not used. 73 and the corresponding slot in buffer_defaults is not used.
79 74
80 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is 75 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
81 zero, that is a bug */ 76 zero, that is a bug. */
82 77
83struct buffer buffer_local_flags; 78struct buffer buffer_local_flags;
84 79
85/* This structure holds the names of symbols whose values may be 80/* This structure holds the names of symbols whose values may be
86 buffer-local. It is indexed and accessed in the same way as the above. */ 81 buffer-local. It is indexed and accessed in the same way as the above. */
87 82
88struct buffer alignas (GCALIGNMENT) buffer_local_symbols; 83struct buffer alignas (GCALIGNMENT) buffer_local_symbols;
89 84
90/* A Lisp_Object pointer to the above, used for staticpro */
91static Lisp_Object Vbuffer_local_symbols;
92
93/* Return the symbol of the per-buffer variable at offset OFFSET in 85/* Return the symbol of the per-buffer variable at offset OFFSET in
94 the buffer structure. */ 86 the buffer structure. */
95 87
@@ -115,7 +107,7 @@ static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
115static void swap_out_buffer_local_variables (struct buffer *b); 107static void swap_out_buffer_local_variables (struct buffer *b);
116static void reset_buffer_local_variables (struct buffer *, bool); 108static void reset_buffer_local_variables (struct buffer *, bool);
117 109
118/* Alist of all buffer names vs the buffers. */ 110/* Alist of all buffer names vs the buffers. */
119/* This used to be a variable, but is no longer, 111/* This used to be a variable, but is no longer,
120 to prevent lossage due to user rplac'ing this alist or its elements. */ 112 to prevent lossage due to user rplac'ing this alist or its elements. */
121Lisp_Object Vbuffer_alist; 113Lisp_Object Vbuffer_alist;
@@ -134,7 +126,7 @@ static Lisp_Object Qpermanent_local_hook;
134 126
135static Lisp_Object Qprotected_field; 127static Lisp_Object Qprotected_field;
136 128
137static Lisp_Object QSFundamental; /* A string "Fundamental" */ 129static Lisp_Object QSFundamental; /* A string "Fundamental". */
138 130
139static Lisp_Object Qkill_buffer_hook; 131static Lisp_Object Qkill_buffer_hook;
140static Lisp_Object Qbuffer_list_update_hook; 132static Lisp_Object Qbuffer_list_update_hook;
@@ -395,7 +387,7 @@ DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0,
395Value is nil if OBJECT is not a buffer or if it has been killed. */) 387Value is nil if OBJECT is not a buffer or if it has been killed. */)
396 (Lisp_Object object) 388 (Lisp_Object object)
397{ 389{
398 return ((BUFFERP (object) && ! NILP (BVAR (XBUFFER (object), name))) 390 return ((BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)))
399 ? Qt : Qnil); 391 ? Qt : Qnil);
400} 392}
401 393
@@ -595,10 +587,6 @@ even if it is dead. The return value is never nil. */)
595 bset_width_table (b, Qnil); 587 bset_width_table (b, Qnil);
596 b->prevent_redisplay_optimizations_p = 1; 588 b->prevent_redisplay_optimizations_p = 1;
597 589
598 /* Put this on the chain of all buffers including killed ones. */
599 b->header.next.buffer = all_buffers;
600 all_buffers = b;
601
602 /* An ordinary buffer normally doesn't need markers 590 /* An ordinary buffer normally doesn't need markers
603 to handle BEGV and ZV. */ 591 to handle BEGV and ZV. */
604 bset_pt_marker (b, Qnil); 592 bset_pt_marker (b, Qnil);
@@ -787,7 +775,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
787 base_buffer = Fget_buffer (base_buffer); 775 base_buffer = Fget_buffer (base_buffer);
788 if (NILP (base_buffer)) 776 if (NILP (base_buffer))
789 error ("No such buffer: `%s'", SDATA (tem)); 777 error ("No such buffer: `%s'", SDATA (tem));
790 if (NILP (BVAR (XBUFFER (base_buffer), name))) 778 if (!BUFFER_LIVE_P (XBUFFER (base_buffer)))
791 error ("Base buffer has been killed"); 779 error ("Base buffer has been killed");
792 780
793 if (SCHARS (name) == 0) 781 if (SCHARS (name) == 0)
@@ -819,10 +807,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
819 b->width_run_cache = 0; 807 b->width_run_cache = 0;
820 bset_width_table (b, Qnil); 808 bset_width_table (b, Qnil);
821 809
822 /* Put this on the chain of all buffers including killed ones. */
823 b->header.next.buffer = all_buffers;
824 all_buffers = b;
825
826 name = Fcopy_sequence (name); 810 name = Fcopy_sequence (name);
827 set_string_intervals (name, NULL); 811 set_string_intervals (name, NULL);
828 bset_name (b, name); 812 bset_name (b, name);
@@ -1242,7 +1226,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1242 result = Fdefault_value (variable); 1226 result = Fdefault_value (variable);
1243 break; 1227 break;
1244 } 1228 }
1245 default: abort (); 1229 default: emacs_abort ();
1246 } 1230 }
1247 1231
1248 return result; 1232 return result;
@@ -1568,7 +1552,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1568 { 1552 {
1569 buf = XCAR (tail); 1553 buf = XCAR (tail);
1570 if (BUFFERP (buf) && !EQ (buf, buffer) 1554 if (BUFFERP (buf) && !EQ (buf, buffer)
1571 && !NILP (BVAR (XBUFFER (buf), name)) 1555 && BUFFER_LIVE_P (XBUFFER (buf))
1572 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') 1556 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1573 /* If the frame has a buffer_predicate, disregard buffers that 1557 /* If the frame has a buffer_predicate, disregard buffers that
1574 don't fit the predicate. */ 1558 don't fit the predicate. */
@@ -1588,7 +1572,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1588 { 1572 {
1589 buf = Fcdr (XCAR (tail)); 1573 buf = Fcdr (XCAR (tail));
1590 if (BUFFERP (buf) && !EQ (buf, buffer) 1574 if (BUFFERP (buf) && !EQ (buf, buffer)
1591 && !NILP (BVAR (XBUFFER (buf), name)) 1575 && BUFFER_LIVE_P (XBUFFER (buf))
1592 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') 1576 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1593 /* If the frame has a buffer_predicate, disregard buffers that 1577 /* If the frame has a buffer_predicate, disregard buffers that
1594 don't fit the predicate. */ 1578 don't fit the predicate. */
@@ -1630,7 +1614,7 @@ other_buffer_safely (Lisp_Object buffer)
1630 { 1614 {
1631 buf = Fcdr (XCAR (tail)); 1615 buf = Fcdr (XCAR (tail));
1632 if (BUFFERP (buf) && !EQ (buf, buffer) 1616 if (BUFFERP (buf) && !EQ (buf, buffer)
1633 && !NILP (BVAR (XBUFFER (buf), name)) 1617 && BUFFER_LIVE_P (XBUFFER (buf))
1634 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')) 1618 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' '))
1635 return buf; 1619 return buf;
1636 } 1620 }
@@ -1749,7 +1733,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1749 b = XBUFFER (buffer); 1733 b = XBUFFER (buffer);
1750 1734
1751 /* Avoid trouble for buffer already dead. */ 1735 /* Avoid trouble for buffer already dead. */
1752 if (NILP (BVAR (b, name))) 1736 if (!BUFFER_LIVE_P (b))
1753 return Qnil; 1737 return Qnil;
1754 1738
1755 /* Query if the buffer is still modified. */ 1739 /* Query if the buffer is still modified. */
@@ -1785,7 +1769,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1785 } 1769 }
1786 1770
1787 /* If the hooks have killed the buffer, exit now. */ 1771 /* If the hooks have killed the buffer, exit now. */
1788 if (NILP (BVAR (b, name))) 1772 if (!BUFFER_LIVE_P (b))
1789 return Qt; 1773 return Qt;
1790 1774
1791 /* We have no more questions to ask. Verify that it is valid 1775 /* 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. */)
1817 UNGCPRO; 1801 UNGCPRO;
1818 1802
1819 /* Exit if we now have killed the base buffer (Bug#11665). */ 1803 /* Exit if we now have killed the base buffer (Bug#11665). */
1820 if (NILP (BVAR (b, name))) 1804 if (!BUFFER_LIVE_P (b))
1821 return Qt; 1805 return Qt;
1822 } 1806 }
1823 1807
@@ -1828,7 +1812,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1828 replace_buffer_in_windows (buffer); 1812 replace_buffer_in_windows (buffer);
1829 1813
1830 /* Exit if replacing the buffer in windows has killed our buffer. */ 1814 /* Exit if replacing the buffer in windows has killed our buffer. */
1831 if (NILP (BVAR (b, name))) 1815 if (!BUFFER_LIVE_P (b))
1832 return Qt; 1816 return Qt;
1833 1817
1834 /* Make this buffer not be current. Exit if it is the sole visible 1818 /* 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. */)
1861 1845
1862 /* Killing buffer processes may run sentinels which may have killed 1846 /* Killing buffer processes may run sentinels which may have killed
1863 our buffer. */ 1847 our buffer. */
1864 if (NILP (BVAR (b, name))) 1848 if (!BUFFER_LIVE_P (b))
1865 return Qt; 1849 return Qt;
1866 1850
1867 /* These may run Lisp code and into infinite loops (if someone 1851 /* 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. */)
1893 } 1877 }
1894 1878
1895 /* Deleting an auto-save file could have killed our buffer. */ 1879 /* Deleting an auto-save file could have killed our buffer. */
1896 if (NILP (BVAR (b, name))) 1880 if (!BUFFER_LIVE_P (b))
1897 return Qt; 1881 return Qt;
1898 1882
1899 if (b->base_buffer) 1883 if (b->base_buffer)
@@ -2062,7 +2046,7 @@ the current buffer's major mode. */)
2062 2046
2063 CHECK_BUFFER (buffer); 2047 CHECK_BUFFER (buffer);
2064 2048
2065 if (NILP (BVAR (XBUFFER (buffer), name))) 2049 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
2066 error ("Attempt to set major mode for a dead buffer"); 2050 error ("Attempt to set major mode for a dead buffer");
2067 2051
2068 if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) 2052 if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
@@ -2198,7 +2182,7 @@ ends when the current command terminates. Use `switch-to-buffer' or
2198 buffer = Fget_buffer (buffer_or_name); 2182 buffer = Fget_buffer (buffer_or_name);
2199 if (NILP (buffer)) 2183 if (NILP (buffer))
2200 nsberror (buffer_or_name); 2184 nsberror (buffer_or_name);
2201 if (NILP (BVAR (XBUFFER (buffer), name))) 2185 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
2202 error ("Selecting deleted buffer"); 2186 error ("Selecting deleted buffer");
2203 set_buffer_internal (XBUFFER (buffer)); 2187 set_buffer_internal (XBUFFER (buffer));
2204 return buffer; 2188 return buffer;
@@ -2209,7 +2193,7 @@ ends when the current command terminates. Use `switch-to-buffer' or
2209Lisp_Object 2193Lisp_Object
2210set_buffer_if_live (Lisp_Object buffer) 2194set_buffer_if_live (Lisp_Object buffer)
2211{ 2195{
2212 if (! NILP (BVAR (XBUFFER (buffer), name))) 2196 if (BUFFER_LIVE_P (XBUFFER (buffer)))
2213 set_buffer_internal (XBUFFER (buffer)); 2197 set_buffer_internal (XBUFFER (buffer));
2214 return Qnil; 2198 return Qnil;
2215} 2199}
@@ -2304,7 +2288,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2304 CHECK_BUFFER (buffer); 2288 CHECK_BUFFER (buffer);
2305 other_buffer = XBUFFER (buffer); 2289 other_buffer = XBUFFER (buffer);
2306 2290
2307 if (NILP (BVAR (other_buffer, name))) 2291 if (!BUFFER_LIVE_P (other_buffer))
2308 error ("Cannot swap a dead buffer's text"); 2292 error ("Cannot swap a dead buffer's text");
2309 2293
2310 /* Actually, it probably works just fine. 2294 /* Actually, it probably works just fine.
@@ -2671,7 +2655,7 @@ current buffer is cleared. */)
2671 /* Make sure no markers were put on the chain 2655 /* Make sure no markers were put on the chain
2672 while the chain value was incorrect. */ 2656 while the chain value was incorrect. */
2673 if (BUF_MARKERS (current_buffer)) 2657 if (BUF_MARKERS (current_buffer))
2674 abort (); 2658 emacs_abort ();
2675 2659
2676 BUF_MARKERS (current_buffer) = markers; 2660 BUF_MARKERS (current_buffer) = markers;
2677 2661
@@ -2700,7 +2684,7 @@ current buffer is cleared. */)
2700 /* Copy this buffer's new multibyte status 2684 /* Copy this buffer's new multibyte status
2701 into all of its indirect buffers. */ 2685 into all of its indirect buffers. */
2702 FOR_EACH_BUFFER (other) 2686 FOR_EACH_BUFFER (other)
2703 if (other->base_buffer == current_buffer && !NILP (BVAR (other, name))) 2687 if (other->base_buffer == current_buffer && BUFFER_LIVE_P (other))
2704 { 2688 {
2705 BVAR (other, enable_multibyte_characters) 2689 BVAR (other, enable_multibyte_characters)
2706 = BVAR (current_buffer, enable_multibyte_characters); 2690 = BVAR (current_buffer, enable_multibyte_characters);
@@ -3413,7 +3397,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3413 } 3397 }
3414 } 3398 }
3415 if (p != overlay_str_buf + total) 3399 if (p != overlay_str_buf + total)
3416 abort (); 3400 emacs_abort ();
3417 if (pstr) 3401 if (pstr)
3418 *pstr = overlay_str_buf; 3402 *pstr = overlay_str_buf;
3419 return total; 3403 return total;
@@ -4073,6 +4057,26 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
4073 4057
4074 return unbind_to (count, Qnil); 4058 return unbind_to (count, Qnil);
4075} 4059}
4060
4061DEFUN ("delete-all-overlays", Fdelete_all_overlays, Sdelete_all_overlays, 0, 1, 0,
4062 doc: /* Delete all overlays of BUFFER.
4063BUFFER omitted or nil means delete all overlays of the current
4064buffer. */)
4065 (Lisp_Object buffer)
4066{
4067 register struct buffer *buf;
4068
4069 if (NILP (buffer))
4070 buf = current_buffer;
4071 else
4072 {
4073 CHECK_BUFFER (buffer);
4074 buf = XBUFFER (buffer);
4075 }
4076
4077 delete_all_overlays (buf);
4078 return Qnil;
4079}
4076 4080
4077/* Overlay dissection functions. */ 4081/* Overlay dissection functions. */
4078 4082
@@ -4576,7 +4580,7 @@ buffer_slot_type_mismatch (Lisp_Object newval, int type)
4576 case_Lisp_Int: predicate = Qintegerp; break; 4580 case_Lisp_Int: predicate = Qintegerp; break;
4577 case Lisp_String: predicate = Qstringp; break; 4581 case Lisp_String: predicate = Qstringp; break;
4578 case Lisp_Symbol: predicate = Qsymbolp; break; 4582 case Lisp_Symbol: predicate = Qsymbolp; break;
4579 default: abort (); 4583 default: emacs_abort ();
4580 } 4584 }
4581 4585
4582 wrong_type_argument (predicate, newval); 4586 wrong_type_argument (predicate, newval);
@@ -5125,10 +5129,11 @@ init_buffer_once (void)
5125 buffer_local_symbols.indirections = 0; 5129 buffer_local_symbols.indirections = 0;
5126 set_buffer_intervals (&buffer_defaults, NULL); 5130 set_buffer_intervals (&buffer_defaults, NULL);
5127 set_buffer_intervals (&buffer_local_symbols, NULL); 5131 set_buffer_intervals (&buffer_local_symbols, NULL);
5132 /* This is not strictly necessary, but let's make them initialized. */
5133 bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*"));
5134 bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*"));
5128 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); 5135 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);
5129 XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
5130 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); 5136 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize);
5131 XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols);
5132 5137
5133 /* Set up the default values of various buffer slots. */ 5138 /* Set up the default values of various buffer slots. */
5134 /* Must do these before making the first buffer! */ 5139 /* Must do these before making the first buffer! */
@@ -5257,7 +5262,7 @@ init_buffer_once (void)
5257 5262
5258 /* Need more room? */ 5263 /* Need more room? */
5259 if (idx >= MAX_PER_BUFFER_VARS) 5264 if (idx >= MAX_PER_BUFFER_VARS)
5260 abort (); 5265 emacs_abort ();
5261 last_per_buffer_idx = idx; 5266 last_per_buffer_idx = idx;
5262 5267
5263 Vbuffer_alist = Qnil; 5268 Vbuffer_alist = Qnil;
@@ -5398,7 +5403,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5398 if (PER_BUFFER_IDX (offset) == 0) 5403 if (PER_BUFFER_IDX (offset) == 0)
5399 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding 5404 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
5400 slot of buffer_local_flags */ 5405 slot of buffer_local_flags */
5401 abort (); 5406 emacs_abort ();
5402} 5407}
5403 5408
5404 5409
@@ -5410,8 +5415,6 @@ syms_of_buffer (void)
5410 last_overlay_modification_hooks 5415 last_overlay_modification_hooks
5411 = Fmake_vector (make_number (10), Qnil); 5416 = Fmake_vector (make_number (10), Qnil);
5412 5417
5413 staticpro (&Vbuffer_defaults);
5414 staticpro (&Vbuffer_local_symbols);
5415 staticpro (&Qfundamental_mode); 5418 staticpro (&Qfundamental_mode);
5416 staticpro (&Qmode_class); 5419 staticpro (&Qmode_class);
5417 staticpro (&QSFundamental); 5420 staticpro (&QSFundamental);
@@ -6286,6 +6289,7 @@ and `bury-buffer-internal'. */);
6286 defsubr (&Soverlayp); 6289 defsubr (&Soverlayp);
6287 defsubr (&Smake_overlay); 6290 defsubr (&Smake_overlay);
6288 defsubr (&Sdelete_overlay); 6291 defsubr (&Sdelete_overlay);
6292 defsubr (&Sdelete_all_overlays);
6289 defsubr (&Smove_overlay); 6293 defsubr (&Smove_overlay);
6290 defsubr (&Soverlay_start); 6294 defsubr (&Soverlay_start);
6291 defsubr (&Soverlay_end); 6295 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)
959 b->INTERNAL_FIELD (width_table) = val; 959 b->INTERNAL_FIELD (width_table) = val;
960} 960}
961 961
962 962/* Convenient check whether buffer B is live. */
963
964#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
965
963/* Chain of all buffers, including killed ones. */ 966/* Chain of all buffers, including killed ones. */
964 967
965extern struct buffer *all_buffers; 968extern struct buffer *all_buffers;
@@ -1149,7 +1152,7 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
1149 We assume you know which buffer it's pointing into. */ 1152 We assume you know which buffer it's pointing into. */
1150 1153
1151#define OVERLAY_POSITION(P) \ 1154#define OVERLAY_POSITION(P) \
1152 (MARKERP (P) ? marker_position (P) : (abort (), 0)) 1155 (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0))
1153 1156
1154 1157
1155/*********************************************************************** 1158/***********************************************************************
@@ -1189,7 +1192,7 @@ extern int last_per_buffer_idx;
1189 1192
1190#define PER_BUFFER_VALUE_P(B, IDX) \ 1193#define PER_BUFFER_VALUE_P(B, IDX) \
1191 (((IDX) < 0 || IDX >= last_per_buffer_idx) \ 1194 (((IDX) < 0 || IDX >= last_per_buffer_idx) \
1192 ? (abort (), 0) \ 1195 ? (emacs_abort (), 0) \
1193 : ((B)->local_flags[IDX] != 0)) 1196 : ((B)->local_flags[IDX] != 0))
1194 1197
1195/* Set whether per-buffer variable with index IDX has a buffer-local 1198/* Set whether per-buffer variable with index IDX has a buffer-local
@@ -1198,7 +1201,7 @@ extern int last_per_buffer_idx;
1198#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ 1201#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \
1199 do { \ 1202 do { \
1200 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ 1203 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \
1201 abort (); \ 1204 emacs_abort (); \
1202 (B)->local_flags[IDX] = (VAL); \ 1205 (B)->local_flags[IDX] = (VAL); \
1203 } while (0) 1206 } while (0)
1204 1207
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:
33 */ 33 */
34 34
35#include <config.h> 35#include <config.h>
36#include <setjmp.h> 36
37#include "lisp.h" 37#include "lisp.h"
38#include "character.h" 38#include "character.h"
39#include "buffer.h" 39#include "buffer.h"
@@ -435,7 +435,7 @@ unmark_byte_stack (void)
435#ifdef BYTE_CODE_SAFE 435#ifdef BYTE_CODE_SAFE
436 436
437#define CHECK_RANGE(ARG) \ 437#define CHECK_RANGE(ARG) \
438 if (ARG >= bytestr_length) abort () 438 if (ARG >= bytestr_length) emacs_abort ()
439 439
440#else /* not BYTE_CODE_SAFE */ 440#else /* not BYTE_CODE_SAFE */
441 441
@@ -458,7 +458,8 @@ unmark_byte_stack (void)
458 Fsignal (Qquit, Qnil); \ 458 Fsignal (Qquit, Qnil); \
459 AFTER_POTENTIAL_GC (); \ 459 AFTER_POTENTIAL_GC (); \
460 } \ 460 } \
461 ELSE_PENDING_SIGNALS \ 461 else if (pending_signals) \
462 process_pending_signals (); \
462 } while (0) 463 } while (0)
463 464
464 465
@@ -508,7 +509,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
508 if (FRAME_X_P (f) 509 if (FRAME_X_P (f)
509 && FRAME_FONT (f)->direction != 0 510 && FRAME_FONT (f)->direction != 0
510 && FRAME_FONT (f)->direction != 1) 511 && FRAME_FONT (f)->direction != 1)
511 abort (); 512 emacs_abort ();
512 } 513 }
513#endif 514#endif
514 515
@@ -600,9 +601,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
600 { 601 {
601#ifdef BYTE_CODE_SAFE 602#ifdef BYTE_CODE_SAFE
602 if (top > stacke) 603 if (top > stacke)
603 abort (); 604 emacs_abort ();
604 else if (top < stack.bottom - 1) 605 else if (top < stack.bottom - 1)
605 abort (); 606 emacs_abort ();
606#endif 607#endif
607 608
608#ifdef BYTE_CODE_METER 609#ifdef BYTE_CODE_METER
@@ -1875,7 +1876,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1875 /* Actually this is Bstack_ref with offset 0, but we use Bdup 1876 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1876 for that instead. */ 1877 for that instead. */
1877 /* CASE (Bstack_ref): */ 1878 /* CASE (Bstack_ref): */
1878 abort (); 1879 emacs_abort ();
1879 1880
1880 /* Handy byte-codes for lexical binding. */ 1881 /* Handy byte-codes for lexical binding. */
1881 CASE (Bstack_ref1): 1882 CASE (Bstack_ref1):
@@ -1928,11 +1929,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1928#ifdef BYTE_CODE_SAFE 1929#ifdef BYTE_CODE_SAFE
1929 if (op < Bconstant) 1930 if (op < Bconstant)
1930 { 1931 {
1931 abort (); 1932 emacs_abort ();
1932 } 1933 }
1933 if ((op -= Bconstant) >= const_length) 1934 if ((op -= Bconstant) >= const_length)
1934 { 1935 {
1935 abort (); 1936 emacs_abort ();
1936 } 1937 }
1937 PUSH (vectorp[op]); 1938 PUSH (vectorp[op]);
1938#else 1939#else
@@ -1951,7 +1952,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1951#ifdef BYTE_CODE_SAFE 1952#ifdef BYTE_CODE_SAFE
1952 error ("binding stack not balanced (serious byte compiler bug)"); 1953 error ("binding stack not balanced (serious byte compiler bug)");
1953#else 1954#else
1954 abort (); 1955 emacs_abort ();
1955#endif 1956#endif
1956 1957
1957 return result; 1958 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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23 22
24#include "lisp.h" 23#include "lisp.h"
25#include "character.h" 24#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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <signal.h>
23#include <errno.h> 22#include <errno.h>
24#include <stdio.h> 23#include <stdio.h>
25#include <setjmp.h>
26#include <sys/types.h> 24#include <sys/types.h>
27#include <unistd.h> 25#include <unistd.h>
28 26
@@ -498,17 +496,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
498 register char **save_environ = environ; 496 register char **save_environ = environ;
499 register int fd1 = fd[1]; 497 register int fd1 = fd[1];
500 int fd_error = fd1; 498 int fd_error = fd1;
501#ifdef HAVE_WORKING_VFORK
502 sigset_t procmask;
503 sigset_t blocked;
504 struct sigaction sigpipe_action;
505#endif
506 499
507 if (fd_output >= 0) 500 if (fd_output >= 0)
508 fd1 = fd_output; 501 fd1 = fd_output;
509#if 0 /* Some systems don't have sigblock. */
510 mask = sigblock (sigmask (SIGCHLD));
511#endif
512 502
513 /* Record that we're about to create a synchronous process. */ 503 /* Record that we're about to create a synchronous process. */
514 synch_process_alive = 1; 504 synch_process_alive = 1;
@@ -592,17 +582,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
592 0, current_dir); 582 0, current_dir);
593#else /* not WINDOWSNT */ 583#else /* not WINDOWSNT */
594 584
595#ifdef HAVE_WORKING_VFORK
596 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
597 this sets the parent's signal handlers as well as the child's.
598 So delay all interrupts whose handlers the child might munge,
599 and record the current handlers so they can be restored later. */
600 sigemptyset (&blocked);
601 sigaddset (&blocked, SIGPIPE);
602 sigaction (SIGPIPE, 0, &sigpipe_action);
603 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
604#endif
605
606 BLOCK_INPUT; 585 BLOCK_INPUT;
607 586
608 /* vfork, and prevent local vars from being clobbered by the vfork. */ 587 /* 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) */)
650 /* GConf causes us to ignore SIGPIPE, make sure it is restored 629 /* GConf causes us to ignore SIGPIPE, make sure it is restored
651 in the child. */ 630 in the child. */
652 signal (SIGPIPE, SIG_DFL); 631 signal (SIGPIPE, SIG_DFL);
653#ifdef HAVE_WORKING_VFORK
654 pthread_sigmask (SIG_SETMASK, &procmask, 0);
655#endif
656 632
657 child_setup (filefd, fd1, fd_error, (char **) new_argv, 633 child_setup (filefd, fd1, fd_error, (char **) new_argv,
658 0, current_dir); 634 0, current_dir);
@@ -660,12 +636,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
660 636
661 UNBLOCK_INPUT; 637 UNBLOCK_INPUT;
662 638
663#ifdef HAVE_WORKING_VFORK
664 /* Restore the signal state. */
665 sigaction (SIGPIPE, &sigpipe_action, 0);
666 pthread_sigmask (SIG_SETMASK, &procmask, 0);
667#endif
668
669#endif /* not WINDOWSNT */ 639#endif /* not WINDOWSNT */
670 640
671 /* The MSDOS case did this already. */ 641 /* 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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "buffer.h" 25#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
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "buffer.h" 25#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/>. */
32 32
33#define CATEGORY_INLINE EXTERN_INLINE 33#define CATEGORY_INLINE EXTERN_INLINE
34 34
35#include <setjmp.h>
36#include "lisp.h" 35#include "lisp.h"
37#include "character.h" 36#include "character.h"
38#include "buffer.h" 37#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/>. */
26#include <config.h> 26#include <config.h>
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30#include <limits.h> 29#include <limits.h>
31 30
32#include "lisp.h" 31#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/>. */
36#ifdef emacs 36#ifdef emacs
37 37
38#include <sys/types.h> 38#include <sys/types.h>
39#include <setjmp.h>
40#include <intprops.h> 39#include <intprops.h>
41#include "lisp.h" 40#include "lisp.h"
42#include "character.h" 41#include "character.h"
@@ -541,7 +540,7 @@ multibyte_chars_in_text (const unsigned char *ptr, ptrdiff_t nbytes)
541 int len = MULTIBYTE_LENGTH (ptr, endp); 540 int len = MULTIBYTE_LENGTH (ptr, endp);
542 541
543 if (len == 0) 542 if (len == 0)
544 abort (); 543 emacs_abort ();
545 ptr += len; 544 ptr += len;
546 chars++; 545 chars++;
547 } 546 }
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/>. */
32#include <unistd.h> 32#include <unistd.h>
33#include <limits.h> 33#include <limits.h>
34#include <sys/types.h> 34#include <sys/types.h>
35#include <setjmp.h>
36#include <c-ctype.h> 35#include <c-ctype.h>
37#include "lisp.h" 36#include "lisp.h"
38#include "character.h" 37#include "character.h"
@@ -636,7 +635,7 @@ load_charset (struct charset *charset, int control_flag)
636 else 635 else
637 { 636 {
638 if (! CHARSET_UNIFIED_P (charset)) 637 if (! CHARSET_UNIFIED_P (charset))
639 abort (); 638 emacs_abort ();
640 map = CHARSET_UNIFY_MAP (charset); 639 map = CHARSET_UNIFY_MAP (charset);
641 } 640 }
642 if (STRINGP (map)) 641 if (STRINGP (map))
@@ -2025,10 +2024,10 @@ CH in the charset. */)
2025 c = XFASTINT (ch); 2024 c = XFASTINT (ch);
2026 charset = CHAR_CHARSET (c); 2025 charset = CHAR_CHARSET (c);
2027 if (! charset) 2026 if (! charset)
2028 abort (); 2027 emacs_abort ();
2029 code = ENCODE_CHAR (charset, c); 2028 code = ENCODE_CHAR (charset, c);
2030 if (code == CHARSET_INVALID_CODE (charset)) 2029 if (code == CHARSET_INVALID_CODE (charset))
2031 abort (); 2030 emacs_abort ();
2032 dimension = CHARSET_DIMENSION (charset); 2031 dimension = CHARSET_DIMENSION (charset);
2033 for (val = Qnil; dimension > 0; dimension--) 2032 for (val = Qnil; dimension > 0; dimension--)
2034 { 2033 {
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
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "charset.h" 25#include "charset.h"
diff --git a/src/cm.c b/src/cm.c
index 1922cd8140a..eda6430bafa 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24 23
25#include "lisp.h" 24#include "lisp.h"
26#include "frame.h" 25#include "frame.h"
@@ -119,7 +118,7 @@ cmcheckmagic (struct tty_display_info *tty)
119 if (curX (tty) == FrameCols (tty)) 118 if (curX (tty) == FrameCols (tty))
120 { 119 {
121 if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1) 120 if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
122 abort (); 121 emacs_abort ();
123 if (tty->termscript) 122 if (tty->termscript)
124 putc ('\r', tty->termscript); 123 putc ('\r', tty->termscript);
125 putc ('\r', tty->output); 124 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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "commands.h" 24#include "commands.h"
25#include "character.h" 25#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)
285 285
286#include <config.h> 286#include <config.h>
287#include <stdio.h> 287#include <stdio.h>
288#include <setjmp.h>
289 288
290#include "lisp.h" 289#include "lisp.h"
291#include "character.h" 290#include "character.h"
@@ -2051,7 +2050,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2051 break; 2050 break;
2052 2051
2053 default: 2052 default:
2054 abort (); 2053 emacs_abort ();
2055 } 2054 }
2056 CODING_DECODE_CHAR (coding, src, src_base, src_end, 2055 CODING_DECODE_CHAR (coding, src, src_base, src_end,
2057 CHARSET_FROM_ID (charset_ID), code, c); 2056 CHARSET_FROM_ID (charset_ID), code, c);
@@ -2345,7 +2344,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
2345 int i; 2344 int i;
2346 2345
2347 if (charbuf_end - charbuf < cmp_status->length) 2346 if (charbuf_end - charbuf < cmp_status->length)
2348 abort (); 2347 emacs_abort ();
2349 for (i = 0; i < cmp_status->length; i++) 2348 for (i = 0; i < cmp_status->length; i++)
2350 *charbuf++ = cmp_status->carryover[i]; 2349 *charbuf++ = cmp_status->carryover[i];
2351 coding->annotated = 1; 2350 coding->annotated = 1;
@@ -2619,7 +2618,7 @@ encode_coding_emacs_mule (struct coding_system *coding)
2619 preferred_charset_id = -1; 2618 preferred_charset_id = -1;
2620 break; 2619 break;
2621 default: 2620 default:
2622 abort (); 2621 emacs_abort ();
2623 } 2622 }
2624 charbuf += -c - 1; 2623 charbuf += -c - 1;
2625 continue; 2624 continue;
@@ -3482,7 +3481,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3482 if (cmp_status->state != COMPOSING_NO) 3481 if (cmp_status->state != COMPOSING_NO)
3483 { 3482 {
3484 if (charbuf_end - charbuf < cmp_status->length) 3483 if (charbuf_end - charbuf < cmp_status->length)
3485 abort (); 3484 emacs_abort ();
3486 for (i = 0; i < cmp_status->length; i++) 3485 for (i = 0; i < cmp_status->length; i++)
3487 *charbuf++ = cmp_status->carryover[i]; 3486 *charbuf++ = cmp_status->carryover[i];
3488 coding->annotated = 1; 3487 coding->annotated = 1;
@@ -3864,7 +3863,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3864 break; 3863 break;
3865 3864
3866 default: 3865 default:
3867 abort (); 3866 emacs_abort ();
3868 } 3867 }
3869 3868
3870 if (cmp_status->state == COMPOSING_NO 3869 if (cmp_status->state == COMPOSING_NO
@@ -4419,7 +4418,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
4419 preferred_charset_id = -1; 4418 preferred_charset_id = -1;
4420 break; 4419 break;
4421 default: 4420 default:
4422 abort (); 4421 emacs_abort ();
4423 } 4422 }
4424 charbuf += -c - 1; 4423 charbuf += -c - 1;
4425 continue; 4424 continue;
@@ -4933,7 +4932,7 @@ encode_coding_sjis (struct coding_system *coding)
4933 } 4932 }
4934 } 4933 }
4935 if (code == CHARSET_INVALID_CODE (charset)) 4934 if (code == CHARSET_INVALID_CODE (charset))
4936 abort (); 4935 emacs_abort ();
4937 if (charset == charset_kanji) 4936 if (charset == charset_kanji)
4938 { 4937 {
4939 int c1, c2; 4938 int c1, c2;
@@ -5023,7 +5022,7 @@ encode_coding_big5 (struct coding_system *coding)
5023 } 5022 }
5024 } 5023 }
5025 if (code == CHARSET_INVALID_CODE (charset)) 5024 if (code == CHARSET_INVALID_CODE (charset))
5026 abort (); 5025 emacs_abort ();
5027 if (charset == charset_big5) 5026 if (charset == charset_big5)
5028 { 5027 {
5029 int c1, c2; 5028 int c1, c2;
@@ -7190,7 +7189,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7190 *buf++ = XINT (XCAR (components)); 7189 *buf++ = XINT (XCAR (components));
7191 } 7190 }
7192 else 7191 else
7193 abort (); 7192 emacs_abort ();
7194 *head -= len; 7193 *head -= len;
7195 } 7194 }
7196 } 7195 }
@@ -9428,7 +9427,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9428 && changed[coding_priorities[j]]) 9427 && changed[coding_priorities[j]])
9429 j++; 9428 j++;
9430 if (j == coding_category_max) 9429 if (j == coding_category_max)
9431 abort (); 9430 emacs_abort ();
9432 priorities[i] = coding_priorities[j]; 9431 priorities[i] = coding_priorities[j];
9433 } 9432 }
9434 9433
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/>. */
26 26
27#define COMPOSITE_INLINE EXTERN_INLINE 27#define COMPOSITE_INLINE EXTERN_INLINE
28 28
29#include <setjmp.h>
30#include "lisp.h" 29#include "lisp.h"
31#include "character.h" 30#include "character.h"
32#include "buffer.h" 31#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;
113 && (end - start) == COMPOSITION_LENGTH (prop)) 113 && (end - start) == COMPOSITION_LENGTH (prop))
114 114
115/* Return the Nth glyph of composition specified by CMP. CMP is a 115/* Return the Nth glyph of composition specified by CMP. CMP is a
116 pointer to `struct composition'. */ 116 pointer to `struct composition'. */
117#define COMPOSITION_GLYPH(cmp, n) \ 117#define COMPOSITION_GLYPH(cmp, n) \
118 XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \ 118 XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \
119 ->key_and_value) \ 119 ->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/>. */
40#endif 40#endif
41#endif 41#endif
42 42
43#ifdef SIGNAL_H_AHB
44#undef SIGNAL_H_AHB
45#include <signal.h>
46#endif
47
48/* This silences a few compilation warnings on FreeBSD. */ 43/* This silences a few compilation warnings on FreeBSD. */
49#ifdef BSD_SYSTEM_AHB 44#ifdef BSD_SYSTEM_AHB
50#undef BSD_SYSTEM_AHB 45#undef BSD_SYSTEM_AHB
@@ -95,7 +90,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
95char *_getpty(); 90char *_getpty();
96#endif 91#endif
97 92
98#undef SA_RESTART /* not the same as defining BROKEN_SA_RESTART */
99#endif /* IRIX6_5 */ 93#endif /* IRIX6_5 */
100 94
101#ifdef MSDOS 95#ifdef MSDOS
@@ -138,22 +132,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
138#endif 132#endif
139#endif /* MSDOS */ 133#endif /* MSDOS */
140 134
141#ifdef USG5_4
142/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars.
143 But get <termio.h> first to make sure ttold.h doesn't interfere. */
144#include <sys/wait.h>
145
146#ifdef emacs
147#include <sys/filio.h>
148#include <termio.h>
149#include <sys/ttold.h>
150#include <signal.h>
151#include <sys/stream.h>
152#include <sys/stropts.h>
153#include <sys/termios.h>
154#endif
155#endif /* USG5_4 */
156
157/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs, 135/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs,
158 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ 136 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
159#ifdef HAVE_NS 137#ifdef HAVE_NS
@@ -181,7 +159,7 @@ extern void _DebPrint (const char *fmt, ...);
181#ifdef emacs /* Don't do this for lib-src. */ 159#ifdef emacs /* Don't do this for lib-src. */
182/* Tell regex.c to use a type compatible with Emacs. */ 160/* Tell regex.c to use a type compatible with Emacs. */
183#define RE_TRANSLATE_TYPE Lisp_Object 161#define RE_TRANSLATE_TYPE Lisp_Object
184#define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C) 162#define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
185#ifdef make_number 163#ifdef make_number
186/* If make_number is a macro, use it. */ 164/* If make_number is a macro, use it. */
187#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0))) 165#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
@@ -192,9 +170,6 @@ extern void _DebPrint (const char *fmt, ...);
192#endif 170#endif
193 171
194#include <string.h> 172#include <string.h>
195/* If you think about removing the line below, note that the
196 MS-Windows build relies on it for declaration of 'environ' needed
197 by a few source files. */
198#include <stdlib.h> 173#include <stdlib.h>
199 174
200#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ 175#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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <signal.h>
23#include <stdio.h> 22#include <stdio.h>
24#include <setjmp.h>
25 23
26#include <intprops.h> 24#include <intprops.h>
27 25
@@ -37,17 +35,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include "keymap.h" 35#include "keymap.h"
38 36
39#include <float.h> 37#include <float.h>
40/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */
41#ifndef IEEE_FLOATING_POINT
42#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ 38#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
43 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 39 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
44#define IEEE_FLOATING_POINT 1 40#define IEEE_FLOATING_POINT 1
45#else 41#else
46#define IEEE_FLOATING_POINT 0 42#define IEEE_FLOATING_POINT 0
47#endif 43#endif
48#endif
49
50#include <math.h>
51 44
52Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; 45Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
53static Lisp_Object Qsubr; 46static Lisp_Object Qsubr;
@@ -77,8 +70,8 @@ Lisp_Object Qchar_table_p, Qvector_or_char_table_p;
77Lisp_Object Qcdr; 70Lisp_Object Qcdr;
78static Lisp_Object Qad_advice_info, Qad_activate_internal; 71static Lisp_Object Qad_advice_info, Qad_activate_internal;
79 72
80Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; 73static Lisp_Object Qdomain_error, Qsingularity_error, Qunderflow_error;
81Lisp_Object Qoverflow_error, Qunderflow_error; 74Lisp_Object Qrange_error, Qoverflow_error;
82 75
83Lisp_Object Qfloatp; 76Lisp_Object Qfloatp;
84Lisp_Object Qnumberp, Qnumber_or_marker_p; 77Lisp_Object Qnumberp, Qnumber_or_marker_p;
@@ -108,7 +101,7 @@ wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value)
108 to try and do that by checking the tagbits, but nowadays all 101 to try and do that by checking the tagbits, but nowadays all
109 tagbits are potentially valid. */ 102 tagbits are potentially valid. */
110 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit) 103 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
111 * abort (); */ 104 * emacs_abort (); */
112 105
113 xsignal2 (Qwrong_type_argument, predicate, value); 106 xsignal2 (Qwrong_type_argument, predicate, value);
114} 107}
@@ -182,7 +175,7 @@ for example, (type-of 1) returns `integer'. */)
182 case Lisp_Misc_Float: 175 case Lisp_Misc_Float:
183 return Qfloat; 176 return Qfloat;
184 } 177 }
185 abort (); 178 emacs_abort ();
186 179
187 case Lisp_Vectorlike: 180 case Lisp_Vectorlike:
188 if (WINDOW_CONFIGURATIONP (object)) 181 if (WINDOW_CONFIGURATIONP (object))
@@ -217,7 +210,7 @@ for example, (type-of 1) returns `integer'. */)
217 return Qfloat; 210 return Qfloat;
218 211
219 default: 212 default:
220 abort (); 213 emacs_abort ();
221 } 214 }
222} 215}
223 216
@@ -551,7 +544,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
551 /* In set_internal, we un-forward vars when their value is 544 /* In set_internal, we un-forward vars when their value is
552 set to Qunbound. */ 545 set to Qunbound. */
553 return Qt; 546 return Qt;
554 default: abort (); 547 default: emacs_abort ();
555 } 548 }
556 549
557 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 550 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -864,7 +857,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
864 don't think anything will break. --lorentey */ 857 don't think anything will break. --lorentey */
865 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset 858 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
866 + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 859 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
867 default: abort (); 860 default: emacs_abort ();
868 } 861 }
869} 862}
870 863
@@ -950,12 +943,14 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
950 break; 943 break;
951 944
952 default: 945 default:
953 abort (); /* goto def; */ 946 emacs_abort (); /* goto def; */
954 } 947 }
955} 948}
956 949
957/* Set up SYMBOL to refer to its global binding. 950/* Set up SYMBOL to refer to its global binding. This makes it safe
958 This makes it safe to alter the status of other bindings. */ 951 to alter the status of other bindings. BEWARE: this may be called
952 during the mark phase of GC, where we assume that Lisp_Object slots
953 of BLV are marked after this function has changed them. */
959 954
960void 955void
961swap_in_global_binding (struct Lisp_Symbol *symbol) 956swap_in_global_binding (struct Lisp_Symbol *symbol)
@@ -1014,7 +1009,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_
1014 else 1009 else
1015 { 1010 {
1016 tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist)); 1011 tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist));
1017 XSETBUFFER (blv->where, current_buffer); 1012 set_blv_where (blv, Fcurrent_buffer ());
1018 } 1013 }
1019 } 1014 }
1020 if (!(blv->found = !NILP (tem1))) 1015 if (!(blv->found = !NILP (tem1)))
@@ -1055,7 +1050,7 @@ find_symbol_value (Lisp_Object symbol)
1055 /* FALLTHROUGH */ 1050 /* FALLTHROUGH */
1056 case SYMBOL_FORWARDED: 1051 case SYMBOL_FORWARDED:
1057 return do_symval_forwarding (SYMBOL_FWD (sym)); 1052 return do_symval_forwarding (SYMBOL_FWD (sym));
1058 default: abort (); 1053 default: emacs_abort ();
1059 } 1054 }
1060} 1055}
1061 1056
@@ -1168,7 +1163,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1168 the default binding is loaded, the loaded binding may be the 1163 the default binding is loaded, the loaded binding may be the
1169 wrong one. */ 1164 wrong one. */
1170 if (!EQ (blv->where, where) 1165 if (!EQ (blv->where, where)
1171 /* Also unload a global binding (if the var is local_if_set). */ 1166 /* Also unload a global binding (if the var is local_if_set). */
1172 || (EQ (blv->valcell, blv->defcell))) 1167 || (EQ (blv->valcell, blv->defcell)))
1173 { 1168 {
1174 /* The currently loaded binding is not necessarily valid. 1169 /* The currently loaded binding is not necessarily valid.
@@ -1265,7 +1260,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1265 store_symval_forwarding (/* sym, */ innercontents, newval, buf); 1260 store_symval_forwarding (/* sym, */ innercontents, newval, buf);
1266 break; 1261 break;
1267 } 1262 }
1268 default: abort (); 1263 default: emacs_abort ();
1269 } 1264 }
1270 return; 1265 return;
1271} 1266}
@@ -1316,7 +1311,7 @@ default_value (Lisp_Object symbol)
1316 /* For other variables, get the current value. */ 1311 /* For other variables, get the current value. */
1317 return do_symval_forwarding (valcontents); 1312 return do_symval_forwarding (valcontents);
1318 } 1313 }
1319 default: abort (); 1314 default: emacs_abort ();
1320 } 1315 }
1321} 1316}
1322 1317
@@ -1414,7 +1409,7 @@ for this variable. */)
1414 else 1409 else
1415 return Fset (symbol, value); 1410 return Fset (symbol, value);
1416 } 1411 }
1417 default: abort (); 1412 default: emacs_abort ();
1418 } 1413 }
1419} 1414}
1420 1415
@@ -1538,7 +1533,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1538 else if (BUFFER_OBJFWDP (valcontents.fwd)) 1533 else if (BUFFER_OBJFWDP (valcontents.fwd))
1539 return variable; 1534 return variable;
1540 break; 1535 break;
1541 default: abort (); 1536 default: emacs_abort ();
1542 } 1537 }
1543 1538
1544 if (sym->constant) 1539 if (sym->constant)
@@ -1611,7 +1606,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1611 error ("Symbol %s may not be buffer-local", 1606 error ("Symbol %s may not be buffer-local",
1612 SDATA (SYMBOL_NAME (variable))); 1607 SDATA (SYMBOL_NAME (variable)));
1613 break; 1608 break;
1614 default: abort (); 1609 default: emacs_abort ();
1615 } 1610 }
1616 1611
1617 if (sym->constant) 1612 if (sym->constant)
@@ -1718,7 +1713,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1718 if (blv->frame_local) 1713 if (blv->frame_local)
1719 return variable; 1714 return variable;
1720 break; 1715 break;
1721 default: abort (); 1716 default: emacs_abort ();
1722 } 1717 }
1723 1718
1724 /* Get rid of this buffer's alist element, if any. */ 1719 /* Get rid of this buffer's alist element, if any. */
@@ -1800,7 +1795,7 @@ frame-local bindings). */)
1800 error ("Symbol %s may not be frame-local", 1795 error ("Symbol %s may not be frame-local",
1801 SDATA (SYMBOL_NAME (variable))); 1796 SDATA (SYMBOL_NAME (variable)));
1802 break; 1797 break;
1803 default: abort (); 1798 default: emacs_abort ();
1804 } 1799 }
1805 1800
1806 if (sym->constant) 1801 if (sym->constant)
@@ -1877,18 +1872,18 @@ BUFFER defaults to the current buffer. */)
1877 } 1872 }
1878 return Qnil; 1873 return Qnil;
1879 } 1874 }
1880 default: abort (); 1875 default: emacs_abort ();
1881 } 1876 }
1882} 1877}
1883 1878
1884DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1879DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
1885 1, 2, 0, 1880 1, 2, 0,
1886 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there. 1881 doc: /* Non-nil if VARIABLE is local in buffer BUFFER when set there.
1887More precisely, this means that setting the variable \(with `set' or`setq'), 1882BUFFER defaults to the current buffer.
1888while it does not have a `let'-style binding that was made in BUFFER, 1883
1889will produce a buffer local binding. See Info node 1884More precisely, return non-nil if either VARIABLE already has a local
1890`(elisp)Creating Buffer-Local'. 1885value in BUFFER, or if VARIABLE is automatically buffer-local (see
1891BUFFER defaults to the current buffer. */) 1886`make-variable-buffer-local'). */)
1892 (register Lisp_Object variable, Lisp_Object buffer) 1887 (register Lisp_Object variable, Lisp_Object buffer)
1893{ 1888{
1894 struct Lisp_Symbol *sym; 1889 struct Lisp_Symbol *sym;
@@ -1912,7 +1907,7 @@ BUFFER defaults to the current buffer. */)
1912 case SYMBOL_FORWARDED: 1907 case SYMBOL_FORWARDED:
1913 /* All BUFFER_OBJFWD slots become local if they are set. */ 1908 /* All BUFFER_OBJFWD slots become local if they are set. */
1914 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); 1909 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil);
1915 default: abort (); 1910 default: emacs_abort ();
1916 } 1911 }
1917} 1912}
1918 1913
@@ -1956,7 +1951,7 @@ If the current binding is global (the default), the value is nil. */)
1956 return SYMBOL_BLV (sym)->where; 1951 return SYMBOL_BLV (sym)->where;
1957 else 1952 else
1958 return Qnil; 1953 return Qnil;
1959 default: abort (); 1954 default: emacs_abort ();
1960 } 1955 }
1961} 1956}
1962 1957
@@ -2272,7 +2267,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2272 return Qnil; 2267 return Qnil;
2273 2268
2274 default: 2269 default:
2275 abort (); 2270 emacs_abort ();
2276 } 2271 }
2277} 2272}
2278 2273
@@ -2738,28 +2733,6 @@ Both must be integers or markers. */)
2738 return val; 2733 return val;
2739} 2734}
2740 2735
2741#ifndef HAVE_FMOD
2742double
2743fmod (double f1, double f2)
2744{
2745 double r = f1;
2746
2747 if (f2 < 0.0)
2748 f2 = -f2;
2749
2750 /* If the magnitude of the result exceeds that of the divisor, or
2751 the sign of the result does not agree with that of the dividend,
2752 iterate with the reduced value. This does not yield a
2753 particularly accurate result, but at least it will be in the
2754 range promised by fmod. */
2755 do
2756 r -= f2 * floor (r / f2);
2757 while (f2 <= (r < 0 ? -r : r) || ((r < 0) != (f1 < 0) && ! isnan (r)));
2758
2759 return r;
2760}
2761#endif /* ! HAVE_FMOD */
2762
2763DEFUN ("mod", Fmod, Smod, 2, 2, 0, 2736DEFUN ("mod", Fmod, Smod, 2, 2, 0,
2764 doc: /* Return X modulo Y. 2737 doc: /* Return X modulo Y.
2765The result falls between zero (inclusive) and Y (exclusive). 2738The result falls between zero (inclusive) and Y (exclusive).
@@ -3207,21 +3180,23 @@ syms_of_data (void)
3207 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; 3180 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1;
3208} 3181}
3209 3182
3210#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 3183static _Noreturn void
3211_Noreturn 3184handle_arith_signal (int sig)
3212#endif
3213static void
3214arith_error (int signo)
3215{ 3185{
3216 sigsetmask (SIGEMPTYMASK); 3186 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3217
3218 SIGNAL_THREAD_CHECK (signo);
3219 xsignal0 (Qarith_error); 3187 xsignal0 (Qarith_error);
3220} 3188}
3221 3189
3190static void
3191deliver_arith_signal (int sig)
3192{
3193 handle_on_main_thread (sig, handle_arith_signal);
3194}
3195
3222void 3196void
3223init_data (void) 3197init_data (void)
3224{ 3198{
3199 struct sigaction action;
3225 /* Don't do this if just dumping out. 3200 /* Don't do this if just dumping out.
3226 We don't want to call `signal' in this case 3201 We don't want to call `signal' in this case
3227 so that we don't have trouble with dumping 3202 so that we don't have trouble with dumping
@@ -3230,5 +3205,6 @@ init_data (void)
3230 if (!initialized) 3205 if (!initialized)
3231 return; 3206 return;
3232#endif /* CANNOT_DUMP */ 3207#endif /* CANNOT_DUMP */
3233 signal (SIGFPE, arith_error); 3208 emacs_sigaction_init (&action, deliver_arith_signal);
3209 sigaction (SIGFPE, &action, 0);
3234} 3210}
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/>. */
21#ifdef HAVE_DBUS 21#ifdef HAVE_DBUS
22#include <stdio.h> 22#include <stdio.h>
23#include <dbus/dbus.h> 23#include <dbus/dbus.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "frame.h" 26#include "frame.h"
27#include "termhooks.h" 27#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/>. */
22#include <stdio.h> 22#include <stdio.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/stat.h> 24#include <sys/stat.h>
25#include <setjmp.h>
26 25
27#ifdef HAVE_PWD_H 26#ifdef HAVE_PWD_H
28#include <pwd.h> 27#include <pwd.h>
@@ -275,7 +274,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
275 274
276 /* Some bug somewhere. */ 275 /* Some bug somewhere. */
277 if (nchars > nbytes) 276 if (nchars > nbytes)
278 abort (); 277 emacs_abort ();
279 278
280 STRING_SET_CHARS (fullname, nchars); 279 STRING_SET_CHARS (fullname, nchars);
281 if (nchars == nbytes) 280 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,
3055int in_display_vector_p (struct it *); 3055int in_display_vector_p (struct it *);
3056int frame_mode_line_height (struct frame *); 3056int frame_mode_line_height (struct frame *);
3057extern Lisp_Object Qtool_bar; 3057extern Lisp_Object Qtool_bar;
3058extern int redisplaying_p; 3058extern bool redisplaying_p;
3059extern int help_echo_showing_p; 3059extern int help_echo_showing_p;
3060extern int current_mode_line_height, current_header_line_height; 3060extern int current_mode_line_height, current_header_line_height;
3061extern Lisp_Object help_echo_string, help_echo_window; 3061extern Lisp_Object help_echo_string, help_echo_window;
@@ -3193,6 +3193,7 @@ void unrequest_sigio (void);
3193int tabs_safe_p (int); 3193int tabs_safe_p (int);
3194void init_baud_rate (int); 3194void init_baud_rate (int);
3195void init_sigio (int); 3195void init_sigio (int);
3196void ignore_sigio (void);
3196 3197
3197/* Defined in xfaces.c */ 3198/* Defined in xfaces.c */
3198 3199
@@ -3251,9 +3252,12 @@ void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
3251 3252
3252extern Lisp_Object tip_frame; 3253extern Lisp_Object tip_frame;
3253extern Window tip_window; 3254extern Window tip_window;
3255extern frame_parm_handler x_frame_parm_handlers[];
3256
3254extern void start_hourglass (void); 3257extern void start_hourglass (void);
3255extern void cancel_hourglass (void); 3258extern void cancel_hourglass (void);
3256extern int hourglass_shown_p; 3259extern int hourglass_shown_p;
3260
3257struct atimer; /* Defined in atimer.h. */ 3261struct atimer; /* Defined in atimer.h. */
3258/* If non-null, an asynchronous timer that, when it expires, displays 3262/* If non-null, an asynchronous timer that, when it expires, displays
3259 an hourglass cursor on all frames. */ 3263 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/>. */
21 21
22#define DISPEXTERN_INLINE EXTERN_INLINE 22#define DISPEXTERN_INLINE EXTERN_INLINE
23 23
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h>
27#include <unistd.h> 25#include <unistd.h>
28 26
29#include "lisp.h" 27#include "lisp.h"
@@ -297,7 +295,7 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history,
297void 295void
298__executable_start (void) 296__executable_start (void)
299{ 297{
300 abort (); 298 emacs_abort ();
301} 299}
302#endif 300#endif
303 301
@@ -347,7 +345,7 @@ free_glyph_matrix (struct glyph_matrix *matrix)
347 /* Detect the case that more matrices are freed than were 345 /* Detect the case that more matrices are freed than were
348 allocated. */ 346 allocated. */
349 if (--glyph_matrix_count < 0) 347 if (--glyph_matrix_count < 0)
350 abort (); 348 emacs_abort ();
351 349
352 /* Free glyph memory if MATRIX owns it. */ 350 /* Free glyph memory if MATRIX owns it. */
353 if (matrix->pool == NULL) 351 if (matrix->pool == NULL)
@@ -2339,9 +2337,9 @@ check_glyph_memory (void)
2339 2337
2340 /* Check that nothing is left allocated. */ 2338 /* Check that nothing is left allocated. */
2341 if (glyph_matrix_count) 2339 if (glyph_matrix_count)
2342 abort (); 2340 emacs_abort ();
2343 if (glyph_pool_count) 2341 if (glyph_pool_count)
2344 abort (); 2342 emacs_abort ();
2345} 2343}
2346 2344
2347 2345
@@ -3024,7 +3022,7 @@ check_matrix_pointers (struct glyph_matrix *window_matrix,
3024 { 3022 {
3025 if (!glyph_row_slice_p (window_matrix->rows + i, 3023 if (!glyph_row_slice_p (window_matrix->rows + i,
3026 frame_matrix->rows + j)) 3024 frame_matrix->rows + j))
3027 abort (); 3025 emacs_abort ();
3028 ++i, ++j; 3026 ++i, ++j;
3029 } 3027 }
3030} 3028}
@@ -3453,7 +3451,7 @@ check_current_matrix_flags (struct window *w)
3453 if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb) 3451 if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb)
3454 last_seen_p = 1; 3452 last_seen_p = 1;
3455 else if (last_seen_p && row->enabled_p) 3453 else if (last_seen_p && row->enabled_p)
3456 abort (); 3454 emacs_abort ();
3457 } 3455 }
3458} 3456}
3459 3457
@@ -3952,6 +3950,11 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3952 { 3950 {
3953 changed_p = 1; 3951 changed_p = 1;
3954 update_marginal_area (w, LEFT_MARGIN_AREA, vpos); 3952 update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
3953 /* Setting this flag will ensure the vertical border, if
3954 any, between this window and the one on its left will be
3955 redrawn. This is necessary because updating the left
3956 margin area can potentially draw over the border. */
3957 current_row->redraw_fringe_bitmaps_p = 1;
3955 } 3958 }
3956 3959
3957 /* Update the display of the text area. */ 3960 /* Update the display of the text area. */
@@ -4809,7 +4812,7 @@ scrolling (struct frame *frame)
4809 struct glyph_matrix *desired_matrix = frame->desired_matrix; 4812 struct glyph_matrix *desired_matrix = frame->desired_matrix;
4810 4813
4811 if (!current_matrix) 4814 if (!current_matrix)
4812 abort (); 4815 emacs_abort ();
4813 4816
4814 /* Compute hash codes of all the lines. Also calculate number of 4817 /* Compute hash codes of all the lines. Also calculate number of
4815 changed lines, number of unchanged lines at the beginning, and 4818 changed lines, number of unchanged lines at the beginning, and
@@ -5477,7 +5480,7 @@ marginal_area_string (struct window *w, enum window_part part,
5477 else if (part == ON_RIGHT_MARGIN) 5480 else if (part == ON_RIGHT_MARGIN)
5478 area = RIGHT_MARGIN_AREA; 5481 area = RIGHT_MARGIN_AREA;
5479 else 5482 else
5480 abort (); 5483 emacs_abort ();
5481 5484
5482 for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) 5485 for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row)
5483 if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) 5486 if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row))
@@ -5552,17 +5555,17 @@ marginal_area_string (struct window *w, enum window_part part,
5552 5555
5553#ifdef SIGWINCH 5556#ifdef SIGWINCH
5554 5557
5558static void deliver_window_change_signal (int);
5559
5555static void 5560static void
5556window_change_signal (int signalnum) /* If we don't have an argument, */ 5561handle_window_change_signal (int sig)
5557 /* some compilers complain in signal calls. */
5558{ 5562{
5559 int width, height; 5563 int width, height;
5560 int old_errno = errno;
5561
5562 struct tty_display_info *tty; 5564 struct tty_display_info *tty;
5563 5565
5564 signal (SIGWINCH, window_change_signal); 5566 struct sigaction action;
5565 SIGNAL_THREAD_CHECK (signalnum); 5567 emacs_sigaction_init (&action, deliver_window_change_signal);
5568 sigaction (SIGWINCH, &action, 0);
5566 5569
5567 /* The frame size change obviously applies to a single 5570 /* The frame size change obviously applies to a single
5568 termcap-controlled terminal, but we can't decide which. 5571 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, */
5591 change_frame_size (XFRAME (frame), height, width, 0, 1, 0); 5594 change_frame_size (XFRAME (frame), height, width, 0, 1, 0);
5592 } 5595 }
5593 } 5596 }
5597}
5594 5598
5595 errno = old_errno; 5599static void
5600deliver_window_change_signal (int sig)
5601{
5602 handle_on_main_thread (sig, handle_window_change_signal);
5596} 5603}
5597#endif /* SIGWINCH */ 5604#endif /* SIGWINCH */
5598 5605
@@ -5604,7 +5611,7 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
5604void 5611void
5605do_pending_window_change (bool safe) 5612do_pending_window_change (bool safe)
5606{ 5613{
5607 /* If window_change_signal should have run before, run it now. */ 5614 /* If window change signal handler should have run before, run it now. */
5608 if (redisplaying_p && !safe) 5615 if (redisplaying_p && !safe)
5609 return; 5616 return;
5610 5617
@@ -5963,7 +5970,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
5963 wrong_type_argument (Qnumberp, timeout); 5970 wrong_type_argument (Qnumberp, timeout);
5964 5971
5965 5972
5966#ifdef SIGIO 5973#ifdef USABLE_SIGIO
5967 gobble_input (0); 5974 gobble_input (0);
5968#endif 5975#endif
5969 5976
@@ -6173,7 +6180,11 @@ init_display (void)
6173#ifndef CANNOT_DUMP 6180#ifndef CANNOT_DUMP
6174 if (initialized) 6181 if (initialized)
6175#endif /* CANNOT_DUMP */ 6182#endif /* CANNOT_DUMP */
6176 signal (SIGWINCH, window_change_signal); 6183 {
6184 struct sigaction action;
6185 emacs_sigaction_init (&action, deliver_window_change_signal);
6186 sigaction (SIGWINCH, &action, 0);
6187 }
6177#endif /* SIGWINCH */ 6188#endif /* SIGWINCH */
6178 6189
6179 /* If running as a daemon, no need to initialize any frames/terminal. */ 6190 /* If running as a daemon, no need to initialize any frames/terminal. */
@@ -6277,7 +6288,7 @@ init_display (void)
6277 6288
6278 /* Convert the initial frame to use the new display. */ 6289 /* Convert the initial frame to use the new display. */
6279 if (f->output_method != output_initial) 6290 if (f->output_method != output_initial)
6280 abort (); 6291 emacs_abort ();
6281 f->output_method = t->type; 6292 f->output_method = t->type;
6282 f->terminal = t; 6293 f->terminal = t;
6283 6294
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/>. */
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/file.h> /* Must be after sys/types.h for USG*/ 24#include <sys/file.h> /* Must be after sys/types.h for USG*/
25#include <setjmp.h>
26#include <fcntl.h> 25#include <fcntl.h>
27#include <unistd.h> 26#include <unistd.h>
28 27
@@ -37,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37 36
38Lisp_Object Qfunction_documentation; 37Lisp_Object Qfunction_documentation;
39 38
40extern Lisp_Object Qclosure;
41/* Buffer used for reading from documentation file. */ 39/* Buffer used for reading from documentation file. */
42static char *get_doc_string_buffer; 40static char *get_doc_string_buffer;
43static ptrdiff_t get_doc_string_buffer_size; 41static 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/>. */
102 102
103#include <config.h> 103#include <config.h>
104#include <stdio.h> 104#include <stdio.h>
105#include <setjmp.h>
106#include <float.h> 105#include <float.h>
107#include <unistd.h> 106#include <unistd.h>
108#include <limits.h> 107#include <limits.h>
@@ -114,10 +113,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
114 another macro. */ 113 another macro. */
115#include "character.h" 114#include "character.h"
116 115
117#ifndef DBL_MAX_10_EXP
118#define DBL_MAX_10_EXP 308 /* IEEE double */
119#endif
120
121/* Generate output from a format-spec FORMAT, 116/* Generate output from a format-spec FORMAT,
122 terminated at position FORMAT_END. 117 terminated at position FORMAT_END.
123 (*FORMAT_END is not part of the format, but must exist and be readable.) 118 (*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/>. */
30#include <dos.h> 30#include <dos.h>
31#undef gettime 31#undef gettime
32#undef settime 32#undef settime
33#include <setjmp.h> 33
34#include "lisp.h" 34#include "lisp.h"
35#include "character.h" 35#include "character.h"
36#include "buffer.h" 36#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/>. */
21#include <config.h> 21#include <config.h>
22#include <sys/types.h> 22#include <sys/types.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#ifdef HAVE_PWD_H 25#ifdef HAVE_PWD_H
27#include <pwd.h> 26#include <pwd.h>
@@ -2613,7 +2612,7 @@ They default to the values of (point-min) and (point-max) in BUFFER. */)
2613 if (NILP (buf)) 2612 if (NILP (buf))
2614 nsberror (buffer); 2613 nsberror (buffer);
2615 bp = XBUFFER (buf); 2614 bp = XBUFFER (buf);
2616 if (NILP (BVAR (bp, name))) 2615 if (!BUFFER_LIVE_P (bp))
2617 error ("Selecting deleted buffer"); 2616 error ("Selecting deleted buffer");
2618 2617
2619 if (NILP (start)) 2618 if (NILP (start))
@@ -2677,7 +2676,7 @@ determines whether case is significant or ignored. */)
2677 if (NILP (buf1)) 2676 if (NILP (buf1))
2678 nsberror (buffer1); 2677 nsberror (buffer1);
2679 bp1 = XBUFFER (buf1); 2678 bp1 = XBUFFER (buf1);
2680 if (NILP (BVAR (bp1, name))) 2679 if (!BUFFER_LIVE_P (bp1))
2681 error ("Selecting deleted buffer"); 2680 error ("Selecting deleted buffer");
2682 } 2681 }
2683 2682
@@ -2715,7 +2714,7 @@ determines whether case is significant or ignored. */)
2715 if (NILP (buf2)) 2714 if (NILP (buf2))
2716 nsberror (buffer2); 2715 nsberror (buffer2);
2717 bp2 = XBUFFER (buf2); 2716 bp2 = XBUFFER (buf2);
2718 if (NILP (BVAR (bp2, name))) 2717 if (!BUFFER_LIVE_P (bp2))
2719 error ("Selecting deleted buffer"); 2718 error ("Selecting deleted buffer");
2720 } 2719 }
2721 2720
@@ -2783,8 +2782,8 @@ determines whether case is significant or ignored. */)
2783 2782
2784 if (!NILP (trt)) 2783 if (!NILP (trt))
2785 { 2784 {
2786 c1 = CHAR_TABLE_TRANSLATE (trt, c1); 2785 c1 = char_table_translate (trt, c1);
2787 c2 = CHAR_TABLE_TRANSLATE (trt, c2); 2786 c2 = char_table_translate (trt, c2);
2788 } 2787 }
2789 if (c1 < c2) 2788 if (c1 < c2)
2790 return make_number (- 1 - chars); 2789 return make_number (- 1 - chars);
@@ -4263,7 +4262,7 @@ usage: (format STRING &rest OBJECTS) */)
4263 } 4262 }
4264 4263
4265 if (bufsize < p - buf) 4264 if (bufsize < p - buf)
4266 abort (); 4265 emacs_abort ();
4267 4266
4268 if (maybe_combine_byte) 4267 if (maybe_combine_byte)
4269 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf); 4268 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf);
@@ -4603,7 +4602,7 @@ Transposing beyond buffer boundaries is an error. */)
4603 len1_byte, end2, start2_byte + len2_byte) 4602 len1_byte, end2, start2_byte + len2_byte)
4604 || count_combining_after (BYTE_POS_ADDR (start1_byte), 4603 || count_combining_after (BYTE_POS_ADDR (start1_byte),
4605 len1_byte, end2, start2_byte + len2_byte)) 4604 len1_byte, end2, start2_byte + len2_byte))
4606 abort (); 4605 emacs_abort ();
4607 } 4606 }
4608 else 4607 else
4609 { 4608 {
@@ -4615,7 +4614,7 @@ Transposing beyond buffer boundaries is an error. */)
4615 len2_byte, end1, start1_byte + len1_byte) 4614 len2_byte, end1, start1_byte + len1_byte)
4616 || count_combining_after (BYTE_POS_ADDR (start1_byte), 4615 || count_combining_after (BYTE_POS_ADDR (start1_byte),
4617 len1_byte, end2, start2_byte + len2_byte)) 4616 len1_byte, end2, start2_byte + len2_byte))
4618 abort (); 4617 emacs_abort ();
4619 } 4618 }
4620#endif 4619#endif
4621 4620
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/>. */
20 20
21 21
22#include <config.h> 22#include <config.h>
23#include <signal.h>
24#include <errno.h> 23#include <errno.h>
25#include <stdio.h> 24#include <stdio.h>
26 25
27#include <sys/types.h> 26#include <sys/types.h>
28#include <sys/file.h> 27#include <sys/file.h>
29#include <setjmp.h>
30#include <unistd.h> 28#include <unistd.h>
31 29
32#include "lisp.h" 30#include "lisp.h"
@@ -101,15 +99,15 @@ extern void moncontrol (int mode);
101#endif 99#endif
102 100
103static const char emacs_version[] = VERSION; 101static const char emacs_version[] = VERSION;
104static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc."; 102static const char emacs_copyright[] = COPYRIGHT;
105 103
106/* Empty lisp strings. To avoid having to build any others. */ 104/* Empty lisp strings. To avoid having to build any others. */
107Lisp_Object empty_unibyte_string, empty_multibyte_string; 105Lisp_Object empty_unibyte_string, empty_multibyte_string;
108 106
109/* Set nonzero after Emacs has started up the first time. 107/* Set after Emacs has started up the first time.
110 Prevents reinitialization of the Lisp world and keymaps 108 Prevents reinitialization of the Lisp world and keymaps
111 on subsequent starts. */ 109 on subsequent starts. */
112int initialized; 110bool initialized;
113 111
114#ifdef DARWIN_OS 112#ifdef DARWIN_OS
115extern void unexec_init_emacs_zone (void); 113extern void unexec_init_emacs_zone (void);
@@ -123,9 +121,9 @@ static void *malloc_state_ptr;
123extern void *malloc_get_state (void); 121extern void *malloc_get_state (void);
124/* From glibc, a routine that overwrites the malloc internal state. */ 122/* From glibc, a routine that overwrites the malloc internal state. */
125extern int malloc_set_state (void*); 123extern int malloc_set_state (void*);
126/* Non-zero if the MALLOC_CHECK_ environment variable was set while 124/* True if the MALLOC_CHECK_ environment variable was set while
127 dumping. Used to work around a bug in glibc's malloc. */ 125 dumping. Used to work around a bug in glibc's malloc. */
128static int malloc_using_checking; 126static bool malloc_using_checking;
129#endif 127#endif
130 128
131Lisp_Object Qfile_name_handler_alist; 129Lisp_Object Qfile_name_handler_alist;
@@ -134,17 +132,17 @@ Lisp_Object Qrisky_local_variable;
134 132
135Lisp_Object Qkill_emacs; 133Lisp_Object Qkill_emacs;
136 134
137/* If non-zero, Emacs should not attempt to use a window-specific code, 135/* If true, Emacs should not attempt to use a window-specific code,
138 but instead should use the virtual terminal under which it was started. */ 136 but instead should use the virtual terminal under which it was started. */
139int inhibit_window_system; 137bool inhibit_window_system;
140 138
141/* If non-zero, a filter or a sentinel is running. Tested to save the match 139/* If true, a filter or a sentinel is running. Tested to save the match
142 data on the first attempt to change it inside asynchronous code. */ 140 data on the first attempt to change it inside asynchronous code. */
143int running_asynch_code; 141bool running_asynch_code;
144 142
145#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 143#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
146/* If non-zero, -d was specified, meaning we're using some window system. */ 144/* If true, -d was specified, meaning we're using some window system. */
147int display_arg; 145bool display_arg;
148#endif 146#endif
149 147
150/* An address near the bottom of the stack. 148/* An address near the bottom of the stack.
@@ -177,11 +175,11 @@ static uprintmax_t heap_bss_diff;
177# define DAEMON_MUST_EXEC 175# define DAEMON_MUST_EXEC
178#endif 176#endif
179 177
180/* Nonzero means running Emacs without interactive terminal. */ 178/* True means running Emacs without interactive terminal. */
181int noninteractive; 179bool noninteractive;
182 180
183/* Nonzero means remove site-lisp directories from load-path. */ 181/* True means remove site-lisp directories from load-path. */
184int no_site_lisp; 182bool no_site_lisp;
185 183
186/* Name for the server started by the daemon.*/ 184/* Name for the server started by the daemon.*/
187static char *daemon_name; 185static char *daemon_name;
@@ -299,16 +297,8 @@ section of the Emacs manual or the file BUGS.\n"
299/* Signal code for the fatal signal that was received. */ 297/* Signal code for the fatal signal that was received. */
300static int fatal_error_code; 298static int fatal_error_code;
301 299
302/* Nonzero if handling a fatal error already. */ 300/* True if handling a fatal error already. */
303int fatal_error_in_progress; 301bool fatal_error_in_progress;
304
305#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
306/* When compiled with GTK and running under Gnome,
307 multiple threads may be created. Keep track of our main
308 thread to make sure signals are delivered to it (see syssignal.h). */
309
310pthread_t main_thread;
311#endif
312 302
313#ifdef HAVE_NS 303#ifdef HAVE_NS
314/* NS autrelease pool, for memory management. */ 304/* NS autrelease pool, for memory management. */
@@ -318,13 +308,23 @@ static void *ns_pool;
318 308
319 309
320/* Handle bus errors, invalid instruction, etc. */ 310/* Handle bus errors, invalid instruction, etc. */
321#ifndef FLOAT_CATCH_SIGILL 311static void
322static 312handle_fatal_signal (int sig)
323#endif 313{
324void 314 fatal_error_backtrace (sig, 10);
325fatal_error_signal (int sig) 315}
316
317static void
318deliver_fatal_signal (int sig)
319{
320 handle_on_main_thread (sig, handle_fatal_signal);
321}
322
323/* Report a fatal error due to signal SIG, output a backtrace of at
324 most BACKTRACE_LIMIT lines, and exit. */
325_Noreturn void
326fatal_error_backtrace (int sig, int backtrace_limit)
326{ 327{
327 SIGNAL_THREAD_CHECK (sig);
328 fatal_error_code = sig; 328 fatal_error_code = sig;
329 signal (sig, SIG_DFL); 329 signal (sig, SIG_DFL);
330 330
@@ -338,7 +338,8 @@ fatal_error_signal (int sig)
338 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) 338 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT)
339 Fkill_emacs (make_number (sig)); 339 Fkill_emacs (make_number (sig));
340 340
341 shut_down_emacs (sig, 0, Qnil); 341 shut_down_emacs (sig, Qnil);
342 emacs_backtrace (backtrace_limit);
342 } 343 }
343 344
344 /* Signal the same code; this time it will really be fatal. 345 /* Signal the same code; this time it will really be fatal.
@@ -346,43 +347,44 @@ fatal_error_signal (int sig)
346 going to send is probably blocked, so we have to unblock it if we 347 going to send is probably blocked, so we have to unblock it if we
347 want to really receive it. */ 348 want to really receive it. */
348#ifndef MSDOS 349#ifndef MSDOS
349 sigunblock (sigmask (fatal_error_code)); 350 {
351 sigset_t unblocked;
352 sigemptyset (&unblocked);
353 sigaddset (&unblocked, fatal_error_code);
354 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
355 }
350#endif 356#endif
351 357
352 kill (getpid (), fatal_error_code); 358 kill (getpid (), fatal_error_code);
359
360 /* This shouldn't be executed, but it prevents a warning. */
361 exit (1);
353} 362}
354 363
355#ifdef SIGDANGER 364#ifdef SIGDANGER
356 365
357/* Handler for SIGDANGER. */ 366/* Handler for SIGDANGER. */
358void 367static void deliver_danger_signal (int);
359memory_warning_signal (int sig) 368
369static void
370handle_danger_signal (int sig)
360{ 371{
361 signal (sig, memory_warning_signal); 372 struct sigaction action;
362 SIGNAL_THREAD_CHECK (sig); 373 emacs_sigaction_init (&action, deliver_danger_signal);
374 sigaction (sig, &action, 0);
363 375
364 malloc_warning ("Operating system warns that virtual memory is running low.\n"); 376 malloc_warning ("Operating system warns that virtual memory is running low.\n");
365 377
366 /* It might be unsafe to call do_auto_save now. */ 378 /* It might be unsafe to call do_auto_save now. */
367 force_auto_save_soon (); 379 force_auto_save_soon ();
368} 380}
369#endif
370
371/* We define abort, rather than using it from the library,
372 so that GDB can return from a breakpoint here.
373 MSDOS has its own definition in msdos.c. */
374 381
375#if ! defined (DOS_NT) && ! defined (NO_ABORT) 382static void
376 383deliver_danger_signal (int sig)
377void
378abort (void)
379{ 384{
380 kill (getpid (), SIGABRT); 385 handle_on_main_thread (sig, handle_danger_signal);
381 /* This shouldn't be executed, but it prevents a warning. */
382 exit (1);
383} 386}
384#endif 387#endif
385
386 388
387/* Code for dealing with Lisp access to the Unix command line. */ 389/* Code for dealing with Lisp access to the Unix command line. */
388 390
@@ -595,7 +597,7 @@ DEFINE_DUMMY_FUNCTION (__main)
595 Too bad we can't just use getopt for all of this, but we don't have 597 Too bad we can't just use getopt for all of this, but we don't have
596 enough information to do it right. */ 598 enough information to do it right. */
597 599
598static int 600static bool
599argmatch (char **argv, int argc, const char *sstr, const char *lstr, 601argmatch (char **argv, int argc, const char *sstr, const char *lstr,
600 int minlen, char **valptr, int *skipptr) 602 int minlen, char **valptr, int *skipptr)
601{ 603{
@@ -702,18 +704,19 @@ main (int argc, char **argv)
702 Lisp_Object dummy; 704 Lisp_Object dummy;
703#endif 705#endif
704 char stack_bottom_variable; 706 char stack_bottom_variable;
705 int do_initial_setlocale; 707 bool do_initial_setlocale;
706 int skip_args = 0; 708 int skip_args = 0;
707#ifdef HAVE_SETRLIMIT 709#ifdef HAVE_SETRLIMIT
708 struct rlimit rlim; 710 struct rlimit rlim;
709#endif 711#endif
710 int no_loadup = 0; 712 bool no_loadup = 0;
711 char *junk = 0; 713 char *junk = 0;
712 char *dname_arg = 0; 714 char *dname_arg = 0;
713#ifdef DAEMON_MUST_EXEC 715#ifdef DAEMON_MUST_EXEC
714 char dname_arg2[80]; 716 char dname_arg2[80];
715#endif /* DAEMON_MUST_EXEC */ 717#endif /* DAEMON_MUST_EXEC */
716 char *ch_to_dir; 718 char *ch_to_dir;
719 struct sigaction fatal_error_action;
717 720
718#if GC_MARK_STACK 721#if GC_MARK_STACK
719 stack_base = &dummy; 722 stack_base = &dummy;
@@ -872,20 +875,12 @@ main (int argc, char **argv)
872 /* Arrange to get warning messages as memory fills up. */ 875 /* Arrange to get warning messages as memory fills up. */
873 memory_warnings (0, malloc_warning); 876 memory_warnings (0, malloc_warning);
874 877
875 /* Call malloc at least once, to run the initial __malloc_hook. 878 /* Call malloc at least once, to run malloc_initialize_hook.
876 Also call realloc and free for consistency. */ 879 Also call realloc and free for consistency. */
877 free (realloc (malloc (4), 4)); 880 free (realloc (malloc (4), 4));
878 881
879# ifndef SYNC_INPUT
880 /* Arrange to disable interrupt input inside malloc etc. */
881 uninterrupt_malloc ();
882# endif /* not SYNC_INPUT */
883#endif /* not SYSTEM_MALLOC */ 882#endif /* not SYSTEM_MALLOC */
884 883
885#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
886 main_thread = pthread_self ();
887#endif /* FORWARD_SIGNAL_TO_MAIN_THREAD */
888
889#if defined (MSDOS) || defined (WINDOWSNT) 884#if defined (MSDOS) || defined (WINDOWSNT)
890 /* We do all file input/output as binary files. When we need to translate 885 /* We do all file input/output as binary files. When we need to translate
891 newlines, we do that manually. */ 886 newlines, we do that manually. */
@@ -1132,6 +1127,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1132 } 1127 }
1133 1128
1134 init_signals (); 1129 init_signals ();
1130 emacs_sigaction_init (&fatal_error_action, deliver_fatal_signal);
1135 1131
1136 /* Don't catch SIGHUP if dumping. */ 1132 /* Don't catch SIGHUP if dumping. */
1137 if (1 1133 if (1
@@ -1140,13 +1136,17 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1140#endif 1136#endif
1141 ) 1137 )
1142 { 1138 {
1143 sigblock (sigmask (SIGHUP));
1144 /* In --batch mode, don't catch SIGHUP if already ignored. 1139 /* In --batch mode, don't catch SIGHUP if already ignored.
1145 That makes nohup work. */ 1140 That makes nohup work. */
1146 if (! noninteractive 1141 bool catch_SIGHUP = !noninteractive;
1147 || signal (SIGHUP, SIG_IGN) != SIG_IGN) 1142 if (!catch_SIGHUP)
1148 signal (SIGHUP, fatal_error_signal); 1143 {
1149 sigunblock (sigmask (SIGHUP)); 1144 struct sigaction old_action;
1145 sigaction (SIGHUP, 0, &old_action);
1146 catch_SIGHUP = old_action.sa_handler != SIG_IGN;
1147 }
1148 if (catch_SIGHUP)
1149 sigaction (SIGHUP, &fatal_error_action, 0);
1150 } 1150 }
1151 1151
1152 if ( 1152 if (
@@ -1160,9 +1160,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1160 /* Don't catch these signals in batch mode if dumping. 1160 /* Don't catch these signals in batch mode if dumping.
1161 On some machines, this sets static data that would make 1161 On some machines, this sets static data that would make
1162 signal fail to work right when the dumped Emacs is run. */ 1162 signal fail to work right when the dumped Emacs is run. */
1163 signal (SIGQUIT, fatal_error_signal); 1163 sigaction (SIGQUIT, &fatal_error_action, 0);
1164 signal (SIGILL, fatal_error_signal); 1164 sigaction (SIGILL, &fatal_error_action, 0);
1165 signal (SIGTRAP, fatal_error_signal); 1165 sigaction (SIGTRAP, &fatal_error_action, 0);
1166#ifdef SIGUSR1 1166#ifdef SIGUSR1
1167 add_user_signal (SIGUSR1, "sigusr1"); 1167 add_user_signal (SIGUSR1, "sigusr1");
1168#endif 1168#endif
@@ -1170,68 +1170,73 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1170 add_user_signal (SIGUSR2, "sigusr2"); 1170 add_user_signal (SIGUSR2, "sigusr2");
1171#endif 1171#endif
1172#ifdef SIGABRT 1172#ifdef SIGABRT
1173 signal (SIGABRT, fatal_error_signal); 1173 sigaction (SIGABRT, &fatal_error_action, 0);
1174#endif 1174#endif
1175#ifdef SIGHWE 1175#ifdef SIGHWE
1176 signal (SIGHWE, fatal_error_signal); 1176 sigaction (SIGHWE, &fatal_error_action, 0);
1177#endif 1177#endif
1178#ifdef SIGPRE 1178#ifdef SIGPRE
1179 signal (SIGPRE, fatal_error_signal); 1179 sigaction (SIGPRE, &fatal_error_action, 0);
1180#endif 1180#endif
1181#ifdef SIGORE 1181#ifdef SIGORE
1182 signal (SIGORE, fatal_error_signal); 1182 sigaction (SIGORE, &fatal_error_action, 0);
1183#endif 1183#endif
1184#ifdef SIGUME 1184#ifdef SIGUME
1185 signal (SIGUME, fatal_error_signal); 1185 sigaction (SIGUME, &fatal_error_action, 0);
1186#endif 1186#endif
1187#ifdef SIGDLK 1187#ifdef SIGDLK
1188 signal (SIGDLK, fatal_error_signal); 1188 sigaction (SIGDLK, &fatal_error_action, 0);
1189#endif 1189#endif
1190#ifdef SIGCPULIM 1190#ifdef SIGCPULIM
1191 signal (SIGCPULIM, fatal_error_signal); 1191 sigaction (SIGCPULIM, &fatal_error_action, 0);
1192#endif 1192#endif
1193#ifdef SIGIOT 1193#ifdef SIGIOT
1194 /* This is missing on some systems - OS/2, for example. */ 1194 /* This is missing on some systems - OS/2, for example. */
1195 signal (SIGIOT, fatal_error_signal); 1195 sigaction (SIGIOT, &fatal_error_action, 0);
1196#endif 1196#endif
1197#ifdef SIGEMT 1197#ifdef SIGEMT
1198 signal (SIGEMT, fatal_error_signal); 1198 sigaction (SIGEMT, &fatal_error_action, 0);
1199#endif 1199#endif
1200 signal (SIGFPE, fatal_error_signal); 1200 sigaction (SIGFPE, &fatal_error_action, 0);
1201#ifdef SIGBUS 1201#ifdef SIGBUS
1202 signal (SIGBUS, fatal_error_signal); 1202 sigaction (SIGBUS, &fatal_error_action, 0);
1203#endif 1203#endif
1204 signal (SIGSEGV, fatal_error_signal); 1204 sigaction (SIGSEGV, &fatal_error_action, 0);
1205#ifdef SIGSYS 1205#ifdef SIGSYS
1206 signal (SIGSYS, fatal_error_signal); 1206 sigaction (SIGSYS, &fatal_error_action, 0);
1207#endif 1207#endif
1208 /* May need special treatment on MS-Windows. See 1208 /* May need special treatment on MS-Windows. See
1209 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html 1209 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
1210 Please update the doc of kill-emacs, kill-emacs-hook, and 1210 Please update the doc of kill-emacs, kill-emacs-hook, and
1211 NEWS if you change this. 1211 NEWS if you change this.
1212 */ 1212 */
1213 if (noninteractive) signal (SIGINT, fatal_error_signal); 1213 if (noninteractive)
1214 signal (SIGTERM, fatal_error_signal); 1214 sigaction (SIGINT, &fatal_error_action, 0);
1215 sigaction (SIGTERM, &fatal_error_action, 0);
1215#ifdef SIGXCPU 1216#ifdef SIGXCPU
1216 signal (SIGXCPU, fatal_error_signal); 1217 sigaction (SIGXCPU, &fatal_error_action, 0);
1217#endif 1218#endif
1218#ifdef SIGXFSZ 1219#ifdef SIGXFSZ
1219 signal (SIGXFSZ, fatal_error_signal); 1220 sigaction (SIGXFSZ, &fatal_error_action, 0);
1220#endif /* SIGXFSZ */ 1221#endif /* SIGXFSZ */
1221 1222
1222#ifdef SIGDANGER 1223#ifdef SIGDANGER
1223 /* This just means available memory is getting low. */ 1224 /* This just means available memory is getting low. */
1224 signal (SIGDANGER, memory_warning_signal); 1225 {
1226 struct sigaction action;
1227 emacs_sigaction_init (&action, deliver_danger_signal);
1228 sigaction (SIGDANGER, &action, 0);
1229 }
1225#endif 1230#endif
1226 1231
1227#ifdef AIX 1232#ifdef AIX
1228/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */ 1233/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
1229 signal (SIGXCPU, fatal_error_signal); 1234 sigaction (SIGXCPU, &fatal_error_action, 0);
1230 signal (SIGIOINT, fatal_error_signal); 1235 sigaction (SIGIOINT, &fatal_error_action, 0);
1231 signal (SIGGRANT, fatal_error_signal); 1236 sigaction (SIGGRANT, &fatal_error_action, 0);
1232 signal (SIGRETRACT, fatal_error_signal); 1237 sigaction (SIGRETRACT, &fatal_error_action, 0);
1233 signal (SIGSOUND, fatal_error_signal); 1238 sigaction (SIGSOUND, &fatal_error_action, 0);
1234 signal (SIGMSG, fatal_error_signal); 1239 sigaction (SIGMSG, &fatal_error_action, 0);
1235#endif /* AIX */ 1240#endif /* AIX */
1236 } 1241 }
1237 1242
@@ -1607,7 +1612,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1607 init_fringe (); 1612 init_fringe ();
1608#endif /* HAVE_WINDOW_SYSTEM */ 1613#endif /* HAVE_WINDOW_SYSTEM */
1609 init_macros (); 1614 init_macros ();
1610 init_floatfns ();
1611 init_window (); 1615 init_window ();
1612 init_font (); 1616 init_font ();
1613 1617
@@ -1922,7 +1926,7 @@ sort_args (int argc, char **argv)
1922 } 1926 }
1923 1927
1924 if (best < 0) 1928 if (best < 0)
1925 abort (); 1929 emacs_abort ();
1926 1930
1927 /* Copy the highest priority remaining option, with its args, to NEW. 1931 /* Copy the highest priority remaining option, with its args, to NEW.
1928 Unless it is a duplicate of the previous one. */ 1932 Unless it is a duplicate of the previous one. */
@@ -1985,7 +1989,7 @@ all of which are called before Emacs is actually killed. */)
1985 x_clipboard_manager_save_all (); 1989 x_clipboard_manager_save_all ();
1986#endif 1990#endif
1987 1991
1988 shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); 1992 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
1989 1993
1990#ifdef HAVE_NS 1994#ifdef HAVE_NS
1991 ns_release_autorelease_pool (ns_pool); 1995 ns_release_autorelease_pool (ns_pool);
@@ -2021,7 +2025,7 @@ all of which are called before Emacs is actually killed. */)
2021 and Fkill_emacs. */ 2025 and Fkill_emacs. */
2022 2026
2023void 2027void
2024shut_down_emacs (int sig, int no_x, Lisp_Object stuff) 2028shut_down_emacs (int sig, Lisp_Object stuff)
2025{ 2029{
2026 /* Prevent running of hooks from now on. */ 2030 /* Prevent running of hooks from now on. */
2027 Vrun_hooks = Qnil; 2031 Vrun_hooks = Qnil;
@@ -2038,7 +2042,7 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
2038 { 2042 {
2039 reset_all_sys_modes (); 2043 reset_all_sys_modes ();
2040 if (sig && sig != SIGTERM) 2044 if (sig && sig != SIGTERM)
2041 fprintf (stderr, "Fatal error (%d)", sig); 2045 fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig));
2042 } 2046 }
2043 } 2047 }
2044#else 2048#else
@@ -2056,23 +2060,10 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
2056 unlock_all_files (); 2060 unlock_all_files ();
2057#endif 2061#endif
2058 2062
2059#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
2060#ifdef HAVE_X_WINDOWS
2061 /* It's not safe to call intern here. Maybe we are crashing. */
2062 if (!noninteractive && SYMBOLP (Vinitial_window_system)
2063 && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1
2064 && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x'
2065 && ! no_x)
2066 Fx_close_current_connection ();
2067#endif /* HAVE_X_WINDOWS */
2068#endif
2069
2070#ifdef SIGIO
2071 /* There is a tendency for a SIGIO signal to arrive within exit, 2063 /* There is a tendency for a SIGIO signal to arrive within exit,
2072 and cause a SIGHUP because the input descriptor is already closed. */ 2064 and cause a SIGHUP because the input descriptor is already closed. */
2073 unrequest_sigio (); 2065 unrequest_sigio ();
2074 signal (SIGIO, SIG_IGN); 2066 ignore_sigio ();
2075#endif
2076 2067
2077#ifdef WINDOWSNT 2068#ifdef WINDOWSNT
2078 term_ntproc (); 2069 term_ntproc ();
@@ -2178,12 +2169,6 @@ You must run Emacs in batch mode in order to dump it. */)
2178 memory_warnings (my_edata, malloc_warning); 2169 memory_warnings (my_edata, malloc_warning);
2179 } 2170 }
2180#endif /* not WINDOWSNT */ 2171#endif /* not WINDOWSNT */
2181#if defined (HAVE_PTHREAD) && !defined SYNC_INPUT
2182 /* Pthread may call malloc before main, and then we will get an endless
2183 loop, because pthread_self (see alloc.c) calls malloc the first time
2184 it is called on some systems. */
2185 reset_malloc_hooks ();
2186#endif
2187#endif /* not SYSTEM_MALLOC */ 2172#endif /* not SYSTEM_MALLOC */
2188#ifdef DOUG_LEA_MALLOC 2173#ifdef DOUG_LEA_MALLOC
2189 malloc_state_ptr = malloc_get_state (); 2174 malloc_state_ptr = malloc_get_state ();
@@ -2258,7 +2243,7 @@ decode_env_path (const char *evarname, const char *defalt)
2258 const char *path, *p; 2243 const char *path, *p;
2259 Lisp_Object lpath, element, tem; 2244 Lisp_Object lpath, element, tem;
2260#ifdef WINDOWSNT 2245#ifdef WINDOWSNT
2261 int defaulted = 0; 2246 bool defaulted = 0;
2262 const char *emacs_dir = egetenv ("emacs_dir"); 2247 const char *emacs_dir = egetenv ("emacs_dir");
2263 static const char *emacs_dir_env = "%emacs_dir%/"; 2248 static const char *emacs_dir_env = "%emacs_dir%/";
2264 const size_t emacs_dir_len = strlen (emacs_dir_env); 2249 const size_t emacs_dir_len = strlen (emacs_dir_env);
@@ -2354,7 +2339,7 @@ from the parent process and its tty file descriptors. */)
2354 (void) 2339 (void)
2355{ 2340{
2356 int nfd; 2341 int nfd;
2357 int err = 0; 2342 bool err = 0;
2358 2343
2359 if (!IS_DAEMON) 2344 if (!IS_DAEMON)
2360 error ("This function can only be called if emacs is run as a daemon"); 2345 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/>. */
21#include <config.h> 21#include <config.h>
22 22
23#include "emacsgtkfixed.h" 23#include "emacsgtkfixed.h"
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h> 25
27#include "lisp.h" 26#include "lisp.h"
28#include "frame.h" 27#include "frame.h"
29#include "xterm.h" 28#include "xterm.h"
30 29
30/* Silence a bogus diagnostic; see GNOME bug 683906. */
31#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
32# pragma GCC diagnostic push
33# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
34#endif
35
31#define EMACS_TYPE_FIXED emacs_fixed_get_type () 36#define EMACS_TYPE_FIXED emacs_fixed_get_type ()
32#define EMACS_FIXED(obj) \ 37#define EMACS_FIXED(obj) \
33 G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed) 38 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/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <limits.h> 21#include <limits.h>
22#include <setjmp.h>
23#include <stdio.h> 22#include <stdio.h>
24#include "lisp.h" 23#include "lisp.h"
25#include "blockinput.h" 24#include "blockinput.h"
@@ -69,7 +68,7 @@ Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp;
69Lisp_Object Qinhibit_quit; 68Lisp_Object Qinhibit_quit;
70Lisp_Object Qand_rest; 69Lisp_Object Qand_rest;
71static Lisp_Object Qand_optional; 70static Lisp_Object Qand_optional;
72static Lisp_Object Qdebug_on_error; 71static Lisp_Object Qinhibit_debugger;
73static Lisp_Object Qdeclare; 72static Lisp_Object Qdeclare;
74Lisp_Object Qinternal_interpreter_environment, Qclosure; 73Lisp_Object Qinternal_interpreter_environment, Qclosure;
75 74
@@ -118,12 +117,6 @@ static EMACS_INT when_entered_debugger;
118 117
119Lisp_Object Vsignaling_function; 118Lisp_Object Vsignaling_function;
120 119
121/* Set to non-zero while processing X events. Checked in Feval to
122 make sure the Lisp interpreter isn't called from a signal handler,
123 which is unsafe because the interpreter isn't reentrant. */
124
125int handling_signal;
126
127/* If non-nil, Lisp code must not be run since some part of Emacs is 120/* If non-nil, Lisp code must not be run since some part of Emacs is
128 in an inconsistent state. Currently, x-create-frame uses this to 121 in an inconsistent state. Currently, x-create-frame uses this to
129 avoid triggering window-configuration-change-hook while the new 122 avoid triggering window-configuration-change-hook while the new
@@ -131,7 +124,7 @@ int handling_signal;
131Lisp_Object inhibit_lisp_code; 124Lisp_Object inhibit_lisp_code;
132 125
133static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); 126static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
134static int interactive_p (int); 127static bool interactive_p (void);
135static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); 128static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
136 129
137/* Functions to set Lisp_Object slots of struct specbinding. */ 130/* Functions to set Lisp_Object slots of struct specbinding. */
@@ -191,10 +184,10 @@ restore_stack_limits (Lisp_Object data)
191 184
192/* Call the Lisp debugger, giving it argument ARG. */ 185/* Call the Lisp debugger, giving it argument ARG. */
193 186
194static Lisp_Object 187Lisp_Object
195call_debugger (Lisp_Object arg) 188call_debugger (Lisp_Object arg)
196{ 189{
197 int debug_while_redisplaying; 190 bool debug_while_redisplaying;
198 ptrdiff_t count = SPECPDL_INDEX (); 191 ptrdiff_t count = SPECPDL_INDEX ();
199 Lisp_Object val; 192 Lisp_Object val;
200 EMACS_INT old_max = max_specpdl_size; 193 EMACS_INT old_max = max_specpdl_size;
@@ -229,7 +222,7 @@ call_debugger (Lisp_Object arg)
229 specbind (intern ("debugger-may-continue"), 222 specbind (intern ("debugger-may-continue"),
230 debug_while_redisplaying ? Qnil : Qt); 223 debug_while_redisplaying ? Qnil : Qt);
231 specbind (Qinhibit_redisplay, Qnil); 224 specbind (Qinhibit_redisplay, Qnil);
232 specbind (Qdebug_on_error, Qnil); 225 specbind (Qinhibit_debugger, Qt);
233 226
234#if 0 /* Binding this prevents execution of Lisp code during 227#if 0 /* Binding this prevents execution of Lisp code during
235 redisplay, which necessarily leads to display problems. */ 228 redisplay, which necessarily leads to display problems. */
@@ -525,7 +518,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
525use `called-interactively-p'. */) 518use `called-interactively-p'. */)
526 (void) 519 (void)
527{ 520{
528 return interactive_p (1) ? Qt : Qnil; 521 return interactive_p () ? Qt : Qnil;
529} 522}
530 523
531 524
@@ -550,19 +543,17 @@ non-nil unconditionally (\"p\" is a good way to do this), or via
550\(not (or executing-kbd-macro noninteractive)). */) 543\(not (or executing-kbd-macro noninteractive)). */)
551 (Lisp_Object kind) 544 (Lisp_Object kind)
552{ 545{
553 return ((INTERACTIVE || !EQ (kind, intern ("interactive"))) 546 return (((INTERACTIVE || !EQ (kind, intern ("interactive")))
554 && interactive_p (1)) ? Qt : Qnil; 547 && interactive_p ())
548 ? Qt : Qnil);
555} 549}
556 550
557 551
558/* Return 1 if function in which this appears was called using 552/* Return true if function in which this appears was called using
559 call-interactively. 553 call-interactively and is not a built-in. */
560 554
561 EXCLUDE_SUBRS_P non-zero means always return 0 if the function 555static bool
562 called is a built-in. */ 556interactive_p (void)
563
564static int
565interactive_p (int exclude_subrs_p)
566{ 557{
567 struct backtrace *btp; 558 struct backtrace *btp;
568 Lisp_Object fun; 559 Lisp_Object fun;
@@ -591,9 +582,9 @@ interactive_p (int exclude_subrs_p)
591 /* `btp' now points at the frame of the innermost function that isn't 582 /* `btp' now points at the frame of the innermost function that isn't
592 a special form, ignoring frames for Finteractive_p and/or 583 a special form, ignoring frames for Finteractive_p and/or
593 Fbytecode at the top. If this frame is for a built-in function 584 Fbytecode at the top. If this frame is for a built-in function
594 (such as load or eval-region) return nil. */ 585 (such as load or eval-region) return false. */
595 fun = Findirect_function (*btp->function, Qnil); 586 fun = Findirect_function (*btp->function, Qnil);
596 if (exclude_subrs_p && SUBRP (fun)) 587 if (SUBRP (fun))
597 return 0; 588 return 0;
598 589
599 /* `btp' points to the frame of a Lisp function that called interactive-p. 590 /* `btp' points to the frame of a Lisp function that called interactive-p.
@@ -709,7 +700,7 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
709 else 700 else
710 { /* Check if there is really a global binding rather than just a let 701 { /* Check if there is really a global binding rather than just a let
711 binding that shadows the global unboundness of the var. */ 702 binding that shadows the global unboundness of the var. */
712 volatile struct specbinding *pdl = specpdl_ptr; 703 struct specbinding *pdl = specpdl_ptr;
713 while (pdl > specpdl) 704 while (pdl > specpdl)
714 { 705 {
715 if (EQ ((--pdl)->symbol, sym) && !pdl->func 706 if (EQ ((--pdl)->symbol, sym) && !pdl->func
@@ -1074,7 +1065,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1074 catchlist = &c; 1065 catchlist = &c;
1075 1066
1076 /* Call FUNC. */ 1067 /* Call FUNC. */
1077 if (! _setjmp (c.jmp)) 1068 if (! sys_setjmp (c.jmp))
1078 c.val = (*func) (arg); 1069 c.val = (*func) (arg);
1079 1070
1080 /* Throw works by a longjmp that comes right here. */ 1071 /* 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
1101static _Noreturn void 1092static _Noreturn void
1102unwind_to_catch (struct catchtag *catch, Lisp_Object value) 1093unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1103{ 1094{
1104 int last_time; 1095 bool last_time;
1105 1096
1106 /* Save the value in the tag. */ 1097 /* Save the value in the tag. */
1107 catch->val = value; 1098 catch->val = value;
@@ -1109,7 +1100,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1109 /* Restore certain special C variables. */ 1100 /* Restore certain special C variables. */
1110 set_poll_suppress_count (catch->poll_suppress_count); 1101 set_poll_suppress_count (catch->poll_suppress_count);
1111 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked); 1102 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked);
1112 handling_signal = 0;
1113 immediate_quit = 0; 1103 immediate_quit = 0;
1114 1104
1115 do 1105 do
@@ -1142,7 +1132,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1142 backtrace_list = catch->backlist; 1132 backtrace_list = catch->backlist;
1143 lisp_eval_depth = catch->lisp_eval_depth; 1133 lisp_eval_depth = catch->lisp_eval_depth;
1144 1134
1145 _longjmp (catch->jmp, 1); 1135 sys_longjmp (catch->jmp, 1);
1146} 1136}
1147 1137
1148DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, 1138DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
@@ -1206,12 +1196,9 @@ See also the function `signal' for more info.
1206usage: (condition-case VAR BODYFORM &rest HANDLERS) */) 1196usage: (condition-case VAR BODYFORM &rest HANDLERS) */)
1207 (Lisp_Object args) 1197 (Lisp_Object args)
1208{ 1198{
1209 register Lisp_Object bodyform, handlers; 1199 Lisp_Object var = Fcar (args);
1210 volatile Lisp_Object var; 1200 Lisp_Object bodyform = Fcar (Fcdr (args));
1211 1201 Lisp_Object handlers = Fcdr (Fcdr (args));
1212 var = Fcar (args);
1213 bodyform = Fcar (Fcdr (args));
1214 handlers = Fcdr (Fcdr (args));
1215 1202
1216 return internal_lisp_condition_case (var, bodyform, handlers); 1203 return internal_lisp_condition_case (var, bodyform, handlers);
1217} 1204}
@@ -1251,7 +1238,7 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform,
1251 c.interrupt_input_blocked = interrupt_input_blocked; 1238 c.interrupt_input_blocked = interrupt_input_blocked;
1252 c.gcpro = gcprolist; 1239 c.gcpro = gcprolist;
1253 c.byte_stack = byte_stack_list; 1240 c.byte_stack = byte_stack_list;
1254 if (_setjmp (c.jmp)) 1241 if (sys_setjmp (c.jmp))
1255 { 1242 {
1256 if (!NILP (h.var)) 1243 if (!NILP (h.var))
1257 specbind (h.var, c.val); 1244 specbind (h.var, c.val);
@@ -1306,7 +1293,7 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers,
1306 c.interrupt_input_blocked = interrupt_input_blocked; 1293 c.interrupt_input_blocked = interrupt_input_blocked;
1307 c.gcpro = gcprolist; 1294 c.gcpro = gcprolist;
1308 c.byte_stack = byte_stack_list; 1295 c.byte_stack = byte_stack_list;
1309 if (_setjmp (c.jmp)) 1296 if (sys_setjmp (c.jmp))
1310 { 1297 {
1311 return (*hfun) (c.val); 1298 return (*hfun) (c.val);
1312 } 1299 }
@@ -1344,7 +1331,7 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg,
1344 c.interrupt_input_blocked = interrupt_input_blocked; 1331 c.interrupt_input_blocked = interrupt_input_blocked;
1345 c.gcpro = gcprolist; 1332 c.gcpro = gcprolist;
1346 c.byte_stack = byte_stack_list; 1333 c.byte_stack = byte_stack_list;
1347 if (_setjmp (c.jmp)) 1334 if (sys_setjmp (c.jmp))
1348 { 1335 {
1349 return (*hfun) (c.val); 1336 return (*hfun) (c.val);
1350 } 1337 }
@@ -1386,7 +1373,7 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
1386 c.interrupt_input_blocked = interrupt_input_blocked; 1373 c.interrupt_input_blocked = interrupt_input_blocked;
1387 c.gcpro = gcprolist; 1374 c.gcpro = gcprolist;
1388 c.byte_stack = byte_stack_list; 1375 c.byte_stack = byte_stack_list;
1389 if (_setjmp (c.jmp)) 1376 if (sys_setjmp (c.jmp))
1390 { 1377 {
1391 return (*hfun) (c.val); 1378 return (*hfun) (c.val);
1392 } 1379 }
@@ -1430,7 +1417,7 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1430 c.interrupt_input_blocked = interrupt_input_blocked; 1417 c.interrupt_input_blocked = interrupt_input_blocked;
1431 c.gcpro = gcprolist; 1418 c.gcpro = gcprolist;
1432 c.byte_stack = byte_stack_list; 1419 c.byte_stack = byte_stack_list;
1433 if (_setjmp (c.jmp)) 1420 if (sys_setjmp (c.jmp))
1434 { 1421 {
1435 return (*hfun) (c.val, nargs, args); 1422 return (*hfun) (c.val, nargs, args);
1436 } 1423 }
@@ -1450,8 +1437,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1450 1437
1451 1438
1452static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); 1439static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object);
1453static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, 1440static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
1454 Lisp_Object data); 1441 Lisp_Object data);
1455 1442
1456void 1443void
1457process_quit_flag (void) 1444process_quit_flag (void)
@@ -1492,10 +1479,10 @@ See also the function `condition-case'. */)
1492 struct handler *h; 1479 struct handler *h;
1493 struct backtrace *bp; 1480 struct backtrace *bp;
1494 1481
1495 immediate_quit = handling_signal = 0; 1482 immediate_quit = 0;
1496 abort_on_gc = 0; 1483 abort_on_gc = 0;
1497 if (gc_in_progress || waiting_for_input) 1484 if (gc_in_progress || waiting_for_input)
1498 abort (); 1485 emacs_abort ();
1499 1486
1500#if 0 /* rms: I don't know why this was here, 1487#if 0 /* rms: I don't know why this was here,
1501 but it is surely wrong for an error that is handled. */ 1488 but it is surely wrong for an error that is handled. */
@@ -1556,7 +1543,7 @@ See also the function `condition-case'. */)
1556 if requested". */ 1543 if requested". */
1557 || EQ (h->handler, Qerror))) 1544 || EQ (h->handler, Qerror)))
1558 { 1545 {
1559 int debugger_called 1546 bool debugger_called
1560 = maybe_call_debugger (conditions, error_symbol, data); 1547 = maybe_call_debugger (conditions, error_symbol, data);
1561 /* We can't return values to code which signaled an error, but we 1548 /* We can't return values to code which signaled an error, but we
1562 can continue code which has signaled a quit. */ 1549 can continue code which has signaled a quit. */
@@ -1592,7 +1579,7 @@ void
1592xsignal (Lisp_Object error_symbol, Lisp_Object data) 1579xsignal (Lisp_Object error_symbol, Lisp_Object data)
1593{ 1580{
1594 Fsignal (error_symbol, data); 1581 Fsignal (error_symbol, data);
1595 abort (); 1582 emacs_abort ();
1596} 1583}
1597 1584
1598/* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ 1585/* 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)
1650} 1637}
1651 1638
1652 1639
1653/* Return nonzero if LIST is a non-nil atom or 1640/* Return true if LIST is a non-nil atom or
1654 a list containing one of CONDITIONS. */ 1641 a list containing one of CONDITIONS. */
1655 1642
1656static int 1643static bool
1657wants_debugger (Lisp_Object list, Lisp_Object conditions) 1644wants_debugger (Lisp_Object list, Lisp_Object conditions)
1658{ 1645{
1659 if (NILP (list)) 1646 if (NILP (list))
@@ -1673,15 +1660,15 @@ wants_debugger (Lisp_Object list, Lisp_Object conditions)
1673 return 0; 1660 return 0;
1674} 1661}
1675 1662
1676/* Return 1 if an error with condition-symbols CONDITIONS, 1663/* Return true if an error with condition-symbols CONDITIONS,
1677 and described by SIGNAL-DATA, should skip the debugger 1664 and described by SIGNAL-DATA, should skip the debugger
1678 according to debugger-ignored-errors. */ 1665 according to debugger-ignored-errors. */
1679 1666
1680static int 1667static bool
1681skip_debugger (Lisp_Object conditions, Lisp_Object data) 1668skip_debugger (Lisp_Object conditions, Lisp_Object data)
1682{ 1669{
1683 Lisp_Object tail; 1670 Lisp_Object tail;
1684 int first_string = 1; 1671 bool first_string = 1;
1685 Lisp_Object error_message; 1672 Lisp_Object error_message;
1686 1673
1687 error_message = Qnil; 1674 error_message = Qnil;
@@ -1716,7 +1703,7 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data)
1716 = SIG is the error symbol, and DATA is the rest of the data. 1703 = SIG is the error symbol, and DATA is the rest of the data.
1717 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). 1704 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1718 This is for memory-full errors only. */ 1705 This is for memory-full errors only. */
1719static int 1706static bool
1720maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) 1707maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
1721{ 1708{
1722 Lisp_Object combined_data; 1709 Lisp_Object combined_data;
@@ -1727,6 +1714,7 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
1727 /* Don't try to run the debugger with interrupts blocked. 1714 /* Don't try to run the debugger with interrupts blocked.
1728 The editing loop would return anyway. */ 1715 The editing loop would return anyway. */
1729 ! INPUT_BLOCKED_P 1716 ! INPUT_BLOCKED_P
1717 && NILP (Vinhibit_debugger)
1730 /* Does user want to enter debugger for this kind of error? */ 1718 /* Does user want to enter debugger for this kind of error? */
1731 && (EQ (sig, Qquit) 1719 && (EQ (sig, Qquit)
1732 ? debug_on_quit 1720 ? debug_on_quit
@@ -2044,9 +2032,6 @@ eval_sub (Lisp_Object form)
2044 struct backtrace backtrace; 2032 struct backtrace backtrace;
2045 struct gcpro gcpro1, gcpro2, gcpro3; 2033 struct gcpro gcpro1, gcpro2, gcpro3;
2046 2034
2047 if (handling_signal)
2048 abort ();
2049
2050 if (SYMBOLP (form)) 2035 if (SYMBOLP (form))
2051 { 2036 {
2052 /* Look up its binding in the lexical environment. 2037 /* Look up its binding in the lexical environment.
@@ -2209,7 +2194,7 @@ eval_sub (Lisp_Object form)
2209 is supported by this code. We need to either rewrite the 2194 is supported by this code. We need to either rewrite the
2210 subr to use a different argument protocol, or add more 2195 subr to use a different argument protocol, or add more
2211 cases to this switch. */ 2196 cases to this switch. */
2212 abort (); 2197 emacs_abort ();
2213 } 2198 }
2214 } 2199 }
2215 } 2200 }
@@ -2232,7 +2217,6 @@ eval_sub (Lisp_Object form)
2232 if (EQ (funcar, Qmacro)) 2217 if (EQ (funcar, Qmacro))
2233 { 2218 {
2234 ptrdiff_t count = SPECPDL_INDEX (); 2219 ptrdiff_t count = SPECPDL_INDEX ();
2235 extern Lisp_Object Qlexical_binding;
2236 Lisp_Object exp; 2220 Lisp_Object exp;
2237 /* Bind lexical-binding during expansion of the macro, so the 2221 /* Bind lexical-binding during expansion of the macro, so the
2238 macro can know reliably if the code it outputs will be 2222 macro can know reliably if the code it outputs will be
@@ -2853,7 +2837,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2853 /* If a subr takes more than 8 arguments without using MANY 2837 /* If a subr takes more than 8 arguments without using MANY
2854 or UNEVALLED, we need to extend this function to support it. 2838 or UNEVALLED, we need to extend this function to support it.
2855 Until this is done, there is no way to call the function. */ 2839 Until this is done, there is no way to call the function. */
2856 abort (); 2840 emacs_abort ();
2857 } 2841 }
2858 } 2842 }
2859 } 2843 }
@@ -2940,7 +2924,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2940 Lisp_Object val, syms_left, next, lexenv; 2924 Lisp_Object val, syms_left, next, lexenv;
2941 ptrdiff_t count = SPECPDL_INDEX (); 2925 ptrdiff_t count = SPECPDL_INDEX ();
2942 ptrdiff_t i; 2926 ptrdiff_t i;
2943 int optional, rest; 2927 bool optional, rest;
2944 2928
2945 if (CONSP (fun)) 2929 if (CONSP (fun))
2946 { 2930 {
@@ -2984,7 +2968,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2984 lexenv = Qnil; 2968 lexenv = Qnil;
2985 } 2969 }
2986 else 2970 else
2987 abort (); 2971 emacs_abort ();
2988 2972
2989 i = optional = rest = 0; 2973 i = optional = rest = 0;
2990 for (; CONSP (syms_left); syms_left = XCDR (syms_left)) 2974 for (; CONSP (syms_left); syms_left = XCDR (syms_left))
@@ -3110,8 +3094,6 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3110{ 3094{
3111 struct Lisp_Symbol *sym; 3095 struct Lisp_Symbol *sym;
3112 3096
3113 eassert (!handling_signal);
3114
3115 CHECK_SYMBOL (symbol); 3097 CHECK_SYMBOL (symbol);
3116 sym = XSYMBOL (symbol); 3098 sym = XSYMBOL (symbol);
3117 if (specpdl_ptr == specpdl + specpdl_size) 3099 if (specpdl_ptr == specpdl + specpdl_size)
@@ -3198,15 +3180,13 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3198 set_internal (symbol, value, Qnil, 1); 3180 set_internal (symbol, value, Qnil, 1);
3199 break; 3181 break;
3200 } 3182 }
3201 default: abort (); 3183 default: emacs_abort ();
3202 } 3184 }
3203} 3185}
3204 3186
3205void 3187void
3206record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) 3188record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg)
3207{ 3189{
3208 eassert (!handling_signal);
3209
3210 if (specpdl_ptr == specpdl + specpdl_size) 3190 if (specpdl_ptr == specpdl + specpdl_size)
3211 grow_specpdl (); 3191 grow_specpdl ();
3212 specpdl_ptr->func = function; 3192 specpdl_ptr->func = function;
@@ -3343,13 +3323,13 @@ Output stream used is value of `standard-output'. */)
3343 write_string ("(", -1); 3323 write_string ("(", -1);
3344 if (backlist->nargs == MANY) 3324 if (backlist->nargs == MANY)
3345 { /* FIXME: Can this happen? */ 3325 { /* FIXME: Can this happen? */
3346 int i; 3326 bool later_arg = 0;
3347 for (tail = *backlist->args, i = 0; 3327 for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail))
3348 !NILP (tail);
3349 tail = Fcdr (tail), i = 1)
3350 { 3328 {
3351 if (i) write_string (" ", -1); 3329 if (later_arg)
3330 write_string (" ", -1);
3352 Fprin1 (Fcar (tail), Qnil); 3331 Fprin1 (Fcar (tail), Qnil);
3332 later_arg = 1;
3353 } 3333 }
3354 } 3334 }
3355 else 3335 else
@@ -3470,7 +3450,7 @@ before making `inhibit-quit' nil. */);
3470 3450
3471 DEFSYM (Qinhibit_quit, "inhibit-quit"); 3451 DEFSYM (Qinhibit_quit, "inhibit-quit");
3472 DEFSYM (Qautoload, "autoload"); 3452 DEFSYM (Qautoload, "autoload");
3473 DEFSYM (Qdebug_on_error, "debug-on-error"); 3453 DEFSYM (Qinhibit_debugger, "inhibit-debugger");
3474 DEFSYM (Qmacro, "macro"); 3454 DEFSYM (Qmacro, "macro");
3475 DEFSYM (Qdeclare, "declare"); 3455 DEFSYM (Qdeclare, "declare");
3476 3456
@@ -3485,6 +3465,12 @@ before making `inhibit-quit' nil. */);
3485 DEFSYM (Qclosure, "closure"); 3465 DEFSYM (Qclosure, "closure");
3486 DEFSYM (Qdebug, "debug"); 3466 DEFSYM (Qdebug, "debug");
3487 3467
3468 DEFVAR_LISP ("inhibit-debugger", Vinhibit_debugger,
3469 doc: /* Non-nil means never enter the debugger.
3470Normally set while the debugger is already active, to avoid recursive
3471invocations. */);
3472 Vinhibit_debugger = Qnil;
3473
3488 DEFVAR_LISP ("debug-on-error", Vdebug_on_error, 3474 DEFVAR_LISP ("debug-on-error", Vdebug_on_error,
3489 doc: /* Non-nil means enter debugger if an error is signaled. 3475 doc: /* Non-nil means enter debugger if an error is signaled.
3490Does not apply to errors handled by `condition-case' or those 3476Does not apply to errors handled by `condition-case' or those
@@ -3494,7 +3480,7 @@ if one of its condition symbols appears in the list.
3494When you evaluate an expression interactively, this variable 3480When you evaluate an expression interactively, this variable
3495is temporarily non-nil if `eval-expression-debug-on-error' is non-nil. 3481is temporarily non-nil if `eval-expression-debug-on-error' is non-nil.
3496The command `toggle-debug-on-error' toggles this. 3482The command `toggle-debug-on-error' toggles this.
3497See also the variable `debug-on-quit'. */); 3483See also the variable `debug-on-quit' and `inhibit-debugger'. */);
3498 Vdebug_on_error = Qnil; 3484 Vdebug_on_error = Qnil;
3499 3485
3500 DEFVAR_LISP ("debug-ignored-errors", Vdebug_ignored_errors, 3486 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/>. */
23#include <stdio.h> 23#include <stdio.h>
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h> 25#include <sys/stat.h>
26#include <setjmp.h>
27#include <unistd.h> 26#include <unistd.h>
28 27
29#ifdef HAVE_PWD_H 28#ifdef HAVE_PWD_H
@@ -85,18 +84,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
85 84
86#include "commands.h" 85#include "commands.h"
87 86
88/* Nonzero during writing of auto-save files. */ 87/* True during writing of auto-save files. */
89static int auto_saving; 88static bool auto_saving;
90 89
91/* Nonzero umask during creation of auto-save directories. */ 90/* Nonzero umask during creation of auto-save directories. */
92static int auto_saving_dir_umask; 91static mode_t auto_saving_dir_umask;
93 92
94/* Set by auto_save_1 to mode of original file so Fwrite_region will create 93/* Set by auto_save_1 to mode of original file so Fwrite_region will create
95 a new file with the same mode as the original. */ 94 a new file with the same mode as the original. */
96static int auto_save_mode_bits; 95static mode_t auto_save_mode_bits;
97 96
98/* Set by auto_save_1 if an error occurred during the last auto-save. */ 97/* Set by auto_save_1 if an error occurred during the last auto-save. */
99static int auto_save_error_occurred; 98static bool auto_save_error_occurred;
100 99
101/* The symbol bound to coding-system-for-read when 100/* The symbol bound to coding-system-for-read when
102 insert-file-contents is called for recovering a file. This is not 101 insert-file-contents is called for recovering a file. This is not
@@ -145,10 +144,10 @@ Lisp_Object Qfile_name_history;
145 144
146static Lisp_Object Qcar_less_than_car; 145static Lisp_Object Qcar_less_than_car;
147 146
148static int a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, 147static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
149 Lisp_Object *, struct coding_system *); 148 Lisp_Object *, struct coding_system *);
150static int e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, 149static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
151 struct coding_system *); 150 struct coding_system *);
152 151
153 152
154void 153void
@@ -595,7 +594,7 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p;
595 which has no existing file. To make this work, PREFIX should be 594 which has no existing file. To make this work, PREFIX should be
596 an absolute file name. 595 an absolute file name.
597 596
598 BASE64_P non-zero means add the pid as 3 characters in base64 597 BASE64_P means add the pid as 3 characters in base64
599 encoding. In this case, 6 characters will be added to PREFIX to 598 encoding. In this case, 6 characters will be added to PREFIX to
600 form the file name. Otherwise, if Emacs is running on a system 599 form the file name. Otherwise, if Emacs is running on a system
601 with long file names, add the pid as a decimal number. 600 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;
604 generated. */ 603 generated. */
605 604
606Lisp_Object 605Lisp_Object
607make_temp_name (Lisp_Object prefix, int base64_p) 606make_temp_name (Lisp_Object prefix, bool base64_p)
608{ 607{
609 Lisp_Object val; 608 Lisp_Object val;
610 int len, clen; 609 int len, clen;
@@ -761,8 +760,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
761 struct passwd *pw; 760 struct passwd *pw;
762#ifdef DOS_NT 761#ifdef DOS_NT
763 int drive = 0; 762 int drive = 0;
764 int collapse_newdir = 1; 763 bool collapse_newdir = 1;
765 int is_escaped = 0; 764 bool is_escaped = 0;
766#endif /* DOS_NT */ 765#endif /* DOS_NT */
767 ptrdiff_t length; 766 ptrdiff_t length;
768 Lisp_Object handler, result, handled_name; 767 Lisp_Object handler, result, handled_name;
@@ -920,10 +919,9 @@ filesystem tree, not (expand-file-name ".." dirname). */)
920 /* If it turns out that the filename we want to return is just a 919 /* If it turns out that the filename we want to return is just a
921 suffix of FILENAME, we don't need to go through and edit 920 suffix of FILENAME, we don't need to go through and edit
922 things; we just need to construct a new string using data 921 things; we just need to construct a new string using data
923 starting at the middle of FILENAME. If we set lose to a 922 starting at the middle of FILENAME. If we set LOSE, that
924 non-zero value, that means we've discovered that we can't do 923 means we've discovered that we can't do that cool trick. */
925 that cool trick. */ 924 bool lose = 0;
926 int lose = 0;
927 char *p = nm; 925 char *p = nm;
928 926
929 while (*p) 927 while (*p)
@@ -1294,7 +1292,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1294 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) 1292 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1])))
1295#endif /* WINDOWSNT */ 1293#endif /* WINDOWSNT */
1296 { 1294 {
1297 if (!drive) abort (); 1295 if (!drive) emacs_abort ();
1298 target -= 2; 1296 target -= 2;
1299 target[0] = DRIVE_LETTER (drive); 1297 target[0] = DRIVE_LETTER (drive);
1300 target[1] = ':'; 1298 target[1] = ':';
@@ -1360,7 +1358,6 @@ See also the function `substitute-in-file-name'.")
1360 ptrdiff_t tlen; 1358 ptrdiff_t tlen;
1361 unsigned char *target; 1359 unsigned char *target;
1362 struct passwd *pw; 1360 struct passwd *pw;
1363 int lose;
1364 1361
1365 CHECK_STRING (name); 1362 CHECK_STRING (name);
1366 nm = SDATA (name); 1363 nm = SDATA (name);
@@ -1369,8 +1366,8 @@ See also the function `substitute-in-file-name'.")
1369 If no /./ or /../ we can return right away. */ 1366 If no /./ or /../ we can return right away. */
1370 if (nm[0] == '/') 1367 if (nm[0] == '/')
1371 { 1368 {
1369 bool lose = 0;
1372 p = nm; 1370 p = nm;
1373 lose = 0;
1374 while (*p) 1371 while (*p)
1375 { 1372 {
1376 if (p[0] == '/' && p[1] == '/' 1373 if (p[0] == '/' && p[1] == '/'
@@ -1494,7 +1491,7 @@ See also the function `substitute-in-file-name'.")
1494#endif 1491#endif
1495 1492
1496/* If /~ or // appears, discard everything through first slash. */ 1493/* If /~ or // appears, discard everything through first slash. */
1497static int 1494static bool
1498file_name_absolute_p (const char *filename) 1495file_name_absolute_p (const char *filename)
1499{ 1496{
1500 return 1497 return
@@ -1560,12 +1557,10 @@ If `//' appears, everything up to and including the first of
1560those `/' is discarded. */) 1557those `/' is discarded. */)
1561 (Lisp_Object filename) 1558 (Lisp_Object filename)
1562{ 1559{
1563 char *nm; 1560 char *nm, *s, *p, *o, *x, *endp;
1564
1565 register char *s, *p, *o, *x, *endp;
1566 char *target = NULL; 1561 char *target = NULL;
1567 int total = 0; 1562 int total = 0;
1568 int substituted = 0; 1563 bool substituted = 0;
1569 bool multibyte; 1564 bool multibyte;
1570 char *xnm; 1565 char *xnm;
1571 Lisp_Object handler; 1566 Lisp_Object handler;
@@ -1780,7 +1775,7 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
1780} 1775}
1781 1776
1782/* Signal an error if the file ABSNAME already exists. 1777/* Signal an error if the file ABSNAME already exists.
1783 If INTERACTIVE is nonzero, ask the user whether to proceed, 1778 If INTERACTIVE, ask the user whether to proceed,
1784 and bypass the error if the user says to go ahead. 1779 and bypass the error if the user says to go ahead.
1785 QUERYSTRING is a name for the action that is being considered 1780 QUERYSTRING is a name for the action that is being considered
1786 to alter the file. 1781 to alter the file.
@@ -1789,13 +1784,14 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
1789 If the file does not exist, STATPTR->st_mode is set to 0. 1784 If the file does not exist, STATPTR->st_mode is set to 0.
1790 If STATPTR is null, we don't store into it. 1785 If STATPTR is null, we don't store into it.
1791 1786
1792 If QUICK is nonzero, we ask for y or n, not yes or no. */ 1787 If QUICK, ask for y or n, not yes or no. */
1793 1788
1794static void 1789static void
1795barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, 1790barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring,
1796 int interactive, struct stat *statptr, int quick) 1791 bool interactive, struct stat *statptr,
1792 bool quick)
1797{ 1793{
1798 register Lisp_Object tem, encoded_filename; 1794 Lisp_Object tem, encoded_filename;
1799 struct stat statbuf; 1795 struct stat statbuf;
1800 struct gcpro gcpro1; 1796 struct gcpro gcpro1;
1801 1797
@@ -1869,11 +1865,11 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1869 Lisp_Object handler; 1865 Lisp_Object handler;
1870 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1866 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1871 ptrdiff_t count = SPECPDL_INDEX (); 1867 ptrdiff_t count = SPECPDL_INDEX ();
1872 int input_file_statable_p; 1868 bool input_file_statable_p;
1873 Lisp_Object encoded_file, encoded_newname; 1869 Lisp_Object encoded_file, encoded_newname;
1874#if HAVE_LIBSELINUX 1870#if HAVE_LIBSELINUX
1875 security_context_t con; 1871 security_context_t con;
1876 int fail, conlength = 0; 1872 int conlength = 0;
1877#endif 1873#endif
1878 1874
1879 encoded_file = encoded_newname = Qnil; 1875 encoded_file = encoded_newname = Qnil;
@@ -1988,7 +1984,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1988 S_IREAD | S_IWRITE); 1984 S_IREAD | S_IWRITE);
1989#else /* not MSDOS */ 1985#else /* not MSDOS */
1990 { 1986 {
1991 int new_mask = 0666; 1987 mode_t new_mask = 0666;
1992 if (input_file_statable_p) 1988 if (input_file_statable_p)
1993 { 1989 {
1994 if (!NILP (preserve_uid_gid)) 1990 if (!NILP (preserve_uid_gid))
@@ -2018,7 +2014,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
2018 owner and group. */ 2014 owner and group. */
2019 if (input_file_statable_p) 2015 if (input_file_statable_p)
2020 { 2016 {
2021 int mode_mask = 07777; 2017 mode_t mode_mask = 07777;
2022 if (!NILP (preserve_uid_gid)) 2018 if (!NILP (preserve_uid_gid))
2023 { 2019 {
2024 /* Attempt to change owner and group. If that doesn't work 2020 /* 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. */)
2041 if (conlength > 0) 2037 if (conlength > 0)
2042 { 2038 {
2043 /* Set the modified context back to the file. */ 2039 /* Set the modified context back to the file. */
2044 fail = fsetfilecon (ofd, con); 2040 bool fail = fsetfilecon (ofd, con) != 0;
2045 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 2041 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
2046 if (fail && errno != ENOTSUP) 2042 if (fail && errno != ENOTSUP)
2047 report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); 2043 report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil));
@@ -2184,17 +2180,14 @@ internal_delete_file_1 (Lisp_Object ignore)
2184 return Qt; 2180 return Qt;
2185} 2181}
2186 2182
2187/* Delete file FILENAME, returning 1 if successful and 0 if failed. 2183/* Delete file FILENAME.
2188 This ignores `delete-by-moving-to-trash'. */ 2184 This ignores `delete-by-moving-to-trash'. */
2189 2185
2190int 2186void
2191internal_delete_file (Lisp_Object filename) 2187internal_delete_file (Lisp_Object filename)
2192{ 2188{
2193 Lisp_Object tem; 2189 internal_condition_case_2 (Fdelete_file, filename, Qnil,
2194 2190 Qt, internal_delete_file_1);
2195 tem = internal_condition_case_2 (Fdelete_file, filename, Qnil,
2196 Qt, internal_delete_file_1);
2197 return NILP (tem);
2198} 2191}
2199 2192
2200DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, 2193DEFUN ("rename-file", Frename_file, Srename_file, 2, 3,
@@ -2430,9 +2423,9 @@ On Unix, this is a name starting with a `/' or a `~'. */)
2430 return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil; 2423 return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
2431} 2424}
2432 2425
2433/* Return nonzero if file FILENAME exists and can be executed. */ 2426/* Return true if file FILENAME exists and can be executed. */
2434 2427
2435static int 2428static bool
2436check_executable (char *filename) 2429check_executable (char *filename)
2437{ 2430{
2438#ifdef DOS_NT 2431#ifdef DOS_NT
@@ -2452,9 +2445,9 @@ check_executable (char *filename)
2452#endif /* not DOS_NT */ 2445#endif /* not DOS_NT */
2453} 2446}
2454 2447
2455/* Return nonzero if file FILENAME exists and can be written. */ 2448/* Return true if file FILENAME exists and can be written. */
2456 2449
2457static int 2450static bool
2458check_writable (const char *filename) 2451check_writable (const char *filename)
2459{ 2452{
2460#ifdef MSDOS 2453#ifdef MSDOS
@@ -2464,7 +2457,7 @@ check_writable (const char *filename)
2464 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); 2457 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
2465#else /* not MSDOS */ 2458#else /* not MSDOS */
2466#ifdef HAVE_EUIDACCESS 2459#ifdef HAVE_EUIDACCESS
2467 int res = (euidaccess (filename, 2) >= 0); 2460 bool res = (euidaccess (filename, 2) >= 0);
2468#ifdef CYGWIN 2461#ifdef CYGWIN
2469 /* euidaccess may have returned failure because Cygwin couldn't 2462 /* euidaccess may have returned failure because Cygwin couldn't
2470 determine the file's UID or GID; if so, we return success. */ 2463 determine the file's UID or GID; if so, we return success. */
@@ -2732,7 +2725,7 @@ searchable directory. */)
2732 (Lisp_Object filename) 2725 (Lisp_Object filename)
2733{ 2726{
2734 Lisp_Object handler; 2727 Lisp_Object handler;
2735 int tem; 2728 bool tem;
2736 struct gcpro gcpro1; 2729 struct gcpro gcpro1;
2737 2730
2738 /* If the file name has special constructs in it, 2731 /* If the file name has special constructs in it,
@@ -2868,7 +2861,8 @@ compiled with SELinux support. */)
2868 Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context))); 2861 Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context)));
2869 Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context)))); 2862 Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context))));
2870 security_context_t con; 2863 security_context_t con;
2871 int fail, conlength; 2864 bool fail;
2865 int conlength;
2872 context_t parsed_con; 2866 context_t parsed_con;
2873#endif 2867#endif
2874 2868
@@ -2912,8 +2906,9 @@ compiled with SELinux support. */)
2912 } 2906 }
2913 2907
2914 /* Set the modified context back to the file. */ 2908 /* Set the modified context back to the file. */
2915 fail = lsetfilecon (SSDATA (encoded_absname), 2909 fail = (lsetfilecon (SSDATA (encoded_absname),
2916 context_str (parsed_con)); 2910 context_str (parsed_con))
2911 != 0);
2917 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 2912 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
2918 if (fail && errno != ENOTSUP) 2913 if (fail && errno != ENOTSUP)
2919 report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); 2914 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,
3004The value is an integer. */) 2999The value is an integer. */)
3005 (void) 3000 (void)
3006{ 3001{
3007 int realmask; 3002 mode_t realmask;
3008 Lisp_Object value; 3003 Lisp_Object value;
3009 3004
3010 BLOCK_INPUT; 3005 BLOCK_INPUT;
@@ -3246,29 +3241,29 @@ variable `last-coding-system-used' to the coding system actually used. */)
3246 struct stat st; 3241 struct stat st;
3247 int file_status; 3242 int file_status;
3248 EMACS_TIME mtime; 3243 EMACS_TIME mtime;
3249 register int fd; 3244 int fd;
3250 ptrdiff_t inserted = 0; 3245 ptrdiff_t inserted = 0;
3251 int nochange = 0; 3246 bool nochange = 0;
3252 register ptrdiff_t how_much; 3247 ptrdiff_t how_much;
3253 off_t beg_offset, end_offset; 3248 off_t beg_offset, end_offset;
3254 register int unprocessed; 3249 int unprocessed;
3255 ptrdiff_t count = SPECPDL_INDEX (); 3250 ptrdiff_t count = SPECPDL_INDEX ();
3256 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 3251 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
3257 Lisp_Object handler, val, insval, orig_filename, old_undo; 3252 Lisp_Object handler, val, insval, orig_filename, old_undo;
3258 Lisp_Object p; 3253 Lisp_Object p;
3259 ptrdiff_t total = 0; 3254 ptrdiff_t total = 0;
3260 int not_regular = 0; 3255 bool not_regular = 0;
3261 int save_errno = 0; 3256 int save_errno = 0;
3262 char read_buf[READ_BUF_SIZE]; 3257 char read_buf[READ_BUF_SIZE];
3263 struct coding_system coding; 3258 struct coding_system coding;
3264 char buffer[1 << 14]; 3259 char buffer[1 << 14];
3265 int replace_handled = 0; 3260 bool replace_handled = 0;
3266 int set_coding_system = 0; 3261 bool set_coding_system = 0;
3267 Lisp_Object coding_system; 3262 Lisp_Object coding_system;
3268 int read_quit = 0; 3263 bool read_quit = 0;
3269 Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; 3264 Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
3270 int we_locked_file = 0; 3265 bool we_locked_file = 0;
3271 int deferred_remove_unwind_protect = 0; 3266 bool deferred_remove_unwind_protect = 0;
3272 3267
3273 if (current_buffer->base_buffer && ! NILP (visit)) 3268 if (current_buffer->base_buffer && ! NILP (visit))
3274 error ("Cannot do file visiting in an indirect buffer"); 3269 error ("Cannot do file visiting in an indirect buffer");
@@ -3569,9 +3564,9 @@ variable `last-coding-system-used' to the coding system actually used. */)
3569 ptrdiff_t same_at_end = ZV_BYTE; 3564 ptrdiff_t same_at_end = ZV_BYTE;
3570 ptrdiff_t overlap; 3565 ptrdiff_t overlap;
3571 /* There is still a possibility we will find the need to do code 3566 /* There is still a possibility we will find the need to do code
3572 conversion. If that happens, we set this variable to 1 to 3567 conversion. If that happens, set this variable to
3573 give up on handling REPLACE in the optimized way. */ 3568 give up on handling REPLACE in the optimized way. */
3574 int giveup_match_end = 0; 3569 bool giveup_match_end = 0;
3575 3570
3576 if (beg_offset != 0) 3571 if (beg_offset != 0)
3577 { 3572 {
@@ -4427,8 +4422,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4427 If it is not set locally, we anyway have to convert EOL 4422 If it is not set locally, we anyway have to convert EOL
4428 format if the default value of `buffer-file-coding-system' 4423 format if the default value of `buffer-file-coding-system'
4429 tells that it is not Unix-like (LF only) format. */ 4424 tells that it is not Unix-like (LF only) format. */
4430 int using_default_coding = 0; 4425 bool using_default_coding = 0;
4431 int force_raw_text = 0; 4426 bool force_raw_text = 0;
4432 4427
4433 val = BVAR (current_buffer, buffer_file_coding_system); 4428 val = BVAR (current_buffer, buffer_file_coding_system);
4434 if (NILP (val) 4429 if (NILP (val)
@@ -4537,8 +4532,8 @@ This calls `write-region-annotate-functions' at the start, and
4537`write-region-post-annotation-function' at the end. */) 4532`write-region-post-annotation-function' at the end. */)
4538 (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew) 4533 (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew)
4539{ 4534{
4540 register int desc; 4535 int desc;
4541 int failure; 4536 bool ok;
4542 int save_errno = 0; 4537 int save_errno = 0;
4543 const char *fn; 4538 const char *fn;
4544 struct stat st; 4539 struct stat st;
@@ -4548,8 +4543,8 @@ This calls `write-region-annotate-functions' at the start, and
4548 Lisp_Object visit_file; 4543 Lisp_Object visit_file;
4549 Lisp_Object annotations; 4544 Lisp_Object annotations;
4550 Lisp_Object encoded_filename; 4545 Lisp_Object encoded_filename;
4551 int visiting = (EQ (visit, Qt) || STRINGP (visit)); 4546 bool visiting = (EQ (visit, Qt) || STRINGP (visit));
4552 int quietly = !NILP (visit); 4547 bool quietly = !NILP (visit);
4553 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 4548 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
4554 struct buffer *given_buffer; 4549 struct buffer *given_buffer;
4555 struct coding_system coding; 4550 struct coding_system coding;
@@ -4713,37 +4708,27 @@ This calls `write-region-annotate-functions' at the start, and
4713 4708
4714 UNGCPRO; 4709 UNGCPRO;
4715 4710
4716 failure = 0;
4717 immediate_quit = 1; 4711 immediate_quit = 1;
4718 4712
4719 if (STRINGP (start)) 4713 if (STRINGP (start))
4720 { 4714 ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding);
4721 failure = 0 > a_write (desc, start, 0, SCHARS (start),
4722 &annotations, &coding);
4723 save_errno = errno;
4724 }
4725 else if (XINT (start) != XINT (end)) 4715 else if (XINT (start) != XINT (end))
4726 { 4716 ok = a_write (desc, Qnil, XINT (start), XINT (end) - XINT (start),
4727 failure = 0 > a_write (desc, Qnil, 4717 &annotations, &coding);
4728 XINT (start), XINT (end) - XINT (start),
4729 &annotations, &coding);
4730 save_errno = errno;
4731 }
4732 else 4718 else
4733 { 4719 {
4734 /* If file was empty, still need to write the annotations */ 4720 /* If file was empty, still need to write the annotations. */
4735 coding.mode |= CODING_MODE_LAST_BLOCK; 4721 coding.mode |= CODING_MODE_LAST_BLOCK;
4736 failure = 0 > a_write (desc, Qnil, XINT (end), 0, &annotations, &coding); 4722 ok = a_write (desc, Qnil, XINT (end), 0, &annotations, &coding);
4737 save_errno = errno;
4738 } 4723 }
4724 save_errno = errno;
4739 4725
4740 if (CODING_REQUIRE_FLUSHING (&coding) 4726 if (ok && CODING_REQUIRE_FLUSHING (&coding)
4741 && !(coding.mode & CODING_MODE_LAST_BLOCK) 4727 && !(coding.mode & CODING_MODE_LAST_BLOCK))
4742 && ! failure)
4743 { 4728 {
4744 /* We have to flush out a data. */ 4729 /* We have to flush out a data. */
4745 coding.mode |= CODING_MODE_LAST_BLOCK; 4730 coding.mode |= CODING_MODE_LAST_BLOCK;
4746 failure = 0 > e_write (desc, Qnil, 1, 1, &coding); 4731 ok = e_write (desc, Qnil, 1, 1, &coding);
4747 save_errno = errno; 4732 save_errno = errno;
4748 } 4733 }
4749 4734
@@ -4760,13 +4745,13 @@ This calls `write-region-annotate-functions' at the start, and
4760 ignore EINVAL which happens when fsync is not supported on this 4745 ignore EINVAL which happens when fsync is not supported on this
4761 file. */ 4746 file. */
4762 if (errno != EINTR && errno != EINVAL) 4747 if (errno != EINTR && errno != EINVAL)
4763 failure = 1, save_errno = errno; 4748 ok = 0, save_errno = errno;
4764 } 4749 }
4765#endif 4750#endif
4766 4751
4767 /* NFS can report a write failure now. */ 4752 /* NFS can report a write failure now. */
4768 if (emacs_close (desc) < 0) 4753 if (emacs_close (desc) < 0)
4769 failure = 1, save_errno = errno; 4754 ok = 0, save_errno = errno;
4770 4755
4771 stat (fn, &st); 4756 stat (fn, &st);
4772 4757
@@ -4803,7 +4788,7 @@ This calls `write-region-annotate-functions' at the start, and
4803 current_buffer->modtime_size = st.st_size; 4788 current_buffer->modtime_size = st.st_size;
4804 } 4789 }
4805 4790
4806 if (failure) 4791 if (! ok)
4807 error ("IO error writing %s: %s", SDATA (filename), 4792 error ("IO error writing %s: %s", SDATA (filename),
4808 emacs_strerror (save_errno)); 4793 emacs_strerror (save_errno));
4809 4794
@@ -4859,7 +4844,8 @@ build_annotations (Lisp_Object start, Lisp_Object end)
4859 Lisp_Object p, res; 4844 Lisp_Object p, res;
4860 struct gcpro gcpro1, gcpro2; 4845 struct gcpro gcpro1, gcpro2;
4861 Lisp_Object original_buffer; 4846 Lisp_Object original_buffer;
4862 int i, used_global = 0; 4847 int i;
4848 bool used_global = 0;
4863 4849
4864 XSETBUFFER (original_buffer, current_buffer); 4850 XSETBUFFER (original_buffer, current_buffer);
4865 4851
@@ -4939,11 +4925,11 @@ build_annotations (Lisp_Object start, Lisp_Object end)
4939 4925
4940 We modify *ANNOT by discarding elements as we use them up. 4926 We modify *ANNOT by discarding elements as we use them up.
4941 4927
4942 The return value is negative in case of system call failure. */ 4928 Return true if successful. */
4943 4929
4944static int 4930static bool
4945a_write (int desc, Lisp_Object string, ptrdiff_t pos, 4931a_write (int desc, Lisp_Object string, ptrdiff_t pos,
4946 register ptrdiff_t nchars, Lisp_Object *annot, 4932 ptrdiff_t nchars, Lisp_Object *annot,
4947 struct coding_system *coding) 4933 struct coding_system *coding)
4948{ 4934{
4949 Lisp_Object tem; 4935 Lisp_Object tem;
@@ -4965,29 +4951,29 @@ a_write (int desc, Lisp_Object string, ptrdiff_t pos,
4965 /* Output buffer text up to the next annotation's position. */ 4951 /* Output buffer text up to the next annotation's position. */
4966 if (nextpos > pos) 4952 if (nextpos > pos)
4967 { 4953 {
4968 if (0 > e_write (desc, string, pos, nextpos, coding)) 4954 if (!e_write (desc, string, pos, nextpos, coding))
4969 return -1; 4955 return 0;
4970 pos = nextpos; 4956 pos = nextpos;
4971 } 4957 }
4972 /* Output the annotation. */ 4958 /* Output the annotation. */
4973 tem = Fcdr (Fcar (*annot)); 4959 tem = Fcdr (Fcar (*annot));
4974 if (STRINGP (tem)) 4960 if (STRINGP (tem))
4975 { 4961 {
4976 if (0 > e_write (desc, tem, 0, SCHARS (tem), coding)) 4962 if (!e_write (desc, tem, 0, SCHARS (tem), coding))
4977 return -1; 4963 return 0;
4978 } 4964 }
4979 *annot = Fcdr (*annot); 4965 *annot = Fcdr (*annot);
4980 } 4966 }
4981 return 0; 4967 return 1;
4982} 4968}
4983 4969
4984 4970
4985/* Write text in the range START and END into descriptor DESC, 4971/* Write text in the range START and END into descriptor DESC,
4986 encoding them with coding system CODING. If STRING is nil, START 4972 encoding them with coding system CODING. If STRING is nil, START
4987 and END are character positions of the current buffer, else they 4973 and END are character positions of the current buffer, else they
4988 are indexes to the string STRING. */ 4974 are indexes to the string STRING. Return true if successful. */
4989 4975
4990static int 4976static bool
4991e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, 4977e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
4992 struct coding_system *coding) 4978 struct coding_system *coding)
4993{ 4979{
@@ -5056,12 +5042,12 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
5056 coding->produced); 5042 coding->produced);
5057 5043
5058 if (coding->produced) 5044 if (coding->produced)
5059 return -1; 5045 return 0;
5060 } 5046 }
5061 start += coding->consumed_char; 5047 start += coding->consumed_char;
5062 } 5048 }
5063 5049
5064 return 0; 5050 return 1;
5065} 5051}
5066 5052
5067DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 5053DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
@@ -5300,12 +5286,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5300{ 5286{
5301 struct buffer *old = current_buffer, *b; 5287 struct buffer *old = current_buffer, *b;
5302 Lisp_Object tail, buf, hook; 5288 Lisp_Object tail, buf, hook;
5303 int auto_saved = 0; 5289 bool auto_saved = 0;
5304 int do_handled_files; 5290 int do_handled_files;
5305 Lisp_Object oquit; 5291 Lisp_Object oquit;
5306 FILE *stream = NULL; 5292 FILE *stream = NULL;
5307 ptrdiff_t count = SPECPDL_INDEX (); 5293 ptrdiff_t count = SPECPDL_INDEX ();
5308 int orig_minibuffer_auto_raise = minibuffer_auto_raise; 5294 bool orig_minibuffer_auto_raise = minibuffer_auto_raise;
5309 bool old_message_p = 0; 5295 bool old_message_p = 0;
5310 struct gcpro gcpro1, gcpro2; 5296 struct gcpro gcpro1, gcpro2;
5311 5297
@@ -5452,7 +5438,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5452 if (!auto_saved && NILP (no_message)) 5438 if (!auto_saved && NILP (no_message))
5453 message1 ("Auto-saving..."); 5439 message1 ("Auto-saving...");
5454 internal_condition_case (auto_save_1, Qt, auto_save_error); 5440 internal_condition_case (auto_save_1, Qt, auto_save_error);
5455 auto_saved++; 5441 auto_saved = 1;
5456 BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b); 5442 BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
5457 XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); 5443 XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
5458 set_buffer_internal (old); 5444 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/>. */
23#include <sys/stat.h> 23#include <sys/stat.h>
24#include <signal.h> 24#include <signal.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#ifdef HAVE_PWD_H 27#ifdef HAVE_PWD_H
29#include <pwd.h> 28#include <pwd.h>
@@ -100,10 +99,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
100/* Return the time of the last system boot. */ 99/* Return the time of the last system boot. */
101 100
102static time_t boot_time; 101static time_t boot_time;
103static int boot_time_initialized; 102static bool boot_time_initialized;
104 103
105#ifdef BOOT_TIME 104#ifdef BOOT_TIME
106static void get_boot_time_1 (const char *, int); 105static void get_boot_time_1 (const char *, bool);
107#endif 106#endif
108 107
109static time_t 108static time_t
@@ -170,7 +169,7 @@ get_boot_time (void)
170 { 169 {
171 char cmd_string[sizeof WTMP_FILE ".19.gz"]; 170 char cmd_string[sizeof WTMP_FILE ".19.gz"];
172 Lisp_Object tempname, filename; 171 Lisp_Object tempname, filename;
173 int delete_flag = 0; 172 bool delete_flag = 0;
174 173
175 filename = Qnil; 174 filename = Qnil;
176 175
@@ -225,13 +224,13 @@ get_boot_time (void)
225 224
226 If FILENAME is zero, use the same file as before; 225 If FILENAME is zero, use the same file as before;
227 if no FILENAME has ever been specified, this is the utmp file. 226 if no FILENAME has ever been specified, this is the utmp file.
228 Use the newest reboot record if NEWEST is nonzero, 227 Use the newest reboot record if NEWEST,
229 the first reboot record otherwise. 228 the first reboot record otherwise.
230 Ignore all reboot records on or before BOOT_TIME. 229 Ignore all reboot records on or before BOOT_TIME.
231 Success is indicated by setting BOOT_TIME to a larger value. */ 230 Success is indicated by setting BOOT_TIME to a larger value. */
232 231
233void 232void
234get_boot_time_1 (const char *filename, int newest) 233get_boot_time_1 (const char *filename, bool newest)
235{ 234{
236 struct utmp ut, *utp; 235 struct utmp ut, *utp;
237 int desc; 236 int desc;
@@ -331,11 +330,11 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
331} 330}
332 331
333/* Lock the lock file named LFNAME. 332/* Lock the lock file named LFNAME.
334 If FORCE is nonzero, we do so even if it is already locked. 333 If FORCE, do so even if it is already locked.
335 Return 1 if successful, 0 if not. */ 334 Return true if successful. */
336 335
337static int 336static bool
338lock_file_1 (char *lfname, int force) 337lock_file_1 (char *lfname, bool force)
339{ 338{
340 int err; 339 int err;
341 int symlink_errno; 340 int symlink_errno;
@@ -370,9 +369,9 @@ lock_file_1 (char *lfname, int force)
370 return err == 0; 369 return err == 0;
371} 370}
372 371
373/* Return 1 if times A and B are no more than one second apart. */ 372/* Return true if times A and B are no more than one second apart. */
374 373
375static int 374static bool
376within_one_second (time_t a, time_t b) 375within_one_second (time_t a, time_t b)
377{ 376{
378 return (a - b >= -1 && a - b <= 1); 377 return (a - b >= -1 && a - b <= 1);
@@ -491,7 +490,7 @@ current_lock_owner (lock_info_type *owner, char *lfname)
491static int 490static int
492lock_if_free (lock_info_type *clasher, register char *lfname) 491lock_if_free (lock_info_type *clasher, register char *lfname)
493{ 492{
494 while (lock_file_1 (lfname, 0) == 0) 493 while (! lock_file_1 (lfname, 0))
495 { 494 {
496 int locker; 495 int locker;
497 496
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];
27char * my_begbss_static = _my_begbss; 27char * my_begbss_static = _my_begbss;
28 28
29/* Add a dummy reference to ensure emacs.obj is linked in. */ 29/* Add a dummy reference to ensure emacs.obj is linked in. */
30extern int initialized; 30extern int main (int, char **);
31static int * dummy = &initialized; 31static int (*dummy) (int, char **) = main;
32#endif 32#endif
33
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
22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 23
24 24
25/* ANSI C requires only these float functions: 25/* C89 requires only the following math.h functions, and Emacs omits
26 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, 26 the starred functions since we haven't found a use for them:
27 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh. 27 acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod,
28 28 frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh.
29 Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh.
30 Define HAVE_CBRT if you have cbrt.
31 Define HAVE_RINT if you have a working rint.
32 If you don't define these, then the appropriate routines will be simulated.
33
34 Define HAVE_MATHERR if on a system supporting the SysV matherr callback.
35 (This should happen automatically.)
36
37 Define FLOAT_CHECK_ERRNO if the float library routines set errno.
38 This has no effect if HAVE_MATHERR is defined.
39
40 Define FLOAT_CATCH_SIGILL if the float library routines signal SIGILL.
41 (What systems actually do this? Please let us know.)
42
43 Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by
44 either setting errno, or signaling SIGFPE/SIGILL. Otherwise, domain and
45 range checking will happen before calling the float routines. This has
46 no effect if HAVE_MATHERR is defined (since matherr will be called when
47 a domain error occurs.)
48 */ 29 */
49 30
50#include <config.h> 31#include <config.h>
51#include <signal.h> 32
52#include <setjmp.h>
53#include "lisp.h" 33#include "lisp.h"
54#include "syssignal.h" 34#include "syssignal.h"
55 35
56#include <float.h> 36#include <float.h>
57/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */
58#ifndef IEEE_FLOATING_POINT
59#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ 37#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
60 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 38 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
61#define IEEE_FLOATING_POINT 1 39#define IEEE_FLOATING_POINT 1
62#else 40#else
63#define IEEE_FLOATING_POINT 0 41#define IEEE_FLOATING_POINT 0
64#endif 42#endif
65#endif
66 43
67#include <math.h> 44#include <math.h>
68 45
69/* This declaration is omitted on some systems, like Ultrix. */ 46#ifndef isfinite
70#if !defined (HPUX) && defined (HAVE_LOGB) && !defined (logb) 47# define isfinite(x) ((x) - (x) == 0)
71extern double logb (double);
72#endif /* not HPUX and HAVE_LOGB and no logb macro */
73
74#if defined (DOMAIN) && defined (SING) && defined (OVERFLOW)
75 /* If those are defined, then this is probably a `matherr' machine. */
76# ifndef HAVE_MATHERR
77# define HAVE_MATHERR
78# endif
79#endif
80
81#ifdef NO_MATHERR
82#undef HAVE_MATHERR
83#endif 48#endif
84 49#ifndef isnan
85#ifdef HAVE_MATHERR 50# define isnan(x) ((x) != (x))
86# ifdef FLOAT_CHECK_ERRNO
87# undef FLOAT_CHECK_ERRNO
88# endif
89# ifdef FLOAT_CHECK_DOMAIN
90# undef FLOAT_CHECK_DOMAIN
91# endif
92#endif
93
94#ifndef NO_FLOAT_CHECK_ERRNO
95#define FLOAT_CHECK_ERRNO
96#endif
97
98#ifdef FLOAT_CHECK_ERRNO
99# include <errno.h>
100#endif
101
102#ifdef FLOAT_CATCH_SIGILL
103static void float_error ();
104#endif
105
106/* Nonzero while executing in floating point.
107 This tells float_error what to do. */
108
109static int in_float;
110
111/* If an argument is out of range for a mathematical function,
112 here is the actual argument value to use in the error message.
113 These variables are used only across the floating point library call
114 so there is no need to staticpro them. */
115
116static Lisp_Object float_error_arg, float_error_arg2;
117
118static const char *float_error_fn_name;
119
120/* Evaluate the floating point expression D, recording NUM
121 as the original argument for error messages.
122 D is normally an assignment expression.
123 Handle errors which may result in signals or may set errno.
124
125 Note that float_error may be declared to return void, so you can't
126 just cast the zero after the colon to (void) to make the types
127 check properly. */
128
129#ifdef FLOAT_CHECK_ERRNO
130#define IN_FLOAT(d, name, num) \
131 do { \
132 float_error_arg = num; \
133 float_error_fn_name = name; \
134 in_float = 1; errno = 0; (d); in_float = 0; \
135 switch (errno) { \
136 case 0: break; \
137 case EDOM: domain_error (float_error_fn_name, float_error_arg); \
138 case ERANGE: range_error (float_error_fn_name, float_error_arg); \
139 default: arith_error (float_error_fn_name, float_error_arg); \
140 } \
141 } while (0)
142#define IN_FLOAT2(d, name, num, num2) \
143 do { \
144 float_error_arg = num; \
145 float_error_arg2 = num2; \
146 float_error_fn_name = name; \
147 in_float = 1; errno = 0; (d); in_float = 0; \
148 switch (errno) { \
149 case 0: break; \
150 case EDOM: domain_error (float_error_fn_name, float_error_arg); \
151 case ERANGE: range_error (float_error_fn_name, float_error_arg); \
152 default: arith_error (float_error_fn_name, float_error_arg); \
153 } \
154 } while (0)
155#else
156#define IN_FLOAT(d, name, num) (in_float = 1, (d), in_float = 0)
157#define IN_FLOAT2(d, name, num, num2) (in_float = 1, (d), in_float = 0)
158#endif
159
160/* Convert float to Lisp_Int if it fits, else signal a range error
161 using the given arguments. */
162#define FLOAT_TO_INT(x, i, name, num) \
163 do \
164 { \
165 if (FIXNUM_OVERFLOW_P (x)) \
166 range_error (name, num); \
167 XSETINT (i, (EMACS_INT)(x)); \
168 } \
169 while (0)
170#define FLOAT_TO_INT2(x, i, name, num1, num2) \
171 do \
172 { \
173 if (FIXNUM_OVERFLOW_P (x)) \
174 range_error2 (name, num1, num2); \
175 XSETINT (i, (EMACS_INT)(x)); \
176 } \
177 while (0)
178
179#define arith_error(op,arg) \
180 xsignal2 (Qarith_error, build_string ((op)), (arg))
181#define range_error(op,arg) \
182 xsignal2 (Qrange_error, build_string ((op)), (arg))
183#define range_error2(op,a1,a2) \
184 xsignal3 (Qrange_error, build_string ((op)), (a1), (a2))
185#define domain_error(op,arg) \
186 xsignal2 (Qdomain_error, build_string ((op)), (arg))
187#ifdef FLOAT_CHECK_DOMAIN
188#define domain_error2(op,a1,a2) \
189 xsignal3 (Qdomain_error, build_string ((op)), (a1), (a2))
190#endif 51#endif
191 52
192/* Extract a Lisp number as a `double', or signal an error. */ 53/* Extract a Lisp number as a `double', or signal an error. */
@@ -205,27 +66,19 @@ extract_float (Lisp_Object num)
205 66
206DEFUN ("acos", Facos, Sacos, 1, 1, 0, 67DEFUN ("acos", Facos, Sacos, 1, 1, 0,
207 doc: /* Return the inverse cosine of ARG. */) 68 doc: /* Return the inverse cosine of ARG. */)
208 (register Lisp_Object arg) 69 (Lisp_Object arg)
209{ 70{
210 double d = extract_float (arg); 71 double d = extract_float (arg);
211#ifdef FLOAT_CHECK_DOMAIN 72 d = acos (d);
212 if (d > 1.0 || d < -1.0)
213 domain_error ("acos", arg);
214#endif
215 IN_FLOAT (d = acos (d), "acos", arg);
216 return make_float (d); 73 return make_float (d);
217} 74}
218 75
219DEFUN ("asin", Fasin, Sasin, 1, 1, 0, 76DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
220 doc: /* Return the inverse sine of ARG. */) 77 doc: /* Return the inverse sine of ARG. */)
221 (register Lisp_Object arg) 78 (Lisp_Object arg)
222{ 79{
223 double d = extract_float (arg); 80 double d = extract_float (arg);
224#ifdef FLOAT_CHECK_DOMAIN 81 d = asin (d);
225 if (d > 1.0 || d < -1.0)
226 domain_error ("asin", arg);
227#endif
228 IN_FLOAT (d = asin (d), "asin", arg);
229 return make_float (d); 82 return make_float (d);
230} 83}
231 84
@@ -235,56 +88,47 @@ If only one argument Y is given, return the inverse tangent of Y.
235If two arguments Y and X are given, return the inverse tangent of Y 88If two arguments Y and X are given, return the inverse tangent of Y
236divided by X, i.e. the angle in radians between the vector (X, Y) 89divided by X, i.e. the angle in radians between the vector (X, Y)
237and the x-axis. */) 90and the x-axis. */)
238 (register Lisp_Object y, Lisp_Object x) 91 (Lisp_Object y, Lisp_Object x)
239{ 92{
240 double d = extract_float (y); 93 double d = extract_float (y);
241 94
242 if (NILP (x)) 95 if (NILP (x))
243 IN_FLOAT (d = atan (d), "atan", y); 96 d = atan (d);
244 else 97 else
245 { 98 {
246 double d2 = extract_float (x); 99 double d2 = extract_float (x);
247 100 d = atan2 (d, d2);
248 IN_FLOAT2 (d = atan2 (d, d2), "atan", y, x);
249 } 101 }
250 return make_float (d); 102 return make_float (d);
251} 103}
252 104
253DEFUN ("cos", Fcos, Scos, 1, 1, 0, 105DEFUN ("cos", Fcos, Scos, 1, 1, 0,
254 doc: /* Return the cosine of ARG. */) 106 doc: /* Return the cosine of ARG. */)
255 (register Lisp_Object arg) 107 (Lisp_Object arg)
256{ 108{
257 double d = extract_float (arg); 109 double d = extract_float (arg);
258 IN_FLOAT (d = cos (d), "cos", arg); 110 d = cos (d);
259 return make_float (d); 111 return make_float (d);
260} 112}
261 113
262DEFUN ("sin", Fsin, Ssin, 1, 1, 0, 114DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
263 doc: /* Return the sine of ARG. */) 115 doc: /* Return the sine of ARG. */)
264 (register Lisp_Object arg) 116 (Lisp_Object arg)
265{ 117{
266 double d = extract_float (arg); 118 double d = extract_float (arg);
267 IN_FLOAT (d = sin (d), "sin", arg); 119 d = sin (d);
268 return make_float (d); 120 return make_float (d);
269} 121}
270 122
271DEFUN ("tan", Ftan, Stan, 1, 1, 0, 123DEFUN ("tan", Ftan, Stan, 1, 1, 0,
272 doc: /* Return the tangent of ARG. */) 124 doc: /* Return the tangent of ARG. */)
273 (register Lisp_Object arg) 125 (Lisp_Object arg)
274{ 126{
275 double d = extract_float (arg); 127 double d = extract_float (arg);
276 double c = cos (d); 128 d = tan (d);
277#ifdef FLOAT_CHECK_DOMAIN
278 if (c == 0.0)
279 domain_error ("tan", arg);
280#endif
281 IN_FLOAT (d = sin (d) / c, "tan", arg);
282 return make_float (d); 129 return make_float (d);
283} 130}
284 131
285#undef isnan
286#define isnan(x) ((x) != (x))
287
288DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, 132DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
289 doc: /* Return non nil iff argument X is a NaN. */) 133 doc: /* Return non nil iff argument X is a NaN. */)
290 (Lisp_Object x) 134 (Lisp_Object x)
@@ -309,6 +153,7 @@ Cause an error if X1 or X2 is not a float. */)
309 153
310 return make_float (copysign (f1, f2)); 154 return make_float (copysign (f1, f2));
311} 155}
156#endif
312 157
313DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, 158DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0,
314 doc: /* Get significand and exponent of a floating point number. 159 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. */)
323 (Lisp_Object x) 168 (Lisp_Object x)
324{ 169{
325 double f = XFLOATINT (x); 170 double f = XFLOATINT (x);
326 171 int exponent;
327 if (f == 0.0) 172 double sgnfcand = frexp (f, &exponent);
328 return Fcons (make_float (0.0), make_number (0)); 173 return Fcons (make_float (sgnfcand), make_number (exponent));
329 else
330 {
331 int exponent;
332 double sgnfcand = frexp (f, &exponent);
333 return Fcons (make_float (sgnfcand), make_number (exponent));
334 }
335} 174}
336 175
337DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, 176DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0,
@@ -343,138 +182,19 @@ Returns the floating point value resulting from multiplying SGNFCAND
343 CHECK_NUMBER (exponent); 182 CHECK_NUMBER (exponent);
344 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent))); 183 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent)));
345} 184}
346#endif
347
348#if 0 /* Leave these out unless we find there's a reason for them. */
349
350DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
351 doc: /* Return the bessel function j0 of ARG. */)
352 (register Lisp_Object arg)
353{
354 double d = extract_float (arg);
355 IN_FLOAT (d = j0 (d), "bessel-j0", arg);
356 return make_float (d);
357}
358
359DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
360 doc: /* Return the bessel function j1 of ARG. */)
361 (register Lisp_Object arg)
362{
363 double d = extract_float (arg);
364 IN_FLOAT (d = j1 (d), "bessel-j1", arg);
365 return make_float (d);
366}
367
368DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
369 doc: /* Return the order N bessel function output jn of ARG.
370The first arg (the order) is truncated to an integer. */)
371 (register Lisp_Object n, Lisp_Object arg)
372{
373 int i1 = extract_float (n);
374 double f2 = extract_float (arg);
375
376 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", n);
377 return make_float (f2);
378}
379
380DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
381 doc: /* Return the bessel function y0 of ARG. */)
382 (register Lisp_Object arg)
383{
384 double d = extract_float (arg);
385 IN_FLOAT (d = y0 (d), "bessel-y0", arg);
386 return make_float (d);
387}
388
389DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
390 doc: /* Return the bessel function y1 of ARG. */)
391 (register Lisp_Object arg)
392{
393 double d = extract_float (arg);
394 IN_FLOAT (d = y1 (d), "bessel-y0", arg);
395 return make_float (d);
396}
397
398DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
399 doc: /* Return the order N bessel function output yn of ARG.
400The first arg (the order) is truncated to an integer. */)
401 (register Lisp_Object n, Lisp_Object arg)
402{
403 int i1 = extract_float (n);
404 double f2 = extract_float (arg);
405
406 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", n);
407 return make_float (f2);
408}
409
410#endif
411
412#if 0 /* Leave these out unless we see they are worth having. */
413
414DEFUN ("erf", Ferf, Serf, 1, 1, 0,
415 doc: /* Return the mathematical error function of ARG. */)
416 (register Lisp_Object arg)
417{
418 double d = extract_float (arg);
419 IN_FLOAT (d = erf (d), "erf", arg);
420 return make_float (d);
421}
422
423DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
424 doc: /* Return the complementary error function of ARG. */)
425 (register Lisp_Object arg)
426{
427 double d = extract_float (arg);
428 IN_FLOAT (d = erfc (d), "erfc", arg);
429 return make_float (d);
430}
431
432DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
433 doc: /* Return the log gamma of ARG. */)
434 (register Lisp_Object arg)
435{
436 double d = extract_float (arg);
437 IN_FLOAT (d = lgamma (d), "log-gamma", arg);
438 return make_float (d);
439}
440
441DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
442 doc: /* Return the cube root of ARG. */)
443 (register Lisp_Object arg)
444{
445 double d = extract_float (arg);
446#ifdef HAVE_CBRT
447 IN_FLOAT (d = cbrt (d), "cube-root", arg);
448#else
449 if (d >= 0.0)
450 IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg);
451 else
452 IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg);
453#endif
454 return make_float (d);
455}
456
457#endif
458 185
459DEFUN ("exp", Fexp, Sexp, 1, 1, 0, 186DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
460 doc: /* Return the exponential base e of ARG. */) 187 doc: /* Return the exponential base e of ARG. */)
461 (register Lisp_Object arg) 188 (Lisp_Object arg)
462{ 189{
463 double d = extract_float (arg); 190 double d = extract_float (arg);
464#ifdef FLOAT_CHECK_DOMAIN 191 d = exp (d);
465 if (d > 709.7827) /* Assume IEEE doubles here */
466 range_error ("exp", arg);
467 else if (d < -709.0)
468 return make_float (0.0);
469 else
470#endif
471 IN_FLOAT (d = exp (d), "exp", arg);
472 return make_float (d); 192 return make_float (d);
473} 193}
474 194
475DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, 195DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
476 doc: /* Return the exponential ARG1 ** ARG2. */) 196 doc: /* Return the exponential ARG1 ** ARG2. */)
477 (register Lisp_Object arg1, Lisp_Object arg2) 197 (Lisp_Object arg1, Lisp_Object arg2)
478{ 198{
479 double f1, f2, f3; 199 double f1, f2, f3;
480 200
@@ -503,159 +223,48 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
503 } 223 }
504 f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1); 224 f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1);
505 f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2); 225 f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2);
506 /* Really should check for overflow, too */ 226 f3 = pow (f1, f2);
507 if (f1 == 0.0 && f2 == 0.0)
508 f1 = 1.0;
509#ifdef FLOAT_CHECK_DOMAIN
510 else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor (f2)))
511 domain_error2 ("expt", arg1, arg2);
512#endif
513 IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2);
514 /* Check for overflow in the result. */
515 if (f1 != 0.0 && f3 == 0.0)
516 range_error ("expt", arg1);
517 return make_float (f3); 227 return make_float (f3);
518} 228}
519 229
520DEFUN ("log", Flog, Slog, 1, 2, 0, 230DEFUN ("log", Flog, Slog, 1, 2, 0,
521 doc: /* Return the natural logarithm of ARG. 231 doc: /* Return the natural logarithm of ARG.
522If the optional argument BASE is given, return log ARG using that base. */) 232If the optional argument BASE is given, return log ARG using that base. */)
523 (register Lisp_Object arg, Lisp_Object base) 233 (Lisp_Object arg, Lisp_Object base)
524{ 234{
525 double d = extract_float (arg); 235 double d = extract_float (arg);
526 236
527#ifdef FLOAT_CHECK_DOMAIN
528 if (d <= 0.0)
529 domain_error2 ("log", arg, base);
530#endif
531 if (NILP (base)) 237 if (NILP (base))
532 IN_FLOAT (d = log (d), "log", arg); 238 d = log (d);
533 else 239 else
534 { 240 {
535 double b = extract_float (base); 241 double b = extract_float (base);
536 242
537#ifdef FLOAT_CHECK_DOMAIN
538 if (b <= 0.0 || b == 1.0)
539 domain_error2 ("log", arg, base);
540#endif
541 if (b == 10.0) 243 if (b == 10.0)
542 IN_FLOAT2 (d = log10 (d), "log", arg, base); 244 d = log10 (d);
543 else 245 else
544 IN_FLOAT2 (d = log (d) / log (b), "log", arg, base); 246 d = log (d) / log (b);
545 } 247 }
546 return make_float (d); 248 return make_float (d);
547} 249}
548 250
549DEFUN ("log10", Flog10, Slog10, 1, 1, 0, 251DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
550 doc: /* Return the logarithm base 10 of ARG. */) 252 doc: /* Return the logarithm base 10 of ARG. */)
551 (register Lisp_Object arg) 253 (Lisp_Object arg)
552{ 254{
553 double d = extract_float (arg); 255 double d = extract_float (arg);
554#ifdef FLOAT_CHECK_DOMAIN 256 d = log10 (d);
555 if (d <= 0.0)
556 domain_error ("log10", arg);
557#endif
558 IN_FLOAT (d = log10 (d), "log10", arg);
559 return make_float (d); 257 return make_float (d);
560} 258}
561 259
562DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, 260DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
563 doc: /* Return the square root of ARG. */) 261 doc: /* Return the square root of ARG. */)
564 (register Lisp_Object arg) 262 (Lisp_Object arg)
565{
566 double d = extract_float (arg);
567#ifdef FLOAT_CHECK_DOMAIN
568 if (d < 0.0)
569 domain_error ("sqrt", arg);
570#endif
571 IN_FLOAT (d = sqrt (d), "sqrt", arg);
572 return make_float (d);
573}
574
575#if 0 /* Not clearly worth adding. */
576
577DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
578 doc: /* Return the inverse hyperbolic cosine of ARG. */)
579 (register Lisp_Object arg)
580{
581 double d = extract_float (arg);
582#ifdef FLOAT_CHECK_DOMAIN
583 if (d < 1.0)
584 domain_error ("acosh", arg);
585#endif
586#ifdef HAVE_INVERSE_HYPERBOLIC
587 IN_FLOAT (d = acosh (d), "acosh", arg);
588#else
589 IN_FLOAT (d = log (d + sqrt (d*d - 1.0)), "acosh", arg);
590#endif
591 return make_float (d);
592}
593
594DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
595 doc: /* Return the inverse hyperbolic sine of ARG. */)
596 (register Lisp_Object arg)
597{
598 double d = extract_float (arg);
599#ifdef HAVE_INVERSE_HYPERBOLIC
600 IN_FLOAT (d = asinh (d), "asinh", arg);
601#else
602 IN_FLOAT (d = log (d + sqrt (d*d + 1.0)), "asinh", arg);
603#endif
604 return make_float (d);
605}
606
607DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
608 doc: /* Return the inverse hyperbolic tangent of ARG. */)
609 (register Lisp_Object arg)
610{
611 double d = extract_float (arg);
612#ifdef FLOAT_CHECK_DOMAIN
613 if (d >= 1.0 || d <= -1.0)
614 domain_error ("atanh", arg);
615#endif
616#ifdef HAVE_INVERSE_HYPERBOLIC
617 IN_FLOAT (d = atanh (d), "atanh", arg);
618#else
619 IN_FLOAT (d = 0.5 * log ((1.0 + d) / (1.0 - d)), "atanh", arg);
620#endif
621 return make_float (d);
622}
623
624DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
625 doc: /* Return the hyperbolic cosine of ARG. */)
626 (register Lisp_Object arg)
627{
628 double d = extract_float (arg);
629#ifdef FLOAT_CHECK_DOMAIN
630 if (d > 710.0 || d < -710.0)
631 range_error ("cosh", arg);
632#endif
633 IN_FLOAT (d = cosh (d), "cosh", arg);
634 return make_float (d);
635}
636
637DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
638 doc: /* Return the hyperbolic sine of ARG. */)
639 (register Lisp_Object arg)
640{
641 double d = extract_float (arg);
642#ifdef FLOAT_CHECK_DOMAIN
643 if (d > 710.0 || d < -710.0)
644 range_error ("sinh", arg);
645#endif
646 IN_FLOAT (d = sinh (d), "sinh", arg);
647 return make_float (d);
648}
649
650DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
651 doc: /* Return the hyperbolic tangent of ARG. */)
652 (register Lisp_Object arg)
653{ 263{
654 double d = extract_float (arg); 264 double d = extract_float (arg);
655 IN_FLOAT (d = tanh (d), "tanh", arg); 265 d = sqrt (d);
656 return make_float (d); 266 return make_float (d);
657} 267}
658#endif
659 268
660DEFUN ("abs", Fabs, Sabs, 1, 1, 0, 269DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
661 doc: /* Return the absolute value of ARG. */) 270 doc: /* Return the absolute value of ARG. */)
@@ -694,38 +303,15 @@ This is the same as the exponent of a float. */)
694 303
695 if (f == 0.0) 304 if (f == 0.0)
696 value = MOST_NEGATIVE_FIXNUM; 305 value = MOST_NEGATIVE_FIXNUM;
697 else 306 else if (isfinite (f))
698 { 307 {
699#ifdef HAVE_LOGB
700 IN_FLOAT (value = logb (f), "logb", arg);
701#else
702#ifdef HAVE_FREXP
703 int ivalue; 308 int ivalue;
704 IN_FLOAT (frexp (f, &ivalue), "logb", arg); 309 frexp (f, &ivalue);
705 value = ivalue - 1; 310 value = ivalue - 1;
706#else
707 int i;
708 double d;
709 if (f < 0.0)
710 f = -f;
711 value = -1;
712 while (f < 0.5)
713 {
714 for (i = 1, d = 0.5; d * d >= f; i += i)
715 d *= d;
716 f /= d;
717 value -= i;
718 }
719 while (f >= 1.0)
720 {
721 for (i = 1, d = 2.0; d * d <= f; i += i)
722 d *= d;
723 f /= d;
724 value += i;
725 }
726#endif
727#endif
728 } 311 }
312 else
313 value = MOST_POSITIVE_FIXNUM;
314
729 XSETINT (val, value); 315 XSETINT (val, value);
730 return val; 316 return val;
731} 317}
@@ -756,8 +342,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor,
756 if (! IEEE_FLOATING_POINT && f2 == 0) 342 if (! IEEE_FLOATING_POINT && f2 == 0)
757 xsignal0 (Qarith_error); 343 xsignal0 (Qarith_error);
758 344
759 IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor); 345 f1 = (*double_round) (f1 / f2);
760 FLOAT_TO_INT2 (f1, arg, name, arg, divisor); 346 if (FIXNUM_OVERFLOW_P (f1))
347 xsignal3 (Qrange_error, build_string (name), arg, divisor);
348 arg = make_number (f1);
761 return arg; 349 return arg;
762 } 350 }
763 351
@@ -773,10 +361,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor,
773 361
774 if (FLOATP (arg)) 362 if (FLOATP (arg))
775 { 363 {
776 double d; 364 double d = (*double_round) (XFLOAT_DATA (arg));
777 365 if (FIXNUM_OVERFLOW_P (d))
778 IN_FLOAT (d = (*double_round) (XFLOAT_DATA (arg)), name, arg); 366 xsignal2 (Qrange_error, build_string (name), arg);
779 FLOAT_TO_INT (d, arg, name, arg); 367 arg = make_number (d);
780 } 368 }
781 369
782 return arg; 370 return arg;
@@ -893,125 +481,57 @@ fmod_float (Lisp_Object x, Lisp_Object y)
893 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x); 481 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x);
894 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y); 482 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y);
895 483
896 if (! IEEE_FLOATING_POINT && f2 == 0) 484 f1 = fmod (f1, f2);
897 xsignal0 (Qarith_error);
898 485
899 /* If the "remainder" comes out with the wrong sign, fix it. */ 486 /* If the "remainder" comes out with the wrong sign, fix it. */
900 IN_FLOAT2 ((f1 = fmod (f1, f2), 487 if (f2 < 0 ? 0 < f1 : f1 < 0)
901 f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1), 488 f1 += f2;
902 "mod", x, y); 489
903 return make_float (f1); 490 return make_float (f1);
904} 491}
905 492
906/* It's not clear these are worth adding. */
907
908DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0, 493DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0,
909 doc: /* Return the smallest integer no less than ARG, as a float. 494 doc: /* Return the smallest integer no less than ARG, as a float.
910\(Round toward +inf.\) */) 495\(Round toward +inf.\) */)
911 (register Lisp_Object arg) 496 (Lisp_Object arg)
912{ 497{
913 double d = extract_float (arg); 498 double d = extract_float (arg);
914 IN_FLOAT (d = ceil (d), "fceiling", arg); 499 d = ceil (d);
915 return make_float (d); 500 return make_float (d);
916} 501}
917 502
918DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0, 503DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0,
919 doc: /* Return the largest integer no greater than ARG, as a float. 504 doc: /* Return the largest integer no greater than ARG, as a float.
920\(Round towards -inf.\) */) 505\(Round towards -inf.\) */)
921 (register Lisp_Object arg) 506 (Lisp_Object arg)
922{ 507{
923 double d = extract_float (arg); 508 double d = extract_float (arg);
924 IN_FLOAT (d = floor (d), "ffloor", arg); 509 d = floor (d);
925 return make_float (d); 510 return make_float (d);
926} 511}
927 512
928DEFUN ("fround", Ffround, Sfround, 1, 1, 0, 513DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
929 doc: /* Return the nearest integer to ARG, as a float. */) 514 doc: /* Return the nearest integer to ARG, as a float. */)
930 (register Lisp_Object arg) 515 (Lisp_Object arg)
931{ 516{
932 double d = extract_float (arg); 517 double d = extract_float (arg);
933 IN_FLOAT (d = emacs_rint (d), "fround", arg); 518 d = emacs_rint (d);
934 return make_float (d); 519 return make_float (d);
935} 520}
936 521
937DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, 522DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
938 doc: /* Truncate a floating point number to an integral float value. 523 doc: /* Truncate a floating point number to an integral float value.
939Rounds the value toward zero. */) 524Rounds the value toward zero. */)
940 (register Lisp_Object arg) 525 (Lisp_Object arg)
941{ 526{
942 double d = extract_float (arg); 527 double d = extract_float (arg);
943 if (d >= 0.0) 528 if (d >= 0.0)
944 IN_FLOAT (d = floor (d), "ftruncate", arg); 529 d = floor (d);
945 else 530 else
946 IN_FLOAT (d = ceil (d), "ftruncate", arg); 531 d = ceil (d);
947 return make_float (d); 532 return make_float (d);
948} 533}
949 534
950#ifdef FLOAT_CATCH_SIGILL
951static void
952float_error (int signo)
953{
954 if (! in_float)
955 fatal_error_signal (signo);
956
957#ifdef BSD_SYSTEM
958 sigsetmask (SIGEMPTYMASK);
959#else
960 /* Must reestablish handler each time it is called. */
961 signal (SIGILL, float_error);
962#endif /* BSD_SYSTEM */
963
964 SIGNAL_THREAD_CHECK (signo);
965 in_float = 0;
966
967 xsignal1 (Qarith_error, float_error_arg);
968}
969
970/* Another idea was to replace the library function `infnan'
971 where SIGILL is signaled. */
972
973#endif /* FLOAT_CATCH_SIGILL */
974
975#ifdef HAVE_MATHERR
976int
977matherr (struct exception *x)
978{
979 Lisp_Object args;
980 const char *name = x->name;
981
982 if (! in_float)
983 /* Not called from emacs-lisp float routines; do the default thing. */
984 return 0;
985 if (!strcmp (x->name, "pow"))
986 name = "expt";
987
988 args
989 = Fcons (build_string (name),
990 Fcons (make_float (x->arg1),
991 ((!strcmp (name, "log") || !strcmp (name, "pow"))
992 ? Fcons (make_float (x->arg2), Qnil)
993 : Qnil)));
994 switch (x->type)
995 {
996 case DOMAIN: xsignal (Qdomain_error, args); break;
997 case SING: xsignal (Qsingularity_error, args); break;
998 case OVERFLOW: xsignal (Qoverflow_error, args); break;
999 case UNDERFLOW: xsignal (Qunderflow_error, args); break;
1000 default: xsignal (Qarith_error, args); break;
1001 }
1002 return (1); /* don't set errno or print a message */
1003}
1004#endif /* HAVE_MATHERR */
1005
1006void
1007init_floatfns (void)
1008{
1009#ifdef FLOAT_CATCH_SIGILL
1010 signal (SIGILL, float_error);
1011#endif
1012 in_float = 0;
1013}
1014
1015void 535void
1016syms_of_floatfns (void) 536syms_of_floatfns (void)
1017{ 537{
@@ -1024,27 +544,9 @@ syms_of_floatfns (void)
1024 defsubr (&Sisnan); 544 defsubr (&Sisnan);
1025#ifdef HAVE_COPYSIGN 545#ifdef HAVE_COPYSIGN
1026 defsubr (&Scopysign); 546 defsubr (&Scopysign);
547#endif
1027 defsubr (&Sfrexp); 548 defsubr (&Sfrexp);
1028 defsubr (&Sldexp); 549 defsubr (&Sldexp);
1029#endif
1030#if 0
1031 defsubr (&Sacosh);
1032 defsubr (&Sasinh);
1033 defsubr (&Satanh);
1034 defsubr (&Scosh);
1035 defsubr (&Ssinh);
1036 defsubr (&Stanh);
1037 defsubr (&Sbessel_y0);
1038 defsubr (&Sbessel_y1);
1039 defsubr (&Sbessel_yn);
1040 defsubr (&Sbessel_j0);
1041 defsubr (&Sbessel_j1);
1042 defsubr (&Sbessel_jn);
1043 defsubr (&Serf);
1044 defsubr (&Serfc);
1045 defsubr (&Slog_gamma);
1046 defsubr (&Scube_root);
1047#endif
1048 defsubr (&Sfceiling); 550 defsubr (&Sfceiling);
1049 defsubr (&Sffloor); 551 defsubr (&Sffloor);
1050 defsubr (&Sfround); 552 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/>. */
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <time.h> 23#include <time.h>
24#include <setjmp.h>
25 24
26#include <intprops.h> 25#include <intprops.h>
27 26
@@ -51,11 +50,7 @@ static Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
51 50
52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512; 51static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512;
53 52
54static int internal_equal (Lisp_Object , Lisp_Object, int, int); 53static bool internal_equal (Lisp_Object, Lisp_Object, int, bool);
55
56#ifndef HAVE_UNISTD_H
57extern long time ();
58#endif
59 54
60DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 55DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
61 doc: /* Return the argument unchanged. */) 56 doc: /* Return the argument unchanged. */)
@@ -356,7 +351,7 @@ Symbols are also allowed; their print names are used instead. */)
356} 351}
357 352
358static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, 353static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args,
359 enum Lisp_Type target_type, int last_special); 354 enum Lisp_Type target_type, bool last_special);
360 355
361/* ARGSUSED */ 356/* ARGSUSED */
362Lisp_Object 357Lisp_Object
@@ -454,19 +449,19 @@ struct textprop_rec
454 449
455static Lisp_Object 450static Lisp_Object
456concat (ptrdiff_t nargs, Lisp_Object *args, 451concat (ptrdiff_t nargs, Lisp_Object *args,
457 enum Lisp_Type target_type, int last_special) 452 enum Lisp_Type target_type, bool last_special)
458{ 453{
459 Lisp_Object val; 454 Lisp_Object val;
460 register Lisp_Object tail; 455 Lisp_Object tail;
461 register Lisp_Object this; 456 Lisp_Object this;
462 ptrdiff_t toindex; 457 ptrdiff_t toindex;
463 ptrdiff_t toindex_byte = 0; 458 ptrdiff_t toindex_byte = 0;
464 register EMACS_INT result_len; 459 EMACS_INT result_len;
465 register EMACS_INT result_len_byte; 460 EMACS_INT result_len_byte;
466 ptrdiff_t argnum; 461 ptrdiff_t argnum;
467 Lisp_Object last_tail; 462 Lisp_Object last_tail;
468 Lisp_Object prev; 463 Lisp_Object prev;
469 int some_multibyte; 464 bool some_multibyte;
470 /* When we make a multibyte string, we can't copy text properties 465 /* When we make a multibyte string, we can't copy text properties
471 while concatenating each string because the length of resulting 466 while concatenating each string because the length of resulting
472 string can't be decided until we finish the whole concatenation. 467 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. */)
1531} 1526}
1532 1527
1533DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0, 1528DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
1534 doc: /* Delete by side effect any occurrences of ELT as a member of LIST. 1529 doc: /* Delete members of LIST which are `eq' to ELT, and return the result.
1535The modified LIST is returned. Comparison is done with `eq'. 1530More precisely, this function skips any members `eq' to ELT at the
1536If the first member of LIST is ELT, there is no way to remove it by side effect; 1531front of LIST, then removes members `eq' to ELT from the remaining
1537therefore, write `(setq foo (delq element foo))' 1532sublist by modifying its list structure, then returns the resulting
1538to be sure of changing the value of `foo'. */) 1533list.
1534
1535Write `(setq foo (delq element foo))' to be sure of correctly changing
1536the value of a list `foo'. */)
1539 (register Lisp_Object elt, Lisp_Object list) 1537 (register Lisp_Object elt, Lisp_Object list)
1540{ 1538{
1541 register Lisp_Object tail, prev; 1539 register Lisp_Object tail, prev;
@@ -1563,13 +1561,19 @@ to be sure of changing the value of `foo'. */)
1563} 1561}
1564 1562
1565DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0, 1563DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0,
1566 doc: /* Delete by side effect any occurrences of ELT as a member of SEQ. 1564 doc: /* Delete members of SEQ which are `equal' to ELT, and return the result.
1567SEQ must be a list, a vector, or a string. 1565SEQ must be a sequence (i.e. a list, a vector, or a string).
1568The modified SEQ is returned. Comparison is done with `equal'. 1566The return value is a sequence of the same type.
1569If SEQ is not a list, or the first member of SEQ is ELT, deleting it 1567
1570is not a side effect; it is simply using a different sequence. 1568If SEQ is a list, this behaves like `delq', except that it compares
1571Therefore, write `(setq foo (delete element foo))' 1569with `equal' instead of `eq'. In particular, it may remove elements
1572to be sure of changing the value of `foo'. */) 1570by altering the list structure.
1571
1572If SEQ is not a list, deletion is never performed destructively;
1573instead this function creates and returns a new vector or string.
1574
1575Write `(setq foo (delete element foo))' to be sure of correctly
1576changing the value of a sequence `foo'. */)
1573 (Lisp_Object elt, Lisp_Object seq) 1577 (Lisp_Object elt, Lisp_Object seq)
1574{ 1578{
1575 if (VECTORP (seq)) 1579 if (VECTORP (seq))
@@ -1992,10 +1996,10 @@ of strings. (`equal' ignores text properties.) */)
1992 1996
1993/* DEPTH is current depth of recursion. Signal an error if it 1997/* DEPTH is current depth of recursion. Signal an error if it
1994 gets too deep. 1998 gets too deep.
1995 PROPS, if non-nil, means compare string text properties too. */ 1999 PROPS means compare string text properties too. */
1996 2000
1997static int 2001static bool
1998internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int props) 2002internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
1999{ 2003{
2000 if (depth > 200) 2004 if (depth > 200)
2001 error ("Stack overflow in equal"); 2005 error ("Stack overflow in equal");
@@ -2593,9 +2597,9 @@ Normally the return value is FEATURE.
2593The normal messages at start and end of loading FILENAME are suppressed. */) 2597The normal messages at start and end of loading FILENAME are suppressed. */)
2594 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror) 2598 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror)
2595{ 2599{
2596 register Lisp_Object tem; 2600 Lisp_Object tem;
2597 struct gcpro gcpro1, gcpro2; 2601 struct gcpro gcpro1, gcpro2;
2598 int from_file = load_in_progress; 2602 bool from_file = load_in_progress;
2599 2603
2600 CHECK_SYMBOL (feature); 2604 CHECK_SYMBOL (feature);
2601 2605
@@ -2921,8 +2925,8 @@ static const short base64_char_to_value[128] =
2921 base64 characters. */ 2925 base64 characters. */
2922 2926
2923 2927
2924static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, int, int); 2928static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, bool, bool);
2925static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, int, 2929static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, bool,
2926 ptrdiff_t *); 2930 ptrdiff_t *);
2927 2931
2928DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2932DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
@@ -2957,7 +2961,7 @@ into shorter lines. */)
2957 encoded, length, NILP (no_line_break), 2961 encoded, length, NILP (no_line_break),
2958 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 2962 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
2959 if (encoded_length > allength) 2963 if (encoded_length > allength)
2960 abort (); 2964 emacs_abort ();
2961 2965
2962 if (encoded_length < 0) 2966 if (encoded_length < 0)
2963 { 2967 {
@@ -3013,7 +3017,7 @@ into shorter lines. */)
3013 encoded, length, NILP (no_line_break), 3017 encoded, length, NILP (no_line_break),
3014 STRING_MULTIBYTE (string)); 3018 STRING_MULTIBYTE (string));
3015 if (encoded_length > allength) 3019 if (encoded_length > allength)
3016 abort (); 3020 emacs_abort ();
3017 3021
3018 if (encoded_length < 0) 3022 if (encoded_length < 0)
3019 { 3023 {
@@ -3030,7 +3034,7 @@ into shorter lines. */)
3030 3034
3031static ptrdiff_t 3035static ptrdiff_t
3032base64_encode_1 (const char *from, char *to, ptrdiff_t length, 3036base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3033 int line_break, int multibyte) 3037 bool line_break, bool multibyte)
3034{ 3038{
3035 int counter = 0; 3039 int counter = 0;
3036 ptrdiff_t i = 0; 3040 ptrdiff_t i = 0;
@@ -3137,7 +3141,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3137 ptrdiff_t old_pos = PT; 3141 ptrdiff_t old_pos = PT;
3138 ptrdiff_t decoded_length; 3142 ptrdiff_t decoded_length;
3139 ptrdiff_t inserted_chars; 3143 ptrdiff_t inserted_chars;
3140 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3144 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3141 USE_SAFE_ALLOCA; 3145 USE_SAFE_ALLOCA;
3142 3146
3143 validate_region (&beg, &end); 3147 validate_region (&beg, &end);
@@ -3158,7 +3162,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3158 decoded, length, 3162 decoded, length,
3159 multibyte, &inserted_chars); 3163 multibyte, &inserted_chars);
3160 if (decoded_length > allength) 3164 if (decoded_length > allength)
3161 abort (); 3165 emacs_abort ();
3162 3166
3163 if (decoded_length < 0) 3167 if (decoded_length < 0)
3164 { 3168 {
@@ -3208,7 +3212,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3208 decoded_length = base64_decode_1 (SSDATA (string), decoded, length, 3212 decoded_length = base64_decode_1 (SSDATA (string), decoded, length,
3209 0, NULL); 3213 0, NULL);
3210 if (decoded_length > length) 3214 if (decoded_length > length)
3211 abort (); 3215 emacs_abort ();
3212 else if (decoded_length >= 0) 3216 else if (decoded_length >= 0)
3213 decoded_string = make_unibyte_string (decoded, decoded_length); 3217 decoded_string = make_unibyte_string (decoded, decoded_length);
3214 else 3218 else
@@ -3222,13 +3226,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3222} 3226}
3223 3227
3224/* Base64-decode the data at FROM of LENGTH bytes into TO. If 3228/* Base64-decode the data at FROM of LENGTH bytes into TO. If
3225 MULTIBYTE is nonzero, the decoded result should be in multibyte 3229 MULTIBYTE, the decoded result should be in multibyte
3226 form. If NCHARS_RETURN is not NULL, store the number of produced 3230 form. If NCHARS_RETURN is not NULL, store the number of produced
3227 characters in *NCHARS_RETURN. */ 3231 characters in *NCHARS_RETURN. */
3228 3232
3229static ptrdiff_t 3233static ptrdiff_t
3230base64_decode_1 (const char *from, char *to, ptrdiff_t length, 3234base64_decode_1 (const char *from, char *to, ptrdiff_t length,
3231 int multibyte, ptrdiff_t *nchars_return) 3235 bool multibyte, ptrdiff_t *nchars_return)
3232{ 3236{
3233 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */ 3237 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3234 char *e = to; 3238 char *e = to;
@@ -3344,7 +3348,7 @@ static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3344static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); 3348static struct Lisp_Hash_Table *check_hash_table (Lisp_Object);
3345static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *); 3349static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *);
3346static void maybe_resize_hash_table (struct Lisp_Hash_Table *); 3350static void maybe_resize_hash_table (struct Lisp_Hash_Table *);
3347static int sweep_weak_table (struct Lisp_Hash_Table *, int); 3351static bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
3348 3352
3349 3353
3350 3354
@@ -3436,10 +3440,10 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
3436 ***********************************************************************/ 3440 ***********************************************************************/
3437 3441
3438/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3442/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3439 HASH2 in hash table H using `eql'. Value is non-zero if KEY1 and 3443 HASH2 in hash table H using `eql'. Value is true if KEY1 and
3440 KEY2 are the same. */ 3444 KEY2 are the same. */
3441 3445
3442static int 3446static bool
3443cmpfn_eql (struct Lisp_Hash_Table *h, 3447cmpfn_eql (struct Lisp_Hash_Table *h,
3444 Lisp_Object key1, EMACS_UINT hash1, 3448 Lisp_Object key1, EMACS_UINT hash1,
3445 Lisp_Object key2, EMACS_UINT hash2) 3449 Lisp_Object key2, EMACS_UINT hash2)
@@ -3451,10 +3455,10 @@ cmpfn_eql (struct Lisp_Hash_Table *h,
3451 3455
3452 3456
3453/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3457/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3454 HASH2 in hash table H using `equal'. Value is non-zero if KEY1 and 3458 HASH2 in hash table H using `equal'. Value is true if KEY1 and
3455 KEY2 are the same. */ 3459 KEY2 are the same. */
3456 3460
3457static int 3461static bool
3458cmpfn_equal (struct Lisp_Hash_Table *h, 3462cmpfn_equal (struct Lisp_Hash_Table *h,
3459 Lisp_Object key1, EMACS_UINT hash1, 3463 Lisp_Object key1, EMACS_UINT hash1,
3460 Lisp_Object key2, EMACS_UINT hash2) 3464 Lisp_Object key2, EMACS_UINT hash2)
@@ -3464,10 +3468,10 @@ cmpfn_equal (struct Lisp_Hash_Table *h,
3464 3468
3465 3469
3466/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code 3470/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code
3467 HASH2 in hash table H using H->user_cmp_function. Value is non-zero 3471 HASH2 in hash table H using H->user_cmp_function. Value is true
3468 if KEY1 and KEY2 are the same. */ 3472 if KEY1 and KEY2 are the same. */
3469 3473
3470static int 3474static bool
3471cmpfn_user_defined (struct Lisp_Hash_Table *h, 3475cmpfn_user_defined (struct Lisp_Hash_Table *h,
3472 Lisp_Object key1, EMACS_UINT hash1, 3476 Lisp_Object key1, EMACS_UINT hash1,
3473 Lisp_Object key2, EMACS_UINT hash2) 3477 Lisp_Object key2, EMACS_UINT hash2)
@@ -3675,7 +3679,7 @@ copy_hash_table (struct Lisp_Hash_Table *h1)
3675 3679
3676 h2 = allocate_hash_table (); 3680 h2 = allocate_hash_table ();
3677 next = h2->header.next.vector; 3681 next = h2->header.next.vector;
3678 memcpy (h2, h1, sizeof *h2); 3682 *h2 = *h1;
3679 h2->header.next.vector = next; 3683 h2->header.next.vector = next;
3680 h2->key_and_value = Fcopy_sequence (h1->key_and_value); 3684 h2->key_and_value = Fcopy_sequence (h1->key_and_value);
3681 h2->hash = Fcopy_sequence (h1->hash); 3685 h2->hash = Fcopy_sequence (h1->hash);
@@ -3927,16 +3931,16 @@ hash_clear (struct Lisp_Hash_Table *h)
3927 Weak Hash Tables 3931 Weak Hash Tables
3928 ************************************************************************/ 3932 ************************************************************************/
3929 3933
3930/* Sweep weak hash table H. REMOVE_ENTRIES_P non-zero means remove 3934/* Sweep weak hash table H. REMOVE_ENTRIES_P means remove
3931 entries from the table that don't survive the current GC. 3935 entries from the table that don't survive the current GC.
3932 REMOVE_ENTRIES_P zero means mark entries that are in use. Value is 3936 !REMOVE_ENTRIES_P means mark entries that are in use. Value is
3933 non-zero if anything was marked. */ 3937 true if anything was marked. */
3934 3938
3935static int 3939static bool
3936sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) 3940sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p)
3937{ 3941{
3938 ptrdiff_t bucket, n; 3942 ptrdiff_t bucket, n;
3939 int marked; 3943 bool marked;
3940 3944
3941 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; 3945 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
3942 marked = 0; 3946 marked = 0;
@@ -3953,7 +3957,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3953 ptrdiff_t i = XFASTINT (idx); 3957 ptrdiff_t i = XFASTINT (idx);
3954 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); 3958 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
3955 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); 3959 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
3956 int remove_p; 3960 bool remove_p;
3957 3961
3958 if (EQ (h->weak, Qkey)) 3962 if (EQ (h->weak, Qkey))
3959 remove_p = !key_known_to_survive_p; 3963 remove_p = !key_known_to_survive_p;
@@ -3964,7 +3968,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3964 else if (EQ (h->weak, Qkey_and_value)) 3968 else if (EQ (h->weak, Qkey_and_value))
3965 remove_p = !(key_known_to_survive_p && value_known_to_survive_p); 3969 remove_p = !(key_known_to_survive_p && value_known_to_survive_p);
3966 else 3970 else
3967 abort (); 3971 emacs_abort ();
3968 3972
3969 next = HASH_NEXT (h, i); 3973 next = HASH_NEXT (h, i);
3970 3974
@@ -4026,7 +4030,7 @@ void
4026sweep_weak_hash_tables (void) 4030sweep_weak_hash_tables (void)
4027{ 4031{
4028 struct Lisp_Hash_Table *h, *used, *next; 4032 struct Lisp_Hash_Table *h, *used, *next;
4029 int marked; 4033 bool marked;
4030 4034
4031 /* Mark all keys and values that are in use. Keep on marking until 4035 /* Mark all keys and values that are in use. Keep on marking until
4032 there is no more change. This is necessary for cases like 4036 there is no more change. This is necessary for cases like
@@ -4260,7 +4264,7 @@ sxhash (Lisp_Object obj, int depth)
4260 break; 4264 break;
4261 4265
4262 default: 4266 default:
4263 abort (); 4267 emacs_abort ();
4264 } 4268 }
4265 4269
4266 return hash; 4270 return hash;
@@ -4678,7 +4682,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4678 coding_system = Vcoding_system_for_write; 4682 coding_system = Vcoding_system_for_write;
4679 else 4683 else
4680 { 4684 {
4681 int force_raw_text = 0; 4685 bool force_raw_text = 0;
4682 4686
4683 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system); 4687 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
4684 if (NILP (coding_system) 4688 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/>. */
23#include <config.h> 23#include <config.h>
24#include <float.h> 24#include <float.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#include <c-ctype.h> 27#include <c-ctype.h>
29 28
@@ -216,13 +215,12 @@ static int num_font_drivers;
216 215
217 216
218/* Return a Lispy value of a font property value at STR and LEN bytes. 217/* Return a Lispy value of a font property value at STR and LEN bytes.
219 If STR is "*", return nil. 218 If STR is "*", return nil. If FORCE_SYMBOL, or if STR does not
220 If FORCE_SYMBOL is zero and all characters in STR are digits, 219 consist entirely of one or more digits, return a symbol interned
221 return an integer. Otherwise, return a symbol interned from 220 from STR. Otherwise, return an integer. */
222 STR. */
223 221
224Lisp_Object 222Lisp_Object
225font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) 223font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
226{ 224{
227 ptrdiff_t i; 225 ptrdiff_t i;
228 Lisp_Object tem; 226 Lisp_Object tem;
@@ -306,7 +304,8 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec)
306 VAL is an integer. */ 304 VAL is an integer. */
307 305
308int 306int
309font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror) 307font_style_to_value (enum font_property_index prop, Lisp_Object val,
308 bool noerror)
310{ 309{
311 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); 310 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX);
312 int len; 311 int len;
@@ -385,7 +384,8 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
385} 384}
386 385
387Lisp_Object 386Lisp_Object
388font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face) 387font_style_symbolic (Lisp_Object font, enum font_property_index prop,
388 bool for_face)
389{ 389{
390 Lisp_Object val = AREF (font, prop); 390 Lisp_Object val = AREF (font, prop);
391 Lisp_Object table, elt; 391 Lisp_Object table, elt;
@@ -1101,7 +1101,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font)
1101 } 1101 }
1102 else 1102 else
1103 { 1103 {
1104 int wild_card_found = 0; 1104 bool wild_card_found = 0;
1105 Lisp_Object prop[XLFD_LAST_INDEX]; 1105 Lisp_Object prop[XLFD_LAST_INDEX];
1106 1106
1107 if (FONT_ENTITY_P (font)) 1107 if (FONT_ENTITY_P (font))
@@ -1337,7 +1337,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font)
1337 } 1337 }
1338 else if (*p == '-') 1338 else if (*p == '-')
1339 { 1339 {
1340 int decimal = 0, size_found = 1; 1340 bool decimal = 0, size_found = 1;
1341 for (q = p + 1; *q && *q != ':'; q++) 1341 for (q = p + 1; *q && *q != ':'; q++)
1342 if (! c_isdigit (*q)) 1342 if (! c_isdigit (*q))
1343 { 1343 {
@@ -1938,7 +1938,7 @@ generate_otf_features (Lisp_Object spec, char *features)
1938{ 1938{
1939 Lisp_Object val; 1939 Lisp_Object val;
1940 char *p; 1940 char *p;
1941 int asterisk; 1941 bool asterisk;
1942 1942
1943 p = features; 1943 p = features;
1944 *p = '\0'; 1944 *p = '\0';
@@ -2302,11 +2302,12 @@ font_update_sort_order (int *order)
2302 } 2302 }
2303} 2303}
2304 2304
2305static int 2305static bool
2306font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table) 2306font_check_otf_features (Lisp_Object script, Lisp_Object langsys,
2307 Lisp_Object features, Lisp_Object table)
2307{ 2308{
2308 Lisp_Object val; 2309 Lisp_Object val;
2309 int negative; 2310 bool negative;
2310 2311
2311 table = assq_no_quit (script, table); 2312 table = assq_no_quit (script, table);
2312 if (NILP (table)) 2313 if (NILP (table))
@@ -2342,7 +2343,7 @@ font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object fe
2342 2343
2343/* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */ 2344/* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */
2344 2345
2345static int 2346static bool
2346font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) 2347font_check_otf (Lisp_Object spec, Lisp_Object otf_capability)
2347{ 2348{
2348 Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil; 2349 Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil;
@@ -2376,7 +2377,7 @@ font_check_otf (Lisp_Object spec, Lisp_Object otf_capability)
2376/* Check if FONT (font-entity or font-object) matches with the font 2377/* Check if FONT (font-entity or font-object) matches with the font
2377 specification SPEC. */ 2378 specification SPEC. */
2378 2379
2379int 2380bool
2380font_match_p (Lisp_Object spec, Lisp_Object font) 2381font_match_p (Lisp_Object spec, Lisp_Object font)
2381{ 2382{
2382 Lisp_Object prop[FONT_SPEC_MAX], *props; 2383 Lisp_Object prop[FONT_SPEC_MAX], *props;
@@ -2694,7 +2695,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec)
2694 Lisp_Object ftype, val; 2695 Lisp_Object ftype, val;
2695 Lisp_Object list = Qnil; 2696 Lisp_Object list = Qnil;
2696 int size; 2697 int size;
2697 int need_filtering = 0; 2698 bool need_filtering = 0;
2698 int i; 2699 int i;
2699 2700
2700 eassert (FONT_SPEC_P (spec)); 2701 eassert (FONT_SPEC_P (spec));
@@ -3036,15 +3037,14 @@ font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs,
3036{ 3037{
3037 Lisp_Object font_entity; 3038 Lisp_Object font_entity;
3038 Lisp_Object prefer; 3039 Lisp_Object prefer;
3039 int result, i; 3040 int i;
3040 FRAME_PTR f = XFRAME (frame); 3041 FRAME_PTR f = XFRAME (frame);
3041 3042
3042 if (NILP (XCDR (entities)) 3043 if (NILP (XCDR (entities))
3043 && ASIZE (XCAR (entities)) == 1) 3044 && ASIZE (XCAR (entities)) == 1)
3044 { 3045 {
3045 font_entity = AREF (XCAR (entities), 0); 3046 font_entity = AREF (XCAR (entities), 0);
3046 if (c < 0 3047 if (c < 0 || font_has_char (f, font_entity, c) > 0)
3047 || (result = font_has_char (f, font_entity, c)) > 0)
3048 return font_entity; 3048 return font_entity;
3049 return Qnil; 3049 return Qnil;
3050 } 3050 }
@@ -3618,7 +3618,7 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3618 Lisp_Object string) 3618 Lisp_Object string)
3619{ 3619{
3620 FRAME_PTR f; 3620 FRAME_PTR f;
3621 int multibyte; 3621 bool multibyte;
3622 Lisp_Object font_object; 3622 Lisp_Object font_object;
3623 3623
3624 multibyte = (NILP (string) 3624 multibyte = (NILP (string)
@@ -4295,12 +4295,15 @@ to get the correct visual image of character sequences set in the
4295header of the glyph-string. 4295header of the glyph-string.
4296 4296
4297If the shaping was successful, the value is GSTRING itself or a newly 4297If the shaping was successful, the value is GSTRING itself or a newly
4298created glyph-string. Otherwise, the value is nil. */) 4298created glyph-string. Otherwise, the value is nil.
4299
4300See the documentation of `composition-get-gstring' for the format of
4301GSTRING. */)
4299 (Lisp_Object gstring) 4302 (Lisp_Object gstring)
4300{ 4303{
4301 struct font *font; 4304 struct font *font;
4302 Lisp_Object font_object, n, glyph; 4305 Lisp_Object font_object, n, glyph;
4303 ptrdiff_t i, j, from, to; 4306 ptrdiff_t i, from, to;
4304 4307
4305 if (! composition_gstring_p (gstring)) 4308 if (! composition_gstring_p (gstring))
4306 signal_error ("Invalid glyph-string: ", gstring); 4309 signal_error ("Invalid glyph-string: ", gstring);
@@ -4326,44 +4329,42 @@ created glyph-string. Otherwise, the value is nil. */)
4326 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) 4329 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring))
4327 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); 4330 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil);
4328 4331
4332 /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that
4333 GLYPHS covers all characters (except for the last few ones) in
4334 GSTRING. More formally, provided that NCHARS is the number of
4335 characters in GSTRING and GLYPHS[i] is the ith glyph, FROM_IDX
4336 and TO_IDX of each glyph must satisfy these conditions:
4337
4338 GLYPHS[0].FROM_IDX == 0
4339 GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX
4340 if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX)
4341 ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster
4342 GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX
4343 else
4344 ;; Be sure to cover all characters.
4345 GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1 */
4329 glyph = LGSTRING_GLYPH (gstring, 0); 4346 glyph = LGSTRING_GLYPH (gstring, 0);
4330 from = LGLYPH_FROM (glyph); 4347 from = LGLYPH_FROM (glyph);
4331 to = LGLYPH_TO (glyph); 4348 to = LGLYPH_TO (glyph);
4332 for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++) 4349 if (from != 0 || to < from)
4350 goto shaper_error;
4351 for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++)
4333 { 4352 {
4334 Lisp_Object this = LGSTRING_GLYPH (gstring, i); 4353 glyph = LGSTRING_GLYPH (gstring, i);
4335 4354 if (NILP (glyph))
4336 if (NILP (this))
4337 break; 4355 break;
4338 if (NILP (LGLYPH_ADJUSTMENT (this))) 4356 if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph)
4339 { 4357 && (LGLYPH_FROM (glyph) == from
4340 if (j < i - 1) 4358 ? LGLYPH_TO (glyph) == to
4341 for (; j < i; j++) 4359 : LGLYPH_FROM (glyph) == to + 1)))
4342 { 4360 goto shaper_error;
4343 glyph = LGSTRING_GLYPH (gstring, j); 4361 from = LGLYPH_FROM (glyph);
4344 LGLYPH_SET_FROM (glyph, from); 4362 to = LGLYPH_TO (glyph);
4345 LGLYPH_SET_TO (glyph, to);
4346 }
4347 from = LGLYPH_FROM (this);
4348 to = LGLYPH_TO (this);
4349 j = i;
4350 }
4351 else
4352 {
4353 if (from > LGLYPH_FROM (this))
4354 from = LGLYPH_FROM (this);
4355 if (to < LGLYPH_TO (this))
4356 to = LGLYPH_TO (this);
4357 }
4358 } 4363 }
4359 if (j < i - 1)
4360 for (; j < i; j++)
4361 {
4362 glyph = LGSTRING_GLYPH (gstring, j);
4363 LGLYPH_SET_FROM (glyph, from);
4364 LGLYPH_SET_TO (glyph, to);
4365 }
4366 return composition_gstring_put_cache (gstring, XINT (n)); 4364 return composition_gstring_put_cache (gstring, XINT (n));
4365
4366 shaper_error:
4367 return Qnil;
4367} 4368}
4368 4369
4369DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, 4370DEFUN ("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
320 negative if that information is not in the font. */ 320 negative if that information is not in the font. */
321 int underline_position; 321 int underline_position;
322 322
323 /* 1 if `vertical-centering-font-regexp' matches this font name. 323 /* True if `vertical-centering-font-regexp' matches this font name.
324 In this case, we render characters at vertical center positions 324 In this case, we render characters at vertical center positions
325 of lines. */ 325 of lines. */
326 int vertical_centering; 326 bool vertical_centering;
327
328 /* Encoding type of the font. The value is one of
329 0, 1, 2, or 3:
330 0: code points 0x20..0x7F or 0x2020..0x7F7F are used
331 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used
332 2: code points 0x20A0..0x7FFF are used
333 3: code points 0xA020..0xFF7F are used
334 If the member `font_encoder' is not NULL, this member is ignored. */
335 unsigned char encoding_type;
336 327
337 /* The baseline position of a font is normally `ascent' value of the 328 /* The baseline position of a font is normally `ascent' value of the
338 font. However, there exist many fonts which don't set `ascent' to 329 font. However, there exist many fonts which don't set `ascent' to
@@ -506,9 +497,9 @@ struct font_driver
506 /* Symbol indicating the type of the font-driver. */ 497 /* Symbol indicating the type of the font-driver. */
507 Lisp_Object type; 498 Lisp_Object type;
508 499
509 /* 1 iff the font's foundry, family, and adstyle names are case 500 /* True iff the font's foundry, family, and adstyle names are case
510 sensitive. */ 501 sensitive. */
511 int case_sensitive; 502 bool case_sensitive;
512 503
513 /* Return a cache of font-entities on frame F. The cache must be a 504 /* Return a cache of font-entities on frame F. The cache must be a
514 cons whose cdr part is the actual cache area. */ 505 cons whose cdr part is the actual cache area. */
@@ -592,11 +583,11 @@ struct font_driver
592 583
593 /* Optional. 584 /* Optional.
594 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel 585 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
595 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND 586 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
596 is nonzero, fill the background in advance. It is assured that 587 fill the background in advance. It is assured that WITH_BACKGROUND
597 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ 588 is false when (FROM > 0 || TO < S->nchars). */
598 int (*draw) (struct glyph_string *s, int from, int to, 589 int (*draw) (struct glyph_string *s, int from, int to,
599 int x, int y, int with_background); 590 int x, int y, bool with_background);
600 591
601 /* Optional. 592 /* Optional.
602 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is 593 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
@@ -648,7 +639,7 @@ struct font_driver
648 short, return -1. */ 639 short, return -1. */
649 int (*otf_drive) (struct font *font, Lisp_Object features, 640 int (*otf_drive) (struct font *font, Lisp_Object features,
650 Lisp_Object gstring_in, int from, int to, 641 Lisp_Object gstring_in, int from, int to,
651 Lisp_Object gstring_out, int idx, int alternate_subst); 642 Lisp_Object gstring_out, int idx, bool alternate_subst);
652 643
653 /* Optional. 644 /* Optional.
654 Make the font driver ready for frame F. Usually this function 645 Make the font driver ready for frame F. Usually this function
@@ -699,9 +690,9 @@ struct font_driver
699 690
700 Return non-zero if FONT_OBJECT can be used as a (cached) font 691 Return non-zero if FONT_OBJECT can be used as a (cached) font
701 for ENTITY on frame F. */ 692 for ENTITY on frame F. */
702 int (*cached_font_ok) (struct frame *f, 693 bool (*cached_font_ok) (struct frame *f,
703 Lisp_Object font_object, 694 Lisp_Object font_object,
704 Lisp_Object entity); 695 Lisp_Object entity);
705}; 696};
706 697
707 698
@@ -711,9 +702,9 @@ struct font_driver
711 702
712struct font_driver_list 703struct font_driver_list
713{ 704{
714 /* 1 iff this driver is currently used. It is ignored in the global 705 /* True iff this driver is currently used. It is ignored in the global
715 font driver list.*/ 706 font driver list.*/
716 int on; 707 bool on;
717 /* Pointer to the font driver. */ 708 /* Pointer to the font driver. */
718 struct font_driver *driver; 709 struct font_driver *driver;
719 /* Pointer to the next element of the chain. */ 710 /* Pointer to the next element of the chain. */
@@ -744,12 +735,12 @@ extern Lisp_Object find_font_encoding (Lisp_Object);
744extern int font_registry_charsets (Lisp_Object, struct charset **, 735extern int font_registry_charsets (Lisp_Object, struct charset **,
745 struct charset **); 736 struct charset **);
746extern int font_style_to_value (enum font_property_index prop, 737extern int font_style_to_value (enum font_property_index prop,
747 Lisp_Object name, int noerror); 738 Lisp_Object name, bool noerror);
748extern Lisp_Object font_style_symbolic (Lisp_Object font, 739extern Lisp_Object font_style_symbolic (Lisp_Object font,
749 enum font_property_index prop, 740 enum font_property_index prop,
750 int for_face); 741 bool for_face);
751 742
752extern int font_match_p (Lisp_Object spec, Lisp_Object font); 743extern bool font_match_p (Lisp_Object spec, Lisp_Object font);
753extern Lisp_Object font_list_entities (Lisp_Object frame, 744extern Lisp_Object font_list_entities (Lisp_Object frame,
754 Lisp_Object spec); 745 Lisp_Object spec);
755 746
@@ -774,7 +765,7 @@ extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec);
774extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name); 765extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name);
775 766
776extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len, 767extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len,
777 int force_symbol); 768 bool force_symbol);
778extern void font_update_sort_order (int *order); 769extern void font_update_sort_order (int *order);
779 770
780extern void font_parse_family_registry (Lisp_Object family, 771extern void font_parse_family_registry (Lisp_Object family,
@@ -817,6 +808,7 @@ extern struct font_driver xfont_driver;
817extern void syms_of_xfont (void); 808extern void syms_of_xfont (void);
818extern void syms_of_ftxfont (void); 809extern void syms_of_ftxfont (void);
819#ifdef HAVE_XFT 810#ifdef HAVE_XFT
811extern Lisp_Object Qxft;
820extern struct font_driver xftfont_driver; 812extern struct font_driver xftfont_driver;
821extern void syms_of_xftfont (void); 813extern void syms_of_xftfont (void);
822#elif defined HAVE_FREETYPE 814#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/>. */
26 26
27#include <config.h> 27#include <config.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "blockinput.h" 31#include "blockinput.h"
@@ -185,21 +184,12 @@ void (*check_window_system_func) (void);
185 184
186 185
187/* Prototype declarations for static functions. */ 186/* Prototype declarations for static functions. */
188static void fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
189static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *,
190 int, int);
191static void reorder_font_vector (Lisp_Object, struct font *);
192static Lisp_Object fontset_font (Lisp_Object, int, struct face *, int);
193static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object); 187static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object);
194static Lisp_Object fontset_pattern_regexp (Lisp_Object);
195static void accumulate_script_ranges (Lisp_Object, Lisp_Object,
196 Lisp_Object);
197static void set_fontset_font (Lisp_Object, Lisp_Object);
198 188
199/* Return 1 if ID is a valid fontset id, else return 0. 189/* Return true if ID is a valid fontset id.
200 Optimized away if ENABLE_CHECKING is not defined. */ 190 Optimized away if ENABLE_CHECKING is not defined. */
201 191
202static int 192static bool
203fontset_id_valid_p (int id) 193fontset_id_valid_p (int id)
204{ 194{
205 return (id >= 0 && id < ASIZE (Vfontset_table) - 1); 195 return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
@@ -413,7 +403,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
413 Lisp_Object vec, font_object; 403 Lisp_Object vec, font_object;
414 int size; 404 int size;
415 int i; 405 int i;
416 int score_changed = 0; 406 bool score_changed = 0;
417 407
418 if (font) 408 if (font)
419 XSETFONT (font_object, font); 409 XSETFONT (font_object, font);
@@ -544,10 +534,11 @@ fontset_get_font_group (Lisp_Object fontset, int c)
544 ID is a charset-id that must be preferred, or -1 meaning no 534 ID is a charset-id that must be preferred, or -1 meaning no
545 preference. 535 preference.
546 536
547 If FALLBACK is nonzero, search only fallback fonts. */ 537 If FALLBACK, search only fallback fonts. */
548 538
549static Lisp_Object 539static Lisp_Object
550fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback) 540fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id,
541 bool fallback)
551{ 542{
552 Lisp_Object vec, font_group; 543 Lisp_Object vec, font_group;
553 int i, charset_matched = 0, found_index; 544 int i, charset_matched = 0, found_index;
@@ -919,11 +910,11 @@ free_face_fontset (FRAME_PTR f, struct face *face)
919 910
920 911
921#if 0 912#if 0
922/* Return 1 if FACE is suitable for displaying character C. 913/* Return true if FACE is suitable for displaying character C.
923 Otherwise return 0. Called from the macro FACE_SUITABLE_FOR_CHAR_P 914 Called from the macro FACE_SUITABLE_FOR_CHAR_P
924 when C is not an ASCII character. */ 915 when C is not an ASCII character. */
925 916
926int 917bool
927face_suitable_for_char_p (struct face *face, int c) 918face_suitable_for_char_p (struct face *face, int c)
928{ 919{
929 Lisp_Object fontset, rfont_def; 920 Lisp_Object fontset, rfont_def;
@@ -1470,7 +1461,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1470 Lisp_Object range_list; 1461 Lisp_Object range_list;
1471 struct charset *charset = NULL; 1462 struct charset *charset = NULL;
1472 Lisp_Object fontname; 1463 Lisp_Object fontname;
1473 int ascii_changed = 0; 1464 bool ascii_changed = 0;
1474 1465
1475 fontset = check_fontset_name (name, &frame); 1466 fontset = check_fontset_name (name, &frame);
1476 1467
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/>. */
24#include <stdio.h> 24#include <stdio.h>
25#include <errno.h> 25#include <errno.h>
26#include <limits.h> 26#include <limits.h>
27#include <setjmp.h>
28 27
29#include <c-ctype.h> 28#include <c-ctype.h>
30 29
@@ -214,7 +213,7 @@ See also `frame-live-p'. */)
214 case output_ns: 213 case output_ns:
215 return Qns; 214 return Qns;
216 default: 215 default:
217 abort (); 216 emacs_abort ();
218 } 217 }
219} 218}
220 219
@@ -620,7 +619,7 @@ affects all frames on the same terminal device. */)
620#ifdef MSDOS 619#ifdef MSDOS
621 if (sf->output_method != output_msdos_raw 620 if (sf->output_method != output_msdos_raw
622 && sf->output_method != output_termcap) 621 && sf->output_method != output_termcap)
623 abort (); 622 emacs_abort ();
624#else /* not MSDOS */ 623#else /* not MSDOS */
625 624
626#ifdef WINDOWSNT /* This should work now! */ 625#ifdef WINDOWSNT /* This should work now! */
@@ -767,7 +766,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
767 Lisp_Object focus; 766 Lisp_Object focus;
768 767
769 if (!FRAMEP (XCAR (tail))) 768 if (!FRAMEP (XCAR (tail)))
770 abort (); 769 emacs_abort ();
771 770
772 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); 771 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
773 772
@@ -897,7 +896,7 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
897 896
898 /* There must always be at least one frame in Vframe_list. */ 897 /* There must always be at least one frame in Vframe_list. */
899 if (! CONSP (Vframe_list)) 898 if (! CONSP (Vframe_list))
900 abort (); 899 emacs_abort ();
901 900
902 /* If this frame is dead, it won't be in Vframe_list, and we'll loop 901 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
903 forever. Forestall that. */ 902 forever. Forestall that. */
@@ -975,7 +974,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf)
975 974
976 /* There must always be at least one frame in Vframe_list. */ 975 /* There must always be at least one frame in Vframe_list. */
977 if (! CONSP (Vframe_list)) 976 if (! CONSP (Vframe_list))
978 abort (); 977 emacs_abort ();
979 978
980 prev = Qnil; 979 prev = Qnil;
981 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 980 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
@@ -984,7 +983,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf)
984 983
985 f = XCAR (tail); 984 f = XCAR (tail);
986 if (!FRAMEP (f)) 985 if (!FRAMEP (f))
987 abort (); 986 emacs_abort ();
988 987
989 if (EQ (frame, f) && !NILP (prev)) 988 if (EQ (frame, f) && !NILP (prev))
990 return prev; 989 return prev;
@@ -1299,6 +1298,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1299 structures can still refer to it. */ 1298 structures can still refer to it. */
1300 fset_menu_bar_vector (f, Qnil); 1299 fset_menu_bar_vector (f, Qnil);
1301 1300
1301 /* If FRAME's buffer lists contains killed
1302 buffers, this helps GC to reclaim them. */
1303 fset_buffer_list (f, Qnil);
1304 fset_buried_buffer_list (f, Qnil);
1305
1302 free_font_driver_list (f); 1306 free_font_driver_list (f);
1303 xfree (f->namebuf); 1307 xfree (f->namebuf);
1304 xfree (f->decode_mode_spec_buffer); 1308 xfree (f->decode_mode_spec_buffer);
@@ -1385,7 +1389,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1385 1389
1386 this = XCAR (frames); 1390 this = XCAR (frames);
1387 if (!FRAMEP (this)) 1391 if (!FRAMEP (this))
1388 abort (); 1392 emacs_abort ();
1389 f1 = XFRAME (this); 1393 f1 = XFRAME (this);
1390 1394
1391 if (kb == FRAME_KBOARD (f1)) 1395 if (kb == FRAME_KBOARD (f1))
@@ -1421,7 +1425,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1421 1425
1422 this = XCAR (frames); 1426 this = XCAR (frames);
1423 if (!FRAMEP (this)) 1427 if (!FRAMEP (this))
1424 abort (); 1428 emacs_abort ();
1425 f1 = XFRAME (this); 1429 f1 = XFRAME (this);
1426 1430
1427 /* Consider only frames on the same kboard 1431 /* Consider only frames on the same kboard
@@ -1447,7 +1451,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1447 that is prohibited at the top; you can't delete surrogate 1451 that is prohibited at the top; you can't delete surrogate
1448 minibuffer frames. */ 1452 minibuffer frames. */
1449 if (NILP (frame_with_minibuf)) 1453 if (NILP (frame_with_minibuf))
1450 abort (); 1454 emacs_abort ();
1451 1455
1452 kset_default_minibuffer_frame (kb, frame_with_minibuf); 1456 kset_default_minibuffer_frame (kb, frame_with_minibuf);
1453 } 1457 }
@@ -2108,7 +2112,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2108 swap_in_global_binding (sym); 2112 swap_in_global_binding (sym);
2109 break; 2113 break;
2110 } 2114 }
2111 default: abort (); 2115 default: emacs_abort ();
2112 } 2116 }
2113 } 2117 }
2114 2118
@@ -3835,7 +3839,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
3835 } 3839 }
3836 3840
3837 default: 3841 default:
3838 abort (); 3842 emacs_abort ();
3839 } 3843 }
3840 } 3844 }
3841 else 3845 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
81#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) 81#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
82#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) 82#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
83 83
84struct terminal;
85
86struct font_driver_list;
87 84
88struct frame 85struct frame
89{ 86{
@@ -981,7 +978,7 @@ extern Lisp_Object selected_frame;
981 ((FRAMEP (selected_frame) \ 978 ((FRAMEP (selected_frame) \
982 && FRAME_LIVE_P (XFRAME (selected_frame))) \ 979 && FRAME_LIVE_P (XFRAME (selected_frame))) \
983 ? XFRAME (selected_frame) \ 980 ? XFRAME (selected_frame) \
984 : (abort (), (struct frame *) 0)) 981 : (emacs_abort (), (struct frame *) 0))
985 982
986 983
987/*********************************************************************** 984/***********************************************************************
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/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <setjmp.h>
22 21
23#include "lisp.h" 22#include "lisp.h"
24#include "frame.h" 23#include "frame.h"
@@ -659,7 +658,14 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
659 { 658 {
660 /* If W has a vertical border to its left, don't draw over it. */ 659 /* If W has a vertical border to its left, don't draw over it. */
661 wd -= ((!WINDOW_LEFTMOST_P (w) 660 wd -= ((!WINDOW_LEFTMOST_P (w)
662 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) 661 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
662 /* But don't reduce the fringe width if the window
663 has a left margin, because that means we are not
664 in danger of drawing over the vertical border,
665 and OTOH leaving out that one pixel leaves behind
666 traces of the cursor, if it was in column zero
667 before drawing non-empty margin area. */
668 && NILP (w->left_margin_cols))
663 ? 1 : 0); 669 ? 1 : 0);
664 p.bx = x - wd; 670 p.bx = x - wd;
665 p.nx = wd; 671 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25
26#include <fontconfig/fontconfig.h> 24#include <fontconfig/fontconfig.h>
27#include <fontconfig/fcfreetype.h> 25#include <fontconfig/fcfreetype.h>
28 26
@@ -45,7 +43,7 @@ static Lisp_Object Qfreetype;
45static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; 43static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
46 44
47/* Flag to tell if FcInit is already called or not. */ 45/* Flag to tell if FcInit is already called or not. */
48static int fc_initialized; 46static bool fc_initialized;
49 47
50/* Handle to a FreeType library instance. */ 48/* Handle to a FreeType library instance. */
51static FT_Library ft_library; 49static FT_Library ft_library;
@@ -65,7 +63,7 @@ struct ftfont_info
65#ifdef HAVE_LIBOTF 63#ifdef HAVE_LIBOTF
66 /* The following four members must be here in this order to be 64 /* The following four members must be here in this order to be
67 compatible with struct xftfont_info (in xftfont.c). */ 65 compatible with struct xftfont_info (in xftfont.c). */
68 int maybe_otf; /* Flag to tell if this may be OTF or not. */ 66 bool maybe_otf; /* Flag to tell if this may be OTF or not. */
69 OTF *otf; 67 OTF *otf;
70#endif /* HAVE_LIBOTF */ 68#endif /* HAVE_LIBOTF */
71 FT_Size ft_size; 69 FT_Size ft_size;
@@ -543,9 +541,9 @@ struct font_driver ftfont_driver =
543 /* We can't draw a text without device dependent functions. */ 541 /* We can't draw a text without device dependent functions. */
544 NULL, /* draw */ 542 NULL, /* draw */
545 ftfont_get_bitmap, 543 ftfont_get_bitmap,
546 NULL, /* get_bitmap */
547 NULL, /* free_bitmap */ 544 NULL, /* free_bitmap */
548 NULL, /* get_outline */ 545 NULL, /* get_outline */
546 NULL, /* free_outline */
549 ftfont_anchor_point, 547 ftfont_anchor_point,
550#ifdef HAVE_LIBOTF 548#ifdef HAVE_LIBOTF
551 ftfont_otf_capability, 549 ftfont_otf_capability,
@@ -661,7 +659,8 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
661{ 659{
662 struct OpenTypeSpec *spec = malloc (sizeof *spec); 660 struct OpenTypeSpec *spec = malloc (sizeof *spec);
663 Lisp_Object val; 661 Lisp_Object val;
664 int i, j, negative; 662 int i, j;
663 bool negative;
665 664
666 if (! spec) 665 if (! spec)
667 return NULL; 666 return NULL;
@@ -1185,7 +1184,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1185 FT_Size ft_size; 1184 FT_Size ft_size;
1186 FT_UInt size; 1185 FT_UInt size;
1187 Lisp_Object val, filename, idx, cache, font_object; 1186 Lisp_Object val, filename, idx, cache, font_object;
1188 int scalable; 1187 bool scalable;
1189 int spacing; 1188 int spacing;
1190 char name[256]; 1189 char name[256];
1191 int i, len; 1190 int i, len;
@@ -1243,7 +1242,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1243 ftfont_info->ft_size = ft_face->size; 1242 ftfont_info->ft_size = ft_face->size;
1244 ftfont_info->index = XINT (idx); 1243 ftfont_info->index = XINT (idx);
1245#ifdef HAVE_LIBOTF 1244#ifdef HAVE_LIBOTF
1246 ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; 1245 ftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
1247 ftfont_info->otf = NULL; 1246 ftfont_info->otf = NULL;
1248#endif /* HAVE_LIBOTF */ 1247#endif /* HAVE_LIBOTF */
1249 /* This means that there's no need of transformation. */ 1248 /* 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
1392 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1391 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
1393 FT_Face ft_face = ftfont_info->ft_size->face; 1392 FT_Face ft_face = ftfont_info->ft_size->face;
1394 int width = 0; 1393 int width = 0;
1395 int i, first; 1394 int i;
1395 bool first;
1396 1396
1397 if (ftfont_info->ft_size != ft_face->size) 1397 if (ftfont_info->ft_size != ft_face->size)
1398 FT_Activate_Size (ftfont_info->ft_size); 1398 FT_Activate_Size (ftfont_info->ft_size);
@@ -1630,7 +1630,7 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring,
1630 FT_Glyph_Metrics *m; 1630 FT_Glyph_Metrics *m;
1631 1631
1632 if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) 1632 if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0)
1633 abort (); 1633 emacs_abort ();
1634 m = &ft_face->glyph->metrics; 1634 m = &ft_face->glyph->metrics;
1635 if (flt_font_ft->matrix) 1635 if (flt_font_ft->matrix)
1636 { 1636 {
@@ -1682,10 +1682,12 @@ ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec)
1682 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; 1682 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font;
1683 OTF *otf = flt_font_ft->otf; 1683 OTF *otf = flt_font_ft->otf;
1684 OTF_Tag *tags; 1684 OTF_Tag *tags;
1685 int i, n, negative; 1685 int i, n;
1686 bool negative;
1686 1687
1687 if (FEATURE_ANY (0) && FEATURE_ANY (1)) 1688 if (FEATURE_ANY (0) && FEATURE_ANY (1))
1688 /* Return 1 iff any of GSUB or GPOS support the script (and language). */ 1689 /* Return true iff any of GSUB or GPOS support the script (and
1690 language). */
1689 return (otf 1691 return (otf
1690 && (OTF_check_features (otf, 0, spec->script, spec->langsys, 1692 && (OTF_check_features (otf, 0, spec->script, spec->langsys,
1691 NULL, 0) > 0 1693 NULL, 0) > 0
@@ -2390,7 +2392,7 @@ ftfont_drive_otf (MFLTFont *font, MFLTOtfSpec *spec, MFLTGlyphString *in,
2390 2392
2391static MFLTGlyphString gstring; 2393static MFLTGlyphString gstring;
2392 2394
2393static int m17n_flt_initialized; 2395static bool m17n_flt_initialized;
2394 2396
2395static Lisp_Object 2397static Lisp_Object
2396ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, 2398ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
@@ -2400,7 +2402,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2400 ptrdiff_t i; 2402 ptrdiff_t i;
2401 struct MFLTFontFT flt_font_ft; 2403 struct MFLTFontFT flt_font_ft;
2402 MFLT *flt = NULL; 2404 MFLT *flt = NULL;
2403 int with_variation_selector = 0; 2405 bool with_variation_selector = 0;
2404 2406
2405 if (! m17n_flt_initialized) 2407 if (! m17n_flt_initialized)
2406 { 2408 {
@@ -2421,7 +2423,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2421 break; 2423 break;
2422 c = LGLYPH_CHAR (g); 2424 c = LGLYPH_CHAR (g);
2423 if (CHAR_VARIATION_SELECTOR_P (c)) 2425 if (CHAR_VARIATION_SELECTOR_P (c))
2424 with_variation_selector++; 2426 with_variation_selector = 1;
2425 } 2427 }
2426 2428
2427 len = i; 2429 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
@@ -43,14 +42,6 @@ static
43#endif 42#endif
44struct font_driver ftxfont_driver; 43struct font_driver ftxfont_driver;
45 44
46/* Prototypes for helper function. */
47static GC *ftxfont_get_gcs (FRAME_PTR, unsigned long, unsigned long);
48static int ftxfont_draw_bitmap (FRAME_PTR, GC, GC *, struct font *,
49 unsigned, int, int, XPoint *, int, int *,
50 int);
51static void ftxfont_draw_background (FRAME_PTR, struct font *, GC,
52 int, int, int);
53
54struct ftxfont_frame_data 45struct ftxfont_frame_data
55{ 46{
56 /* Background and foreground colors. */ 47 /* Background and foreground colors. */
@@ -143,7 +134,9 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba
143} 134}
144 135
145static int 136static int
146ftxfont_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) 137ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font,
138 unsigned int code, int x, int y, XPoint *p, int size,
139 int *n, bool flush)
147{ 140{
148 struct font_bitmap bitmap; 141 struct font_bitmap bitmap;
149 unsigned char *b; 142 unsigned char *b;
@@ -232,13 +225,6 @@ ftxfont_draw_background (FRAME_PTR f, struct font *font, GC gc, int x, int y,
232 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground); 225 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
233} 226}
234 227
235/* Prototypes for font-driver methods. */
236static Lisp_Object ftxfont_list (Lisp_Object, Lisp_Object);
237static Lisp_Object ftxfont_match (Lisp_Object, Lisp_Object);
238static Lisp_Object ftxfont_open (FRAME_PTR, Lisp_Object, int);
239static void ftxfont_close (FRAME_PTR, struct font *);
240static int ftxfont_draw (struct glyph_string *, int, int, int, int, int);
241
242static Lisp_Object 228static Lisp_Object
243ftxfont_list (Lisp_Object frame, Lisp_Object spec) 229ftxfont_list (Lisp_Object frame, Lisp_Object spec)
244{ 230{
@@ -280,7 +266,8 @@ ftxfont_close (FRAME_PTR f, struct font *font)
280} 266}
281 267
282static int 268static int
283ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 269ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
270 bool with_background)
284{ 271{
285 FRAME_PTR f = s->f; 272 FRAME_PTR f = s->f;
286 struct face *face = s->face; 273 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/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <errno.h> 20#include <errno.h>
21#include <setjmp.h>
22 21
23#include "lisp.h" 22#include "lisp.h"
24#include "process.h" 23#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/>. */
21 21
22#ifdef USE_GTK 22#ifdef USE_GTK
23#include <float.h> 23#include <float.h>
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h>
27 25
28#include <c-ctype.h> 26#include <c-ctype.h>
29 27
@@ -254,7 +252,7 @@ void
254free_widget_value (widget_value *wv) 252free_widget_value (widget_value *wv)
255{ 253{
256 if (wv->free_list) 254 if (wv->free_list)
257 abort (); 255 emacs_abort ();
258 256
259 if (malloc_cpt > 25) 257 if (malloc_cpt > 25)
260 { 258 {
@@ -1979,7 +1977,10 @@ xg_get_file_name (FRAME_PTR f,
1979 /* I really don't know why this is needed, but without this the GLIBC add on 1977 /* I really don't know why this is needed, but without this the GLIBC add on
1980 library linuxthreads hangs when the Gnome file chooser backend creates 1978 library linuxthreads hangs when the Gnome file chooser backend creates
1981 threads. */ 1979 threads. */
1982 sigblock (sigmask (__SIGRTMIN)); 1980 sigset_t blocked;
1981 sigemptyset (&blocked);
1982 sigaddset (&blocked, __SIGRTMIN);
1983 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1983#endif /* HAVE_PTHREAD */ 1984#endif /* HAVE_PTHREAD */
1984 1985
1985#ifdef HAVE_GTK_FILE_SELECTION_NEW 1986#ifdef HAVE_GTK_FILE_SELECTION_NEW
@@ -2001,7 +2002,7 @@ xg_get_file_name (FRAME_PTR f,
2001 filesel_done = xg_dialog_run (f, w); 2002 filesel_done = xg_dialog_run (f, w);
2002 2003
2003#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2004#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2004 sigunblock (sigmask (__SIGRTMIN)); 2005 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2005#endif 2006#endif
2006 2007
2007 if (filesel_done == GTK_RESPONSE_OK) 2008 if (filesel_done == GTK_RESPONSE_OK)
@@ -2019,11 +2020,6 @@ xg_get_file_name (FRAME_PTR f,
2019 2020
2020#if USE_NEW_GTK_FONT_CHOOSER 2021#if USE_NEW_GTK_FONT_CHOOSER
2021 2022
2022extern Lisp_Object Qxft, Qnormal;
2023extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold;
2024extern Lisp_Object Qbold, Qextra_bold, Qultra_bold;
2025extern Lisp_Object Qoblique, Qitalic;
2026
2027#define XG_WEIGHT_TO_SYMBOL(w) \ 2023#define XG_WEIGHT_TO_SYMBOL(w) \
2028 (w <= PANGO_WEIGHT_THIN ? Qextra_light \ 2024 (w <= PANGO_WEIGHT_THIN ? Qextra_light \
2029 : w <= PANGO_WEIGHT_ULTRALIGHT ? Qlight \ 2025 : w <= PANGO_WEIGHT_ULTRALIGHT ? Qlight \
@@ -2043,6 +2039,7 @@ extern Lisp_Object Qoblique, Qitalic;
2043 2039
2044 2040
2045static char *x_last_font_name; 2041static char *x_last_font_name;
2042extern Lisp_Object Qxft;
2046 2043
2047/* Pop up a GTK font selector and return the name of the font the user 2044/* Pop up a GTK font selector and return the name of the font the user
2048 selects, as a C string. The returned font name follows GTK's own 2045 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)
2061 Lisp_Object font = Qnil; 2058 Lisp_Object font = Qnil;
2062 2059
2063#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2060#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2064 sigblock (sigmask (__SIGRTMIN)); 2061 sigset_t blocked;
2062 sigemptyset (&blocked);
2063 sigaddset (&blocked, __SIGRTMIN);
2064 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2065#endif /* HAVE_PTHREAD */ 2065#endif /* HAVE_PTHREAD */
2066 2066
2067 w = gtk_font_chooser_dialog_new 2067 w = gtk_font_chooser_dialog_new
@@ -2090,7 +2090,7 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2090 done = xg_dialog_run (f, w); 2090 done = xg_dialog_run (f, w);
2091 2091
2092#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2092#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2093 sigunblock (sigmask (__SIGRTMIN)); 2093 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2094#endif 2094#endif
2095 2095
2096 if (done == GTK_RESPONSE_OK) 2096 if (done == GTK_RESPONSE_OK)
@@ -3523,7 +3523,7 @@ xg_store_widget_in_map (GtkWidget *w)
3523 } 3523 }
3524 3524
3525 /* Should never end up here */ 3525 /* Should never end up here */
3526 abort (); 3526 emacs_abort ();
3527} 3527}
3528 3528
3529/* Remove pointer at IDX from id_to_widget. 3529/* Remove pointer at IDX from id_to_widget.
@@ -4091,7 +4091,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
4091 else 4091 else
4092 { 4092 {
4093 fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n"); 4093 fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n");
4094 abort (); 4094 emacs_abort ();
4095 } 4095 }
4096 } 4096 }
4097 else if (store_type == GTK_IMAGE_ICON_NAME) 4097 else if (store_type == GTK_IMAGE_ICON_NAME)
@@ -4106,7 +4106,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
4106 else 4106 else
4107 { 4107 {
4108 fprintf (stderr, "internal error: store_type is %d\n", store_type); 4108 fprintf (stderr, "internal error: store_type is %d\n", store_type);
4109 abort (); 4109 emacs_abort ();
4110 } 4110 }
4111 } 4111 }
4112 if (wmenuimage) 4112 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/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <math.h>
23#include <unistd.h> 22#include <unistd.h>
24 23
25#ifdef HAVE_PNG 24#ifdef HAVE_PNG
@@ -575,7 +574,6 @@ static int x_build_heuristic_mask (struct frame *, struct image *,
575 Lisp_Object); 574 Lisp_Object);
576#ifdef WINDOWSNT 575#ifdef WINDOWSNT
577extern Lisp_Object Vlibrary_cache; 576extern Lisp_Object Vlibrary_cache;
578
579#define CACHE_IMAGE_TYPE(type, status) \ 577#define CACHE_IMAGE_TYPE(type, status) \
580 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) 578 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
581#else 579#else
@@ -600,7 +598,7 @@ define_image_type (struct image_type *type, int loaded)
600 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. 598 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
601 The initialized data segment is read-only. */ 599 The initialized data segment is read-only. */
602 struct image_type *p = xmalloc (sizeof *p); 600 struct image_type *p = xmalloc (sizeof *p);
603 memcpy (p, type, sizeof *p); 601 *p = *type;
604 p->next = image_types; 602 p->next = image_types;
605 image_types = p; 603 image_types = p;
606 success = Qt; 604 success = Qt;
@@ -847,7 +845,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
847 break; 845 break;
848 846
849 default: 847 default:
850 abort (); 848 emacs_abort ();
851 break; 849 break;
852 } 850 }
853 851
@@ -5528,15 +5526,24 @@ init_png_functions (Lisp_Object libraries)
5528 5526
5529#endif /* WINDOWSNT */ 5527#endif /* WINDOWSNT */
5530 5528
5529/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp.
5530 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp
5531 substitute may munge the signal mask, but that should be OK here.
5532 MinGW (MS-Windows) uses _setjmp and defines setjmp to _setjmp in
5533 the system header setjmp.h; don't mess up that. */
5534#ifndef HAVE__SETJMP
5535# define _setjmp(j) setjmp (j)
5536# define _longjmp longjmp
5537#endif
5531 5538
5532#if (PNG_LIBPNG_VER < 10500) 5539#if (PNG_LIBPNG_VER < 10500)
5533#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) 5540#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1))
5534#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5541#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5535#else 5542#else
5536/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ 5543/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
5537#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) 5544#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1))
5538#define PNG_JMPBUF(ptr) \ 5545#define PNG_JMPBUF(ptr) \
5539 (*fn_png_set_longjmp_fn ((ptr), longjmp, sizeof (jmp_buf))) 5546 (*fn_png_set_longjmp_fn ((ptr), _longjmp, sizeof (jmp_buf)))
5540#endif 5547#endif
5541 5548
5542/* Error and warning handlers installed when the PNG library 5549/* 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)
5605/* Load PNG image IMG for use on frame F. Value is non-zero if 5612/* Load PNG image IMG for use on frame F. Value is non-zero if
5606 successful. */ 5613 successful. */
5607 5614
5615struct png_load_context
5616{
5617 /* These are members so that longjmp doesn't munge local variables. */
5618 png_struct *png_ptr;
5619 png_info *info_ptr;
5620 png_info *end_info;
5621 FILE *fp;
5622 png_byte *pixels;
5623 png_byte **rows;
5624};
5625
5608static int 5626static int
5609png_load (struct frame *f, struct image *img) 5627png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5610{ 5628{
5611 Lisp_Object file, specified_file; 5629 Lisp_Object file, specified_file;
5612 Lisp_Object specified_data; 5630 Lisp_Object specified_data;
5613 int x, y; 5631 int x, y;
5614 ptrdiff_t i; 5632 ptrdiff_t i;
5615 XImagePtr ximg, mask_img = NULL; 5633 XImagePtr ximg, mask_img = NULL;
5616 png_struct *png_ptr = NULL; 5634 png_struct *png_ptr;
5617 png_info *info_ptr = NULL, *end_info = NULL; 5635 png_info *info_ptr = NULL, *end_info = NULL;
5618 FILE *volatile fp = NULL; 5636 FILE *fp = NULL;
5619 png_byte sig[8]; 5637 png_byte sig[8];
5620 png_byte * volatile pixels = NULL; 5638 png_byte *pixels = NULL;
5621 png_byte ** volatile rows = NULL; 5639 png_byte **rows = NULL;
5622 png_uint_32 width, height; 5640 png_uint_32 width, height;
5623 int bit_depth, color_type, interlace_type; 5641 int bit_depth, color_type, interlace_type;
5624 png_byte channels; 5642 png_byte channels;
@@ -5685,41 +5703,47 @@ png_load (struct frame *f, struct image *img)
5685 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, 5703 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING,
5686 NULL, my_png_error, 5704 NULL, my_png_error,
5687 my_png_warning); 5705 my_png_warning);
5688 if (!png_ptr) 5706 if (png_ptr)
5689 { 5707 {
5690 if (fp) fclose (fp); 5708 info_ptr = fn_png_create_info_struct (png_ptr);
5691 return 0; 5709 end_info = fn_png_create_info_struct (png_ptr);
5692 } 5710 }
5693 5711
5694 info_ptr = fn_png_create_info_struct (png_ptr); 5712 c->png_ptr = png_ptr;
5695 if (!info_ptr) 5713 c->info_ptr = info_ptr;
5714 c->end_info = end_info;
5715 c->fp = fp;
5716 c->pixels = pixels;
5717 c->rows = rows;
5718
5719 if (! (info_ptr && end_info))
5696 { 5720 {
5697 fn_png_destroy_read_struct (&png_ptr, NULL, NULL); 5721 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5698 if (fp) fclose (fp); 5722 png_ptr = 0;
5699 return 0;
5700 } 5723 }
5701 5724 if (! png_ptr)
5702 end_info = fn_png_create_info_struct (png_ptr);
5703 if (!end_info)
5704 { 5725 {
5705 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
5706 if (fp) fclose (fp); 5726 if (fp) fclose (fp);
5707 return 0; 5727 return 0;
5708 } 5728 }
5709 5729
5710 /* Set error jump-back. We come back here when the PNG library 5730 /* Set error jump-back. We come back here when the PNG library
5711 detects an error. */ 5731 detects an error. */
5712 if (setjmp (PNG_JMPBUF (png_ptr))) 5732 if (_setjmp (PNG_JMPBUF (png_ptr)))
5713 { 5733 {
5714 error: 5734 error:
5715 if (png_ptr) 5735 if (c->png_ptr)
5716 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); 5736 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5717 xfree (pixels); 5737 xfree (c->pixels);
5718 xfree (rows); 5738 xfree (c->rows);
5719 if (fp) fclose (fp); 5739 if (c->fp)
5740 fclose (c->fp);
5720 return 0; 5741 return 0;
5721 } 5742 }
5722 5743
5744 /* Silence a bogus diagnostic; see GCC bug 54561. */
5745 IF_LINT (fp = c->fp);
5746
5723 /* Read image info. */ 5747 /* Read image info. */
5724 if (!NILP (specified_data)) 5748 if (!NILP (specified_data))
5725 fn_png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory); 5749 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)
5835 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height 5859 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
5836 || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes) 5860 || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes)
5837 memory_full (SIZE_MAX); 5861 memory_full (SIZE_MAX);
5838 pixels = xmalloc (sizeof *pixels * row_bytes * height); 5862 c->pixels = pixels = xmalloc (sizeof *pixels * row_bytes * height);
5839 rows = xmalloc (height * sizeof *rows); 5863 c->rows = rows = xmalloc (height * sizeof *rows);
5840 for (i = 0; i < height; ++i) 5864 for (i = 0; i < height; ++i)
5841 rows[i] = pixels + i * row_bytes; 5865 rows[i] = pixels + i * row_bytes;
5842 5866
@@ -5846,7 +5870,7 @@ png_load (struct frame *f, struct image *img)
5846 if (fp) 5870 if (fp)
5847 { 5871 {
5848 fclose (fp); 5872 fclose (fp);
5849 fp = NULL; 5873 c->fp = NULL;
5850 } 5874 }
5851 5875
5852 /* Create an image and pixmap serving as mask if the PNG image 5876 /* Create an image and pixmap serving as mask if the PNG image
@@ -5921,7 +5945,7 @@ png_load (struct frame *f, struct image *img)
5921#endif /* COLOR_TABLE_SUPPORT */ 5945#endif /* COLOR_TABLE_SUPPORT */
5922 5946
5923 /* Clean up. */ 5947 /* Clean up. */
5924 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); 5948 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5925 xfree (rows); 5949 xfree (rows);
5926 xfree (pixels); 5950 xfree (pixels);
5927 5951
@@ -5950,6 +5974,13 @@ png_load (struct frame *f, struct image *img)
5950 return 1; 5974 return 1;
5951} 5975}
5952 5976
5977static int
5978png_load (struct frame *f, struct image *img)
5979{
5980 struct png_load_context c;
5981 return png_load_body (f, img, &c);
5982}
5983
5953#else /* HAVE_PNG */ 5984#else /* HAVE_PNG */
5954 5985
5955#ifdef HAVE_NS 5986#ifdef HAVE_NS
@@ -6125,7 +6156,20 @@ jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6125struct my_jpeg_error_mgr 6156struct my_jpeg_error_mgr
6126{ 6157{
6127 struct jpeg_error_mgr pub; 6158 struct jpeg_error_mgr pub;
6128 jmp_buf setjmp_buffer; 6159 sys_jmp_buf setjmp_buffer;
6160
6161 /* The remaining members are so that longjmp doesn't munge local
6162 variables. */
6163 struct jpeg_decompress_struct cinfo;
6164 enum
6165 {
6166 MY_JPEG_ERROR_EXIT,
6167 MY_JPEG_INVALID_IMAGE_SIZE,
6168 MY_JPEG_CANNOT_CREATE_X
6169 } failure_code;
6170#ifdef lint
6171 FILE *fp;
6172#endif
6129}; 6173};
6130 6174
6131 6175
@@ -6133,7 +6177,8 @@ static _Noreturn void
6133my_error_exit (j_common_ptr cinfo) 6177my_error_exit (j_common_ptr cinfo)
6134{ 6178{
6135 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6179 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6136 longjmp (mgr->setjmp_buffer, 1); 6180 mgr->failure_code = MY_JPEG_ERROR_EXIT;
6181 sys_longjmp (mgr->setjmp_buffer, 1);
6137} 6182}
6138 6183
6139 6184
@@ -6201,7 +6246,7 @@ our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes)
6201 reading the image. */ 6246 reading the image. */
6202 6247
6203static void 6248static void
6204jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) 6249jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len)
6205{ 6250{
6206 struct jpeg_source_mgr *src; 6251 struct jpeg_source_mgr *src;
6207 6252
@@ -6339,17 +6384,15 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
6339 from the JPEG lib. */ 6384 from the JPEG lib. */
6340 6385
6341static int 6386static int
6342jpeg_load (struct frame *f, struct image *img) 6387jpeg_load_body (struct frame *f, struct image *img,
6388 struct my_jpeg_error_mgr *mgr)
6343{ 6389{
6344 struct jpeg_decompress_struct cinfo;
6345 struct my_jpeg_error_mgr mgr;
6346 Lisp_Object file, specified_file; 6390 Lisp_Object file, specified_file;
6347 Lisp_Object specified_data; 6391 Lisp_Object specified_data;
6348 FILE * volatile fp = NULL; 6392 FILE *fp = NULL;
6349 JSAMPARRAY buffer; 6393 JSAMPARRAY buffer;
6350 int row_stride, x, y; 6394 int row_stride, x, y;
6351 XImagePtr ximg = NULL; 6395 XImagePtr ximg = NULL;
6352 int rc;
6353 unsigned long *colors; 6396 unsigned long *colors;
6354 int width, height; 6397 int width, height;
6355 6398
@@ -6379,26 +6422,37 @@ jpeg_load (struct frame *f, struct image *img)
6379 return 0; 6422 return 0;
6380 } 6423 }
6381 6424
6425 IF_LINT (mgr->fp = fp);
6426
6382 /* Customize libjpeg's error handling to call my_error_exit when an 6427 /* Customize libjpeg's error handling to call my_error_exit when an
6383 error is detected. This function will perform a longjmp. */ 6428 error is detected. This function will perform a longjmp. */
6384 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6429 mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub);
6385 mgr.pub.error_exit = my_error_exit; 6430 mgr->pub.error_exit = my_error_exit;
6386 6431 if (sys_setjmp (mgr->setjmp_buffer))
6387 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
6388 { 6432 {
6389 if (rc == 1) 6433 switch (mgr->failure_code)
6390 { 6434 {
6391 /* Called from my_error_exit. Display a JPEG error. */ 6435 case MY_JPEG_ERROR_EXIT:
6392 char buf[JMSG_LENGTH_MAX]; 6436 {
6393 cinfo.err->format_message ((j_common_ptr) &cinfo, buf); 6437 char buf[JMSG_LENGTH_MAX];
6394 image_error ("Error reading JPEG image `%s': %s", img->spec, 6438 mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf);
6395 build_string (buf)); 6439 image_error ("Error reading JPEG image `%s': %s", img->spec,
6440 build_string (buf));
6441 break;
6442 }
6443
6444 case MY_JPEG_INVALID_IMAGE_SIZE:
6445 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
6446 break;
6447
6448 case MY_JPEG_CANNOT_CREATE_X:
6449 break;
6396 } 6450 }
6397 6451
6398 /* Close the input file and destroy the JPEG object. */ 6452 /* Close the input file and destroy the JPEG object. */
6399 if (fp) 6453 if (fp)
6400 fclose ((FILE *) fp); 6454 fclose (fp);
6401 fn_jpeg_destroy_decompress (&cinfo); 6455 fn_jpeg_destroy_decompress (&mgr->cinfo);
6402 6456
6403 /* If we already have an XImage, free that. */ 6457 /* If we already have an XImage, free that. */
6404 x_destroy_x_image (ximg); 6458 x_destroy_x_image (ximg);
@@ -6408,46 +6462,52 @@ jpeg_load (struct frame *f, struct image *img)
6408 return 0; 6462 return 0;
6409 } 6463 }
6410 6464
6465 /* Silence a bogus diagnostic; see GCC bug 54561. */
6466 IF_LINT (fp = mgr->fp);
6467
6411 /* Create the JPEG decompression object. Let it read from fp. 6468 /* Create the JPEG decompression object. Let it read from fp.
6412 Read the JPEG image header. */ 6469 Read the JPEG image header. */
6413 fn_jpeg_CreateDecompress (&cinfo, JPEG_LIB_VERSION, sizeof (cinfo)); 6470 fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
6414 6471
6415 if (NILP (specified_data)) 6472 if (NILP (specified_data))
6416 jpeg_file_src (&cinfo, (FILE *) fp); 6473 jpeg_file_src (&mgr->cinfo, fp);
6417 else 6474 else
6418 jpeg_memory_src (&cinfo, SDATA (specified_data), 6475 jpeg_memory_src (&mgr->cinfo, SDATA (specified_data),
6419 SBYTES (specified_data)); 6476 SBYTES (specified_data));
6420 6477
6421 fn_jpeg_read_header (&cinfo, 1); 6478 fn_jpeg_read_header (&mgr->cinfo, 1);
6422 6479
6423 /* Customize decompression so that color quantization will be used. 6480 /* Customize decompression so that color quantization will be used.
6424 Start decompression. */ 6481 Start decompression. */
6425 cinfo.quantize_colors = 1; 6482 mgr->cinfo.quantize_colors = 1;
6426 fn_jpeg_start_decompress (&cinfo); 6483 fn_jpeg_start_decompress (&mgr->cinfo);
6427 width = img->width = cinfo.output_width; 6484 width = img->width = mgr->cinfo.output_width;
6428 height = img->height = cinfo.output_height; 6485 height = img->height = mgr->cinfo.output_height;
6429 6486
6430 if (!check_image_size (f, width, height)) 6487 if (!check_image_size (f, width, height))
6431 { 6488 {
6432 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6489 mgr->failure_code = MY_JPEG_INVALID_IMAGE_SIZE;
6433 longjmp (mgr.setjmp_buffer, 2); 6490 sys_longjmp (mgr->setjmp_buffer, 1);
6434 } 6491 }
6435 6492
6436 /* Create X image and pixmap. */ 6493 /* Create X image and pixmap. */
6437 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6494 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6438 longjmp (mgr.setjmp_buffer, 2); 6495 {
6496 mgr->failure_code = MY_JPEG_CANNOT_CREATE_X;
6497 sys_longjmp (mgr->setjmp_buffer, 1);
6498 }
6439 6499
6440 /* Allocate colors. When color quantization is used, 6500 /* Allocate colors. When color quantization is used,
6441 cinfo.actual_number_of_colors has been set with the number of 6501 mgr->cinfo.actual_number_of_colors has been set with the number of
6442 colors generated, and cinfo.colormap is a two-dimensional array 6502 colors generated, and mgr->cinfo.colormap is a two-dimensional array
6443 of color indices in the range 0..cinfo.actual_number_of_colors. 6503 of color indices in the range 0..mgr->cinfo.actual_number_of_colors.
6444 No more than 255 colors will be generated. */ 6504 No more than 255 colors will be generated. */
6445 { 6505 {
6446 int i, ir, ig, ib; 6506 int i, ir, ig, ib;
6447 6507
6448 if (cinfo.out_color_components > 2) 6508 if (mgr->cinfo.out_color_components > 2)
6449 ir = 0, ig = 1, ib = 2; 6509 ir = 0, ig = 1, ib = 2;
6450 else if (cinfo.out_color_components > 1) 6510 else if (mgr->cinfo.out_color_components > 1)
6451 ir = 0, ig = 1, ib = 0; 6511 ir = 0, ig = 1, ib = 0;
6452 else 6512 else
6453 ir = 0, ig = 0, ib = 0; 6513 ir = 0, ig = 0, ib = 0;
@@ -6457,15 +6517,15 @@ jpeg_load (struct frame *f, struct image *img)
6457 a default color, and we don't have to care about which colors 6517 a default color, and we don't have to care about which colors
6458 can be freed safely, and which can't. */ 6518 can be freed safely, and which can't. */
6459 init_color_table (); 6519 init_color_table ();
6460 colors = alloca (cinfo.actual_number_of_colors * sizeof *colors); 6520 colors = alloca (mgr->cinfo.actual_number_of_colors * sizeof *colors);
6461 6521
6462 for (i = 0; i < cinfo.actual_number_of_colors; ++i) 6522 for (i = 0; i < mgr->cinfo.actual_number_of_colors; ++i)
6463 { 6523 {
6464 /* Multiply RGB values with 255 because X expects RGB values 6524 /* Multiply RGB values with 255 because X expects RGB values
6465 in the range 0..0xffff. */ 6525 in the range 0..0xffff. */
6466 int r = cinfo.colormap[ir][i] << 8; 6526 int r = mgr->cinfo.colormap[ir][i] << 8;
6467 int g = cinfo.colormap[ig][i] << 8; 6527 int g = mgr->cinfo.colormap[ig][i] << 8;
6468 int b = cinfo.colormap[ib][i] << 8; 6528 int b = mgr->cinfo.colormap[ib][i] << 8;
6469 colors[i] = lookup_rgb_color (f, r, g, b); 6529 colors[i] = lookup_rgb_color (f, r, g, b);
6470 } 6530 }
6471 6531
@@ -6477,21 +6537,21 @@ jpeg_load (struct frame *f, struct image *img)
6477 } 6537 }
6478 6538
6479 /* Read pixels. */ 6539 /* Read pixels. */
6480 row_stride = width * cinfo.output_components; 6540 row_stride = width * mgr->cinfo.output_components;
6481 buffer = cinfo.mem->alloc_sarray ((j_common_ptr) &cinfo, JPOOL_IMAGE, 6541 buffer = mgr->cinfo.mem->alloc_sarray ((j_common_ptr) &mgr->cinfo,
6482 row_stride, 1); 6542 JPOOL_IMAGE, row_stride, 1);
6483 for (y = 0; y < height; ++y) 6543 for (y = 0; y < height; ++y)
6484 { 6544 {
6485 fn_jpeg_read_scanlines (&cinfo, buffer, 1); 6545 fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1);
6486 for (x = 0; x < cinfo.output_width; ++x) 6546 for (x = 0; x < mgr->cinfo.output_width; ++x)
6487 XPutPixel (ximg, x, y, colors[buffer[0][x]]); 6547 XPutPixel (ximg, x, y, colors[buffer[0][x]]);
6488 } 6548 }
6489 6549
6490 /* Clean up. */ 6550 /* Clean up. */
6491 fn_jpeg_finish_decompress (&cinfo); 6551 fn_jpeg_finish_decompress (&mgr->cinfo);
6492 fn_jpeg_destroy_decompress (&cinfo); 6552 fn_jpeg_destroy_decompress (&mgr->cinfo);
6493 if (fp) 6553 if (fp)
6494 fclose ((FILE *) fp); 6554 fclose (fp);
6495 6555
6496 /* Maybe fill in the background field while we have ximg handy. */ 6556 /* Maybe fill in the background field while we have ximg handy. */
6497 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 6557 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@@ -6504,6 +6564,13 @@ jpeg_load (struct frame *f, struct image *img)
6504 return 1; 6564 return 1;
6505} 6565}
6506 6566
6567static int
6568jpeg_load (struct frame *f, struct image *img)
6569{
6570 struct my_jpeg_error_mgr mgr;
6571 return jpeg_load_body (f, img, &mgr);
6572}
6573
6507#else /* HAVE_JPEG */ 6574#else /* HAVE_JPEG */
6508 6575
6509#ifdef HAVE_NS 6576#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/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <setjmp.h>
23 22
24#include "lisp.h" 23#include "lisp.h"
25#include "character.h" 24#include "character.h"
@@ -122,7 +121,7 @@ disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *w
122 int i; 121 int i;
123 122
124 if (widthtab->header.size != 256) 123 if (widthtab->header.size != 256)
125 abort (); 124 emacs_abort ();
126 125
127 for (i = 0; i < 256; i++) 126 for (i = 0; i < 256; i++)
128 if (character_width (i, disptab) 127 if (character_width (i, disptab)
@@ -144,7 +143,7 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab)
144 bset_width_table (buf, Fmake_vector (make_number (256), make_number (0))); 143 bset_width_table (buf, Fmake_vector (make_number (256), make_number (0)));
145 widthtab = XVECTOR (BVAR (buf, width_table)); 144 widthtab = XVECTOR (BVAR (buf, width_table));
146 if (widthtab->header.size != 256) 145 if (widthtab->header.size != 256)
147 abort (); 146 emacs_abort ();
148 147
149 for (i = 0; i < 256; i++) 148 for (i = 0; i < 256; i++)
150 XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); 149 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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23 22
24#include <intprops.h> 23#include <intprops.h>
25 24
@@ -69,13 +68,13 @@ check_markers (void)
69 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) 68 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
70 { 69 {
71 if (tail->buffer->text != current_buffer->text) 70 if (tail->buffer->text != current_buffer->text)
72 abort (); 71 emacs_abort ();
73 if (tail->charpos > Z) 72 if (tail->charpos > Z)
74 abort (); 73 emacs_abort ();
75 if (tail->bytepos > Z_BYTE) 74 if (tail->bytepos > Z_BYTE)
76 abort (); 75 emacs_abort ();
77 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos))) 76 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos)))
78 abort (); 77 emacs_abort ();
79 } 78 }
80} 79}
81 80
@@ -808,7 +807,7 @@ insert_1_both (const char *string,
808#ifdef BYTE_COMBINING_DEBUG 807#ifdef BYTE_COMBINING_DEBUG
809 if (count_combining_before (string, nbytes, PT, PT_BYTE) 808 if (count_combining_before (string, nbytes, PT, PT_BYTE)
810 || count_combining_after (string, nbytes, PT, PT_BYTE)) 809 || count_combining_after (string, nbytes, PT, PT_BYTE))
811 abort (); 810 emacs_abort ();
812#endif 811#endif
813 812
814 /* Record deletion of the surrounding text that combines with 813 /* Record deletion of the surrounding text that combines with
@@ -840,8 +839,7 @@ insert_1_both (const char *string,
840 PT + nchars, PT_BYTE + nbytes, 839 PT + nchars, PT_BYTE + nbytes,
841 before_markers); 840 before_markers);
842 841
843 if (buffer_intervals (current_buffer)) 842 offset_intervals (current_buffer, PT, nchars);
844 offset_intervals (current_buffer, PT, nchars);
845 843
846 if (!inherit && buffer_intervals (current_buffer)) 844 if (!inherit && buffer_intervals (current_buffer))
847 set_text_properties (make_number (PT), make_number (PT + nchars), 845 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,
943 the text that has been stored by copy_text. */ 941 the text that has been stored by copy_text. */
944 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) 942 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)
945 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) 943 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE))
946 abort (); 944 emacs_abort ();
947#endif 945#endif
948 946
949 record_insert (PT, nchars); 947 record_insert (PT, nchars);
@@ -1126,7 +1124,7 @@ insert_from_buffer_1 (struct buffer *buf,
1126 the text that has been stored by copy_text. */ 1124 the text that has been stored by copy_text. */
1127 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) 1125 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)
1128 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) 1126 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE))
1129 abort (); 1127 emacs_abort ();
1130#endif 1128#endif
1131 1129
1132 record_insert (PT, nchars); 1130 record_insert (PT, nchars);
@@ -1153,8 +1151,7 @@ insert_from_buffer_1 (struct buffer *buf,
1153 PT_BYTE + outgoing_nbytes, 1151 PT_BYTE + outgoing_nbytes,
1154 0); 1152 0);
1155 1153
1156 if (buffer_intervals (current_buffer)) 1154 offset_intervals (current_buffer, PT, nchars);
1157 offset_intervals (current_buffer, PT, nchars);
1158 1155
1159 /* Get the intervals for the part of the string we are inserting. */ 1156 /* Get the intervals for the part of the string we are inserting. */
1160 intervals = buffer_intervals (buf); 1157 intervals = buffer_intervals (buf);
@@ -1187,7 +1184,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1187#ifdef BYTE_COMBINING_DEBUG 1184#ifdef BYTE_COMBINING_DEBUG
1188 if (count_combining_before (GPT_ADDR, len_byte, from, from_byte) 1185 if (count_combining_before (GPT_ADDR, len_byte, from, from_byte)
1189 || count_combining_after (GPT_ADDR, len_byte, from, from_byte)) 1186 || count_combining_after (GPT_ADDR, len_byte, from, from_byte))
1190 abort (); 1187 emacs_abort ();
1191#endif 1188#endif
1192 1189
1193 if (STRINGP (prev_text)) 1190 if (STRINGP (prev_text))
@@ -1222,8 +1219,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1222 else if (len < nchars_del) 1219 else if (len < nchars_del)
1223 adjust_overlays_for_delete (from, nchars_del - len); 1220 adjust_overlays_for_delete (from, nchars_del - len);
1224 1221
1225 if (buffer_intervals (current_buffer)) 1222 offset_intervals (current_buffer, from, len - nchars_del);
1226 offset_intervals (current_buffer, from, len - nchars_del);
1227 1223
1228 if (from < PT) 1224 if (from < PT)
1229 adjust_point (len - nchars_del, len_byte - nbytes_del); 1225 adjust_point (len - nchars_del, len_byte - nbytes_del);
@@ -1370,7 +1366,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1370 the text that has been stored by copy_text. */ 1366 the text that has been stored by copy_text. */
1371 if (count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte) 1367 if (count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte)
1372 || count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte)) 1368 || count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte))
1373 abort (); 1369 emacs_abort ();
1374#endif 1370#endif
1375 1371
1376 if (! EQ (BVAR (current_buffer, undo_list), Qt)) 1372 if (! EQ (BVAR (current_buffer, undo_list), Qt))
@@ -1394,16 +1390,16 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1394 1390
1395 eassert (GPT <= GPT_BYTE); 1391 eassert (GPT <= GPT_BYTE);
1396 1392
1397 /* Adjust the overlay center as needed. This must be done after
1398 adjusting the markers that bound the overlays. */
1399 adjust_overlays_for_delete (from, nchars_del);
1400 adjust_overlays_for_insert (from, inschars);
1401
1402 /* Adjust markers for the deletion and the insertion. */ 1393 /* Adjust markers for the deletion and the insertion. */
1403 if (markers) 1394 if (markers)
1404 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1395 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1405 inschars, outgoing_insbytes); 1396 inschars, outgoing_insbytes);
1406 1397
1398 /* Adjust the overlay center as needed. This must be done after
1399 adjusting the markers that bound the overlays. */
1400 adjust_overlays_for_delete (from, nchars_del);
1401 adjust_overlays_for_insert (from, inschars);
1402
1407 offset_intervals (current_buffer, from, inschars - nchars_del); 1403 offset_intervals (current_buffer, from, inschars - nchars_del);
1408 1404
1409 /* Get the intervals for the part of the string we are inserting-- 1405 /* 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,
1496 the text that has been stored by copy_text. */ 1492 the text that has been stored by copy_text. */
1497 if (count_combining_before (GPT_ADDR, insbytes, from, from_byte) 1493 if (count_combining_before (GPT_ADDR, insbytes, from, from_byte)
1498 || count_combining_after (GPT_ADDR, insbytes, from, from_byte)) 1494 || count_combining_after (GPT_ADDR, insbytes, from, from_byte))
1499 abort (); 1495 emacs_abort ();
1500#endif 1496#endif
1501 1497
1502 GAP_SIZE -= insbytes; 1498 GAP_SIZE -= insbytes;
@@ -1510,6 +1506,12 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1510 1506
1511 eassert (GPT <= GPT_BYTE); 1507 eassert (GPT <= GPT_BYTE);
1512 1508
1509 /* Adjust markers for the deletion and the insertion. */
1510 if (markers
1511 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1512 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1513 inschars, insbytes);
1514
1513 /* Adjust the overlay center as needed. This must be done after 1515 /* Adjust the overlay center as needed. This must be done after
1514 adjusting the markers that bound the overlays. */ 1516 adjusting the markers that bound the overlays. */
1515 if (nchars_del != inschars) 1517 if (nchars_del != inschars)
@@ -1518,12 +1520,6 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1518 adjust_overlays_for_delete (from + inschars, nchars_del); 1520 adjust_overlays_for_delete (from + inschars, nchars_del);
1519 } 1521 }
1520 1522
1521 /* Adjust markers for the deletion and the insertion. */
1522 if (markers
1523 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1524 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1525 inschars, insbytes);
1526
1527 offset_intervals (current_buffer, from, inschars - nchars_del); 1523 offset_intervals (current_buffer, from, inschars - nchars_del);
1528 1524
1529 /* Relocate point as if it were a marker. */ 1525 /* Relocate point as if it were a marker. */
@@ -1704,7 +1700,7 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1704#ifdef BYTE_COMBINING_DEBUG 1700#ifdef BYTE_COMBINING_DEBUG
1705 if (count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte), 1701 if (count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte),
1706 Z_BYTE - to_byte, from, from_byte)) 1702 Z_BYTE - to_byte, from, from_byte))
1707 abort (); 1703 emacs_abort ();
1708#endif 1704#endif
1709 1705
1710 if (ret_string || ! EQ (BVAR (current_buffer, undo_list), Qt)) 1706 if (ret_string || ! EQ (BVAR (current_buffer, undo_list), Qt))
@@ -2107,7 +2103,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
2107 non-nil, and insertion calls a file handler (e.g. through 2103 non-nil, and insertion calls a file handler (e.g. through
2108 lock_file) which scribbles into a temp file -- cyd */ 2104 lock_file) which scribbles into a temp file -- cyd */
2109 if (!BUFFERP (combine_after_change_buffer) 2105 if (!BUFFERP (combine_after_change_buffer)
2110 || NILP (BVAR (XBUFFER (combine_after_change_buffer), name))) 2106 || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer)))
2111 { 2107 {
2112 combine_after_change_list = Qnil; 2108 combine_after_change_list = Qnil;
2113 return Qnil; 2109 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/>. */
41 41
42#define INTERVALS_INLINE EXTERN_INLINE 42#define INTERVALS_INLINE EXTERN_INLINE
43 43
44#include <setjmp.h>
45#include <intprops.h> 44#include <intprops.h>
46#include "lisp.h" 45#include "lisp.h"
47#include "intervals.h" 46#include "intervals.h"
@@ -199,13 +198,13 @@ intervals_equal (INTERVAL i0, INTERVAL i1)
199 i0_sym = XCAR (i0_cdr); 198 i0_sym = XCAR (i0_cdr);
200 i0_cdr = XCDR (i0_cdr); 199 i0_cdr = XCDR (i0_cdr);
201 if (!CONSP (i0_cdr)) 200 if (!CONSP (i0_cdr))
202 return 0; /* abort (); */ 201 return 0;
203 i1_val = i1->plist; 202 i1_val = i1->plist;
204 while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym)) 203 while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym))
205 { 204 {
206 i1_val = XCDR (i1_val); 205 i1_val = XCDR (i1_val);
207 if (!CONSP (i1_val)) 206 if (!CONSP (i1_val))
208 return 0; /* abort (); */ 207 return 0;
209 i1_val = XCDR (i1_val); 208 i1_val = XCDR (i1_val);
210 } 209 }
211 210
@@ -223,7 +222,7 @@ intervals_equal (INTERVAL i0, INTERVAL i1)
223 222
224 i1_cdr = XCDR (i1_cdr); 223 i1_cdr = XCDR (i1_cdr);
225 if (!CONSP (i1_cdr)) 224 if (!CONSP (i1_cdr))
226 return 0; /* abort (); */ 225 return 0;
227 i1_cdr = XCDR (i1_cdr); 226 i1_cdr = XCDR (i1_cdr);
228 } 227 }
229 228
@@ -674,8 +673,7 @@ find_interval (register INTERVAL tree, register ptrdiff_t position)
674 673
675 eassert (relative_position <= TOTAL_LENGTH (tree)); 674 eassert (relative_position <= TOTAL_LENGTH (tree));
676 675
677 if (!handling_signal) 676 tree = balance_possible_root_interval (tree);
678 tree = balance_possible_root_interval (tree);
679 677
680 while (1) 678 while (1)
681 { 679 {
@@ -1253,7 +1251,7 @@ delete_interval (register INTERVAL i)
1253 else if (STRINGP (owner)) 1251 else if (STRINGP (owner))
1254 set_string_intervals (owner, parent); 1252 set_string_intervals (owner, parent);
1255 else 1253 else
1256 abort (); 1254 emacs_abort ();
1257 1255
1258 return; 1256 return;
1259 } 1257 }
@@ -1408,7 +1406,7 @@ offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length)
1408 start, length); 1406 start, length);
1409 else 1407 else
1410 { 1408 {
1411 IF_LINT (if (length < - TYPE_MAXIMUM (ptrdiff_t)) abort ();) 1409 lint_assume (- TYPE_MAXIMUM (ptrdiff_t) <= length);
1412 adjust_intervals_for_deletion (buffer, start, -length); 1410 adjust_intervals_for_deletion (buffer, start, -length);
1413 } 1411 }
1414} 1412}
@@ -1468,7 +1466,7 @@ merge_interval_right (register INTERVAL i)
1468 1466
1469 /* This must be the rightmost or last interval and cannot 1467 /* This must be the rightmost or last interval and cannot
1470 be merged right. The caller should have known. */ 1468 be merged right. The caller should have known. */
1471 abort (); 1469 emacs_abort ();
1472} 1470}
1473 1471
1474/* Merge interval I with its lexicographic predecessor. The resulting 1472/* Merge interval I with its lexicographic predecessor. The resulting
@@ -1524,7 +1522,7 @@ merge_interval_left (register INTERVAL i)
1524 1522
1525 /* This must be the leftmost or first interval and cannot 1523 /* This must be the leftmost or first interval and cannot
1526 be merged left. The caller should have known. */ 1524 be merged left. The caller should have known. */
1527 abort (); 1525 emacs_abort ();
1528} 1526}
1529 1527
1530/* Create a copy of SOURCE but with the default value of UP. */ 1528/* 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,
2170 else if (STRINGP (object)) 2168 else if (STRINGP (object))
2171 i = find_interval (string_intervals (object), pos); 2169 i = find_interval (string_intervals (object), pos);
2172 else 2170 else
2173 abort (); 2171 emacs_abort ();
2174 2172
2175 if (!i || (i->position + LENGTH (i) <= pos)) 2173 if (!i || (i->position + LENGTH (i) <= pos))
2176 return 0; 2174 return 0;
@@ -2209,7 +2207,7 @@ get_local_map (register ptrdiff_t position, register struct buffer *buffer,
2209 2207
2210 /* Perhaps we should just change `position' to the limit. */ 2208 /* Perhaps we should just change `position' to the limit. */
2211 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) 2209 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer))
2212 abort (); 2210 emacs_abort ();
2213 2211
2214 /* Ignore narrowing, so that a local map continues to be valid even if 2212 /* Ignore narrowing, so that a local map continues to be valid even if
2215 the visible region contains no characters and hence no properties. */ 2213 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/>. */
21 21
22#define KEYBOARD_INLINE EXTERN_INLINE 22#define KEYBOARD_INLINE EXTERN_INLINE
23 23
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h> 25
27#include "lisp.h" 26#include "lisp.h"
28#include "termchar.h" 27#include "termchar.h"
29#include "termopts.h" 28#include "termopts.h"
@@ -57,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
57#include <sys/ioctl.h> 56#include <sys/ioctl.h>
58#endif /* not MSDOS */ 57#endif /* not MSDOS */
59 58
59#if defined USABLE_FIONREAD && defined USG5_4
60# include <sys/filio.h>
61#endif
62
60#include "syssignal.h" 63#include "syssignal.h"
61 64
62#include <sys/types.h> 65#include <sys/types.h>
@@ -81,9 +84,7 @@ int interrupt_input_pending;
81 pending_atimers separately, to reduce code size. So, any code that 84 pending_atimers separately, to reduce code size. So, any code that
82 changes interrupt_input_pending or pending_atimers should update 85 changes interrupt_input_pending or pending_atimers should update
83 this too. */ 86 this too. */
84#ifdef SYNC_INPUT
85int pending_signals; 87int pending_signals;
86#endif
87 88
88#define KBD_BUFFER_SIZE 4096 89#define KBD_BUFFER_SIZE 4096
89 90
@@ -142,7 +143,7 @@ static ptrdiff_t before_command_echo_length;
142 143
143/* For longjmp to where kbd input is being done. */ 144/* For longjmp to where kbd input is being done. */
144 145
145static jmp_buf getcjmp; 146static sys_jmp_buf getcjmp;
146 147
147/* True while doing kbd input. */ 148/* True while doing kbd input. */
148int waiting_for_input; 149int waiting_for_input;
@@ -386,19 +387,6 @@ int interrupt_input;
386/* Nonzero while interrupts are temporarily deferred during redisplay. */ 387/* Nonzero while interrupts are temporarily deferred during redisplay. */
387int interrupts_deferred; 388int interrupts_deferred;
388 389
389/* Allow configure to inhibit use of FIONREAD. */
390#ifdef BROKEN_FIONREAD
391#undef FIONREAD
392#endif
393
394/* We are unable to use interrupts if FIONREAD is not available,
395 so flush SIGIO so we won't try. */
396#if !defined (FIONREAD)
397#ifdef SIGIO
398#undef SIGIO
399#endif
400#endif
401
402/* If we support a window system, turn on the code to poll periodically 390/* If we support a window system, turn on the code to poll periodically
403 to detect C-g. It isn't actually used when doing interrupt input. */ 391 to detect C-g. It isn't actually used when doing interrupt input. */
404#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 392#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
@@ -444,14 +432,13 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
444 Lisp_Object *, ptrdiff_t); 432 Lisp_Object *, ptrdiff_t);
445static Lisp_Object make_lispy_switch_frame (Lisp_Object); 433static Lisp_Object make_lispy_switch_frame (Lisp_Object);
446static int help_char_p (Lisp_Object); 434static int help_char_p (Lisp_Object);
447static void save_getcjmp (jmp_buf); 435static void save_getcjmp (sys_jmp_buf);
448static void restore_getcjmp (jmp_buf); 436static void restore_getcjmp (sys_jmp_buf);
449static Lisp_Object apply_modifiers (int, Lisp_Object); 437static Lisp_Object apply_modifiers (int, Lisp_Object);
450static void clear_event (struct input_event *); 438static void clear_event (struct input_event *);
451static Lisp_Object restore_kboard_configuration (Lisp_Object); 439static Lisp_Object restore_kboard_configuration (Lisp_Object);
452static void interrupt_signal (int signalnum); 440#ifdef USABLE_SIGIO
453#ifdef SIGIO 441static void deliver_input_available_signal (int signo);
454static void input_available_signal (int signo);
455#endif 442#endif
456static void handle_interrupt (void); 443static void handle_interrupt (void);
457static _Noreturn void quit_throw_to_read_char (int); 444static _Noreturn void quit_throw_to_read_char (int);
@@ -459,7 +446,7 @@ static void process_special_events (void);
459static void timer_start_idle (void); 446static void timer_start_idle (void);
460static void timer_stop_idle (void); 447static void timer_stop_idle (void);
461static void timer_resume_idle (void); 448static void timer_resume_idle (void);
462static void handle_user_signal (int); 449static void deliver_user_signal (int);
463static char *find_user_signal_name (int); 450static char *find_user_signal_name (int);
464static int store_user_signal_events (void); 451static int store_user_signal_events (void);
465 452
@@ -1023,7 +1010,7 @@ restore_kboard_configuration (Lisp_Object was_locked)
1023 pop_kboard (); 1010 pop_kboard ();
1024 /* The pop should not change the kboard. */ 1011 /* The pop should not change the kboard. */
1025 if (single_kboard && current_kboard != prev) 1012 if (single_kboard && current_kboard != prev)
1026 abort (); 1013 emacs_abort ();
1027 } 1014 }
1028 return Qnil; 1015 return Qnil;
1029} 1016}
@@ -1315,7 +1302,7 @@ usage: (track-mouse BODY...) */)
1315 If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement 1302 If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement
1316 after resizing the tool-bar window. */ 1303 after resizing the tool-bar window. */
1317 1304
1318#if !defined HAVE_WINDOW_SYSTEM 1305#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS
1319static 1306static
1320#endif 1307#endif
1321int ignore_mouse_drag_p; 1308int ignore_mouse_drag_p;
@@ -2021,17 +2008,9 @@ static struct atimer *poll_timer;
2021void 2008void
2022poll_for_input_1 (void) 2009poll_for_input_1 (void)
2023{ 2010{
2024/* Tell ns_read_socket() it is being called asynchronously so it can avoid
2025 doing anything dangerous. */
2026#ifdef HAVE_NS
2027 ++handling_signal;
2028#endif
2029 if (interrupt_input_blocked == 0 2011 if (interrupt_input_blocked == 0
2030 && !waiting_for_input) 2012 && !waiting_for_input)
2031 read_avail_input (0); 2013 read_avail_input (0);
2032#ifdef HAVE_NS
2033 --handling_signal;
2034#endif
2035} 2014}
2036 2015
2037/* Timer callback function for poll_timer. TIMER is equal to 2016/* Timer callback function for poll_timer. TIMER is equal to
@@ -2042,12 +2021,8 @@ poll_for_input (struct atimer *timer)
2042{ 2021{
2043 if (poll_suppress_count == 0) 2022 if (poll_suppress_count == 0)
2044 { 2023 {
2045#ifdef SYNC_INPUT
2046 interrupt_input_pending = 1; 2024 interrupt_input_pending = 1;
2047 pending_signals = 1; 2025 pending_signals = 1;
2048#else
2049 poll_for_input_1 ();
2050#endif
2051 } 2026 }
2052} 2027}
2053 2028
@@ -2326,8 +2301,8 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2326{ 2301{
2327 volatile Lisp_Object c; 2302 volatile Lisp_Object c;
2328 ptrdiff_t jmpcount; 2303 ptrdiff_t jmpcount;
2329 jmp_buf local_getcjmp; 2304 sys_jmp_buf local_getcjmp;
2330 jmp_buf save_jump; 2305 sys_jmp_buf save_jump;
2331 volatile int key_already_recorded = 0; 2306 volatile int key_already_recorded = 0;
2332 Lisp_Object tem, save; 2307 Lisp_Object tem, save;
2333 volatile Lisp_Object previous_echo_area_message; 2308 volatile Lisp_Object previous_echo_area_message;
@@ -2368,15 +2343,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2368 goto reread_first; 2343 goto reread_first;
2369 } 2344 }
2370 2345
2371 if (unread_command_char != -1)
2372 {
2373 XSETINT (c, unread_command_char);
2374 unread_command_char = -1;
2375
2376 reread = 1;
2377 goto reread_first;
2378 }
2379
2380 if (CONSP (Vunread_command_events)) 2346 if (CONSP (Vunread_command_events))
2381 { 2347 {
2382 int was_disabled = 0; 2348 int was_disabled = 0;
@@ -2561,7 +2527,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2561 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2527 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
2562 /* Don't bring up a menu if we already have another event. */ 2528 /* Don't bring up a menu if we already have another event. */
2563 && NILP (Vunread_command_events) 2529 && NILP (Vunread_command_events)
2564 && unread_command_char < 0
2565 && !detect_input_pending_run_timers (0)) 2530 && !detect_input_pending_run_timers (0))
2566 { 2531 {
2567 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); 2532 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
@@ -2583,7 +2548,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2583 it *must not* be in effect when we call redisplay. */ 2548 it *must not* be in effect when we call redisplay. */
2584 2549
2585 jmpcount = SPECPDL_INDEX (); 2550 jmpcount = SPECPDL_INDEX ();
2586 if (_setjmp (local_getcjmp)) 2551 if (sys_setjmp (local_getcjmp))
2587 { 2552 {
2588 /* Handle quits while reading the keyboard. */ 2553 /* Handle quits while reading the keyboard. */
2589 /* We must have saved the outer value of getcjmp here, 2554 /* We must have saved the outer value of getcjmp here,
@@ -2605,13 +2570,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2605 Lisp_Object last = KVAR (kb, kbd_queue); 2570 Lisp_Object last = KVAR (kb, kbd_queue);
2606 /* We shouldn't get here if we were in single-kboard mode! */ 2571 /* We shouldn't get here if we were in single-kboard mode! */
2607 if (single_kboard) 2572 if (single_kboard)
2608 abort (); 2573 emacs_abort ();
2609 if (CONSP (last)) 2574 if (CONSP (last))
2610 { 2575 {
2611 while (CONSP (XCDR (last))) 2576 while (CONSP (XCDR (last)))
2612 last = XCDR (last); 2577 last = XCDR (last);
2613 if (!NILP (XCDR (last))) 2578 if (!NILP (XCDR (last)))
2614 abort (); 2579 emacs_abort ();
2615 } 2580 }
2616 if (!CONSP (last)) 2581 if (!CONSP (last))
2617 kset_kbd_queue (kb, Fcons (c, Qnil)); 2582 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -2697,8 +2662,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2697 && !EQ (XCAR (prev_event), Qmenu_bar) 2662 && !EQ (XCAR (prev_event), Qmenu_bar)
2698 && !EQ (XCAR (prev_event), Qtool_bar) 2663 && !EQ (XCAR (prev_event), Qtool_bar)
2699 /* Don't bring up a menu if we already have another event. */ 2664 /* Don't bring up a menu if we already have another event. */
2700 && NILP (Vunread_command_events) 2665 && NILP (Vunread_command_events))
2701 && unread_command_char < 0)
2702 { 2666 {
2703 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 2667 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
2704 2668
@@ -2784,7 +2748,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2784 if (current_kboard->kbd_queue_has_data) 2748 if (current_kboard->kbd_queue_has_data)
2785 { 2749 {
2786 if (!CONSP (KVAR (current_kboard, kbd_queue))) 2750 if (!CONSP (KVAR (current_kboard, kbd_queue)))
2787 abort (); 2751 emacs_abort ();
2788 c = XCAR (KVAR (current_kboard, kbd_queue)); 2752 c = XCAR (KVAR (current_kboard, kbd_queue));
2789 kset_kbd_queue (current_kboard, 2753 kset_kbd_queue (current_kboard,
2790 XCDR (KVAR (current_kboard, kbd_queue))); 2754 XCDR (KVAR (current_kboard, kbd_queue)));
@@ -2851,7 +2815,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2851 while (CONSP (XCDR (last))) 2815 while (CONSP (XCDR (last)))
2852 last = XCDR (last); 2816 last = XCDR (last);
2853 if (!NILP (XCDR (last))) 2817 if (!NILP (XCDR (last)))
2854 abort (); 2818 emacs_abort ();
2855 } 2819 }
2856 if (!CONSP (last)) 2820 if (!CONSP (last))
2857 kset_kbd_queue (kb, Fcons (c, Qnil)); 2821 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -3416,13 +3380,13 @@ record_char (Lisp_Object c)
3416 See read_process_output. */ 3380 See read_process_output. */
3417 3381
3418static void 3382static void
3419save_getcjmp (jmp_buf temp) 3383save_getcjmp (sys_jmp_buf temp)
3420{ 3384{
3421 memcpy (temp, getcjmp, sizeof getcjmp); 3385 memcpy (temp, getcjmp, sizeof getcjmp);
3422} 3386}
3423 3387
3424static void 3388static void
3425restore_getcjmp (jmp_buf temp) 3389restore_getcjmp (sys_jmp_buf temp)
3426{ 3390{
3427 memcpy (getcjmp, temp, sizeof getcjmp); 3391 memcpy (getcjmp, temp, sizeof getcjmp);
3428} 3392}
@@ -3560,7 +3524,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3560 struct input_event *hold_quit) 3524 struct input_event *hold_quit)
3561{ 3525{
3562 if (event->kind == NO_EVENT) 3526 if (event->kind == NO_EVENT)
3563 abort (); 3527 emacs_abort ();
3564 3528
3565 if (hold_quit && hold_quit->kind != NO_EVENT) 3529 if (hold_quit && hold_quit->kind != NO_EVENT)
3566 return; 3530 return;
@@ -3604,7 +3568,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3604 3568
3605 if (hold_quit) 3569 if (hold_quit)
3606 { 3570 {
3607 memcpy (hold_quit, event, sizeof (*event)); 3571 *hold_quit = *event;
3608 return; 3572 return;
3609 } 3573 }
3610 3574
@@ -3659,10 +3623,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3659 /* Don't read keyboard input until we have processed kbd_buffer. 3623 /* Don't read keyboard input until we have processed kbd_buffer.
3660 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ 3624 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3661 hold_keyboard_input (); 3625 hold_keyboard_input ();
3662#ifdef SIGIO
3663 if (!noninteractive) 3626 if (!noninteractive)
3664 signal (SIGIO, SIG_IGN); 3627 ignore_sigio ();
3665#endif
3666 stop_polling (); 3628 stop_polling ();
3667 } 3629 }
3668#endif /* subprocesses */ 3630#endif /* subprocesses */
@@ -3681,7 +3643,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3681 if (immediate_quit && NILP (Vinhibit_quit)) 3643 if (immediate_quit && NILP (Vinhibit_quit))
3682 { 3644 {
3683 immediate_quit = 0; 3645 immediate_quit = 0;
3684 sigfree (); 3646 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3685 QUIT; 3647 QUIT;
3686 } 3648 }
3687 } 3649 }
@@ -3831,10 +3793,14 @@ kbd_buffer_get_event (KBOARD **kbp,
3831 /* Start reading input again because we have processed enough to 3793 /* Start reading input again because we have processed enough to
3832 be able to accept new events again. */ 3794 be able to accept new events again. */
3833 unhold_keyboard_input (); 3795 unhold_keyboard_input ();
3834#ifdef SIGIO 3796#ifdef USABLE_SIGIO
3835 if (!noninteractive) 3797 if (!noninteractive)
3836 signal (SIGIO, input_available_signal); 3798 {
3837#endif /* SIGIO */ 3799 struct sigaction action;
3800 emacs_sigaction_init (&action, deliver_input_available_signal);
3801 sigaction (SIGIO, &action, 0);
3802 }
3803#endif
3838 start_polling (); 3804 start_polling ();
3839 } 3805 }
3840#endif /* subprocesses */ 3806#endif /* subprocesses */
@@ -3876,10 +3842,9 @@ kbd_buffer_get_event (KBOARD **kbp,
3876 /* One way or another, wait until input is available; then, if 3842 /* One way or another, wait until input is available; then, if
3877 interrupt handlers have not read it, read it now. */ 3843 interrupt handlers have not read it, read it now. */
3878 3844
3879/* Note SIGIO has been undef'd if FIONREAD is missing. */ 3845#ifdef USABLE_SIGIO
3880#ifdef SIGIO
3881 gobble_input (0); 3846 gobble_input (0);
3882#endif /* SIGIO */ 3847#endif
3883 if (kbd_fetch_ptr != kbd_store_ptr) 3848 if (kbd_fetch_ptr != kbd_store_ptr)
3884 break; 3849 break;
3885#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 3850#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -3955,7 +3920,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3955#else 3920#else
3956 /* We're getting selection request events, but we don't have 3921 /* We're getting selection request events, but we don't have
3957 a window system. */ 3922 a window system. */
3958 abort (); 3923 emacs_abort ();
3959#endif 3924#endif
3960 } 3925 }
3961 3926
@@ -4131,7 +4096,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4131 *used_mouse_menu = 1; 4096 *used_mouse_menu = 1;
4132#endif 4097#endif
4133#ifdef HAVE_NS 4098#ifdef HAVE_NS
4134 /* certain system events are non-key events */ 4099 /* Certain system events are non-key events. */
4135 if (used_mouse_menu 4100 if (used_mouse_menu
4136 && event->kind == NS_NONKEY_EVENT) 4101 && event->kind == NS_NONKEY_EVENT)
4137 *used_mouse_menu = 1; 4102 *used_mouse_menu = 1;
@@ -4159,7 +4124,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4159 so x remains nil. */ 4124 so x remains nil. */
4160 x = Qnil; 4125 x = Qnil;
4161 4126
4162 /* XXX Can f or mouse_position_hook be NULL here? */ 4127 /* XXX Can f or mouse_position_hook be NULL here? */
4163 if (f && FRAME_TERMINAL (f)->mouse_position_hook) 4128 if (f && FRAME_TERMINAL (f)->mouse_position_hook)
4164 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window, 4129 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window,
4165 &part, &x, &y, &t); 4130 &part, &x, &y, &t);
@@ -4192,7 +4157,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4192 else 4157 else
4193 /* We were promised by the above while loop that there was 4158 /* We were promised by the above while loop that there was
4194 something for us to read! */ 4159 something for us to read! */
4195 abort (); 4160 emacs_abort ();
4196 4161
4197 input_pending = readable_events (0); 4162 input_pending = readable_events (0);
4198 4163
@@ -4261,7 +4226,7 @@ process_special_events (void)
4261#else 4226#else
4262 /* We're getting selection request events, but we don't have 4227 /* We're getting selection request events, but we don't have
4263 a window system. */ 4228 a window system. */
4264 abort (); 4229 emacs_abort ();
4265#endif 4230#endif
4266 } 4231 }
4267 } 4232 }
@@ -4351,7 +4316,7 @@ decode_timer (Lisp_Object timer, EMACS_TIME *result)
4351 if (! NILP (vector[0])) 4316 if (! NILP (vector[0]))
4352 return 0; 4317 return 0;
4353 4318
4354 return decode_time_components (vector[1], vector[2], vector[3], vector[4], 4319 return decode_time_components (vector[1], vector[2], vector[3], vector[8],
4355 result, 0); 4320 result, 0);
4356} 4321}
4357 4322
@@ -4553,7 +4518,7 @@ in the same style as (current-time).
4553 4518
4554The value when Emacs is not idle is nil. 4519The value when Emacs is not idle is nil.
4555 4520
4556NSEC is a multiple of the system clock resolution. */) 4521PSEC is a multiple of the system clock resolution. */)
4557 (void) 4522 (void)
4558{ 4523{
4559 if (EMACS_TIME_VALID_P (timer_idleness_start_time)) 4524 if (EMACS_TIME_VALID_P (timer_idleness_start_time))
@@ -5614,7 +5579,7 @@ make_lispy_event (struct input_event *event)
5614 else if (FRAMEP (event->frame_or_window)) 5579 else if (FRAMEP (event->frame_or_window))
5615 f = XFRAME (event->frame_or_window); 5580 f = XFRAME (event->frame_or_window);
5616 else 5581 else
5617 abort (); 5582 emacs_abort ();
5618 5583
5619 if (FRAME_WINDOW_P (f)) 5584 if (FRAME_WINDOW_P (f))
5620 fuzz = double_click_fuzz; 5585 fuzz = double_click_fuzz;
@@ -5721,7 +5686,7 @@ make_lispy_event (struct input_event *event)
5721 else 5686 else
5722 /* Every mouse event should either have the down_modifier or 5687 /* Every mouse event should either have the down_modifier or
5723 the up_modifier set. */ 5688 the up_modifier set. */
5724 abort (); 5689 emacs_abort ();
5725 5690
5726 { 5691 {
5727 /* Get the symbol we should use for the mouse click. */ 5692 /* Get the symbol we should use for the mouse click. */
@@ -5782,7 +5747,7 @@ make_lispy_event (struct input_event *event)
5782 else if (FRAMEP (event->frame_or_window)) 5747 else if (FRAMEP (event->frame_or_window))
5783 fr = XFRAME (event->frame_or_window); 5748 fr = XFRAME (event->frame_or_window);
5784 else 5749 else
5785 abort (); 5750 emacs_abort ();
5786 5751
5787 fuzz = FRAME_WINDOW_P (fr) 5752 fuzz = FRAME_WINDOW_P (fr)
5788 ? double_click_fuzz : double_click_fuzz / 8; 5753 ? double_click_fuzz : double_click_fuzz / 8;
@@ -5802,7 +5767,7 @@ make_lispy_event (struct input_event *event)
5802 else 5767 else
5803 /* Every wheel event should either have the down_modifier or 5768 /* Every wheel event should either have the down_modifier or
5804 the up_modifier set. */ 5769 the up_modifier set. */
5805 abort (); 5770 emacs_abort ();
5806 5771
5807 if (event->kind == HORIZ_WHEEL_EVENT) 5772 if (event->kind == HORIZ_WHEEL_EVENT)
5808 symbol_num += 2; 5773 symbol_num += 2;
@@ -5971,7 +5936,7 @@ make_lispy_event (struct input_event *event)
5971 { 5936 {
5972 char *name = find_user_signal_name (event->code); 5937 char *name = find_user_signal_name (event->code);
5973 if (!name) 5938 if (!name)
5974 abort (); 5939 emacs_abort ();
5975 return intern (name); 5940 return intern (name);
5976 } 5941 }
5977 5942
@@ -6052,7 +6017,7 @@ make_lispy_event (struct input_event *event)
6052 6017
6053 /* The 'kind' field of the event is something we don't recognize. */ 6018 /* The 'kind' field of the event is something we don't recognize. */
6054 default: 6019 default:
6055 abort (); 6020 emacs_abort ();
6056 } 6021 }
6057} 6022}
6058 6023
@@ -6229,7 +6194,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_
6229 /* Only the event queue may use the `up' modifier; it should always 6194 /* Only the event queue may use the `up' modifier; it should always
6230 be turned into a click or drag event before presented to lisp code. */ 6195 be turned into a click or drag event before presented to lisp code. */
6231 if (modifiers & up_modifier) 6196 if (modifiers & up_modifier)
6232 abort (); 6197 emacs_abort ();
6233 6198
6234 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } 6199 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; }
6235 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } 6200 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
@@ -6324,7 +6289,7 @@ parse_modifiers (Lisp_Object symbol)
6324 Qnil); 6289 Qnil);
6325 6290
6326 if (modifiers & ~INTMASK) 6291 if (modifiers & ~INTMASK)
6327 abort (); 6292 emacs_abort ();
6328 XSETFASTINT (mask, modifiers); 6293 XSETFASTINT (mask, modifiers);
6329 elements = Fcons (unmodified, Fcons (mask, Qnil)); 6294 elements = Fcons (unmodified, Fcons (mask, Qnil));
6330 6295
@@ -6778,13 +6743,15 @@ get_input_pending (int *addr, int flags)
6778void 6743void
6779gobble_input (int expected) 6744gobble_input (int expected)
6780{ 6745{
6781#ifdef SIGIO 6746#ifdef USABLE_SIGIO
6782 if (interrupt_input) 6747 if (interrupt_input)
6783 { 6748 {
6784 SIGMASKTYPE mask; 6749 sigset_t blocked, procmask;
6785 mask = sigblock (sigmask (SIGIO)); 6750 sigemptyset (&blocked);
6751 sigaddset (&blocked, SIGIO);
6752 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6786 read_avail_input (expected); 6753 read_avail_input (expected);
6787 sigsetmask (mask); 6754 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6788 } 6755 }
6789 else 6756 else
6790#ifdef POLL_FOR_INPUT 6757#ifdef POLL_FOR_INPUT
@@ -6793,10 +6760,12 @@ gobble_input (int expected)
6793 it's always set. */ 6760 it's always set. */
6794 if (!interrupt_input && poll_suppress_count == 0) 6761 if (!interrupt_input && poll_suppress_count == 0)
6795 { 6762 {
6796 SIGMASKTYPE mask; 6763 sigset_t blocked, procmask;
6797 mask = sigblock (sigmask (SIGALRM)); 6764 sigemptyset (&blocked);
6765 sigaddset (&blocked, SIGALRM);
6766 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6798 read_avail_input (expected); 6767 read_avail_input (expected);
6799 sigsetmask (mask); 6768 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6800 } 6769 }
6801 else 6770 else
6802#endif 6771#endif
@@ -6829,13 +6798,15 @@ record_asynch_buffer_change (void)
6829 return; 6798 return;
6830 6799
6831 /* Make sure no interrupt happens while storing the event. */ 6800 /* Make sure no interrupt happens while storing the event. */
6832#ifdef SIGIO 6801#ifdef USABLE_SIGIO
6833 if (interrupt_input) 6802 if (interrupt_input)
6834 { 6803 {
6835 SIGMASKTYPE mask; 6804 sigset_t blocked, procmask;
6836 mask = sigblock (sigmask (SIGIO)); 6805 sigemptyset (&blocked);
6806 sigaddset (&blocked, SIGIO);
6807 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6837 kbd_buffer_store_event (&event); 6808 kbd_buffer_store_event (&event);
6838 sigsetmask (mask); 6809 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6839 } 6810 }
6840 else 6811 else
6841#endif 6812#endif
@@ -7001,7 +6972,7 @@ tty_read_avail_input (struct terminal *terminal,
7001 6972
7002 if (terminal->type != output_termcap 6973 if (terminal->type != output_termcap
7003 && terminal->type != output_msdos_raw) 6974 && terminal->type != output_msdos_raw)
7004 abort (); 6975 emacs_abort ();
7005 6976
7006 /* XXX I think the following code should be moved to separate hook 6977 /* XXX I think the following code should be moved to separate hook
7007 functions in system-dependent files. */ 6978 functions in system-dependent files. */
@@ -7053,7 +7024,7 @@ tty_read_avail_input (struct terminal *terminal,
7053#endif /* HAVE_GPM */ 7024#endif /* HAVE_GPM */
7054 7025
7055/* Determine how many characters we should *try* to read. */ 7026/* Determine how many characters we should *try* to read. */
7056#ifdef FIONREAD 7027#ifdef USABLE_FIONREAD
7057 /* Find out how much input is available. */ 7028 /* Find out how much input is available. */
7058 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 7029 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
7059 { 7030 {
@@ -7066,14 +7037,12 @@ tty_read_avail_input (struct terminal *terminal,
7066 return 0; 7037 return 0;
7067 if (n_to_read > sizeof cbuf) 7038 if (n_to_read > sizeof cbuf)
7068 n_to_read = sizeof cbuf; 7039 n_to_read = sizeof cbuf;
7069#else /* no FIONREAD */ 7040#elif defined USG || defined CYGWIN
7070#if defined (USG) || defined (CYGWIN)
7071 /* Read some input if available, but don't wait. */ 7041 /* Read some input if available, but don't wait. */
7072 n_to_read = sizeof cbuf; 7042 n_to_read = sizeof cbuf;
7073 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 7043 fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
7074#else 7044#else
7075 you lose; 7045# error "Cannot read without possibly delaying"
7076#endif
7077#endif 7046#endif
7078 7047
7079#ifdef subprocesses 7048#ifdef subprocesses
@@ -7122,7 +7091,7 @@ tty_read_avail_input (struct terminal *terminal,
7122#endif 7091#endif
7123 ); 7092 );
7124 7093
7125#ifndef FIONREAD 7094#ifndef USABLE_FIONREAD
7126#if defined (USG) || defined (CYGWIN) 7095#if defined (USG) || defined (CYGWIN)
7127 fcntl (fileno (tty->input), F_SETFL, 0); 7096 fcntl (fileno (tty->input), F_SETFL, 0);
7128#endif /* USG or CYGWIN */ 7097#endif /* USG or CYGWIN */
@@ -7193,19 +7162,12 @@ tty_read_avail_input (struct terminal *terminal,
7193 return nread; 7162 return nread;
7194} 7163}
7195 7164
7196#if defined SYNC_INPUT || defined SIGIO
7197static void 7165static void
7198handle_async_input (void) 7166handle_async_input (void)
7199{ 7167{
7200 interrupt_input_pending = 0; 7168 interrupt_input_pending = 0;
7201#ifdef SYNC_INPUT
7202 pending_signals = pending_atimers; 7169 pending_signals = pending_atimers;
7203#endif 7170
7204/* Tell ns_read_socket() it is being called asynchronously so it can avoid
7205 doing anything dangerous. */
7206#ifdef HAVE_NS
7207 ++handling_signal;
7208#endif
7209 while (1) 7171 while (1)
7210 { 7172 {
7211 int nread; 7173 int nread;
@@ -7216,13 +7178,8 @@ handle_async_input (void)
7216 if (nread <= 0) 7178 if (nread <= 0)
7217 break; 7179 break;
7218 } 7180 }
7219#ifdef HAVE_NS
7220 --handling_signal;
7221#endif
7222} 7181}
7223#endif /* SYNC_INPUT || SIGIO */
7224 7182
7225#ifdef SYNC_INPUT
7226void 7183void
7227process_pending_signals (void) 7184process_pending_signals (void)
7228{ 7185{
@@ -7230,33 +7187,25 @@ process_pending_signals (void)
7230 handle_async_input (); 7187 handle_async_input ();
7231 do_pending_atimers (); 7188 do_pending_atimers ();
7232} 7189}
7233#endif
7234 7190
7235#ifdef SIGIO /* for entire page */ 7191#ifdef USABLE_SIGIO
7236/* Note SIGIO has been undef'd if FIONREAD is missing. */
7237 7192
7238static void 7193static void
7239input_available_signal (int signo) 7194handle_input_available_signal (int sig)
7240{ 7195{
7241 /* Must preserve main program's value of errno. */
7242 int old_errno = errno;
7243 SIGNAL_THREAD_CHECK (signo);
7244
7245#ifdef SYNC_INPUT
7246 interrupt_input_pending = 1; 7196 interrupt_input_pending = 1;
7247 pending_signals = 1; 7197 pending_signals = 1;
7248#endif
7249 7198
7250 if (input_available_clear_time) 7199 if (input_available_clear_time)
7251 *input_available_clear_time = make_emacs_time (0, 0); 7200 *input_available_clear_time = make_emacs_time (0, 0);
7201}
7252 7202
7253#ifndef SYNC_INPUT 7203static void
7254 handle_async_input (); 7204deliver_input_available_signal (int sig)
7255#endif 7205{
7256 7206 handle_on_main_thread (sig, handle_input_available_signal);
7257 errno = old_errno;
7258} 7207}
7259#endif /* SIGIO */ 7208#endif /* USABLE_SIGIO */
7260 7209
7261/* Send ourselves a SIGIO. 7210/* Send ourselves a SIGIO.
7262 7211
@@ -7267,7 +7216,7 @@ input_available_signal (int signo)
7267void 7216void
7268reinvoke_input_signal (void) 7217reinvoke_input_signal (void)
7269{ 7218{
7270#ifdef SIGIO 7219#ifdef USABLE_SIGIO
7271 handle_async_input (); 7220 handle_async_input ();
7272#endif 7221#endif
7273} 7222}
@@ -7296,6 +7245,7 @@ static struct user_signal_info *user_signals = NULL;
7296void 7245void
7297add_user_signal (int sig, const char *name) 7246add_user_signal (int sig, const char *name)
7298{ 7247{
7248 struct sigaction action;
7299 struct user_signal_info *p; 7249 struct user_signal_info *p;
7300 7250
7301 for (p = user_signals; p; p = p->next) 7251 for (p = user_signals; p; p = p->next)
@@ -7310,18 +7260,16 @@ add_user_signal (int sig, const char *name)
7310 p->next = user_signals; 7260 p->next = user_signals;
7311 user_signals = p; 7261 user_signals = p;
7312 7262
7313 signal (sig, handle_user_signal); 7263 emacs_sigaction_init (&action, deliver_user_signal);
7264 sigaction (sig, &action, 0);
7314} 7265}
7315 7266
7316static void 7267static void
7317handle_user_signal (int sig) 7268handle_user_signal (int sig)
7318{ 7269{
7319 int old_errno = errno;
7320 struct user_signal_info *p; 7270 struct user_signal_info *p;
7321 const char *special_event_name = NULL; 7271 const char *special_event_name = NULL;
7322 7272
7323 SIGNAL_THREAD_CHECK (sig);
7324
7325 if (SYMBOLP (Vdebug_on_event)) 7273 if (SYMBOLP (Vdebug_on_event))
7326 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event)); 7274 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event));
7327 7275
@@ -7342,7 +7290,7 @@ handle_user_signal (int sig)
7342 } 7290 }
7343 7291
7344 p->npending++; 7292 p->npending++;
7345#ifdef SIGIO 7293#ifdef USABLE_SIGIO
7346 if (interrupt_input) 7294 if (interrupt_input)
7347 kill (getpid (), SIGIO); 7295 kill (getpid (), SIGIO);
7348 else 7296 else
@@ -7355,8 +7303,12 @@ handle_user_signal (int sig)
7355 } 7303 }
7356 break; 7304 break;
7357 } 7305 }
7306}
7358 7307
7359 errno = old_errno; 7308static void
7309deliver_user_signal (int sig)
7310{
7311 handle_on_main_thread (sig, handle_user_signal);
7360} 7312}
7361 7313
7362static char * 7314static char *
@@ -7381,7 +7333,7 @@ store_user_signal_events (void)
7381 for (p = user_signals; p; p = p->next) 7333 for (p = user_signals; p; p = p->next)
7382 if (p->npending > 0) 7334 if (p->npending > 0)
7383 { 7335 {
7384 SIGMASKTYPE mask; 7336 sigset_t blocked, procmask;
7385 7337
7386 if (nstored == 0) 7338 if (nstored == 0)
7387 { 7339 {
@@ -7391,7 +7343,10 @@ store_user_signal_events (void)
7391 } 7343 }
7392 nstored += p->npending; 7344 nstored += p->npending;
7393 7345
7394 mask = sigblock (sigmask (p->sig)); 7346 sigemptyset (&blocked);
7347 sigaddset (&blocked, p->sig);
7348 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
7349
7395 do 7350 do
7396 { 7351 {
7397 buf.code = p->sig; 7352 buf.code = p->sig;
@@ -7399,7 +7354,8 @@ store_user_signal_events (void)
7399 p->npending--; 7354 p->npending--;
7400 } 7355 }
7401 while (p->npending > 0); 7356 while (p->npending > 0);
7402 sigsetmask (mask); 7357
7358 pthread_sigmask (SIG_SETMASK, &procmask, 0);
7403 } 7359 }
7404 7360
7405 return nstored; 7361 return nstored;
@@ -10438,7 +10394,7 @@ clear_input_pending (void)
10438int 10394int
10439requeued_events_pending_p (void) 10395requeued_events_pending_p (void)
10440{ 10396{
10441 return (!NILP (Vunread_command_events) || unread_command_char != -1); 10397 return (!NILP (Vunread_command_events));
10442} 10398}
10443 10399
10444 10400
@@ -10448,7 +10404,7 @@ Actually, the value is nil only if we can be sure that no input is available;
10448if there is a doubt, the value is t. */) 10404if there is a doubt, the value is t. */)
10449 (void) 10405 (void)
10450{ 10406{
10451 if (!NILP (Vunread_command_events) || unread_command_char != -1 10407 if (!NILP (Vunread_command_events)
10452 || !NILP (Vunread_post_input_method_events) 10408 || !NILP (Vunread_post_input_method_events)
10453 || !NILP (Vunread_input_method_events)) 10409 || !NILP (Vunread_input_method_events))
10454 return (Qt); 10410 return (Qt);
@@ -10636,7 +10592,6 @@ Also end any kbd macro being defined. */)
10636 update_mode_lines++; 10592 update_mode_lines++;
10637 10593
10638 Vunread_command_events = Qnil; 10594 Vunread_command_events = Qnil;
10639 unread_command_char = -1;
10640 10595
10641 discard_tty_input (); 10596 discard_tty_input ();
10642 10597
@@ -10776,17 +10731,10 @@ clear_waiting_for_input (void)
10776 Otherwise, tell QUIT to kill Emacs. */ 10731 Otherwise, tell QUIT to kill Emacs. */
10777 10732
10778static void 10733static void
10779interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10734handle_interrupt_signal (int sig)
10780 /* compilers complain in signal calls. */
10781{ 10735{
10782 /* Must preserve main program's value of errno. */
10783 int old_errno = errno;
10784 struct terminal *terminal;
10785
10786 SIGNAL_THREAD_CHECK (signalnum);
10787
10788 /* See if we have an active terminal on our controlling tty. */ 10736 /* See if we have an active terminal on our controlling tty. */
10789 terminal = get_named_tty ("/dev/tty"); 10737 struct terminal *terminal = get_named_tty ("/dev/tty");
10790 if (!terminal) 10738 if (!terminal)
10791 { 10739 {
10792 /* If there are no frames there, let's pretend that we are a 10740 /* 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 */
10807 10755
10808 handle_interrupt (); 10756 handle_interrupt ();
10809 } 10757 }
10758}
10810 10759
10811 errno = old_errno; 10760static void
10761deliver_interrupt_signal (int sig)
10762{
10763 handle_on_main_thread (sig, handle_interrupt_signal);
10812} 10764}
10813 10765
10766
10814/* If Emacs is stuck because `inhibit-quit' is true, then keep track 10767/* If Emacs is stuck because `inhibit-quit' is true, then keep track
10815 of the number of times C-g has been requested. If C-g is pressed 10768 of the number of times C-g has been requested. If C-g is pressed
10816 enough times, then quit anyway. See bug#6585. */ 10769 enough times, then quit anyway. See bug#6585. */
@@ -10840,7 +10793,10 @@ handle_interrupt (void)
10840 /* If SIGINT isn't blocked, don't let us be interrupted by 10793 /* If SIGINT isn't blocked, don't let us be interrupted by
10841 another SIGINT, it might be harmful due to non-reentrancy 10794 another SIGINT, it might be harmful due to non-reentrancy
10842 in I/O functions. */ 10795 in I/O functions. */
10843 sigblock (sigmask (SIGINT)); 10796 sigset_t blocked;
10797 sigemptyset (&blocked);
10798 sigaddset (&blocked, SIGINT);
10799 pthread_sigmask (SIG_BLOCK, &blocked, 0);
10844 10800
10845 fflush (stdout); 10801 fflush (stdout);
10846 reset_all_sys_modes (); 10802 reset_all_sys_modes ();
@@ -10902,7 +10858,7 @@ handle_interrupt (void)
10902#endif /* not MSDOS */ 10858#endif /* not MSDOS */
10903 fflush (stdout); 10859 fflush (stdout);
10904 if (((c = getchar ()) & ~040) == 'Y') 10860 if (((c = getchar ()) & ~040) == 'Y')
10905 abort (); 10861 emacs_abort ();
10906 while (c != '\n') c = getchar (); 10862 while (c != '\n') c = getchar ();
10907#ifdef MSDOS 10863#ifdef MSDOS
10908 printf ("\r\nContinuing...\r\n"); 10864 printf ("\r\nContinuing...\r\n");
@@ -10911,7 +10867,7 @@ handle_interrupt (void)
10911#endif /* not MSDOS */ 10867#endif /* not MSDOS */
10912 fflush (stdout); 10868 fflush (stdout);
10913 init_all_sys_modes (); 10869 init_all_sys_modes ();
10914 sigfree (); 10870 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10915 } 10871 }
10916 else 10872 else
10917 { 10873 {
@@ -10924,7 +10880,7 @@ handle_interrupt (void)
10924 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 10880 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
10925 10881
10926 immediate_quit = 0; 10882 immediate_quit = 0;
10927 sigfree (); 10883 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10928 saved = gl_state; 10884 saved = gl_state;
10929 GCPRO4 (saved.object, saved.global_code, 10885 GCPRO4 (saved.object, saved.global_code,
10930 saved.current_syntax_table, saved.old_prop); 10886 saved.current_syntax_table, saved.old_prop);
@@ -10969,13 +10925,12 @@ quit_throw_to_read_char (int from_signal)
10969 if (!from_signal && EQ (Vquit_flag, Qkill_emacs)) 10925 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
10970 Fkill_emacs (Qnil); 10926 Fkill_emacs (Qnil);
10971 10927
10972 sigfree (); 10928 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10973 /* Prevent another signal from doing this before we finish. */ 10929 /* Prevent another signal from doing this before we finish. */
10974 clear_waiting_for_input (); 10930 clear_waiting_for_input ();
10975 input_pending = 0; 10931 input_pending = 0;
10976 10932
10977 Vunread_command_events = Qnil; 10933 Vunread_command_events = Qnil;
10978 unread_command_char = -1;
10979 10934
10980#if 0 /* Currently, sit_for is called from read_char without turning 10935#if 0 /* Currently, sit_for is called from read_char without turning
10981 off polling. And that can call set_waiting_for_input. 10936 off polling. And that can call set_waiting_for_input.
@@ -10983,7 +10938,7 @@ quit_throw_to_read_char (int from_signal)
10983#ifdef POLL_FOR_INPUT 10938#ifdef POLL_FOR_INPUT
10984 /* May be > 1 if in recursive minibuffer. */ 10939 /* May be > 1 if in recursive minibuffer. */
10985 if (poll_suppress_count == 0) 10940 if (poll_suppress_count == 0)
10986 abort (); 10941 emacs_abort ();
10987#endif 10942#endif
10988#endif 10943#endif
10989 if (FRAMEP (internal_last_event_frame) 10944 if (FRAMEP (internal_last_event_frame)
@@ -10991,7 +10946,7 @@ quit_throw_to_read_char (int from_signal)
10991 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 10946 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
10992 0, 0, Qnil); 10947 0, 0, Qnil);
10993 10948
10994 _longjmp (getcjmp, 1); 10949 sys_longjmp (getcjmp, 1);
10995} 10950}
10996 10951
10997DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, 10952DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode,
@@ -11004,8 +10959,7 @@ See also `current-input-mode'. */)
11004 (Lisp_Object interrupt) 10959 (Lisp_Object interrupt)
11005{ 10960{
11006 int new_interrupt_input; 10961 int new_interrupt_input;
11007#ifdef SIGIO 10962#ifdef USABLE_SIGIO
11008/* Note SIGIO has been undef'd if FIONREAD is missing. */
11009#ifdef HAVE_X_WINDOWS 10963#ifdef HAVE_X_WINDOWS
11010 if (x_display_list != NULL) 10964 if (x_display_list != NULL)
11011 { 10965 {
@@ -11016,9 +10970,9 @@ See also `current-input-mode'. */)
11016 else 10970 else
11017#endif /* HAVE_X_WINDOWS */ 10971#endif /* HAVE_X_WINDOWS */
11018 new_interrupt_input = !NILP (interrupt); 10972 new_interrupt_input = !NILP (interrupt);
11019#else /* not SIGIO */ 10973#else /* not USABLE_SIGIO */
11020 new_interrupt_input = 0; 10974 new_interrupt_input = 0;
11021#endif /* not SIGIO */ 10975#endif /* not USABLE_SIGIO */
11022 10976
11023 if (new_interrupt_input != interrupt_input) 10977 if (new_interrupt_input != interrupt_input)
11024 { 10978 {
@@ -11341,7 +11295,7 @@ delete_kboard (KBOARD *kb)
11341 11295
11342 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard) 11296 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard)
11343 if (*kbp == NULL) 11297 if (*kbp == NULL)
11344 abort (); 11298 emacs_abort ();
11345 *kbp = kb->next_kboard; 11299 *kbp = kb->next_kboard;
11346 11300
11347 /* Prevent a dangling reference to KB. */ 11301 /* Prevent a dangling reference to KB. */
@@ -11352,7 +11306,7 @@ delete_kboard (KBOARD *kb)
11352 current_kboard = FRAME_KBOARD (XFRAME (selected_frame)); 11306 current_kboard = FRAME_KBOARD (XFRAME (selected_frame));
11353 single_kboard = 0; 11307 single_kboard = 0;
11354 if (current_kboard == kb) 11308 if (current_kboard == kb)
11355 abort (); 11309 emacs_abort ();
11356 } 11310 }
11357 11311
11358 wipe_kboard (kb); 11312 wipe_kboard (kb);
@@ -11362,12 +11316,11 @@ delete_kboard (KBOARD *kb)
11362void 11316void
11363init_keyboard (void) 11317init_keyboard (void)
11364{ 11318{
11365 /* This is correct before outermost invocation of the editor loop */ 11319 /* This is correct before outermost invocation of the editor loop. */
11366 command_loop_level = -1; 11320 command_loop_level = -1;
11367 immediate_quit = 0; 11321 immediate_quit = 0;
11368 quit_char = Ctl ('g'); 11322 quit_char = Ctl ('g');
11369 Vunread_command_events = Qnil; 11323 Vunread_command_events = Qnil;
11370 unread_command_char = -1;
11371 timer_idleness_start_time = invalid_emacs_time (); 11324 timer_idleness_start_time = invalid_emacs_time ();
11372 total_keys = 0; 11325 total_keys = 0;
11373 recent_keys_index = 0; 11326 recent_keys_index = 0;
@@ -11379,9 +11332,7 @@ init_keyboard (void)
11379 input_pending = 0; 11332 input_pending = 0;
11380 interrupt_input_blocked = 0; 11333 interrupt_input_blocked = 0;
11381 interrupt_input_pending = 0; 11334 interrupt_input_pending = 0;
11382#ifdef SYNC_INPUT
11383 pending_signals = 0; 11335 pending_signals = 0;
11384#endif
11385 11336
11386 /* This means that command_loop_1 won't try to select anything the first 11337 /* This means that command_loop_1 won't try to select anything the first
11387 time through. */ 11338 time through. */
@@ -11404,18 +11355,23 @@ init_keyboard (void)
11404 SIGINT. There is special code in interrupt_signal to exit 11355 SIGINT. There is special code in interrupt_signal to exit
11405 Emacs on SIGINT when there are no termcap frames on the 11356 Emacs on SIGINT when there are no termcap frames on the
11406 controlling terminal. */ 11357 controlling terminal. */
11407 signal (SIGINT, interrupt_signal); 11358 struct sigaction action;
11359 emacs_sigaction_init (&action, deliver_interrupt_signal);
11360 sigaction (SIGINT, &action, 0);
11408#ifndef DOS_NT 11361#ifndef DOS_NT
11409 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 11362 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
11410 SIGQUIT and we can't tell which one it will give us. */ 11363 SIGQUIT and we can't tell which one it will give us. */
11411 signal (SIGQUIT, interrupt_signal); 11364 sigaction (SIGQUIT, &action, 0);
11412#endif /* not DOS_NT */ 11365#endif /* not DOS_NT */
11413 } 11366 }
11414/* Note SIGIO has been undef'd if FIONREAD is missing. */ 11367#ifdef USABLE_SIGIO
11415#ifdef SIGIO
11416 if (!noninteractive) 11368 if (!noninteractive)
11417 signal (SIGIO, input_available_signal); 11369 {
11418#endif /* SIGIO */ 11370 struct sigaction action;
11371 emacs_sigaction_init (&action, deliver_input_available_signal);
11372 sigaction (SIGIO, &action, 0);
11373 }
11374#endif
11419 11375
11420/* Use interrupt input by default, if it works and noninterrupt input 11376/* Use interrupt input by default, if it works and noninterrupt input
11421 has deficiencies. */ 11377 has deficiencies. */
@@ -11426,7 +11382,7 @@ init_keyboard (void)
11426 interrupt_input = 0; 11382 interrupt_input = 0;
11427#endif 11383#endif
11428 11384
11429 sigfree (); 11385 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
11430 dribble = 0; 11386 dribble = 0;
11431 11387
11432 if (keyboard_init_hook) 11388 if (keyboard_init_hook)
@@ -11694,9 +11650,6 @@ as they will already have been added once as they were read for the first time.
11694An element of the form (t . EVENT) forces EVENT to be added to that list. */); 11650An element of the form (t . EVENT) forces EVENT to be added to that list. */);
11695 Vunread_command_events = Qnil; 11651 Vunread_command_events = Qnil;
11696 11652
11697 DEFVAR_INT ("unread-command-char", unread_command_char,
11698 doc: /* If not -1, an object to be read as next command input event. */);
11699
11700 DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events, 11653 DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events,
11701 doc: /* List of events to be processed as input by input methods. 11654 doc: /* List of events to be processed as input by input methods.
11702These events are processed before `unread-command-events' 11655These 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;
469 happens. */ 469 happens. */
470extern EMACS_TIME *input_available_clear_time; 470extern EMACS_TIME *input_available_clear_time;
471 471
472#if defined HAVE_WINDOW_SYSTEM 472#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS
473extern int ignore_mouse_drag_p; 473extern int ignore_mouse_drag_p;
474#endif 474#endif
475 475
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/>. */
40 40
41#include <config.h> 41#include <config.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <setjmp.h> 43
44#include "lisp.h" 44#include "lisp.h"
45#include "commands.h" 45#include "commands.h"
46#include "character.h" 46#include "character.h"
@@ -2923,7 +2923,7 @@ You type Translation\n\
2923 char *title, *p; 2923 char *title, *p;
2924 2924
2925 if (!SYMBOLP (modes[i])) 2925 if (!SYMBOLP (modes[i]))
2926 abort (); 2926 emacs_abort ();
2927 2927
2928 p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); 2928 p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i])));
2929 *p++ = '\f'; 2929 *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/>. */
20#ifndef EMACS_LISP_H 20#ifndef EMACS_LISP_H
21#define EMACS_LISP_H 21#define EMACS_LISP_H
22 22
23#include <setjmp.h>
23#include <stdalign.h> 24#include <stdalign.h>
24#include <stdarg.h> 25#include <stdarg.h>
25#include <stdbool.h> 26#include <stdbool.h>
@@ -325,7 +326,7 @@ enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 1 };
325typedef EMACS_INT Lisp_Object; 326typedef EMACS_INT Lisp_Object;
326#define XLI(o) (o) 327#define XLI(o) (o)
327#define XIL(i) (i) 328#define XIL(i) (i)
328#define LISP_MAKE_RVALUE(o) (0+(o)) 329#define LISP_MAKE_RVALUE(o) (0 + (o))
329#define LISP_INITIALLY_ZERO 0 330#define LISP_INITIALLY_ZERO 0
330enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 }; 331enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 };
331#endif /* CHECK_LISP_OBJECT_TYPE */ 332#endif /* CHECK_LISP_OBJECT_TYPE */
@@ -417,9 +418,9 @@ enum lsb_bits
417#define XINT(a) (XLI (a) >> INTTYPEBITS) 418#define XINT(a) (XLI (a) >> INTTYPEBITS)
418#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS) 419#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS)
419#define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS) 420#define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS)
420#define XSET(var, type, ptr) \ 421#define make_lisp_ptr(ptr, type) \
421 (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \ 422 (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \
422 (var) = XIL ((type) | (intptr_t) (ptr))) 423 XIL ((type) | (intptr_t) (ptr)))
423 424
424#define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK)) 425#define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK))
425#define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type))) 426#define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type)))
@@ -444,13 +445,13 @@ static EMACS_INT const VALMASK
444#define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK)) 445#define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK))
445#define make_number(N) XIL ((EMACS_INT) (N) & INTMASK) 446#define make_number(N) XIL ((EMACS_INT) (N) & INTMASK)
446 447
447#define XSET(var, type, ptr) \ 448#define make_lisp_ptr(ptr, type) \
448 ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ 449 (XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
449 + ((intptr_t) (ptr) & VALMASK))) 450 + ((intptr_t) (ptr) & VALMASK)))
450 451
451#if DATA_SEG_BITS 452#if DATA_SEG_BITS
452/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 453/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
453 which were stored in a Lisp_Object */ 454 which were stored in a Lisp_Object. */
454#define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) 455#define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS))
455#else 456#else
456#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK)) 457#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK))
@@ -554,16 +555,16 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
554 555
555/* Construct a Lisp_Object from a value or address. */ 556/* Construct a Lisp_Object from a value or address. */
556 557
557#define XSETINT(a, b) (a) = make_number (b) 558#define XSETINT(a, b) ((a) = make_number (b))
558#define XSETCONS(a, b) XSET (a, Lisp_Cons, b) 559#define XSETCONS(a, b) ((a) = make_lisp_ptr (b, Lisp_Cons))
559#define XSETVECTOR(a, b) XSET (a, Lisp_Vectorlike, b) 560#define XSETVECTOR(a, b) ((a) = make_lisp_ptr (b, Lisp_Vectorlike))
560#define XSETSTRING(a, b) XSET (a, Lisp_String, b) 561#define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String))
561#define XSETSYMBOL(a, b) XSET (a, Lisp_Symbol, b) 562#define XSETSYMBOL(a, b) ((a) = make_lisp_ptr (b, Lisp_Symbol))
562#define XSETFLOAT(a, b) XSET (a, Lisp_Float, b) 563#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float))
563 564
564/* Misc types. */ 565/* Misc types. */
565 566
566#define XSETMISC(a, b) XSET (a, Lisp_Misc, b) 567#define XSETMISC(a, b) ((a) = make_lisp_ptr (b, Lisp_Misc))
567#define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker) 568#define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker)
568 569
569/* Pseudovector types. */ 570/* Pseudovector types. */
@@ -909,14 +910,6 @@ enum
909 (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \ 910 (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \
910 : char_table_ref ((CT), (IDX))) 911 : char_table_ref ((CT), (IDX)))
911 912
912/* Almost equivalent to Faref (CT, IDX). However, if the result is
913 not a character, return IDX.
914
915 For these characters, do not check validity of CT
916 and do not follow parent. */
917#define CHAR_TABLE_TRANSLATE(CT, IDX) \
918 char_table_translate (CT, IDX)
919
920/* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and 913/* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and
921 8-bit European characters. Do not check validity of CT. */ 914 8-bit European characters. Do not check validity of CT. */
922#define CHAR_TABLE_SET(CT, IDX, VAL) \ 915#define CHAR_TABLE_SET(CT, IDX, VAL) \
@@ -1205,9 +1198,9 @@ struct Lisp_Hash_Table
1205 struct Lisp_Hash_Table *next_weak; 1198 struct Lisp_Hash_Table *next_weak;
1206 1199
1207 /* C function to compare two keys. */ 1200 /* C function to compare two keys. */
1208 int (*cmpfn) (struct Lisp_Hash_Table *, 1201 bool (*cmpfn) (struct Lisp_Hash_Table *,
1209 Lisp_Object, EMACS_UINT, 1202 Lisp_Object, EMACS_UINT,
1210 Lisp_Object, EMACS_UINT); 1203 Lisp_Object, EMACS_UINT);
1211 1204
1212 /* C function to compute hash code. */ 1205 /* C function to compute hash code. */
1213 EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object); 1206 EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object);
@@ -1627,7 +1620,7 @@ typedef struct {
1627 int mouse_face_image_state; 1620 int mouse_face_image_state;
1628} Mouse_HLInfo; 1621} Mouse_HLInfo;
1629 1622
1630/* Data type checking */ 1623/* Data type checking. */
1631 1624
1632#define NILP(x) EQ (x, Qnil) 1625#define NILP(x) EQ (x, Qnil)
1633 1626
@@ -1971,7 +1964,25 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
1971 static struct Lisp_Kboard_Objfwd ko_fwd; \ 1964 static struct Lisp_Kboard_Objfwd ko_fwd; \
1972 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ 1965 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
1973 } while (0) 1966 } while (0)
1974 1967
1968/* Save and restore the instruction and environment pointers,
1969 without affecting the signal mask. */
1970
1971#ifdef HAVE__SETJMP
1972typedef jmp_buf sys_jmp_buf;
1973# define sys_setjmp(j) _setjmp (j)
1974# define sys_longjmp(j, v) _longjmp (j, v)
1975#elif defined HAVE_SIGSETJMP
1976typedef sigjmp_buf sys_jmp_buf;
1977# define sys_setjmp(j) sigsetjmp (j, 0)
1978# define sys_longjmp(j, v) siglongjmp (j, v)
1979#else
1980/* A platform that uses neither _longjmp nor siglongjmp; assume
1981 longjmp does not affect the sigmask. */
1982typedef jmp_buf sys_jmp_buf;
1983# define sys_setjmp(j) setjmp (j)
1984# define sys_longjmp(j, v) longjmp (j, v)
1985#endif
1975 1986
1976 1987
1977/* Structure for recording Lisp call stack for backtrace purposes. */ 1988/* Structure for recording Lisp call stack for backtrace purposes. */
@@ -2000,7 +2011,7 @@ struct specbinding
2000 { 2011 {
2001 Lisp_Object symbol, old_value; 2012 Lisp_Object symbol, old_value;
2002 specbinding_func func; 2013 specbinding_func func;
2003 Lisp_Object unused; /* Dividing by 16 is faster than by 12 */ 2014 Lisp_Object unused; /* Dividing by 16 is faster than by 12. */
2004 }; 2015 };
2005 2016
2006extern struct specbinding *specpdl; 2017extern struct specbinding *specpdl;
@@ -2009,7 +2020,10 @@ extern ptrdiff_t specpdl_size;
2009 2020
2010#define SPECPDL_INDEX() (specpdl_ptr - specpdl) 2021#define SPECPDL_INDEX() (specpdl_ptr - specpdl)
2011 2022
2012/* Everything needed to describe an active condition case. */ 2023/* Everything needed to describe an active condition case.
2024
2025 Members are volatile if their values need to survive _longjmp when
2026 a 'struct handler' is a local variable. */
2013struct handler 2027struct handler
2014 { 2028 {
2015 /* The handler clauses and variable from the condition-case form. */ 2029 /* The handler clauses and variable from the condition-case form. */
@@ -2020,10 +2034,12 @@ struct handler
2020 error: handle all conditions, and errors can run the debugger 2034 error: handle all conditions, and errors can run the debugger
2021 or display a backtrace. */ 2035 or display a backtrace. */
2022 Lisp_Object handler; 2036 Lisp_Object handler;
2023 Lisp_Object var; 2037
2038 Lisp_Object volatile var;
2039
2024 /* Fsignal stores here the condition-case clause that applies, 2040 /* Fsignal stores here the condition-case clause that applies,
2025 and Fcondition_case thus knows which clause to run. */ 2041 and Fcondition_case thus knows which clause to run. */
2026 Lisp_Object chosen_clause; 2042 Lisp_Object volatile chosen_clause;
2027 2043
2028 /* Used to effect the longjump out to the handler. */ 2044 /* Used to effect the longjump out to the handler. */
2029 struct catchtag *tag; 2045 struct catchtag *tag;
@@ -2049,19 +2065,21 @@ struct handler
2049 of the catch form. 2065 of the catch form.
2050 2066
2051 All the other members are concerned with restoring the interpreter 2067 All the other members are concerned with restoring the interpreter
2052 state. */ 2068 state.
2053 2069
2070 Members are volatile if their values need to survive _longjmp when
2071 a 'struct catchtag' is a local variable. */
2054struct catchtag 2072struct catchtag
2055{ 2073{
2056 Lisp_Object tag; 2074 Lisp_Object tag;
2057 Lisp_Object val; 2075 Lisp_Object volatile val;
2058 struct catchtag *next; 2076 struct catchtag *volatile next;
2059 struct gcpro *gcpro; 2077 struct gcpro *gcpro;
2060 jmp_buf jmp; 2078 sys_jmp_buf jmp;
2061 struct backtrace *backlist; 2079 struct backtrace *backlist;
2062 struct handler *handlerlist; 2080 struct handler *handlerlist;
2063 EMACS_INT lisp_eval_depth; 2081 EMACS_INT lisp_eval_depth;
2064 ptrdiff_t pdlcount; 2082 ptrdiff_t volatile pdlcount;
2065 int poll_suppress_count; 2083 int poll_suppress_count;
2066 int interrupt_input_blocked; 2084 int interrupt_input_blocked;
2067 struct byte_stack *byte_stack; 2085 struct byte_stack *byte_stack;
@@ -2089,22 +2107,16 @@ extern char *stack_bottom;
2089 If quit-flag is set to `kill-emacs' the SIGINT handler has received 2107 If quit-flag is set to `kill-emacs' the SIGINT handler has received
2090 a request to exit Emacs when it is safe to do. */ 2108 a request to exit Emacs when it is safe to do. */
2091 2109
2092#ifdef SYNC_INPUT
2093extern void process_pending_signals (void); 2110extern void process_pending_signals (void);
2094extern int pending_signals; 2111extern int pending_signals;
2095#define ELSE_PENDING_SIGNALS \
2096 else if (pending_signals) \
2097 process_pending_signals ();
2098#else /* not SYNC_INPUT */
2099#define ELSE_PENDING_SIGNALS
2100#endif /* not SYNC_INPUT */
2101 2112
2102extern void process_quit_flag (void); 2113extern void process_quit_flag (void);
2103#define QUIT \ 2114#define QUIT \
2104 do { \ 2115 do { \
2105 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ 2116 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
2106 process_quit_flag (); \ 2117 process_quit_flag (); \
2107 ELSE_PENDING_SIGNALS \ 2118 else if (pending_signals) \
2119 process_pending_signals (); \
2108 } while (0) 2120 } while (0)
2109 2121
2110 2122
@@ -2288,7 +2300,7 @@ extern int gcpro_level;
2288 2300
2289#define UNGCPRO \ 2301#define UNGCPRO \
2290 ((--gcpro_level != gcpro1.level) \ 2302 ((--gcpro_level != gcpro1.level) \
2291 ? (abort (), 0) \ 2303 ? (emacs_abort (), 0) \
2292 : ((gcprolist = gcpro1.next), 0)) 2304 : ((gcprolist = gcpro1.next), 0))
2293 2305
2294#endif /* DEBUG_GCPRO */ 2306#endif /* DEBUG_GCPRO */
@@ -2567,8 +2579,7 @@ extern Lisp_Object Qchar_table_p, Qvector_or_char_table_p;
2567 2579
2568extern Lisp_Object Qcdr; 2580extern Lisp_Object Qcdr;
2569 2581
2570extern Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; 2582extern Lisp_Object Qrange_error, Qoverflow_error;
2571extern Lisp_Object Qoverflow_error, Qunderflow_error;
2572 2583
2573extern Lisp_Object Qfloatp; 2584extern Lisp_Object Qfloatp;
2574extern Lisp_Object Qnumberp, Qnumber_or_marker_p; 2585extern Lisp_Object Qnumberp, Qnumber_or_marker_p;
@@ -2579,10 +2590,10 @@ extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
2579 2590
2580EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST; 2591EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST;
2581 2592
2582/* Defined in frame.c */ 2593/* Defined in frame.c. */
2583extern Lisp_Object Qframep; 2594extern Lisp_Object Qframep;
2584 2595
2585/* Defined in data.c */ 2596/* Defined in data.c. */
2586extern Lisp_Object indirect_function (Lisp_Object); 2597extern Lisp_Object indirect_function (Lisp_Object);
2587extern Lisp_Object find_symbol_value (Lisp_Object); 2598extern Lisp_Object find_symbol_value (Lisp_Object);
2588 2599
@@ -2629,7 +2640,7 @@ extern void swap_in_global_binding (struct Lisp_Symbol *);
2629extern void syms_of_cmds (void); 2640extern void syms_of_cmds (void);
2630extern void keys_of_cmds (void); 2641extern void keys_of_cmds (void);
2631 2642
2632/* Defined in coding.c */ 2643/* Defined in coding.c. */
2633extern Lisp_Object Qcharset; 2644extern Lisp_Object Qcharset;
2634extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 2645extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
2635 ptrdiff_t, bool, bool, Lisp_Object); 2646 ptrdiff_t, bool, bool, Lisp_Object);
@@ -2637,7 +2648,7 @@ extern void init_coding (void);
2637extern void init_coding_once (void); 2648extern void init_coding_once (void);
2638extern void syms_of_coding (void); 2649extern void syms_of_coding (void);
2639 2650
2640/* Defined in character.c */ 2651/* Defined in character.c. */
2641EXFUN (Fmax_char, 0) ATTRIBUTE_CONST; 2652EXFUN (Fmax_char, 0) ATTRIBUTE_CONST;
2642extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t); 2653extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t);
2643extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t); 2654extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t);
@@ -2645,21 +2656,21 @@ extern int multibyte_char_to_unibyte (int) ATTRIBUTE_CONST;
2645extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST; 2656extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST;
2646extern void syms_of_character (void); 2657extern void syms_of_character (void);
2647 2658
2648/* Defined in charset.c */ 2659/* Defined in charset.c. */
2649extern void init_charset (void); 2660extern void init_charset (void);
2650extern void init_charset_once (void); 2661extern void init_charset_once (void);
2651extern void syms_of_charset (void); 2662extern void syms_of_charset (void);
2652/* Structure forward declarations. */ 2663/* Structure forward declarations. */
2653struct charset; 2664struct charset;
2654 2665
2655/* Defined in composite.c */ 2666/* Defined in composite.c. */
2656extern void syms_of_composite (void); 2667extern void syms_of_composite (void);
2657 2668
2658/* Defined in syntax.c */ 2669/* Defined in syntax.c. */
2659extern void init_syntax_once (void); 2670extern void init_syntax_once (void);
2660extern void syms_of_syntax (void); 2671extern void syms_of_syntax (void);
2661 2672
2662/* Defined in fns.c */ 2673/* Defined in fns.c. */
2663extern Lisp_Object QCrehash_size, QCrehash_threshold; 2674extern Lisp_Object QCrehash_size, QCrehash_threshold;
2664enum { NEXT_ALMOST_PRIME_LIMIT = 11 }; 2675enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
2665EXFUN (Fidentity, 1) ATTRIBUTE_CONST; 2676EXFUN (Fidentity, 1) ATTRIBUTE_CONST;
@@ -2693,13 +2704,12 @@ extern Lisp_Object string_to_multibyte (Lisp_Object);
2693extern Lisp_Object string_make_unibyte (Lisp_Object); 2704extern Lisp_Object string_make_unibyte (Lisp_Object);
2694extern void syms_of_fns (void); 2705extern void syms_of_fns (void);
2695 2706
2696/* Defined in floatfns.c */ 2707/* Defined in floatfns.c. */
2697extern double extract_float (Lisp_Object); 2708extern double extract_float (Lisp_Object);
2698extern void init_floatfns (void);
2699extern void syms_of_floatfns (void); 2709extern void syms_of_floatfns (void);
2700extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); 2710extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y);
2701 2711
2702/* Defined in fringe.c */ 2712/* Defined in fringe.c. */
2703extern void syms_of_fringe (void); 2713extern void syms_of_fringe (void);
2704extern void init_fringe (void); 2714extern void init_fringe (void);
2705#ifdef HAVE_WINDOW_SYSTEM 2715#ifdef HAVE_WINDOW_SYSTEM
@@ -2707,13 +2717,13 @@ extern void mark_fringe_data (void);
2707extern void init_fringe_once (void); 2717extern void init_fringe_once (void);
2708#endif /* HAVE_WINDOW_SYSTEM */ 2718#endif /* HAVE_WINDOW_SYSTEM */
2709 2719
2710/* Defined in image.c */ 2720/* Defined in image.c. */
2711extern Lisp_Object QCascent, QCmargin, QCrelief; 2721extern Lisp_Object QCascent, QCmargin, QCrelief;
2712extern Lisp_Object QCconversion; 2722extern Lisp_Object QCconversion;
2713extern int x_bitmap_mask (struct frame *, ptrdiff_t); 2723extern int x_bitmap_mask (struct frame *, ptrdiff_t);
2714extern void syms_of_image (void); 2724extern void syms_of_image (void);
2715 2725
2716/* Defined in insdel.c */ 2726/* Defined in insdel.c. */
2717extern Lisp_Object Qinhibit_modification_hooks; 2727extern Lisp_Object Qinhibit_modification_hooks;
2718extern void move_gap (ptrdiff_t); 2728extern void move_gap (ptrdiff_t);
2719extern void move_gap_both (ptrdiff_t, ptrdiff_t); 2729extern 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,
2759 const char *, ptrdiff_t, ptrdiff_t, bool); 2769 const char *, ptrdiff_t, ptrdiff_t, bool);
2760extern void syms_of_insdel (void); 2770extern void syms_of_insdel (void);
2761 2771
2762/* Defined in dispnew.c */ 2772/* Defined in dispnew.c. */
2763#if (defined PROFILING \ 2773#if (defined PROFILING \
2764 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) 2774 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
2765_Noreturn void __executable_start (void); 2775_Noreturn void __executable_start (void);
@@ -2770,7 +2780,7 @@ extern Lisp_Object sit_for (Lisp_Object, bool, int);
2770extern void init_display (void); 2780extern void init_display (void);
2771extern void syms_of_display (void); 2781extern void syms_of_display (void);
2772 2782
2773/* Defined in xdisp.c */ 2783/* Defined in xdisp.c. */
2774extern Lisp_Object Qinhibit_point_motion_hooks; 2784extern Lisp_Object Qinhibit_point_motion_hooks;
2775extern Lisp_Object Qinhibit_redisplay, Qdisplay; 2785extern Lisp_Object Qinhibit_redisplay, Qdisplay;
2776extern Lisp_Object Qmenu_bar_update_hook; 2786extern Lisp_Object Qmenu_bar_update_hook;
@@ -2821,17 +2831,15 @@ extern Lisp_Object safe_eval (Lisp_Object);
2821extern int pos_visible_p (struct window *, ptrdiff_t, int *, 2831extern int pos_visible_p (struct window *, ptrdiff_t, int *,
2822 int *, int *, int *, int *, int *); 2832 int *, int *, int *, int *, int *);
2823 2833
2824/* Defined in xsettings.c */ 2834/* Defined in xsettings.c. */
2825extern void syms_of_xsettings (void); 2835extern void syms_of_xsettings (void);
2826 2836
2827/* Defined in vm-limit.c. */ 2837/* Defined in vm-limit.c. */
2828extern void memory_warnings (void *, void (*warnfun) (const char *)); 2838extern void memory_warnings (void *, void (*warnfun) (const char *));
2829 2839
2830/* Defined in alloc.c */ 2840/* Defined in alloc.c. */
2831extern void check_pure_size (void); 2841extern void check_pure_size (void);
2832extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); 2842extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
2833extern void reset_malloc_hooks (void);
2834extern void uninterrupt_malloc (void);
2835extern void malloc_warning (const char *); 2843extern void malloc_warning (const char *);
2836extern _Noreturn void memory_full (size_t); 2844extern _Noreturn void memory_full (size_t);
2837extern _Noreturn void buffer_memory_full (ptrdiff_t); 2845extern _Noreturn void buffer_memory_full (ptrdiff_t);
@@ -2930,7 +2938,7 @@ extern void check_cons_list (void);
2930#endif 2938#endif
2931 2939
2932#ifdef REL_ALLOC 2940#ifdef REL_ALLOC
2933/* Defined in ralloc.c */ 2941/* Defined in ralloc.c. */
2934extern void *r_alloc (void **, size_t); 2942extern void *r_alloc (void **, size_t);
2935extern void r_alloc_free (void **); 2943extern void r_alloc_free (void **);
2936extern void *r_re_alloc (void **, size_t); 2944extern void *r_re_alloc (void **, size_t);
@@ -2938,7 +2946,7 @@ extern void r_alloc_reset_variable (void **, void **);
2938extern void r_alloc_inhibit_buffer_relocation (int); 2946extern void r_alloc_inhibit_buffer_relocation (int);
2939#endif 2947#endif
2940 2948
2941/* Defined in chartab.c */ 2949/* Defined in chartab.c. */
2942extern Lisp_Object copy_char_table (Lisp_Object); 2950extern Lisp_Object copy_char_table (Lisp_Object);
2943extern Lisp_Object char_table_ref (Lisp_Object, int); 2951extern Lisp_Object char_table_ref (Lisp_Object, int);
2944extern Lisp_Object char_table_ref_and_range (Lisp_Object, int, 2952extern 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
2956extern Lisp_Object uniprop_table (Lisp_Object); 2964extern Lisp_Object uniprop_table (Lisp_Object);
2957extern void syms_of_chartab (void); 2965extern void syms_of_chartab (void);
2958 2966
2959/* Defined in print.c */ 2967/* Defined in print.c. */
2960extern Lisp_Object Vprin1_to_string_buffer; 2968extern Lisp_Object Vprin1_to_string_buffer;
2961extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE; 2969extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE;
2962extern Lisp_Object Qstandard_output; 2970extern Lisp_Object Qstandard_output;
@@ -2973,7 +2981,7 @@ enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 };
2973extern int float_to_string (char *, double); 2981extern int float_to_string (char *, double);
2974extern void syms_of_print (void); 2982extern void syms_of_print (void);
2975 2983
2976/* Defined in doprnt.c */ 2984/* Defined in doprnt.c. */
2977extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *, 2985extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *,
2978 va_list); 2986 va_list);
2979extern ptrdiff_t esprintf (char *, char const *, ...) 2987extern ptrdiff_t esprintf (char *, char const *, ...)
@@ -2988,6 +2996,7 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t,
2988/* Defined in lread.c. */ 2996/* Defined in lread.c. */
2989extern Lisp_Object Qvariable_documentation, Qstandard_input; 2997extern Lisp_Object Qvariable_documentation, Qstandard_input;
2990extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; 2998extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
2999extern Lisp_Object Qlexical_binding;
2991extern Lisp_Object check_obarray (Lisp_Object); 3000extern Lisp_Object check_obarray (Lisp_Object);
2992extern Lisp_Object intern_1 (const char *, ptrdiff_t); 3001extern Lisp_Object intern_1 (const char *, ptrdiff_t);
2993extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); 3002extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t);
@@ -3021,12 +3030,11 @@ intern_c_string (const char *str)
3021 3030
3022/* Defined in eval.c. */ 3031/* Defined in eval.c. */
3023extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; 3032extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro;
3024extern Lisp_Object Qinhibit_quit, Qclosure; 3033extern Lisp_Object Qinhibit_quit, Qinternal_interpreter_environment, Qclosure;
3025extern Lisp_Object Qand_rest; 3034extern Lisp_Object Qand_rest;
3026extern Lisp_Object Vautoload_queue; 3035extern Lisp_Object Vautoload_queue;
3027extern Lisp_Object Vsignaling_function; 3036extern Lisp_Object Vsignaling_function;
3028extern Lisp_Object inhibit_lisp_code; 3037extern Lisp_Object inhibit_lisp_code;
3029extern int handling_signal;
3030#if BYTE_MARK_STACK 3038#if BYTE_MARK_STACK
3031extern struct catchtag *catchlist; 3039extern struct catchtag *catchlist;
3032extern struct handler *handlerlist; 3040extern struct handler *handlerlist;
@@ -3075,6 +3083,7 @@ extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
3075extern _Noreturn void verror (const char *, va_list) 3083extern _Noreturn void verror (const char *, va_list)
3076 ATTRIBUTE_FORMAT_PRINTF (1, 0); 3084 ATTRIBUTE_FORMAT_PRINTF (1, 0);
3077extern Lisp_Object un_autoload (Lisp_Object); 3085extern Lisp_Object un_autoload (Lisp_Object);
3086extern Lisp_Object call_debugger (Lisp_Object arg);
3078extern void init_eval_once (void); 3087extern void init_eval_once (void);
3079extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); 3088extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
3080extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); 3089extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
@@ -3137,7 +3146,7 @@ extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
3137extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t); 3146extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t);
3138extern void syms_of_marker (void); 3147extern void syms_of_marker (void);
3139 3148
3140/* Defined in fileio.c */ 3149/* Defined in fileio.c. */
3141 3150
3142extern Lisp_Object Qfile_error; 3151extern Lisp_Object Qfile_error;
3143extern Lisp_Object Qfile_exists_p; 3152extern Lisp_Object Qfile_exists_p;
@@ -3145,16 +3154,16 @@ extern Lisp_Object Qfile_directory_p;
3145extern Lisp_Object Qinsert_file_contents; 3154extern Lisp_Object Qinsert_file_contents;
3146extern Lisp_Object Qfile_name_history; 3155extern Lisp_Object Qfile_name_history;
3147extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); 3156extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
3148EXFUN (Fread_file_name, 6); /* not a normal DEFUN */ 3157EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
3149extern Lisp_Object close_file_unwind (Lisp_Object); 3158extern Lisp_Object close_file_unwind (Lisp_Object);
3150extern Lisp_Object restore_point_unwind (Lisp_Object); 3159extern Lisp_Object restore_point_unwind (Lisp_Object);
3151extern _Noreturn void report_file_error (const char *, Lisp_Object); 3160extern _Noreturn void report_file_error (const char *, Lisp_Object);
3152extern int internal_delete_file (Lisp_Object); 3161extern void internal_delete_file (Lisp_Object);
3153extern void syms_of_fileio (void); 3162extern void syms_of_fileio (void);
3154extern Lisp_Object make_temp_name (Lisp_Object, int); 3163extern Lisp_Object make_temp_name (Lisp_Object, bool);
3155extern Lisp_Object Qdelete_file; 3164extern Lisp_Object Qdelete_file;
3156 3165
3157/* Defined in search.c */ 3166/* Defined in search.c. */
3158extern void shrink_regexp_cache (void); 3167extern void shrink_regexp_cache (void);
3159extern void restore_search_regs (void); 3168extern void restore_search_regs (void);
3160extern void record_unwind_save_match_data (void); 3169extern void record_unwind_save_match_data (void);
@@ -3227,9 +3236,7 @@ extern void cmd_error_internal (Lisp_Object, const char *);
3227extern Lisp_Object command_loop_1 (void); 3236extern Lisp_Object command_loop_1 (void);
3228extern Lisp_Object recursive_edit_1 (void); 3237extern Lisp_Object recursive_edit_1 (void);
3229extern void record_auto_save (void); 3238extern void record_auto_save (void);
3230#ifdef SIGDANGER
3231extern void force_auto_save_soon (void); 3239extern void force_auto_save_soon (void);
3232#endif
3233extern void init_keyboard (void); 3240extern void init_keyboard (void);
3234extern void syms_of_keyboard (void); 3241extern void syms_of_keyboard (void);
3235extern void keys_of_keyboard (void); 3242extern void keys_of_keyboard (void);
@@ -3257,14 +3264,12 @@ extern void syms_of_frame (void);
3257extern char **initial_argv; 3264extern char **initial_argv;
3258extern int initial_argc; 3265extern int initial_argc;
3259#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 3266#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
3260extern int display_arg; 3267extern bool display_arg;
3261#endif 3268#endif
3262extern Lisp_Object decode_env_path (const char *, const char *); 3269extern Lisp_Object decode_env_path (const char *, const char *);
3263extern Lisp_Object empty_unibyte_string, empty_multibyte_string; 3270extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
3264extern Lisp_Object Qfile_name_handler_alist; 3271extern Lisp_Object Qfile_name_handler_alist;
3265#ifdef FLOAT_CATCH_SIGILL 3272extern _Noreturn void fatal_error_backtrace (int, int);
3266extern void fatal_error_signal (int);
3267#endif
3268extern Lisp_Object Qkill_emacs; 3273extern Lisp_Object Qkill_emacs;
3269#if HAVE_SETLOCALE 3274#if HAVE_SETLOCALE
3270void fixup_locale (void); 3275void fixup_locale (void);
@@ -3276,22 +3281,26 @@ void synchronize_system_time_locale (void);
3276#define synchronize_system_messages_locale() 3281#define synchronize_system_messages_locale()
3277#define synchronize_system_time_locale() 3282#define synchronize_system_time_locale()
3278#endif 3283#endif
3279void shut_down_emacs (int, int, Lisp_Object); 3284extern void shut_down_emacs (int, Lisp_Object);
3280/* Nonzero means don't do interactive redisplay and don't change tty modes. */
3281extern int noninteractive;
3282 3285
3283/* Nonzero means remove site-lisp directories from load-path. */ 3286/* True means don't do interactive redisplay and don't change tty modes. */
3284extern int no_site_lisp; 3287extern bool noninteractive;
3288
3289/* True means remove site-lisp directories from load-path. */
3290extern bool no_site_lisp;
3285 3291
3286/* Pipe used to send exit notification to the daemon parent at 3292/* Pipe used to send exit notification to the daemon parent at
3287 startup. */ 3293 startup. */
3288extern int daemon_pipe[2]; 3294extern int daemon_pipe[2];
3289#define IS_DAEMON (daemon_pipe[1] != 0) 3295#define IS_DAEMON (daemon_pipe[1] != 0)
3290 3296
3291/* Nonzero means don't do use window-system-specific display code. */ 3297/* True if handling a fatal error already. */
3292extern int inhibit_window_system; 3298extern bool fatal_error_in_progress;
3293/* Nonzero means that a filter or a sentinel is running. */ 3299
3294extern int running_asynch_code; 3300/* True means don't do use window-system-specific display code. */
3301extern bool inhibit_window_system;
3302/* True means that a filter or a sentinel is running. */
3303extern bool running_asynch_code;
3295 3304
3296/* Defined in process.c. */ 3305/* Defined in process.c. */
3297extern Lisp_Object QCtype, Qlocal; 3306extern Lisp_Object QCtype, Qlocal;
@@ -3329,14 +3338,14 @@ extern void init_callproc (void);
3329extern void set_initial_environment (void); 3338extern void set_initial_environment (void);
3330extern void syms_of_callproc (void); 3339extern void syms_of_callproc (void);
3331 3340
3332/* Defined in doc.c */ 3341/* Defined in doc.c. */
3333extern Lisp_Object Qfunction_documentation; 3342extern Lisp_Object Qfunction_documentation;
3334extern Lisp_Object read_doc_string (Lisp_Object); 3343extern Lisp_Object read_doc_string (Lisp_Object);
3335extern Lisp_Object get_doc_string (Lisp_Object, bool, bool); 3344extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
3336extern void syms_of_doc (void); 3345extern void syms_of_doc (void);
3337extern int read_bytecode_char (bool); 3346extern int read_bytecode_char (bool);
3338 3347
3339/* Defined in bytecode.c */ 3348/* Defined in bytecode.c. */
3340extern Lisp_Object Qbytecode; 3349extern Lisp_Object Qbytecode;
3341extern void syms_of_bytecode (void); 3350extern void syms_of_bytecode (void);
3342extern struct byte_stack *byte_stack_list; 3351extern struct byte_stack *byte_stack_list;
@@ -3347,12 +3356,12 @@ extern void unmark_byte_stack (void);
3347extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, 3356extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object,
3348 Lisp_Object, ptrdiff_t, Lisp_Object *); 3357 Lisp_Object, ptrdiff_t, Lisp_Object *);
3349 3358
3350/* Defined in macros.c */ 3359/* Defined in macros.c. */
3351extern Lisp_Object Qexecute_kbd_macro; 3360extern Lisp_Object Qexecute_kbd_macro;
3352extern void init_macros (void); 3361extern void init_macros (void);
3353extern void syms_of_macros (void); 3362extern void syms_of_macros (void);
3354 3363
3355/* Defined in undo.c */ 3364/* Defined in undo.c. */
3356extern Lisp_Object Qapply; 3365extern Lisp_Object Qapply;
3357extern Lisp_Object Qinhibit_read_only; 3366extern Lisp_Object Qinhibit_read_only;
3358extern void truncate_undo_list (struct buffer *); 3367extern void truncate_undo_list (struct buffer *);
@@ -3365,7 +3374,7 @@ extern void record_property_change (ptrdiff_t, ptrdiff_t,
3365 Lisp_Object, Lisp_Object, 3374 Lisp_Object, Lisp_Object,
3366 Lisp_Object); 3375 Lisp_Object);
3367extern void syms_of_undo (void); 3376extern void syms_of_undo (void);
3368/* Defined in textprop.c */ 3377/* Defined in textprop.c. */
3369extern Lisp_Object Qfont, Qmouse_face; 3378extern Lisp_Object Qfont, Qmouse_face;
3370extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks; 3379extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks;
3371extern Lisp_Object Qfront_sticky, Qrear_nonsticky; 3380extern Lisp_Object Qfront_sticky, Qrear_nonsticky;
@@ -3373,19 +3382,19 @@ extern Lisp_Object Qminibuffer_prompt;
3373 3382
3374extern void report_interval_modification (Lisp_Object, Lisp_Object); 3383extern void report_interval_modification (Lisp_Object, Lisp_Object);
3375 3384
3376/* Defined in menu.c */ 3385/* Defined in menu.c. */
3377extern void syms_of_menu (void); 3386extern void syms_of_menu (void);
3378 3387
3379/* Defined in xmenu.c */ 3388/* Defined in xmenu.c. */
3380extern void syms_of_xmenu (void); 3389extern void syms_of_xmenu (void);
3381 3390
3382/* Defined in termchar.h */ 3391/* Defined in termchar.h. */
3383struct tty_display_info; 3392struct tty_display_info;
3384 3393
3385/* Defined in termhooks.h */ 3394/* Defined in termhooks.h. */
3386struct terminal; 3395struct terminal;
3387 3396
3388/* Defined in sysdep.c */ 3397/* Defined in sysdep.c. */
3389#ifndef HAVE_GET_CURRENT_DIR_NAME 3398#ifndef HAVE_GET_CURRENT_DIR_NAME
3390extern char *get_current_dir_name (void); 3399extern char *get_current_dir_name (void);
3391#endif 3400#endif
@@ -3407,6 +3416,8 @@ extern int set_window_size (int, int, int);
3407extern EMACS_INT get_random (void); 3416extern EMACS_INT get_random (void);
3408extern void seed_random (void *, ptrdiff_t); 3417extern void seed_random (void *, ptrdiff_t);
3409extern void init_random (void); 3418extern void init_random (void);
3419extern void emacs_backtrace (int);
3420extern _Noreturn void emacs_abort (void) NO_INLINE;
3410extern int emacs_open (const char *, int, int); 3421extern int emacs_open (const char *, int, int);
3411extern int emacs_close (int); 3422extern int emacs_close (int);
3412extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 3423extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
@@ -3420,45 +3431,45 @@ extern void unlock_file (Lisp_Object);
3420extern void unlock_buffer (struct buffer *); 3431extern void unlock_buffer (struct buffer *);
3421extern void syms_of_filelock (void); 3432extern void syms_of_filelock (void);
3422 3433
3423/* Defined in sound.c */ 3434/* Defined in sound.c. */
3424extern void syms_of_sound (void); 3435extern void syms_of_sound (void);
3425 3436
3426/* Defined in category.c */ 3437/* Defined in category.c. */
3427extern void init_category_once (void); 3438extern void init_category_once (void);
3428extern Lisp_Object char_category_set (int); 3439extern Lisp_Object char_category_set (int);
3429extern void syms_of_category (void); 3440extern void syms_of_category (void);
3430 3441
3431/* Defined in ccl.c */ 3442/* Defined in ccl.c. */
3432extern void syms_of_ccl (void); 3443extern void syms_of_ccl (void);
3433 3444
3434/* Defined in dired.c */ 3445/* Defined in dired.c. */
3435extern void syms_of_dired (void); 3446extern void syms_of_dired (void);
3436extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, 3447extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
3437 Lisp_Object, Lisp_Object, 3448 Lisp_Object, Lisp_Object,
3438 bool, Lisp_Object); 3449 bool, Lisp_Object);
3439 3450
3440/* Defined in term.c */ 3451/* Defined in term.c. */
3441extern int *char_ins_del_vector; 3452extern int *char_ins_del_vector;
3442extern void syms_of_term (void); 3453extern void syms_of_term (void);
3443extern _Noreturn void fatal (const char *msgid, ...) 3454extern _Noreturn void fatal (const char *msgid, ...)
3444 ATTRIBUTE_FORMAT_PRINTF (1, 2); 3455 ATTRIBUTE_FORMAT_PRINTF (1, 2);
3445 3456
3446/* Defined in terminal.c */ 3457/* Defined in terminal.c. */
3447extern void syms_of_terminal (void); 3458extern void syms_of_terminal (void);
3448 3459
3449/* Defined in font.c */ 3460/* Defined in font.c. */
3450extern void syms_of_font (void); 3461extern void syms_of_font (void);
3451extern void init_font (void); 3462extern void init_font (void);
3452 3463
3453#ifdef HAVE_WINDOW_SYSTEM 3464#ifdef HAVE_WINDOW_SYSTEM
3454/* Defined in fontset.c */ 3465/* Defined in fontset.c. */
3455extern void syms_of_fontset (void); 3466extern void syms_of_fontset (void);
3456 3467
3457/* Defined in xfns.c, w32fns.c, or macfns.c */ 3468/* Defined in xfns.c, w32fns.c, or macfns.c. */
3458extern Lisp_Object Qfont_param; 3469extern Lisp_Object Qfont_param;
3459#endif 3470#endif
3460 3471
3461/* Defined in xfaces.c */ 3472/* Defined in xfaces.c. */
3462extern Lisp_Object Qdefault, Qtool_bar, Qfringe; 3473extern Lisp_Object Qdefault, Qtool_bar, Qfringe;
3463extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; 3474extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor;
3464extern Lisp_Object Qmode_line_inactive; 3475extern Lisp_Object Qmode_line_inactive;
@@ -3466,31 +3477,34 @@ extern Lisp_Object Qface;
3466extern Lisp_Object Qnormal; 3477extern Lisp_Object Qnormal;
3467extern Lisp_Object QCfamily, QCweight, QCslant; 3478extern Lisp_Object QCfamily, QCweight, QCslant;
3468extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground; 3479extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground;
3480extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold;
3481extern Lisp_Object Qbold, Qextra_bold, Qultra_bold;
3482extern Lisp_Object Qoblique, Qitalic;
3469extern Lisp_Object Vface_alternative_font_family_alist; 3483extern Lisp_Object Vface_alternative_font_family_alist;
3470extern Lisp_Object Vface_alternative_font_registry_alist; 3484extern Lisp_Object Vface_alternative_font_registry_alist;
3471extern void syms_of_xfaces (void); 3485extern void syms_of_xfaces (void);
3472 3486
3473#ifdef HAVE_X_WINDOWS 3487#ifdef HAVE_X_WINDOWS
3474/* Defined in xfns.c */ 3488/* Defined in xfns.c. */
3475extern void syms_of_xfns (void); 3489extern void syms_of_xfns (void);
3476 3490
3477/* Defined in xsmfns.c */ 3491/* Defined in xsmfns.c. */
3478extern void syms_of_xsmfns (void); 3492extern void syms_of_xsmfns (void);
3479 3493
3480/* Defined in xselect.c */ 3494/* Defined in xselect.c. */
3481extern void syms_of_xselect (void); 3495extern void syms_of_xselect (void);
3482 3496
3483/* Defined in xterm.c */ 3497/* Defined in xterm.c. */
3484extern void syms_of_xterm (void); 3498extern void syms_of_xterm (void);
3485#endif /* HAVE_X_WINDOWS */ 3499#endif /* HAVE_X_WINDOWS */
3486 3500
3487#ifdef HAVE_WINDOW_SYSTEM 3501#ifdef HAVE_WINDOW_SYSTEM
3488/* Defined in xterm.c, nsterm.m, w32term.c */ 3502/* Defined in xterm.c, nsterm.m, w32term.c. */
3489extern char *x_get_keysym_name (int); 3503extern char *x_get_keysym_name (int);
3490#endif /* HAVE_WINDOW_SYSTEM */ 3504#endif /* HAVE_WINDOW_SYSTEM */
3491 3505
3492#ifdef HAVE_LIBXML2 3506#ifdef HAVE_LIBXML2
3493/* Defined in xml.c */ 3507/* Defined in xml.c. */
3494extern void syms_of_xml (void); 3508extern void syms_of_xml (void);
3495extern void xml_cleanup_parser (void); 3509extern void xml_cleanup_parser (void);
3496#endif 3510#endif
@@ -3501,20 +3515,20 @@ extern int have_menus_p (void);
3501#endif 3515#endif
3502 3516
3503#ifdef HAVE_DBUS 3517#ifdef HAVE_DBUS
3504/* Defined in dbusbind.c */ 3518/* Defined in dbusbind.c. */
3505void syms_of_dbusbind (void); 3519void syms_of_dbusbind (void);
3506#endif 3520#endif
3507 3521
3508#ifdef DOS_NT 3522#ifdef DOS_NT
3509/* Defined in msdos.c, w32.c */ 3523/* Defined in msdos.c, w32.c. */
3510extern char *emacs_root_dir (void); 3524extern char *emacs_root_dir (void);
3511#endif /* DOS_NT */ 3525#endif /* DOS_NT */
3512 3526
3513/* Nonzero means Emacs has already been initialized. 3527/* True means Emacs has already been initialized.
3514 Used during startup to detect startup of dumped Emacs. */ 3528 Used during startup to detect startup of dumped Emacs. */
3515extern int initialized; 3529extern bool initialized;
3516 3530
3517extern int immediate_quit; /* Nonzero means ^G can quit instantly */ 3531extern int immediate_quit; /* Nonzero means ^G can quit instantly. */
3518 3532
3519extern void *xmalloc (size_t); 3533extern void *xmalloc (size_t);
3520extern void *xzalloc (size_t); 3534extern void *xzalloc (size_t);
@@ -3544,36 +3558,10 @@ extern void init_system_name (void);
3544#define make_fixnum_or_float(val) \ 3558#define make_fixnum_or_float(val) \
3545 (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val)) 3559 (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val))
3546 3560
3547
3548/* Checks the `cycle check' variable CHECK to see if it indicates that
3549 EL is part of a cycle; CHECK must be either Qnil or a value returned
3550 by an earlier use of CYCLE_CHECK. SUSPICIOUS is the number of
3551 elements after which a cycle might be suspected; after that many
3552 elements, this macro begins consing in order to keep more precise
3553 track of elements.
3554
3555 Returns nil if a cycle was detected, otherwise a new value for CHECK
3556 that includes EL.
3557
3558 CHECK is evaluated multiple times, EL and SUSPICIOUS 0 or 1 times, so
3559 the caller should make sure that's ok. */
3560
3561#define CYCLE_CHECK(check, el, suspicious) \
3562 (NILP (check) \
3563 ? make_number (0) \
3564 : (INTEGERP (check) \
3565 ? (XFASTINT (check) < (suspicious) \
3566 ? make_number (XFASTINT (check) + 1) \
3567 : Fcons (el, Qnil)) \
3568 : (!NILP (Fmemq ((el), (check))) \
3569 ? Qnil \
3570 : Fcons ((el), (check)))))
3571
3572
3573/* SAFE_ALLOCA normally allocates memory on the stack, but if size is 3561/* SAFE_ALLOCA normally allocates memory on the stack, but if size is
3574 larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ 3562 larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */
3575 3563
3576enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; 3564enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
3577 3565
3578extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3566extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3579extern void *record_xmalloc (size_t); 3567extern 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 = \
65 $(lispsource)/format.elc \ 65 $(lispsource)/format.elc \
66 $(lispsource)/bindings.elc \ 66 $(lispsource)/bindings.elc \
67 $(lispsource)/files.elc \ 67 $(lispsource)/files.elc \
68 $(lispsource)/emacs-lisp/macroexp.elc \
68 $(lispsource)/cus-face.elc \ 69 $(lispsource)/cus-face.elc \
69 $(lispsource)/faces.elc \ 70 $(lispsource)/faces.elc \
70 $(lispsource)/button.elc \ 71 $(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/>. */
25#include <sys/file.h> 25#include <sys/file.h>
26#include <errno.h> 26#include <errno.h>
27#include <limits.h> /* For CHAR_BIT. */ 27#include <limits.h> /* For CHAR_BIT. */
28#include <setjmp.h>
29#include <stat-time.h> 28#include <stat-time.h>
30#include "lisp.h" 29#include "lisp.h"
31#include "intervals.h" 30#include "intervals.h"
@@ -50,7 +49,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#endif 49#endif
51 50
52#include <unistd.h> 51#include <unistd.h>
53#include <math.h>
54 52
55#ifdef HAVE_SETLOCALE 53#ifdef HAVE_SETLOCALE
56#include <locale.h> 54#include <locale.h>
@@ -89,8 +87,6 @@ static Lisp_Object Qget_emacs_mule_file_char;
89 87
90static Lisp_Object Qload_force_doc_strings; 88static Lisp_Object Qload_force_doc_strings;
91 89
92extern Lisp_Object Qinternal_interpreter_environment;
93
94static Lisp_Object Qload_in_progress; 90static Lisp_Object Qload_in_progress;
95 91
96/* The association list of objects read with the #n=object form. 92/* The association list of objects read with the #n=object form.
@@ -1682,6 +1678,17 @@ readevalloop (Lisp_Object readcharfun,
1682 int whole_buffer = 0; 1678 int whole_buffer = 0;
1683 /* 1 on the first time around. */ 1679 /* 1 on the first time around. */
1684 int first_sexp = 1; 1680 int first_sexp = 1;
1681 Lisp_Object macroexpand = intern ("internal-macroexpand-for-load");
1682
1683 if (NILP (Ffboundp (macroexpand))
1684 /* Don't macroexpand in .elc files, since it should have been done
1685 already. We actually don't know whether we're in a .elc file or not,
1686 so we use circumstancial evidence: .el files normally go through
1687 Vload_source_file_function -> load-with-code-conversion
1688 -> eval-buffer. */
1689 || EQ (readcharfun, Qget_file_char)
1690 || EQ (readcharfun, Qget_emacs_mule_file_char))
1691 macroexpand = Qnil;
1685 1692
1686 if (MARKERP (readcharfun)) 1693 if (MARKERP (readcharfun))
1687 { 1694 {
@@ -1696,7 +1703,7 @@ readevalloop (Lisp_Object readcharfun,
1696 1703
1697 /* We assume START is nil when input is not from a buffer. */ 1704 /* We assume START is nil when input is not from a buffer. */
1698 if (! NILP (start) && !b) 1705 if (! NILP (start) && !b)
1699 abort (); 1706 emacs_abort ();
1700 1707
1701 specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */ 1708 specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */
1702 specbind (Qcurrent_load_list, Qnil); 1709 specbind (Qcurrent_load_list, Qnil);
@@ -1726,7 +1733,7 @@ readevalloop (Lisp_Object readcharfun,
1726 { 1733 {
1727 ptrdiff_t count1 = SPECPDL_INDEX (); 1734 ptrdiff_t count1 = SPECPDL_INDEX ();
1728 1735
1729 if (b != 0 && NILP (BVAR (b, name))) 1736 if (b != 0 && !BUFFER_LIVE_P (b))
1730 error ("Reading from killed buffer"); 1737 error ("Reading from killed buffer");
1731 1738
1732 if (!NILP (start)) 1739 if (!NILP (start))
@@ -1811,6 +1818,8 @@ readevalloop (Lisp_Object readcharfun,
1811 unbind_to (count1, Qnil); 1818 unbind_to (count1, Qnil);
1812 1819
1813 /* Now eval what we just read. */ 1820 /* Now eval what we just read. */
1821 if (!NILP (macroexpand))
1822 val = call1 (macroexpand, val);
1814 val = eval_sub (val); 1823 val = eval_sub (val);
1815 1824
1816 if (printflag) 1825 if (printflag)
@@ -3673,7 +3682,7 @@ intern_c_string_1 (const char *str, ptrdiff_t len)
3673 /* Creating a non-pure string from a string literal not 3682 /* Creating a non-pure string from a string literal not
3674 implemented yet. We could just use make_string here and live 3683 implemented yet. We could just use make_string here and live
3675 with the extra copy. */ 3684 with the extra copy. */
3676 abort (); 3685 emacs_abort ();
3677 3686
3678 return Fintern (make_pure_c_string (str, len), obarray); 3687 return Fintern (make_pure_c_string (str, len), obarray);
3679} 3688}
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/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "macros.h" 24#include "macros.h"
25#include "commands.h" 25#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 \
482$(BLD)/alloc.$(O) : \ 482$(BLD)/alloc.$(O) : \
483 $(SRC)/alloc.c \ 483 $(SRC)/alloc.c \
484 $(SRC)/puresize.h \ 484 $(SRC)/puresize.h \
485 $(SRC)/syssignal.h \
486 $(SRC)/w32.h \ 485 $(SRC)/w32.h \
487 $(NT_INC)/unistd.h \ 486 $(NT_INC)/unistd.h \
488 $(GNU_LIB)/verify.h \ 487 $(GNU_LIB)/verify.h \
@@ -1365,6 +1364,7 @@ $(BLD)/sysdep.$(O) : \
1365 $(NT_INC)/sys/stat.h \ 1364 $(NT_INC)/sys/stat.h \
1366 $(NT_INC)/unistd.h \ 1365 $(NT_INC)/unistd.h \
1367 $(GNU_LIB)/allocator.h \ 1366 $(GNU_LIB)/allocator.h \
1367 $(GNU_LIB)/execinfo.h \
1368 $(GNU_LIB)/ignore-value.h \ 1368 $(GNU_LIB)/ignore-value.h \
1369 $(GNU_LIB)/utimens.h \ 1369 $(GNU_LIB)/utimens.h \
1370 $(BLOCKINPUT_H) \ 1370 $(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/>. */
18 18
19 19
20#include <config.h> 20#include <config.h>
21#include <setjmp.h> 21
22#include "lisp.h" 22#include "lisp.h"
23#include "character.h" 23#include "character.h"
24#include "buffer.h" 24#include "buffer.h"
@@ -59,7 +59,7 @@ byte_char_debug_check (struct buffer *b, ptrdiff_t charpos, ptrdiff_t bytepos)
59 bytepos - BUF_BEG_BYTE (b)); 59 bytepos - BUF_BEG_BYTE (b));
60 60
61 if (charpos - 1 != nchars) 61 if (charpos - 1 != nchars)
62 abort (); 62 emacs_abort ();
63} 63}
64 64
65#else /* not MARKER_DEBUG */ 65#else /* not MARKER_DEBUG */
@@ -67,7 +67,7 @@ byte_char_debug_check (struct buffer *b, ptrdiff_t charpos, ptrdiff_t bytepos)
67#define byte_char_debug_check(b, charpos, bytepos) do { } while (0) 67#define byte_char_debug_check(b, charpos, bytepos) do { } while (0)
68 68
69#endif /* MARKER_DEBUG */ 69#endif /* MARKER_DEBUG */
70 70
71void 71void
72clear_charpos_cache (struct buffer *b) 72clear_charpos_cache (struct buffer *b)
73{ 73{
@@ -142,7 +142,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
142 ptrdiff_t best_below, best_below_byte; 142 ptrdiff_t best_below, best_below_byte;
143 143
144 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) 144 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b))
145 abort (); 145 emacs_abort ();
146 146
147 best_above = BUF_Z (b); 147 best_above = BUF_Z (b);
148 best_above_byte = BUF_Z_BYTE (b); 148 best_above_byte = BUF_Z_BYTE (b);
@@ -296,7 +296,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
296 ptrdiff_t best_below, best_below_byte; 296 ptrdiff_t best_below, best_below_byte;
297 297
298 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) 298 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b))
299 abort (); 299 emacs_abort ();
300 300
301 best_above = BUF_Z (b); 301 best_above = BUF_Z (b);
302 best_above_byte = BUF_Z_BYTE (b); 302 best_above_byte = BUF_Z_BYTE (b);
@@ -407,7 +407,7 @@ Returns nil if MARKER points into a dead buffer. */)
407 does not preserve the buffer from being GC'd (it's weak), so 407 does not preserve the buffer from being GC'd (it's weak), so
408 markers have to be unlinked from their buffer as soon as the buffer 408 markers have to be unlinked from their buffer as soon as the buffer
409 is killed. */ 409 is killed. */
410 eassert (!NILP (BVAR (XBUFFER (buf), name))); 410 eassert (BUFFER_LIVE_P (XBUFFER (buf)));
411 return buf; 411 return buf;
412 } 412 }
413 return Qnil; 413 return Qnil;
@@ -462,13 +462,13 @@ live_buffer (Lisp_Object buffer)
462 if (NILP (buffer)) 462 if (NILP (buffer))
463 { 463 {
464 b = current_buffer; 464 b = current_buffer;
465 eassert (!NILP (BVAR (b, name))); 465 eassert (BUFFER_LIVE_P (b));
466 } 466 }
467 else 467 else
468 { 468 {
469 CHECK_BUFFER (buffer); 469 CHECK_BUFFER (buffer);
470 b = XBUFFER (buffer); 470 b = XBUFFER (buffer);
471 if (NILP (BVAR (b, name))) 471 if (!BUFFER_LIVE_P (b))
472 b = NULL; 472 b = NULL;
473 } 473 }
474 return b; 474 return b;
@@ -506,7 +506,7 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position,
506 else 506 else
507 { 507 {
508 register ptrdiff_t charpos, bytepos; 508 register ptrdiff_t charpos, bytepos;
509 509
510 CHECK_NUMBER_COERCE_MARKER (position); 510 CHECK_NUMBER_COERCE_MARKER (position);
511 charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), 511 charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b),
512 XINT (position), 512 XINT (position),
@@ -570,8 +570,8 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer,
570 570
571 if (b) 571 if (b)
572 { 572 {
573 attach_marker 573 attach_marker
574 (m, b, 574 (m, b,
575 clip_to_bounds (BUF_BEGV (b), charpos, BUF_ZV (b)), 575 clip_to_bounds (BUF_BEGV (b), charpos, BUF_ZV (b)),
576 clip_to_bounds (BUF_BEGV_BYTE (b), bytepos, BUF_ZV_BYTE (b))); 576 clip_to_bounds (BUF_BEGV_BYTE (b), bytepos, BUF_ZV_BYTE (b)));
577 } 577 }
@@ -595,7 +595,7 @@ unchain_marker (register struct Lisp_Marker *marker)
595 register struct Lisp_Marker *tail, **prev; 595 register struct Lisp_Marker *tail, **prev;
596 596
597 /* No dead buffers here. */ 597 /* No dead buffers here. */
598 eassert (!NILP (BVAR (b, name))); 598 eassert (BUFFER_LIVE_P (b));
599 599
600 marker->buffer = NULL; 600 marker->buffer = NULL;
601 prev = &BUF_MARKERS (b); 601 prev = &BUF_MARKERS (b);
@@ -605,12 +605,12 @@ unchain_marker (register struct Lisp_Marker *marker)
605 { 605 {
606 if (*prev == BUF_MARKERS (b)) 606 if (*prev == BUF_MARKERS (b))
607 { 607 {
608 /* Deleting first marker from the buffer's chain. Crash 608 /* Deleting first marker from the buffer's chain. Crash
609 if new first marker in chain does not say it belongs 609 if new first marker in chain does not say it belongs
610 to the same buffer, or at least that they have the same 610 to the same buffer, or at least that they have the same
611 base buffer. */ 611 base buffer. */
612 if (tail->next && b->text != tail->next->buffer->text) 612 if (tail->next && b->text != tail->next->buffer->text)
613 abort (); 613 emacs_abort ();
614 } 614 }
615 *prev = tail->next; 615 *prev = tail->next;
616 /* We have removed the marker from the chain; 616 /* 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/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24#include <limits.h> /* for INT_MAX */ 23#include <limits.h> /* for INT_MAX */
25 24
26#include "lisp.h" 25#include "lisp.h"
@@ -737,7 +736,7 @@ digest_single_submenu (int start, int end, int top_level_items)
737 736
738 /* All items should be contained in panes. */ 737 /* All items should be contained in panes. */
739 if (panes_seen == 0) 738 if (panes_seen == 0)
740 abort (); 739 emacs_abort ();
741 740
742 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 741 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
743 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 742 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
@@ -811,7 +810,7 @@ digest_single_submenu (int start, int end, int top_level_items)
811 else if (EQ (type, QCtoggle)) 810 else if (EQ (type, QCtoggle))
812 wv->button_type = BUTTON_TYPE_TOGGLE; 811 wv->button_type = BUTTON_TYPE_TOGGLE;
813 else 812 else
814 abort (); 813 emacs_abort ();
815 814
816 wv->selected = !NILP (selected); 815 wv->selected = !NILP (selected);
817 if (! STRINGP (help)) 816 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/>. */
21#include <config.h> 21#include <config.h>
22#include <errno.h> 22#include <errno.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "commands.h" 26#include "commands.h"
@@ -110,7 +109,7 @@ choose_minibuf_frame (void)
110 /* I don't think that any frames may validly have a null minibuffer 109 /* I don't think that any frames may validly have a null minibuffer
111 window anymore. */ 110 window anymore. */
112 if (NILP (sf->minibuffer_window)) 111 if (NILP (sf->minibuffer_window))
113 abort (); 112 emacs_abort ();
114 113
115 /* Under X, we come here with minibuf_window being the 114 /* Under X, we come here with minibuf_window being the
116 minibuffer window of the unused termcap window created in 115 minibuffer window of the unused termcap window created in
@@ -798,7 +797,7 @@ get_minibuffer (EMACS_INT depth)
798 Vminibuffer_list = nconc2 (Vminibuffer_list, tail); 797 Vminibuffer_list = nconc2 (Vminibuffer_list, tail);
799 } 798 }
800 buf = Fcar (tail); 799 buf = Fcar (tail);
801 if (NILP (buf) || NILP (BVAR (XBUFFER (buf), name))) 800 if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf)))
802 { 801 {
803 buf = Fget_buffer_create 802 buf = Fget_buffer_create
804 (make_formatted_string (name, " *Minibuf-%"pI"d*", depth)); 803 (make_formatted_string (name, " *Minibuf-%"pI"d*", depth));
@@ -1860,7 +1859,6 @@ the values STRING, PREDICATE and `lambda'. */)
1860} 1859}
1861 1860
1862static Lisp_Object Qmetadata; 1861static Lisp_Object Qmetadata;
1863extern Lisp_Object Qbuffer;
1864 1862
1865DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0, 1863DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0,
1866 doc: /* Perform completion on buffer names. 1864 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)
796 /* The default face for the frame should always be realized and 796 /* The default face for the frame should always be realized and
797 cached. */ 797 cached. */
798 if (!fp) 798 if (!fp)
799 abort (); 799 emacs_abort ();
800 } 800 }
801 screen_face = face; 801 screen_face = face;
802 fg = fp->foreground; 802 fg = fp->foreground;
@@ -1029,7 +1029,6 @@ IT_clear_end_of_line (struct frame *f, int first_unused)
1029{ 1029{
1030 char *spaces, *sp; 1030 char *spaces, *sp;
1031 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 1031 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
1032 extern int fatal_error_in_progress;
1033 struct tty_display_info *tty = FRAME_TTY (f); 1032 struct tty_display_info *tty = FRAME_TTY (f);
1034 1033
1035 if (new_pos_X >= first_unused || fatal_error_in_progress) 1034 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)
1394static void 1393static void
1395IT_delete_glyphs (struct frame *f, int n) 1394IT_delete_glyphs (struct frame *f, int n)
1396{ 1395{
1397 abort (); 1396 emacs_abort ();
1398} 1397}
1399 1398
1400/* set-window-configuration on window.c needs this. */ 1399/* set-window-configuration on window.c needs this. */
@@ -3014,7 +3013,7 @@ XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable)
3014 const char *p; 3013 const char *p;
3015 3014
3016 if (!enable) 3015 if (!enable)
3017 abort (); 3016 emacs_abort ();
3018 3017
3019 IT_menu_make_room (menu); 3018 IT_menu_make_room (menu);
3020 menu->submenu[menu->count] = IT_menu_create (); 3019 menu->submenu[menu->count] = IT_menu_create ();
@@ -4120,7 +4119,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4120 FD_ZERO (efds); 4119 FD_ZERO (efds);
4121 4120
4122 if (nfds != 1) 4121 if (nfds != 1)
4123 abort (); 4122 emacs_abort ();
4124 4123
4125 /* If we are looking only for the terminal, with no timeout, 4124 /* If we are looking only for the terminal, with no timeout,
4126 just read it and wait -- that's more efficient. */ 4125 just read it and wait -- that's more efficient. */
@@ -4215,26 +4214,8 @@ init_gettimeofday (void)
4215} 4214}
4216#endif 4215#endif
4217 4216
4218#ifdef abort
4219#undef abort
4220void 4217void
4221dos_abort (char *file, int line) 4218emacs_abort (void)
4222{
4223 char buffer1[200], buffer2[400];
4224 int i, j;
4225
4226 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line);
4227 for (i = j = 0; buffer1[i]; i++) {
4228 buffer2[j++] = buffer1[i];
4229 buffer2[j++] = 0x70;
4230 }
4231 dosmemput (buffer2, j, (int)ScreenPrimary);
4232 ScreenSetCursor (2, 0);
4233 abort ();
4234}
4235#else
4236void
4237abort (void)
4238{ 4219{
4239 dos_ttcooked (); 4220 dos_ttcooked ();
4240 ScreenSetCursor (10, 0); 4221 ScreenSetCursor (10, 0);
@@ -4250,7 +4231,6 @@ abort (void)
4250#endif /* __DJGPP_MINOR__ >= 2 */ 4231#endif /* __DJGPP_MINOR__ >= 2 */
4251 exit (2); 4232 exit (2);
4252} 4233}
4253#endif
4254 4234
4255void 4235void
4256syms_of_msdos (void) 4236syms_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 @@
1### autodeps.mk --- src/Makefile fragment for GNU Emacs
2
3## Copyright (C) 2008-2012 Free Software Foundation, Inc.
4
5## This file is part of GNU Emacs.
6
7## GNU Emacs is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (at your option) any later version.
11##
12## GNU Emacs is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20### Commentary:
21
22## This is inserted in src/Makefile if HAVE_NS.
23
24## The only reason this is in a separate file is because $ns_appdir,
25## which appears as a target, is empty on non-NS builds. Some makes
26## do not like empty targets, even if they are never used.
27
28${ns_appdir}: ${ns_appsrc}
29 rm -fr ${ns_appdir}
30 ${MKDIR_P} ${ns_appdir}
31 ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - )
32
33${ns_appbindir}/Emacs: emacs${EXEEXT}
34 ${MKDIR_P} ${ns_appbindir}
35 cp -f emacs${EXEEXT} ${ns_appbindir}/Emacs
36
37ns-app: ${ns_appdir} ${ns_appbindir}/Emacs
38
39### 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)
30 interpretation of even the system includes. */ 30 interpretation of even the system includes. */
31#include <config.h> 31#include <config.h>
32 32
33#include <signal.h>
34#include <math.h> 33#include <math.h>
35#include <setjmp.h>
36#include <c-strcase.h> 34#include <c-strcase.h>
37 35
38#include "lisp.h" 36#include "lisp.h"
@@ -1798,19 +1796,6 @@ terminate Emacs if we can't open the connection.
1798 SSDATA (display)); 1796 SSDATA (display));
1799 } 1797 }
1800 1798
1801 /* Register our external input/output types, used for determining
1802 applicable services and also drag/drop eligibility. */
1803 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
1804 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
1805 retain];
1806 ns_drag_types = [[NSArray arrayWithObjects:
1807 NSStringPboardType,
1808 NSTabularTextPboardType,
1809 NSFilenamesPboardType,
1810 NSURLPboardType,
1811 NSColorPboardType,
1812 NSFontPboardType, nil] retain];
1813
1814 return Qnil; 1799 return Qnil;
1815} 1800}
1816 1801
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)
23/* This should be the first include, as it may set up #defines affecting 23/* This should be the first include, as it may set up #defines affecting
24 interpretation of even the system includes. */ 24 interpretation of even the system includes. */
25#include <config.h> 25#include <config.h>
26#include <setjmp.h>
27 26
28#include "lisp.h" 27#include "lisp.h"
29#include "dispextern.h" 28#include "dispextern.h"
@@ -625,7 +624,7 @@ static unsigned int nsfont_encode_char (struct font *font, int c);
625static int nsfont_text_extents (struct font *font, unsigned int *code, 624static int nsfont_text_extents (struct font *font, unsigned int *code,
626 int nglyphs, struct font_metrics *metrics); 625 int nglyphs, struct font_metrics *metrics);
627static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, 626static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
628 int with_background); 627 bool with_background);
629 628
630struct font_driver nsfont_driver = 629struct font_driver nsfont_driver =
631 { 630 {
@@ -833,7 +832,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
833 font = (struct font *) font_info; 832 font = (struct font *) font_info;
834 font->pixel_size = [sfont pointSize]; 833 font->pixel_size = [sfont pointSize];
835 font->driver = &nsfont_driver; 834 font->driver = &nsfont_driver;
836 font->encoding_type = FONT_ENCODING_NOT_DECIDED;
837 font->encoding_charset = -1; 835 font->encoding_charset = -1;
838 font->repertory_charset = -1; 836 font->repertory_charset = -1;
839 font->default_ascent = 0; 837 font->default_ascent = 0;
@@ -1042,12 +1040,12 @@ nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
1042 1040
1043 1041
1044/* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel 1042/* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
1045 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND 1043 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
1046 is nonzero, fill the background in advance. It is assured that 1044 fill the background in advance. It is assured that WITH_BACKGROUND
1047 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ 1045 is false when (FROM > 0 || TO < S->nchars). */
1048static int 1046static int
1049nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, 1047nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1050 int with_background) 1048 bool with_background)
1051/* NOTE: focus and clip must be set 1049/* NOTE: focus and clip must be set
1052 also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ 1050 also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
1053{ 1051{
@@ -1330,7 +1328,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
1330 1328
1331 font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); 1329 font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short));
1332 if (!unichars || !(font_info->glyphs[block])) 1330 if (!unichars || !(font_info->glyphs[block]))
1333 abort (); 1331 emacs_abort ();
1334 1332
1335 /* create a string containing all Unicode characters in this block */ 1333 /* create a string containing all Unicode characters in this block */
1336 for (idx = block<<8, i = 0; i < 0x100; idx++, i++) 1334 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)
1405 1403
1406 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); 1404 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics));
1407 if (!(font_info->metrics[block])) 1405 if (!(font_info->metrics[block]))
1408 abort (); 1406 emacs_abort ();
1409 1407
1410 metrics = font_info->metrics[block]; 1408 metrics = font_info->metrics[block];
1411 for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) 1409 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)
28/* This should be the first include, as it may set up #defines affecting 28/* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */ 29 interpretation of even the system includes. */
30#include <config.h> 30#include <config.h>
31#include <setjmp.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34#include "dispextern.h" 33#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. */
24/* This should be the first include, as it may set up #defines affecting 24/* This should be the first include, as it may set up #defines affecting
25 interpretation of even the system includes. */ 25 interpretation of even the system includes. */
26#include <config.h> 26#include <config.h>
27#include <setjmp.h>
28 27
29#include "lisp.h" 28#include "lisp.h"
30#include "window.h" 29#include "window.h"
@@ -589,10 +588,7 @@ extern NSString *NSMenuDidBeginTrackingNotification;
589 From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the 588 From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the
590 key press case, NSMenuPropertyItemImage (e.g.) won't be set. 589 key press case, NSMenuPropertyItemImage (e.g.) won't be set.
591 */ 590 */
592 if (trackingMenu == 0 591 if (trackingMenu == 0)
593 /* Also, don't try this if from an event picked up asynchronously,
594 as lots of lisp evaluation happens in ns_update_menubar. */
595 || handling_signal != 0)
596 return; 592 return;
597/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ 593/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
598 ns_update_menubar (frame, 1, self); 594 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,
948 else if (EQ (type, QCradio)) 944 else if (EQ (type, QCradio))
949 wv->button_type = BUTTON_TYPE_RADIO; 945 wv->button_type = BUTTON_TYPE_RADIO;
950 else 946 else
951 abort (); 947 emacs_abort ();
952 948
953 wv->selected = !NILP (selected); 949 wv->selected = !NILP (selected);
954 950
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)
28/* This should be the first include, as it may set up #defines affecting 28/* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */ 29 interpretation of even the system includes. */
30#include <config.h> 30#include <config.h>
31#include <setjmp.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34#include "nsterm.h" 33#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/>. */
103- (void) setWindowClosing: (BOOL)closing; 103- (void) setWindowClosing: (BOOL)closing;
104- (EmacsToolbar *) toolbar; 104- (EmacsToolbar *) toolbar;
105- (void) deleteWorkingText; 105- (void) deleteWorkingText;
106- (void) updateFrameSize: (BOOL) delay;
106 107
107#ifdef NS_IMPL_GNUSTEP 108#ifdef NS_IMPL_GNUSTEP
108/* Not declared, but useful. */ 109/* 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)
35#include <time.h> 35#include <time.h>
36#include <signal.h> 36#include <signal.h>
37#include <unistd.h> 37#include <unistd.h>
38#include <setjmp.h>
39 38
40#include <c-ctype.h> 39#include <c-ctype.h>
41#include <c-strcase.h> 40#include <c-strcase.h>
@@ -627,6 +626,8 @@ ns_update_begin (struct frame *f)
627 -------------------------------------------------------------------------- */ 626 -------------------------------------------------------------------------- */
628{ 627{
629 NSView *view = FRAME_NS_VIEW (f); 628 NSView *view = FRAME_NS_VIEW (f);
629 NSRect r = [view frame];
630 NSBezierPath *bp;
630 NSTRACE (ns_update_begin); 631 NSTRACE (ns_update_begin);
631 632
632 ns_update_auto_hide_menu_bar (); 633 ns_update_auto_hide_menu_bar ();
@@ -634,6 +635,14 @@ ns_update_begin (struct frame *f)
634 ns_updating_frame = f; 635 ns_updating_frame = f;
635 [view lockFocus]; 636 [view lockFocus];
636 637
638 /* drawRect may have been called for say the minibuffer, and then clip path
639 is for the minibuffer. But the display engine may draw more because
640 we have set the frame as garbaged. So reset clip path to the whole
641 view. */
642 bp = [[NSBezierPath bezierPathWithRect: r] retain];
643 [bp setClip];
644 [bp release];
645
637#ifdef NS_IMPL_GNUSTEP 646#ifdef NS_IMPL_GNUSTEP
638 uRect = NSMakeRect (0, 0, 0, 0); 647 uRect = NSMakeRect (0, 0, 0, 0);
639#endif 648#endif
@@ -650,7 +659,6 @@ ns_update_window_begin (struct window *w)
650 struct frame *f = XFRAME (WINDOW_FRAME (w)); 659 struct frame *f = XFRAME (WINDOW_FRAME (w));
651 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 660 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
652 NSTRACE (ns_update_window_begin); 661 NSTRACE (ns_update_window_begin);
653
654 updated_window = w; 662 updated_window = w;
655 set_output_cursor (&w->cursor); 663 set_output_cursor (&w->cursor);
656 664
@@ -871,25 +879,12 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, int area, BOOL gc)
871 879
872 window_box (w, area, &window_x, &window_y, &window_width, 0); 880 window_box (w, area, &window_x, &window_y, &window_width, 0);
873 881
874 clip_rect.origin.x = window_x - FRAME_INTERNAL_BORDER_WIDTH (f); 882 clip_rect.origin.x = window_x;
875 clip_rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y)); 883 clip_rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y));
876 clip_rect.origin.y = max (clip_rect.origin.y, window_y); 884 clip_rect.origin.y = max (clip_rect.origin.y, window_y);
877 clip_rect.size.width = window_width + 2 * FRAME_INTERNAL_BORDER_WIDTH (f); 885 clip_rect.size.width = window_width;
878 clip_rect.size.height = row->visible_height; 886 clip_rect.size.height = row->visible_height;
879 887
880 /* allow a full-height row at the top when requested
881 (used to draw fringe all the way through internal border area) */
882 if (gc && clip_rect.origin.y < 5)
883 {
884 clip_rect.origin.y -= FRAME_INTERNAL_BORDER_WIDTH (f);
885 clip_rect.size.height += FRAME_INTERNAL_BORDER_WIDTH (f);
886 }
887
888 /* likewise at bottom */
889 if (gc &&
890 FRAME_PIXEL_HEIGHT (f) - (clip_rect.origin.y + clip_rect.size.height) < 5)
891 clip_rect.size.height += FRAME_INTERNAL_BORDER_WIDTH (f);
892
893 ns_focus (f, &clip_rect, 1); 888 ns_focus (f, &clip_rect, 1);
894} 889}
895 890
@@ -1237,18 +1232,10 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1237 NSRect wr = [window frame]; 1232 NSRect wr = [window frame];
1238 int tb = FRAME_EXTERNAL_TOOL_BAR (f); 1233 int tb = FRAME_EXTERNAL_TOOL_BAR (f);
1239 int pixelwidth, pixelheight; 1234 int pixelwidth, pixelheight;
1240 static int oldRows, oldCols, oldFontWidth, oldFontHeight;
1241 static int oldTB;
1242 static struct frame *oldF;
1243 1235
1244 NSTRACE (x_set_window_size); 1236 NSTRACE (x_set_window_size);
1245 1237
1246 if (view == nil || 1238 if (view == nil)
1247 (f == oldF
1248 && rows == oldRows && cols == oldCols
1249 && oldFontWidth == FRAME_COLUMN_WIDTH (f)
1250 && oldFontHeight == FRAME_LINE_HEIGHT (f)
1251 && oldTB == tb))
1252 return; 1239 return;
1253 1240
1254/*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */ 1241/*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)
1256 BLOCK_INPUT; 1243 BLOCK_INPUT;
1257 1244
1258 check_frame_size (f, &rows, &cols); 1245 check_frame_size (f, &rows, &cols);
1259 oldF = f;
1260 oldRows = rows;
1261 oldCols = cols;
1262 oldFontWidth = FRAME_COLUMN_WIDTH (f);
1263 oldFontHeight = FRAME_LINE_HEIGHT (f);
1264 oldTB = tb;
1265 1246
1266 f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); 1247 f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
1267 compute_fringe_widths (f, 0); 1248 compute_fringe_widths (f, 0);
@@ -1939,7 +1920,7 @@ ns_redraw_scroll_bars (struct frame *f)
1939 int i; 1920 int i;
1940 id view; 1921 id view;
1941 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; 1922 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews];
1942 NSTRACE (ns_judge_scroll_bars); 1923 NSTRACE (ns_redraw_scroll_bars);
1943 for (i =[subviews count]-1; i >= 0; i--) 1924 for (i =[subviews count]-1; i >= 0; i--)
1944 { 1925 {
1945 view = [subviews objectAtIndex: i]; 1926 view = [subviews objectAtIndex: i];
@@ -2125,9 +2106,9 @@ ns_after_update_window_line (struct glyph_row *desired_row)
2125 desired_row->redraw_fringe_bitmaps_p = 1; 2106 desired_row->redraw_fringe_bitmaps_p = 1;
2126 2107
2127 /* When a window has disappeared, make sure that no rest of 2108 /* When a window has disappeared, make sure that no rest of
2128 full-width rows stays visible in the internal border. 2109 full-width rows stays visible in the internal border. */
2129 Under NS this is drawn inside the fringes. */
2130 if (windows_or_buffers_changed 2110 if (windows_or_buffers_changed
2111 && desired_row->full_width_p
2131 && (f = XFRAME (w->frame), 2112 && (f = XFRAME (w->frame),
2132 width = FRAME_INTERNAL_BORDER_WIDTH (f), 2113 width = FRAME_INTERNAL_BORDER_WIDTH (f),
2133 width != 0) 2114 width != 0)
@@ -2136,24 +2117,11 @@ ns_after_update_window_line (struct glyph_row *desired_row)
2136 { 2117 {
2137 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 2118 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
2138 2119
2139 /* Internal border is drawn below the tool bar. */
2140 if (WINDOWP (f->tool_bar_window)
2141 && w == XWINDOW (f->tool_bar_window))
2142 y -= width;
2143 /* end copy from other terms */
2144
2145 BLOCK_INPUT; 2120 BLOCK_INPUT;
2146 if (!desired_row->full_width_p) 2121 ns_clear_frame_area (f, 0, y, width, height);
2147 { 2122 ns_clear_frame_area (f,
2148 int x1 = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w) 2123 FRAME_PIXEL_WIDTH (f) - width,
2149 + WINDOW_LEFT_FRINGE_WIDTH (w); 2124 y, width, height);
2150 int x2 = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w)
2151 + FRAME_PIXEL_WIDTH (f) - NS_SCROLL_BAR_WIDTH (f)
2152 - WINDOW_RIGHT_FRINGE_WIDTH (w)
2153 - FRAME_INTERNAL_BORDER_WIDTH (f);
2154 ns_clear_frame_area (f, x1, y, width, height);
2155 ns_clear_frame_area (f, x2, y, width, height);
2156 }
2157 UNBLOCK_INPUT; 2125 UNBLOCK_INPUT;
2158 } 2126 }
2159} 2127}
@@ -2238,17 +2206,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2238 int rowY; 2206 int rowY;
2239 static EmacsImage **bimgs = NULL; 2207 static EmacsImage **bimgs = NULL;
2240 static int nBimgs = 0; 2208 static int nBimgs = 0;
2241 /* NS-specific: move internal border inside fringe */
2242 int x = p->bx < 0 ? p->x : p->bx;
2243 int wd = p->bx < 0 ? p->wd : p->nx;
2244 BOOL fringeOnVeryLeft
2245 = x - WINDOW_LEFT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)
2246 - FRAME_INTERNAL_BORDER_WIDTH (f) < 10;
2247 BOOL fringeOnVeryRight
2248 = FRAME_PIXEL_WIDTH (f) - x - wd - FRAME_INTERNAL_BORDER_WIDTH (f)
2249 - WINDOW_RIGHT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w) < 10;
2250 int xAdjust = FRAME_INTERNAL_BORDER_WIDTH (f) *
2251 (fringeOnVeryLeft ? -1 : (fringeOnVeryRight ? 1 : 0));
2252 2209
2253 /* grow bimgs if needed */ 2210 /* grow bimgs if needed */
2254 if (nBimgs < max_used_fringe_bitmap) 2211 if (nBimgs < max_used_fringe_bitmap)
@@ -2263,22 +2220,68 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2263 rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 2220 rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
2264 ns_clip_to_row (w, row, -1, YES); 2221 ns_clip_to_row (w, row, -1, YES);
2265 2222
2266 if (p->bx >= 0 && !p->overlay_p) 2223 if (!p->overlay_p)
2267 { 2224 {
2268 int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ? 2225 int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny;
2269 -FRAME_INTERNAL_BORDER_WIDTH (f) : 0; 2226
2270 int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ? 2227 /* If the fringe is adjacent to the left (right) scroll bar of a
2271 FRAME_INTERNAL_BORDER_WIDTH (f) : 0 2228 leftmost (rightmost, respectively) window, then extend its
2272 + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0); 2229 background to the gap between the fringe and the bar. */
2273 NSRect r = NSMakeRect (p->bx+xAdjust, p->by+yAdjust, p->nx, p->ny+yIncr); 2230 if ((WINDOW_LEFTMOST_P (w)
2274 NSRectClip (r); 2231 && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
2275 [ns_lookup_indexed_color(face->background, f) set]; 2232 || (WINDOW_RIGHTMOST_P (w)
2276 NSRectFill (r); 2233 && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)))
2234 {
2235 int sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
2236
2237 if (sb_width > 0)
2238 {
2239 int bar_area_x = WINDOW_SCROLL_BAR_AREA_X (w);
2240 int bar_area_width = (WINDOW_CONFIG_SCROLL_BAR_COLS (w)
2241 * FRAME_COLUMN_WIDTH (f));
2242
2243 if (bx < 0)
2244 {
2245 /* Bitmap fills the fringe. */
2246 if (bar_area_x + bar_area_width == p->x)
2247 bx = bar_area_x + sb_width;
2248 else if (p->x + p->wd == bar_area_x)
2249 bx = bar_area_x;
2250 if (bx >= 0)
2251 {
2252 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
2253
2254 nx = bar_area_width - sb_width;
2255 by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
2256 row->y));
2257 ny = row->visible_height;
2258 }
2259 }
2260 else
2261 {
2262 if (bar_area_x + bar_area_width == bx)
2263 {
2264 bx = bar_area_x + sb_width;
2265 nx += bar_area_width - sb_width;
2266 }
2267 else if (bx + nx == bar_area_x)
2268 nx += bar_area_width - sb_width;
2269 }
2270 }
2271 }
2272
2273 if (bx >= 0 && nx > 0)
2274 {
2275 NSRect r = NSMakeRect (bx, by, nx, ny);
2276 NSRectClip (r);
2277 [ns_lookup_indexed_color (face->background, f) set];
2278 NSRectFill (r);
2279 }
2277 } 2280 }
2278 2281
2279 if (p->which) 2282 if (p->which)
2280 { 2283 {
2281 NSRect r = NSMakeRect (p->x+xAdjust, p->y, p->wd, p->h); 2284 NSRect r = NSMakeRect (p->x, p->y, p->wd, p->h);
2282 EmacsImage *img = bimgs[p->which - 1]; 2285 EmacsImage *img = bimgs[p->which - 1];
2283 2286
2284 if (!img) 2287 if (!img)
@@ -2288,7 +2291,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2288 int i; 2291 int i;
2289 unsigned char *cbits = xmalloc (len); 2292 unsigned char *cbits = xmalloc (len);
2290 2293
2291 for (i =0; i<len; i++) 2294 for (i = 0; i < len; i++)
2292 cbits[i] = ~(bits[i] & 0xff); 2295 cbits[i] = ~(bits[i] & 0xff);
2293 img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h 2296 img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h
2294 flip: NO]; 2297 flip: NO];
@@ -2302,12 +2305,20 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2302 [ns_lookup_indexed_color(face->background, f) set]; 2305 [ns_lookup_indexed_color(face->background, f) set];
2303 NSRectFill (r); 2306 NSRectFill (r);
2304 [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)]; 2307 [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)];
2308#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
2305 [img drawInRect: r 2309 [img drawInRect: r
2306 fromRect: NSZeroRect 2310 fromRect: NSZeroRect
2307 operation: NSCompositeSourceOver 2311 operation: NSCompositeSourceOver
2308 fraction: 1.0 2312 fraction: 1.0
2309 respectFlipped: YES 2313 respectFlipped: YES
2310 hints: nil]; 2314 hints: nil];
2315#else
2316 {
2317 NSPoint pt = r.origin;
2318 pt.y += p->h;
2319 [img compositeToPoint: pt operation: NSCompositeSourceOver];
2320 }
2321#endif
2311 } 2322 }
2312 ns_unfocus (f); 2323 ns_unfocus (f);
2313} 2324}
@@ -2386,14 +2397,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2386 r.size.height = h; 2397 r.size.height = h;
2387 r.size.width = w->phys_cursor_width; 2398 r.size.width = w->phys_cursor_width;
2388 2399
2389 /* FIXME: if we overwrite the internal border area, it does not get erased;
2390 fix by truncating cursor, but better would be to erase properly */
2391 overspill = r.origin.x + r.size.width -
2392 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w)
2393 - WINDOW_TOTAL_FRINGE_WIDTH (w) - FRAME_INTERNAL_BORDER_WIDTH (f));
2394 if (overspill > 0)
2395 r.size.width -= overspill;
2396
2397 /* TODO: only needed in rare cases with last-resort font in HELLO.. 2400 /* TODO: only needed in rare cases with last-resort font in HELLO..
2398 should we do this more efficiently? */ 2401 should we do this more efficiently? */
2399 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */ 2402 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
@@ -2517,31 +2520,6 @@ hide_hourglass (void)
2517 2520
2518 ========================================================================== */ 2521 ========================================================================== */
2519 2522
2520
2521static inline NSRect
2522ns_fix_rect_ibw (NSRect r, int fibw, int frame_pixel_width)
2523/* --------------------------------------------------------------------------
2524 Under NS we draw internal borders inside fringes, and want full-width
2525 rendering to go all the way to edge. This function makes that correction.
2526 -------------------------------------------------------------------------- */
2527{
2528 if (r.origin.y <= fibw+1)
2529 {
2530 r.size.height += r.origin.y;
2531 r.origin.y = 0;
2532 }
2533 if (r.origin.x <= fibw+1)
2534 {
2535 r.size.width += r.origin.x;
2536 r.origin.x = 0;
2537 }
2538 if (frame_pixel_width - (r.origin.x+r.size.width) <= fibw+1)
2539 r.size.width += fibw;
2540
2541 return r;
2542}
2543
2544
2545static int 2523static int
2546ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) 2524ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2547/* -------------------------------------------------------------------------- 2525/* --------------------------------------------------------------------------
@@ -2551,14 +2529,6 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2551 -------------------------------------------------------------------------- */ 2529 -------------------------------------------------------------------------- */
2552{ 2530{
2553 int n = get_glyph_string_clip_rects (s, nr, 2); 2531 int n = get_glyph_string_clip_rects (s, nr, 2);
2554 if (s->row->full_width_p)
2555 {
2556 *nr = ns_fix_rect_ibw (*nr, FRAME_INTERNAL_BORDER_WIDTH (s->f),
2557 FRAME_PIXEL_WIDTH (s->f));
2558 if (n == 2)
2559 *nr = ns_fix_rect_ibw (*(nr+1), FRAME_INTERNAL_BORDER_WIDTH (s->f),
2560 FRAME_PIXEL_WIDTH (s->f));
2561 }
2562 return n; 2532 return n;
2563} 2533}
2564 2534
@@ -2883,11 +2853,6 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
2883 2853
2884 r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height); 2854 r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height);
2885 2855
2886 /* expand full-width row over internal borders */
2887 if (s->row->full_width_p)
2888 r = ns_fix_rect_ibw (r, FRAME_INTERNAL_BORDER_WIDTH (s->f),
2889 FRAME_PIXEL_WIDTH (s->f));
2890
2891 /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */ 2856 /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */
2892 if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color) 2857 if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
2893 { 2858 {
@@ -2943,26 +2908,6 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
2943 NSRect r = NSMakeRect (s->x, s->y + box_line_width, 2908 NSRect r = NSMakeRect (s->x, s->y + box_line_width,
2944 s->background_width, 2909 s->background_width,
2945 s->height-2*box_line_width); 2910 s->height-2*box_line_width);
2946
2947 /* expand full-width row over internal borders */
2948 if (s->row->full_width_p)
2949 {
2950 int fibw = FRAME_INTERNAL_BORDER_WIDTH (s->f);
2951 if (r.origin.y <= fibw+1 + box_line_width)
2952 {
2953 r.size.height += r.origin.y;
2954 r.origin.y = 0;
2955 }
2956 if (r.origin.x <= fibw+1)
2957 {
2958 r.size.width += 2*r.origin.x;
2959 r.origin.x = 0;
2960 }
2961 if (FRAME_PIXEL_WIDTH (s->f) - (r.origin.x + r.size.width)
2962 <= fibw+1)
2963 r.size.width += fibw;
2964 }
2965
2966 NSRectFill (r); 2911 NSRectFill (r);
2967 } 2912 }
2968 2913
@@ -3028,34 +2973,23 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
3028 br = NSMakeRect (x, y, s->slice.width, s->slice.height); 2973 br = NSMakeRect (x, y, s->slice.width, s->slice.height);
3029 } 2974 }
3030 2975
3031 /* expand full-width row over internal borders */
3032 if (s->row->full_width_p)
3033 {
3034 int fibw = FRAME_INTERNAL_BORDER_WIDTH (s->f);
3035 if (br.origin.y <= fibw+1 + box_line_vwidth)
3036 {
3037 br.size.height += br.origin.y;
3038 br.origin.y = 0;
3039 }
3040 if (br.origin.x <= fibw+1 + box_line_vwidth)
3041 {
3042 br.size.width += br.origin.x;
3043 br.origin.x = 0;
3044 }
3045 if (FRAME_PIXEL_WIDTH (s->f) - (br.origin.x + br.size.width) <= fibw+1)
3046 br.size.width += fibw;
3047 }
3048
3049 NSRectFill (br); 2976 NSRectFill (br);
3050 2977
3051 /* Draw the image.. do we need to draw placeholder if img ==nil? */ 2978 /* Draw the image.. do we need to draw placeholder if img ==nil? */
3052 if (img != nil) 2979 if (img != nil)
2980 {
2981#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
3053 [img drawInRect: br 2982 [img drawInRect: br
3054 fromRect: NSZeroRect 2983 fromRect: NSZeroRect
3055 operation: NSCompositeSourceOver 2984 operation: NSCompositeSourceOver
3056 fraction: 1.0 2985 fraction: 1.0
3057 respectFlipped: YES 2986 respectFlipped: YES
3058 hints: nil]; 2987 hints: nil];
2988#else
2989 [img compositeToPoint: NSMakePoint (x, y + s->slice.height)
2990 operation: NSCompositeSourceOver];
2991#endif
2992 }
3059 2993
3060 if (s->hl == DRAW_CURSOR) 2994 if (s->hl == DRAW_CURSOR)
3061 { 2995 {
@@ -3143,7 +3077,7 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3143 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f); 3077 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3144 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); 3078 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3145 3079
3146 for (i=0; i<n; i++) 3080 for (i = 0; i < n; ++i)
3147 { 3081 {
3148 if (!s->row->full_width_p) 3082 if (!s->row->full_width_p)
3149 { 3083 {
@@ -3173,13 +3107,6 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3173 r[i].size.height = min (s->height, s->row->visible_height); 3107 r[i].size.height = min (s->height, s->row->visible_height);
3174 } 3108 }
3175 3109
3176 /* expand full-width rows over internal borders */
3177 else
3178 {
3179 r[i] = ns_fix_rect_ibw (r[i], FRAME_INTERNAL_BORDER_WIDTH (s->f),
3180 FRAME_PIXEL_WIDTH (s->f));
3181 }
3182
3183 [bgCol set]; 3110 [bgCol set];
3184 3111
3185 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid 3112 /* 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)
3340 break; 3267 break;
3341 3268
3342 default: 3269 default:
3343 abort (); 3270 emacs_abort ();
3344 } 3271 }
3345 3272
3346 /* Draw box if not done already. */ 3273 /* Draw box if not done already. */
@@ -3428,16 +3355,12 @@ ns_read_socket (struct terminal *terminal, int expected,
3428 if (interrupt_input_blocked) 3355 if (interrupt_input_blocked)
3429 { 3356 {
3430 interrupt_input_pending = 1; 3357 interrupt_input_pending = 1;
3431#ifdef SYNC_INPUT
3432 pending_signals = 1; 3358 pending_signals = 1;
3433#endif
3434 return -1; 3359 return -1;
3435 } 3360 }
3436 3361
3437 interrupt_input_pending = 0; 3362 interrupt_input_pending = 0;
3438#ifdef SYNC_INPUT
3439 pending_signals = pending_atimers; 3363 pending_signals = pending_atimers;
3440#endif
3441 3364
3442 BLOCK_INPUT; 3365 BLOCK_INPUT;
3443 n_emacs_events_pending = 0; 3366 n_emacs_events_pending = 0;
@@ -3475,7 +3398,7 @@ ns_read_socket (struct terminal *terminal, int expected,
3475 3398
3476 if (++apploopnr != 1) 3399 if (++apploopnr != 1)
3477 { 3400 {
3478 abort (); 3401 emacs_abort ();
3479 } 3402 }
3480 [NSApp run]; 3403 [NSApp run];
3481 --apploopnr; 3404 --apploopnr;
@@ -3515,7 +3438,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3515 [outerpool release]; 3438 [outerpool release];
3516 outerpool = [[NSAutoreleasePool alloc] init]; 3439 outerpool = [[NSAutoreleasePool alloc] init];
3517 3440
3518 3441
3519 send_appdefined = YES; 3442 send_appdefined = YES;
3520 if (nr > 0) 3443 if (nr > 0)
3521 { 3444 {
@@ -3568,7 +3491,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3568 emacs_event = &event; 3491 emacs_event = &event;
3569 if (++apploopnr != 1) 3492 if (++apploopnr != 1)
3570 { 3493 {
3571 abort(); 3494 emacs_abort ();
3572 } 3495 }
3573 [NSApp run]; 3496 [NSApp run];
3574 --apploopnr; 3497 --apploopnr;
@@ -3586,7 +3509,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3586 { 3509 {
3587 int t; 3510 int t;
3588 if ([ev type] != NSApplicationDefined) 3511 if ([ev type] != NSApplicationDefined)
3589 abort (); 3512 emacs_abort ();
3590 3513
3591 t = [ev data1]; 3514 t = [ev data1];
3592 last_appdefined_event = 0; 3515 last_appdefined_event = 0;
@@ -3639,9 +3562,9 @@ ns_set_vertical_scroll_bar (struct window *window,
3639 struct frame *f = XFRAME (WINDOW_FRAME (window)); 3562 struct frame *f = XFRAME (WINDOW_FRAME (window));
3640 EmacsView *view = FRAME_NS_VIEW (f); 3563 EmacsView *view = FRAME_NS_VIEW (f);
3641 int window_y, window_height; 3564 int window_y, window_height;
3642 BOOL barOnVeryLeft, barOnVeryRight;
3643 int top, left, height, width, sb_width, sb_left; 3565 int top, left, height, width, sb_width, sb_left;
3644 EmacsScroller *bar; 3566 EmacsScroller *bar;
3567 BOOL fringe_extended_p;
3645 3568
3646 /* optimization; display engine sends WAY too many of these.. */ 3569 /* optimization; display engine sends WAY too many of these.. */
3647 if (!NILP (window->vertical_scroll_bar)) 3570 if (!NILP (window->vertical_scroll_bar))
@@ -3668,26 +3591,27 @@ ns_set_vertical_scroll_bar (struct window *window,
3668 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f); 3591 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f);
3669 left = WINDOW_SCROLL_BAR_AREA_X (window); 3592 left = WINDOW_SCROLL_BAR_AREA_X (window);
3670 3593
3671 if (top < 5) /* top scrollbar adjustment */
3672 {
3673 top -= FRAME_INTERNAL_BORDER_WIDTH (f);
3674 height += FRAME_INTERNAL_BORDER_WIDTH (f);
3675 }
3676
3677 /* allow for displaying a skinnier scrollbar than char area allotted */ 3594 /* allow for displaying a skinnier scrollbar than char area allotted */
3678 sb_width = (WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) > 0) ? 3595 sb_width = (WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) > 0) ?
3679 WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) : width; 3596 WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) : width;
3680 3597 sb_left = left;
3681 barOnVeryLeft = left < 5;
3682 barOnVeryRight = FRAME_PIXEL_WIDTH (f) - left - width < 5;
3683 sb_left = left + FRAME_INTERNAL_BORDER_WIDTH (f)
3684 * (barOnVeryLeft ? -1 : (barOnVeryRight ? 1 : 0));
3685 3598
3686 r = NSMakeRect (sb_left, top, sb_width, height); 3599 r = NSMakeRect (sb_left, top, sb_width, height);
3687 /* the parent view is flipped, so we need to flip y value */ 3600 /* the parent view is flipped, so we need to flip y value */
3688 v = [view frame]; 3601 v = [view frame];
3689 r.origin.y = (v.size.height - r.size.height - r.origin.y); 3602 r.origin.y = (v.size.height - r.size.height - r.origin.y);
3690 3603
3604 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (window))
3605 fringe_extended_p = (WINDOW_LEFTMOST_P (window)
3606 && WINDOW_LEFT_FRINGE_WIDTH (window)
3607 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window)
3608 || WINDOW_LEFT_MARGIN_COLS (window) == 0));
3609 else
3610 fringe_extended_p = (WINDOW_RIGHTMOST_P (window)
3611 && WINDOW_RIGHT_FRINGE_WIDTH (window)
3612 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window)
3613 || WINDOW_RIGHT_MARGIN_COLS (window) == 0));
3614
3691 XSETWINDOW (win, window); 3615 XSETWINDOW (win, window);
3692 BLOCK_INPUT; 3616 BLOCK_INPUT;
3693 3617
@@ -3707,7 +3631,14 @@ ns_set_vertical_scroll_bar (struct window *window,
3707 3631
3708 if (NILP (window->vertical_scroll_bar)) 3632 if (NILP (window->vertical_scroll_bar))
3709 { 3633 {
3710 ns_clear_frame_area (f, sb_left, top, width, height); 3634 if (width > 0 && height > 0)
3635 {
3636 if (fringe_extended_p)
3637 ns_clear_frame_area (f, sb_left, top, sb_width, height);
3638 else
3639 ns_clear_frame_area (f, left, top, width, height);
3640 }
3641
3711 bar = [[EmacsScroller alloc] initFrame: r window: win]; 3642 bar = [[EmacsScroller alloc] initFrame: r window: win];
3712 wset_vertical_scroll_bar (window, make_save_value (bar, 0)); 3643 wset_vertical_scroll_bar (window, make_save_value (bar, 0));
3713 } 3644 }
@@ -3778,14 +3709,21 @@ ns_judge_scroll_bars (struct frame *f)
3778{ 3709{
3779 int i; 3710 int i;
3780 id view; 3711 id view;
3781 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; 3712 EmacsView *eview = FRAME_NS_VIEW (f);
3713 NSArray *subviews = [[eview superview] subviews];
3714 BOOL removed = NO;
3715
3782 NSTRACE (ns_judge_scroll_bars); 3716 NSTRACE (ns_judge_scroll_bars);
3783 for (i =[subviews count]-1; i >= 0; i--) 3717 for (i = [subviews count]-1; i >= 0; --i)
3784 { 3718 {
3785 view = [subviews objectAtIndex: i]; 3719 view = [subviews objectAtIndex: i];
3786 if (![view isKindOfClass: [EmacsScroller class]]) continue; 3720 if (![view isKindOfClass: [EmacsScroller class]]) continue;
3787 [view judge]; 3721 [view judge];
3722 removed = YES;
3788 } 3723 }
3724
3725 if (removed)
3726 [eview updateFrameSize: NO];
3789} 3727}
3790 3728
3791 3729
@@ -4035,33 +3973,34 @@ ns_term_init (Lisp_Object display_name)
4035 static int ns_initialized = 0; 3973 static int ns_initialized = 0;
4036 Lisp_Object tmp; 3974 Lisp_Object tmp;
4037 3975
3976 if (ns_initialized) return x_display_list;
3977 ns_initialized = 1;
3978
4038 NSTRACE (ns_term_init); 3979 NSTRACE (ns_term_init);
4039 3980
3981 [outerpool release];
3982 outerpool = [[NSAutoreleasePool alloc] init];
3983
4040 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */ 3984 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */
4041 /*GSDebugAllocationActive (YES); */ 3985 /*GSDebugAllocationActive (YES); */
4042 BLOCK_INPUT; 3986 BLOCK_INPUT;
4043 handling_signal = 0;
4044 3987
4045 if (!ns_initialized) 3988 baud_rate = 38400;
4046 { 3989 Fset_input_interrupt_mode (Qnil);
4047 baud_rate = 38400;
4048 Fset_input_interrupt_mode (Qnil);
4049 3990
4050 if (selfds[0] == -1) 3991 if (selfds[0] == -1)
3992 {
3993 if (pipe (selfds) == -1)
4051 { 3994 {
4052 if (pipe (selfds) == -1) 3995 fprintf (stderr, "Failed to create pipe: %s\n",
4053 { 3996 emacs_strerror (errno));
4054 fprintf (stderr, "Failed to create pipe: %s\n", 3997 emacs_abort ();
4055 emacs_strerror (errno));
4056 abort ();
4057 }
4058
4059 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL));
4060 FD_ZERO (&select_readfds);
4061 FD_ZERO (&select_writefds);
4062 pthread_mutex_init (&select_mutex, NULL);
4063 } 3998 }
4064 ns_initialized = 1; 3999
4000 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL));
4001 FD_ZERO (&select_readfds);
4002 FD_ZERO (&select_writefds);
4003 pthread_mutex_init (&select_mutex, NULL);
4065 } 4004 }
4066 4005
4067 ns_pending_files = [[NSMutableArray alloc] init]; 4006 ns_pending_files = [[NSMutableArray alloc] init];
@@ -4252,6 +4191,20 @@ ns_term_init (Lisp_Object display_name)
4252 } 4191 }
4253#endif /* MAC OS X menu setup */ 4192#endif /* MAC OS X menu setup */
4254 4193
4194 /* Register our external input/output types, used for determining
4195 applicable services and also drag/drop eligibility. */
4196 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
4197 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
4198 retain];
4199 ns_drag_types = [[NSArray arrayWithObjects:
4200 NSStringPboardType,
4201 NSTabularTextPboardType,
4202 NSFilenamesPboardType,
4203 NSURLPboardType,
4204 NSColorPboardType,
4205 NSFontPboardType, nil] retain];
4206
4207
4255 [NSApp run]; 4208 [NSApp run];
4256 ns_do_open_file = YES; 4209 ns_do_open_file = YES;
4257 return dpyinfo; 4210 return dpyinfo;
@@ -4273,7 +4226,7 @@ ns_term_shutdown (int sig)
4273 } 4226 }
4274 else // force a stack trace to happen 4227 else // force a stack trace to happen
4275 { 4228 {
4276 abort(); 4229 emacs_abort ();
4277 } 4230 }
4278} 4231}
4279 4232
@@ -4534,10 +4487,10 @@ not_in_argv (NSString *arg)
4534 /* Don't open files from the command line unconditionally, 4487 /* Don't open files from the command line unconditionally,
4535 Cocoa parses the command line wrong, --option value tries to open value 4488 Cocoa parses the command line wrong, --option value tries to open value
4536 if --option is the last option. */ 4489 if --option is the last option. */
4537 while ((file = [files nextObject]) != nil) 4490 while ((file = [files nextObject]) != nil)
4538 if (ns_do_open_file || not_in_argv (file)) 4491 if (ns_do_open_file || not_in_argv (file))
4539 [ns_pending_files addObject: file]; 4492 [ns_pending_files addObject: file];
4540 4493
4541 [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; 4494 [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
4542 4495
4543} 4496}
@@ -4604,7 +4557,7 @@ not_in_argv (NSString *arg)
4604 4557
4605 /* NSTRACE (fd_handler); */ 4558 /* NSTRACE (fd_handler); */
4606 4559
4607 for (;;) 4560 for (;;)
4608 { 4561 {
4609 [pool release]; 4562 [pool release];
4610 pool = [[NSAutoreleasePool alloc] init]; 4563 pool = [[NSAutoreleasePool alloc] init];
@@ -4889,7 +4842,7 @@ not_in_argv (NSString *arg)
4889 is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask; 4842 is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask;
4890 is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask 4843 is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask
4891 || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask); 4844 || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask);
4892 4845
4893 if (is_right_key) 4846 if (is_right_key)
4894 emacs_event->modifiers |= parse_solitary_modifier 4847 emacs_event->modifiers |= parse_solitary_modifier
4895 (EQ (ns_right_command_modifier, Qleft) 4848 (EQ (ns_right_command_modifier, Qleft)
@@ -5420,6 +5373,50 @@ not_in_argv (NSString *arg)
5420 return NO; 5373 return NO;
5421} 5374}
5422 5375
5376- (void) updateFrameSize: (BOOL) delay;
5377{
5378 NSWindow *window = [self window];
5379 NSRect wr = [window frame];
5380#ifdef NS_IMPL_GNUSTEP
5381 int extra = 3;
5382#else
5383 int extra = 0;
5384#endif
5385
5386 int oldc = cols, oldr = rows;
5387 int oldw = FRAME_PIXEL_WIDTH (emacsframe),
5388 oldh = FRAME_PIXEL_HEIGHT (emacsframe);
5389 int neww, newh;
5390
5391 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + extra);
5392
5393 if (cols < MINWIDTH)
5394 cols = MINWIDTH;
5395
5396 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES
5397 (emacsframe, wr.size.height
5398 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + extra
5399 - FRAME_TOOLBAR_HEIGHT (emacsframe));
5400
5401 if (rows < MINHEIGHT)
5402 rows = MINHEIGHT;
5403
5404 neww = (int)wr.size.width - emacsframe->border_width;
5405 newh = ((int)wr.size.height
5406 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
5407 - FRAME_TOOLBAR_HEIGHT (emacsframe));
5408
5409 if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
5410 {
5411 NSView *view = FRAME_NS_VIEW (emacsframe);
5412 FRAME_PIXEL_WIDTH (emacsframe) = neww;
5413 FRAME_PIXEL_HEIGHT (emacsframe) = newh;
5414 change_frame_size (emacsframe, rows, cols, 0, delay, 0);
5415 SET_FRAME_GARBAGED (emacsframe);
5416 cancel_mouse_face (emacsframe);
5417 [view setFrame: NSMakeRect (0, 0, neww, newh)];
5418 }
5419}
5423 5420
5424- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize 5421- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
5425/* normalize frame to gridded text size */ 5422/* normalize frame to gridded text size */
@@ -5517,16 +5514,7 @@ not_in_argv (NSString *arg)
5517 x_set_window_size (emacsframe, 0, cols, rows); 5514 x_set_window_size (emacsframe, 0, cols, rows);
5518 else 5515 else
5519 { 5516 {
5520 NSWindow *window = [self window]; 5517 [self updateFrameSize: YES];
5521 NSRect wr = [window frame];
5522 FRAME_PIXEL_WIDTH (emacsframe) = (int)wr.size.width
5523 - emacsframe->border_width;
5524 FRAME_PIXEL_HEIGHT (emacsframe) = (int)wr.size.height
5525 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
5526 - FRAME_TOOLBAR_HEIGHT (emacsframe);
5527 change_frame_size (emacsframe, rows, cols, 0, 0, 1);
5528 SET_FRAME_GARBAGED (emacsframe);
5529 cancel_mouse_face (emacsframe);
5530 } 5518 }
5531 } 5519 }
5532#endif 5520#endif
@@ -5853,7 +5841,7 @@ not_in_argv (NSString *arg)
5853 NSTRACE (menuDown); 5841 NSTRACE (menuDown);
5854 if (context_menu_value == -1) 5842 if (context_menu_value == -1)
5855 context_menu_value = [sender tag]; 5843 context_menu_value = [sender tag];
5856 else 5844 else
5857 { 5845 {
5858 NSInteger tag = [sender tag]; 5846 NSInteger tag = [sender tag];
5859 find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used, 5847 find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used,
@@ -6180,7 +6168,7 @@ not_in_argv (NSString *arg)
6180 Lisp_Object str = Qnil; 6168 Lisp_Object str = Qnil;
6181 struct frame *f = SELECTED_FRAME (); 6169 struct frame *f = SELECTED_FRAME ();
6182 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); 6170 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer);
6183 6171
6184 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) 6172 if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
6185 return NSAccessibilityTextFieldRole; 6173 return NSAccessibilityTextFieldRole;
6186 6174
@@ -6193,13 +6181,13 @@ not_in_argv (NSString *arg)
6193 { 6181 {
6194 if (! NILP (BVAR (curbuf, mark_active))) 6182 if (! NILP (BVAR (curbuf, mark_active)))
6195 str = ns_get_local_selection (QPRIMARY, QUTF8_STRING); 6183 str = ns_get_local_selection (QPRIMARY, QUTF8_STRING);
6196 6184
6197 if (NILP (str)) 6185 if (NILP (str))
6198 { 6186 {
6199 ptrdiff_t start_byte = BUF_BEGV_BYTE (curbuf); 6187 ptrdiff_t start_byte = BUF_BEGV_BYTE (curbuf);
6200 ptrdiff_t byte_range = BUF_ZV_BYTE (curbuf) - start_byte; 6188 ptrdiff_t byte_range = BUF_ZV_BYTE (curbuf) - start_byte;
6201 ptrdiff_t range = BUF_ZV (curbuf) - BUF_BEGV (curbuf); 6189 ptrdiff_t range = BUF_ZV (curbuf) - BUF_BEGV (curbuf);
6202 6190
6203 if (! NILP (BVAR (curbuf, enable_multibyte_characters))) 6191 if (! NILP (BVAR (curbuf, enable_multibyte_characters)))
6204 str = make_uninit_multibyte_string (range, byte_range); 6192 str = make_uninit_multibyte_string (range, byte_range);
6205 else 6193 else
@@ -6209,9 +6197,9 @@ not_in_argv (NSString *arg)
6209 memcpy (SDATA (str), BYTE_POS_ADDR (start_byte), byte_range); 6197 memcpy (SDATA (str), BYTE_POS_ADDR (start_byte), byte_range);
6210 } 6198 }
6211 } 6199 }
6212 6200
6213 6201
6214 if (! NILP (str)) 6202 if (! NILP (str))
6215 { 6203 {
6216 if (CONSP (str) && SYMBOLP (XCAR (str))) 6204 if (CONSP (str) && SYMBOLP (XCAR (str)))
6217 { 6205 {
@@ -6226,7 +6214,7 @@ not_in_argv (NSString *arg)
6226 return nsStr; 6214 return nsStr;
6227 } 6215 }
6228 } 6216 }
6229 6217
6230 return [super accessibilityAttributeValue:attribute]; 6218 return [super accessibilityAttributeValue:attribute];
6231} 6219}
6232#endif /* NS_IMPL_COCOA */ 6220#endif /* NS_IMPL_COCOA */
@@ -6242,7 +6230,10 @@ not_in_argv (NSString *arg)
6242 NSTRACE (constrainFrameRect); 6230 NSTRACE (constrainFrameRect);
6243 6231
6244 if (nr_screens == 1) 6232 if (nr_screens == 1)
6245 return [super constrainFrameRect:frameRect toScreen:screen]; 6233 {
6234 NSRect r = [super constrainFrameRect:frameRect toScreen:screen];
6235 return r;
6236 }
6246 6237
6247 if (f->output_data.ns->dont_constrain 6238 if (f->output_data.ns->dont_constrain
6248 || ns_menu_bar_should_be_hidden ()) 6239 || 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "character.h" 26#include "character.h"
27#include "buffer.h" 27#include "buffer.h"
@@ -45,15 +45,9 @@ static Lisp_Object Qtemp_buffer_setup_hook;
45 45
46static Lisp_Object Qfloat_output_format; 46static Lisp_Object Qfloat_output_format;
47 47
48#include <math.h>
49#include <float.h> 48#include <float.h>
50#include <ftoastr.h> 49#include <ftoastr.h>
51 50
52/* Default to values appropriate for IEEE floating point. */
53#ifndef DBL_DIG
54#define DBL_DIG 15
55#endif
56
57/* Avoid actual stack overflow in print. */ 51/* Avoid actual stack overflow in print. */
58static ptrdiff_t print_depth; 52static ptrdiff_t print_depth;
59 53
@@ -1879,7 +1873,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1879 } 1873 }
1880 else if (BUFFERP (obj)) 1874 else if (BUFFERP (obj))
1881 { 1875 {
1882 if (NILP (BVAR (XBUFFER (obj), name))) 1876 if (!BUFFER_LIVE_P (XBUFFER (obj)))
1883 strout ("#<killed buffer>", -1, -1, printcharfun); 1877 strout ("#<killed buffer>", -1, -1, printcharfun);
1884 else if (escapeflag) 1878 else if (escapeflag)
1885 { 1879 {
@@ -2060,7 +2054,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2060 { 2054 {
2061 int len; 2055 int len;
2062 /* We're in trouble if this happens! 2056 /* We're in trouble if this happens!
2063 Probably should just abort () */ 2057 Probably should just emacs_abort (). */
2064 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); 2058 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun);
2065 if (MISCP (obj)) 2059 if (MISCP (obj))
2066 len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); 2060 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/>. */
23 23
24#define PROCESS_INLINE EXTERN_INLINE 24#define PROCESS_INLINE EXTERN_INLINE
25 25
26#include <signal.h>
27#include <stdio.h> 26#include <stdio.h>
28#include <errno.h> 27#include <errno.h>
29#include <setjmp.h>
30#include <sys/types.h> /* Some typedefs are used in sys/file.h. */ 28#include <sys/types.h> /* Some typedefs are used in sys/file.h. */
31#include <sys/file.h> 29#include <sys/file.h>
32#include <sys/stat.h> 30#include <sys/stat.h>
33#include <setjmp.h>
34
35#include <unistd.h> 31#include <unistd.h>
36#include <fcntl.h> 32#include <fcntl.h>
37 33
@@ -76,6 +72,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
76#include <bsdtty.h> 72#include <bsdtty.h>
77#endif 73#endif
78 74
75#ifdef USG5_4
76# include <sys/stream.h>
77# include <sys/stropts.h>
78#endif
79
79#ifdef HAVE_RES_INIT 80#ifdef HAVE_RES_INIT
80#include <netinet/in.h> 81#include <netinet/in.h>
81#include <arpa/nameser.h> 82#include <arpa/nameser.h>
@@ -124,6 +125,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
124#include "xgselect.h" 125#include "xgselect.h"
125#endif 126#endif
126 127
128#ifndef WNOHANG
129# undef waitpid
130# define waitpid(pid, status, options) wait (status)
131#endif
132#ifndef WUNTRACED
133# define WUNTRACED 0
134#endif
135
127/* Work around GCC 4.7.0 bug with strict overflow checking; see 136/* Work around GCC 4.7.0 bug with strict overflow checking; see
128 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 137 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
129 These lines can be removed once the GCC bug is fixed. */ 138 These lines can be removed once the GCC bug is fixed. */
@@ -165,16 +174,6 @@ static Lisp_Object QClocal, QCremote, QCcoding;
165static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; 174static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop;
166static Lisp_Object QCsentinel, QClog, QCoptions, QCplist; 175static Lisp_Object QCsentinel, QClog, QCoptions, QCplist;
167static Lisp_Object Qlast_nonmenu_event; 176static Lisp_Object Qlast_nonmenu_event;
168/* QCfamily is declared and initialized in xfaces.c,
169 QCfilter in keyboard.c. */
170extern Lisp_Object QCfamily, QCfilter;
171
172/* Qexit is declared and initialized in eval.c. */
173
174/* QCfamily is defined in xfaces.c. */
175extern Lisp_Object QCfamily;
176/* QCfilter is defined in keyboard.c. */
177extern Lisp_Object QCfilter;
178 177
179#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) 178#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
180#define NETCONN1_P(p) (EQ (p->type, Qnetwork)) 179#define NETCONN1_P(p) (EQ (p->type, Qnetwork))
@@ -215,17 +214,13 @@ static EMACS_INT update_tick;
215 "non-destructive" select. So we require either native select, 214 "non-destructive" select. So we require either native select,
216 or emulation of select using FIONREAD. */ 215 or emulation of select using FIONREAD. */
217 216
218#ifdef BROKEN_DATAGRAM_SOCKETS 217#ifndef BROKEN_DATAGRAM_SOCKETS
219#undef DATAGRAM_SOCKETS 218# if defined HAVE_SELECT || defined USABLE_FIONREAD
220#else 219# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE
221#ifndef DATAGRAM_SOCKETS 220# define DATAGRAM_SOCKETS
222#if defined (HAVE_SELECT) || defined (FIONREAD) 221# endif
223#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) 222# endif
224#define DATAGRAM_SOCKETS 223#endif
225#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
226#endif /* HAVE_SELECT || FIONREAD */
227#endif /* DATAGRAM_SOCKETS */
228#endif /* BROKEN_DATAGRAM_SOCKETS */
229 224
230#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS 225#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS
231# define HAVE_SEQPACKET 226# define HAVE_SEQPACKET
@@ -254,7 +249,7 @@ static int process_output_skip;
254#endif 249#endif
255 250
256static void create_process (Lisp_Object, char **, Lisp_Object); 251static void create_process (Lisp_Object, char **, Lisp_Object);
257#ifdef SIGIO 252#ifdef USABLE_SIGIO
258static int keyboard_bit_set (SELECT_TYPE *); 253static int keyboard_bit_set (SELECT_TYPE *);
259#endif 254#endif
260static void deactivate_process (Lisp_Object); 255static void deactivate_process (Lisp_Object);
@@ -811,7 +806,7 @@ get_process (register Lisp_Object name)
811#ifdef SIGCHLD 806#ifdef SIGCHLD
812/* Fdelete_process promises to immediately forget about the process, but in 807/* Fdelete_process promises to immediately forget about the process, but in
813 reality, Emacs needs to remember those processes until they have been 808 reality, Emacs needs to remember those processes until they have been
814 treated by sigchld_handler; otherwise this handler would consider the 809 treated by the SIGCHLD handler; otherwise this handler would consider the
815 process as being synchronous and say that the synchronous process is 810 process as being synchronous and say that the synchronous process is
816 dead. */ 811 dead. */
817static Lisp_Object deleted_pid_list; 812static Lisp_Object deleted_pid_list;
@@ -859,7 +854,8 @@ nil, indicating the current buffer's process. */)
859#endif 854#endif
860 { 855 {
861 Fkill_process (process, Qnil); 856 Fkill_process (process, Qnil);
862 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 857 /* Do this now, since remove_process will make the
858 SIGCHLD handler do nothing. */
863 pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil))); 859 pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)));
864 p->tick = ++process_tick; 860 p->tick = ++process_tick;
865 status_notify (p); 861 status_notify (p);
@@ -1587,7 +1583,7 @@ static Lisp_Object
1587start_process_unwind (Lisp_Object proc) 1583start_process_unwind (Lisp_Object proc)
1588{ 1584{
1589 if (!PROCESSP (proc)) 1585 if (!PROCESSP (proc))
1590 abort (); 1586 emacs_abort ();
1591 1587
1592 /* Was PROC started successfully? 1588 /* Was PROC started successfully?
1593 -2 is used for a pty with no process, eg for gdb. */ 1589 -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)
1613#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1609#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1614 int wait_child_setup[2]; 1610 int wait_child_setup[2];
1615#endif 1611#endif
1616 sigset_t procmask; 1612#ifdef SIGCHLD
1617 sigset_t blocked; 1613 sigset_t blocked, procmask;
1618 struct sigaction sigint_action;
1619 struct sigaction sigquit_action;
1620 struct sigaction sigpipe_action;
1621#ifdef AIX
1622 struct sigaction sighup_action;
1623#endif 1614#endif
1624 /* Use volatile to protect variables from being clobbered by longjmp. */ 1615 /* Use volatile to protect variables from being clobbered by vfork. */
1625 volatile int forkin, forkout; 1616 volatile int forkin, forkout;
1626 volatile int pty_flag = 0; 1617 volatile int pty_flag = 0;
1627 1618
@@ -1713,32 +1704,20 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1713 XPROCESS (process)->pty_flag = pty_flag; 1704 XPROCESS (process)->pty_flag = pty_flag;
1714 pset_status (XPROCESS (process), Qrun); 1705 pset_status (XPROCESS (process), Qrun);
1715 1706
1707#ifdef SIGCHLD
1716 /* Delay interrupts until we have a chance to store 1708 /* Delay interrupts until we have a chance to store
1717 the new fork's pid in its process structure */ 1709 the new fork's pid in its process structure */
1718 sigemptyset (&blocked); 1710 sigemptyset (&blocked);
1719#ifdef SIGCHLD
1720 sigaddset (&blocked, SIGCHLD); 1711 sigaddset (&blocked, SIGCHLD);
1721#endif
1722#ifdef HAVE_WORKING_VFORK
1723 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
1724 this sets the parent's signal handlers as well as the child's.
1725 So delay all interrupts whose handlers the child might munge,
1726 and record the current handlers so they can be restored later. */
1727 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action );
1728 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action);
1729 sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action);
1730#ifdef AIX
1731 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action );
1732#endif
1733#endif /* HAVE_WORKING_VFORK */
1734 pthread_sigmask (SIG_BLOCK, &blocked, &procmask); 1712 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
1713#endif
1735 1714
1736 FD_SET (inchannel, &input_wait_mask); 1715 FD_SET (inchannel, &input_wait_mask);
1737 FD_SET (inchannel, &non_keyboard_wait_mask); 1716 FD_SET (inchannel, &non_keyboard_wait_mask);
1738 if (inchannel > max_process_desc) 1717 if (inchannel > max_process_desc)
1739 max_process_desc = inchannel; 1718 max_process_desc = inchannel;
1740 1719
1741 /* Until we store the proper pid, enable sigchld_handler 1720 /* Until we store the proper pid, enable the SIGCHLD handler
1742 to recognize an unknown pid as standing for this process. 1721 to recognize an unknown pid as standing for this process.
1743 It is very important not to let this `marker' value stay 1722 It is very important not to let this `marker' value stay
1744 in the table after this function has returned; if it does 1723 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)
1766 int xforkin = forkin; 1745 int xforkin = forkin;
1767 int xforkout = forkout; 1746 int xforkout = forkout;
1768 1747
1769#if 0 /* This was probably a mistake--it duplicates code later on,
1770 but fails to handle all the cases. */
1771 /* Make sure SIGCHLD is not blocked in the child. */
1772 sigsetmask (SIGEMPTYMASK);
1773#endif
1774
1775 /* Make the pty be the controlling terminal of the process. */ 1748 /* Make the pty be the controlling terminal of the process. */
1776#ifdef HAVE_PTYS 1749#ifdef HAVE_PTYS
1777 /* First, disconnect its current controlling terminal. */ 1750 /* First, disconnect its current controlling terminal. */
@@ -1890,8 +1863,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1890 in the child. */ 1863 in the child. */
1891 signal (SIGPIPE, SIG_DFL); 1864 signal (SIGPIPE, SIG_DFL);
1892 1865
1866#ifdef SIGCHLD
1893 /* Stop blocking signals in the child. */ 1867 /* Stop blocking signals in the child. */
1894 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1868 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1869#endif
1895 1870
1896 if (pty_flag) 1871 if (pty_flag)
1897 child_setup_tty (xforkout); 1872 child_setup_tty (xforkout);
@@ -1970,19 +1945,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1970#endif 1945#endif
1971 } 1946 }
1972 1947
1973 /* Restore the signal state whether vfork succeeded or not. 1948#ifdef SIGCHLD
1974 (We will signal an error, below, if it failed.) */
1975#ifdef HAVE_WORKING_VFORK
1976 /* Restore the parent's signal handlers. */
1977 sigaction (SIGINT, &sigint_action, 0);
1978 sigaction (SIGQUIT, &sigquit_action, 0);
1979 sigaction (SIGPIPE, &sigpipe_action, 0);
1980#ifdef AIX
1981 sigaction (SIGHUP, &sighup_action, 0);
1982#endif
1983#endif /* HAVE_WORKING_VFORK */
1984 /* Stop blocking signals in the parent. */ 1949 /* Stop blocking signals in the parent. */
1985 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1950 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1951#endif
1986 1952
1987 /* Now generate the error if vfork failed. */ 1953 /* Now generate the error if vfork failed. */
1988 if (pid < 0) 1954 if (pid < 0)
@@ -2560,7 +2526,7 @@ static Lisp_Object
2560make_serial_process_unwind (Lisp_Object proc) 2526make_serial_process_unwind (Lisp_Object proc)
2561{ 2527{
2562 if (!PROCESSP (proc)) 2528 if (!PROCESSP (proc))
2563 abort (); 2529 emacs_abort ();
2564 remove_process (proc); 2530 remove_process (proc);
2565 return Qnil; 2531 return Qnil;
2566} 2532}
@@ -3397,7 +3363,7 @@ usage: (make-network-process &rest ARGS) */)
3397 if (socktype == SOCK_DGRAM) 3363 if (socktype == SOCK_DGRAM)
3398 { 3364 {
3399 if (datagram_address[s].sa) 3365 if (datagram_address[s].sa)
3400 abort (); 3366 emacs_abort ();
3401 datagram_address[s].sa = xmalloc (lres->ai_addrlen); 3367 datagram_address[s].sa = xmalloc (lres->ai_addrlen);
3402 datagram_address[s].len = lres->ai_addrlen; 3368 datagram_address[s].len = lres->ai_addrlen;
3403 if (is_server) 3369 if (is_server)
@@ -3983,7 +3949,7 @@ deactivate_process (Lisp_Object proc)
3983 FD_CLR (inchannel, &connect_wait_mask); 3949 FD_CLR (inchannel, &connect_wait_mask);
3984 FD_CLR (inchannel, &write_mask); 3950 FD_CLR (inchannel, &write_mask);
3985 if (--num_pending_connects < 0) 3951 if (--num_pending_connects < 0)
3986 abort (); 3952 emacs_abort ();
3987 } 3953 }
3988#endif 3954#endif
3989 if (inchannel == max_process_desc) 3955 if (inchannel == max_process_desc)
@@ -4406,10 +4372,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4406 Otherwise, do pending quit if requested. */ 4372 Otherwise, do pending quit if requested. */
4407 if (read_kbd >= 0) 4373 if (read_kbd >= 0)
4408 QUIT; 4374 QUIT;
4409#ifdef SYNC_INPUT
4410 else 4375 else
4411 process_pending_signals (); 4376 process_pending_signals ();
4412#endif
4413 4377
4414 /* Exit now if the cell we're waiting for became non-nil. */ 4378 /* Exit now if the cell we're waiting for became non-nil. */
4415 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4379 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,
4763 Cleanup occurs c/o status_notify after SIGCLD. */ 4727 Cleanup occurs c/o status_notify after SIGCLD. */
4764 no_avail = 1; /* Cannot depend on values returned */ 4728 no_avail = 1; /* Cannot depend on values returned */
4765#else 4729#else
4766 abort (); 4730 emacs_abort ();
4767#endif 4731#endif
4768 } 4732 }
4769 else 4733 else
@@ -4846,7 +4810,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4846 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4810 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4847 break; 4811 break;
4848 4812
4849#ifdef SIGIO 4813#ifdef USABLE_SIGIO
4850 /* If we think we have keyboard input waiting, but didn't get SIGIO, 4814 /* If we think we have keyboard input waiting, but didn't get SIGIO,
4851 go read it. This can happen with X on BSD after logging out. 4815 go read it. This can happen with X on BSD after logging out.
4852 In that case, there really is no input and no SIGIO, 4816 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,
4967 4931
4968 if (p->pid == -2) 4932 if (p->pid == -2)
4969 { 4933 {
4970 /* If the EIO occurs on a pty, sigchld_handler's 4934 /* If the EIO occurs on a pty, the SIGCHLD handler's
4971 waitpid() will not find the process object to 4935 waitpid call will not find the process object to
4972 delete. Do it here. */ 4936 delete. Do it here. */
4973 p->tick = ++process_tick; 4937 p->tick = ++process_tick;
4974 pset_status (p, Qfailed); 4938 pset_status (p, Qfailed);
@@ -5004,7 +4968,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5004 FD_CLR (channel, &connect_wait_mask); 4968 FD_CLR (channel, &connect_wait_mask);
5005 FD_CLR (channel, &write_mask); 4969 FD_CLR (channel, &write_mask);
5006 if (--num_pending_connects < 0) 4970 if (--num_pending_connects < 0)
5007 abort (); 4971 emacs_abort ();
5008 4972
5009 proc = chan_process[channel]; 4973 proc = chan_process[channel];
5010 if (NILP (proc)) 4974 if (NILP (proc))
@@ -5205,7 +5169,7 @@ read_process_output (Lisp_Object proc, register int channel)
5205 if (!NILP (outstream)) 5169 if (!NILP (outstream))
5206 { 5170 {
5207 Lisp_Object text; 5171 Lisp_Object text;
5208 int outer_running_asynch_code = running_asynch_code; 5172 bool outer_running_asynch_code = running_asynch_code;
5209 int waiting = waiting_for_user_input_p; 5173 int waiting = waiting_for_user_input_p;
5210 5174
5211 /* No need to gcpro these, because all we do with them later 5175 /* 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)
5308 } 5272 }
5309 5273
5310 /* If no filter, write into buffer if it isn't dead. */ 5274 /* If no filter, write into buffer if it isn't dead. */
5311 else if (!NILP (p->buffer) && !NILP (BVAR (XBUFFER (p->buffer), name))) 5275 else if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5312 { 5276 {
5313 Lisp_Object old_read_only; 5277 Lisp_Object old_read_only;
5314 ptrdiff_t old_begv, old_zv; 5278 ptrdiff_t old_begv, old_zv;
@@ -5430,19 +5394,23 @@ read_process_output (Lisp_Object proc, register int channel)
5430 5394
5431/* Sending data to subprocess */ 5395/* Sending data to subprocess */
5432 5396
5433static jmp_buf send_process_frame; 5397static sys_jmp_buf send_process_frame;
5434static Lisp_Object process_sent_to; 5398static Lisp_Object process_sent_to;
5435 5399
5436#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 5400static _Noreturn void
5437static _Noreturn void send_process_trap (int); 5401handle_pipe_signal (int sig)
5438#endif 5402{
5403 sigset_t unblocked;
5404 sigemptyset (&unblocked);
5405 sigaddset (&unblocked, SIGPIPE);
5406 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
5407 sys_longjmp (send_process_frame, 1);
5408}
5439 5409
5440static void 5410static void
5441send_process_trap (int ignore) 5411deliver_pipe_signal (int sig)
5442{ 5412{
5443 SIGNAL_THREAD_CHECK (SIGPIPE); 5413 handle_on_main_thread (sig, handle_pipe_signal);
5444 sigunblock (sigmask (SIGPIPE));
5445 longjmp (send_process_frame, 1);
5446} 5414}
5447 5415
5448/* In send_process, when a write fails temporarily, 5416/* In send_process, when a write fails temporarily,
@@ -5535,7 +5503,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5535 struct Lisp_Process *p = XPROCESS (proc); 5503 struct Lisp_Process *p = XPROCESS (proc);
5536 ssize_t rv; 5504 ssize_t rv;
5537 struct coding_system *coding; 5505 struct coding_system *coding;
5538 void (*volatile old_sigpipe) (int); 5506 struct sigaction old_sigpipe_action;
5539 5507
5540 if (p->raw_status_new) 5508 if (p->raw_status_new)
5541 update_status (p); 5509 update_status (p);
@@ -5645,7 +5613,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5645 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5613 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5646 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5614 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5647 when returning with longjmp despite being declared volatile. */ 5615 when returning with longjmp despite being declared volatile. */
5648 if (!setjmp (send_process_frame)) 5616 if (!sys_setjmp (send_process_frame))
5649 { 5617 {
5650 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5618 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5651 process_sent_to = proc; 5619 process_sent_to = proc;
@@ -5674,7 +5642,9 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5674 /* Send this batch, using one or more write calls. */ 5642 /* Send this batch, using one or more write calls. */
5675 ptrdiff_t written = 0; 5643 ptrdiff_t written = 0;
5676 int outfd = p->outfd; 5644 int outfd = p->outfd;
5677 old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap); 5645 struct sigaction action;
5646 emacs_sigaction_init (&action, deliver_pipe_signal);
5647 sigaction (SIGPIPE, &action, &old_sigpipe_action);
5678#ifdef DATAGRAM_SOCKETS 5648#ifdef DATAGRAM_SOCKETS
5679 if (DATAGRAM_CHAN_P (outfd)) 5649 if (DATAGRAM_CHAN_P (outfd))
5680 { 5650 {
@@ -5685,7 +5655,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5685 written = rv; 5655 written = rv;
5686 else if (errno == EMSGSIZE) 5656 else if (errno == EMSGSIZE)
5687 { 5657 {
5688 signal (SIGPIPE, old_sigpipe); 5658 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5689 report_file_error ("sending datagram", 5659 report_file_error ("sending datagram",
5690 Fcons (proc, Qnil)); 5660 Fcons (proc, Qnil));
5691 } 5661 }
@@ -5710,7 +5680,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5710 } 5680 }
5711#endif 5681#endif
5712 } 5682 }
5713 signal (SIGPIPE, old_sigpipe); 5683 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5714 5684
5715 if (rv < 0) 5685 if (rv < 0)
5716 { 5686 {
@@ -5770,7 +5740,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5770 } 5740 }
5771 else 5741 else
5772 { 5742 {
5773 signal (SIGPIPE, old_sigpipe); 5743 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5774 proc = process_sent_to; 5744 proc = process_sent_to;
5775 p = XPROCESS (proc); 5745 p = XPROCESS (proc);
5776 p->raw_status_new = 0; 5746 p->raw_status_new = 0;
@@ -6365,15 +6335,14 @@ process has been transmitted to the serial port. */)
6365#endif /* not HAVE_SHUTDOWN */ 6335#endif /* not HAVE_SHUTDOWN */
6366 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); 6336 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
6367 if (new_outfd < 0) 6337 if (new_outfd < 0)
6368 abort (); 6338 emacs_abort ();
6369 old_outfd = XPROCESS (proc)->outfd; 6339 old_outfd = XPROCESS (proc)->outfd;
6370 6340
6371 if (!proc_encode_coding_system[new_outfd]) 6341 if (!proc_encode_coding_system[new_outfd])
6372 proc_encode_coding_system[new_outfd] 6342 proc_encode_coding_system[new_outfd]
6373 = xmalloc (sizeof (struct coding_system)); 6343 = xmalloc (sizeof (struct coding_system));
6374 memcpy (proc_encode_coding_system[new_outfd], 6344 *proc_encode_coding_system[new_outfd]
6375 proc_encode_coding_system[old_outfd], 6345 = *proc_encode_coding_system[old_outfd];
6376 sizeof (struct coding_system));
6377 memset (proc_encode_coding_system[old_outfd], 0, 6346 memset (proc_encode_coding_system[old_outfd], 0,
6378 sizeof (struct coding_system)); 6347 sizeof (struct coding_system));
6379 6348
@@ -6408,143 +6377,135 @@ process has been transmitted to the serial port. */)
6408 indirectly; if it does, that is a bug */ 6377 indirectly; if it does, that is a bug */
6409 6378
6410#ifdef SIGCHLD 6379#ifdef SIGCHLD
6411static void 6380
6412sigchld_handler (int signo) 6381/* Record one child's changed status. Return true if a child was found. */
6382static bool
6383record_child_status_change (void)
6413{ 6384{
6414 int old_errno = errno;
6415 Lisp_Object proc; 6385 Lisp_Object proc;
6416 struct Lisp_Process *p; 6386 struct Lisp_Process *p;
6387 pid_t pid;
6388 int w;
6389 Lisp_Object tail;
6417 6390
6418 SIGNAL_THREAD_CHECK (signo); 6391 do
6419 6392 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6420 while (1) 6393 while (pid < 0 && errno == EINTR);
6421 {
6422 pid_t pid;
6423 int w;
6424 Lisp_Object tail;
6425
6426#ifdef WNOHANG
6427#ifndef WUNTRACED
6428#define WUNTRACED 0
6429#endif /* no WUNTRACED */
6430 /* Keep trying to get a status until we get a definitive result. */
6431 do
6432 {
6433 errno = 0;
6434 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6435 }
6436 while (pid < 0 && errno == EINTR);
6437
6438 if (pid <= 0)
6439 {
6440 /* PID == 0 means no processes found, PID == -1 means a real
6441 failure. We have done all our job, so return. */
6442 6394
6443 errno = old_errno; 6395 /* PID == 0 means no processes found, PID == -1 means a real failure.
6444 return; 6396 Either way, we have done all our job. */
6445 } 6397 if (pid <= 0)
6446#else 6398 return false;
6447 pid = wait (&w);
6448#endif /* no WNOHANG */
6449 6399
6450 /* Find the process that signaled us, and record its status. */ 6400 /* Find the process that signaled us, and record its status. */
6451 6401
6452 /* The process can have been deleted by Fdelete_process. */ 6402 /* The process can have been deleted by Fdelete_process. */
6453 for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) 6403 for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail))
6404 {
6405 Lisp_Object xpid = XCAR (tail);
6406 if ((INTEGERP (xpid) && pid == XINT (xpid))
6407 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid)))
6454 { 6408 {
6455 Lisp_Object xpid = XCAR (tail); 6409 XSETCAR (tail, Qnil);
6456 if ((INTEGERP (xpid) && pid == XINT (xpid)) 6410 return true;
6457 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid)))
6458 {
6459 XSETCAR (tail, Qnil);
6460 goto sigchld_end_of_loop;
6461 }
6462 } 6411 }
6412 }
6463 6413
6464 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ 6414 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */
6415 p = 0;
6416 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6417 {
6418 proc = XCDR (XCAR (tail));
6419 p = XPROCESS (proc);
6420 if (EQ (p->type, Qreal) && p->pid == pid)
6421 break;
6465 p = 0; 6422 p = 0;
6466 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6423 }
6467 {
6468 proc = XCDR (XCAR (tail));
6469 p = XPROCESS (proc);
6470 if (EQ (p->type, Qreal) && p->pid == pid)
6471 break;
6472 p = 0;
6473 }
6474
6475 /* Look for an asynchronous process whose pid hasn't been filled
6476 in yet. */
6477 if (p == 0)
6478 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6479 {
6480 proc = XCDR (XCAR (tail));
6481 p = XPROCESS (proc);
6482 if (p->pid == -1)
6483 break;
6484 p = 0;
6485 }
6486
6487 /* Change the status of the process that was found. */
6488 if (p != 0)
6489 {
6490 int clear_desc_flag = 0;
6491 6424
6492 p->tick = ++process_tick; 6425 /* Look for an asynchronous process whose pid hasn't been filled
6493 p->raw_status = w; 6426 in yet. */
6494 p->raw_status_new = 1; 6427 if (! p)
6428 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6429 {
6430 proc = XCDR (XCAR (tail));
6431 p = XPROCESS (proc);
6432 if (p->pid == -1)
6433 break;
6434 p = 0;
6435 }
6495 6436
6496 /* If process has terminated, stop waiting for its output. */ 6437 /* Change the status of the process that was found. */
6497 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6438 if (p)
6498 && p->infd >= 0) 6439 {
6499 clear_desc_flag = 1; 6440 int clear_desc_flag = 0;
6500 6441
6501 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ 6442 p->tick = ++process_tick;
6502 if (clear_desc_flag) 6443 p->raw_status = w;
6503 { 6444 p->raw_status_new = 1;
6504 FD_CLR (p->infd, &input_wait_mask);
6505 FD_CLR (p->infd, &non_keyboard_wait_mask);
6506 }
6507 6445
6508 /* Tell wait_reading_process_output that it needs to wake up and 6446 /* If process has terminated, stop waiting for its output. */
6509 look around. */ 6447 if ((WIFSIGNALED (w) || WIFEXITED (w))
6510 if (input_available_clear_time) 6448 && p->infd >= 0)
6511 *input_available_clear_time = make_emacs_time (0, 0); 6449 clear_desc_flag = 1;
6512 }
6513 6450
6514 /* There was no asynchronous process found for that pid: we have 6451 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */
6515 a synchronous process. */ 6452 if (clear_desc_flag)
6516 else
6517 { 6453 {
6518 synch_process_alive = 0; 6454 FD_CLR (p->infd, &input_wait_mask);
6519 6455 FD_CLR (p->infd, &non_keyboard_wait_mask);
6520 /* Report the status of the synchronous process. */
6521 if (WIFEXITED (w))
6522 synch_process_retcode = WEXITSTATUS (w);
6523 else if (WIFSIGNALED (w))
6524 synch_process_termsig = WTERMSIG (w);
6525
6526 /* Tell wait_reading_process_output that it needs to wake up and
6527 look around. */
6528 if (input_available_clear_time)
6529 *input_available_clear_time = make_emacs_time (0, 0);
6530 } 6456 }
6531 6457
6532 sigchld_end_of_loop: 6458 /* Tell wait_reading_process_output that it needs to wake up and
6533 ; 6459 look around. */
6460 if (input_available_clear_time)
6461 *input_available_clear_time = make_emacs_time (0, 0);
6462 }
6463 /* There was no asynchronous process found for that pid: we have
6464 a synchronous process. */
6465 else
6466 {
6467 synch_process_alive = 0;
6468
6469 /* Report the status of the synchronous process. */
6470 if (WIFEXITED (w))
6471 synch_process_retcode = WEXITSTATUS (w);
6472 else if (WIFSIGNALED (w))
6473 synch_process_termsig = WTERMSIG (w);
6474
6475 /* Tell wait_reading_process_output that it needs to wake up and
6476 look around. */
6477 if (input_available_clear_time)
6478 *input_available_clear_time = make_emacs_time (0, 0);
6479 }
6480
6481 return true;
6482}
6534 6483
6535 /* On some systems, we must return right away. 6484/* On some systems, the SIGCHLD handler must return right away. If
6536 If any more processes want to signal us, we will 6485 any more processes want to signal us, we will get another signal.
6537 get another signal. 6486 Otherwise, loop around to use up all the processes that have
6538 Otherwise (on systems that have WNOHANG), loop around 6487 something to tell us. */
6539 to use up all the processes that have something to tell us. */
6540#if (defined WINDOWSNT \ 6488#if (defined WINDOWSNT \
6541 || (defined USG && !defined GNU_LINUX \ 6489 || (defined USG && !defined GNU_LINUX \
6542 && !(defined HPUX && defined WNOHANG))) 6490 && !(defined HPUX && defined WNOHANG)))
6543 errno = old_errno; 6491enum { CAN_HANDLE_MULTIPLE_CHILDREN = 0 };
6544 return; 6492#else
6545#endif /* USG, but not HPUX with WNOHANG */ 6493enum { CAN_HANDLE_MULTIPLE_CHILDREN = 1 };
6546 } 6494#endif
6495
6496static void
6497handle_child_signal (int sig)
6498{
6499 while (record_child_status_change () && CAN_HANDLE_MULTIPLE_CHILDREN)
6500 continue;
6547} 6501}
6502
6503static void
6504deliver_child_signal (int sig)
6505{
6506 handle_on_main_thread (sig, handle_child_signal);
6507}
6508
6548#endif /* SIGCHLD */ 6509#endif /* SIGCHLD */
6549 6510
6550 6511
@@ -6569,9 +6530,9 @@ static void
6569exec_sentinel (Lisp_Object proc, Lisp_Object reason) 6530exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6570{ 6531{
6571 Lisp_Object sentinel, odeactivate; 6532 Lisp_Object sentinel, odeactivate;
6572 register struct Lisp_Process *p = XPROCESS (proc); 6533 struct Lisp_Process *p = XPROCESS (proc);
6573 ptrdiff_t count = SPECPDL_INDEX (); 6534 ptrdiff_t count = SPECPDL_INDEX ();
6574 int outer_running_asynch_code = running_asynch_code; 6535 bool outer_running_asynch_code = running_asynch_code;
6575 int waiting = waiting_for_user_input_p; 6536 int waiting = waiting_for_user_input_p;
6576 6537
6577 if (inhibit_sentinels) 6538 if (inhibit_sentinels)
@@ -6734,7 +6695,7 @@ status_notify (struct Lisp_Process *deleting_process)
6734 6695
6735 /* Avoid error if buffer is deleted 6696 /* Avoid error if buffer is deleted
6736 (probably that's why the process is dead, too) */ 6697 (probably that's why the process is dead, too) */
6737 if (NILP (BVAR (XBUFFER (buffer), name))) 6698 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
6738 continue; 6699 continue;
6739 Fset_buffer (buffer); 6700 Fset_buffer (buffer);
6740 6701
@@ -6866,7 +6827,7 @@ delete_gpm_wait_descriptor (int desc)
6866 6827
6867# endif 6828# endif
6868 6829
6869# ifdef SIGIO 6830# ifdef USABLE_SIGIO
6870 6831
6871/* Return nonzero if *MASK has a bit set 6832/* Return nonzero if *MASK has a bit set
6872 that corresponds to one of the keyboard input descriptors. */ 6833 that corresponds to one of the keyboard input descriptors. */
@@ -7398,7 +7359,11 @@ init_process_emacs (void)
7398#ifndef CANNOT_DUMP 7359#ifndef CANNOT_DUMP
7399 if (! noninteractive || initialized) 7360 if (! noninteractive || initialized)
7400#endif 7361#endif
7401 signal (SIGCHLD, sigchld_handler); 7362 {
7363 struct sigaction action;
7364 emacs_sigaction_init (&action, deliver_child_signal);
7365 sigaction (SIGCHLD, &action, 0);
7366 }
7402#endif 7367#endif
7403 7368
7404 FD_ZERO (&input_wait_mask); 7369 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/>. */
25#ifdef emacs 25#ifdef emacs
26 26
27#include <config.h> 27#include <config.h>
28#include <setjmp.h> 28
29#include "lisp.h" /* Needed for VALBITS. */ 29#include "lisp.h" /* Needed for VALBITS. */
30#include "blockinput.h" 30#include "blockinput.h"
31 31
@@ -237,7 +237,7 @@ obtain (POINTER address, SIZE size)
237 } 237 }
238 238
239 if (! heap) 239 if (! heap)
240 abort (); 240 emacs_abort ();
241 241
242 /* If we can't fit SIZE bytes in that heap, 242 /* If we can't fit SIZE bytes in that heap,
243 try successive later heaps. */ 243 try successive later heaps. */
@@ -330,7 +330,7 @@ relinquish (void)
330 /* This heap should have no blocs in it. */ 330 /* This heap should have no blocs in it. */
331 if (last_heap->first_bloc != NIL_BLOC 331 if (last_heap->first_bloc != NIL_BLOC
332 || last_heap->last_bloc != NIL_BLOC) 332 || last_heap->last_bloc != NIL_BLOC)
333 abort (); 333 emacs_abort ();
334 334
335 /* Return the last heap, with its header, to the system. */ 335 /* Return the last heap, with its header, to the system. */
336 excess = (char *)last_heap->end - (char *)last_heap->start; 336 excess = (char *)last_heap->end - (char *)last_heap->start;
@@ -355,7 +355,7 @@ relinquish (void)
355 which returns the entire last heap to the system, seems 355 which returns the entire last heap to the system, seems
356 unlikely to trigger this mode of failure. */ 356 unlikely to trigger this mode of failure. */
357 if (last_heap->end != (*real_morecore) (0)) 357 if (last_heap->end != (*real_morecore) (0))
358 abort (); 358 emacs_abort ();
359 } 359 }
360 } 360 }
361} 361}
@@ -452,7 +452,7 @@ relocate_blocs (bloc_ptr bloc, heap_ptr heap, POINTER address)
452 452
453 /* No need to ever call this if arena is frozen, bug somewhere! */ 453 /* No need to ever call this if arena is frozen, bug somewhere! */
454 if (r_alloc_freeze_level) 454 if (r_alloc_freeze_level)
455 abort (); 455 emacs_abort ();
456 456
457 while (b) 457 while (b)
458 { 458 {
@@ -576,7 +576,7 @@ resize_bloc (bloc_ptr bloc, SIZE size)
576 576
577 /* No need to ever call this if arena is frozen, bug somewhere! */ 577 /* No need to ever call this if arena is frozen, bug somewhere! */
578 if (r_alloc_freeze_level) 578 if (r_alloc_freeze_level)
579 abort (); 579 emacs_abort ();
580 580
581 if (bloc == NIL_BLOC || size == bloc->size) 581 if (bloc == NIL_BLOC || size == bloc->size)
582 return 1; 582 return 1;
@@ -588,7 +588,7 @@ resize_bloc (bloc_ptr bloc, SIZE size)
588 } 588 }
589 589
590 if (heap == NIL_HEAP) 590 if (heap == NIL_HEAP)
591 abort (); 591 emacs_abort ();
592 592
593 old_size = bloc->size; 593 old_size = bloc->size;
594 bloc->size = size; 594 bloc->size = size;
@@ -937,7 +937,7 @@ r_alloc_free (register POINTER *ptr)
937 937
938 dead_bloc = find_bloc (ptr); 938 dead_bloc = find_bloc (ptr);
939 if (dead_bloc == NIL_BLOC) 939 if (dead_bloc == NIL_BLOC)
940 abort (); /* Double free? PTR not originally used to allocate? */ 940 emacs_abort (); /* Double free? PTR not originally used to allocate? */
941 941
942 free_bloc (dead_bloc); 942 free_bloc (dead_bloc);
943 *ptr = 0; 943 *ptr = 0;
@@ -979,7 +979,7 @@ r_re_alloc (POINTER *ptr, SIZE size)
979 979
980 bloc = find_bloc (ptr); 980 bloc = find_bloc (ptr);
981 if (bloc == NIL_BLOC) 981 if (bloc == NIL_BLOC)
982 abort (); /* Already freed? PTR not originally used to allocate? */ 982 emacs_abort (); /* Already freed? PTR not originally used to allocate? */
983 983
984 if (size < bloc->size) 984 if (size < bloc->size)
985 { 985 {
@@ -1152,7 +1152,7 @@ r_alloc_reset_variable (POINTER *old, POINTER *new)
1152 } 1152 }
1153 1153
1154 if (bloc == NIL_BLOC || bloc->variable != old) 1154 if (bloc == NIL_BLOC || bloc->variable != old)
1155 abort (); /* Already freed? OLD not originally used to allocate? */ 1155 emacs_abort (); /* Already freed? OLD not originally used to allocate? */
1156 1156
1157 /* Update variable to point to the new location. */ 1157 /* Update variable to point to the new location. */
1158 bloc->variable = new; 1158 bloc->variable = new;
@@ -1193,7 +1193,7 @@ r_alloc_init (void)
1193 first_heap->start = first_heap->bloc_start 1193 first_heap->start = first_heap->bloc_start
1194 = virtual_break_value = break_value = (*real_morecore) (0); 1194 = virtual_break_value = break_value = (*real_morecore) (0);
1195 if (break_value == NIL) 1195 if (break_value == NIL)
1196 abort (); 1196 emacs_abort ();
1197 1197
1198 extra_bytes = ROUNDUP (50000); 1198 extra_bytes = ROUNDUP (50000);
1199#endif 1199#endif
@@ -1204,9 +1204,15 @@ r_alloc_init (void)
1204 UNBLOCK_INPUT; 1204 UNBLOCK_INPUT;
1205#else 1205#else
1206#ifndef SYSTEM_MALLOC 1206#ifndef SYSTEM_MALLOC
1207 /* Give GNU malloc's morecore some hysteresis 1207 /* Give GNU malloc's morecore some hysteresis so that we move all
1208 so that we move all the relocatable blocks much less often. */ 1208 the relocatable blocks much less often. The number used to be
1209 __malloc_extra_blocks = 64; 1209 64, but alloc.c would override that with 32 in code that was
1210 removed when SYNC_INPUT became the only input handling mode.
1211 That code was conditioned on !DOUG_LEA_MALLOC, so the call to
1212 mallopt above is left unchanged. (Actually, I think there's no
1213 system nowadays that uses DOUG_LEA_MALLOC and also uses
1214 REL_ALLOC.) */
1215 __malloc_extra_blocks = 32;
1210#endif 1216#endif
1211#endif 1217#endif
1212 1218
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 @@
126 that make sense only in Emacs. */ 126 that make sense only in Emacs. */
127#ifdef emacs 127#ifdef emacs
128 128
129# include <setjmp.h>
130# include "lisp.h" 129# include "lisp.h"
131# include "character.h" 130# include "character.h"
132# include "buffer.h" 131# include "buffer.h"
@@ -1832,9 +1831,9 @@ typedef struct
1832/* The next available element. */ 1831/* The next available element. */
1833#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) 1832#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
1834 1833
1835/* Explicit quit checking is only used on NTemacs and whenever we 1834/* Explicit quit checking is needed for Emacs, which uses polling to
1836 use polling to process input events. */ 1835 process input events. */
1837#if defined emacs && (defined WINDOWSNT || defined SYNC_INPUT) && defined QUIT 1836#ifdef emacs
1838extern int immediate_quit; 1837extern int immediate_quit;
1839# define IMMEDIATE_QUIT_CHECK \ 1838# define IMMEDIATE_QUIT_CHECK \
1840 do { \ 1839 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "character.h" 26#include "character.h"
@@ -194,7 +193,7 @@ find_cache_boundary (struct region_cache *c, ptrdiff_t pos)
194 if (BOUNDARY_POS (c, low) > pos 193 if (BOUNDARY_POS (c, low) > pos
195 || (low + 1 < c->cache_len 194 || (low + 1 < c->cache_len
196 && BOUNDARY_POS (c, low + 1) <= pos)) 195 && BOUNDARY_POS (c, low + 1) <= pos))
197 abort (); 196 emacs_abort ();
198 197
199 return low; 198 return low;
200} 199}
@@ -217,12 +216,12 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
217 216
218 if (pos < 0 217 if (pos < 0
219 || pos > c->cache_len) 218 || pos > c->cache_len)
220 abort (); 219 emacs_abort ();
221 220
222 /* We mustn't ever try to put the gap before the dummy start 221 /* We mustn't ever try to put the gap before the dummy start
223 boundary. That must always be start-relative. */ 222 boundary. That must always be start-relative. */
224 if (pos == 0) 223 if (pos == 0)
225 abort (); 224 emacs_abort ();
226 225
227 /* Need we move the gap right? */ 226 /* Need we move the gap right? */
228 while (gap_start < pos) 227 while (gap_start < pos)
@@ -291,24 +290,24 @@ insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
291{ 290{
292 /* i must be a valid cache index. */ 291 /* i must be a valid cache index. */
293 if (i < 0 || i > c->cache_len) 292 if (i < 0 || i > c->cache_len)
294 abort (); 293 emacs_abort ();
295 294
296 /* We must never want to insert something before the dummy first 295 /* We must never want to insert something before the dummy first
297 boundary. */ 296 boundary. */
298 if (i == 0) 297 if (i == 0)
299 abort (); 298 emacs_abort ();
300 299
301 /* We must only be inserting things in order. */ 300 /* We must only be inserting things in order. */
302 if (! (BOUNDARY_POS (c, i - 1) < pos 301 if (! (BOUNDARY_POS (c, i - 1) < pos
303 && (i == c->cache_len 302 && (i == c->cache_len
304 || pos < BOUNDARY_POS (c, i)))) 303 || pos < BOUNDARY_POS (c, i))))
305 abort (); 304 emacs_abort ();
306 305
307 /* The value must be different from the ones around it. However, we 306 /* The value must be different from the ones around it. However, we
308 temporarily create boundaries that establish the same value as 307 temporarily create boundaries that establish the same value as
309 the subsequent boundary, so we're not going to flag that case. */ 308 the subsequent boundary, so we're not going to flag that case. */
310 if (BOUNDARY_VALUE (c, i - 1) == value) 309 if (BOUNDARY_VALUE (c, i - 1) == value)
311 abort (); 310 emacs_abort ();
312 311
313 move_cache_gap (c, i, 1); 312 move_cache_gap (c, i, 1);
314 313
@@ -331,16 +330,16 @@ delete_cache_boundaries (struct region_cache *c,
331 /* Gotta be in range. */ 330 /* Gotta be in range. */
332 if (start < 0 331 if (start < 0
333 || end > c->cache_len) 332 || end > c->cache_len)
334 abort (); 333 emacs_abort ();
335 334
336 /* Gotta be in order. */ 335 /* Gotta be in order. */
337 if (start > end) 336 if (start > end)
338 abort (); 337 emacs_abort ();
339 338
340 /* Can't delete the dummy entry. */ 339 /* Can't delete the dummy entry. */
341 if (start == 0 340 if (start == 0
342 && end >= 1) 341 && end >= 1)
343 abort (); 342 emacs_abort ();
344 343
345 /* Minimize gap motion. If we're deleting nothing, do nothing. */ 344 /* Minimize gap motion. If we're deleting nothing, do nothing. */
346 if (len == 0) 345 if (len == 0)
@@ -380,10 +379,10 @@ set_cache_region (struct region_cache *c,
380 ptrdiff_t start, ptrdiff_t end, int value) 379 ptrdiff_t start, ptrdiff_t end, int value)
381{ 380{
382 if (start > end) 381 if (start > end)
383 abort (); 382 emacs_abort ();
384 if (start < c->buffer_beg 383 if (start < c->buffer_beg
385 || end > c->buffer_end) 384 || end > c->buffer_end)
386 abort (); 385 emacs_abort ();
387 386
388 /* Eliminate this case; then we can assume that start and end-1 are 387 /* Eliminate this case; then we can assume that start and end-1 are
389 both the locations of real characters in the buffer. */ 388 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "termchar.h" 26#include "termchar.h"
27#include "dispextern.h" 27#include "dispextern.h"
@@ -195,13 +195,13 @@ calculate_scrolling (FRAME_PTR frame,
195 { 195 {
196 cost = p1->writecost + first_insert_cost[i]; 196 cost = p1->writecost + first_insert_cost[i];
197 if ((int) p1->insertcount > i) 197 if ((int) p1->insertcount > i)
198 abort (); 198 emacs_abort ();
199 cost1 = p1->insertcost + next_insert_cost[i - p1->insertcount]; 199 cost1 = p1->insertcost + next_insert_cost[i - p1->insertcount];
200 } 200 }
201 p->insertcost = min (cost, cost1) + draw_cost[i] + extra_cost; 201 p->insertcost = min (cost, cost1) + draw_cost[i] + extra_cost;
202 p->insertcount = (cost < cost1) ? 1 : p1->insertcount + 1; 202 p->insertcount = (cost < cost1) ? 1 : p1->insertcount + 1;
203 if ((int) p->insertcount > i) 203 if ((int) p->insertcount > i)
204 abort (); 204 emacs_abort ();
205 205
206 /* Calculate the cost if we do a delete line after 206 /* Calculate the cost if we do a delete line after
207 outputting this line. 207 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/>. */
20 20
21 21
22#include <config.h> 22#include <config.h>
23#include <setjmp.h> 23
24#include "lisp.h" 24#include "lisp.h"
25#include "syntax.h" 25#include "syntax.h"
26#include "category.h" 26#include "category.h"
@@ -1009,7 +1009,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
1009 if (!EQ (noerror, Qt)) 1009 if (!EQ (noerror, Qt))
1010 { 1010 {
1011 if (lim < BEGV || lim > ZV) 1011 if (lim < BEGV || lim > ZV)
1012 abort (); 1012 emacs_abort ();
1013 SET_PT_BOTH (lim, lim_byte); 1013 SET_PT_BOTH (lim, lim_byte);
1014 return Qnil; 1014 return Qnil;
1015#if 0 /* This would be clean, but maybe programs depend on 1015#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,
1022 } 1022 }
1023 1023
1024 if (np < BEGV || np > ZV) 1024 if (np < BEGV || np > ZV)
1025 abort (); 1025 emacs_abort ();
1026 1026
1027 SET_PT (np); 1027 SET_PT (np);
1028 1028
@@ -2770,7 +2770,7 @@ Return value is undefined if the last search failed. */)
2770 } 2770 }
2771 else 2771 else
2772 /* last_thing_searched must always be Qt, a buffer, or Qnil. */ 2772 /* last_thing_searched must always be Qt, a buffer, or Qnil. */
2773 abort (); 2773 emacs_abort ();
2774 2774
2775 len = 2 * i + 2; 2775 len = 2 * i + 2;
2776 } 2776 }
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/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h> 23
24#include "lisp.h" 24#include "lisp.h"
25 25
26#include <unistd.h> 26#include <unistd.h>
@@ -93,4 +93,3 @@ report_sheap_usage (int die_if_pure_storage_exceeded)
93 bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE); 93 bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE);
94 message ("%s", buf); 94 message ("%s", buf);
95} 95}
96
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/>. */
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <errno.h> 46#include <errno.h>
47#include <setjmp.h> 47
48#include "lisp.h" 48#include "lisp.h"
49#include "dispextern.h" 49#include "dispextern.h"
50#include "atimer.h" 50#include "atimer.h"
51#include <signal.h>
52#include "syssignal.h" 51#include "syssignal.h"
53/* END: Common Includes */ 52/* END: Common Includes */
54 53
@@ -315,8 +314,13 @@ sound_perror (const char *msg)
315 int saved_errno = errno; 314 int saved_errno = errno;
316 315
317 turn_on_atimers (1); 316 turn_on_atimers (1);
318#ifdef SIGIO 317#ifdef USABLE_SIGIO
319 sigunblock (sigmask (SIGIO)); 318 {
319 sigset_t unblocked;
320 sigemptyset (&unblocked);
321 sigaddset (&unblocked, SIGIO);
322 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
323 }
320#endif 324#endif
321 if (saved_errno != 0) 325 if (saved_errno != 0)
322 error ("%s: %s", msg, strerror (saved_errno)); 326 error ("%s: %s", msg, strerror (saved_errno));
@@ -728,6 +732,9 @@ static void
728vox_configure (struct sound_device *sd) 732vox_configure (struct sound_device *sd)
729{ 733{
730 int val; 734 int val;
735#ifdef USABLE_SIGIO
736 sigset_t blocked;
737#endif
731 738
732 eassert (sd->fd >= 0); 739 eassert (sd->fd >= 0);
733 740
@@ -735,8 +742,10 @@ vox_configure (struct sound_device *sd)
735 interrupted by a signal. Block the ones we know to cause 742 interrupted by a signal. Block the ones we know to cause
736 troubles. */ 743 troubles. */
737 turn_on_atimers (0); 744 turn_on_atimers (0);
738#ifdef SIGIO 745#ifdef USABLE_SIGIO
739 sigblock (sigmask (SIGIO)); 746 sigemptyset (&blocked);
747 sigaddset (&blocked, SIGIO);
748 pthread_sigmask (SIG_BLOCK, &blocked, 0);
740#endif 749#endif
741 750
742 val = sd->format; 751 val = sd->format;
@@ -769,8 +778,8 @@ vox_configure (struct sound_device *sd)
769 } 778 }
770 779
771 turn_on_atimers (1); 780 turn_on_atimers (1);
772#ifdef SIGIO 781#ifdef USABLE_SIGIO
773 sigunblock (sigmask (SIGIO)); 782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
774#endif 783#endif
775} 784}
776 785
@@ -785,8 +794,11 @@ vox_close (struct sound_device *sd)
785 /* On GNU/Linux, it seems that the device driver doesn't like to 794 /* On GNU/Linux, it seems that the device driver doesn't like to
786 be interrupted by a signal. Block the ones we know to cause 795 be interrupted by a signal. Block the ones we know to cause
787 troubles. */ 796 troubles. */
788#ifdef SIGIO 797#ifdef USABLE_SIGIO
789 sigblock (sigmask (SIGIO)); 798 sigset_t blocked;
799 sigemptyset (&blocked);
800 sigaddset (&blocked, SIGIO);
801 pthread_sigmask (SIG_BLOCK, &blocked, 0);
790#endif 802#endif
791 turn_on_atimers (0); 803 turn_on_atimers (0);
792 804
@@ -794,8 +806,8 @@ vox_close (struct sound_device *sd)
794 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); 806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
795 807
796 turn_on_atimers (1); 808 turn_on_atimers (1);
797#ifdef SIGIO 809#ifdef USABLE_SIGIO
798 sigunblock (sigmask (SIGIO)); 810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
799#endif 811#endif
800 812
801 /* Close the device. */ 813 /* Close the device. */
@@ -843,7 +855,7 @@ vox_choose_format (struct sound_device *sd, struct sound *s)
843 } 855 }
844 } 856 }
845 else 857 else
846 abort (); 858 emacs_abort ();
847} 859}
848 860
849 861
@@ -1138,7 +1150,7 @@ alsa_choose_format (struct sound_device *sd, struct sound *s)
1138 } 1150 }
1139 } 1151 }
1140 else 1152 else
1141 abort (); 1153 emacs_abort ();
1142} 1154}
1143 1155
1144 1156
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/>. */
21#include <config.h> 21#include <config.h>
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "commands.h" 26#include "commands.h"
27#include "character.h" 27#include "character.h"
@@ -921,11 +921,11 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0,
921} 921}
922 922
923DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0, 923DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0,
924 doc: /* Convert a syntax specification STRING into syntax cell form. 924 doc: /* Convert a syntax descriptor STRING into a raw syntax descriptor.
925STRING should be a string as it is allowed as argument of 925STRING should be a string of the form allowed as argument of
926`modify-syntax-entry'. Value is the equivalent cons cell 926`modify-syntax-entry'. The return value is a raw syntax descriptor: a
927\(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table' 927cons cell \(CODE . MATCHING-CHAR) which can be used, for example, as
928text property. */) 928the value of a `syntax-table' text property. */)
929 (Lisp_Object string) 929 (Lisp_Object string)
930{ 930{
931 register const unsigned char *p; 931 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/>. */
21 21
22#define SYSTIME_INLINE EXTERN_INLINE 22#define SYSTIME_INLINE EXTERN_INLINE
23 23
24#include <signal.h> 24#include <execinfo.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27#ifdef HAVE_PWD_H 26#ifdef HAVE_PWD_H
28#include <pwd.h> 27#include <pwd.h>
29#include <grp.h> 28#include <grp.h>
@@ -107,9 +106,6 @@ extern char *getwd (char *);
107 106
108static int emacs_get_tty (int, struct emacs_tty *); 107static int emacs_get_tty (int, struct emacs_tty *);
109static int emacs_set_tty (int, struct emacs_tty *, int); 108static int emacs_set_tty (int, struct emacs_tty *, int);
110#if defined TIOCNOTTY || defined USG5 || defined CYGWIN
111static _Noreturn void croak (char *);
112#endif
113 109
114/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ 110/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
115#ifndef ULLONG_MAX 111#ifndef ULLONG_MAX
@@ -302,27 +298,34 @@ wait_for_termination_1 (pid_t pid, int interruptible)
302 termination of subprocesses, perhaps involving a kernel bug too, 298 termination of subprocesses, perhaps involving a kernel bug too,
303 but no idea what it is. Just as a hunch we signal SIGCHLD to see 299 but no idea what it is. Just as a hunch we signal SIGCHLD to see
304 if that causes the problem to go away or get worse. */ 300 if that causes the problem to go away or get worse. */
305 sigsetmask (sigmask (SIGCHLD)); 301 sigset_t sigchild_mask;
302 sigemptyset (&sigchild_mask);
303 sigaddset (&sigchild_mask, SIGCHLD);
304 pthread_sigmask (SIG_SETMASK, &sigchild_mask, 0);
305
306 if (0 > kill (pid, 0)) 306 if (0 > kill (pid, 0))
307 { 307 {
308 sigsetmask (SIGEMPTYMASK); 308 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
309 kill (getpid (), SIGCHLD); 309 kill (getpid (), SIGCHLD);
310 break; 310 break;
311 } 311 }
312 if (wait_debugging) 312 if (wait_debugging)
313 sleep (1); 313 sleep (1);
314 else 314 else
315 sigpause (SIGEMPTYMASK); 315 sigsuspend (&empty_mask);
316#else /* not BSD_SYSTEM, and not HPUX version >= 6 */ 316#else /* not BSD_SYSTEM, and not HPUX version >= 6 */
317#ifdef WINDOWSNT 317#ifdef WINDOWSNT
318 wait (0); 318 wait (0);
319 break; 319 break;
320#else /* not WINDOWSNT */ 320#else /* not WINDOWSNT */
321 sigblock (sigmask (SIGCHLD)); 321 sigset_t blocked;
322 sigemptyset (&blocked);
323 sigaddset (&blocked, SIGCHLD);
324 pthread_sigmask (SIG_BLOCK, &blocked, 0);
322 errno = 0; 325 errno = 0;
323 if (kill (pid, 0) == -1 && errno == ESRCH) 326 if (kill (pid, 0) == -1 && errno == ESRCH)
324 { 327 {
325 sigunblock (sigmask (SIGCHLD)); 328 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
326 break; 329 break;
327 } 330 }
328 331
@@ -456,11 +459,11 @@ child_setup_tty (int out)
456#endif /* not MSDOS */ 459#endif /* not MSDOS */
457 460
458 461
459/* Record a signal code and the handler for it. */ 462/* Record a signal code and the action for it. */
460struct save_signal 463struct save_signal
461{ 464{
462 int code; 465 int code;
463 void (*handler) (int); 466 struct sigaction action;
464}; 467};
465 468
466static void save_signal_handlers (struct save_signal *); 469static void save_signal_handlers (struct save_signal *);
@@ -506,7 +509,7 @@ sys_subshell (void)
506 saved_handlers[0].code = SIGINT; 509 saved_handlers[0].code = SIGINT;
507 saved_handlers[1].code = SIGQUIT; 510 saved_handlers[1].code = SIGQUIT;
508 saved_handlers[2].code = SIGTERM; 511 saved_handlers[2].code = SIGTERM;
509#ifdef SIGIO 512#ifdef USABLE_SIGIO
510 saved_handlers[3].code = SIGIO; 513 saved_handlers[3].code = SIGIO;
511 saved_handlers[4].code = 0; 514 saved_handlers[4].code = 0;
512#else 515#else
@@ -618,8 +621,9 @@ save_signal_handlers (struct save_signal *saved_handlers)
618{ 621{
619 while (saved_handlers->code) 622 while (saved_handlers->code)
620 { 623 {
621 saved_handlers->handler 624 struct sigaction action;
622 = (void (*) (int)) signal (saved_handlers->code, SIG_IGN); 625 emacs_sigaction_init (&action, SIG_IGN);
626 sigaction (saved_handlers->code, &action, &saved_handlers->action);
623 saved_handlers++; 627 saved_handlers++;
624 } 628 }
625} 629}
@@ -629,118 +633,80 @@ restore_signal_handlers (struct save_signal *saved_handlers)
629{ 633{
630 while (saved_handlers->code) 634 while (saved_handlers->code)
631 { 635 {
632 signal (saved_handlers->code, saved_handlers->handler); 636 sigaction (saved_handlers->code, &saved_handlers->action, 0);
633 saved_handlers++; 637 saved_handlers++;
634 } 638 }
635} 639}
636 640
637#ifndef SIGIO 641#ifdef USABLE_SIGIO
638/* If SIGIO is broken, don't do anything. */
639void
640init_sigio (int fd)
641{
642}
643
644static void
645reset_sigio (int fd)
646{
647}
648
649void
650request_sigio (void)
651{
652}
653
654void
655unrequest_sigio (void)
656{
657}
658
659#else
660#ifdef F_SETFL
661
662static int old_fcntl_flags[MAXDESC]; 642static int old_fcntl_flags[MAXDESC];
643#endif
663 644
664void 645void
665init_sigio (int fd) 646init_sigio (int fd)
666{ 647{
667#ifdef FASYNC 648#ifdef USABLE_SIGIO
668 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; 649 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
669 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); 650 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC);
670#endif
671 interrupts_deferred = 0; 651 interrupts_deferred = 0;
652#endif
672} 653}
673 654
674static void 655static void
675reset_sigio (int fd) 656reset_sigio (int fd)
676{ 657{
677#ifdef FASYNC 658#ifdef USABLE_SIGIO
678 fcntl (fd, F_SETFL, old_fcntl_flags[fd]); 659 fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
679#endif 660#endif
680} 661}
681 662
682#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
683/* XXX Uhm, FASYNC is not used anymore here. */
684/* XXX Yeah, but you need it for SIGIO, don't you? */
685
686void 663void
687request_sigio (void) 664request_sigio (void)
688{ 665{
666#ifdef USABLE_SIGIO
667 sigset_t unblocked;
668
689 if (noninteractive) 669 if (noninteractive)
690 return; 670 return;
691 671
692#ifdef SIGWINCH 672 sigemptyset (&unblocked);
693 sigunblock (sigmask (SIGWINCH)); 673# ifdef SIGWINCH
694#endif 674 sigaddset (&unblocked, SIGWINCH);
695 sigunblock (sigmask (SIGIO)); 675# endif
676 sigaddset (&unblocked, SIGIO);
677 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
696 678
697 interrupts_deferred = 0; 679 interrupts_deferred = 0;
680#endif
698} 681}
699 682
700void 683void
701unrequest_sigio (void) 684unrequest_sigio (void)
702{ 685{
703 if (noninteractive) 686#ifdef USABLE_SIGIO
704 return; 687 sigset_t blocked;
705 688
706#if 0 /* XXX What's wrong with blocking SIGIO under X? */ 689 if (noninteractive)
707 if (x_display_list)
708 return; 690 return;
709#endif
710 691
711#ifdef SIGWINCH 692 sigemptyset (&blocked);
712 sigblock (sigmask (SIGWINCH)); 693# ifdef SIGWINCH
713#endif 694 sigaddset (&blocked, SIGWINCH);
714 sigblock (sigmask (SIGIO)); 695# endif
696 sigaddset (&blocked, SIGIO);
697 pthread_sigmask (SIG_BLOCK, &blocked, 0);
715 interrupts_deferred = 1; 698 interrupts_deferred = 1;
716} 699#endif
717
718#else /* no FASYNC */
719#ifndef MSDOS
720
721void
722request_sigio (void)
723{
724 if (noninteractive || read_socket_hook)
725 return;
726
727 croak ("request_sigio");
728} 700}
729 701
730void 702void
731unrequest_sigio (void) 703ignore_sigio (void)
732{ 704{
733 if (noninteractive || read_socket_hook) 705#ifdef USABLE_SIGIO
734 return; 706 signal (SIGIO, SIG_IGN);
735 707#endif
736 croak ("unrequest_sigio");
737} 708}
738 709
739#endif /* MSDOS */
740#endif /* FASYNC */
741#endif /* F_SETFL */
742#endif /* SIGIO */
743
744 710
745/* Getting and setting emacs_tty structures. */ 711/* Getting and setting emacs_tty structures. */
746 712
@@ -1470,86 +1436,64 @@ init_system_name (void)
1470 } 1436 }
1471} 1437}
1472 1438
1473/* POSIX signals support - DJB */
1474/* Anyone with POSIX signals should have ANSI C declarations */
1475
1476sigset_t empty_mask; 1439sigset_t empty_mask;
1477 1440
1478#ifndef WINDOWSNT 1441/* Store into *ACTION a signal action suitable for Emacs, with handler
1479 1442 HANDLER. */
1480signal_handler_t 1443void
1481sys_signal (int signal_number, signal_handler_t action) 1444emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1482{ 1445{
1483 struct sigaction new_action, old_action; 1446 sigemptyset (&action->sa_mask);
1484 sigemptyset (&new_action.sa_mask); 1447 action->sa_handler = handler;
1485 new_action.sa_handler = action; 1448 action->sa_flags = 0;
1486 new_action.sa_flags = 0;
1487#if defined (SA_RESTART) 1449#if defined (SA_RESTART)
1488 /* Emacs mostly works better with restartable system services. If this 1450 /* SA_RESTART causes interruptible functions with timeouts (e.g.,
1489 flag exists, we probably want to turn it on here. 1451 'select') to reset their timeout on some platforms (e.g.,
1490 However, on some systems (only hpux11 at present) this resets the 1452 HP-UX 11), which is not what we want. Also, when Emacs is
1491 timeout of `select' which means that `select' never finishes if 1453 interactive, we don't want SA_RESTART because we need to poll
1492 it keeps getting signals.
1493 We define BROKEN_SA_RESTART on those systems. */
1494 /* It's not clear why the comment above says "mostly works better". --Stef
1495 When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
1496 for pending input so we need long-running syscalls to be interrupted 1454 for pending input so we need long-running syscalls to be interrupted
1497 after a signal that sets the interrupt_input_pending flag. */ 1455 after a signal that sets the interrupt_input_pending flag. */
1498 /* Non-interactive keyboard input goes through stdio, where we always 1456 /* Non-interactive keyboard input goes through stdio, where we always
1499 want restartable system calls. */ 1457 want restartable system calls. */
1500# if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT)
1501 if (noninteractive) 1458 if (noninteractive)
1502# endif 1459 action->sa_flags = SA_RESTART;
1503 new_action.sa_flags = SA_RESTART;
1504#endif 1460#endif
1505 sigaction (signal_number, &new_action, &old_action);
1506 return (old_action.sa_handler);
1507} 1461}
1508 1462
1509#endif /* WINDOWSNT */ 1463#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1510 1464static pthread_t main_thread;
1511#ifndef __GNUC__
1512/* If we're compiling with GCC, we don't need this function, since it
1513 can be written as a macro. */
1514sigset_t
1515sys_sigmask (int sig)
1516{
1517 sigset_t mask;
1518 sigemptyset (&mask);
1519 sigaddset (&mask, sig);
1520 return mask;
1521}
1522#endif 1465#endif
1523 1466
1524/* I'd like to have these guys return pointers to the mask storage in here, 1467/* If we are on the main thread, handle the signal SIG with HANDLER.
1525 but there'd be trouble if the code was saving multiple masks. I'll be 1468 Otherwise, redirect the signal to the main thread, blocking it from
1526 safe and pass the structure. It normally won't be more than 2 bytes 1469 this thread. POSIX says any thread can receive a signal that is
1527 anyhow. - DJB */ 1470 associated with a process, process group, or asynchronous event.
1528 1471 On GNU/Linux that is not true, but for other systems (FreeBSD at
1529sigset_t 1472 least) it is. */
1530sys_sigblock (sigset_t new_mask) 1473void
1474handle_on_main_thread (int sig, signal_handler_t handler)
1531{ 1475{
1532 sigset_t old_mask; 1476 /* Preserve errno, to avoid race conditions with signal handlers that
1533 pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); 1477 might change errno. Races can occur even in single-threaded hosts. */
1534 return (old_mask); 1478 int old_errno = errno;
1535}
1536 1479
1537sigset_t 1480 bool on_main_thread = true;
1538sys_sigunblock (sigset_t new_mask) 1481#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1539{ 1482 if (! pthread_equal (pthread_self (), main_thread))
1540 sigset_t old_mask; 1483 {
1541 pthread_sigmask (SIG_UNBLOCK, &new_mask, &old_mask); 1484 sigset_t blocked;
1542 return (old_mask); 1485 sigemptyset (&blocked);
1543} 1486 sigaddset (&blocked, sig);
1487 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1488 pthread_kill (main_thread, sig);
1489 on_main_thread = false;
1490 }
1491#endif
1492 if (on_main_thread)
1493 handler (sig);
1544 1494
1545sigset_t 1495 errno = old_errno;
1546sys_sigsetmask (sigset_t new_mask)
1547{
1548 sigset_t old_mask;
1549 pthread_sigmask (SIG_SETMASK, &new_mask, &old_mask);
1550 return (old_mask);
1551} 1496}
1552
1553 1497
1554#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1498#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1555static char *my_sys_siglist[NSIG]; 1499static char *my_sys_siglist[NSIG];
@@ -1564,6 +1508,10 @@ init_signals (void)
1564{ 1508{
1565 sigemptyset (&empty_mask); 1509 sigemptyset (&empty_mask);
1566 1510
1511#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1512 main_thread = pthread_self ();
1513#endif
1514
1567#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1515#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1568 if (! initialized) 1516 if (! initialized)
1569 { 1517 {
@@ -1856,6 +1804,33 @@ snprintf (char *buf, size_t bufsize, char const *format, ...)
1856} 1804}
1857#endif 1805#endif
1858 1806
1807/* If a backtrace is available, output the top lines of it to stderr.
1808 Do not output more than BACKTRACE_LIMIT or BACKTRACE_LIMIT_MAX lines.
1809 This function may be called from a signal handler, so it should
1810 not invoke async-unsafe functions like malloc. */
1811void
1812emacs_backtrace (int backtrace_limit)
1813{
1814 enum { BACKTRACE_LIMIT_MAX = 500 };
1815 void *buffer[BACKTRACE_LIMIT_MAX + 1];
1816 int bounded_limit = min (backtrace_limit, BACKTRACE_LIMIT_MAX);
1817 int npointers = backtrace (buffer, bounded_limit + 1);
1818 if (npointers)
1819 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12));
1820 backtrace_symbols_fd (buffer, bounded_limit, STDERR_FILENO);
1821 if (bounded_limit < npointers)
1822 ignore_value (write (STDERR_FILENO, "...\n", 4));
1823}
1824
1825#ifndef HAVE_NTGUI
1826/* Using emacs_abort lets GDB return from a breakpoint here. */
1827void
1828emacs_abort (void)
1829{
1830 fatal_error_backtrace (SIGABRT, 10);
1831}
1832#endif
1833
1859int 1834int
1860emacs_open (const char *path, int oflag, int mode) 1835emacs_open (const char *path, int oflag, int mode)
1861{ 1836{
@@ -1933,11 +1908,9 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte)
1933 { 1908 {
1934 if (errno == EINTR) 1909 if (errno == EINTR)
1935 { 1910 {
1936#ifdef SYNC_INPUT
1937 /* I originally used `QUIT' but that might causes files to 1911 /* I originally used `QUIT' but that might causes files to
1938 be truncated if you hit C-g in the middle of it. --Stef */ 1912 be truncated if you hit C-g in the middle of it. --Stef */
1939 process_pending_signals (); 1913 process_pending_signals ();
1940#endif
1941 continue; 1914 continue;
1942 } 1915 }
1943 else 1916 else
@@ -2020,19 +1993,6 @@ getwd (char *pathname)
2020} 1993}
2021 1994
2022#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ 1995#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */
2023
2024/*
2025 * This function will go away as soon as all the stubs fixed. (fnf)
2026 */
2027
2028void
2029croak (char *badfunc)
2030{
2031 printf ("%s not yet implemented\r\n", badfunc);
2032 reset_all_sys_modes ();
2033 exit (1);
2034}
2035
2036#endif /* USG */ 1996#endif /* USG */
2037 1997
2038/* Directory routines for systems that don't have them. */ 1998/* 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.
17You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <signal.h>
21
20extern void init_signals (void); 22extern void init_signals (void);
21 23
22#ifdef HAVE_PTHREAD 24#ifdef HAVE_PTHREAD
@@ -26,83 +28,14 @@ extern void init_signals (void);
26#define FORWARD_SIGNAL_TO_MAIN_THREAD 28#define FORWARD_SIGNAL_TO_MAIN_THREAD
27#endif 29#endif
28 30
29/* Don't #include <signal.h>. That header should always be #included
30 before "config.h", because some configuration files (like s/hpux.h)
31 indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file
32 #includes <signal.h>, then that will re-#define SIGIO and confuse
33 things. */
34/* XXX This is not correct anymore, there is a BROKEN_SIGIO macro. */
35
36#define SIGMASKTYPE sigset_t
37
38#define SIGEMPTYMASK (empty_mask)
39extern sigset_t empty_mask; 31extern sigset_t empty_mask;
40 32
41/* POSIX pretty much destroys any possibility of writing sigmask as a
42 macro in standard C. We always define our own version because the
43 predefined macro in Glibc 2.1 is only provided for compatibility for old
44 programs that use int as signal mask type. */
45#undef sigmask
46#ifdef __GNUC__
47#define sigmask(SIG) \
48 ({ \
49 sigset_t _mask; \
50 sigemptyset (&_mask); \
51 sigaddset (&_mask, SIG); \
52 _mask; \
53 })
54#else /* ! defined (__GNUC__) */
55extern sigset_t sys_sigmask ();
56#define sigmask(SIG) (sys_sigmask (SIG))
57#endif /* ! defined (__GNUC__) */
58
59#undef sigpause
60#define sigpause(MASK) sigsuspend (&(MASK))
61
62#define sigblock(SIG) sys_sigblock (SIG)
63#define sigunblock(SIG) sys_sigunblock (SIG)
64#ifndef sigsetmask
65#define sigsetmask(SIG) sys_sigsetmask (SIG)
66#endif
67#undef signal
68#define signal(SIG,ACT) sys_signal(SIG,ACT)
69
70/* Whether this is what all systems want or not, this is what
71 appears to be assumed in the source, for example data.c:arith_error. */
72typedef void (*signal_handler_t) (int); 33typedef void (*signal_handler_t) (int);
73 34
74signal_handler_t sys_signal (int signal_number, signal_handler_t action); 35extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
75sigset_t sys_sigblock (sigset_t new_mask);
76sigset_t sys_sigunblock (sigset_t new_mask);
77sigset_t sys_sigsetmask (sigset_t new_mask);
78#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN)
79_Noreturn void croak (char *);
80#endif
81
82#define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
83
84#define sigfree() sigsetmask (SIGEMPTYMASK)
85
86#if defined (SIGIO) && defined (BROKEN_SIGIO)
87# undef SIGIO
88#endif
89/* These are only used by AIX */
90#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
91#undef SIGPOLL
92#endif
93#if defined (SIGAIO) && defined (BROKEN_SIGAIO)
94#undef SIGAIO
95#endif
96#if defined (SIGPTY) && defined (BROKEN_SIGPTY)
97#undef SIGPTY
98#endif
99
100 36
101/* FIXME? Emacs only defines NSIG_MINIMUM on some platforms? */
102#if NSIG < NSIG_MINIMUM 37#if NSIG < NSIG_MINIMUM
103# ifdef NSIG 38# undef NSIG
104# undef NSIG
105# endif
106# define NSIG NSIG_MINIMUM 39# define NSIG NSIG_MINIMUM
107#endif 40#endif
108 41
@@ -131,26 +64,4 @@ _Noreturn void croak (char *);
131char *strsignal (int); 64char *strsignal (int);
132#endif 65#endif
133 66
134#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 67void handle_on_main_thread (int, signal_handler_t);
135extern pthread_t main_thread;
136#define SIGNAL_THREAD_CHECK(signo) \
137 do { \
138 if (!pthread_equal (pthread_self (), main_thread)) \
139 { \
140 /* POSIX says any thread can receive the signal. On GNU/Linux \
141 that is not true, but for other systems (FreeBSD at least) \
142 it is. So direct the signal to the correct thread and block \
143 it from this thread. */ \
144 sigset_t new_mask; \
145 \
146 sigemptyset (&new_mask); \
147 sigaddset (&new_mask, signo); \
148 pthread_sigmask (SIG_BLOCK, &new_mask, 0); \
149 pthread_kill (main_thread, signo); \
150 return; \
151 } \
152 } while (0)
153
154#else /* not FORWARD_SIGNAL_TO_MAIN_THREAD */
155#define SIGNAL_THREAD_CHECK(signo)
156#endif /* not FORWARD_SIGNAL_TO_MAIN_THREAD */
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
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19/* Include the proper files. */ 19/* Include the proper files. */
20
20#ifndef DOS_NT 21#ifndef DOS_NT
21#ifndef NO_TERMIO
22#include <termio.h>
23#endif /* not NO_TERMIO */
24#include <termios.h> 22#include <termios.h>
25#include <fcntl.h> 23#include <fcntl.h>
26#endif /* not DOS_NT */ 24#endif /* not DOS_NT */
@@ -39,20 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include <unistd.h> 37#include <unistd.h>
40 38
41 39
42/* Special cases - inhibiting the use of certain features. */
43
44/* Allow configure to inhibit use of FIONREAD. */
45#ifdef BROKEN_FIONREAD
46#undef FIONREAD
47#undef ASYNC
48#endif
49
50/* Interrupt input is not used if there is no FIONREAD. */
51#ifndef FIONREAD
52#undef SIGIO
53#endif
54
55
56/* Try to establish the correct character to disable terminal functions 40/* Try to establish the correct character to disable terminal functions
57 in a system-independent manner. Note that USG (at least) define 41 in a system-independent manner. Note that USG (at least) define
58 _POSIX_VDISABLE as 0! */ 42 _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/>. */
25#include <sys/file.h> 25#include <sys/file.h>
26#include <sys/time.h> 26#include <sys/time.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <signal.h>
29#include <setjmp.h>
30 28
31#include "lisp.h" 29#include "lisp.h"
32#include "termchar.h" 30#include "termchar.h"
@@ -1498,7 +1496,7 @@ append_glyph (struct it *it)
1498 { 1496 {
1499 glyph->resolved_level = it->bidi_it.resolved_level; 1497 glyph->resolved_level = it->bidi_it.resolved_level;
1500 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1498 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1501 abort (); 1499 emacs_abort ();
1502 glyph->bidi_type = it->bidi_it.type; 1500 glyph->bidi_type = it->bidi_it.type;
1503 } 1501 }
1504 else 1502 else
@@ -1695,7 +1693,7 @@ append_composite_glyph (struct it *it)
1695 { 1693 {
1696 glyph->resolved_level = it->bidi_it.resolved_level; 1694 glyph->resolved_level = it->bidi_it.resolved_level;
1697 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1695 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1698 abort (); 1696 emacs_abort ();
1699 glyph->bidi_type = it->bidi_it.type; 1697 glyph->bidi_type = it->bidi_it.type;
1700 } 1698 }
1701 else 1699 else
@@ -1780,7 +1778,7 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1780 { 1778 {
1781 glyph->resolved_level = it->bidi_it.resolved_level; 1779 glyph->resolved_level = it->bidi_it.resolved_level;
1782 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1780 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1783 abort (); 1781 emacs_abort ();
1784 glyph->bidi_type = it->bidi_it.type; 1782 glyph->bidi_type = it->bidi_it.type;
1785 } 1783 }
1786 else 1784 else
@@ -2250,7 +2248,7 @@ get_named_tty (const char *name)
2250 struct terminal *t; 2248 struct terminal *t;
2251 2249
2252 if (!name) 2250 if (!name)
2253 abort (); 2251 emacs_abort ();
2254 2252
2255 for (t = terminal_list; t; t = t->next_terminal) 2253 for (t = terminal_list; t; t = t->next_terminal)
2256 { 2254 {
@@ -2798,7 +2796,7 @@ create_tty_output (struct frame *f)
2798 struct tty_output *t = xzalloc (sizeof *t); 2796 struct tty_output *t = xzalloc (sizeof *t);
2799 2797
2800 if (! FRAME_TERMCAP_P (f)) 2798 if (! FRAME_TERMCAP_P (f))
2801 abort (); 2799 emacs_abort ();
2802 2800
2803 t->display_info = FRAME_TERMINAL (f)->display_info.tty; 2801 t->display_info = FRAME_TERMINAL (f)->display_info.tty;
2804 2802
@@ -2811,7 +2809,7 @@ static void
2811tty_free_frame_resources (struct frame *f) 2809tty_free_frame_resources (struct frame *f)
2812{ 2810{
2813 if (! FRAME_TERMCAP_P (f)) 2811 if (! FRAME_TERMCAP_P (f))
2814 abort (); 2812 emacs_abort ();
2815 2813
2816 if (FRAME_FACE_CACHE (f)) 2814 if (FRAME_FACE_CACHE (f))
2817 free_frame_faces (f); 2815 free_frame_faces (f);
@@ -2827,7 +2825,7 @@ static void
2827tty_free_frame_resources (struct frame *f) 2825tty_free_frame_resources (struct frame *f)
2828{ 2826{
2829 if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f)) 2827 if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f))
2830 abort (); 2828 emacs_abort ();
2831 2829
2832 if (FRAME_FACE_CACHE (f)) 2830 if (FRAME_FACE_CACHE (f))
2833 free_frame_faces (f); 2831 free_frame_faces (f);
@@ -2932,7 +2930,10 @@ dissociate_if_controlling_tty (int fd)
2932 no_controlling_tty = 1; 2930 no_controlling_tty = 1;
2933#else 2931#else
2934#ifdef TIOCNOTTY /* Try BSD ioctls. */ 2932#ifdef TIOCNOTTY /* Try BSD ioctls. */
2935 sigblock (sigmask (SIGTTOU)); 2933 sigset_t blocked;
2934 sigemptyset (&blocked);
2935 sigaddset (&blocked, SIGTTOU);
2936 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2936 fd = emacs_open (DEV_TTY, O_RDWR, 0); 2937 fd = emacs_open (DEV_TTY, O_RDWR, 0);
2937 if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1) 2938 if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1)
2938 { 2939 {
@@ -2940,10 +2941,9 @@ dissociate_if_controlling_tty (int fd)
2940 } 2941 }
2941 if (fd != -1) 2942 if (fd != -1)
2942 emacs_close (fd); 2943 emacs_close (fd);
2943 sigunblock (sigmask (SIGTTOU)); 2944 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2944#else 2945#else
2945 /* Unknown system. */ 2946# error "Unknown system."
2946 croak ();
2947#endif /* ! TIOCNOTTY */ 2947#endif /* ! TIOCNOTTY */
2948#endif /* ! USG */ 2948#endif /* ! USG */
2949 } 2949 }
@@ -3074,9 +3074,14 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3074 3074
3075 /* On some systems, tgetent tries to access the controlling 3075 /* On some systems, tgetent tries to access the controlling
3076 terminal. */ 3076 terminal. */
3077 sigblock (sigmask (SIGTTOU)); 3077 {
3078 status = tgetent (tty->termcap_term_buffer, terminal_type); 3078 sigset_t blocked;
3079 sigunblock (sigmask (SIGTTOU)); 3079 sigemptyset (&blocked);
3080 sigaddset (&blocked, SIGTTOU);
3081 pthread_sigmask (SIG_BLOCK, &blocked, 0);
3082 status = tgetent (tty->termcap_term_buffer, terminal_type);
3083 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
3084 }
3080 3085
3081 if (status < 0) 3086 if (status < 0)
3082 { 3087 {
@@ -3108,7 +3113,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3108 3113
3109#ifndef TERMINFO 3114#ifndef TERMINFO
3110 if (strlen (tty->termcap_term_buffer) >= buffer_size) 3115 if (strlen (tty->termcap_term_buffer) >= buffer_size)
3111 abort (); 3116 emacs_abort ();
3112 buffer_size = strlen (tty->termcap_term_buffer); 3117 buffer_size = strlen (tty->termcap_term_buffer);
3113#endif 3118#endif
3114 tty->termcap_strings_buffer = area = xmalloc (buffer_size); 3119 tty->termcap_strings_buffer = area = xmalloc (buffer_size);
@@ -3467,7 +3472,7 @@ maybe_fatal (int must_succeed, struct terminal *terminal,
3467 verror (str1, ap); 3472 verror (str1, ap);
3468 3473
3469 va_end (ap); 3474 va_end (ap);
3470 abort (); 3475 emacs_abort ();
3471} 3476}
3472 3477
3473void 3478void
@@ -3494,7 +3499,7 @@ delete_tty (struct terminal *terminal)
3494 return; 3499 return;
3495 3500
3496 if (terminal->type != output_termcap) 3501 if (terminal->type != output_termcap)
3497 abort (); 3502 emacs_abort ();
3498 3503
3499 tty = terminal->display_info.tty; 3504 tty = terminal->display_info.tty;
3500 3505
@@ -3508,7 +3513,7 @@ delete_tty (struct terminal *terminal)
3508 3513
3509 if (! p) 3514 if (! p)
3510 /* This should not happen. */ 3515 /* This should not happen. */
3511 abort (); 3516 emacs_abort ();
3512 3517
3513 p->next = tty->next; 3518 p->next = tty->next;
3514 tty->next = 0; 3519 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. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23#include <sys/file.h> 22#include <sys/file.h>
24#include <fcntl.h> 23#include <fcntl.h>
25#include <unistd.h> 24#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;
207 (((f)->output_method == output_termcap \ 207 (((f)->output_method == output_termcap \
208 || (f)->output_method == output_msdos_raw) \ 208 || (f)->output_method == output_msdos_raw) \
209 ? (f)->terminal->display_info.tty \ 209 ? (f)->terminal->display_info.tty \
210 : (abort (), (struct tty_display_info *) 0)) 210 : (emacs_abort (), (struct tty_display_info *) 0))
211 211
212#define CURTTY() FRAME_TTY (SELECTED_FRAME()) 212#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/>. */
21#define TERMHOOKS_INLINE EXTERN_INLINE 21#define TERMHOOKS_INLINE EXTERN_INLINE
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "frame.h" 26#include "frame.h"
@@ -294,7 +293,7 @@ delete_terminal (struct terminal *terminal)
294 293
295 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal) 294 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
296 if (! *tp) 295 if (! *tp)
297 abort (); 296 emacs_abort ();
298 *tp = terminal->next_terminal; 297 *tp = terminal->next_terminal;
299 298
300 xfree (terminal->keyboard_coding); 299 xfree (terminal->keyboard_coding);
@@ -411,7 +410,7 @@ possible return values. */)
411 case output_ns: 410 case output_ns:
412 return Qns; 411 return Qns;
413 default: 412 default:
414 abort (); 413 emacs_abort ();
415 } 414 }
416} 415}
417 416
@@ -519,7 +518,7 @@ struct terminal *
519init_initial_terminal (void) 518init_initial_terminal (void)
520{ 519{
521 if (initialized || terminal_list || tty_list) 520 if (initialized || terminal_list || tty_list)
522 abort (); 521 emacs_abort ();
523 522
524 initial_terminal = create_terminal (); 523 initial_terminal = create_terminal ();
525 initial_terminal->type = output_initial; 524 initial_terminal->type = output_initial;
@@ -538,7 +537,7 @@ static void
538delete_initial_terminal (struct terminal *terminal) 537delete_initial_terminal (struct terminal *terminal)
539{ 538{
540 if (terminal != initial_terminal) 539 if (terminal != initial_terminal)
541 abort (); 540 emacs_abort ();
542 541
543 delete_terminal (terminal); 542 delete_terminal (terminal);
544 initial_terminal = NULL; 543 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/>. */
19#include <config.h> 19#include <config.h>
20#include "tparam.h" 20#include "tparam.h"
21 21
22#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.h"
24 23
25/* Define these variables that serve as global parameters to termcap, 24/* Define these variables that serve as global parameters to termcap,
@@ -46,7 +45,7 @@ tparam (const char *string, char *outstring, int len,
46 45
47 /* Emacs always should pass a null OUTSTRING and zero LEN. */ 46 /* Emacs always should pass a null OUTSTRING and zero LEN. */
48 if (outstring || len) 47 if (outstring || len)
49 abort (); 48 emacs_abort ();
50 49
51 temp = tparm (string, arg1, arg2, arg3, arg4); 50 temp = tparm (string, arg1, arg2, arg3, arg4);
52 return xstrdup (temp); 51 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
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <setjmp.h> 20
21#include "lisp.h" 21#include "lisp.h"
22#include "intervals.h" 22#include "intervals.h"
23#include "character.h" 23#include "character.h"
@@ -556,7 +556,8 @@ If POSITION is at the end of OBJECT, the value is nil. */)
556 556
557DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0, 557DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0,
558 doc: /* Return the value of POSITION's property PROP, in OBJECT. 558 doc: /* Return the value of POSITION's property PROP, in OBJECT.
559OBJECT is optional and defaults to the current buffer. 559OBJECT should be a buffer or a string; if omitted or nil, it defaults
560to the current buffer.
560If POSITION is at the end of OBJECT, the value is nil. */) 561If POSITION is at the end of OBJECT, the value is nil. */)
561 (Lisp_Object position, Lisp_Object prop, Lisp_Object object) 562 (Lisp_Object position, Lisp_Object prop, Lisp_Object object)
562{ 563{
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. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" /* for xmalloc */ 23#include "lisp.h" /* for xmalloc */
24#include "tparam.h" 24#include "tparam.h"
25 25
@@ -247,7 +247,7 @@ tparam1 (const char *string, char *outstring, int len,
247 break; 247 break;
248 248
249 default: 249 default:
250 abort (); 250 emacs_abort ();
251 } 251 }
252 } 252 }
253 else 253 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/>. */
18 18
19 19
20#include <config.h> 20#include <config.h>
21#include <setjmp.h> 21
22#include "lisp.h" 22#include "lisp.h"
23#include "character.h" 23#include "character.h"
24#include "buffer.h" 24#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 *);
89 89
90static int pagemask; 90static int pagemask;
91 91
92#include <setjmp.h>
93#include "lisp.h" 92#include "lisp.h"
94 93
95static void 94static 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;
120 120
121#define ADDR_CORRECT(x) ((char *)(x) - (char*)0) 121#define ADDR_CORRECT(x) ((char *)(x) - (char*)0)
122 122
123#include <setjmp.h>
124#include "lisp.h" 123#include "lisp.h"
125 124
126static void 125static 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/>. */
21#include <config.h> 21#include <config.h>
22#include "unexec.h" 22#include "unexec.h"
23 23
24#include <setjmp.h>
25#include <lisp.h> 24#include <lisp.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <fcntl.h> 26#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 @@
4#include "unexec.h" 4#include "unexec.h"
5 5
6#include <dlfcn.h> 6#include <dlfcn.h>
7#include <setjmp.h>
8 7
9#include "lisp.h" 8#include "lisp.h"
10#include "character.h" 9#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
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <setjmp.h>
21#include <unistd.h> /* for 'environ', on AIX */ 20#include <unistd.h> /* for 'environ', on AIX */
22#include "lisp.h" 21#include "lisp.h"
23#include "mem-limits.h" 22#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/>. */
31#include <dpmi.h> 31#include <dpmi.h>
32#include <go32.h> 32#include <go32.h>
33#include <sys/farptr.h> 33#include <sys/farptr.h>
34#include <setjmp.h>
35#include "lisp.h" 34#include "lisp.h"
36#include "dispextern.h" /* frame.h seems to want this */ 35#include "dispextern.h" /* frame.h seems to want this */
37#include "frame.h" /* Need this to get the X window of selected_frame */ 36#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/>. */
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/utime.h> 33#include <sys/utime.h>
34#include <math.h> 34#include <math.h>
35#include <setjmp.h>
36#include <time.h> 35#include <time.h>
37 36
38/* must include CRT headers *before* config.h */ 37/* must include CRT headers *before* config.h */
@@ -1256,9 +1255,9 @@ init_user_info (void)
1256 1255
1257 /* Ensure HOME and SHELL are defined. */ 1256 /* Ensure HOME and SHELL are defined. */
1258 if (getenv ("HOME") == NULL) 1257 if (getenv ("HOME") == NULL)
1259 abort (); 1258 emacs_abort ();
1260 if (getenv ("SHELL") == NULL) 1259 if (getenv ("SHELL") == NULL)
1261 abort (); 1260 emacs_abort ();
1262 1261
1263 /* Set dir and shell from environment variables. */ 1262 /* Set dir and shell from environment variables. */
1264 strcpy (dflt_passwd.pw_dir, getenv ("HOME")); 1263 strcpy (dflt_passwd.pw_dir, getenv ("HOME"));
@@ -1513,34 +1512,10 @@ is_unc_volume (const char *filename)
1513} 1512}
1514 1513
1515/* Routines that are no-ops on NT but are defined to get Emacs to compile. */ 1514/* Routines that are no-ops on NT but are defined to get Emacs to compile. */
1516
1517int
1518sigsetmask (int signal_mask)
1519{
1520 return 0;
1521}
1522
1523int
1524sigmask (int sig)
1525{
1526 return 0;
1527}
1528
1529int
1530sigblock (int sig)
1531{
1532 return 0;
1533}
1534
1535int
1536sigunblock (int sig)
1537{
1538 return 0;
1539}
1540
1541int 1515int
1542sigemptyset (sigset_t *set) 1516sigemptyset (sigset_t *set)
1543{ 1517{
1518 *set = 0;
1544 return 0; 1519 return 0;
1545} 1520}
1546 1521
@@ -1771,9 +1746,9 @@ init_environment (char ** argv)
1771 char modname[MAX_PATH]; 1746 char modname[MAX_PATH];
1772 1747
1773 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 1748 if (!GetModuleFileName (NULL, modname, MAX_PATH))
1774 abort (); 1749 emacs_abort ();
1775 if ((p = strrchr (modname, '\\')) == NULL) 1750 if ((p = strrchr (modname, '\\')) == NULL)
1776 abort (); 1751 emacs_abort ();
1777 *p = 0; 1752 *p = 0;
1778 1753
1779 if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0) 1754 if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0)
@@ -1885,13 +1860,13 @@ init_environment (char ** argv)
1885 /* FIXME: Do we need to resolve possible symlinks in startup_dir? 1860 /* FIXME: Do we need to resolve possible symlinks in startup_dir?
1886 Does it matter anywhere in Emacs? */ 1861 Does it matter anywhere in Emacs? */
1887 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) 1862 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))
1888 abort (); 1863 emacs_abort ();
1889 1864
1890 { 1865 {
1891 static char modname[MAX_PATH]; 1866 static char modname[MAX_PATH];
1892 1867
1893 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 1868 if (!GetModuleFileName (NULL, modname, MAX_PATH))
1894 abort (); 1869 emacs_abort ();
1895 argv[0] = modname; 1870 argv[0] = modname;
1896 } 1871 }
1897 1872
@@ -1913,7 +1888,7 @@ emacs_root_dir (void)
1913 1888
1914 p = getenv ("emacs_dir"); 1889 p = getenv ("emacs_dir");
1915 if (p == NULL) 1890 if (p == NULL)
1916 abort (); 1891 emacs_abort ();
1917 strcpy (root_dir, p); 1892 strcpy (root_dir, p);
1918 root_dir[parse_root (root_dir, NULL)] = '\0'; 1893 root_dir[parse_root (root_dir, NULL)] = '\0';
1919 dostounix_filename (root_dir); 1894 dostounix_filename (root_dir);
@@ -3270,7 +3245,7 @@ generate_inode_val (const char * name)
3270 doesn't resolve aliasing due to subst commands, or recognize hard 3245 doesn't resolve aliasing due to subst commands, or recognize hard
3271 links. */ 3246 links. */
3272 if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH)) 3247 if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH))
3273 abort (); 3248 emacs_abort ();
3274 3249
3275 parse_root (fullname, &p); 3250 parse_root (fullname, &p);
3276 /* Normal W32 filesystems are still case insensitive. */ 3251 /* Normal W32 filesystems are still case insensitive. */
@@ -5570,7 +5545,7 @@ socket_to_fd (SOCKET s)
5570 if (fd_info[ fd ].cp != NULL) 5545 if (fd_info[ fd ].cp != NULL)
5571 { 5546 {
5572 DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd)); 5547 DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd));
5573 abort (); 5548 emacs_abort ();
5574 } 5549 }
5575 5550
5576 fd_info[ fd ].cp = cp; 5551 fd_info[ fd ].cp = cp;
@@ -5949,7 +5924,7 @@ sys_close (int fd)
5949 { 5924 {
5950 if (fd_info[fd].flags & FILE_SOCKET) 5925 if (fd_info[fd].flags & FILE_SOCKET)
5951 { 5926 {
5952 if (winsock_lib == NULL) abort (); 5927 if (winsock_lib == NULL) emacs_abort ();
5953 5928
5954 pfn_shutdown (SOCK_HANDLE (fd), 2); 5929 pfn_shutdown (SOCK_HANDLE (fd), 2);
5955 rc = pfn_closesocket (SOCK_HANDLE (fd)); 5930 rc = pfn_closesocket (SOCK_HANDLE (fd));
@@ -6067,7 +6042,7 @@ _sys_read_ahead (int fd)
6067 || (fd_info[fd].flags & FILE_READ) == 0) 6042 || (fd_info[fd].flags & FILE_READ) == 0)
6068 { 6043 {
6069 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe, serial port, or socket!\n", fd)); 6044 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe, serial port, or socket!\n", fd));
6070 abort (); 6045 emacs_abort ();
6071 } 6046 }
6072 6047
6073 cp->status = STATUS_READ_IN_PROGRESS; 6048 cp->status = STATUS_READ_IN_PROGRESS;
@@ -6203,7 +6178,7 @@ sys_read (int fd, char * buffer, unsigned int count)
6203 /* re-read CR carried over from last read */ 6178 /* re-read CR carried over from last read */
6204 if (fd_info[fd].flags & FILE_LAST_CR) 6179 if (fd_info[fd].flags & FILE_LAST_CR)
6205 { 6180 {
6206 if (fd_info[fd].flags & FILE_BINARY) abort (); 6181 if (fd_info[fd].flags & FILE_BINARY) emacs_abort ();
6207 *buffer++ = 0x0d; 6182 *buffer++ = 0x0d;
6208 count--; 6183 count--;
6209 nchars++; 6184 nchars++;
@@ -6306,7 +6281,7 @@ sys_read (int fd, char * buffer, unsigned int count)
6306 } 6281 }
6307 else /* FILE_SOCKET */ 6282 else /* FILE_SOCKET */
6308 { 6283 {
6309 if (winsock_lib == NULL) abort (); 6284 if (winsock_lib == NULL) emacs_abort ();
6310 6285
6311 /* do the equivalent of a non-blocking read */ 6286 /* do the equivalent of a non-blocking read */
6312 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting); 6287 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting);
@@ -6457,7 +6432,7 @@ sys_write (int fd, const void * buffer, unsigned int count)
6457 else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) 6432 else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
6458 { 6433 {
6459 unsigned long nblock = 0; 6434 unsigned long nblock = 0;
6460 if (winsock_lib == NULL) abort (); 6435 if (winsock_lib == NULL) emacs_abort ();
6461 6436
6462 /* TODO: implement select() properly so non-blocking I/O works. */ 6437 /* TODO: implement select() properly so non-blocking I/O works. */
6463 /* For now, make sure the write blocks. */ 6438 /* For now, make sure the write blocks. */
@@ -6623,8 +6598,7 @@ check_windows_init_file (void)
6623 buffer, 6598 buffer,
6624 "Emacs Abort Dialog", 6599 "Emacs Abort Dialog",
6625 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); 6600 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
6626 /* Use the low-level Emacs abort. */ 6601 /* Use the low-level system abort. */
6627#undef abort
6628 abort (); 6602 abort ();
6629 } 6603 }
6630 else 6604 else
@@ -6756,7 +6730,7 @@ shutdown_handler (DWORD type)
6756 || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */ 6730 || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */
6757 { 6731 {
6758 /* Shut down cleanly, making sure autosave files are up to date. */ 6732 /* Shut down cleanly, making sure autosave files are up to date. */
6759 shut_down_emacs (0, 0, Qnil); 6733 shut_down_emacs (0, Qnil);
6760 } 6734 }
6761 6735
6762 /* Allow other handlers to handle this signal. */ 6736 /* 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/>. */
26 26
27#include <stdio.h> 27#include <stdio.h>
28#include <windows.h> 28#include <windows.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "character.h" 31#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/>. */
26#include <limits.h> 26#include <limits.h>
27#include <errno.h> 27#include <errno.h>
28#include <math.h> 28#include <math.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "w32term.h" 31#include "w32term.h"
@@ -2368,7 +2367,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2368 CoInitialize (NULL); 2367 CoInitialize (NULL);
2369 w32_createwindow ((struct frame *) msg.wParam); 2368 w32_createwindow ((struct frame *) msg.wParam);
2370 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2369 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2371 abort (); 2370 emacs_abort ();
2372 break; 2371 break;
2373 case WM_EMACS_SETLOCALE: 2372 case WM_EMACS_SETLOCALE:
2374 SetThreadLocale (msg.wParam); 2373 SetThreadLocale (msg.wParam);
@@ -2378,7 +2377,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2378 result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0); 2377 result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
2379 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 2378 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
2380 result, 0)) 2379 result, 0))
2381 abort (); 2380 emacs_abort ();
2382 break; 2381 break;
2383 case WM_EMACS_REGISTER_HOT_KEY: 2382 case WM_EMACS_REGISTER_HOT_KEY:
2384 focus_window = GetFocus (); 2383 focus_window = GetFocus ();
@@ -2399,7 +2398,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2399 GC. */ 2398 GC. */
2400 XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil); 2399 XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil);
2401 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2400 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2402 abort (); 2401 emacs_abort ();
2403 break; 2402 break;
2404 case WM_EMACS_TOGGLE_LOCK_KEY: 2403 case WM_EMACS_TOGGLE_LOCK_KEY:
2405 { 2404 {
@@ -2431,7 +2430,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2431 } 2430 }
2432 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 2431 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
2433 cur_state, 0)) 2432 cur_state, 0))
2434 abort (); 2433 emacs_abort ();
2435 } 2434 }
2436 break; 2435 break;
2437#ifdef MSG_DEBUG 2436#ifdef MSG_DEBUG
@@ -2486,11 +2485,11 @@ send_deferred_msg (deferred_msg * msg_buf,
2486{ 2485{
2487 /* Only input thread can send deferred messages. */ 2486 /* Only input thread can send deferred messages. */
2488 if (GetCurrentThreadId () != dwWindowsThreadId) 2487 if (GetCurrentThreadId () != dwWindowsThreadId)
2489 abort (); 2488 emacs_abort ();
2490 2489
2491 /* It is an error to send a message that is already deferred. */ 2490 /* It is an error to send a message that is already deferred. */
2492 if (find_deferred_msg (hwnd, msg) != NULL) 2491 if (find_deferred_msg (hwnd, msg) != NULL)
2493 abort (); 2492 emacs_abort ();
2494 2493
2495 /* Enforced synchronization is not needed because this is the only 2494 /* Enforced synchronization is not needed because this is the only
2496 function that alters deferred_msg_head, and the following critical 2495 function that alters deferred_msg_head, and the following critical
@@ -2563,7 +2562,7 @@ w32_msg_worker (void *arg)
2563 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); 2562 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
2564 2563
2565 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2564 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2566 abort (); 2565 emacs_abort ();
2567 2566
2568 memset (&dummy_buf, 0, sizeof (dummy_buf)); 2567 memset (&dummy_buf, 0, sizeof (dummy_buf));
2569 dummy_buf.w32msg.msg.hwnd = NULL; 2568 dummy_buf.w32msg.msg.hwnd = NULL;
@@ -3224,7 +3223,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3224 msg = WM_MBUTTONUP; 3223 msg = WM_MBUTTONUP;
3225 button_state &= ~MMOUSE; 3224 button_state &= ~MMOUSE;
3226 3225
3227 if (button_state) abort (); 3226 if (button_state) emacs_abort ();
3228 } 3227 }
3229 else 3228 else
3230 return 0; 3229 return 0;
@@ -3455,7 +3454,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3455 /* Detect if message has already been deferred; in this case 3454 /* Detect if message has already been deferred; in this case
3456 we cannot return any sensible value to ignore this. */ 3455 we cannot return any sensible value to ignore this. */
3457 if (find_deferred_msg (hwnd, msg) != NULL) 3456 if (find_deferred_msg (hwnd, msg) != NULL)
3458 abort (); 3457 emacs_abort ();
3459 3458
3460 menubar_in_use = 1; 3459 menubar_in_use = 1;
3461 3460
@@ -3930,7 +3929,7 @@ my_create_window (struct frame * f)
3930 MSG msg; 3929 MSG msg;
3931 3930
3932 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0)) 3931 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0))
3933 abort (); 3932 emacs_abort ();
3934 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 3933 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
3935} 3934}
3936 3935
@@ -6490,7 +6489,7 @@ w32_parse_hot_key (Lisp_Object key)
6490 lisp_modifiers = XINT (Fcar (Fcdr (c))); 6489 lisp_modifiers = XINT (Fcar (Fcdr (c)));
6491 c = Fcar (c); 6490 c = Fcar (c);
6492 if (!SYMBOLP (c)) 6491 if (!SYMBOLP (c))
6493 abort (); 6492 emacs_abort ();
6494 vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c))); 6493 vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c)));
6495 } 6494 }
6496 else if (INTEGERP (c)) 6495 else if (INTEGERP (c))
@@ -7685,10 +7684,8 @@ globals_of_w32fns (void)
7685 syms_of_w32uniscribe (); 7684 syms_of_w32uniscribe ();
7686} 7685}
7687 7686
7688#undef abort
7689
7690void 7687void
7691w32_abort (void) 7688emacs_abort (void)
7692{ 7689{
7693 int button; 7690 int button;
7694 button = MessageBox (NULL, 7691 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/>. */
22#include <math.h> 22#include <math.h>
23#include <ctype.h> 23#include <ctype.h>
24#include <commdlg.h> 24#include <commdlg.h>
25#include <setjmp.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
28#include "w32term.h" 27#include "w32term.h"
@@ -636,9 +635,9 @@ w32font_text_extents (struct font *font, unsigned *code,
636/* w32 implementation of draw for font backend. 635/* w32 implementation of draw for font backend.
637 Optional. 636 Optional.
638 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel 637 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
639 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND 638 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
640 is nonzero, fill the background in advance. It is assured that 639 fill the background in advance. It is assured that WITH_BACKGROUND
641 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). 640 is false when (FROM > 0 || TO < S->nchars).
642 641
643 TODO: Currently this assumes that the colors and fonts are already 642 TODO: Currently this assumes that the colors and fonts are already
644 set in the DC. This seems to be true now, but maybe only due to 643 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,
648 647
649int 648int
650w32font_draw (struct glyph_string *s, int from, int to, 649w32font_draw (struct glyph_string *s, int from, int to,
651 int x, int y, int with_background) 650 int x, int y, bool with_background)
652{ 651{
653 UINT options; 652 UINT options;
654 HRGN orig_clip = NULL; 653 HRGN orig_clip = NULL;
@@ -805,7 +804,7 @@ static int
805w32font_otf_drive (struct font *font, Lisp_Object features, 804w32font_otf_drive (struct font *font, Lisp_Object features,
806 Lisp_Object gstring_in, int from, int to, 805 Lisp_Object gstring_in, int from, int to,
807 Lisp_Object gstring_out, int idx, 806 Lisp_Object gstring_out, int idx,
808 int alternate_subst); 807 bool alternate_subst);
809 */ 808 */
810 809
811/* Internal implementation of w32font_list. 810/* Internal implementation of w32font_list.
@@ -988,7 +987,6 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity,
988 font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth; 987 font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;
989 988
990 font->vertical_centering = 0; 989 font->vertical_centering = 0;
991 font->encoding_type = 0;
992 font->baseline_offset = 0; 990 font->baseline_offset = 0;
993 font->relative_compose = 0; 991 font->relative_compose = 0;
994 font->default_ascent = w32_font->metrics.tmAscent; 992 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);
77int w32font_text_extents (struct font *font, unsigned *code, int nglyphs, 77int w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
78 struct font_metrics *metrics); 78 struct font_metrics *metrics);
79int w32font_draw (struct glyph_string *s, int from, int to, 79int w32font_draw (struct glyph_string *s, int from, int to,
80 int x, int y, int with_background); 80 int x, int y, bool with_background);
81 81
82 82
83int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec); 83int 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/>. */
22 22
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h>
26 25
27#include "w32heap.h" 26#include "w32heap.h"
28#include "lisp.h" /* for VALMASK */ 27#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/>. */
25#include <config.h> 25#include <config.h>
26#include <stdio.h> 26#include <stdio.h>
27#include <windows.h> 27#include <windows.h>
28#include <setjmp.h>
29 28
30#ifndef MOUSE_MOVED 29#ifndef MOUSE_MOVED
31#define MOUSE_MOVED 1 30#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,
835 else if (EQ (type, QCradio)) 835 else if (EQ (type, QCradio))
836 wv->button_type = BUTTON_TYPE_RADIO; 836 wv->button_type = BUTTON_TYPE_RADIO;
837 else 837 else
838 abort (); 838 emacs_abort ();
839 839
840 wv->selected = !NILP (selected); 840 wv->selected = !NILP (selected);
841 841
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/>. */
28#include <fcntl.h> 28#include <fcntl.h>
29#include <signal.h> 29#include <signal.h>
30#include <sys/file.h> 30#include <sys/file.h>
31#include <setjmp.h>
32 31
33/* must include CRT headers *before* config.h */ 32/* must include CRT headers *before* config.h */
34#include <config.h> 33#include <config.h>
@@ -89,6 +88,29 @@ sys_signal (int sig, signal_handler handler)
89 return old; 88 return old;
90} 89}
91 90
91/* Emulate sigaction. */
92int
93sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
94{
95 signal_handler old;
96
97 if (sig != SIGCHLD)
98 {
99 errno = EINVAL;
100 return -1;
101 }
102 old = sig_handlers[sig];
103 if (act)
104 sig_handlers[sig] = act->sa_handler;
105 if (oact)
106 {
107 oact->sa_handler = old;
108 oact->sa_flags = 0;
109 oact->sa_mask = empty_mask;
110 }
111 return 0;
112}
113
92/* Defined in <process.h> which conflicts with the local copy */ 114/* Defined in <process.h> which conflicts with the local copy */
93#define _P_NOWAIT 1 115#define _P_NOWAIT 1
94 116
@@ -162,7 +184,7 @@ delete_child (child_process *cp)
162 /* Should not be deleting a child that is still needed. */ 184 /* Should not be deleting a child that is still needed. */
163 for (i = 0; i < MAXDESC; i++) 185 for (i = 0; i < MAXDESC; i++)
164 if (fd_info[i].cp == cp) 186 if (fd_info[i].cp == cp)
165 abort (); 187 emacs_abort ();
166 188
167 if (!CHILD_ACTIVE (cp)) 189 if (!CHILD_ACTIVE (cp))
168 return; 190 return;
@@ -302,7 +324,7 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
302 DWORD flags; 324 DWORD flags;
303 char dir[ MAXPATHLEN ]; 325 char dir[ MAXPATHLEN ];
304 326
305 if (cp == NULL) abort (); 327 if (cp == NULL) emacs_abort ();
306 328
307 memset (&start, 0, sizeof (start)); 329 memset (&start, 0, sizeof (start));
308 start.cb = sizeof (start); 330 start.cb = sizeof (start);
@@ -391,7 +413,7 @@ register_child (int pid, int fd)
391 if (fd_info[fd].cp != NULL) 413 if (fd_info[fd].cp != NULL)
392 { 414 {
393 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd)); 415 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd));
394 abort (); 416 emacs_abort ();
395 } 417 }
396 418
397 fd_info[fd].cp = cp; 419 fd_info[fd].cp = cp;
@@ -445,7 +467,7 @@ sys_wait (int *status)
445 /* We want to wait for a specific child */ 467 /* We want to wait for a specific child */
446 wait_hnd[nh] = dead_child->procinfo.hProcess; 468 wait_hnd[nh] = dead_child->procinfo.hProcess;
447 cps[nh] = dead_child; 469 cps[nh] = dead_child;
448 if (!wait_hnd[nh]) abort (); 470 if (!wait_hnd[nh]) emacs_abort ();
449 nh++; 471 nh++;
450 active = 0; 472 active = 0;
451 goto get_result; 473 goto get_result;
@@ -493,7 +515,7 @@ sys_wait (int *status)
493 active -= WAIT_ABANDONED_0; 515 active -= WAIT_ABANDONED_0;
494 } 516 }
495 else 517 else
496 abort (); 518 emacs_abort ();
497 519
498get_result: 520get_result:
499 if (!GetExitCodeProcess (wait_hnd[active], &retval)) 521 if (!GetExitCodeProcess (wait_hnd[active], &retval))
@@ -1175,7 +1197,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
1175#endif 1197#endif
1176 wait_hnd[nh] = cp->char_avail; 1198 wait_hnd[nh] = cp->char_avail;
1177 fdindex[nh] = i; 1199 fdindex[nh] = i;
1178 if (!wait_hnd[nh]) abort (); 1200 if (!wait_hnd[nh]) emacs_abort ();
1179 nh++; 1201 nh++;
1180#ifdef FULL_DEBUG 1202#ifdef FULL_DEBUG
1181 DebPrint (("select waiting on child %d fd %d\n", 1203 DebPrint (("select waiting on child %d fd %d\n",
@@ -1262,7 +1284,7 @@ count_children:
1262 active -= WAIT_ABANDONED_0; 1284 active -= WAIT_ABANDONED_0;
1263 } 1285 }
1264 else 1286 else
1265 abort (); 1287 emacs_abort ();
1266 1288
1267 /* Loop over all handles after active (now officially documented as 1289 /* Loop over all handles after active (now officially documented as
1268 being the first signaled handle in the array). We do this to 1290 being the first signaled handle in the array). We do this to
@@ -1392,6 +1414,9 @@ sys_kill (int pid, int sig)
1392 int need_to_free = 0; 1414 int need_to_free = 0;
1393 int rc = 0; 1415 int rc = 0;
1394 1416
1417 if (pid == getpid () && sig == SIGABRT)
1418 emacs_abort ();
1419
1395 /* Only handle signals that will result in the process dying */ 1420 /* Only handle signals that will result in the process dying */
1396 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) 1421 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
1397 { 1422 {
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/>. */
19/* Written by Kevin Gallo */ 19/* Written by Kevin Gallo */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.h"
24#include "w32term.h" 23#include "w32term.h"
25#include "blockinput.h" 24#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/>. */
73 */ 73 */
74 74
75#include <config.h> 75#include <config.h>
76#include <setjmp.h>
77#include "lisp.h" 76#include "lisp.h"
78#include "w32term.h" /* for all of the w32 includes */ 77#include "w32term.h" /* for all of the w32 includes */
79#include "w32heap.h" /* os_subtype */ 78#include "w32heap.h" /* os_subtype */
@@ -399,7 +398,7 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
399 398
400 BLOCK_INPUT; 399 BLOCK_INPUT;
401 400
402 /* Fsignal calls abort() if it sees that waiting_for_input is 401 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
403 set. */ 402 set. */
404 owfi = waiting_for_input; 403 owfi = waiting_for_input;
405 waiting_for_input = 0; 404 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/>. */
20#include <config.h> 20#include <config.h>
21#include <signal.h> 21#include <signal.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24#include "lisp.h" 23#include "lisp.h"
25#include "blockinput.h" 24#include "blockinput.h"
26#include "w32term.h" 25#include "w32term.h"
@@ -2440,7 +2439,7 @@ x_draw_glyph_string (struct glyph_string *s)
2440 break; 2439 break;
2441 2440
2442 default: 2441 default:
2443 abort (); 2442 emacs_abort ();
2444 } 2443 }
2445 2444
2446 if (!s->for_overlaps) 2445 if (!s->for_overlaps)
@@ -2605,6 +2604,7 @@ x_draw_glyph_string (struct glyph_string *s)
2605 w32_set_clip_rectangle (next->hdc, NULL); 2604 w32_set_clip_rectangle (next->hdc, NULL);
2606 next->hl = save; 2605 next->hl = save;
2607 next->num_clips = 0; 2606 next->num_clips = 0;
2607 next->clip_head = s->next;
2608 } 2608 }
2609 } 2609 }
2610 } 2610 }
@@ -2640,7 +2640,7 @@ x_delete_glyphs (struct frame *f, register int n)
2640 if (! FRAME_W32_P (f)) 2640 if (! FRAME_W32_P (f))
2641 return; 2641 return;
2642 2642
2643 abort (); 2643 emacs_abort ();
2644} 2644}
2645 2645
2646 2646
@@ -2723,7 +2723,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n)
2723 if (! FRAME_W32_P (f)) 2723 if (! FRAME_W32_P (f))
2724 return; 2724 return;
2725 2725
2726 abort (); 2726 emacs_abort ();
2727} 2727}
2728 2728
2729 2729
@@ -3445,7 +3445,7 @@ x_window_to_scroll_bar (Window window_id)
3445 frame = XCAR (tail); 3445 frame = XCAR (tail);
3446 /* All elements of Vframe_list should be frames. */ 3446 /* All elements of Vframe_list should be frames. */
3447 if (! FRAMEP (frame)) 3447 if (! FRAMEP (frame))
3448 abort (); 3448 emacs_abort ();
3449 3449
3450 /* Scan this frame's scroll bar list for a scroll bar with the 3450 /* Scan this frame's scroll bar list for a scroll bar with the
3451 right window ID. */ 3451 right window ID. */
@@ -3868,7 +3868,7 @@ w32_redeem_scroll_bar (struct window *window)
3868 3868
3869 /* We can't redeem this window's scroll bar if it doesn't have one. */ 3869 /* We can't redeem this window's scroll bar if it doesn't have one. */
3870 if (NILP (window->vertical_scroll_bar)) 3870 if (NILP (window->vertical_scroll_bar))
3871 abort (); 3871 emacs_abort ();
3872 3872
3873 bar = XSCROLL_BAR (window->vertical_scroll_bar); 3873 bar = XSCROLL_BAR (window->vertical_scroll_bar);
3874 3874
@@ -3887,7 +3887,7 @@ w32_redeem_scroll_bar (struct window *window)
3887 else 3887 else
3888 /* If its prev pointer is nil, it must be at the front of 3888 /* If its prev pointer is nil, it must be at the front of
3889 one or the other! */ 3889 one or the other! */
3890 abort (); 3890 emacs_abort ();
3891 } 3891 }
3892 else 3892 else
3893 XSCROLL_BAR (bar->prev)->next = bar->next; 3893 XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -3942,7 +3942,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
3942 struct input_event *emacs_event) 3942 struct input_event *emacs_event)
3943{ 3943{
3944 if (! WINDOWP (bar->window)) 3944 if (! WINDOWP (bar->window))
3945 abort (); 3945 emacs_abort ();
3946 3946
3947 emacs_event->kind = SCROLL_BAR_CLICK_EVENT; 3947 emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
3948 emacs_event->code = 0; 3948 emacs_event->code = 0;
@@ -4177,6 +4177,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4177 if (interrupt_input_blocked) 4177 if (interrupt_input_blocked)
4178 { 4178 {
4179 interrupt_input_pending = 1; 4179 interrupt_input_pending = 1;
4180 pending_signals = 1;
4180 return -1; 4181 return -1;
4181 } 4182 }
4182 4183
@@ -5255,7 +5256,7 @@ w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
5255 break; 5256 break;
5256 5257
5257 default: 5258 default:
5258 abort (); 5259 emacs_abort ();
5259 } 5260 }
5260 } 5261 }
5261} 5262}
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/>. */
27#define _WIN32_WINNT 0x500 27#define _WIN32_WINNT 0x500
28#include <windows.h> 28#include <windows.h>
29#include <usp10.h> 29#include <usp10.h>
30#include <setjmp.h>
31 30
32#include "lisp.h" 31#include "lisp.h"
33#include "w32term.h" 32#include "w32term.h"
@@ -454,7 +453,11 @@ uniscribe_shape (Lisp_Object lgstring)
454 } 453 }
455 else 454 else
456 ASET (vec, 0, make_number (offsets[j].du + adj_offset)); 455 ASET (vec, 0, make_number (offsets[j].du + adj_offset));
457 ASET (vec, 1, make_number (offsets[j].dv)); 456 /* In the font definition coordinate system, the
457 Y coordinate points up, while in our screen
458 coordinates Y grows downwards. So we need to
459 reverse the sign of Y-OFFSET here. */
460 ASET (vec, 1, make_number (-offsets[j].dv));
458 /* Based on what ftfont.c does... */ 461 /* Based on what ftfont.c does... */
459 ASET (vec, 2, make_number (advances[j])); 462 ASET (vec, 2, make_number (advances[j]));
460 LGLYPH_SET_ADJUSTMENT (lglyph, vec); 463 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/>. */
19#include <config.h> 19#include <config.h>
20#include <signal.h> 20#include <signal.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <setjmp.h>
23 22
24#include "lisp.h" 23#include "lisp.h"
25#include "keyboard.h" 24#include "keyboard.h"
@@ -131,7 +130,7 @@ get_frame_dc (FRAME_PTR f)
131 HDC hdc; 130 HDC hdc;
132 131
133 if (f->output_method != output_w32) 132 if (f->output_method != output_w32)
134 abort (); 133 emacs_abort ();
135 134
136 enter_crit (); 135 enter_crit ();
137 136
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/>. */
30 30
31#include <config.h> 31#include <config.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <setjmp.h> 33
34#include "lisp.h" 34#include "lisp.h"
35#include "xterm.h" 35#include "xterm.h"
36 36
@@ -50,9 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#include <X11/ShellP.h> 50#include <X11/ShellP.h>
51#include "../lwlib/lwlib.h" 51#include "../lwlib/lwlib.h"
52 52
53#include <signal.h>
54#include "syssignal.h"
55
56#include "character.h" 53#include "character.h"
57#include "font.h" 54#include "font.h"
58 55
@@ -226,7 +223,7 @@ get_wm_shell (Widget w)
226static void 223static void
227mark_shell_size_user_specified (Widget wmshell) 224mark_shell_size_user_specified (Widget wmshell)
228{ 225{
229 if (! XtIsWMShell (wmshell)) abort (); 226 if (! XtIsWMShell (wmshell)) emacs_abort ();
230 /* This is kind of sleazy, but I can't see how else to tell it to make it 227 /* This is kind of sleazy, but I can't see how else to tell it to make it
231 mark the WM_SIZE_HINTS size as user specified when appropriate. */ 228 mark the WM_SIZE_HINTS size as user specified when appropriate. */
232 ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; 229 ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize;
@@ -290,7 +287,7 @@ set_frame_size (EmacsFrame ew)
290 Widget wmshell = get_wm_shell ((Widget) ew); 287 Widget wmshell = get_wm_shell ((Widget) ew);
291 /* Each Emacs shell is now independent and top-level. */ 288 /* Each Emacs shell is now independent and top-level. */
292 289
293 if (! XtIsSubclass (wmshell, shellWidgetClass)) abort (); 290 if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort ();
294 291
295 /* We don't need this for the moment. The geometry is computed in 292 /* We don't need this for the moment. The geometry is computed in
296 xfns.c. */ 293 xfns.c. */
@@ -671,16 +668,14 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs
671 update_wm_hints (ew); 668 update_wm_hints (ew);
672} 669}
673 670
674extern void free_frame_faces (struct frame *);
675
676static void 671static void
677EmacsFrameDestroy (Widget widget) 672EmacsFrameDestroy (Widget widget)
678{ 673{
679 EmacsFrame ew = (EmacsFrame) widget; 674 EmacsFrame ew = (EmacsFrame) widget;
680 struct frame* s = ew->emacs_frame.frame; 675 struct frame* s = ew->emacs_frame.frame;
681 676
682 if (! s) abort (); 677 if (! s) emacs_abort ();
683 if (! s->output_data.x) abort (); 678 if (! s->output_data.x) emacs_abort ();
684 679
685 BLOCK_INPUT; 680 BLOCK_INPUT;
686 x_free_gcs (s); 681 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/>. */
23#define WINDOW_INLINE EXTERN_INLINE 23#define WINDOW_INLINE EXTERN_INLINE
24 24
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#include "lisp.h" 27#include "lisp.h"
29#include "character.h" 28#include "character.h"
@@ -176,11 +175,6 @@ wset_new_total (struct window *w, Lisp_Object val)
176 w->new_total = val; 175 w->new_total = val;
177} 176}
178static inline void 177static inline void
179wset_next_buffers (struct window *w, Lisp_Object val)
180{
181 w->next_buffers = val;
182}
183static inline void
184wset_normal_cols (struct window *w, Lisp_Object val) 178wset_normal_cols (struct window *w, Lisp_Object val)
185{ 179{
186 w->normal_cols = val; 180 w->normal_cols = val;
@@ -201,11 +195,6 @@ wset_pointm (struct window *w, Lisp_Object val)
201 w->pointm = val; 195 w->pointm = val;
202} 196}
203static inline void 197static inline void
204wset_prev_buffers (struct window *w, Lisp_Object val)
205{
206 w->prev_buffers = val;
207}
208static inline void
209wset_right_fringe_width (struct window *w, Lisp_Object val) 198wset_right_fringe_width (struct window *w, Lisp_Object val)
210{ 199{
211 w->right_fringe_width = val; 200 w->right_fringe_width = val;
@@ -386,7 +375,7 @@ the first window of that frame. */)
386 else if (! NILP (XWINDOW (window)->vchild)) 375 else if (! NILP (XWINDOW (window)->vchild))
387 window = XWINDOW (window)->vchild; 376 window = XWINDOW (window)->vchild;
388 else 377 else
389 abort (); 378 emacs_abort ();
390 } 379 }
391 380
392 return window; 381 return window;
@@ -1289,7 +1278,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1289 return Qnil; 1278 return Qnil;
1290 1279
1291 default: 1280 default:
1292 abort (); 1281 emacs_abort ();
1293 } 1282 }
1294} 1283}
1295 1284
@@ -1866,23 +1855,23 @@ return value is a list of elements of the form (PARAMETER . VALUE). */)
1866DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 1855DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter,
1867 2, 2, 0, 1856 2, 2, 0,
1868 doc: /* Return WINDOW's value for PARAMETER. 1857 doc: /* Return WINDOW's value for PARAMETER.
1869WINDOW must be a valid window and defaults to the selected one. */) 1858WINDOW can be any window and defaults to the selected one. */)
1870 (Lisp_Object window, Lisp_Object parameter) 1859 (Lisp_Object window, Lisp_Object parameter)
1871{ 1860{
1872 Lisp_Object result; 1861 Lisp_Object result;
1873 1862
1874 result = Fassq (parameter, decode_valid_window (window)->window_parameters); 1863 result = Fassq (parameter, decode_any_window (window)->window_parameters);
1875 return CDR_SAFE (result); 1864 return CDR_SAFE (result);
1876} 1865}
1877 1866
1878DEFUN ("set-window-parameter", Fset_window_parameter, 1867DEFUN ("set-window-parameter", Fset_window_parameter,
1879 Sset_window_parameter, 3, 3, 0, 1868 Sset_window_parameter, 3, 3, 0,
1880 doc: /* Set WINDOW's value of PARAMETER to VALUE. 1869 doc: /* Set WINDOW's value of PARAMETER to VALUE.
1881WINDOW must be a valid window and defaults to the selected one. 1870WINDOW can be any window and defaults to the selected one.
1882Return VALUE. */) 1871Return VALUE. */)
1883 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) 1872 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value)
1884{ 1873{
1885 register struct window *w = decode_valid_window (window); 1874 register struct window *w = decode_any_window (window);
1886 Lisp_Object old_alist_elt; 1875 Lisp_Object old_alist_elt;
1887 1876
1888 old_alist_elt = Fassq (parameter, w->window_parameters); 1877 old_alist_elt = Fassq (parameter, w->window_parameters);
@@ -1948,7 +1937,7 @@ unshow_buffer (register struct window *w)
1948 buf = w->buffer; 1937 buf = w->buffer;
1949 b = XBUFFER (buf); 1938 b = XBUFFER (buf);
1950 if (b != XMARKER (w->pointm)->buffer) 1939 if (b != XMARKER (w->pointm)->buffer)
1951 abort (); 1940 emacs_abort ();
1952 1941
1953#if 0 1942#if 0
1954 if (w == XWINDOW (selected_window) 1943 if (w == XWINDOW (selected_window)
@@ -2668,8 +2657,8 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2668 /* Check for a window that has a killed buffer. */ 2657 /* Check for a window that has a killed buffer. */
2669 case CHECK_ALL_WINDOWS: 2658 case CHECK_ALL_WINDOWS:
2670 if (! NILP (w->buffer) 2659 if (! NILP (w->buffer)
2671 && NILP (BVAR (XBUFFER (w->buffer), name))) 2660 && !BUFFER_LIVE_P (XBUFFER (w->buffer)))
2672 abort (); 2661 emacs_abort ();
2673 break; 2662 break;
2674 2663
2675 case WINDOW_LOOP_UNUSED: 2664 case WINDOW_LOOP_UNUSED:
@@ -3273,7 +3262,7 @@ This function runs `window-scroll-functions' before running
3273 XSETWINDOW (window, w); 3262 XSETWINDOW (window, w);
3274 buffer = Fget_buffer (buffer_or_name); 3263 buffer = Fget_buffer (buffer_or_name);
3275 CHECK_BUFFER (buffer); 3264 CHECK_BUFFER (buffer);
3276 if (NILP (BVAR (XBUFFER (buffer), name))) 3265 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
3277 error ("Attempt to display deleted buffer"); 3266 error ("Attempt to display deleted buffer");
3278 3267
3279 tem = w->buffer; 3268 tem = w->buffer;
@@ -3338,7 +3327,7 @@ displaying that buffer. */)
3338 3327
3339 if (STRINGP (object)) 3328 if (STRINGP (object))
3340 object = Fget_buffer (object); 3329 object = Fget_buffer (object);
3341 if (BUFFERP (object) && !NILP (BVAR (XBUFFER (object), name))) 3330 if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)))
3342 { 3331 {
3343 /* Walk all windows looking for buffer, and force update 3332 /* Walk all windows looking for buffer, and force update
3344 of each of those windows. */ 3333 of each of those windows. */
@@ -5549,7 +5538,7 @@ the return value is nil. Otherwise the value is t. */)
5549 saved_windows = XVECTOR (data->saved_windows); 5538 saved_windows = XVECTOR (data->saved_windows);
5550 5539
5551 new_current_buffer = data->current_buffer; 5540 new_current_buffer = data->current_buffer;
5552 if (NILP (BVAR (XBUFFER (new_current_buffer), name))) 5541 if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer)))
5553 new_current_buffer = Qnil; 5542 new_current_buffer = Qnil;
5554 else 5543 else
5555 { 5544 {
@@ -5624,7 +5613,7 @@ the return value is nil. Otherwise the value is t. */)
5624 w = XWINDOW (window); 5613 w = XWINDOW (window);
5625 if (!NILP (w->buffer) 5614 if (!NILP (w->buffer)
5626 && !EQ (w->buffer, p->buffer) 5615 && !EQ (w->buffer, p->buffer)
5627 && !NILP (BVAR (XBUFFER (p->buffer), name))) 5616 && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5628 /* If a window we restore gets another buffer, record the 5617 /* If a window we restore gets another buffer, record the
5629 window's old buffer. */ 5618 window's old buffer. */
5630 call1 (Qrecord_window_buffer, window); 5619 call1 (Qrecord_window_buffer, window);
@@ -5774,7 +5763,7 @@ the return value is nil. Otherwise the value is t. */)
5774 if (NILP (p->buffer)) 5763 if (NILP (p->buffer))
5775 /* An internal window. */ 5764 /* An internal window. */
5776 wset_buffer (w, p->buffer); 5765 wset_buffer (w, p->buffer);
5777 else if (!NILP (BVAR (XBUFFER (p->buffer), name))) 5766 else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
5778 /* If saved buffer is alive, install it. */ 5767 /* If saved buffer is alive, install it. */
5779 { 5768 {
5780 wset_buffer (w, p->buffer); 5769 wset_buffer (w, p->buffer);
@@ -5793,7 +5782,7 @@ the return value is nil. Otherwise the value is t. */)
5793 Fgoto_char (w->pointm); 5782 Fgoto_char (w->pointm);
5794 } 5783 }
5795 else if (!NILP (w->buffer) 5784 else if (!NILP (w->buffer)
5796 && !NILP (BVAR (XBUFFER (w->buffer), name))) 5785 && BUFFER_LIVE_P (XBUFFER (w->buffer)))
5797 /* Keep window's old buffer; make sure the markers are 5786 /* Keep window's old buffer; make sure the markers are
5798 real. */ 5787 real. */
5799 { 5788 {
@@ -6576,15 +6565,17 @@ freeze_window_starts (struct frame *f, int freeze_p)
6576/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 6565/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2
6577 describe the same state of affairs. This is used by Fequal. 6566 describe the same state of affairs. This is used by Fequal.
6578 6567
6579 ignore_positions non-zero means ignore non-matching scroll positions 6568 IGNORE_POSITIONS means ignore non-matching scroll positions
6580 and the like. 6569 and the like.
6581 6570
6582 This ignores a couple of things like the dedication status of 6571 This ignores a couple of things like the dedication status of
6583 window, combination_limit and the like. This might have to be 6572 window, combination_limit and the like. This might have to be
6584 fixed. */ 6573 fixed. */
6585 6574
6586int 6575bool
6587compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions) 6576compare_window_configurations (Lisp_Object configuration1,
6577 Lisp_Object configuration2,
6578 bool ignore_positions)
6588{ 6579{
6589 register struct save_window_data *d1, *d2; 6580 register struct save_window_data *d1, *d2;
6590 struct Lisp_Vector *sws1, *sws2; 6581 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
27# define WINDOW_INLINE INLINE 27# define WINDOW_INLINE INLINE
28#endif 28#endif
29 29
30extern Lisp_Object Qleft, Qright;
31
32/* Windows are allocated as if they were vectors, but then the 30/* Windows are allocated as if they were vectors, but then the
33Lisp data type is changed to Lisp_Window. They are garbage 31Lisp data type is changed to Lisp_Window. They are garbage
34collected along with the vectors. 32collected along with the vectors.
@@ -416,7 +414,16 @@ wset_window_end_vpos (struct window *w, Lisp_Object val)
416{ 414{
417 w->window_end_vpos = val; 415 w->window_end_vpos = val;
418} 416}
419 417WINDOW_INLINE void
418wset_prev_buffers (struct window *w, Lisp_Object val)
419{
420 w->prev_buffers = val;
421}
422WINDOW_INLINE void
423wset_next_buffers (struct window *w, Lisp_Object val)
424{
425 w->next_buffers = val;
426}
420 427
421/* 1 if W is a minibuffer window. */ 428/* 1 if W is a minibuffer window. */
422 429
@@ -973,7 +980,7 @@ extern Lisp_Object Qwindowp, Qwindow_live_p;
973extern Lisp_Object Vwindow_list; 980extern Lisp_Object Vwindow_list;
974 981
975extern struct window *decode_live_window (Lisp_Object); 982extern struct window *decode_live_window (Lisp_Object);
976extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); 983extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool);
977extern void mark_window_cursors_off (struct window *); 984extern void mark_window_cursors_off (struct window *);
978extern int window_internal_height (struct window *); 985extern int window_internal_height (struct window *);
979extern int window_body_cols (struct window *w); 986extern 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/>. */
273#include <config.h> 273#include <config.h>
274#include <stdio.h> 274#include <stdio.h>
275#include <limits.h> 275#include <limits.h>
276#include <setjmp.h>
277 276
278#include "lisp.h" 277#include "lisp.h"
279#include "keyboard.h" 278#include "keyboard.h"
@@ -768,9 +767,9 @@ static int clear_image_cache_count;
768static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 }; 767static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
769#endif 768#endif
770 769
771/* Non-zero while redisplay_internal is in progress. */ 770/* True while redisplay_internal is in progress. */
772 771
773int redisplaying_p; 772bool redisplaying_p;
774 773
775static Lisp_Object Qinhibit_free_realized_faces; 774static Lisp_Object Qinhibit_free_realized_faces;
776static Lisp_Object Qmode_line_default_help_echo; 775static Lisp_Object Qmode_line_default_help_echo;
@@ -3666,7 +3665,7 @@ handle_fontified_prop (struct it *it)
3666 } 3665 }
3667 /* There isn't much we can reasonably do to protect against 3666 /* There isn't much we can reasonably do to protect against
3668 misbehaving fontification, but here's a fig leaf. */ 3667 misbehaving fontification, but here's a fig leaf. */
3669 else if (!NILP (BVAR (obuf, name))) 3668 else if (BUFFER_LIVE_P (obuf))
3670 set_buffer_internal_1 (obuf); 3669 set_buffer_internal_1 (obuf);
3671 3670
3672 /* The fontification code may have added/removed text. 3671 /* The fontification code may have added/removed text.
@@ -7306,7 +7305,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
7306 7305
7307 default: 7306 default:
7308 /* There are no other methods defined, so this should be a bug. */ 7307 /* There are no other methods defined, so this should be a bug. */
7309 abort (); 7308 emacs_abort ();
7310 } 7309 }
7311 7310
7312 eassert (it->method != GET_FROM_STRING 7311 eassert (it->method != GET_FROM_STRING
@@ -7761,7 +7760,7 @@ compute_stop_pos_backwards (struct it *it)
7761 compute_stop_pos (it); 7760 compute_stop_pos (it);
7762 /* We must advance forward, right? */ 7761 /* We must advance forward, right? */
7763 if (it->stop_charpos <= charpos) 7762 if (it->stop_charpos <= charpos)
7764 abort (); 7763 emacs_abort ();
7765 } 7764 }
7766 while (charpos > BEGV && it->stop_charpos >= it->end_charpos); 7765 while (charpos > BEGV && it->stop_charpos >= it->end_charpos);
7767 7766
@@ -7810,7 +7809,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
7810 compute_stop_pos (it); 7809 compute_stop_pos (it);
7811 /* We must advance forward, right? */ 7810 /* We must advance forward, right? */
7812 if (it->stop_charpos <= it->prev_stop) 7811 if (it->stop_charpos <= it->prev_stop)
7813 abort (); 7812 emacs_abort ();
7814 charpos = it->stop_charpos; 7813 charpos = it->stop_charpos;
7815 } 7814 }
7816 while (charpos <= where_we_are); 7815 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
8898 break; 8897 break;
8899 8898
8900 default: 8899 default:
8901 abort (); 8900 emacs_abort ();
8902 } 8901 }
8903 8902
8904 /* Reset/increment for the next run. */ 8903 /* Reset/increment for the next run. */
@@ -9291,12 +9290,6 @@ add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2)
9291 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9290 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9292 USE_SAFE_ALLOCA; 9291 USE_SAFE_ALLOCA;
9293 9292
9294 /* Do nothing if called asynchronously. Inserting text into
9295 a buffer may call after-change-functions and alike and
9296 that would means running Lisp asynchronously. */
9297 if (handling_signal)
9298 return;
9299
9300 fmt = msg = Qnil; 9293 fmt = msg = Qnil;
9301 GCPRO4 (fmt, msg, arg1, arg2); 9294 GCPRO4 (fmt, msg, arg1, arg2);
9302 9295
@@ -9909,7 +9902,7 @@ ensure_echo_area_buffers (void)
9909 9902
9910 for (i = 0; i < 2; ++i) 9903 for (i = 0; i < 2; ++i)
9911 if (!BUFFERP (echo_buffer[i]) 9904 if (!BUFFERP (echo_buffer[i])
9912 || NILP (BVAR (XBUFFER (echo_buffer[i]), name))) 9905 || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i])))
9913 { 9906 {
9914 char name[30]; 9907 char name[30];
9915 Lisp_Object old_buffer; 9908 Lisp_Object old_buffer;
@@ -10532,7 +10525,7 @@ void
10532check_message_stack (void) 10525check_message_stack (void)
10533{ 10526{
10534 if (!NILP (Vmessage_stack)) 10527 if (!NILP (Vmessage_stack))
10535 abort (); 10528 emacs_abort ();
10536} 10529}
10537 10530
10538 10531
@@ -10571,7 +10564,6 @@ truncate_message_1 (ptrdiff_t nchars, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4
10571 return 0; 10564 return 0;
10572} 10565}
10573 10566
10574
10575/* Set the current message to a substring of S or STRING. 10567/* Set the current message to a substring of S or STRING.
10576 10568
10577 If STRING is a Lisp string, set the message to the first NBYTES 10569 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,
10598 (intptr_t) s, string, nbytes, multibyte_p); 10590 (intptr_t) s, string, nbytes, multibyte_p);
10599 message_buf_print = 0; 10591 message_buf_print = 0;
10600 help_echo_showing_p = 0; 10592 help_echo_showing_p = 0;
10593
10594 if (STRINGP (Vdebug_on_message)
10595 && fast_string_match (Vdebug_on_message, string) >= 0)
10596 call_debugger (list2 (Qerror, string));
10601} 10597}
10602 10598
10603 10599
@@ -12789,7 +12785,7 @@ overlay_arrow_at_row (struct it *it, struct glyph_row *row)
12789 return make_number (fringe_bitmap); 12785 return make_number (fringe_bitmap);
12790 } 12786 }
12791#endif 12787#endif
12792 return make_number (-1); /* Use default arrow bitmap */ 12788 return make_number (-1); /* Use default arrow bitmap. */
12793 } 12789 }
12794 return overlay_arrow_string_or_property (var); 12790 return overlay_arrow_string_or_property (var);
12795 } 12791 }
@@ -12966,12 +12962,11 @@ redisplay_internal (void)
12966 if (redisplaying_p) 12962 if (redisplaying_p)
12967 return; 12963 return;
12968 12964
12969 /* Record a function that resets redisplaying_p to its old value 12965 /* Record a function that clears redisplaying_p
12970 when we leave this function. */ 12966 when we leave this function. */
12971 count = SPECPDL_INDEX (); 12967 count = SPECPDL_INDEX ();
12972 record_unwind_protect (unwind_redisplay, 12968 record_unwind_protect (unwind_redisplay, selected_frame);
12973 Fcons (make_number (redisplaying_p), selected_frame)); 12969 redisplaying_p = 1;
12974 ++redisplaying_p;
12975 specbind (Qinhibit_free_realized_faces, Qnil); 12970 specbind (Qinhibit_free_realized_faces, Qnil);
12976 12971
12977 { 12972 {
@@ -13709,21 +13704,15 @@ redisplay_preserve_echo_area (int from_where)
13709} 13704}
13710 13705
13711 13706
13712/* Function registered with record_unwind_protect in 13707/* Function registered with record_unwind_protect in redisplay_internal.
13713 redisplay_internal. Reset redisplaying_p to the value it had 13708 Clear redisplaying_p. Also, select the previously
13714 before redisplay_internal was called, and clear
13715 prevent_freeing_realized_faces_p. It also selects the previously
13716 selected frame, unless it has been deleted (by an X connection 13709 selected frame, unless it has been deleted (by an X connection
13717 failure during redisplay, for example). */ 13710 failure during redisplay, for example). */
13718 13711
13719static Lisp_Object 13712static Lisp_Object
13720unwind_redisplay (Lisp_Object val) 13713unwind_redisplay (Lisp_Object old_frame)
13721{ 13714{
13722 Lisp_Object old_redisplaying_p, old_frame; 13715 redisplaying_p = 0;
13723
13724 old_redisplaying_p = XCAR (val);
13725 redisplaying_p = XFASTINT (old_redisplaying_p);
13726 old_frame = XCDR (val);
13727 if (! EQ (old_frame, selected_frame) 13716 if (! EQ (old_frame, selected_frame)
13728 && FRAME_LIVE_P (XFRAME (old_frame))) 13717 && FRAME_LIVE_P (XFRAME (old_frame)))
13729 select_frame_for_redisplay (old_frame); 13718 select_frame_for_redisplay (old_frame);
@@ -14422,7 +14411,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14422 for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) 14411 for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++)
14423 { 14412 {
14424 if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]) 14413 if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA])
14425 abort (); 14414 emacs_abort ();
14426 x += g->pixel_width; 14415 x += g->pixel_width;
14427 } 14416 }
14428 } 14417 }
@@ -14543,7 +14532,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14543 SET_MARKER_FROM_TEXT_POS (w->start, startp); 14532 SET_MARKER_FROM_TEXT_POS (w->start, startp);
14544 14533
14545 if (current_buffer != XBUFFER (w->buffer)) 14534 if (current_buffer != XBUFFER (w->buffer))
14546 abort (); 14535 emacs_abort ();
14547 14536
14548 if (!NILP (Vwindow_scroll_functions)) 14537 if (!NILP (Vwindow_scroll_functions))
14549 { 14538 {
@@ -15512,9 +15501,9 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15512 /* Some sanity checks. */ 15501 /* Some sanity checks. */
15513 CHECK_WINDOW_END (w); 15502 CHECK_WINDOW_END (w);
15514 if (Z == Z_BYTE && CHARPOS (opoint) != BYTEPOS (opoint)) 15503 if (Z == Z_BYTE && CHARPOS (opoint) != BYTEPOS (opoint))
15515 abort (); 15504 emacs_abort ();
15516 if (BYTEPOS (opoint) < CHARPOS (opoint)) 15505 if (BYTEPOS (opoint) < CHARPOS (opoint))
15517 abort (); 15506 emacs_abort ();
15518 15507
15519 /* If %c is in mode line, update it if needed. */ 15508 /* If %c is in mode line, update it if needed. */
15520 if (!NILP (w->column_number_displayed) 15509 if (!NILP (w->column_number_displayed)
@@ -15726,7 +15715,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15726 goto try_to_scroll; 15715 goto try_to_scroll;
15727 15716
15728 default: 15717 default:
15729 abort (); 15718 emacs_abort ();
15730 } 15719 }
15731 } 15720 }
15732 /* If current starting point was originally the beginning of a line 15721 /* 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)
15889 break; 15878 break;
15890 15879
15891 default: 15880 default:
15892 abort (); 15881 emacs_abort ();
15893 } 15882 }
15894 } 15883 }
15895 15884
@@ -17337,7 +17326,7 @@ try_window_id (struct window *w)
17337 if (row) 17326 if (row)
17338 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); 17327 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
17339 else 17328 else
17340 abort (); 17329 emacs_abort ();
17341 return 1; 17330 return 1;
17342 } 17331 }
17343 } 17332 }
@@ -17381,7 +17370,7 @@ try_window_id (struct window *w)
17381 if (row) 17370 if (row)
17382 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); 17371 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
17383 else 17372 else
17384 abort (); 17373 emacs_abort ();
17385 return 2; 17374 return 2;
17386 } 17375 }
17387 } 17376 }
@@ -17870,7 +17859,7 @@ try_window_id (struct window *w)
17870 IF_DEBUG (debug_method_add (w, "C")); 17859 IF_DEBUG (debug_method_add (w, "C"));
17871 } 17860 }
17872 else 17861 else
17873 abort (); 17862 emacs_abort ();
17874 17863
17875 IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos); 17864 IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos);
17876 debug_end_vpos = XFASTINT (w->window_end_vpos)); 17865 debug_end_vpos = XFASTINT (w->window_end_vpos));
@@ -19247,7 +19236,7 @@ find_row_edges (struct it *it, struct glyph_row *row,
19247 /* A line that is entirely from a string/image/stretch... */ 19236 /* A line that is entirely from a string/image/stretch... */
19248 row->maxpos = row->minpos; 19237 row->maxpos = row->minpos;
19249 else 19238 else
19250 abort (); 19239 emacs_abort ();
19251 } 19240 }
19252 else 19241 else
19253 row->maxpos = it->current.pos; 19242 row->maxpos = it->current.pos;
@@ -20088,7 +20077,7 @@ See also `bidi-paragraph-direction'. */)
20088 return Qright_to_left; 20077 return Qright_to_left;
20089 break; 20078 break;
20090 default: 20079 default:
20091 abort (); 20080 emacs_abort ();
20092 } 20081 }
20093 } 20082 }
20094} 20083}
@@ -21043,8 +21032,7 @@ are the selected window and the WINDOW's buffer). */)
21043 : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID 21032 : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID
21044 : DEFAULT_FACE_ID; 21033 : DEFAULT_FACE_ID;
21045 21034
21046 if (XBUFFER (buffer) != current_buffer) 21035 old_buffer = current_buffer;
21047 old_buffer = current_buffer;
21048 21036
21049 /* Save things including mode_line_proptrans_alist, 21037 /* Save things including mode_line_proptrans_alist,
21050 and set that to nil so that we don't alter the outer value. */ 21038 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). */)
21055 mode_line_proptrans_alist = Qnil; 21043 mode_line_proptrans_alist = Qnil;
21056 21044
21057 Fselect_window (window, Qt); 21045 Fselect_window (window, Qt);
21058 if (old_buffer) 21046 set_buffer_internal_1 (XBUFFER (buffer));
21059 set_buffer_internal_1 (XBUFFER (buffer));
21060 21047
21061 init_iterator (&it, w, -1, -1, NULL, face_id); 21048 init_iterator (&it, w, -1, -1, NULL, face_id);
21062 21049
@@ -22001,7 +21988,7 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st
22001 { 21988 {
22002 /* Glyph is off the left margin of the display area. 21989 /* Glyph is off the left margin of the display area.
22003 Should not happen. */ 21990 Should not happen. */
22004 abort (); 21991 emacs_abort ();
22005 } 21992 }
22006 21993
22007 row->ascent = max (row->ascent, it->max_ascent); 21994 row->ascent = max (row->ascent, it->max_ascent);
@@ -23046,7 +23033,8 @@ right_overwritten (struct glyph_string *s)
23046 { 23033 {
23047 int x = 0, i; 23034 int x = 0, i;
23048 struct glyph *glyphs = s->row->glyphs[s->area]; 23035 struct glyph *glyphs = s->row->glyphs[s->area];
23049 int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); 23036 int first = (s->first_glyph - glyphs
23037 + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars));
23050 int end = s->row->used[s->area]; 23038 int end = s->row->used[s->area];
23051 23039
23052 for (i = first; i < end && s->right_overhang > x; ++i) 23040 for (i = first; i < end && s->right_overhang > x; ++i)
@@ -23069,7 +23057,8 @@ right_overwriting (struct glyph_string *s)
23069 int i, k, x; 23057 int i, k, x;
23070 int end = s->row->used[s->area]; 23058 int end = s->row->used[s->area];
23071 struct glyph *glyphs = s->row->glyphs[s->area]; 23059 struct glyph *glyphs = s->row->glyphs[s->area];
23072 int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); 23060 int first = (s->first_glyph - glyphs
23061 + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars));
23073 23062
23074 k = -1; 23063 k = -1;
23075 x = 0; 23064 x = 0;
@@ -23366,7 +23355,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
23366 break; \ 23355 break; \
23367 \ 23356 \
23368 default: \ 23357 default: \
23369 abort (); \ 23358 emacs_abort (); \
23370 } \ 23359 } \
23371 \ 23360 \
23372 if (s) \ 23361 if (s) \
@@ -23707,7 +23696,7 @@ append_glyph (struct it *it)
23707 { 23696 {
23708 glyph->resolved_level = it->bidi_it.resolved_level; 23697 glyph->resolved_level = it->bidi_it.resolved_level;
23709 if ((it->bidi_it.type & 7) != it->bidi_it.type) 23698 if ((it->bidi_it.type & 7) != it->bidi_it.type)
23710 abort (); 23699 emacs_abort ();
23711 glyph->bidi_type = it->bidi_it.type; 23700 glyph->bidi_type = it->bidi_it.type;
23712 } 23701 }
23713 else 23702 else
@@ -23781,7 +23770,7 @@ append_composite_glyph (struct it *it)
23781 { 23770 {
23782 glyph->resolved_level = it->bidi_it.resolved_level; 23771 glyph->resolved_level = it->bidi_it.resolved_level;
23783 if ((it->bidi_it.type & 7) != it->bidi_it.type) 23772 if ((it->bidi_it.type & 7) != it->bidi_it.type)
23784 abort (); 23773 emacs_abort ();
23785 glyph->bidi_type = it->bidi_it.type; 23774 glyph->bidi_type = it->bidi_it.type;
23786 } 23775 }
23787 ++it->glyph_row->used[area]; 23776 ++it->glyph_row->used[area];
@@ -23960,7 +23949,7 @@ produce_image_glyph (struct it *it)
23960 { 23949 {
23961 glyph->resolved_level = it->bidi_it.resolved_level; 23950 glyph->resolved_level = it->bidi_it.resolved_level;
23962 if ((it->bidi_it.type & 7) != it->bidi_it.type) 23951 if ((it->bidi_it.type & 7) != it->bidi_it.type)
23963 abort (); 23952 emacs_abort ();
23964 glyph->bidi_type = it->bidi_it.type; 23953 glyph->bidi_type = it->bidi_it.type;
23965 } 23954 }
23966 ++it->glyph_row->used[area]; 23955 ++it->glyph_row->used[area];
@@ -24021,7 +24010,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object,
24021 { 24010 {
24022 glyph->resolved_level = it->bidi_it.resolved_level; 24011 glyph->resolved_level = it->bidi_it.resolved_level;
24023 if ((it->bidi_it.type & 7) != it->bidi_it.type) 24012 if ((it->bidi_it.type & 7) != it->bidi_it.type)
24024 abort (); 24013 emacs_abort ();
24025 glyph->bidi_type = it->bidi_it.type; 24014 glyph->bidi_type = it->bidi_it.type;
24026 } 24015 }
24027 else 24016 else
@@ -24276,7 +24265,7 @@ produce_special_glyphs (struct it *it, enum display_element_type what)
24276 } 24265 }
24277 } 24266 }
24278 else 24267 else
24279 abort (); 24268 emacs_abort ();
24280 24269
24281#ifdef HAVE_WINDOW_SYSTEM 24270#ifdef HAVE_WINDOW_SYSTEM
24282 /* On a GUI frame, when the right fringe (left fringe for R2L rows) 24271 /* 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,
24473 { 24462 {
24474 glyph->resolved_level = it->bidi_it.resolved_level; 24463 glyph->resolved_level = it->bidi_it.resolved_level;
24475 if ((it->bidi_it.type & 7) != it->bidi_it.type) 24464 if ((it->bidi_it.type & 7) != it->bidi_it.type)
24476 abort (); 24465 emacs_abort ();
24477 glyph->bidi_type = it->bidi_it.type; 24466 glyph->bidi_type = it->bidi_it.type;
24478 } 24467 }
24479 ++it->glyph_row->used[area]; 24468 ++it->glyph_row->used[area];
@@ -29306,6 +29295,10 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
29306 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil); 29295 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
29307 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0), 29296 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
29308 Qempty_box); 29297 Qempty_box);
29298
29299 DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
29300 doc: /* If non-nil, debug if a message matching this regexp is displayed. */);
29301 Vdebug_on_message = Qnil;
29309} 29302}
29310 29303
29311 29304
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/>. */
204#include <sys/types.h> 204#include <sys/types.h>
205#include <sys/stat.h> 205#include <sys/stat.h>
206#include <stdio.h> /* This needs to be before termchar.h */ 206#include <stdio.h> /* This needs to be before termchar.h */
207#include <setjmp.h>
208 207
209#include "lisp.h" 208#include "lisp.h"
210#include "character.h" 209#include "character.h"
@@ -315,9 +314,10 @@ static Lisp_Object QCfontset;
315Lisp_Object Qnormal; 314Lisp_Object Qnormal;
316Lisp_Object Qbold; 315Lisp_Object Qbold;
317static Lisp_Object Qline, Qwave; 316static Lisp_Object Qline, Qwave;
318Lisp_Object Qultra_light, Qextra_light, Qlight; 317static Lisp_Object Qultra_light, Qreverse_oblique, Qreverse_italic;
318Lisp_Object Qextra_light, Qlight;
319Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; 319Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
320Lisp_Object Qoblique, Qreverse_oblique, Qreverse_italic; 320Lisp_Object Qoblique;
321Lisp_Object Qitalic; 321Lisp_Object Qitalic;
322static Lisp_Object Qultra_condensed, Qextra_condensed; 322static Lisp_Object Qultra_condensed, Qextra_condensed;
323Lisp_Object Qcondensed; 323Lisp_Object Qcondensed;
@@ -452,18 +452,7 @@ static int menu_face_changed_default;
452struct table_entry; 452struct table_entry;
453struct named_merge_point; 453struct named_merge_point;
454 454
455static void map_tty_color (struct frame *, struct face *,
456 enum lface_attribute_index, int *);
457static Lisp_Object resolve_face_name (Lisp_Object, int);
458static void set_font_frame_param (Lisp_Object, Lisp_Object); 455static void set_font_frame_param (Lisp_Object, Lisp_Object);
459static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *,
460 int, struct named_merge_point *);
461static ptrdiff_t load_pixmap (struct frame *, Lisp_Object,
462 unsigned *, unsigned *);
463static struct frame *frame_or_selected_frame (Lisp_Object, int);
464static void load_face_colors (struct frame *, struct face *, Lisp_Object *);
465static void free_face_colors (struct frame *, struct face *);
466static int face_color_gray_p (struct frame *, const char *);
467static struct face *realize_face (struct face_cache *, Lisp_Object *, 456static struct face *realize_face (struct face_cache *, Lisp_Object *,
468 int); 457 int);
469static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, 458static 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 *);
473static int realize_basic_faces (struct frame *); 462static int realize_basic_faces (struct frame *);
474static int realize_default_face (struct frame *); 463static int realize_default_face (struct frame *);
475static void realize_named_face (struct frame *, Lisp_Object, int); 464static void realize_named_face (struct frame *, Lisp_Object, int);
476static int lface_fully_specified_p (Lisp_Object *);
477static int lface_equal_p (Lisp_Object *, Lisp_Object *);
478static unsigned hash_string_case_insensitive (Lisp_Object);
479static unsigned lface_hash (Lisp_Object *);
480static int lface_same_font_attributes_p (Lisp_Object *, Lisp_Object *);
481static struct face_cache *make_face_cache (struct frame *); 465static struct face_cache *make_face_cache (struct frame *);
482static void clear_face_gcs (struct face_cache *); 466static void clear_face_gcs (struct face_cache *);
483static void free_face_cache (struct face_cache *); 467static void free_face_cache (struct face_cache *);
484static int face_fontset (Lisp_Object *);
485static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*,
486 struct named_merge_point *);
487static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, 468static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *,
488 int, struct named_merge_point *); 469 int, struct named_merge_point *);
489static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object,
490 int);
491static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int);
492static struct face *make_realized_face (Lisp_Object *);
493static void cache_face (struct face_cache *, struct face *, unsigned);
494static void uncache_face (struct face_cache *, struct face *);
495
496#ifdef HAVE_WINDOW_SYSTEM
497
498static GC x_create_gc (struct frame *, unsigned long, XGCValues *);
499static void x_free_gc (struct frame *, GC);
500
501#ifdef USE_X_TOOLKIT
502static void x_update_menu_appearance (struct frame *);
503
504extern void free_frame_menubar (struct frame *);
505#endif /* USE_X_TOOLKIT */
506
507#endif /* HAVE_WINDOW_SYSTEM */
508 470
509 471
510/*********************************************************************** 472/***********************************************************************
@@ -547,7 +509,7 @@ unregister_color (unsigned long pixel)
547 if (color_count[pixel] > 0) 509 if (color_count[pixel] > 0)
548 --color_count[pixel]; 510 --color_count[pixel];
549 else 511 else
550 abort (); 512 emacs_abort ();
551} 513}
552 514
553 515
@@ -698,7 +660,7 @@ x_create_gc (struct frame *f,
698 XGCValues *xgcv) 660 XGCValues *xgcv)
699{ 661{
700 GC gc = xmalloc (sizeof *gc); 662 GC gc = xmalloc (sizeof *gc);
701 memcpy (gc, xgcv, sizeof (XGCValues)); 663 *gc = *xgcv;
702 return gc; 664 return gc;
703} 665}
704 666
@@ -764,7 +726,7 @@ init_frame_faces (struct frame *f)
764 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) 726 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f))
765#endif 727#endif
766 if (!realize_basic_faces (f)) 728 if (!realize_basic_faces (f))
767 abort (); 729 emacs_abort ();
768} 730}
769 731
770 732
@@ -808,7 +770,7 @@ recompute_basic_faces (struct frame *f)
808 { 770 {
809 clear_face_cache (0); 771 clear_face_cache (0);
810 if (!realize_basic_faces (f)) 772 if (!realize_basic_faces (f))
811 abort (); 773 emacs_abort ();
812 } 774 }
813} 775}
814 776
@@ -1145,7 +1107,7 @@ defined_color (struct frame *f, const char *color_name, XColor *color_def,
1145 return ns_defined_color (f, color_name, color_def, alloc, 1); 1107 return ns_defined_color (f, color_name, color_def, alloc, 1);
1146#endif 1108#endif
1147 else 1109 else
1148 abort (); 1110 emacs_abort ();
1149} 1111}
1150 1112
1151 1113
@@ -1341,7 +1303,7 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
1341 break; 1303 break;
1342 1304
1343 default: 1305 default:
1344 abort (); 1306 emacs_abort ();
1345 } 1307 }
1346 } 1308 }
1347#ifdef GLYPH_DEBUG 1309#ifdef GLYPH_DEBUG
@@ -4585,7 +4547,7 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, int signal_p)
4585 return -1; 4547 return -1;
4586 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 4548 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
4587 if (default_face == NULL) 4549 if (default_face == NULL)
4588 abort (); /* realize_basic_faces must have set it up */ 4550 emacs_abort (); /* realize_basic_faces must have set it up */
4589 } 4551 }
4590 4552
4591 if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) 4553 if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
@@ -4628,7 +4590,7 @@ lookup_basic_face (struct frame *f, int face_id)
4628 case MENU_FACE_ID: name = Qmenu; break; 4590 case MENU_FACE_ID: name = Qmenu; break;
4629 4591
4630 default: 4592 default:
4631 abort (); /* the caller is supposed to pass us a basic face id */ 4593 emacs_abort (); /* the caller is supposed to pass us a basic face id */
4632 } 4594 }
4633 4595
4634 /* Do a quick scan through Vface_remapping_alist, and return immediately 4596 /* 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,
4749 struct face *default_face = FACE_FROM_ID (f, face_id); 4711 struct face *default_face = FACE_FROM_ID (f, face_id);
4750 4712
4751 if (!default_face) 4713 if (!default_face)
4752 abort (); 4714 emacs_abort ();
4753 4715
4754 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) 4716 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
4755 return -1; 4717 return -1;
@@ -5139,7 +5101,7 @@ face for italic. */)
5139 error ("Cannot realize default face"); 5101 error ("Cannot realize default face");
5140 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 5102 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
5141 if (def_face == NULL) 5103 if (def_face == NULL)
5142 abort (); /* realize_basic_faces must have set it up */ 5104 emacs_abort (); /* realize_basic_faces must have set it up */
5143 } 5105 }
5144 5106
5145 /* Dispatch to the appropriate handler. */ 5107 /* Dispatch to the appropriate handler. */
@@ -5424,7 +5386,7 @@ realize_default_face (struct frame *f)
5424 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) 5386 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5425 ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg)); 5387 ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg));
5426 else 5388 else
5427 abort (); 5389 emacs_abort ();
5428 } 5390 }
5429 5391
5430 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) 5392 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
@@ -5439,7 +5401,7 @@ realize_default_face (struct frame *f)
5439 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) 5401 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5440 ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg)); 5402 ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg));
5441 else 5403 else
5442 abort (); 5404 emacs_abort ();
5443 } 5405 }
5444 5406
5445 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) 5407 if (UNSPECIFIEDP (LFACE_STIPPLE (lface)))
@@ -5539,7 +5501,7 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id)
5539 face = make_realized_face (attrs); 5501 face = make_realized_face (attrs);
5540 } 5502 }
5541 else 5503 else
5542 abort (); 5504 emacs_abort ();
5543 5505
5544 /* Insert the new face. */ 5506 /* Insert the new face. */
5545 cache_face (cache, face, lface_hash (attrs)); 5507 cache_face (cache, face, lface_hash (attrs));
@@ -5634,7 +5596,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
5634 if (default_face) 5596 if (default_face)
5635 fontset = default_face->fontset; 5597 fontset = default_face->fontset;
5636 if (fontset == -1) 5598 if (fontset == -1)
5637 abort (); 5599 emacs_abort ();
5638 } 5600 }
5639 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX])) 5601 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
5640 attrs[LFACE_FONT_INDEX] 5602 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/>. */
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <math.h> 22#include <math.h>
23#include <setjmp.h>
24#include <unistd.h> 23#include <unistd.h>
25 24
26/* This makes the fields of a Display accessible, in Xlib header files. */ 25/* 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
@@ -46,7 +45,6 @@ struct xfont_info
46}; 45};
47 46
48/* Prototypes of support functions. */ 47/* Prototypes of support functions. */
49extern void x_clear_errors (Display *);
50 48
51static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); 49static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *);
52 50
@@ -127,7 +125,7 @@ static int xfont_has_char (Lisp_Object, int);
127static unsigned xfont_encode_char (struct font *, int); 125static unsigned xfont_encode_char (struct font *, int);
128static int xfont_text_extents (struct font *, unsigned *, int, 126static int xfont_text_extents (struct font *, unsigned *, int,
129 struct font_metrics *); 127 struct font_metrics *);
130static int xfont_draw (struct glyph_string *, int, int, int, int, int); 128static int xfont_draw (struct glyph_string *, int, int, int, int, bool);
131static int xfont_check (FRAME_PTR, struct font *); 129static int xfont_check (FRAME_PTR, struct font *);
132 130
133struct font_driver xfont_driver = 131struct font_driver xfont_driver =
@@ -218,9 +216,9 @@ xfont_encode_coding_xlfd (char *xlfd)
218/* Check if CHARS (cons or vector) is supported by XFONT whose 216/* Check if CHARS (cons or vector) is supported by XFONT whose
219 encoding charset is ENCODING (XFONT is NULL) or by a font whose 217 encoding charset is ENCODING (XFONT is NULL) or by a font whose
220 registry corresponds to ENCODING and REPERTORY. 218 registry corresponds to ENCODING and REPERTORY.
221 Return 1 if supported, return 0 otherwise. */ 219 Return true if supported. */
222 220
223static int 221static bool
224xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, 222xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
225 struct charset *encoding, struct charset *repertory) 223 struct charset *encoding, struct charset *repertory)
226{ 224{
@@ -1020,7 +1018,8 @@ xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct f
1020} 1018}
1021 1019
1022static int 1020static int
1023xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 1021xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1022 bool with_background)
1024{ 1023{
1025 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; 1024 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont;
1026 int len = to - from; 1025 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
1041 for (i = 0; i < len ; i++) 1040 for (i = 0; i < len ; i++)
1042 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); 1041 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
1043 BLOCK_INPUT; 1042 BLOCK_INPUT;
1044 if (with_background > 0) 1043 if (with_background)
1045 { 1044 {
1046 if (s->padding_p) 1045 if (s->padding_p)
1047 for (i = 0; i < len; i++) 1046 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
1067 } 1066 }
1068 1067
1069 BLOCK_INPUT; 1068 BLOCK_INPUT;
1070 if (with_background > 0) 1069 if (with_background)
1071 { 1070 {
1072 if (s->padding_p) 1071 if (s->padding_p)
1073 for (i = 0; i < len; i++) 1072 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/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26#include <X11/Xft/Xft.h> 25#include <X11/Xft/Xft.h>
27 26
@@ -52,7 +51,7 @@ struct xftfont_info
52 /* The following five members must be here in this order to be 51 /* The following five members must be here in this order to be
53 compatible with struct ftfont_info (in ftfont.c). */ 52 compatible with struct ftfont_info (in ftfont.c). */
54#ifdef HAVE_LIBOTF 53#ifdef HAVE_LIBOTF
55 int maybe_otf; /* Flag to tell if this may be OTF or not. */ 54 bool maybe_otf; /* Flag to tell if this may be OTF or not. */
56 OTF *otf; 55 OTF *otf;
57#endif /* HAVE_LIBOTF */ 56#endif /* HAVE_LIBOTF */
58 FT_Size ft_size; 57 FT_Size ft_size;
@@ -92,7 +91,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
92 else 91 else
93 { 92 {
94 XGCValues xgcv; 93 XGCValues xgcv;
95 int fg_done = 0, bg_done = 0; 94 bool fg_done = 0, bg_done = 0;
96 95
97 BLOCK_INPUT; 96 BLOCK_INPUT;
98 XGetGCValues (FRAME_X_DISPLAY (f), gc, 97 XGetGCValues (FRAME_X_DISPLAY (f), gc,
@@ -111,7 +110,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
111 *bg = xftface_info->xft_fg, bg_done = 1; 110 *bg = xftface_info->xft_fg, bg_done = 1;
112 } 111 }
113 112
114 if (fg_done + bg_done < 2) 113 if (! (fg_done & bg_done))
115 { 114 {
116 XColor colors[2]; 115 XColor colors[2];
117 116
@@ -137,19 +136,6 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
137} 136}
138 137
139 138
140static Lisp_Object xftfont_list (Lisp_Object, Lisp_Object);
141static Lisp_Object xftfont_match (Lisp_Object, Lisp_Object);
142static Lisp_Object xftfont_open (FRAME_PTR, Lisp_Object, int);
143static void xftfont_close (FRAME_PTR, struct font *);
144static int xftfont_prepare_face (FRAME_PTR, struct face *);
145static void xftfont_done_face (FRAME_PTR, struct face *);
146static int xftfont_has_char (Lisp_Object, int);
147static unsigned xftfont_encode_char (struct font *, int);
148static int xftfont_text_extents (struct font *, unsigned *, int,
149 struct font_metrics *);
150static int xftfont_draw (struct glyph_string *, int, int, int, int, int);
151static int xftfont_end_for_frame (FRAME_PTR f);
152
153struct font_driver xftfont_driver; 139struct font_driver xftfont_driver;
154 140
155static Lisp_Object 141static Lisp_Object
@@ -470,7 +456,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
470 font->underline_thickness = 0; 456 font->underline_thickness = 0;
471 } 457 }
472#ifdef HAVE_LIBOTF 458#ifdef HAVE_LIBOTF
473 xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; 459 xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
474 xftfont_info->otf = NULL; 460 xftfont_info->otf = NULL;
475#endif /* HAVE_LIBOTF */ 461#endif /* HAVE_LIBOTF */
476 xftfont_info->ft_size = ft_face->size; 462 xftfont_info->ft_size = ft_face->size;
@@ -630,7 +616,8 @@ xftfont_get_xft_draw (FRAME_PTR f)
630} 616}
631 617
632static int 618static int
633xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 619xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
620 bool with_background)
634{ 621{
635 FRAME_PTR f = s->f; 622 FRAME_PTR f = s->f;
636 struct face *face = s->face; 623 struct face *face = s->face;
@@ -711,15 +698,17 @@ xftfont_end_for_frame (FRAME_PTR f)
711 return 0; 698 return 0;
712} 699}
713 700
714static int 701static bool
715xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity) 702xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
703 Lisp_Object entity)
716{ 704{
717 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object); 705 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object);
718 FcPattern *oldpat = info->xftfont->pattern; 706 FcPattern *oldpat = info->xftfont->pattern;
719 Display *display = FRAME_X_DISPLAY (f); 707 Display *display = FRAME_X_DISPLAY (f);
720 FcPattern *pat = FcPatternCreate (); 708 FcPattern *pat = FcPatternCreate ();
721 FcBool b1, b2; 709 FcBool b1, b2;
722 int ok = 0, i1, i2, r1, r2; 710 bool ok = 0;
711 int i1, i2, r1, r2;
723 712
724 xftfont_add_rendering_parameters (pat, entity); 713 xftfont_add_rendering_parameters (pat, entity);
725 XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); 714 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/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include <setjmp.h>
23#include "xgselect.h" 22#include "xgselect.h"
24 23
25#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 24#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
26 25
27#include <glib.h> 26#include <glib.h>
28#include <errno.h> 27#include <errno.h>
29#include <setjmp.h>
30#include "xterm.h" 28#include "xterm.h"
31 29
32int 30int
@@ -49,9 +47,9 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
49 && g_main_context_pending (context = g_main_context_default ()))) 47 && g_main_context_pending (context = g_main_context_default ())))
50 return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); 48 return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask);
51 49
52 if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); 50 if (rfds) all_rfds = *rfds;
53 else FD_ZERO (&all_rfds); 51 else FD_ZERO (&all_rfds);
54 if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); 52 if (wfds) all_wfds = *wfds;
55 else FD_ZERO (&all_wfds); 53 else FD_ZERO (&all_wfds);
56 54
57 n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, 55 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/>. */
32 32
33#include <config.h> 33#include <config.h>
34 34
35#if 0 /* Why was this included? And without syssignal.h? */
36/* On 4.3 this loses if it comes after xterm.h. */
37#include <signal.h>
38#endif
39
40#include <stdio.h> 35#include <stdio.h>
41#include <setjmp.h>
42 36
43#include "lisp.h" 37#include "lisp.h"
44#include "keyboard.h" 38#include "keyboard.h"
@@ -169,7 +163,7 @@ mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
169 int dummy; 163 int dummy;
170 164
171 if (! FRAME_X_P (f)) 165 if (! FRAME_X_P (f))
172 abort (); 166 emacs_abort ();
173 167
174 BLOCK_INPUT; 168 BLOCK_INPUT;
175 169
@@ -636,7 +630,7 @@ void
636x_activate_menubar (FRAME_PTR f) 630x_activate_menubar (FRAME_PTR f)
637{ 631{
638 if (! FRAME_X_P (f)) 632 if (! FRAME_X_P (f))
639 abort (); 633 emacs_abort ();
640 634
641 if (!f->output_data.x->saved_menu_event->type) 635 if (!f->output_data.x->saved_menu_event->type)
642 return; 636 return;
@@ -852,7 +846,7 @@ update_frame_menubar (FRAME_PTR f)
852 int columns, rows; 846 int columns, rows;
853 847
854 if (! FRAME_X_P (f)) 848 if (! FRAME_X_P (f))
855 abort (); 849 emacs_abort ();
856 850
857 x = f->output_data.x; 851 x = f->output_data.x;
858 852
@@ -940,7 +934,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
940 int *submenu_top_level_items, *submenu_n_panes; 934 int *submenu_top_level_items, *submenu_n_panes;
941 935
942 if (! FRAME_X_P (f)) 936 if (! FRAME_X_P (f))
943 abort (); 937 emacs_abort ();
944 938
945 menubar_widget = f->output_data.x->menubar_widget; 939 menubar_widget = f->output_data.x->menubar_widget;
946 940
@@ -1299,7 +1293,7 @@ free_frame_menubar (FRAME_PTR f)
1299 Widget menubar_widget; 1293 Widget menubar_widget;
1300 1294
1301 if (! FRAME_X_P (f)) 1295 if (! FRAME_X_P (f))
1302 abort (); 1296 emacs_abort ();
1303 1297
1304 menubar_widget = f->output_data.x->menubar_widget; 1298 menubar_widget = f->output_data.x->menubar_widget;
1305 1299
@@ -1450,7 +1444,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y,
1450#endif 1444#endif
1451 1445
1452 if (! FRAME_X_P (f)) 1446 if (! FRAME_X_P (f))
1453 abort (); 1447 emacs_abort ();
1454 1448
1455 xg_crazy_callback_abort = 1; 1449 xg_crazy_callback_abort = 1;
1456 menu = xg_create_widget ("popup", first_wv->name, f, first_wv, 1450 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,
1557 Widget menu; 1551 Widget menu;
1558 1552
1559 if (! FRAME_X_P (f)) 1553 if (! FRAME_X_P (f))
1560 abort (); 1554 emacs_abort ();
1561 1555
1562#ifdef USE_LUCID 1556#ifdef USE_LUCID
1563 apply_systemfont_to_menu (f, f->output_data.x->widget); 1557 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,
1646 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 1640 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
1647 1641
1648 if (! FRAME_X_P (f)) 1642 if (! FRAME_X_P (f))
1649 abort (); 1643 emacs_abort ();
1650 1644
1651 *error_name = NULL; 1645 *error_name = NULL;
1652 1646
@@ -1792,7 +1786,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1792 else if (EQ (type, QCradio)) 1786 else if (EQ (type, QCradio))
1793 wv->button_type = BUTTON_TYPE_RADIO; 1787 wv->button_type = BUTTON_TYPE_RADIO;
1794 else 1788 else
1795 abort (); 1789 emacs_abort ();
1796 1790
1797 wv->selected = !NILP (selected); 1791 wv->selected = !NILP (selected);
1798 1792
@@ -1930,7 +1924,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
1930 GtkWidget *menu; 1924 GtkWidget *menu;
1931 1925
1932 if (! FRAME_X_P (f)) 1926 if (! FRAME_X_P (f))
1933 abort (); 1927 emacs_abort ();
1934 1928
1935 menu = xg_create_widget ("dialog", first_wv->name, f, first_wv, 1929 menu = xg_create_widget ("dialog", first_wv->name, f, first_wv,
1936 G_CALLBACK (dialog_selection_callback), 1930 G_CALLBACK (dialog_selection_callback),
@@ -1977,7 +1971,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
1977 LWLIB_ID dialog_id; 1971 LWLIB_ID dialog_id;
1978 1972
1979 if (!FRAME_X_P (f)) 1973 if (!FRAME_X_P (f))
1980 abort (); 1974 emacs_abort ();
1981 1975
1982 dialog_id = widget_id_tick++; 1976 dialog_id = widget_id_tick++;
1983#ifdef USE_LUCID 1977#ifdef USE_LUCID
@@ -2036,7 +2030,7 @@ xdialog_show (FRAME_PTR f,
2036 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 2030 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
2037 2031
2038 if (! FRAME_X_P (f)) 2032 if (! FRAME_X_P (f))
2039 abort (); 2033 emacs_abort ();
2040 2034
2041 *error_name = NULL; 2035 *error_name = NULL;
2042 2036
@@ -2301,7 +2295,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
2301 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 2295 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
2302 2296
2303 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f)) 2297 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
2304 abort (); 2298 emacs_abort ();
2305 2299
2306 *error_name = 0; 2300 *error_name = 0;
2307 if (menu_items_n_panes == 0) 2301 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/>. */
20 20
21#ifdef HAVE_LIBXML2 21#ifdef HAVE_LIBXML2
22 22
23#include <setjmp.h>
24#include <libxml/tree.h> 23#include <libxml/tree.h>
25#include <libxml/parser.h> 24#include <libxml/parser.h>
26#include <libxml/HTMLparser.h> 25#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/>. */
26#include <epaths.h> 26#include <epaths.h>
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32 31
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/>. */
22#include <config.h> 22#include <config.h>
23#include <limits.h> 23#include <limits.h>
24#include <stdio.h> /* termhooks.h needs this */ 24#include <stdio.h> /* termhooks.h needs this */
25#include <setjmp.h>
26 25
27#ifdef HAVE_SYS_TYPES_H 26#ifdef HAVE_SYS_TYPES_H
28#include <sys/types.h> 27#include <sys/types.h>
@@ -193,7 +192,7 @@ static void
193x_start_queuing_selection_requests (void) 192x_start_queuing_selection_requests (void)
194{ 193{
195 if (x_queue_selection_requests) 194 if (x_queue_selection_requests)
196 abort (); 195 emacs_abort ();
197 196
198 x_queue_selection_requests++; 197 x_queue_selection_requests++;
199 TRACE1 ("x_start_queuing_selection_requests %d", x_queue_selection_requests); 198 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)
245 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; 244 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP;
246 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; 245 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS;
247 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; 246 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL;
248 if (!SYMBOLP (sym)) abort (); 247 if (!SYMBOLP (sym)) emacs_abort ();
249 248
250 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); 249 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
251 BLOCK_INPUT; 250 BLOCK_INPUT;
@@ -1138,7 +1137,7 @@ wait_for_property_change (struct prop_location *location)
1138 ptrdiff_t count = SPECPDL_INDEX (); 1137 ptrdiff_t count = SPECPDL_INDEX ();
1139 1138
1140 if (property_change_reply_object) 1139 if (property_change_reply_object)
1141 abort (); 1140 emacs_abort ();
1142 1141
1143 /* Make sure to do unexpect_property_change if we quit or err. */ 1142 /* Make sure to do unexpect_property_change if we quit or err. */
1144 record_unwind_protect (wait_for_property_change_unwind, 1143 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/>. */
21 21
22#include <float.h> 22#include <float.h>
23#include <limits.h> 23#include <limits.h>
24#include <setjmp.h>
25#include <fcntl.h> 24#include <fcntl.h>
26#include "lisp.h" 25#include "lisp.h"
27#include "xterm.h" 26#include "xterm.h"
@@ -711,12 +710,12 @@ apply_xft_settings (struct x_display_info *dpyinfo,
711 if (send_event_p) 710 if (send_event_p)
712 store_config_changed_event (Qfont_render, 711 store_config_changed_event (Qfont_render,
713 XCAR (dpyinfo->name_list_element)); 712 XCAR (dpyinfo->name_list_element));
714 Vxft_settings 713 Vxft_settings
715 = make_formatted_string (buf, format, 714 = make_formatted_string (buf, format,
716 oldsettings.aa, oldsettings.hinting, 715 oldsettings.aa, oldsettings.hinting,
717 oldsettings.rgba, oldsettings.lcdfilter, 716 oldsettings.rgba, oldsettings.lcdfilter,
718 oldsettings.hintstyle, oldsettings.dpi); 717 oldsettings.hintstyle, oldsettings.dpi);
719 718
720 } 719 }
721 else 720 else
722 FcPatternDestroy (pat); 721 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/>. */
29#include <unistd.h> 29#include <unistd.h>
30#include <sys/param.h> 30#include <sys/param.h>
31#include <stdio.h> 31#include <stdio.h>
32#include <setjmp.h>
33 32
34#include "lisp.h" 33#include "lisp.h"
35#include "systime.h" 34#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/>. */
21/* Xt features made by Fred Pierresteguy. */ 21/* Xt features made by Fred Pierresteguy. */
22 22
23#include <config.h> 23#include <config.h>
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h>
27 25
28#ifdef HAVE_X_WINDOWS 26#ifdef HAVE_X_WINDOWS
29 27
30#include "lisp.h" 28#include "lisp.h"
31#include "blockinput.h" 29#include "blockinput.h"
32
33/* Need syssignal.h for various externs and definitions that may be required
34 by some configurations for calls to signal later in this source file. */
35#include "syssignal.h" 30#include "syssignal.h"
36 31
37/* This may include sys/types.h, and that somehow loses 32/* 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/>. */
51 46
52#include <fcntl.h> 47#include <fcntl.h>
53#include <errno.h> 48#include <errno.h>
54#include <setjmp.h>
55#include <sys/stat.h> 49#include <sys/stat.h>
56/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */ 50/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */
57/* #include <sys/param.h> */ 51/* #include <sys/param.h> */
@@ -165,13 +159,6 @@ struct x_display_info *x_display_list;
165 159
166Lisp_Object x_display_name_list; 160Lisp_Object x_display_name_list;
167 161
168/* Frame being updated by update_frame. This is declared in term.c.
169 This is set by update_begin and looked at by all the XT functions.
170 It is zero while not inside an update. In that case, the XT
171 functions assume that `selected_frame' is the frame to apply to. */
172
173extern struct frame *updating_frame;
174
175/* This is a frame waiting to be auto-raised, within XTread_socket. */ 162/* This is a frame waiting to be auto-raised, within XTread_socket. */
176 163
177static struct frame *pending_autoraise_frame; 164static struct frame *pending_autoraise_frame;
@@ -1474,7 +1461,7 @@ x_frame_of_widget (Widget widget)
1474 && f->output_data.x->widget == widget) 1461 && f->output_data.x->widget == widget)
1475 return f; 1462 return f;
1476 1463
1477 abort (); 1464 emacs_abort ();
1478} 1465}
1479 1466
1480/* Allocate a color which is lighter or darker than *PIXEL by FACTOR 1467/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
@@ -2703,7 +2690,7 @@ x_draw_underwave (struct glyph_string *s)
2703 y2 += dy; 2690 y2 += dy;
2704 2691
2705 if (INT_MAX - dx < xmax) 2692 if (INT_MAX - dx < xmax)
2706 abort (); 2693 emacs_abort ();
2707 2694
2708 while (x1 <= xmax) 2695 while (x1 <= xmax)
2709 { 2696 {
@@ -2812,7 +2799,7 @@ x_draw_glyph_string (struct glyph_string *s)
2812 break; 2799 break;
2813 2800
2814 default: 2801 default:
2815 abort (); 2802 emacs_abort ();
2816 } 2803 }
2817 2804
2818 if (!s->for_overlaps) 2805 if (!s->for_overlaps)
@@ -2986,6 +2973,7 @@ x_draw_glyph_string (struct glyph_string *s)
2986 XSetClipMask (next->display, next->gc, None); 2973 XSetClipMask (next->display, next->gc, None);
2987 next->hl = save; 2974 next->hl = save;
2988 next->num_clips = 0; 2975 next->num_clips = 0;
2976 next->clip_head = s->next;
2989 } 2977 }
2990 } 2978 }
2991 } 2979 }
@@ -3012,7 +3000,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height,
3012static void 3000static void
3013x_delete_glyphs (struct frame *f, register int n) 3001x_delete_glyphs (struct frame *f, register int n)
3014{ 3002{
3015 abort (); 3003 emacs_abort ();
3016} 3004}
3017 3005
3018 3006
@@ -3285,7 +3273,7 @@ XTset_terminal_window (struct frame *f, int n)
3285static void 3273static void
3286x_ins_del_lines (struct frame *f, int vpos, int n) 3274x_ins_del_lines (struct frame *f, int vpos, int n)
3287{ 3275{
3288 abort (); 3276 emacs_abort ();
3289} 3277}
3290 3278
3291 3279
@@ -4122,7 +4110,7 @@ x_window_to_scroll_bar (Display *display, Window window_id)
4122 frame = XCAR (tail); 4110 frame = XCAR (tail);
4123 /* All elements of Vframe_list should be frames. */ 4111 /* All elements of Vframe_list should be frames. */
4124 if (! FRAMEP (frame)) 4112 if (! FRAMEP (frame))
4125 abort (); 4113 emacs_abort ();
4126 4114
4127 if (! FRAME_X_P (XFRAME (frame))) 4115 if (! FRAME_X_P (XFRAME (frame)))
4128 continue; 4116 continue;
@@ -5441,7 +5429,7 @@ XTredeem_scroll_bar (struct window *window)
5441 5429
5442 /* We can't redeem this window's scroll bar if it doesn't have one. */ 5430 /* We can't redeem this window's scroll bar if it doesn't have one. */
5443 if (NILP (window->vertical_scroll_bar)) 5431 if (NILP (window->vertical_scroll_bar))
5444 abort (); 5432 emacs_abort ();
5445 5433
5446 bar = XSCROLL_BAR (window->vertical_scroll_bar); 5434 bar = XSCROLL_BAR (window->vertical_scroll_bar);
5447 5435
@@ -5460,7 +5448,7 @@ XTredeem_scroll_bar (struct window *window)
5460 else 5448 else
5461 /* If its prev pointer is nil, it must be at the front of 5449 /* If its prev pointer is nil, it must be at the front of
5462 one or the other! */ 5450 one or the other! */
5463 abort (); 5451 emacs_abort ();
5464 } 5452 }
5465 else 5453 else
5466 XSCROLL_BAR (bar->prev)->next = bar->next; 5454 XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -5558,7 +5546,7 @@ static void
5558x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) 5546x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event)
5559{ 5547{
5560 if (! WINDOWP (bar->window)) 5548 if (! WINDOWP (bar->window))
5561 abort (); 5549 emacs_abort ();
5562 5550
5563 emacs_event->kind = SCROLL_BAR_CLICK_EVENT; 5551 emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
5564 emacs_event->code = event->xbutton.button - Button1; 5552 emacs_event->code = event->xbutton.button - Button1;
@@ -6464,7 +6452,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6464 } 6452 }
6465 else if (status_return != XLookupKeySym 6453 else if (status_return != XLookupKeySym
6466 && status_return != XLookupBoth) 6454 && status_return != XLookupBoth)
6467 abort (); 6455 emacs_abort ();
6468 } 6456 }
6469 else 6457 else
6470 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr, 6458 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr,
@@ -7141,25 +7129,17 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7141 if (interrupt_input_blocked) 7129 if (interrupt_input_blocked)
7142 { 7130 {
7143 interrupt_input_pending = 1; 7131 interrupt_input_pending = 1;
7144#ifdef SYNC_INPUT
7145 pending_signals = 1; 7132 pending_signals = 1;
7146#endif
7147 return -1; 7133 return -1;
7148 } 7134 }
7149 7135
7150 interrupt_input_pending = 0; 7136 interrupt_input_pending = 0;
7151#ifdef SYNC_INPUT
7152 pending_signals = pending_atimers; 7137 pending_signals = pending_atimers;
7153#endif
7154 BLOCK_INPUT; 7138 BLOCK_INPUT;
7155 7139
7156 /* So people can tell when we have read the available input. */ 7140 /* So people can tell when we have read the available input. */
7157 input_signal_count++; 7141 input_signal_count++;
7158 7142
7159#ifndef SYNC_INPUT
7160 ++handling_signal;
7161#endif
7162
7163 /* For debugging, this gives a way to fake an I/O error. */ 7143 /* For debugging, this gives a way to fake an I/O error. */
7164 if (terminal->display_info.x == XTread_socket_fake_io_error) 7144 if (terminal->display_info.x == XTread_socket_fake_io_error)
7165 { 7145 {
@@ -7248,9 +7228,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7248 pending_autoraise_frame = 0; 7228 pending_autoraise_frame = 0;
7249 } 7229 }
7250 7230
7251#ifndef SYNC_INPUT
7252 --handling_signal;
7253#endif
7254 UNBLOCK_INPUT; 7231 UNBLOCK_INPUT;
7255 7232
7256 return count; 7233 return count;
@@ -7503,7 +7480,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int
7503 break; 7480 break;
7504 7481
7505 default: 7482 default:
7506 abort (); 7483 emacs_abort ();
7507 } 7484 }
7508 } 7485 }
7509 7486
@@ -7773,7 +7750,9 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */
7773#ifdef USG 7750#ifdef USG
7774 /* USG systems forget handlers when they are used; 7751 /* USG systems forget handlers when they are used;
7775 must reestablish each time */ 7752 must reestablish each time */
7776 signal (signalnum, x_connection_signal); 7753 struct sigaction action;
7754 emacs_sigaction_init (&action, x_connection_signal);
7755 sigaction (signalnum, &action, 0);
7777#endif /* USG */ 7756#endif /* USG */
7778} 7757}
7779 7758
@@ -7798,7 +7777,6 @@ x_connection_closed (Display *dpy, const char *error_message)
7798 7777
7799 error_msg = alloca (strlen (error_message) + 1); 7778 error_msg = alloca (strlen (error_message) + 1);
7800 strcpy (error_msg, error_message); 7779 strcpy (error_msg, error_message);
7801 handling_signal = 0;
7802 7780
7803 /* Inhibit redisplay while frames are being deleted. */ 7781 /* Inhibit redisplay while frames are being deleted. */
7804 specbind (Qinhibit_redisplay, Qt); 7782 specbind (Qinhibit_redisplay, Qt);
@@ -7850,13 +7828,13 @@ x_connection_closed (Display *dpy, const char *error_message)
7850 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once, 7828 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once,
7851 the resulting Glib error message loop filled a user's disk. 7829 the resulting Glib error message loop filled a user's disk.
7852 To avoid this, kill Emacs unconditionally on disconnect. */ 7830 To avoid this, kill Emacs unconditionally on disconnect. */
7853 shut_down_emacs (0, 0, Qnil); 7831 shut_down_emacs (0, Qnil);
7854 fprintf (stderr, "%s\n\ 7832 fprintf (stderr, "%s\n\
7855When compiled with GTK, Emacs cannot recover from X disconnects.\n\ 7833When compiled with GTK, Emacs cannot recover from X disconnects.\n\
7856This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 7834This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
7857For details, see etc/PROBLEMS.\n", 7835For details, see etc/PROBLEMS.\n",
7858 error_msg); 7836 error_msg);
7859 abort (); 7837 emacs_abort ();
7860#endif /* USE_GTK */ 7838#endif /* USE_GTK */
7861 7839
7862 /* Indicate that this display is dead. */ 7840 /* Indicate that this display is dead. */
@@ -7866,7 +7844,7 @@ For details, see etc/PROBLEMS.\n",
7866 dpyinfo->terminal->reference_count--; 7844 dpyinfo->terminal->reference_count--;
7867 if (dpyinfo->reference_count != 0) 7845 if (dpyinfo->reference_count != 0)
7868 /* We have just closed all frames on this display. */ 7846 /* We have just closed all frames on this display. */
7869 abort (); 7847 emacs_abort ();
7870 7848
7871 { 7849 {
7872 Lisp_Object tmp; 7850 Lisp_Object tmp;
@@ -7883,10 +7861,15 @@ For details, see etc/PROBLEMS.\n",
7883 } 7861 }
7884 7862
7885 /* Ordinary stack unwind doesn't deal with these. */ 7863 /* Ordinary stack unwind doesn't deal with these. */
7886#ifdef SIGIO 7864 {
7887 sigunblock (sigmask (SIGIO)); 7865 sigset_t unblocked;
7866 sigemptyset (&unblocked);
7867#ifdef USABLE_SIGIO
7868 sigaddset (&unblocked, SIGIO);
7888#endif 7869#endif
7889 sigunblock (sigmask (SIGALRM)); 7870 sigaddset (&unblocked, SIGALRM);
7871 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
7872 }
7890 TOTALLY_UNBLOCK_INPUT; 7873 TOTALLY_UNBLOCK_INPUT;
7891 7874
7892 unbind_to (idx, Qnil); 7875 unbind_to (idx, Qnil);
@@ -10424,10 +10407,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10424 fcntl (connection, F_SETOWN, getpid ()); 10407 fcntl (connection, F_SETOWN, getpid ());
10425#endif /* ! defined (F_SETOWN) */ 10408#endif /* ! defined (F_SETOWN) */
10426 10409
10427#ifdef SIGIO
10428 if (interrupt_input) 10410 if (interrupt_input)
10429 init_sigio (connection); 10411 init_sigio (connection);
10430#endif /* ! defined (SIGIO) */
10431 10412
10432#ifdef USE_LUCID 10413#ifdef USE_LUCID
10433 { 10414 {
@@ -10443,7 +10424,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10443 to.addr = (XPointer)&font; 10424 to.addr = (XPointer)&font;
10444 x_catch_errors (dpy); 10425 x_catch_errors (dpy);
10445 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) 10426 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
10446 abort (); 10427 emacs_abort ();
10447 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) 10428 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
10448 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); 10429 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
10449 x_uncatch_errors (); 10430 x_uncatch_errors ();
@@ -10609,8 +10590,6 @@ x_activate_timeout_atimer (void)
10609 10590
10610/* Set up use of X before we make the first connection. */ 10591/* Set up use of X before we make the first connection. */
10611 10592
10612extern frame_parm_handler x_frame_parm_handlers[];
10613
10614static struct redisplay_interface x_redisplay_interface = 10593static struct redisplay_interface x_redisplay_interface =
10615 { 10594 {
10616 x_frame_parm_handlers, 10595 x_frame_parm_handlers,
@@ -10768,6 +10747,8 @@ x_create_terminal (struct x_display_info *dpyinfo)
10768void 10747void
10769x_initialize (void) 10748x_initialize (void)
10770{ 10749{
10750 struct sigaction action;
10751
10771 baud_rate = 19200; 10752 baud_rate = 19200;
10772 10753
10773 x_noop_count = 0; 10754 x_noop_count = 0;
@@ -10814,7 +10795,8 @@ x_initialize (void)
10814 XSetErrorHandler (x_error_handler); 10795 XSetErrorHandler (x_error_handler);
10815 XSetIOErrorHandler (x_io_error_quitter); 10796 XSetIOErrorHandler (x_io_error_quitter);
10816 10797
10817 signal (SIGPIPE, x_connection_signal); 10798 emacs_sigaction_init (&action, x_connection_signal);
10799 sigaction (SIGPIPE, &action, 0);
10818} 10800}
10819 10801
10820 10802