aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2012-09-10 16:03:53 +0200
committerJoakim Verona2012-09-10 16:03:53 +0200
commitb035a30e5cd2f34fedc04c253eeb5a11afed8145 (patch)
treeb9350cce389602f4967bdc1beed745929155ad5d /src
parent4a37733c693d59a9b83a3fb2d0c7f9461d149f60 (diff)
parenta31a4cdacb196cc96dcb9bd229edb1d635e01344 (diff)
downloademacs-b035a30e5cd2f34fedc04c253eeb5a11afed8145.tar.gz
emacs-b035a30e5cd2f34fedc04c253eeb5a11afed8145.zip
upstream
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit11
-rw-r--r--src/ChangeLog439
-rw-r--r--src/alloc.c124
-rw-r--r--src/atimer.c69
-rw-r--r--src/bidi.c79
-rw-r--r--src/blockinput.h3
-rw-r--r--src/buffer.c44
-rw-r--r--src/buffer.h6
-rw-r--r--src/bytecode.c16
-rw-r--r--src/callproc.c4
-rw-r--r--src/character.c2
-rw-r--r--src/charset.c6
-rw-r--r--src/cm.c2
-rw-r--r--src/coding.c20
-rw-r--r--src/conf_post.h10
-rw-r--r--src/data.c97
-rw-r--r--src/dired.c2
-rw-r--r--src/dispnew.c50
-rw-r--r--src/doc.c3
-rw-r--r--src/doprnt.c4
-rw-r--r--src/editfns.c10
-rw-r--r--src/emacs.c153
-rw-r--r--src/emacsgtkfixed.c1
-rw-r--r--src/eval.c16
-rw-r--r--src/fileio.c201
-rw-r--r--src/filelock.c24
-rw-r--r--src/floatfns.c471
-rw-r--r--src/fns.c115
-rw-r--r--src/font.c41
-rw-r--r--src/font.h45
-rw-r--r--src/fontset.c28
-rw-r--r--src/frame.c22
-rw-r--r--src/frame.h5
-rw-r--r--src/fringe.c9
-rw-r--r--src/ftfont.c30
-rw-r--r--src/ftxfont.c22
-rw-r--r--src/gtkutil.c23
-rw-r--r--src/image.c17
-rw-r--r--src/indent.c4
-rw-r--r--src/insdel.c22
-rw-r--r--src/intervals.c18
-rw-r--r--src/keyboard.c160
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h194
-rw-r--r--src/lisp.mk1
-rw-r--r--src/lread.c18
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/marker.c18
-rw-r--r--src/menu.c4
-rw-r--r--src/minibuf.c2
-rw-r--r--src/msdos.c29
-rw-r--r--src/nsfns.m1
-rw-r--r--src/nsfont.m15
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsterm.h1
-rw-r--r--src/nsterm.m397
-rw-r--r--src/print.c8
-rw-r--r--src/process.c299
-rw-r--r--src/ralloc.c20
-rw-r--r--src/regex.c6
-rw-r--r--src/region-cache.c24
-rw-r--r--src/scroll.c4
-rw-r--r--src/search.c6
-rw-r--r--src/sound.c28
-rw-r--r--src/syntax.c10
-rw-r--r--src/sysdep.c165
-rw-r--r--src/syssignal.h88
-rw-r--r--src/systty.h5
-rw-r--r--src/term.c41
-rw-r--r--src/termchar.h2
-rw-r--r--src/terminal.c8
-rw-r--r--src/terminfo.c2
-rw-r--r--src/textprop.c3
-rw-r--r--src/tparam.c2
-rw-r--r--src/w32.c57
-rw-r--r--src/w32fns.c26
-rw-r--r--src/w32font.c11
-rw-r--r--src/w32font.h2
-rw-r--r--src/w32menu.c2
-rw-r--r--src/w32proc.c37
-rw-r--r--src/w32select.c2
-rw-r--r--src/w32term.c16
-rw-r--r--src/w32uniscribe.c6
-rw-r--r--src/w32xfns.c2
-rw-r--r--src/widget.c11
-rw-r--r--src/window.c16
-rw-r--r--src/window.h4
-rw-r--r--src/xdisp.c73
-rw-r--r--src/xfaces.c26
-rw-r--r--src/xfont.c13
-rw-r--r--src/xftfont.c32
-rw-r--r--src/xmenu.c31
-rw-r--r--src/xselect.c6
-rw-r--r--src/xterm.c50
94 files changed, 2136 insertions, 2121 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 43e629eb5f6..548c80b3b85 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,11 +1,440 @@
12012-09-10 Chong Yidong <cyd@gnu.org>
2
3 * fns.c (Fdelq, Fdelete): Doc fix.
4
52012-09-10 Paul Eggert <eggert@cs.ucla.edu>
6
7 * lisp.h (XSETINT, XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL)
8 (XSETFLOAT, XSETMISC): Parenthesize macro bodies.
9
102012-09-09 Stefan Monnier <monnier@iro.umontreal.ca>
11
12 * lisp.h (make_lisp_ptr): New macro to replace XSET.
13 (XSETCONS, XSETVECTOR, XSETSTRING, XSETSYMBOL, XSETFLOAT, XSETMISC):
14 Use it.
15
162012-09-09 Eli Zaretskii <eliz@gnu.org>
17
18 * fringe.c (draw_fringe_bitmap_1): Don't reduce the width of the
19 left fringe if the window has a left margin. This avoids leaving
20 traces of the cursor because its leftmost pixel is not drawn over.
21
22 * dispnew.c (update_window_line): When the left margin area of a
23 screen line is updated, set the redraw_fringe_bitmaps_p flag of
24 that screen line. (Bug#12277)
25
262012-09-09 Paul Eggert <eggert@cs.ucla.edu>
27
28 Assume C89 or later for math functions (Bug#12381).
29 This simplifies the code, and makes it a bit smaller and faster,
30 and (most important) makes it easier to clean up signal handling
31 since we can stop worring about floating-point exceptions in
32 library code. That was a problem before C89, but the problem
33 went away many years ago on all practical Emacs targets.
34 * data.c, image.c, lread.c, print.c:
35 Don't include <math.h>; no longer needed.
36 * data.c, floatfns.c (IEEE_FLOATING_POINT): Don't worry that it
37 might be autoconfigured, as that never happens.
38 * data.c (fmod):
39 * doprnt.c (DBL_MAX_10_EXP):
40 * print.c (DBL_DIG):
41 Remove. C89 or later always defines these.
42 * floatfns.c (HAVE_MATHERR, FLOAT_CHECK_ERRNO, FLOAT_CHECK_DOMAIN)
43 (in_float, float_error_arg, float_error_arg2, float_error_fn_name)
44 (arith_error, domain_error, domain_error2):
45 Remove all this pre-C89 cruft. Do not include <errno.h> as that's
46 no longer needed -- we simply return what C returns. All uses removed.
47 (IN_FLOAT, IN_FLOAT2): Remove. All uses replaced with
48 the wrapped code.
49 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error, range_error2):
50 Remove. All uses expanded, as these macros are no longer used
51 more than once and are now more trouble than they're worth.
52 (Ftan): Use tan, not sin / cos.
53 (Flogb): Assume C89 frexp.
54 (fmod_float): Assume C89 fmod.
55 (matherr) [HAVE_MATHERR]: Remove; no longer needed.
56 (init_floatfns): Remove. All uses removed.
57
582012-09-08 Jan Djärv <jan.h.d@swipnet.se>
59
60 * nsterm.m (ns_draw_fringe_bitmap, ns_dumpglyphs_image): Take back
61 compositeToPoint for OSX < 10.6 (Bug#12390).
62
632012-09-08 Paul Eggert <eggert@cs.ucla.edu>
64
65 * floatfns.c (Ftan): Use tan (x), not (sin (x) / cos (x)).
66 This produces more-accurate results.
67
682012-09-08 Jan Djärv <jan.h.d@swipnet.se>
69
70 * nsterm.m (updateFrameSize): Call setFrame: on the view when size
71 changes (Bug#12088).
72
732012-09-08 Chong Yidong <cyd@gnu.org>
74
75 * syntax.c (Fstring_to_syntax): Doc fix.
76
772012-09-08 Jan Djärv <jan.h.d@swipnet.se>
78
79 * nsterm.m (ns_clip_to_row): Remove code that deals with drawing fringe
80 in the internal border.
81 (x_set_window_size): Remove static variables and their usage.
82 (ns_redraw_scroll_bars): Fix NSTRACE arg.
83 (ns_after_update_window_line, ns_draw_fringe_bitmap): Remove
84 fringe/internal border adjustment (Bug#11052).
85 (ns_draw_fringe_bitmap): Make code more like other terms (xterm.c).
86 (ns_draw_window_cursor): Remove fringe/internal border adjustment.
87 (ns_fix_rect_ibw): Remove.
88 (ns_get_glyph_string_clip_rect): Remove call to ns_fix_rect_ibw.
89 (ns_dumpglyphs_box_or_relief): Ditto.
90 (ns_maybe_dumpglyphs_background): Remove fringe/internal border
91 adjustment.
92 (ns_dumpglyphs_image): Ditto.
93 (ns_dumpglyphs_stretch): Fix coding style. Remove fringe/internal
94 border adjustment.
95 (ns_set_vertical_scroll_bar): Remove variables barOnVeryLeft/Right and
96 their usage. Add fringe_extended_p and its use as in other terms.
97 (ns_judge_scroll_bars): Code style fix. Call updateFrameSize if
98 scroll bar was removed.
99 (updateFrameSize): New function.
100 (windowDidResize): Move code to updateFrameSize and call it.
101
102 * nsterm.h (EmacsView): Add updateFrameSize.
103
1042012-09-07 Chong Yidong <cyd@gnu.org>
105
106 * textprop.c (Fget_text_property): Minor doc fix (Bug#12323).
107
108 * data.c (Flocal_variable_if_set_p): Doc fix (Bug#10713).
109
1102012-09-07 Paul Eggert <eggert@cs.ucla.edu>
111
112 More signal-handler cleanup (Bug#12327).
113 * emacs.c (main): Convert three 'signal' calls to 'sigaction' calls.
114 Problem introduced when merging patches. Noted by Eli Zaretskii in
115 <http://bugs.gnu.org/12327#67>.
116 * floatfns.c: Comment fix.
117 * lisp.h (force_auto_save_soon): Declare regardless of SIGDANGER.
118 SIGDANGER might not be in scope so "#ifdef SIGDANGER" is not right,
119 and anyway the declaration is harmless even if SIGDANGER is not defined.
120 * syssignal.h (SIGIO): Also #undef if (! defined FIONREAD ||
121 defined BROKEN_FIONREAD). systty.h formerly did this, but other
122 source files not surprisingly expected syssignal.h to define, or
123 not define, SIGIO, and it's cleaner to do it that way, for consistency.
124 Include <sys/ioctl.h>, for FIONREAD.
125 * systty.h (SIGIO): Do not #undef here; it's now syssignal.h's job.
126 This eliminates a problem whereby other files mysteriously had
127 to include "syssignal.h" before including "systty.h" if they
128 wanted to use "#ifdef SIGIO".
129
1302012-09-07 Eli Zaretskii <eliz@gnu.org>
131
132 * w32proc.c (sigaction): New function, emulates Posix 'sigaction'.
133
134 * w32.c (sigemptyset): Empty the set.
135 (sigsetmask, sigmask, sigblock, sigunblock): Remove unused functions.
136
137 * alloc.c [ENABLE_CHECKING]: Include signal.h, since we need SIGABRT.
138
1392012-09-07 Dmitry Antipov <dmantipov@yandex.ru>
140
141 * alloc.c (mark_buffer): Revert unsafe marking optimization.
142 (mark_object): Likewise for frame objects.
143
1442012-09-07 Paul Eggert <eggert@cs.ucla.edu>
145
146 * syssignal.h (handle_on_main_thread): Always declare,
147 even if FORWARD_SIGNAL_TO_MAIN_THREAD is not defined.
148 This ports to platforms without HAVE_PTHREAD.
149
1502012-09-06 Paul Eggert <eggert@cs.ucla.edu>
151
152 Signal-handler cleanup (Bug#12327).
153 Emacs's signal handlers were written in the old 4.2BSD style with
154 sigblock and sigmask and so forth, and this led to some
155 inefficiencies and confusion. Rewrite these to use
156 pthread_sigmask etc. without copying signal sets around. Also,
157 get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and
158 'signal', and instead use functions that do not attempt to take
159 over the system name space. This patch causes Emacs's text
160 segment to shrink by 0.7% on my platform, Fedora 17 x86-64.
161 * alloc.c, emacsgtkfixed.c, nsfns.m, widget.c, xmenu.c:
162 Do not include <signal.h> or "syssignal.h", as these
163 modules do not use signals.
164 * atimer.c, callproc.c, data.c, dispnew.c, emacs.c, floatfns.c:
165 * gtkutil.c, keyboard.c, process.c, sound.c, sysdep.c, term.c, xterm.c:
166 Do not include <signal.h>, as "syssignal.h" does that for us now.
167 * atimer.c (sigmask_atimers): New function.
168 (block_atimers, unblock_atimers): New functions,
169 replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS.
170 All uses replaced.
171 * conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>;
172 no longer needed here.
173 * emacs.c (main): Inspect existing signal handler with sigaction,
174 so that there's no need to block and unblock SIGHUP.
175 * sysdep.c (struct save_signal): New member 'action', replacing
176 old member 'handler'.
177 (save_signal_handlers, restore_signal_handlers):
178 Use sigaction instead of 'signal' to save and restore.
179 (get_set_sighandler, set_sighandler) [!WINDOWSNT]:
180 New function. All users of 'signal' modified to use set_sighandler
181 if they're writeonly, and to use sys_signal if they're read+write.
182 (emacs_sigaction_init, forwarded_signal): New functions.
183 (sys_signal): Remove. All uses replaced by calls to sigaction
184 and emacs_sigaction_init, or by direct calls to 'signal'.
185 (sys_sigmask) [!__GNUC__]: Remove; no longer needed.
186 (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove;
187 all uses replaced by pthread_sigmask etc. calls.
188 * syssignal.h: Include <signal.h>.
189 (emacs_sigaction_init, forwarded_signal): New decls.
190 (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t.
191 (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask.
192 (sigmask, sys_sigmask): Remove; no longer needed.
193 (sigpause): Remove. All uses replaced by its definiens, sigsuspend.
194 (sigblock, sigunblock, sigfree):
195 (sigsetmask) [!defined sigsetmask]:
196 Remove. All uses replaced by pthread_sigmask.
197 (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN)
198 no longer need to be replaced, and its typical old uses
199 are now done via emacs_sigaction_init and sigaction.
200 (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls.
201 (sys_sigdel): Remove; unused.
202 (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef.
203
2042012-09-06 Eli Zaretskii <eliz@gnu.org>
205
206 * process.c (CAN_HANDLE_MULTIPLE_CHILDREN): Fix a typo that broke
207 SIGCHLD handling on systems that don't have WNOHANG. (Bug#12327)
208
2092012-09-06 Dmitry Antipov <dmantipov@yandex.ru>
210
211 Explicitly mark buffer_defaults and buffer_local_symbols.
212 * alloc.c (Fgarbage_collect): Mark buffer_defaults and
213 mark_local_symbols here.
214 (mark_object): If GC_CHECK_MARKED_OBJECTS, simplify checking
215 since special buffers aren't marked here any more.
216 (allocate_buffer): Chain new buffer with all_buffers here...
217 * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): ...and
218 not here.
219 (Vbuffer_defaults, Vbuffer_local_symbols): Remove.
220 (syms_of_buffer): Remove staticpro of the above.
221 (init_buffer_once): Set names for buffer_defaults and
222 buffer_local_symbols.
223
2242012-09-06 Paul Eggert <eggert@cs.ucla.edu>
225
226 Use bool for booleans in font-related modules.
227 * font.c (font_intern_prop, font_style_to_value)
228 (font_style_symbolic, font_parse_xlfd, font_parse_fcname)
229 (generate_otf_features, font_check_otf_features, font_check_otf)
230 (font_match_p, font_list_entities, font_at):
231 * fontset.c (fontset_id_valid_p, reorder_font_vector
232 (fontset_find_font, Fset_fontset_font)
233 (face_suitable_for_char_p) [0]:
234 * ftfont.c (fc_initialized, ftfont_get_open_type_spec)
235 (ftfont_open, ftfont_text_extents, ftfont_check_otf):
236 (m17n_flt_initialized, ftfont_shape_by_flt):
237 * ftxfont.c (ftxfont_draw_bitmap, ftxfont_draw):
238 * nsfont.m (nsfont_draw):
239 * w32font.c (w32font_draw):
240 * w32term.c (x_draw_glyphless_glyph_string_foreground):
241 Use bool for booleans.
242 * font.h: Adjust to above API changes.
243 (struct font, struct font_driver, struct font_driver_list):
244 Use bool for booleans.
245 (struct font): Remove useless member encoding_type.
246 All users removed.
247 * fontset.c, xftfont.c: Omit unnecessary static decls.
248
2492012-09-06 Dmitry Antipov <dmantipov@yandex.ru>
250
251 * alloc.c (mark_object): Revert window marking code
252 since it's unsafe for the Fset_window_configuration.
253
2542012-09-05 Paul Eggert <eggert@cs.ucla.edu>
255
256 Fix race conditions with signal handlers and errno (Bug#12327).
257 Be more systematic about preserving errno whenever a signal
258 handler returns, even if it's not in the main thread. Do this by
259 renaming signal handlers to distinguish between signal delivery
260 and signal handling. All uses changed.
261 * atimer.c (deliver_alarm_signal): Rename from alarm_signal_handler.
262 * data.c (deliver_arith_signal): Rename from arith_error.
263 * dispnew.c (deliver_window_change_signal): Rename from
264 window_change_signal.
265 * emacs.c (deliver_error_signal): Rename from fatal_error_signal.
266 (deliver_danger_signal) [SIGDANGER]: Rename from memory_warning_signal.
267 * keyboard.c (deliver_input_available_signal): Rename from
268 input_available_signal.
269 (deliver_user_signal): Rename from handle_user_signal.
270 (deliver_interrupt_signal): Rename from interrupt_signal.
271 * process.c (deliver_pipe_signal): Rename from send_process_trap.
272 (deliver_child_signal): Rename from sigchld_handler.
273 * atimer.c (handle_alarm_signal):
274 * data.c (handle_arith_signal):
275 * dispnew.c (handle_window_change_signal):
276 * emacs.c (handle_fatal_signal, handle_danger_signal):
277 * keyboard.c (handle_input_available_signal):
278 * keyboard.c (handle_user_signal, handle_interrupt_signal):
279 * process.c (handle_pipe_signal, handle_child_signal):
280 New functions, with the actual signal-handling code taken from the
281 original respective signal handlers, sans the sporadic attempts to
282 preserve errno, since that's now done by handle_on_main_thread.
283 * atimer.c (alarm_signal_handler): Remove unnecessary decl.
284 * emacs.c, floatfns.c, lisp.h: Remove unused FLOAT_CATCH_SIGKILL cruft.
285 * emacs.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
286 Move to sysdep.c.
287 (main) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
288 Move initialization of main_thread to sysdep.c's init_signals.
289 * process.c (waitpid) [!WNOHANG]: #define to wait; that's good enough for
290 our usage, and simplifies the mainline code.
291 (record_child_status_change): New static function, as a helper
292 for handle_child_signal, and with most of the old child handler's
293 contents.
294 (CAN_HANDLE_MULTIPLE_CHILDREN): New constant.
295 (handle_child_signal): Use the above.
296 * sysdep.c (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
297 Moved here from emacs.c.
298 (init_signals) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Initialize it;
299 code moved here from emacs.c's main function.
300 * sysdep.c, syssignal.h (handle_on_main_thread): New function,
301 replacing the old SIGNAL_THREAD_CHECK. All uses changed. This
302 lets callers save and restore errno properly.
303
3042012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
305
306 Remove redundant or unused things here and there.
307 * lisp.h (CYCLE_CHECK, CHAR_TABLE_TRANSLATE): Remove.
308 * conf_post.h (RE_TRANSLATE): Use char_table_translate.
309 * editfns.c (Fcompare_buffer_substrings): Likewise.
310 * frame.h (struct terminal, struct font_driver_list):
311 Remove redundant declarations.
312 * window.h (Qleft, Qright): Likewise.
313
3142012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
315
316 Do not mark objects from deleted buffers, windows and frames.
317 * alloc.c (mark_buffer): Mark just the buffer if it is dead.
318 (mark_object): Likewise for windows and frames.
319
3202012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
321
322 * alloc.c (valid_lisp_object_p): Treat killed buffers,
323 buffer_defaults and buffer_local_symbols as valid objects.
324 Return special value to denote them.
325
3262012-09-05 Paul Eggert <eggert@cs.ucla.edu>
327
328 * fileio.c, filelock.c, floatfns.c, fns.c: Use bool for boolean.
329 * fileio.c (auto_saving, auto_save_error_occurred, make_temp_name)
330 (Fexpand_file_name, barf_or_query_if_file_exists, Fcopy_file)
331 (file_name_absolute_p, Fsubstitute_in_file_name):
332 (check_executable, check_writable, Ffile_accessible_directory_p)
333 (Fset_file_selinux_context, Fdefault_file_modes)
334 (Finsert_file_contents, choose_write_coding_system)
335 (Fwrite_region, build_annotations, a_write, e_write)
336 (Fdo_auto_save):
337 * filelock.c (boot_time_initialized, get_boot_time)
338 (get_boot_time_1, lock_file_1, within_one_second):
339 * floatfns.c (in_float):
340 * fns.c (concat, internal_equal, Frequire, base64_encode_1)
341 (base64_decode_1, cmpfn_eql, cmpfn_user_defined)
342 (sweep_weak_table, sweep_weak_hash_tables, secure_hash):
343 * lisp.h (struct Lisp_Hash_Table.cmpfn):
344 * window.c (compare_window_configurations):
345 Use bool for booleans.
346 * fileio.c (auto_saving_dir_umask, auto_saving_mode_bits)
347 (Fdefault_file_modes): Now mode_t, not int, for modes.
348 (Fdo_auto_save): Set a boolean to 1 rather than using ++.
349 (internal_delete_file): Now returns void, not a (boolean) int,
350 since nobody was looking at the return value.
351 * lisp.h, window.h: Adjust to above API changes.
352
353 * xdisp.c (set_message): Simplify and reindent last change.
354
3552012-09-05 Juanma Barranquero <lekktu@gmail.com>
356
357 * makefile.w32-in ($(BLD)/sysdep.$(O)): Update dependencies.
358
3592012-09-04 Lars Ingebrigtsen <larsi@gnus.org>
360
361 * eval.c (call_debugger): Make the function non-static so that we
362 can call it from set_message.
363
364 * xdisp.c (set_message): Implement the new variable `debug-on-message'.
365 (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'.
366
3672012-09-04 Paul Eggert <eggert@cs.ucla.edu>
368
369 Give more-useful info on a fatal error (Bug#12328).
370 * alloc.c [ENABLE_CHECKING]: Do not include <execinfo.h>.
371 (die) [ENABLE_CHECKING]: Call fatal_error_backtrace instead
372 of doing the work ourselves.
373 * emacs.c (fatal_error_signal): Let fatal_error_backtrace
374 do most of the work.
375 (fatal_error_backtrace): New function, taken from the guts
376 of the old fatal_error_signal, but with a new option to output
377 a backtrace.
378 (shut_down_emacs) [!DOS_NT]: Use strsignal to give more-useful
379 info about the signal than just its number.
380 * lisp.h (fatal_error_backtrace, emacs_backtrace): New decls.
381 * sysdep.c: Include <execinfo.h>
382 (emacs_backtrace): New function, taken partly from the previous
383 code of the 'die' function.
384 (emacs_abort): Call fatal_error_backtrace rather than abort.
385
3862012-09-04 Stefan Monnier <monnier@iro.umontreal.ca>
387
388 * lread.c (readevalloop): Call internal-macroexpand-for-load to perform
389 eager (load-time) macro-expansion.
390 * lisp.mk (lisp): Add macroexp.
391
3922012-09-04 Paul Eggert <eggert@cs.ucla.edu>
393
394 Simplify redefinition of 'abort' (Bug#12316).
395 Do not try to redefine the 'abort' function. Instead, redo
396 the code so that it calls 'emacs_abort' rather than 'abort'.
397 This removes the need for the NO_ABORT configure-time macro
398 and makes it easier to change the abort code to do a backtrace.
399 * .gdbinit: Just stop at emacs_abort, not at w32_abort or abort.
400 * emacs.c (abort) [!DOS_NT && !NO_ABORT]:
401 Remove; sysdep.c's emacs_abort now takes its place.
402 * lisp.h (emacs_abort): New decl. All calls from Emacs code to
403 'abort' changed to use 'emacs_abort'.
404 * msdos.c (dos_abort) [defined abort]: Remove; not used.
405 (abort) [!defined abort]: Rename to ...
406 (emacs_abort): ... new name.
407 * sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking
408 the place of the old 'abort' in emacs.c.
409 * w32.c, w32fns.c (abort): Do not #undef.
410 * w32.c (emacs_abort): Rename from w32_abort.
411
4122012-09-04 Eli Zaretskii <eliz@gnu.org>
413
414 * w32uniscribe.c (uniscribe_shape): Reverse the sign of
415 offsets[j].dv, since the y axis of the screen coordinates points
416 down, while the y axis of the font definition coordinates points
417 up. This fixes display of Arabic diacritics such as KASRA and
418 KASRATAN. (Bug#11860)
419
4202012-09-04 Paul Eggert <eggert@cs.ucla.edu>
421
422 Be more systematic about _setjmp vs setjmp.
423 * alloc.c (test_setjmp, mark_stack):
424 * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]:
425 (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]:
426 (png_load, my_error_exit, jpeg_load):
427 * process.c (send_process_trap, send_process):
428 Uniformly prefer _setjmp and _longjmp to setjmp and longjmp.
429 The underscored versions are up to 30x faster on some hosts.
430 Formerly, the code used setjmp+longjmp sometimes and
431 _setjmp+_longjmp at other times, with no particular reason to
432 prefer setjmp+longjmp.
433
12012-09-03 Paul Eggert <eggert@cs.ucla.edu> 4342012-09-03 Paul Eggert <eggert@cs.ucla.edu>
2 435
3 Fix minor problems found by static checking. 436 Fix minor problem found by static checking.
4 * buffer.c (Fdelete_all_overlays): Return nil. 437 * buffer.c (Fdelete_all_overlays): Return nil.
5 * doc.c (Fsubstitute_command_keys):
6 * regex.c (WEAK_ALIAS):
7 * xdisp.c (redisplay_internal):
8 Move initialization down, to pacify GCC 4.7.1 -Wjump-misses-init.
9 438
102012-09-03 Martin Rudalics <rudalics@gmx.at> 4392012-09-03 Martin Rudalics <rudalics@gmx.at>
11 440
diff --git a/src/alloc.c b/src/alloc.c
index 188a514376d..33dc68df48e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -26,7 +26,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <limits.h> /* For CHAR_BIT. */ 26#include <limits.h> /* For CHAR_BIT. */
27#include <setjmp.h> 27#include <setjmp.h>
28 28
29#include <signal.h> 29#ifdef ENABLE_CHECKING
30#include <signal.h> /* For SIGABRT. */
31#endif
30 32
31#ifdef HAVE_PTHREAD 33#ifdef HAVE_PTHREAD
32#include <pthread.h> 34#include <pthread.h>
@@ -42,7 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#include "keyboard.h" 44#include "keyboard.h"
43#include "frame.h" 45#include "frame.h"
44#include "blockinput.h" 46#include "blockinput.h"
45#include "syssignal.h"
46#include "termhooks.h" /* For struct terminal. */ 47#include "termhooks.h" /* For struct terminal. */
47#include <setjmp.h> 48#include <setjmp.h>
48#include <verify.h> 49#include <verify.h>
@@ -278,6 +279,7 @@ static void gc_sweep (void);
278static Lisp_Object make_pure_vector (ptrdiff_t); 279static Lisp_Object make_pure_vector (ptrdiff_t);
279static void mark_glyph_matrix (struct glyph_matrix *); 280static void mark_glyph_matrix (struct glyph_matrix *);
280static void mark_face_cache (struct face_cache *); 281static void mark_face_cache (struct face_cache *);
282static void mark_buffer (struct buffer *);
281 283
282#if !defined REL_ALLOC || defined SYSTEM_MALLOC 284#if !defined REL_ALLOC || defined SYSTEM_MALLOC
283static void refill_memory_reserve (void); 285static void refill_memory_reserve (void);
@@ -613,7 +615,7 @@ overrun_check_malloc (size_t size)
613 register unsigned char *val; 615 register unsigned char *val;
614 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; 616 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0;
615 if (SIZE_MAX - overhead < size) 617 if (SIZE_MAX - overhead < size)
616 abort (); 618 emacs_abort ();
617 619
618 val = malloc (size + overhead); 620 val = malloc (size + overhead);
619 if (val && check_depth == 1) 621 if (val && check_depth == 1)
@@ -638,7 +640,7 @@ overrun_check_realloc (void *block, size_t size)
638 register unsigned char *val = (unsigned char *) block; 640 register unsigned char *val = (unsigned char *) block;
639 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; 641 int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0;
640 if (SIZE_MAX - overhead < size) 642 if (SIZE_MAX - overhead < size)
641 abort (); 643 emacs_abort ();
642 644
643 if (val 645 if (val
644 && check_depth == 1 646 && check_depth == 1
@@ -649,7 +651,7 @@ overrun_check_realloc (void *block, size_t size)
649 size_t osize = xmalloc_get_size (val); 651 size_t osize = xmalloc_get_size (val);
650 if (memcmp (xmalloc_overrun_check_trailer, val + osize, 652 if (memcmp (xmalloc_overrun_check_trailer, val + osize,
651 XMALLOC_OVERRUN_CHECK_SIZE)) 653 XMALLOC_OVERRUN_CHECK_SIZE))
652 abort (); 654 emacs_abort ();
653 memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); 655 memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
654 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 656 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
655 memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); 657 memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE);
@@ -686,7 +688,7 @@ overrun_check_free (void *block)
686 size_t osize = xmalloc_get_size (val); 688 size_t osize = xmalloc_get_size (val);
687 if (memcmp (xmalloc_overrun_check_trailer, val + osize, 689 if (memcmp (xmalloc_overrun_check_trailer, val + osize,
688 XMALLOC_OVERRUN_CHECK_SIZE)) 690 XMALLOC_OVERRUN_CHECK_SIZE))
689 abort (); 691 emacs_abort ();
690#ifdef XMALLOC_CLEAR_FREE_MEMORY 692#ifdef XMALLOC_CLEAR_FREE_MEMORY
691 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; 693 val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
692 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD); 694 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD);
@@ -1272,7 +1274,7 @@ emacs_blocked_free (void *ptr, const void *ptr2)
1272 { 1274 {
1273 fprintf (stderr, 1275 fprintf (stderr,
1274 "Freeing `%p' which wasn't allocated with malloc\n", ptr); 1276 "Freeing `%p' which wasn't allocated with malloc\n", ptr);
1275 abort (); 1277 emacs_abort ();
1276 } 1278 }
1277 else 1279 else
1278 { 1280 {
@@ -1331,7 +1333,7 @@ emacs_blocked_malloc (size_t size, const void *ptr)
1331 fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n", 1333 fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n",
1332 m->start, m->end, (char *) m->end - (char *) m->start, 1334 m->start, m->end, (char *) m->end - (char *) m->start,
1333 m->type); 1335 m->type);
1334 abort (); 1336 emacs_abort ();
1335 } 1337 }
1336 1338
1337 if (!dont_register_blocks) 1339 if (!dont_register_blocks)
@@ -1369,7 +1371,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
1369 fprintf (stderr, 1371 fprintf (stderr,
1370 "Realloc of %p which wasn't allocated with malloc\n", 1372 "Realloc of %p which wasn't allocated with malloc\n",
1371 ptr); 1373 ptr);
1372 abort (); 1374 emacs_abort ();
1373 } 1375 }
1374 1376
1375 mem_delete (m); 1377 mem_delete (m);
@@ -1391,7 +1393,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
1391 if (m != MEM_NIL) 1393 if (m != MEM_NIL)
1392 { 1394 {
1393 fprintf (stderr, "Realloc returns memory that is already in use\n"); 1395 fprintf (stderr, "Realloc returns memory that is already in use\n");
1394 abort (); 1396 emacs_abort ();
1395 } 1397 }
1396 1398
1397 /* Can't handle zero size regions in the red-black tree. */ 1399 /* Can't handle zero size regions in the red-black tree. */
@@ -1804,7 +1806,7 @@ string_bytes (struct Lisp_String *s)
1804 if (!PURE_POINTER_P (s) 1806 if (!PURE_POINTER_P (s)
1805 && s->data 1807 && s->data
1806 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) 1808 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
1807 abort (); 1809 emacs_abort ();
1808 return nbytes; 1810 return nbytes;
1809} 1811}
1810 1812
@@ -1878,7 +1880,7 @@ check_string_free_list (void)
1878 while (s != NULL) 1880 while (s != NULL)
1879 { 1881 {
1880 if ((uintptr_t) s < 1024) 1882 if ((uintptr_t) s < 1024)
1881 abort (); 1883 emacs_abort ();
1882 s = NEXT_FREE_LISP_STRING (s); 1884 s = NEXT_FREE_LISP_STRING (s);
1883 } 1885 }
1884} 1886}
@@ -2107,7 +2109,7 @@ sweep_strings (void)
2107 back-pointer so that we know it's free. */ 2109 back-pointer so that we know it's free. */
2108#ifdef GC_CHECK_STRING_BYTES 2110#ifdef GC_CHECK_STRING_BYTES
2109 if (string_bytes (s) != SDATA_NBYTES (data)) 2111 if (string_bytes (s) != SDATA_NBYTES (data))
2110 abort (); 2112 emacs_abort ();
2111#else 2113#else
2112 data->u.nbytes = STRING_BYTES (s); 2114 data->u.nbytes = STRING_BYTES (s);
2113#endif 2115#endif
@@ -2218,7 +2220,7 @@ compact_small_strings (void)
2218 /* Check that the string size recorded in the string is the 2220 /* Check that the string size recorded in the string is the
2219 same as the one recorded in the sdata structure. */ 2221 same as the one recorded in the sdata structure. */
2220 if (s && string_bytes (s) != SDATA_NBYTES (from)) 2222 if (s && string_bytes (s) != SDATA_NBYTES (from))
2221 abort (); 2223 emacs_abort ();
2222#endif /* GC_CHECK_STRING_BYTES */ 2224#endif /* GC_CHECK_STRING_BYTES */
2223 2225
2224 nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); 2226 nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from);
@@ -2231,7 +2233,7 @@ compact_small_strings (void)
2231 if (memcmp (string_overrun_cookie, 2233 if (memcmp (string_overrun_cookie,
2232 (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, 2234 (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE,
2233 GC_STRING_OVERRUN_COOKIE_SIZE)) 2235 GC_STRING_OVERRUN_COOKIE_SIZE))
2234 abort (); 2236 emacs_abort ();
2235#endif 2237#endif
2236 2238
2237 /* Non-NULL S means it's alive. Copy its data. */ 2239 /* Non-NULL S means it's alive. Copy its data. */
@@ -2488,7 +2490,7 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
2488 struct Lisp_String *s; 2490 struct Lisp_String *s;
2489 2491
2490 if (nchars < 0) 2492 if (nchars < 0)
2491 abort (); 2493 emacs_abort ();
2492 if (!nbytes) 2494 if (!nbytes)
2493 return empty_multibyte_string; 2495 return empty_multibyte_string;
2494 2496
@@ -2809,7 +2811,7 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
2809 else if (type == CONSTYPE_HEAP) 2811 else if (type == CONSTYPE_HEAP)
2810 val = Fcons (objp[i], val); 2812 val = Fcons (objp[i], val);
2811 else 2813 else
2812 abort (); 2814 emacs_abort ();
2813 } 2815 }
2814 return val; 2816 return val;
2815} 2817}
@@ -3281,7 +3283,10 @@ allocate_buffer (void)
3281 3283
3282 XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) 3284 XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text)
3283 - header_size) / word_size); 3285 - header_size) / word_size);
3284 /* Note that the fields of B are not initialized. */ 3286 /* Put B on the chain of all buffers including killed ones. */
3287 b->header.next.buffer = all_buffers;
3288 all_buffers = b;
3289 /* Note that the rest fields of B are not initialized. */
3285 return b; 3290 return b;
3286} 3291}
3287 3292
@@ -3919,7 +3924,7 @@ mem_insert (void *start, void *end, enum mem_type type)
3919 while (c != MEM_NIL) 3924 while (c != MEM_NIL)
3920 { 3925 {
3921 if (start >= c->start && start < c->end) 3926 if (start >= c->start && start < c->end)
3922 abort (); 3927 emacs_abort ();
3923 parent = c; 3928 parent = c;
3924 c = start < c->start ? c->left : c->right; 3929 c = start < c->start ? c->left : c->right;
3925 } 3930 }
@@ -3938,7 +3943,7 @@ mem_insert (void *start, void *end, enum mem_type type)
3938#ifdef GC_MALLOC_CHECK 3943#ifdef GC_MALLOC_CHECK
3939 x = _malloc_internal (sizeof *x); 3944 x = _malloc_internal (sizeof *x);
3940 if (x == NULL) 3945 if (x == NULL)
3941 abort (); 3946 emacs_abort ();
3942#else 3947#else
3943 x = xmalloc (sizeof *x); 3948 x = xmalloc (sizeof *x);
3944#endif 3949#endif
@@ -4613,7 +4618,7 @@ mark_maybe_pointer (void *p)
4613 break; 4618 break;
4614 4619
4615 default: 4620 default:
4616 abort (); 4621 emacs_abort ();
4617 } 4622 }
4618 4623
4619 if (!NILP (obj)) 4624 if (!NILP (obj))
@@ -4764,7 +4769,7 @@ test_setjmp (void)
4764 x = strlen (buf); 4769 x = strlen (buf);
4765 x = 2 * x - 1; 4770 x = 2 * x - 1;
4766 4771
4767 setjmp (jbuf); 4772 _setjmp (jbuf);
4768 if (longjmps_done == 1) 4773 if (longjmps_done == 1)
4769 { 4774 {
4770 /* Came here after the longjmp at the end of the function. 4775 /* Came here after the longjmp at the end of the function.
@@ -4789,7 +4794,7 @@ test_setjmp (void)
4789 ++longjmps_done; 4794 ++longjmps_done;
4790 x = 2; 4795 x = 2;
4791 if (longjmps_done == 1) 4796 if (longjmps_done == 1)
4792 longjmp (jbuf, 1); 4797 _longjmp (jbuf, 1);
4793} 4798}
4794 4799
4795#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ 4800#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */
@@ -4810,7 +4815,7 @@ check_gcpros (void)
4810 if (!survives_gc_p (p->var[i])) 4815 if (!survives_gc_p (p->var[i]))
4811 /* FIXME: It's not necessarily a bug. It might just be that the 4816 /* FIXME: It's not necessarily a bug. It might just be that the
4812 GCPRO is unnecessary or should release the object sooner. */ 4817 GCPRO is unnecessary or should release the object sooner. */
4813 abort (); 4818 emacs_abort ();
4814} 4819}
4815 4820
4816#elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 4821#elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
@@ -4931,7 +4936,7 @@ mark_stack (void)
4931 } 4936 }
4932#endif /* GC_SETJMP_WORKS */ 4937#endif /* GC_SETJMP_WORKS */
4933 4938
4934 setjmp (j.j); 4939 _setjmp (j.j);
4935 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4940 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4936#endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4941#endif /* not GC_SAVE_REGISTERS_ON_STACK */
4937#endif /* not HAVE___BUILTIN_UNWIND_INIT */ 4942#endif /* not HAVE___BUILTIN_UNWIND_INIT */
@@ -4981,7 +4986,8 @@ valid_pointer_p (void *p)
4981#endif 4986#endif
4982} 4987}
4983 4988
4984/* Return 1 if OBJ is a valid lisp object. 4989/* Return 2 if OBJ is a killed or special buffer object.
4990 Return 1 if OBJ is a valid lisp object.
4985 Return 0 if OBJ is NOT a valid lisp object. 4991 Return 0 if OBJ is NOT a valid lisp object.
4986 Return -1 if we cannot validate OBJ. 4992 Return -1 if we cannot validate OBJ.
4987 This function can be quite slow, 4993 This function can be quite slow,
@@ -5002,6 +5008,9 @@ valid_lisp_object_p (Lisp_Object obj)
5002 if (PURE_POINTER_P (p)) 5008 if (PURE_POINTER_P (p))
5003 return 1; 5009 return 1;
5004 5010
5011 if (p == &buffer_defaults || p == &buffer_local_symbols)
5012 return 2;
5013
5005#if !GC_MARK_STACK 5014#if !GC_MARK_STACK
5006 return valid_pointer_p (p); 5015 return valid_pointer_p (p);
5007#else 5016#else
@@ -5027,7 +5036,7 @@ valid_lisp_object_p (Lisp_Object obj)
5027 return 0; 5036 return 0;
5028 5037
5029 case MEM_TYPE_BUFFER: 5038 case MEM_TYPE_BUFFER:
5030 return live_buffer_p (m, p); 5039 return live_buffer_p (m, p) ? 1 : 2;
5031 5040
5032 case MEM_TYPE_CONS: 5041 case MEM_TYPE_CONS:
5033 return live_cons_p (m, p); 5042 return live_cons_p (m, p);
@@ -5351,7 +5360,7 @@ staticpro (Lisp_Object *varaddress)
5351{ 5360{
5352 staticvec[staticidx++] = varaddress; 5361 staticvec[staticidx++] = varaddress;
5353 if (staticidx >= NSTATICS) 5362 if (staticidx >= NSTATICS)
5354 abort (); 5363 emacs_abort ();
5355} 5364}
5356 5365
5357 5366
@@ -5406,7 +5415,7 @@ See Info node `(elisp)Garbage Collection'. */)
5406 Lisp_Object retval = Qnil; 5415 Lisp_Object retval = Qnil;
5407 5416
5408 if (abort_on_gc) 5417 if (abort_on_gc)
5409 abort (); 5418 emacs_abort ();
5410 5419
5411 /* Can't GC if pure storage overflowed because we can't determine 5420 /* Can't GC if pure storage overflowed because we can't determine
5412 if something is a pure object or not. */ 5421 if something is a pure object or not. */
@@ -5469,6 +5478,9 @@ See Info node `(elisp)Garbage Collection'. */)
5469 5478
5470 /* Mark all the special slots that serve as the roots of accessibility. */ 5479 /* Mark all the special slots that serve as the roots of accessibility. */
5471 5480
5481 mark_buffer (&buffer_defaults);
5482 mark_buffer (&buffer_local_symbols);
5483
5472 for (i = 0; i < staticidx; i++) 5484 for (i = 0; i < staticidx; i++)
5473 mark_object (*staticvec[i]); 5485 mark_object (*staticvec[i]);
5474 5486
@@ -5887,7 +5899,7 @@ mark_object (Lisp_Object arg)
5887 do { \ 5899 do { \
5888 m = mem_find (po); \ 5900 m = mem_find (po); \
5889 if (m == MEM_NIL) \ 5901 if (m == MEM_NIL) \
5890 abort (); \ 5902 emacs_abort (); \
5891 } while (0) 5903 } while (0)
5892 5904
5893 /* Check that the object pointed to by PO is live, using predicate 5905 /* Check that the object pointed to by PO is live, using predicate
@@ -5895,7 +5907,7 @@ mark_object (Lisp_Object arg)
5895#define CHECK_LIVE(LIVEP) \ 5907#define CHECK_LIVE(LIVEP) \
5896 do { \ 5908 do { \
5897 if (!LIVEP (m, po)) \ 5909 if (!LIVEP (m, po)) \
5898 abort (); \ 5910 emacs_abort (); \
5899 } while (0) 5911 } while (0)
5900 5912
5901 /* Check both of the above conditions. */ 5913 /* Check both of the above conditions. */
@@ -5940,10 +5952,8 @@ mark_object (Lisp_Object arg)
5940 5952
5941#ifdef GC_CHECK_MARKED_OBJECTS 5953#ifdef GC_CHECK_MARKED_OBJECTS
5942 m = mem_find (po); 5954 m = mem_find (po);
5943 if (m == MEM_NIL && !SUBRP (obj) 5955 if (m == MEM_NIL && !SUBRP (obj))
5944 && po != &buffer_defaults 5956 emacs_abort ();
5945 && po != &buffer_local_symbols)
5946 abort ();
5947#endif /* GC_CHECK_MARKED_OBJECTS */ 5957#endif /* GC_CHECK_MARKED_OBJECTS */
5948 5958
5949 if (ptr->header.size & PSEUDOVECTOR_FLAG) 5959 if (ptr->header.size & PSEUDOVECTOR_FLAG)
@@ -5959,15 +5969,14 @@ mark_object (Lisp_Object arg)
5959 { 5969 {
5960 case PVEC_BUFFER: 5970 case PVEC_BUFFER:
5961#ifdef GC_CHECK_MARKED_OBJECTS 5971#ifdef GC_CHECK_MARKED_OBJECTS
5962 if (po != &buffer_defaults && po != &buffer_local_symbols) 5972 {
5963 { 5973 struct buffer *b;
5964 struct buffer *b; 5974 FOR_EACH_BUFFER (b)
5965 FOR_EACH_BUFFER (b) 5975 if (b == po)
5966 if (b == po) 5976 break;
5967 break; 5977 if (b == NULL)
5968 if (b == NULL) 5978 emacs_abort ();
5969 abort (); 5979 }
5970 }
5971#endif /* GC_CHECK_MARKED_OBJECTS */ 5980#endif /* GC_CHECK_MARKED_OBJECTS */
5972 mark_buffer ((struct buffer *) ptr); 5981 mark_buffer ((struct buffer *) ptr);
5973 break; 5982 break;
@@ -5992,10 +6001,8 @@ mark_object (Lisp_Object arg)
5992 break; 6001 break;
5993 6002
5994 case PVEC_FRAME: 6003 case PVEC_FRAME:
5995 { 6004 mark_vectorlike (ptr);
5996 mark_vectorlike (ptr); 6005 mark_face_cache (((struct frame *) ptr)->face_cache);
5997 mark_face_cache (((struct frame *) ptr)->face_cache);
5998 }
5999 break; 6006 break;
6000 6007
6001 case PVEC_WINDOW: 6008 case PVEC_WINDOW:
@@ -6042,7 +6049,7 @@ mark_object (Lisp_Object arg)
6042 break; 6049 break;
6043 6050
6044 case PVEC_FREE: 6051 case PVEC_FREE:
6045 abort (); 6052 emacs_abort ();
6046 6053
6047 default: 6054 default:
6048 mark_vectorlike (ptr); 6055 mark_vectorlike (ptr);
@@ -6089,7 +6096,7 @@ mark_object (Lisp_Object arg)
6089 And if it's forwarded to a C variable, either it's not 6096 And if it's forwarded to a C variable, either it's not
6090 a Lisp_Object var, or it's staticpro'd already. */ 6097 a Lisp_Object var, or it's staticpro'd already. */
6091 break; 6098 break;
6092 default: abort (); 6099 default: emacs_abort ();
6093 } 6100 }
6094 if (!PURE_POINTER_P (XSTRING (ptr->name))) 6101 if (!PURE_POINTER_P (XSTRING (ptr->name)))
6095 MARK_STRING (XSTRING (ptr->name)); 6102 MARK_STRING (XSTRING (ptr->name));
@@ -6143,7 +6150,7 @@ mark_object (Lisp_Object arg)
6143 break; 6150 break;
6144 6151
6145 default: 6152 default:
6146 abort (); 6153 emacs_abort ();
6147 } 6154 }
6148 break; 6155 break;
6149 6156
@@ -6165,7 +6172,7 @@ mark_object (Lisp_Object arg)
6165 obj = ptr->u.cdr; 6172 obj = ptr->u.cdr;
6166 cdr_count++; 6173 cdr_count++;
6167 if (cdr_count == mark_object_loop_halt) 6174 if (cdr_count == mark_object_loop_halt)
6168 abort (); 6175 emacs_abort ();
6169 goto loop; 6176 goto loop;
6170 } 6177 }
6171 6178
@@ -6178,7 +6185,7 @@ mark_object (Lisp_Object arg)
6178 break; 6185 break;
6179 6186
6180 default: 6187 default:
6181 abort (); 6188 emacs_abort ();
6182 } 6189 }
6183 6190
6184#undef CHECK_LIVE 6191#undef CHECK_LIVE
@@ -6247,7 +6254,7 @@ survives_gc_p (Lisp_Object obj)
6247 break; 6254 break;
6248 6255
6249 default: 6256 default:
6250 abort (); 6257 emacs_abort ();
6251 } 6258 }
6252 6259
6253 return survives_p || PURE_POINTER_P ((void *) XPNTR (obj)); 6260 return survives_p || PURE_POINTER_P ((void *) XPNTR (obj));
@@ -6685,21 +6692,14 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6685 6692
6686#ifdef ENABLE_CHECKING 6693#ifdef ENABLE_CHECKING
6687 6694
6688# include <execinfo.h>
6689
6690bool suppress_checking; 6695bool suppress_checking;
6691 6696
6692void 6697void
6693die (const char *msg, const char *file, int line) 6698die (const char *msg, const char *file, int line)
6694{ 6699{
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", 6700 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6699 file, line, msg); 6701 file, line, msg);
6700 npointers = backtrace (buffer, NPOINTERS_MAX); 6702 fatal_error_backtrace (SIGABRT, INT_MAX);
6701 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
6702 abort ();
6703} 6703}
6704#endif 6704#endif
6705 6705
diff --git a/src/atimer.c b/src/atimer.c
index eb3136ae55d..34731920af5 100644
--- a/src/atimer.c
+++ b/src/atimer.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 <signal.h>
21#include <stdio.h> 20#include <stdio.h>
22#include <setjmp.h> 21#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.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
@@ -374,13 +387,9 @@ run_timers (void)
374/* Signal handler for SIGALRM. SIGNO is the signal number, i.e. 387/* Signal handler for SIGALRM. SIGNO is the signal number, i.e.
375 SIGALRM. */ 388 SIGALRM. */
376 389
377void 390static void
378alarm_signal_handler (int signo) 391handle_alarm_signal (int sig)
379{ 392{
380#ifndef SYNC_INPUT
381 SIGNAL_THREAD_CHECK (signo);
382#endif
383
384 pending_atimers = 1; 393 pending_atimers = 1;
385#ifdef SYNC_INPUT 394#ifdef SYNC_INPUT
386 pending_signals = 1; 395 pending_signals = 1;
@@ -389,17 +398,23 @@ alarm_signal_handler (int signo)
389#endif 398#endif
390} 399}
391 400
401static void
402deliver_alarm_signal (int sig)
403{
404 handle_on_main_thread (sig, handle_alarm_signal);
405}
406
392 407
393/* Call alarm_signal_handler for pending timers. */ 408/* Call alarm signal handler for pending timers. */
394 409
395void 410void
396do_pending_atimers (void) 411do_pending_atimers (void)
397{ 412{
398 if (pending_atimers) 413 if (pending_atimers)
399 { 414 {
400 BLOCK_ATIMERS; 415 block_atimers ();
401 run_timers (); 416 run_timers ();
402 UNBLOCK_ATIMERS; 417 unblock_atimers ();
403 } 418 }
404} 419}
405 420
@@ -412,7 +427,9 @@ turn_on_atimers (bool on)
412{ 427{
413 if (on) 428 if (on)
414 { 429 {
415 signal (SIGALRM, alarm_signal_handler); 430 struct sigaction action;
431 emacs_sigaction_init (&action, deliver_alarm_signal);
432 sigaction (SIGALRM, &action, 0);
416 set_alarm (); 433 set_alarm ();
417 } 434 }
418 else 435 else
@@ -423,8 +440,10 @@ turn_on_atimers (bool on)
423void 440void
424init_atimer (void) 441init_atimer (void)
425{ 442{
443 struct sigaction action;
426 free_atimers = stopped_atimers = atimers = NULL; 444 free_atimers = stopped_atimers = atimers = NULL;
427 pending_atimers = 0; 445 pending_atimers = 0;
428 /* pending_signals is initialized in init_keyboard.*/ 446 /* pending_signals is initialized in init_keyboard.*/
429 signal (SIGALRM, alarm_signal_handler); 447 emacs_sigaction_init (&action, deliver_alarm_signal);
448 sigaction (SIGALRM, &action, 0);
430} 449}
diff --git a/src/bidi.c b/src/bidi.c
index 6b3ac53d318..73fec3533a4 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -105,7 +105,7 @@ bidi_get_type (int ch, bidi_dir_t override)
105 if (ch == BIDI_EOB) 105 if (ch == BIDI_EOB)
106 return NEUTRAL_B; 106 return NEUTRAL_B;
107 if (ch < 0 || ch > MAX_CHAR) 107 if (ch < 0 || ch > MAX_CHAR)
108 abort (); 108 emacs_abort ();
109 109
110 default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); 110 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 111 /* Every valid character code, even those that are unassigned by the
@@ -113,7 +113,7 @@ bidi_get_type (int ch, bidi_dir_t override)
113 DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT 113 DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT
114 (= zero) code from CHAR_TABLE_REF, that's a bug. */ 114 (= zero) code from CHAR_TABLE_REF, that's a bug. */
115 if (default_type == UNKNOWN_BT) 115 if (default_type == UNKNOWN_BT)
116 abort (); 116 emacs_abort ();
117 117
118 if (override == NEUTRAL_DIR) 118 if (override == NEUTRAL_DIR)
119 return default_type; 119 return default_type;
@@ -141,7 +141,7 @@ bidi_get_type (int ch, bidi_dir_t override)
141 else if (override == R2L) 141 else if (override == R2L)
142 return STRONG_R; 142 return STRONG_R;
143 else 143 else
144 abort (); /* can't happen: handled above */ 144 emacs_abort (); /* can't happen: handled above */
145 } 145 }
146 } 146 }
147} 147}
@@ -183,7 +183,7 @@ bidi_get_category (bidi_type_t type)
183 case NEUTRAL_ON: 183 case NEUTRAL_ON:
184 return NEUTRAL; 184 return NEUTRAL;
185 default: 185 default:
186 abort (); 186 emacs_abort ();
187 } 187 }
188} 188}
189 189
@@ -199,7 +199,7 @@ bidi_mirror_char (int c)
199 if (c == BIDI_EOB) 199 if (c == BIDI_EOB)
200 return c; 200 return c;
201 if (c < 0 || c > MAX_CHAR) 201 if (c < 0 || c > MAX_CHAR)
202 abort (); 202 emacs_abort ();
203 203
204 val = CHAR_TABLE_REF (bidi_mirror_table, c); 204 val = CHAR_TABLE_REF (bidi_mirror_table, c);
205 if (INTEGERP (val)) 205 if (INTEGERP (val))
@@ -215,7 +215,7 @@ bidi_mirror_char (int c)
215 /* Minimal test we must do in optimized builds, to prevent weird 215 /* Minimal test we must do in optimized builds, to prevent weird
216 crashes further down the road. */ 216 crashes further down the road. */
217 if (v < 0 || v > MAX_CHAR) 217 if (v < 0 || v > MAX_CHAR)
218 abort (); 218 emacs_abort ();
219 219
220 return v; 220 return v;
221 } 221 }
@@ -373,7 +373,7 @@ bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it)
373 int current_scan_dir = bidi_it->scan_dir; 373 int current_scan_dir = bidi_it->scan_dir;
374 374
375 if (idx < bidi_cache_start || idx >= bidi_cache_idx) 375 if (idx < bidi_cache_start || idx >= bidi_cache_idx)
376 abort (); 376 emacs_abort ();
377 377
378 bidi_copy_it (bidi_it, &bidi_cache[idx]); 378 bidi_copy_it (bidi_it, &bidi_cache[idx]);
379 bidi_it->scan_dir = current_scan_dir; 379 bidi_it->scan_dir = current_scan_dir;
@@ -518,7 +518,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
518 518
519 /* We should never cache on backward scans. */ 519 /* We should never cache on backward scans. */
520 if (bidi_it->scan_dir == -1) 520 if (bidi_it->scan_dir == -1)
521 abort (); 521 emacs_abort ();
522 idx = bidi_cache_search (bidi_it->charpos, -1, 1); 522 idx = bidi_cache_search (bidi_it->charpos, -1, 1);
523 523
524 if (idx < 0) 524 if (idx < 0)
@@ -537,7 +537,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
537 idx = bidi_cache_start; 537 idx = bidi_cache_start;
538 } 538 }
539 if (bidi_it->nchars <= 0) 539 if (bidi_it->nchars <= 0)
540 abort (); 540 emacs_abort ();
541 bidi_copy_it (&bidi_cache[idx], bidi_it); 541 bidi_copy_it (&bidi_cache[idx], bidi_it);
542 if (!resolved) 542 if (!resolved)
543 bidi_cache[idx].resolved_level = -1; 543 bidi_cache[idx].resolved_level = -1;
@@ -592,7 +592,7 @@ static inline int
592bidi_peek_at_next_level (struct bidi_it *bidi_it) 592bidi_peek_at_next_level (struct bidi_it *bidi_it)
593{ 593{
594 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1) 594 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1)
595 abort (); 595 emacs_abort ();
596 return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level; 596 return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level;
597} 597}
598 598
@@ -629,7 +629,7 @@ void
629bidi_pop_it (struct bidi_it *bidi_it) 629bidi_pop_it (struct bidi_it *bidi_it)
630{ 630{
631 if (bidi_cache_start <= 0) 631 if (bidi_cache_start <= 0)
632 abort (); 632 emacs_abort ();
633 633
634 /* Reset the next free cache slot index to what it was before the 634 /* Reset the next free cache slot index to what it was before the
635 call to bidi_push_it. */ 635 call to bidi_push_it. */
@@ -640,7 +640,7 @@ bidi_pop_it (struct bidi_it *bidi_it)
640 640
641 /* Pop the previous cache start from the stack. */ 641 /* Pop the previous cache start from the stack. */
642 if (bidi_cache_sp <= 0) 642 if (bidi_cache_sp <= 0)
643 abort (); 643 emacs_abort ();
644 bidi_cache_start = bidi_cache_start_stack[--bidi_cache_sp]; 644 bidi_cache_start = bidi_cache_start_stack[--bidi_cache_sp];
645 645
646 /* Invalidate the last-used cache slot data. */ 646 /* Invalidate the last-used cache slot data. */
@@ -762,12 +762,12 @@ bidi_initialize (void)
762{ 762{
763 bidi_type_table = uniprop_table (intern ("bidi-class")); 763 bidi_type_table = uniprop_table (intern ("bidi-class"));
764 if (NILP (bidi_type_table)) 764 if (NILP (bidi_type_table))
765 abort (); 765 emacs_abort ();
766 staticpro (&bidi_type_table); 766 staticpro (&bidi_type_table);
767 767
768 bidi_mirror_table = uniprop_table (intern ("mirroring")); 768 bidi_mirror_table = uniprop_table (intern ("mirroring"));
769 if (NILP (bidi_mirror_table)) 769 if (NILP (bidi_mirror_table))
770 abort (); 770 emacs_abort ();
771 staticpro (&bidi_mirror_table); 771 staticpro (&bidi_mirror_table);
772 772
773 Qparagraph_start = intern ("paragraph-start"); 773 Qparagraph_start = intern ("paragraph-start");
@@ -885,7 +885,7 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
885 else 885 else
886 { 886 {
887 if (!CHAR_HEAD_P (*p)) 887 if (!CHAR_HEAD_P (*p))
888 abort (); 888 emacs_abort ();
889 889
890 while (pos < end) 890 while (pos < end)
891 { 891 {
@@ -965,7 +965,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 965 /* We don't expect to find ourselves in the middle of a display
966 property. Hopefully, it will never be needed. */ 966 property. Hopefully, it will never be needed. */
967 if (charpos > *disp_pos) 967 if (charpos > *disp_pos)
968 abort (); 968 emacs_abort ();
969 /* Text covered by `display' properties and overlays with 969 /* Text covered by `display' properties and overlays with
970 display properties or display strings is handled as a single 970 display properties or display strings is handled as a single
971 character that represents the entire run of characters 971 character that represents the entire run of characters
@@ -995,7 +995,7 @@ bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos,
995 } 995 }
996 *nchars = disp_end_pos - *disp_pos; 996 *nchars = disp_end_pos - *disp_pos;
997 if (*nchars <= 0) 997 if (*nchars <= 0)
998 abort (); 998 emacs_abort ();
999 if (string->s) 999 if (string->s)
1000 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos, 1000 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos,
1001 disp_end_pos, string->unibyte); 1001 disp_end_pos, string->unibyte);
@@ -1160,7 +1160,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p)
1160 dir = L2R; 1160 dir = L2R;
1161 /* We should never be called at EOB or before BEGV. */ 1161 /* We should never be called at EOB or before BEGV. */
1162 else if (bidi_it->charpos >= end || bytepos < begbyte) 1162 else if (bidi_it->charpos >= end || bytepos < begbyte)
1163 abort (); 1163 emacs_abort ();
1164 1164
1165 if (dir == L2R) 1165 if (dir == L2R)
1166 { 1166 {
@@ -1298,7 +1298,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); 1298 && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR);
1299 } 1299 }
1300 else 1300 else
1301 abort (); 1301 emacs_abort ();
1302 1302
1303 /* Contrary to UAX#9 clause P3, we only default the paragraph 1303 /* Contrary to UAX#9 clause P3, we only default the paragraph
1304 direction to L2R if we have no previous usable paragraph 1304 direction to L2R if we have no previous usable paragraph
@@ -1325,7 +1325,7 @@ bidi_explicit_dir_char (int ch)
1325 bidi_type_t ch_type; 1325 bidi_type_t ch_type;
1326 1326
1327 if (!bidi_initialized) 1327 if (!bidi_initialized)
1328 abort (); 1328 emacs_abort ();
1329 ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); 1329 ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch));
1330 return (ch_type == LRE || ch_type == LRO 1330 return (ch_type == LRE || ch_type == LRO
1331 || ch_type == RLE || ch_type == RLO 1331 || ch_type == RLE || ch_type == RLO
@@ -1378,10 +1378,10 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1378 /* Advance to the next character, skipping characters covered by 1378 /* Advance to the next character, skipping characters covered by
1379 display strings (nchars > 1). */ 1379 display strings (nchars > 1). */
1380 if (bidi_it->nchars <= 0) 1380 if (bidi_it->nchars <= 0)
1381 abort (); 1381 emacs_abort ();
1382 bidi_it->charpos += bidi_it->nchars; 1382 bidi_it->charpos += bidi_it->nchars;
1383 if (bidi_it->ch_len == 0) 1383 if (bidi_it->ch_len == 0)
1384 abort (); 1384 emacs_abort ();
1385 bidi_it->bytepos += bidi_it->ch_len; 1385 bidi_it->bytepos += bidi_it->ch_len;
1386 } 1386 }
1387 1387
@@ -1581,7 +1581,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
1581 } 1581 }
1582 1582
1583 if (bidi_it->nchars <= 0) 1583 if (bidi_it->nchars <= 0)
1584 abort (); 1584 emacs_abort ();
1585 if (level == prev_level) /* empty embedding */ 1585 if (level == prev_level) /* empty embedding */
1586 saved_it.ignore_bn_limit = bidi_it->charpos + bidi_it->nchars; 1586 saved_it.ignore_bn_limit = bidi_it->charpos + bidi_it->nchars;
1587 else /* this embedding is non-empty */ 1587 else /* this embedding is non-empty */
@@ -1644,7 +1644,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1644 || type == RLE 1644 || type == RLE
1645 || type == RLO 1645 || type == RLO
1646 || type == PDF) 1646 || type == PDF)
1647 abort (); 1647 emacs_abort ();
1648 1648
1649 if (new_level != prev_level 1649 if (new_level != prev_level
1650 || bidi_it->type == NEUTRAL_B) 1650 || bidi_it->type == NEUTRAL_B)
@@ -1685,7 +1685,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1685 else if (bidi_it->sor == L2R) 1685 else if (bidi_it->sor == L2R)
1686 type = STRONG_L; 1686 type = STRONG_L;
1687 else /* shouldn't happen! */ 1687 else /* shouldn't happen! */
1688 abort (); 1688 emacs_abort ();
1689 } 1689 }
1690 if (type == WEAK_EN /* W2 */ 1690 if (type == WEAK_EN /* W2 */
1691 && bidi_it->last_strong.type_after_w1 == STRONG_AL) 1691 && bidi_it->last_strong.type_after_w1 == STRONG_AL)
@@ -1767,7 +1767,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1767 : bidi_it->string.s); 1767 : bidi_it->string.s);
1768 1768
1769 if (bidi_it->nchars <= 0) 1769 if (bidi_it->nchars <= 0)
1770 abort (); 1770 emacs_abort ();
1771 next_char 1771 next_char
1772 = (bidi_it->charpos + bidi_it->nchars >= eob 1772 = (bidi_it->charpos + bidi_it->nchars >= eob
1773 ? BIDI_EOB 1773 ? BIDI_EOB
@@ -1875,7 +1875,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1875 || type == NEUTRAL_S 1875 || type == NEUTRAL_S
1876 || type == NEUTRAL_WS 1876 || type == NEUTRAL_WS
1877 || type == NEUTRAL_ON)) 1877 || type == NEUTRAL_ON))
1878 abort (); 1878 emacs_abort ();
1879 1879
1880 if ((type != NEUTRAL_B /* Don't risk entering the long loop below if 1880 if ((type != NEUTRAL_B /* Don't risk entering the long loop below if
1881 we are already at paragraph end. */ 1881 we are already at paragraph end. */
@@ -1930,7 +1930,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1930 bidi_type_t next_type; 1930 bidi_type_t next_type;
1931 1931
1932 if (bidi_it->scan_dir == -1) 1932 if (bidi_it->scan_dir == -1)
1933 abort (); 1933 emacs_abort ();
1934 1934
1935 bidi_copy_it (&saved_it, bidi_it); 1935 bidi_copy_it (&saved_it, bidi_it);
1936 /* Scan the text forward until we find the first non-neutral 1936 /* Scan the text forward until we find the first non-neutral
@@ -1979,7 +1979,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1979 break; 1979 break;
1980 case WEAK_BN: 1980 case WEAK_BN:
1981 if (!bidi_explicit_dir_char (bidi_it->ch)) 1981 if (!bidi_explicit_dir_char (bidi_it->ch))
1982 abort (); /* can't happen: BNs are skipped */ 1982 emacs_abort (); /* can't happen: BNs are skipped */
1983 /* FALLTHROUGH */ 1983 /* FALLTHROUGH */
1984 case NEUTRAL_B: 1984 case NEUTRAL_B:
1985 /* Marched all the way to the end of this level run. 1985 /* Marched all the way to the end of this level run.
@@ -1998,7 +1998,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1998 } 1998 }
1999 break; 1999 break;
2000 default: 2000 default:
2001 abort (); 2001 emacs_abort ();
2002 } 2002 }
2003 type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type, 2003 type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type,
2004 next_type, current_level); 2004 next_type, current_level);
@@ -2023,7 +2023,7 @@ bidi_type_of_next_char (struct bidi_it *bidi_it)
2023 2023
2024 /* This should always be called during a forward scan. */ 2024 /* This should always be called during a forward scan. */
2025 if (bidi_it->scan_dir != 1) 2025 if (bidi_it->scan_dir != 1)
2026 abort (); 2026 emacs_abort ();
2027 2027
2028 /* Reset the limit until which to ignore BNs if we step out of the 2028 /* Reset the limit until which to ignore BNs if we step out of the
2029 area where we found only empty levels. */ 2029 area where we found only empty levels. */
@@ -2107,7 +2107,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2107 if (bidi_it->scan_dir > 0) 2107 if (bidi_it->scan_dir > 0)
2108 { 2108 {
2109 if (bidi_it->nchars <= 0) 2109 if (bidi_it->nchars <= 0)
2110 abort (); 2110 emacs_abort ();
2111 next_char_pos = bidi_it->charpos + bidi_it->nchars; 2111 next_char_pos = bidi_it->charpos + bidi_it->nchars;
2112 } 2112 }
2113 else if (bidi_it->charpos >= bob) 2113 else if (bidi_it->charpos >= bob)
@@ -2143,7 +2143,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2143 if (bidi_it->scan_dir == -1) 2143 if (bidi_it->scan_dir == -1)
2144 /* If we are going backwards, the iterator state is already cached 2144 /* If we are going backwards, the iterator state is already cached
2145 from previous scans, and should be fully resolved. */ 2145 from previous scans, and should be fully resolved. */
2146 abort (); 2146 emacs_abort ();
2147 2147
2148 if (type == UNKNOWN_BT) 2148 if (type == UNKNOWN_BT)
2149 type = bidi_type_of_next_char (bidi_it); 2149 type = bidi_type_of_next_char (bidi_it);
@@ -2156,7 +2156,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2156 || (type == WEAK_BN && prev_level == level)) 2156 || (type == WEAK_BN && prev_level == level))
2157 { 2157 {
2158 if (bidi_it->next_for_neutral.type == UNKNOWN_BT) 2158 if (bidi_it->next_for_neutral.type == UNKNOWN_BT)
2159 abort (); 2159 emacs_abort ();
2160 2160
2161 /* If the cached state shows a neutral character, it was not 2161 /* If the cached state shows a neutral character, it was not
2162 resolved by bidi_resolve_neutral, so do it now. */ 2162 resolved by bidi_resolve_neutral, so do it now. */
@@ -2170,7 +2170,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2170 || type == WEAK_BN 2170 || type == WEAK_BN
2171 || type == WEAK_EN 2171 || type == WEAK_EN
2172 || type == WEAK_AN)) 2172 || type == WEAK_AN))
2173 abort (); 2173 emacs_abort ();
2174 bidi_it->type = type; 2174 bidi_it->type = type;
2175 bidi_check_type (bidi_it->type); 2175 bidi_check_type (bidi_it->type);
2176 2176
@@ -2192,7 +2192,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2192 int dpp = bidi_it->disp_prop; 2192 int dpp = bidi_it->disp_prop;
2193 2193
2194 if (bidi_it->nchars <= 0) 2194 if (bidi_it->nchars <= 0)
2195 abort (); 2195 emacs_abort ();
2196 do { 2196 do {
2197 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs, 2197 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs,
2198 fwp, &clen, &nc); 2198 fwp, &clen, &nc);
@@ -2301,8 +2301,9 @@ bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, bool end_flag)
2301 { 2301 {
2302 int new_level; 2302 int new_level;
2303 2303
2304 /* If we are at end of level, its edges must be cached. */
2304 if (end_flag) 2305 if (end_flag)
2305 abort (); /* if we are at end of level, its edges must be cached */ 2306 emacs_abort ();
2306 2307
2307 bidi_cache_iterator_state (bidi_it, 1); 2308 bidi_cache_iterator_state (bidi_it, 1);
2308 do { 2309 do {
@@ -2320,7 +2321,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2320 struct gcpro gcpro1; 2321 struct gcpro gcpro1;
2321 2322
2322 if (bidi_it->charpos < 0 || bidi_it->bytepos < 0) 2323 if (bidi_it->charpos < 0 || bidi_it->bytepos < 0)
2323 abort (); 2324 emacs_abort ();
2324 2325
2325 if (bidi_it->scan_dir == 0) 2326 if (bidi_it->scan_dir == 0)
2326 { 2327 {
@@ -2431,7 +2432,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2431 = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars, 2432 = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars,
2432 bidi_it->bytepos + bidi_it->ch_len); 2433 bidi_it->bytepos + bidi_it->ch_len);
2433 if (bidi_it->nchars <= 0) 2434 if (bidi_it->nchars <= 0)
2434 abort (); 2435 emacs_abort ();
2435 if (sep_len >= 0) 2436 if (sep_len >= 0)
2436 { 2437 {
2437 bidi_it->new_paragraph = 1; 2438 bidi_it->new_paragraph = 1;
diff --git a/src/blockinput.h b/src/blockinput.h
index dc02919cf4f..3f61b2b27b9 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -89,7 +89,7 @@ extern int pending_atimers;
89 do_pending_atimers (); \ 89 do_pending_atimers (); \
90 } \ 90 } \
91 else if (interrupt_input_blocked < 0) \ 91 else if (interrupt_input_blocked < 0) \
92 abort (); \ 92 emacs_abort (); \
93 } \ 93 } \
94 while (0) 94 while (0)
95 95
@@ -124,4 +124,3 @@ extern int pending_atimers;
124extern void reinvoke_input_signal (void); 124extern void reinvoke_input_signal (void);
125 125
126#endif /* EMACS_BLOCKINPUT_H */ 126#endif /* EMACS_BLOCKINPUT_H */
127
diff --git a/src/buffer.c b/src/buffer.c
index f4d38e50a47..3af45122a0d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "keymap.h" 44#include "keymap.h"
45#include "frame.h" 45#include "frame.h"
46 46
47struct buffer *current_buffer; /* the current buffer */ 47struct buffer *current_buffer; /* The current buffer. */
48 48
49/* First buffer in chain of all buffers (in reverse order of creation). 49/* First buffer in chain of all buffers (in reverse order of creation).
50 Threaded through ->header.next.buffer. */ 50 Threaded through ->header.next.buffer. */
@@ -60,10 +60,6 @@ struct buffer *all_buffers;
60 60
61struct buffer alignas (GCALIGNMENT) buffer_defaults; 61struct buffer alignas (GCALIGNMENT) buffer_defaults;
62 62
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 63/* This structure marks which slots in a buffer have corresponding
68 default values in buffer_defaults. 64 default values in buffer_defaults.
69 Each such slot has a nonzero value in this structure. 65 Each such slot has a nonzero value in this structure.
@@ -78,18 +74,15 @@ static Lisp_Object Vbuffer_defaults;
78 and the corresponding slot in buffer_defaults is not used. 74 and the corresponding slot in buffer_defaults is not used.
79 75
80 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is 76 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
81 zero, that is a bug */ 77 zero, that is a bug. */
82 78
83struct buffer buffer_local_flags; 79struct buffer buffer_local_flags;
84 80
85/* This structure holds the names of symbols whose values may be 81/* 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. */ 82 buffer-local. It is indexed and accessed in the same way as the above. */
87 83
88struct buffer alignas (GCALIGNMENT) buffer_local_symbols; 84struct buffer alignas (GCALIGNMENT) buffer_local_symbols;
89 85
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 86/* Return the symbol of the per-buffer variable at offset OFFSET in
94 the buffer structure. */ 87 the buffer structure. */
95 88
@@ -115,7 +108,7 @@ static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
115static void swap_out_buffer_local_variables (struct buffer *b); 108static void swap_out_buffer_local_variables (struct buffer *b);
116static void reset_buffer_local_variables (struct buffer *, bool); 109static void reset_buffer_local_variables (struct buffer *, bool);
117 110
118/* Alist of all buffer names vs the buffers. */ 111/* Alist of all buffer names vs the buffers. */
119/* This used to be a variable, but is no longer, 112/* This used to be a variable, but is no longer,
120 to prevent lossage due to user rplac'ing this alist or its elements. */ 113 to prevent lossage due to user rplac'ing this alist or its elements. */
121Lisp_Object Vbuffer_alist; 114Lisp_Object Vbuffer_alist;
@@ -134,7 +127,7 @@ static Lisp_Object Qpermanent_local_hook;
134 127
135static Lisp_Object Qprotected_field; 128static Lisp_Object Qprotected_field;
136 129
137static Lisp_Object QSFundamental; /* A string "Fundamental" */ 130static Lisp_Object QSFundamental; /* A string "Fundamental". */
138 131
139static Lisp_Object Qkill_buffer_hook; 132static Lisp_Object Qkill_buffer_hook;
140static Lisp_Object Qbuffer_list_update_hook; 133static Lisp_Object Qbuffer_list_update_hook;
@@ -595,10 +588,6 @@ even if it is dead. The return value is never nil. */)
595 bset_width_table (b, Qnil); 588 bset_width_table (b, Qnil);
596 b->prevent_redisplay_optimizations_p = 1; 589 b->prevent_redisplay_optimizations_p = 1;
597 590
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 591 /* An ordinary buffer normally doesn't need markers
603 to handle BEGV and ZV. */ 592 to handle BEGV and ZV. */
604 bset_pt_marker (b, Qnil); 593 bset_pt_marker (b, Qnil);
@@ -819,10 +808,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
819 b->width_run_cache = 0; 808 b->width_run_cache = 0;
820 bset_width_table (b, Qnil); 809 bset_width_table (b, Qnil);
821 810
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); 811 name = Fcopy_sequence (name);
827 set_string_intervals (name, NULL); 812 set_string_intervals (name, NULL);
828 bset_name (b, name); 813 bset_name (b, name);
@@ -1242,7 +1227,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1242 result = Fdefault_value (variable); 1227 result = Fdefault_value (variable);
1243 break; 1228 break;
1244 } 1229 }
1245 default: abort (); 1230 default: emacs_abort ();
1246 } 1231 }
1247 1232
1248 return result; 1233 return result;
@@ -2671,7 +2656,7 @@ current buffer is cleared. */)
2671 /* Make sure no markers were put on the chain 2656 /* Make sure no markers were put on the chain
2672 while the chain value was incorrect. */ 2657 while the chain value was incorrect. */
2673 if (BUF_MARKERS (current_buffer)) 2658 if (BUF_MARKERS (current_buffer))
2674 abort (); 2659 emacs_abort ();
2675 2660
2676 BUF_MARKERS (current_buffer) = markers; 2661 BUF_MARKERS (current_buffer) = markers;
2677 2662
@@ -3413,7 +3398,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3413 } 3398 }
3414 } 3399 }
3415 if (p != overlay_str_buf + total) 3400 if (p != overlay_str_buf + total)
3416 abort (); 3401 emacs_abort ();
3417 if (pstr) 3402 if (pstr)
3418 *pstr = overlay_str_buf; 3403 *pstr = overlay_str_buf;
3419 return total; 3404 return total;
@@ -4596,7 +4581,7 @@ buffer_slot_type_mismatch (Lisp_Object newval, int type)
4596 case_Lisp_Int: predicate = Qintegerp; break; 4581 case_Lisp_Int: predicate = Qintegerp; break;
4597 case Lisp_String: predicate = Qstringp; break; 4582 case Lisp_String: predicate = Qstringp; break;
4598 case Lisp_Symbol: predicate = Qsymbolp; break; 4583 case Lisp_Symbol: predicate = Qsymbolp; break;
4599 default: abort (); 4584 default: emacs_abort ();
4600 } 4585 }
4601 4586
4602 wrong_type_argument (predicate, newval); 4587 wrong_type_argument (predicate, newval);
@@ -5145,10 +5130,11 @@ init_buffer_once (void)
5145 buffer_local_symbols.indirections = 0; 5130 buffer_local_symbols.indirections = 0;
5146 set_buffer_intervals (&buffer_defaults, NULL); 5131 set_buffer_intervals (&buffer_defaults, NULL);
5147 set_buffer_intervals (&buffer_local_symbols, NULL); 5132 set_buffer_intervals (&buffer_local_symbols, NULL);
5133 /* This is not strictly necessary, but let's make them initialized. */
5134 bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*"));
5135 bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*"));
5148 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); 5136 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);
5149 XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
5150 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); 5137 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize);
5151 XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols);
5152 5138
5153 /* Set up the default values of various buffer slots. */ 5139 /* Set up the default values of various buffer slots. */
5154 /* Must do these before making the first buffer! */ 5140 /* Must do these before making the first buffer! */
@@ -5277,7 +5263,7 @@ init_buffer_once (void)
5277 5263
5278 /* Need more room? */ 5264 /* Need more room? */
5279 if (idx >= MAX_PER_BUFFER_VARS) 5265 if (idx >= MAX_PER_BUFFER_VARS)
5280 abort (); 5266 emacs_abort ();
5281 last_per_buffer_idx = idx; 5267 last_per_buffer_idx = idx;
5282 5268
5283 Vbuffer_alist = Qnil; 5269 Vbuffer_alist = Qnil;
@@ -5418,7 +5404,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5418 if (PER_BUFFER_IDX (offset) == 0) 5404 if (PER_BUFFER_IDX (offset) == 0)
5419 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding 5405 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
5420 slot of buffer_local_flags */ 5406 slot of buffer_local_flags */
5421 abort (); 5407 emacs_abort ();
5422} 5408}
5423 5409
5424 5410
@@ -5430,8 +5416,6 @@ syms_of_buffer (void)
5430 last_overlay_modification_hooks 5416 last_overlay_modification_hooks
5431 = Fmake_vector (make_number (10), Qnil); 5417 = Fmake_vector (make_number (10), Qnil);
5432 5418
5433 staticpro (&Vbuffer_defaults);
5434 staticpro (&Vbuffer_local_symbols);
5435 staticpro (&Qfundamental_mode); 5419 staticpro (&Qfundamental_mode);
5436 staticpro (&Qmode_class); 5420 staticpro (&Qmode_class);
5437 staticpro (&QSFundamental); 5421 staticpro (&QSFundamental);
diff --git a/src/buffer.h b/src/buffer.h
index 3acf1423816..da40a7ce3d8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1149,7 +1149,7 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
1149 We assume you know which buffer it's pointing into. */ 1149 We assume you know which buffer it's pointing into. */
1150 1150
1151#define OVERLAY_POSITION(P) \ 1151#define OVERLAY_POSITION(P) \
1152 (MARKERP (P) ? marker_position (P) : (abort (), 0)) 1152 (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0))
1153 1153
1154 1154
1155/*********************************************************************** 1155/***********************************************************************
@@ -1189,7 +1189,7 @@ extern int last_per_buffer_idx;
1189 1189
1190#define PER_BUFFER_VALUE_P(B, IDX) \ 1190#define PER_BUFFER_VALUE_P(B, IDX) \
1191 (((IDX) < 0 || IDX >= last_per_buffer_idx) \ 1191 (((IDX) < 0 || IDX >= last_per_buffer_idx) \
1192 ? (abort (), 0) \ 1192 ? (emacs_abort (), 0) \
1193 : ((B)->local_flags[IDX] != 0)) 1193 : ((B)->local_flags[IDX] != 0))
1194 1194
1195/* Set whether per-buffer variable with index IDX has a buffer-local 1195/* Set whether per-buffer variable with index IDX has a buffer-local
@@ -1198,7 +1198,7 @@ extern int last_per_buffer_idx;
1198#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ 1198#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \
1199 do { \ 1199 do { \
1200 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ 1200 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \
1201 abort (); \ 1201 emacs_abort (); \
1202 (B)->local_flags[IDX] = (VAL); \ 1202 (B)->local_flags[IDX] = (VAL); \
1203 } while (0) 1203 } while (0)
1204 1204
diff --git a/src/bytecode.c b/src/bytecode.c
index 40729cbd453..97730636d0e 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -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
@@ -508,7 +508,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
508 if (FRAME_X_P (f) 508 if (FRAME_X_P (f)
509 && FRAME_FONT (f)->direction != 0 509 && FRAME_FONT (f)->direction != 0
510 && FRAME_FONT (f)->direction != 1) 510 && FRAME_FONT (f)->direction != 1)
511 abort (); 511 emacs_abort ();
512 } 512 }
513#endif 513#endif
514 514
@@ -600,9 +600,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
600 { 600 {
601#ifdef BYTE_CODE_SAFE 601#ifdef BYTE_CODE_SAFE
602 if (top > stacke) 602 if (top > stacke)
603 abort (); 603 emacs_abort ();
604 else if (top < stack.bottom - 1) 604 else if (top < stack.bottom - 1)
605 abort (); 605 emacs_abort ();
606#endif 606#endif
607 607
608#ifdef BYTE_CODE_METER 608#ifdef BYTE_CODE_METER
@@ -1875,7 +1875,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 1875 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1876 for that instead. */ 1876 for that instead. */
1877 /* CASE (Bstack_ref): */ 1877 /* CASE (Bstack_ref): */
1878 abort (); 1878 emacs_abort ();
1879 1879
1880 /* Handy byte-codes for lexical binding. */ 1880 /* Handy byte-codes for lexical binding. */
1881 CASE (Bstack_ref1): 1881 CASE (Bstack_ref1):
@@ -1928,11 +1928,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1928#ifdef BYTE_CODE_SAFE 1928#ifdef BYTE_CODE_SAFE
1929 if (op < Bconstant) 1929 if (op < Bconstant)
1930 { 1930 {
1931 abort (); 1931 emacs_abort ();
1932 } 1932 }
1933 if ((op -= Bconstant) >= const_length) 1933 if ((op -= Bconstant) >= const_length)
1934 { 1934 {
1935 abort (); 1935 emacs_abort ();
1936 } 1936 }
1937 PUSH (vectorp[op]); 1937 PUSH (vectorp[op]);
1938#else 1938#else
@@ -1951,7 +1951,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1951#ifdef BYTE_CODE_SAFE 1951#ifdef BYTE_CODE_SAFE
1952 error ("binding stack not balanced (serious byte compiler bug)"); 1952 error ("binding stack not balanced (serious byte compiler bug)");
1953#else 1953#else
1954 abort (); 1954 emacs_abort ();
1955#endif 1955#endif
1956 1956
1957 return result; 1957 return result;
diff --git a/src/callproc.c b/src/callproc.c
index 2e9a8950700..a92959a1559 100644
--- a/src/callproc.c
+++ b/src/callproc.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 <signal.h>
23#include <errno.h> 22#include <errno.h>
24#include <stdio.h> 23#include <stdio.h>
25#include <setjmp.h> 24#include <setjmp.h>
@@ -506,9 +505,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
506 505
507 if (fd_output >= 0) 506 if (fd_output >= 0)
508 fd1 = fd_output; 507 fd1 = fd_output;
509#if 0 /* Some systems don't have sigblock. */
510 mask = sigblock (sigmask (SIGCHLD));
511#endif
512 508
513 /* Record that we're about to create a synchronous process. */ 509 /* Record that we're about to create a synchronous process. */
514 synch_process_alive = 1; 510 synch_process_alive = 1;
diff --git a/src/character.c b/src/character.c
index cfaaf8eeca9..37963d1878c 100644
--- a/src/character.c
+++ b/src/character.c
@@ -541,7 +541,7 @@ multibyte_chars_in_text (const unsigned char *ptr, ptrdiff_t nbytes)
541 int len = MULTIBYTE_LENGTH (ptr, endp); 541 int len = MULTIBYTE_LENGTH (ptr, endp);
542 542
543 if (len == 0) 543 if (len == 0)
544 abort (); 544 emacs_abort ();
545 ptr += len; 545 ptr += len;
546 chars++; 546 chars++;
547 } 547 }
diff --git a/src/charset.c b/src/charset.c
index 0673790e91c..972a0598059 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -636,7 +636,7 @@ load_charset (struct charset *charset, int control_flag)
636 else 636 else
637 { 637 {
638 if (! CHARSET_UNIFIED_P (charset)) 638 if (! CHARSET_UNIFIED_P (charset))
639 abort (); 639 emacs_abort ();
640 map = CHARSET_UNIFY_MAP (charset); 640 map = CHARSET_UNIFY_MAP (charset);
641 } 641 }
642 if (STRINGP (map)) 642 if (STRINGP (map))
@@ -2025,10 +2025,10 @@ CH in the charset. */)
2025 c = XFASTINT (ch); 2025 c = XFASTINT (ch);
2026 charset = CHAR_CHARSET (c); 2026 charset = CHAR_CHARSET (c);
2027 if (! charset) 2027 if (! charset)
2028 abort (); 2028 emacs_abort ();
2029 code = ENCODE_CHAR (charset, c); 2029 code = ENCODE_CHAR (charset, c);
2030 if (code == CHARSET_INVALID_CODE (charset)) 2030 if (code == CHARSET_INVALID_CODE (charset))
2031 abort (); 2031 emacs_abort ();
2032 dimension = CHARSET_DIMENSION (charset); 2032 dimension = CHARSET_DIMENSION (charset);
2033 for (val = Qnil; dimension > 0; dimension--) 2033 for (val = Qnil; dimension > 0; dimension--)
2034 { 2034 {
diff --git a/src/cm.c b/src/cm.c
index 1922cd8140a..4b17b92eebc 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -119,7 +119,7 @@ cmcheckmagic (struct tty_display_info *tty)
119 if (curX (tty) == FrameCols (tty)) 119 if (curX (tty) == FrameCols (tty))
120 { 120 {
121 if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1) 121 if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
122 abort (); 122 emacs_abort ();
123 if (tty->termscript) 123 if (tty->termscript)
124 putc ('\r', tty->termscript); 124 putc ('\r', tty->termscript);
125 putc ('\r', tty->output); 125 putc ('\r', tty->output);
diff --git a/src/coding.c b/src/coding.c
index 02e7b34695e..94a2d9fea80 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -2051,7 +2051,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2051 break; 2051 break;
2052 2052
2053 default: 2053 default:
2054 abort (); 2054 emacs_abort ();
2055 } 2055 }
2056 CODING_DECODE_CHAR (coding, src, src_base, src_end, 2056 CODING_DECODE_CHAR (coding, src, src_base, src_end,
2057 CHARSET_FROM_ID (charset_ID), code, c); 2057 CHARSET_FROM_ID (charset_ID), code, c);
@@ -2345,7 +2345,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
2345 int i; 2345 int i;
2346 2346
2347 if (charbuf_end - charbuf < cmp_status->length) 2347 if (charbuf_end - charbuf < cmp_status->length)
2348 abort (); 2348 emacs_abort ();
2349 for (i = 0; i < cmp_status->length; i++) 2349 for (i = 0; i < cmp_status->length; i++)
2350 *charbuf++ = cmp_status->carryover[i]; 2350 *charbuf++ = cmp_status->carryover[i];
2351 coding->annotated = 1; 2351 coding->annotated = 1;
@@ -2619,7 +2619,7 @@ encode_coding_emacs_mule (struct coding_system *coding)
2619 preferred_charset_id = -1; 2619 preferred_charset_id = -1;
2620 break; 2620 break;
2621 default: 2621 default:
2622 abort (); 2622 emacs_abort ();
2623 } 2623 }
2624 charbuf += -c - 1; 2624 charbuf += -c - 1;
2625 continue; 2625 continue;
@@ -3482,7 +3482,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3482 if (cmp_status->state != COMPOSING_NO) 3482 if (cmp_status->state != COMPOSING_NO)
3483 { 3483 {
3484 if (charbuf_end - charbuf < cmp_status->length) 3484 if (charbuf_end - charbuf < cmp_status->length)
3485 abort (); 3485 emacs_abort ();
3486 for (i = 0; i < cmp_status->length; i++) 3486 for (i = 0; i < cmp_status->length; i++)
3487 *charbuf++ = cmp_status->carryover[i]; 3487 *charbuf++ = cmp_status->carryover[i];
3488 coding->annotated = 1; 3488 coding->annotated = 1;
@@ -3864,7 +3864,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3864 break; 3864 break;
3865 3865
3866 default: 3866 default:
3867 abort (); 3867 emacs_abort ();
3868 } 3868 }
3869 3869
3870 if (cmp_status->state == COMPOSING_NO 3870 if (cmp_status->state == COMPOSING_NO
@@ -4419,7 +4419,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
4419 preferred_charset_id = -1; 4419 preferred_charset_id = -1;
4420 break; 4420 break;
4421 default: 4421 default:
4422 abort (); 4422 emacs_abort ();
4423 } 4423 }
4424 charbuf += -c - 1; 4424 charbuf += -c - 1;
4425 continue; 4425 continue;
@@ -4933,7 +4933,7 @@ encode_coding_sjis (struct coding_system *coding)
4933 } 4933 }
4934 } 4934 }
4935 if (code == CHARSET_INVALID_CODE (charset)) 4935 if (code == CHARSET_INVALID_CODE (charset))
4936 abort (); 4936 emacs_abort ();
4937 if (charset == charset_kanji) 4937 if (charset == charset_kanji)
4938 { 4938 {
4939 int c1, c2; 4939 int c1, c2;
@@ -5023,7 +5023,7 @@ encode_coding_big5 (struct coding_system *coding)
5023 } 5023 }
5024 } 5024 }
5025 if (code == CHARSET_INVALID_CODE (charset)) 5025 if (code == CHARSET_INVALID_CODE (charset))
5026 abort (); 5026 emacs_abort ();
5027 if (charset == charset_big5) 5027 if (charset == charset_big5)
5028 { 5028 {
5029 int c1, c2; 5029 int c1, c2;
@@ -7190,7 +7190,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7190 *buf++ = XINT (XCAR (components)); 7190 *buf++ = XINT (XCAR (components));
7191 } 7191 }
7192 else 7192 else
7193 abort (); 7193 emacs_abort ();
7194 *head -= len; 7194 *head -= len;
7195 } 7195 }
7196 } 7196 }
@@ -9428,7 +9428,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9428 && changed[coding_priorities[j]]) 9428 && changed[coding_priorities[j]])
9429 j++; 9429 j++;
9430 if (j == coding_category_max) 9430 if (j == coding_category_max)
9431 abort (); 9431 emacs_abort ();
9432 priorities[i] = coding_priorities[j]; 9432 priorities[i] = coding_priorities[j];
9433 } 9433 }
9434 9434
diff --git a/src/conf_post.h b/src/conf_post.h
index f90ef90fb83..1bf40af260b 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
@@ -167,7 +162,7 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
167#ifdef emacs /* Don't do this for lib-src. */ 162#ifdef emacs /* Don't do this for lib-src. */
168/* Tell regex.c to use a type compatible with Emacs. */ 163/* Tell regex.c to use a type compatible with Emacs. */
169#define RE_TRANSLATE_TYPE Lisp_Object 164#define RE_TRANSLATE_TYPE Lisp_Object
170#define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C) 165#define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
171#ifdef make_number 166#ifdef make_number
172/* If make_number is a macro, use it. */ 167/* If make_number is a macro, use it. */
173#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0))) 168#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
@@ -178,9 +173,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
178#endif 173#endif
179 174
180#include <string.h> 175#include <string.h>
181/* If you think about removing the line below, note that the
182 MS-Windows build relies on it for declaration of 'environ' needed
183 by a few source files. */
184#include <stdlib.h> 176#include <stdlib.h>
185 177
186#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ 178#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
diff --git a/src/data.c b/src/data.c
index d8b7f42ea3f..a4cca0a3ee5 100644
--- a/src/data.c
+++ b/src/data.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 <signal.h>
23#include <stdio.h> 22#include <stdio.h>
24#include <setjmp.h> 23#include <setjmp.h>
25 24
@@ -37,17 +36,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include "keymap.h" 36#include "keymap.h"
38 37
39#include <float.h> 38#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 \ 39#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
43 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 40 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
44#define IEEE_FLOATING_POINT 1 41#define IEEE_FLOATING_POINT 1
45#else 42#else
46#define IEEE_FLOATING_POINT 0 43#define IEEE_FLOATING_POINT 0
47#endif 44#endif
48#endif
49
50#include <math.h>
51 45
52Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; 46Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
53static Lisp_Object Qsubr; 47static Lisp_Object Qsubr;
@@ -108,7 +102,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 102 to try and do that by checking the tagbits, but nowadays all
109 tagbits are potentially valid. */ 103 tagbits are potentially valid. */
110 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit) 104 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
111 * abort (); */ 105 * emacs_abort (); */
112 106
113 xsignal2 (Qwrong_type_argument, predicate, value); 107 xsignal2 (Qwrong_type_argument, predicate, value);
114} 108}
@@ -182,7 +176,7 @@ for example, (type-of 1) returns `integer'. */)
182 case Lisp_Misc_Float: 176 case Lisp_Misc_Float:
183 return Qfloat; 177 return Qfloat;
184 } 178 }
185 abort (); 179 emacs_abort ();
186 180
187 case Lisp_Vectorlike: 181 case Lisp_Vectorlike:
188 if (WINDOW_CONFIGURATIONP (object)) 182 if (WINDOW_CONFIGURATIONP (object))
@@ -217,7 +211,7 @@ for example, (type-of 1) returns `integer'. */)
217 return Qfloat; 211 return Qfloat;
218 212
219 default: 213 default:
220 abort (); 214 emacs_abort ();
221 } 215 }
222} 216}
223 217
@@ -551,7 +545,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
551 /* In set_internal, we un-forward vars when their value is 545 /* In set_internal, we un-forward vars when their value is
552 set to Qunbound. */ 546 set to Qunbound. */
553 return Qt; 547 return Qt;
554 default: abort (); 548 default: emacs_abort ();
555 } 549 }
556 550
557 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 551 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -864,7 +858,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
864 don't think anything will break. --lorentey */ 858 don't think anything will break. --lorentey */
865 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset 859 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
866 + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 860 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
867 default: abort (); 861 default: emacs_abort ();
868 } 862 }
869} 863}
870 864
@@ -950,7 +944,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
950 break; 944 break;
951 945
952 default: 946 default:
953 abort (); /* goto def; */ 947 emacs_abort (); /* goto def; */
954 } 948 }
955} 949}
956 950
@@ -1055,7 +1049,7 @@ find_symbol_value (Lisp_Object symbol)
1055 /* FALLTHROUGH */ 1049 /* FALLTHROUGH */
1056 case SYMBOL_FORWARDED: 1050 case SYMBOL_FORWARDED:
1057 return do_symval_forwarding (SYMBOL_FWD (sym)); 1051 return do_symval_forwarding (SYMBOL_FWD (sym));
1058 default: abort (); 1052 default: emacs_abort ();
1059 } 1053 }
1060} 1054}
1061 1055
@@ -1265,7 +1259,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1265 store_symval_forwarding (/* sym, */ innercontents, newval, buf); 1259 store_symval_forwarding (/* sym, */ innercontents, newval, buf);
1266 break; 1260 break;
1267 } 1261 }
1268 default: abort (); 1262 default: emacs_abort ();
1269 } 1263 }
1270 return; 1264 return;
1271} 1265}
@@ -1316,7 +1310,7 @@ default_value (Lisp_Object symbol)
1316 /* For other variables, get the current value. */ 1310 /* For other variables, get the current value. */
1317 return do_symval_forwarding (valcontents); 1311 return do_symval_forwarding (valcontents);
1318 } 1312 }
1319 default: abort (); 1313 default: emacs_abort ();
1320 } 1314 }
1321} 1315}
1322 1316
@@ -1414,7 +1408,7 @@ for this variable. */)
1414 else 1408 else
1415 return Fset (symbol, value); 1409 return Fset (symbol, value);
1416 } 1410 }
1417 default: abort (); 1411 default: emacs_abort ();
1418 } 1412 }
1419} 1413}
1420 1414
@@ -1538,7 +1532,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1538 else if (BUFFER_OBJFWDP (valcontents.fwd)) 1532 else if (BUFFER_OBJFWDP (valcontents.fwd))
1539 return variable; 1533 return variable;
1540 break; 1534 break;
1541 default: abort (); 1535 default: emacs_abort ();
1542 } 1536 }
1543 1537
1544 if (sym->constant) 1538 if (sym->constant)
@@ -1611,7 +1605,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1611 error ("Symbol %s may not be buffer-local", 1605 error ("Symbol %s may not be buffer-local",
1612 SDATA (SYMBOL_NAME (variable))); 1606 SDATA (SYMBOL_NAME (variable)));
1613 break; 1607 break;
1614 default: abort (); 1608 default: emacs_abort ();
1615 } 1609 }
1616 1610
1617 if (sym->constant) 1611 if (sym->constant)
@@ -1718,7 +1712,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1718 if (blv->frame_local) 1712 if (blv->frame_local)
1719 return variable; 1713 return variable;
1720 break; 1714 break;
1721 default: abort (); 1715 default: emacs_abort ();
1722 } 1716 }
1723 1717
1724 /* Get rid of this buffer's alist element, if any. */ 1718 /* Get rid of this buffer's alist element, if any. */
@@ -1800,7 +1794,7 @@ frame-local bindings). */)
1800 error ("Symbol %s may not be frame-local", 1794 error ("Symbol %s may not be frame-local",
1801 SDATA (SYMBOL_NAME (variable))); 1795 SDATA (SYMBOL_NAME (variable)));
1802 break; 1796 break;
1803 default: abort (); 1797 default: emacs_abort ();
1804 } 1798 }
1805 1799
1806 if (sym->constant) 1800 if (sym->constant)
@@ -1877,18 +1871,18 @@ BUFFER defaults to the current buffer. */)
1877 } 1871 }
1878 return Qnil; 1872 return Qnil;
1879 } 1873 }
1880 default: abort (); 1874 default: emacs_abort ();
1881 } 1875 }
1882} 1876}
1883 1877
1884DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1878DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
1885 1, 2, 0, 1879 1, 2, 0,
1886 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there. 1880 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'), 1881BUFFER defaults to the current buffer.
1888while it does not have a `let'-style binding that was made in BUFFER, 1882
1889will produce a buffer local binding. See Info node 1883More precisely, return non-nil if either VARIABLE already has a local
1890`(elisp)Creating Buffer-Local'. 1884value in BUFFER, or if VARIABLE is automatically buffer-local (see
1891BUFFER defaults to the current buffer. */) 1885`make-variable-buffer-local'). */)
1892 (register Lisp_Object variable, Lisp_Object buffer) 1886 (register Lisp_Object variable, Lisp_Object buffer)
1893{ 1887{
1894 struct Lisp_Symbol *sym; 1888 struct Lisp_Symbol *sym;
@@ -1912,7 +1906,7 @@ BUFFER defaults to the current buffer. */)
1912 case SYMBOL_FORWARDED: 1906 case SYMBOL_FORWARDED:
1913 /* All BUFFER_OBJFWD slots become local if they are set. */ 1907 /* All BUFFER_OBJFWD slots become local if they are set. */
1914 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); 1908 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil);
1915 default: abort (); 1909 default: emacs_abort ();
1916 } 1910 }
1917} 1911}
1918 1912
@@ -1956,7 +1950,7 @@ If the current binding is global (the default), the value is nil. */)
1956 return SYMBOL_BLV (sym)->where; 1950 return SYMBOL_BLV (sym)->where;
1957 else 1951 else
1958 return Qnil; 1952 return Qnil;
1959 default: abort (); 1953 default: emacs_abort ();
1960 } 1954 }
1961} 1955}
1962 1956
@@ -2272,7 +2266,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2272 return Qnil; 2266 return Qnil;
2273 2267
2274 default: 2268 default:
2275 abort (); 2269 emacs_abort ();
2276 } 2270 }
2277} 2271}
2278 2272
@@ -2738,28 +2732,6 @@ Both must be integers or markers. */)
2738 return val; 2732 return val;
2739} 2733}
2740 2734
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, 2735DEFUN ("mod", Fmod, Smod, 2, 2, 0,
2764 doc: /* Return X modulo Y. 2736 doc: /* Return X modulo Y.
2765The result falls between zero (inclusive) and Y (exclusive). 2737The result falls between zero (inclusive) and Y (exclusive).
@@ -3207,21 +3179,23 @@ syms_of_data (void)
3207 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; 3179 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1;
3208} 3180}
3209 3181
3210#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 3182static _Noreturn void
3211_Noreturn 3183handle_arith_signal (int sig)
3212#endif
3213static void
3214arith_error (int signo)
3215{ 3184{
3216 sigsetmask (SIGEMPTYMASK); 3185 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3217
3218 SIGNAL_THREAD_CHECK (signo);
3219 xsignal0 (Qarith_error); 3186 xsignal0 (Qarith_error);
3220} 3187}
3221 3188
3189static void
3190deliver_arith_signal (int sig)
3191{
3192 handle_on_main_thread (sig, handle_arith_signal);
3193}
3194
3222void 3195void
3223init_data (void) 3196init_data (void)
3224{ 3197{
3198 struct sigaction action;
3225 /* Don't do this if just dumping out. 3199 /* Don't do this if just dumping out.
3226 We don't want to call `signal' in this case 3200 We don't want to call `signal' in this case
3227 so that we don't have trouble with dumping 3201 so that we don't have trouble with dumping
@@ -3230,5 +3204,6 @@ init_data (void)
3230 if (!initialized) 3204 if (!initialized)
3231 return; 3205 return;
3232#endif /* CANNOT_DUMP */ 3206#endif /* CANNOT_DUMP */
3233 signal (SIGFPE, arith_error); 3207 emacs_sigaction_init (&action, deliver_arith_signal);
3208 sigaction (SIGFPE, &action, 0);
3234} 3209}
diff --git a/src/dired.c b/src/dired.c
index fa293258107..9af5f76821b 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -275,7 +275,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
275 275
276 /* Some bug somewhere. */ 276 /* Some bug somewhere. */
277 if (nchars > nbytes) 277 if (nchars > nbytes)
278 abort (); 278 emacs_abort ();
279 279
280 STRING_SET_CHARS (fullname, nchars); 280 STRING_SET_CHARS (fullname, nchars);
281 if (nchars == nbytes) 281 if (nchars == nbytes)
diff --git a/src/dispnew.c b/src/dispnew.c
index 2bd6d7f2a6f..bc9141a575d 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#define DISPEXTERN_INLINE EXTERN_INLINE 21#define DISPEXTERN_INLINE EXTERN_INLINE
22 22
23#include <signal.h>
24#include <stdio.h> 23#include <stdio.h>
25#include <setjmp.h> 24#include <setjmp.h>
26#include <unistd.h> 25#include <unistd.h>
@@ -299,7 +298,7 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history,
299void 298void
300__executable_start (void) 299__executable_start (void)
301{ 300{
302 abort (); 301 emacs_abort ();
303} 302}
304#endif 303#endif
305 304
@@ -349,7 +348,7 @@ free_glyph_matrix (struct glyph_matrix *matrix)
349 /* Detect the case that more matrices are freed than were 348 /* Detect the case that more matrices are freed than were
350 allocated. */ 349 allocated. */
351 if (--glyph_matrix_count < 0) 350 if (--glyph_matrix_count < 0)
352 abort (); 351 emacs_abort ();
353 352
354 /* Free glyph memory if MATRIX owns it. */ 353 /* Free glyph memory if MATRIX owns it. */
355 if (matrix->pool == NULL) 354 if (matrix->pool == NULL)
@@ -2341,9 +2340,9 @@ check_glyph_memory (void)
2341 2340
2342 /* Check that nothing is left allocated. */ 2341 /* Check that nothing is left allocated. */
2343 if (glyph_matrix_count) 2342 if (glyph_matrix_count)
2344 abort (); 2343 emacs_abort ();
2345 if (glyph_pool_count) 2344 if (glyph_pool_count)
2346 abort (); 2345 emacs_abort ();
2347} 2346}
2348 2347
2349 2348
@@ -3026,7 +3025,7 @@ check_matrix_pointers (struct glyph_matrix *window_matrix,
3026 { 3025 {
3027 if (!glyph_row_slice_p (window_matrix->rows + i, 3026 if (!glyph_row_slice_p (window_matrix->rows + i,
3028 frame_matrix->rows + j)) 3027 frame_matrix->rows + j))
3029 abort (); 3028 emacs_abort ();
3030 ++i, ++j; 3029 ++i, ++j;
3031 } 3030 }
3032} 3031}
@@ -3455,7 +3454,7 @@ check_current_matrix_flags (struct window *w)
3455 if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb) 3454 if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb)
3456 last_seen_p = 1; 3455 last_seen_p = 1;
3457 else if (last_seen_p && row->enabled_p) 3456 else if (last_seen_p && row->enabled_p)
3458 abort (); 3457 emacs_abort ();
3459 } 3458 }
3460} 3459}
3461 3460
@@ -3957,6 +3956,11 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3957 { 3956 {
3958 changed_p = 1; 3957 changed_p = 1;
3959 update_marginal_area (w, LEFT_MARGIN_AREA, vpos); 3958 update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
3959 /* Setting this flag will ensure the vertical border, if
3960 any, between this window and the one on its left will be
3961 redrawn. This is necessary because updating the left
3962 margin area can potentially draw over the border. */
3963 current_row->redraw_fringe_bitmaps_p = 1;
3960 } 3964 }
3961 3965
3962 /* Update the display of the text area. */ 3966 /* Update the display of the text area. */
@@ -4820,7 +4824,7 @@ scrolling (struct frame *frame)
4820 struct glyph_matrix *desired_matrix = frame->desired_matrix; 4824 struct glyph_matrix *desired_matrix = frame->desired_matrix;
4821 4825
4822 if (!current_matrix) 4826 if (!current_matrix)
4823 abort (); 4827 emacs_abort ();
4824 4828
4825 /* Compute hash codes of all the lines. Also calculate number of 4829 /* Compute hash codes of all the lines. Also calculate number of
4826 changed lines, number of unchanged lines at the beginning, and 4830 changed lines, number of unchanged lines at the beginning, and
@@ -5488,7 +5492,7 @@ marginal_area_string (struct window *w, enum window_part part,
5488 else if (part == ON_RIGHT_MARGIN) 5492 else if (part == ON_RIGHT_MARGIN)
5489 area = RIGHT_MARGIN_AREA; 5493 area = RIGHT_MARGIN_AREA;
5490 else 5494 else
5491 abort (); 5495 emacs_abort ();
5492 5496
5493 for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) 5497 for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row)
5494 if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) 5498 if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row))
@@ -5563,17 +5567,17 @@ marginal_area_string (struct window *w, enum window_part part,
5563 5567
5564#ifdef SIGWINCH 5568#ifdef SIGWINCH
5565 5569
5570static void deliver_window_change_signal (int);
5571
5566static void 5572static void
5567window_change_signal (int signalnum) /* If we don't have an argument, */ 5573handle_window_change_signal (int sig)
5568 /* some compilers complain in signal calls. */
5569{ 5574{
5570 int width, height; 5575 int width, height;
5571 int old_errno = errno;
5572
5573 struct tty_display_info *tty; 5576 struct tty_display_info *tty;
5574 5577
5575 signal (SIGWINCH, window_change_signal); 5578 struct sigaction action;
5576 SIGNAL_THREAD_CHECK (signalnum); 5579 emacs_sigaction_init (&action, deliver_window_change_signal);
5580 sigaction (SIGWINCH, &action, 0);
5577 5581
5578 /* The frame size change obviously applies to a single 5582 /* The frame size change obviously applies to a single
5579 termcap-controlled terminal, but we can't decide which. 5583 termcap-controlled terminal, but we can't decide which.
@@ -5602,8 +5606,12 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
5602 change_frame_size (XFRAME (frame), height, width, 0, 1, 0); 5606 change_frame_size (XFRAME (frame), height, width, 0, 1, 0);
5603 } 5607 }
5604 } 5608 }
5609}
5605 5610
5606 errno = old_errno; 5611static void
5612deliver_window_change_signal (int sig)
5613{
5614 handle_on_main_thread (sig, handle_window_change_signal);
5607} 5615}
5608#endif /* SIGWINCH */ 5616#endif /* SIGWINCH */
5609 5617
@@ -5615,7 +5623,7 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
5615void 5623void
5616do_pending_window_change (bool safe) 5624do_pending_window_change (bool safe)
5617{ 5625{
5618 /* If window_change_signal should have run before, run it now. */ 5626 /* If window change signal handler should have run before, run it now. */
5619 if (redisplaying_p && !safe) 5627 if (redisplaying_p && !safe)
5620 return; 5628 return;
5621 5629
@@ -6184,7 +6192,11 @@ init_display (void)
6184#ifndef CANNOT_DUMP 6192#ifndef CANNOT_DUMP
6185 if (initialized) 6193 if (initialized)
6186#endif /* CANNOT_DUMP */ 6194#endif /* CANNOT_DUMP */
6187 signal (SIGWINCH, window_change_signal); 6195 {
6196 struct sigaction action;
6197 emacs_sigaction_init (&action, deliver_window_change_signal);
6198 sigaction (SIGWINCH, &action, 0);
6199 }
6188#endif /* SIGWINCH */ 6200#endif /* SIGWINCH */
6189 6201
6190 /* If running as a daemon, no need to initialize any frames/terminal. */ 6202 /* If running as a daemon, no need to initialize any frames/terminal. */
@@ -6288,7 +6300,7 @@ init_display (void)
6288 6300
6289 /* Convert the initial frame to use the new display. */ 6301 /* Convert the initial frame to use the new display. */
6290 if (f->output_method != output_initial) 6302 if (f->output_method != output_initial)
6291 abort (); 6303 emacs_abort ();
6292 f->output_method = t->type; 6304 f->output_method = t->type;
6293 f->terminal = t; 6305 f->terminal = t;
6294 6306
diff --git a/src/doc.c b/src/doc.c
index c21935577f2..02a5b4b8143 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -848,10 +848,9 @@ Otherwise, return a new string, without any text properties. */)
848 struct buffer *oldbuf; 848 struct buffer *oldbuf;
849 ptrdiff_t start_idx; 849 ptrdiff_t start_idx;
850 /* This is for computing the SHADOWS arg for describe_map_tree. */ 850 /* This is for computing the SHADOWS arg for describe_map_tree. */
851 Lisp_Object active_maps; 851 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
852 Lisp_Object earlier_maps; 852 Lisp_Object earlier_maps;
853 853
854 active_maps = Fcurrent_active_maps (Qnil, Qnil);
855 changed = 1; 854 changed = 1;
856 strp += 2; /* skip \{ or \< */ 855 strp += 2; /* skip \{ or \< */
857 start = strp; 856 start = strp;
diff --git a/src/doprnt.c b/src/doprnt.c
index b36e946005d..3b7391f07d4 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -114,10 +114,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
114 another macro. */ 114 another macro. */
115#include "character.h" 115#include "character.h"
116 116
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, 117/* Generate output from a format-spec FORMAT,
122 terminated at position FORMAT_END. 118 terminated at position FORMAT_END.
123 (*FORMAT_END is not part of the format, but must exist and be readable.) 119 (*FORMAT_END is not part of the format, but must exist and be readable.)
diff --git a/src/editfns.c b/src/editfns.c
index a14e043c1bf..65baaf4e3f8 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2783,8 +2783,8 @@ determines whether case is significant or ignored. */)
2783 2783
2784 if (!NILP (trt)) 2784 if (!NILP (trt))
2785 { 2785 {
2786 c1 = CHAR_TABLE_TRANSLATE (trt, c1); 2786 c1 = char_table_translate (trt, c1);
2787 c2 = CHAR_TABLE_TRANSLATE (trt, c2); 2787 c2 = char_table_translate (trt, c2);
2788 } 2788 }
2789 if (c1 < c2) 2789 if (c1 < c2)
2790 return make_number (- 1 - chars); 2790 return make_number (- 1 - chars);
@@ -4263,7 +4263,7 @@ usage: (format STRING &rest OBJECTS) */)
4263 } 4263 }
4264 4264
4265 if (bufsize < p - buf) 4265 if (bufsize < p - buf)
4266 abort (); 4266 emacs_abort ();
4267 4267
4268 if (maybe_combine_byte) 4268 if (maybe_combine_byte)
4269 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf); 4269 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf);
@@ -4603,7 +4603,7 @@ Transposing beyond buffer boundaries is an error. */)
4603 len1_byte, end2, start2_byte + len2_byte) 4603 len1_byte, end2, start2_byte + len2_byte)
4604 || count_combining_after (BYTE_POS_ADDR (start1_byte), 4604 || count_combining_after (BYTE_POS_ADDR (start1_byte),
4605 len1_byte, end2, start2_byte + len2_byte)) 4605 len1_byte, end2, start2_byte + len2_byte))
4606 abort (); 4606 emacs_abort ();
4607 } 4607 }
4608 else 4608 else
4609 { 4609 {
@@ -4615,7 +4615,7 @@ Transposing beyond buffer boundaries is an error. */)
4615 len2_byte, end1, start1_byte + len1_byte) 4615 len2_byte, end1, start1_byte + len1_byte)
4616 || count_combining_after (BYTE_POS_ADDR (start1_byte), 4616 || count_combining_after (BYTE_POS_ADDR (start1_byte),
4617 len1_byte, end2, start2_byte + len2_byte)) 4617 len1_byte, end2, start2_byte + len2_byte))
4618 abort (); 4618 emacs_abort ();
4619 } 4619 }
4620#endif 4620#endif
4621 4621
diff --git a/src/emacs.c b/src/emacs.c
index b454e2423fb..d0e2f1e021d 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -20,7 +20,6 @@ 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
@@ -278,14 +277,6 @@ static int fatal_error_code;
278/* True if handling a fatal error already. */ 277/* True if handling a fatal error already. */
279bool fatal_error_in_progress; 278bool fatal_error_in_progress;
280 279
281#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
282/* When compiled with GTK and running under Gnome,
283 multiple threads may be created. Keep track of our main
284 thread to make sure signals are delivered to it (see syssignal.h). */
285
286pthread_t main_thread;
287#endif
288
289#ifdef HAVE_NS 280#ifdef HAVE_NS
290/* NS autrelease pool, for memory management. */ 281/* NS autrelease pool, for memory management. */
291static void *ns_pool; 282static void *ns_pool;
@@ -294,13 +285,23 @@ static void *ns_pool;
294 285
295 286
296/* Handle bus errors, invalid instruction, etc. */ 287/* Handle bus errors, invalid instruction, etc. */
297#ifndef FLOAT_CATCH_SIGILL 288static void
298static 289handle_fatal_signal (int sig)
299#endif 290{
300void 291 fatal_error_backtrace (sig, 10);
301fatal_error_signal (int sig) 292}
293
294static void
295deliver_fatal_signal (int sig)
296{
297 handle_on_main_thread (sig, handle_fatal_signal);
298}
299
300/* Report a fatal error due to signal SIG, output a backtrace of at
301 most BACKTRACE_LIMIT lines, and exit. */
302_Noreturn void
303fatal_error_backtrace (int sig, int backtrace_limit)
302{ 304{
303 SIGNAL_THREAD_CHECK (sig);
304 fatal_error_code = sig; 305 fatal_error_code = sig;
305 signal (sig, SIG_DFL); 306 signal (sig, SIG_DFL);
306 307
@@ -315,6 +316,7 @@ fatal_error_signal (int sig)
315 Fkill_emacs (make_number (sig)); 316 Fkill_emacs (make_number (sig));
316 317
317 shut_down_emacs (sig, Qnil); 318 shut_down_emacs (sig, Qnil);
319 emacs_backtrace (backtrace_limit);
318 } 320 }
319 321
320 /* Signal the same code; this time it will really be fatal. 322 /* Signal the same code; this time it will really be fatal.
@@ -322,43 +324,44 @@ fatal_error_signal (int sig)
322 going to send is probably blocked, so we have to unblock it if we 324 going to send is probably blocked, so we have to unblock it if we
323 want to really receive it. */ 325 want to really receive it. */
324#ifndef MSDOS 326#ifndef MSDOS
325 sigunblock (sigmask (fatal_error_code)); 327 {
328 sigset_t unblocked;
329 sigemptyset (&unblocked);
330 sigaddset (&unblocked, fatal_error_code);
331 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
332 }
326#endif 333#endif
327 334
328 kill (getpid (), fatal_error_code); 335 kill (getpid (), fatal_error_code);
336
337 /* This shouldn't be executed, but it prevents a warning. */
338 exit (1);
329} 339}
330 340
331#ifdef SIGDANGER 341#ifdef SIGDANGER
332 342
333/* Handler for SIGDANGER. */ 343/* Handler for SIGDANGER. */
334void 344static void deliver_danger_signal (int);
335memory_warning_signal (int sig) 345
346static void
347handle_danger_signal (int sig)
336{ 348{
337 signal (sig, memory_warning_signal); 349 struct sigaction action;
338 SIGNAL_THREAD_CHECK (sig); 350 emacs_sigaction_init (&action, deliver_danger_signal);
351 sigaction (sig, &action, 0);
339 352
340 malloc_warning ("Operating system warns that virtual memory is running low.\n"); 353 malloc_warning ("Operating system warns that virtual memory is running low.\n");
341 354
342 /* It might be unsafe to call do_auto_save now. */ 355 /* It might be unsafe to call do_auto_save now. */
343 force_auto_save_soon (); 356 force_auto_save_soon ();
344} 357}
345#endif
346 358
347/* We define abort, rather than using it from the library, 359static void
348 so that GDB can return from a breakpoint here. 360deliver_danger_signal (int sig)
349 MSDOS has its own definition in msdos.c. */
350
351#if ! defined (DOS_NT) && ! defined (NO_ABORT)
352
353void
354abort (void)
355{ 361{
356 kill (getpid (), SIGABRT); 362 handle_on_main_thread (sig, handle_danger_signal);
357 /* This shouldn't be executed, but it prevents a warning. */
358 exit (1);
359} 363}
360#endif 364#endif
361
362 365
363/* Code for dealing with Lisp access to the Unix command line. */ 366/* Code for dealing with Lisp access to the Unix command line. */
364 367
@@ -690,6 +693,7 @@ main (int argc, char **argv)
690 char dname_arg2[80]; 693 char dname_arg2[80];
691#endif 694#endif
692 char *ch_to_dir; 695 char *ch_to_dir;
696 struct sigaction fatal_error_action;
693 697
694#if GC_MARK_STACK 698#if GC_MARK_STACK
695 stack_base = &dummy; 699 stack_base = &dummy;
@@ -858,10 +862,6 @@ main (int argc, char **argv)
858# endif /* not SYNC_INPUT */ 862# endif /* not SYNC_INPUT */
859#endif /* not SYSTEM_MALLOC */ 863#endif /* not SYSTEM_MALLOC */
860 864
861#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
862 main_thread = pthread_self ();
863#endif /* FORWARD_SIGNAL_TO_MAIN_THREAD */
864
865#if defined (MSDOS) || defined (WINDOWSNT) 865#if defined (MSDOS) || defined (WINDOWSNT)
866 /* We do all file input/output as binary files. When we need to translate 866 /* We do all file input/output as binary files. When we need to translate
867 newlines, we do that manually. */ 867 newlines, we do that manually. */
@@ -1114,6 +1114,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1114 } 1114 }
1115 1115
1116 init_signals (); 1116 init_signals ();
1117 emacs_sigaction_init (&fatal_error_action, deliver_fatal_signal);
1117 1118
1118 /* Don't catch SIGHUP if dumping. */ 1119 /* Don't catch SIGHUP if dumping. */
1119 if (1 1120 if (1
@@ -1122,13 +1123,17 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1122#endif 1123#endif
1123 ) 1124 )
1124 { 1125 {
1125 sigblock (sigmask (SIGHUP));
1126 /* In --batch mode, don't catch SIGHUP if already ignored. 1126 /* In --batch mode, don't catch SIGHUP if already ignored.
1127 That makes nohup work. */ 1127 That makes nohup work. */
1128 if (! noninteractive 1128 bool catch_SIGHUP = !noninteractive;
1129 || signal (SIGHUP, SIG_IGN) != SIG_IGN) 1129 if (!catch_SIGHUP)
1130 signal (SIGHUP, fatal_error_signal); 1130 {
1131 sigunblock (sigmask (SIGHUP)); 1131 struct sigaction old_action;
1132 sigaction (SIGHUP, 0, &old_action);
1133 catch_SIGHUP = old_action.sa_handler != SIG_IGN;
1134 }
1135 if (catch_SIGHUP)
1136 sigaction (SIGHUP, &fatal_error_action, 0);
1132 } 1137 }
1133 1138
1134 if ( 1139 if (
@@ -1142,9 +1147,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1142 /* Don't catch these signals in batch mode if dumping. 1147 /* Don't catch these signals in batch mode if dumping.
1143 On some machines, this sets static data that would make 1148 On some machines, this sets static data that would make
1144 signal fail to work right when the dumped Emacs is run. */ 1149 signal fail to work right when the dumped Emacs is run. */
1145 signal (SIGQUIT, fatal_error_signal); 1150 sigaction (SIGQUIT, &fatal_error_action, 0);
1146 signal (SIGILL, fatal_error_signal); 1151 sigaction (SIGILL, &fatal_error_action, 0);
1147 signal (SIGTRAP, fatal_error_signal); 1152 sigaction (SIGTRAP, &fatal_error_action, 0);
1148#ifdef SIGUSR1 1153#ifdef SIGUSR1
1149 add_user_signal (SIGUSR1, "sigusr1"); 1154 add_user_signal (SIGUSR1, "sigusr1");
1150#endif 1155#endif
@@ -1152,68 +1157,73 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1152 add_user_signal (SIGUSR2, "sigusr2"); 1157 add_user_signal (SIGUSR2, "sigusr2");
1153#endif 1158#endif
1154#ifdef SIGABRT 1159#ifdef SIGABRT
1155 signal (SIGABRT, fatal_error_signal); 1160 sigaction (SIGABRT, &fatal_error_action, 0);
1156#endif 1161#endif
1157#ifdef SIGHWE 1162#ifdef SIGHWE
1158 signal (SIGHWE, fatal_error_signal); 1163 sigaction (SIGHWE, &fatal_error_action, 0);
1159#endif 1164#endif
1160#ifdef SIGPRE 1165#ifdef SIGPRE
1161 signal (SIGPRE, fatal_error_signal); 1166 sigaction (SIGPRE, &fatal_error_action, 0);
1162#endif 1167#endif
1163#ifdef SIGORE 1168#ifdef SIGORE
1164 signal (SIGORE, fatal_error_signal); 1169 sigaction (SIGORE, &fatal_error_action, 0);
1165#endif 1170#endif
1166#ifdef SIGUME 1171#ifdef SIGUME
1167 signal (SIGUME, fatal_error_signal); 1172 sigaction (SIGUME, &fatal_error_action, 0);
1168#endif 1173#endif
1169#ifdef SIGDLK 1174#ifdef SIGDLK
1170 signal (SIGDLK, fatal_error_signal); 1175 sigaction (SIGDLK, &fatal_error_action, 0);
1171#endif 1176#endif
1172#ifdef SIGCPULIM 1177#ifdef SIGCPULIM
1173 signal (SIGCPULIM, fatal_error_signal); 1178 sigaction (SIGCPULIM, &fatal_error_action, 0);
1174#endif 1179#endif
1175#ifdef SIGIOT 1180#ifdef SIGIOT
1176 /* This is missing on some systems - OS/2, for example. */ 1181 /* This is missing on some systems - OS/2, for example. */
1177 signal (SIGIOT, fatal_error_signal); 1182 sigaction (SIGIOT, &fatal_error_action, 0);
1178#endif 1183#endif
1179#ifdef SIGEMT 1184#ifdef SIGEMT
1180 signal (SIGEMT, fatal_error_signal); 1185 sigaction (SIGEMT, &fatal_error_action, 0);
1181#endif 1186#endif
1182 signal (SIGFPE, fatal_error_signal); 1187 sigaction (SIGFPE, &fatal_error_action, 0);
1183#ifdef SIGBUS 1188#ifdef SIGBUS
1184 signal (SIGBUS, fatal_error_signal); 1189 sigaction (SIGBUS, &fatal_error_action, 0);
1185#endif 1190#endif
1186 signal (SIGSEGV, fatal_error_signal); 1191 sigaction (SIGSEGV, &fatal_error_action, 0);
1187#ifdef SIGSYS 1192#ifdef SIGSYS
1188 signal (SIGSYS, fatal_error_signal); 1193 sigaction (SIGSYS, &fatal_error_action, 0);
1189#endif 1194#endif
1190 /* May need special treatment on MS-Windows. See 1195 /* May need special treatment on MS-Windows. See
1191 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html 1196 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
1192 Please update the doc of kill-emacs, kill-emacs-hook, and 1197 Please update the doc of kill-emacs, kill-emacs-hook, and
1193 NEWS if you change this. 1198 NEWS if you change this.
1194 */ 1199 */
1195 if (noninteractive) signal (SIGINT, fatal_error_signal); 1200 if (noninteractive)
1196 signal (SIGTERM, fatal_error_signal); 1201 sigaction (SIGINT, &fatal_error_action, 0);
1202 sigaction (SIGTERM, &fatal_error_action, 0);
1197#ifdef SIGXCPU 1203#ifdef SIGXCPU
1198 signal (SIGXCPU, fatal_error_signal); 1204 sigaction (SIGXCPU, &fatal_error_action, 0);
1199#endif 1205#endif
1200#ifdef SIGXFSZ 1206#ifdef SIGXFSZ
1201 signal (SIGXFSZ, fatal_error_signal); 1207 sigaction (SIGXFSZ, &fatal_error_action, 0);
1202#endif /* SIGXFSZ */ 1208#endif /* SIGXFSZ */
1203 1209
1204#ifdef SIGDANGER 1210#ifdef SIGDANGER
1205 /* This just means available memory is getting low. */ 1211 /* This just means available memory is getting low. */
1206 signal (SIGDANGER, memory_warning_signal); 1212 {
1213 struct sigaction action;
1214 emacs_sigaction_init (&action, deliver_danger_signal);
1215 sigaction (SIGDANGER, &action, 0);
1216 }
1207#endif 1217#endif
1208 1218
1209#ifdef AIX 1219#ifdef AIX
1210/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */ 1220/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
1211 signal (SIGXCPU, fatal_error_signal); 1221 sigaction (SIGXCPU, &fatal_error_action, 0);
1212 signal (SIGIOINT, fatal_error_signal); 1222 sigaction (SIGIOINT, &fatal_error_action, 0);
1213 signal (SIGGRANT, fatal_error_signal); 1223 sigaction (SIGGRANT, &fatal_error_action, 0);
1214 signal (SIGRETRACT, fatal_error_signal); 1224 sigaction (SIGRETRACT, &fatal_error_action, 0);
1215 signal (SIGSOUND, fatal_error_signal); 1225 sigaction (SIGSOUND, &fatal_error_action, 0);
1216 signal (SIGMSG, fatal_error_signal); 1226 sigaction (SIGMSG, &fatal_error_action, 0);
1217#endif /* AIX */ 1227#endif /* AIX */
1218 } 1228 }
1219 1229
@@ -1583,7 +1593,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1583 init_fringe (); 1593 init_fringe ();
1584#endif /* HAVE_WINDOW_SYSTEM */ 1594#endif /* HAVE_WINDOW_SYSTEM */
1585 init_macros (); 1595 init_macros ();
1586 init_floatfns ();
1587 init_window (); 1596 init_window ();
1588 init_font (); 1597 init_font ();
1589 1598
@@ -1898,7 +1907,7 @@ sort_args (int argc, char **argv)
1898 } 1907 }
1899 1908
1900 if (best < 0) 1909 if (best < 0)
1901 abort (); 1910 emacs_abort ();
1902 1911
1903 /* Copy the highest priority remaining option, with its args, to NEW. 1912 /* Copy the highest priority remaining option, with its args, to NEW.
1904 Unless it is a duplicate of the previous one. */ 1913 Unless it is a duplicate of the previous one. */
@@ -2014,7 +2023,7 @@ shut_down_emacs (int sig, Lisp_Object stuff)
2014 { 2023 {
2015 reset_all_sys_modes (); 2024 reset_all_sys_modes ();
2016 if (sig && sig != SIGTERM) 2025 if (sig && sig != SIGTERM)
2017 fprintf (stderr, "Fatal error (%d)", sig); 2026 fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig));
2018 } 2027 }
2019 } 2028 }
2020#else 2029#else
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index e45cc716a31..5f90a5b90aa 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.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 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#include <setjmp.h>
27#include "lisp.h" 26#include "lisp.h"
diff --git a/src/eval.c b/src/eval.c
index 3a4953665e3..4f0d6c69a51 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -191,7 +191,7 @@ restore_stack_limits (Lisp_Object data)
191 191
192/* Call the Lisp debugger, giving it argument ARG. */ 192/* Call the Lisp debugger, giving it argument ARG. */
193 193
194static Lisp_Object 194Lisp_Object
195call_debugger (Lisp_Object arg) 195call_debugger (Lisp_Object arg)
196{ 196{
197 bool debug_while_redisplaying; 197 bool debug_while_redisplaying;
@@ -1493,7 +1493,7 @@ See also the function `condition-case'. */)
1493 immediate_quit = handling_signal = 0; 1493 immediate_quit = handling_signal = 0;
1494 abort_on_gc = 0; 1494 abort_on_gc = 0;
1495 if (gc_in_progress || waiting_for_input) 1495 if (gc_in_progress || waiting_for_input)
1496 abort (); 1496 emacs_abort ();
1497 1497
1498#if 0 /* rms: I don't know why this was here, 1498#if 0 /* rms: I don't know why this was here,
1499 but it is surely wrong for an error that is handled. */ 1499 but it is surely wrong for an error that is handled. */
@@ -1590,7 +1590,7 @@ void
1590xsignal (Lisp_Object error_symbol, Lisp_Object data) 1590xsignal (Lisp_Object error_symbol, Lisp_Object data)
1591{ 1591{
1592 Fsignal (error_symbol, data); 1592 Fsignal (error_symbol, data);
1593 abort (); 1593 emacs_abort ();
1594} 1594}
1595 1595
1596/* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ 1596/* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */
@@ -2043,7 +2043,7 @@ eval_sub (Lisp_Object form)
2043 struct gcpro gcpro1, gcpro2, gcpro3; 2043 struct gcpro gcpro1, gcpro2, gcpro3;
2044 2044
2045 if (handling_signal) 2045 if (handling_signal)
2046 abort (); 2046 emacs_abort ();
2047 2047
2048 if (SYMBOLP (form)) 2048 if (SYMBOLP (form))
2049 { 2049 {
@@ -2207,7 +2207,7 @@ eval_sub (Lisp_Object form)
2207 is supported by this code. We need to either rewrite the 2207 is supported by this code. We need to either rewrite the
2208 subr to use a different argument protocol, or add more 2208 subr to use a different argument protocol, or add more
2209 cases to this switch. */ 2209 cases to this switch. */
2210 abort (); 2210 emacs_abort ();
2211 } 2211 }
2212 } 2212 }
2213 } 2213 }
@@ -2850,7 +2850,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2850 /* If a subr takes more than 8 arguments without using MANY 2850 /* If a subr takes more than 8 arguments without using MANY
2851 or UNEVALLED, we need to extend this function to support it. 2851 or UNEVALLED, we need to extend this function to support it.
2852 Until this is done, there is no way to call the function. */ 2852 Until this is done, there is no way to call the function. */
2853 abort (); 2853 emacs_abort ();
2854 } 2854 }
2855 } 2855 }
2856 } 2856 }
@@ -2981,7 +2981,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2981 lexenv = Qnil; 2981 lexenv = Qnil;
2982 } 2982 }
2983 else 2983 else
2984 abort (); 2984 emacs_abort ();
2985 2985
2986 i = optional = rest = 0; 2986 i = optional = rest = 0;
2987 for (; CONSP (syms_left); syms_left = XCDR (syms_left)) 2987 for (; CONSP (syms_left); syms_left = XCDR (syms_left))
@@ -3195,7 +3195,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3195 set_internal (symbol, value, Qnil, 1); 3195 set_internal (symbol, value, Qnil, 1);
3196 break; 3196 break;
3197 } 3197 }
3198 default: abort (); 3198 default: emacs_abort ();
3199 } 3199 }
3200} 3200}
3201 3201
diff --git a/src/fileio.c b/src/fileio.c
index 7466914af1c..f0b3f0cc2fd 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -85,18 +85,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
85 85
86#include "commands.h" 86#include "commands.h"
87 87
88/* Nonzero during writing of auto-save files. */ 88/* True during writing of auto-save files. */
89static int auto_saving; 89static bool auto_saving;
90 90
91/* Nonzero umask during creation of auto-save directories. */ 91/* Nonzero umask during creation of auto-save directories. */
92static int auto_saving_dir_umask; 92static mode_t auto_saving_dir_umask;
93 93
94/* Set by auto_save_1 to mode of original file so Fwrite_region will create 94/* 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. */ 95 a new file with the same mode as the original. */
96static int auto_save_mode_bits; 96static mode_t auto_save_mode_bits;
97 97
98/* Set by auto_save_1 if an error occurred during the last auto-save. */ 98/* Set by auto_save_1 if an error occurred during the last auto-save. */
99static int auto_save_error_occurred; 99static bool auto_save_error_occurred;
100 100
101/* The symbol bound to coding-system-for-read when 101/* The symbol bound to coding-system-for-read when
102 insert-file-contents is called for recovering a file. This is not 102 insert-file-contents is called for recovering a file. This is not
@@ -145,10 +145,10 @@ Lisp_Object Qfile_name_history;
145 145
146static Lisp_Object Qcar_less_than_car; 146static Lisp_Object Qcar_less_than_car;
147 147
148static int a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, 148static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
149 Lisp_Object *, struct coding_system *); 149 Lisp_Object *, struct coding_system *);
150static int e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, 150static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
151 struct coding_system *); 151 struct coding_system *);
152 152
153 153
154void 154void
@@ -595,7 +595,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 595 which has no existing file. To make this work, PREFIX should be
596 an absolute file name. 596 an absolute file name.
597 597
598 BASE64_P non-zero means add the pid as 3 characters in base64 598 BASE64_P means add the pid as 3 characters in base64
599 encoding. In this case, 6 characters will be added to PREFIX to 599 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 600 form the file name. Otherwise, if Emacs is running on a system
601 with long file names, add the pid as a decimal number. 601 with long file names, add the pid as a decimal number.
@@ -604,7 +604,7 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p;
604 generated. */ 604 generated. */
605 605
606Lisp_Object 606Lisp_Object
607make_temp_name (Lisp_Object prefix, int base64_p) 607make_temp_name (Lisp_Object prefix, bool base64_p)
608{ 608{
609 Lisp_Object val; 609 Lisp_Object val;
610 int len, clen; 610 int len, clen;
@@ -761,8 +761,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
761 struct passwd *pw; 761 struct passwd *pw;
762#ifdef DOS_NT 762#ifdef DOS_NT
763 int drive = 0; 763 int drive = 0;
764 int collapse_newdir = 1; 764 bool collapse_newdir = 1;
765 int is_escaped = 0; 765 bool is_escaped = 0;
766#endif /* DOS_NT */ 766#endif /* DOS_NT */
767 ptrdiff_t length; 767 ptrdiff_t length;
768 Lisp_Object handler, result, handled_name; 768 Lisp_Object handler, result, handled_name;
@@ -920,10 +920,9 @@ filesystem tree, not (expand-file-name ".." dirname). */)
920 /* If it turns out that the filename we want to return is just a 920 /* 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 921 suffix of FILENAME, we don't need to go through and edit
922 things; we just need to construct a new string using data 922 things; we just need to construct a new string using data
923 starting at the middle of FILENAME. If we set lose to a 923 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 924 means we've discovered that we can't do that cool trick. */
925 that cool trick. */ 925 bool lose = 0;
926 int lose = 0;
927 char *p = nm; 926 char *p = nm;
928 927
929 while (*p) 928 while (*p)
@@ -1294,7 +1293,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1294 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) 1293 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1])))
1295#endif /* WINDOWSNT */ 1294#endif /* WINDOWSNT */
1296 { 1295 {
1297 if (!drive) abort (); 1296 if (!drive) emacs_abort ();
1298 target -= 2; 1297 target -= 2;
1299 target[0] = DRIVE_LETTER (drive); 1298 target[0] = DRIVE_LETTER (drive);
1300 target[1] = ':'; 1299 target[1] = ':';
@@ -1360,7 +1359,6 @@ See also the function `substitute-in-file-name'.")
1360 ptrdiff_t tlen; 1359 ptrdiff_t tlen;
1361 unsigned char *target; 1360 unsigned char *target;
1362 struct passwd *pw; 1361 struct passwd *pw;
1363 int lose;
1364 1362
1365 CHECK_STRING (name); 1363 CHECK_STRING (name);
1366 nm = SDATA (name); 1364 nm = SDATA (name);
@@ -1369,8 +1367,8 @@ See also the function `substitute-in-file-name'.")
1369 If no /./ or /../ we can return right away. */ 1367 If no /./ or /../ we can return right away. */
1370 if (nm[0] == '/') 1368 if (nm[0] == '/')
1371 { 1369 {
1370 bool lose = 0;
1372 p = nm; 1371 p = nm;
1373 lose = 0;
1374 while (*p) 1372 while (*p)
1375 { 1373 {
1376 if (p[0] == '/' && p[1] == '/' 1374 if (p[0] == '/' && p[1] == '/'
@@ -1494,7 +1492,7 @@ See also the function `substitute-in-file-name'.")
1494#endif 1492#endif
1495 1493
1496/* If /~ or // appears, discard everything through first slash. */ 1494/* If /~ or // appears, discard everything through first slash. */
1497static int 1495static bool
1498file_name_absolute_p (const char *filename) 1496file_name_absolute_p (const char *filename)
1499{ 1497{
1500 return 1498 return
@@ -1560,12 +1558,10 @@ If `//' appears, everything up to and including the first of
1560those `/' is discarded. */) 1558those `/' is discarded. */)
1561 (Lisp_Object filename) 1559 (Lisp_Object filename)
1562{ 1560{
1563 char *nm; 1561 char *nm, *s, *p, *o, *x, *endp;
1564
1565 register char *s, *p, *o, *x, *endp;
1566 char *target = NULL; 1562 char *target = NULL;
1567 int total = 0; 1563 int total = 0;
1568 int substituted = 0; 1564 bool substituted = 0;
1569 bool multibyte; 1565 bool multibyte;
1570 char *xnm; 1566 char *xnm;
1571 Lisp_Object handler; 1567 Lisp_Object handler;
@@ -1780,7 +1776,7 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
1780} 1776}
1781 1777
1782/* Signal an error if the file ABSNAME already exists. 1778/* Signal an error if the file ABSNAME already exists.
1783 If INTERACTIVE is nonzero, ask the user whether to proceed, 1779 If INTERACTIVE, ask the user whether to proceed,
1784 and bypass the error if the user says to go ahead. 1780 and bypass the error if the user says to go ahead.
1785 QUERYSTRING is a name for the action that is being considered 1781 QUERYSTRING is a name for the action that is being considered
1786 to alter the file. 1782 to alter the file.
@@ -1789,13 +1785,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. 1785 If the file does not exist, STATPTR->st_mode is set to 0.
1790 If STATPTR is null, we don't store into it. 1786 If STATPTR is null, we don't store into it.
1791 1787
1792 If QUICK is nonzero, we ask for y or n, not yes or no. */ 1788 If QUICK, ask for y or n, not yes or no. */
1793 1789
1794static void 1790static void
1795barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, 1791barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring,
1796 int interactive, struct stat *statptr, int quick) 1792 bool interactive, struct stat *statptr,
1793 bool quick)
1797{ 1794{
1798 register Lisp_Object tem, encoded_filename; 1795 Lisp_Object tem, encoded_filename;
1799 struct stat statbuf; 1796 struct stat statbuf;
1800 struct gcpro gcpro1; 1797 struct gcpro gcpro1;
1801 1798
@@ -1869,11 +1866,11 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1869 Lisp_Object handler; 1866 Lisp_Object handler;
1870 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1867 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1871 ptrdiff_t count = SPECPDL_INDEX (); 1868 ptrdiff_t count = SPECPDL_INDEX ();
1872 int input_file_statable_p; 1869 bool input_file_statable_p;
1873 Lisp_Object encoded_file, encoded_newname; 1870 Lisp_Object encoded_file, encoded_newname;
1874#if HAVE_LIBSELINUX 1871#if HAVE_LIBSELINUX
1875 security_context_t con; 1872 security_context_t con;
1876 int fail, conlength = 0; 1873 int conlength = 0;
1877#endif 1874#endif
1878 1875
1879 encoded_file = encoded_newname = Qnil; 1876 encoded_file = encoded_newname = Qnil;
@@ -1988,7 +1985,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1988 S_IREAD | S_IWRITE); 1985 S_IREAD | S_IWRITE);
1989#else /* not MSDOS */ 1986#else /* not MSDOS */
1990 { 1987 {
1991 int new_mask = 0666; 1988 mode_t new_mask = 0666;
1992 if (input_file_statable_p) 1989 if (input_file_statable_p)
1993 { 1990 {
1994 if (!NILP (preserve_uid_gid)) 1991 if (!NILP (preserve_uid_gid))
@@ -2018,7 +2015,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
2018 owner and group. */ 2015 owner and group. */
2019 if (input_file_statable_p) 2016 if (input_file_statable_p)
2020 { 2017 {
2021 int mode_mask = 07777; 2018 mode_t mode_mask = 07777;
2022 if (!NILP (preserve_uid_gid)) 2019 if (!NILP (preserve_uid_gid))
2023 { 2020 {
2024 /* Attempt to change owner and group. If that doesn't work 2021 /* Attempt to change owner and group. If that doesn't work
@@ -2041,7 +2038,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
2041 if (conlength > 0) 2038 if (conlength > 0)
2042 { 2039 {
2043 /* Set the modified context back to the file. */ 2040 /* Set the modified context back to the file. */
2044 fail = fsetfilecon (ofd, con); 2041 bool fail = fsetfilecon (ofd, con) != 0;
2045 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 2042 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
2046 if (fail && errno != ENOTSUP) 2043 if (fail && errno != ENOTSUP)
2047 report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); 2044 report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil));
@@ -2184,17 +2181,14 @@ internal_delete_file_1 (Lisp_Object ignore)
2184 return Qt; 2181 return Qt;
2185} 2182}
2186 2183
2187/* Delete file FILENAME, returning 1 if successful and 0 if failed. 2184/* Delete file FILENAME.
2188 This ignores `delete-by-moving-to-trash'. */ 2185 This ignores `delete-by-moving-to-trash'. */
2189 2186
2190int 2187void
2191internal_delete_file (Lisp_Object filename) 2188internal_delete_file (Lisp_Object filename)
2192{ 2189{
2193 Lisp_Object tem; 2190 internal_condition_case_2 (Fdelete_file, filename, Qnil,
2194 2191 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} 2192}
2199 2193
2200DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, 2194DEFUN ("rename-file", Frename_file, Srename_file, 2, 3,
@@ -2430,9 +2424,9 @@ On Unix, this is a name starting with a `/' or a `~'. */)
2430 return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil; 2424 return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
2431} 2425}
2432 2426
2433/* Return nonzero if file FILENAME exists and can be executed. */ 2427/* Return true if file FILENAME exists and can be executed. */
2434 2428
2435static int 2429static bool
2436check_executable (char *filename) 2430check_executable (char *filename)
2437{ 2431{
2438#ifdef DOS_NT 2432#ifdef DOS_NT
@@ -2452,9 +2446,9 @@ check_executable (char *filename)
2452#endif /* not DOS_NT */ 2446#endif /* not DOS_NT */
2453} 2447}
2454 2448
2455/* Return nonzero if file FILENAME exists and can be written. */ 2449/* Return true if file FILENAME exists and can be written. */
2456 2450
2457static int 2451static bool
2458check_writable (const char *filename) 2452check_writable (const char *filename)
2459{ 2453{
2460#ifdef MSDOS 2454#ifdef MSDOS
@@ -2464,7 +2458,7 @@ check_writable (const char *filename)
2464 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); 2458 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
2465#else /* not MSDOS */ 2459#else /* not MSDOS */
2466#ifdef HAVE_EUIDACCESS 2460#ifdef HAVE_EUIDACCESS
2467 int res = (euidaccess (filename, 2) >= 0); 2461 bool res = (euidaccess (filename, 2) >= 0);
2468#ifdef CYGWIN 2462#ifdef CYGWIN
2469 /* euidaccess may have returned failure because Cygwin couldn't 2463 /* euidaccess may have returned failure because Cygwin couldn't
2470 determine the file's UID or GID; if so, we return success. */ 2464 determine the file's UID or GID; if so, we return success. */
@@ -2732,7 +2726,7 @@ searchable directory. */)
2732 (Lisp_Object filename) 2726 (Lisp_Object filename)
2733{ 2727{
2734 Lisp_Object handler; 2728 Lisp_Object handler;
2735 int tem; 2729 bool tem;
2736 struct gcpro gcpro1; 2730 struct gcpro gcpro1;
2737 2731
2738 /* If the file name has special constructs in it, 2732 /* If the file name has special constructs in it,
@@ -2868,7 +2862,8 @@ compiled with SELinux support. */)
2868 Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context))); 2862 Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context)));
2869 Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context)))); 2863 Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context))));
2870 security_context_t con; 2864 security_context_t con;
2871 int fail, conlength; 2865 bool fail;
2866 int conlength;
2872 context_t parsed_con; 2867 context_t parsed_con;
2873#endif 2868#endif
2874 2869
@@ -2912,8 +2907,9 @@ compiled with SELinux support. */)
2912 } 2907 }
2913 2908
2914 /* Set the modified context back to the file. */ 2909 /* Set the modified context back to the file. */
2915 fail = lsetfilecon (SSDATA (encoded_absname), 2910 fail = (lsetfilecon (SSDATA (encoded_absname),
2916 context_str (parsed_con)); 2911 context_str (parsed_con))
2912 != 0);
2917 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 2913 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
2918 if (fail && errno != ENOTSUP) 2914 if (fail && errno != ENOTSUP)
2919 report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); 2915 report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil));
@@ -3004,7 +3000,7 @@ DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0,
3004The value is an integer. */) 3000The value is an integer. */)
3005 (void) 3001 (void)
3006{ 3002{
3007 int realmask; 3003 mode_t realmask;
3008 Lisp_Object value; 3004 Lisp_Object value;
3009 3005
3010 BLOCK_INPUT; 3006 BLOCK_INPUT;
@@ -3246,29 +3242,29 @@ variable `last-coding-system-used' to the coding system actually used. */)
3246 struct stat st; 3242 struct stat st;
3247 int file_status; 3243 int file_status;
3248 EMACS_TIME mtime; 3244 EMACS_TIME mtime;
3249 register int fd; 3245 int fd;
3250 ptrdiff_t inserted = 0; 3246 ptrdiff_t inserted = 0;
3251 int nochange = 0; 3247 bool nochange = 0;
3252 register ptrdiff_t how_much; 3248 ptrdiff_t how_much;
3253 off_t beg_offset, end_offset; 3249 off_t beg_offset, end_offset;
3254 register int unprocessed; 3250 int unprocessed;
3255 ptrdiff_t count = SPECPDL_INDEX (); 3251 ptrdiff_t count = SPECPDL_INDEX ();
3256 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 3252 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
3257 Lisp_Object handler, val, insval, orig_filename, old_undo; 3253 Lisp_Object handler, val, insval, orig_filename, old_undo;
3258 Lisp_Object p; 3254 Lisp_Object p;
3259 ptrdiff_t total = 0; 3255 ptrdiff_t total = 0;
3260 int not_regular = 0; 3256 bool not_regular = 0;
3261 int save_errno = 0; 3257 int save_errno = 0;
3262 char read_buf[READ_BUF_SIZE]; 3258 char read_buf[READ_BUF_SIZE];
3263 struct coding_system coding; 3259 struct coding_system coding;
3264 char buffer[1 << 14]; 3260 char buffer[1 << 14];
3265 int replace_handled = 0; 3261 bool replace_handled = 0;
3266 int set_coding_system = 0; 3262 bool set_coding_system = 0;
3267 Lisp_Object coding_system; 3263 Lisp_Object coding_system;
3268 int read_quit = 0; 3264 bool read_quit = 0;
3269 Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; 3265 Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
3270 int we_locked_file = 0; 3266 bool we_locked_file = 0;
3271 int deferred_remove_unwind_protect = 0; 3267 bool deferred_remove_unwind_protect = 0;
3272 3268
3273 if (current_buffer->base_buffer && ! NILP (visit)) 3269 if (current_buffer->base_buffer && ! NILP (visit))
3274 error ("Cannot do file visiting in an indirect buffer"); 3270 error ("Cannot do file visiting in an indirect buffer");
@@ -3569,9 +3565,9 @@ variable `last-coding-system-used' to the coding system actually used. */)
3569 ptrdiff_t same_at_end = ZV_BYTE; 3565 ptrdiff_t same_at_end = ZV_BYTE;
3570 ptrdiff_t overlap; 3566 ptrdiff_t overlap;
3571 /* There is still a possibility we will find the need to do code 3567 /* 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 3568 conversion. If that happens, set this variable to
3573 give up on handling REPLACE in the optimized way. */ 3569 give up on handling REPLACE in the optimized way. */
3574 int giveup_match_end = 0; 3570 bool giveup_match_end = 0;
3575 3571
3576 if (beg_offset != 0) 3572 if (beg_offset != 0)
3577 { 3573 {
@@ -4427,8 +4423,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 4423 If it is not set locally, we anyway have to convert EOL
4428 format if the default value of `buffer-file-coding-system' 4424 format if the default value of `buffer-file-coding-system'
4429 tells that it is not Unix-like (LF only) format. */ 4425 tells that it is not Unix-like (LF only) format. */
4430 int using_default_coding = 0; 4426 bool using_default_coding = 0;
4431 int force_raw_text = 0; 4427 bool force_raw_text = 0;
4432 4428
4433 val = BVAR (current_buffer, buffer_file_coding_system); 4429 val = BVAR (current_buffer, buffer_file_coding_system);
4434 if (NILP (val) 4430 if (NILP (val)
@@ -4537,8 +4533,8 @@ This calls `write-region-annotate-functions' at the start, and
4537`write-region-post-annotation-function' at the end. */) 4533`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) 4534 (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew)
4539{ 4535{
4540 register int desc; 4536 int desc;
4541 int failure; 4537 bool ok;
4542 int save_errno = 0; 4538 int save_errno = 0;
4543 const char *fn; 4539 const char *fn;
4544 struct stat st; 4540 struct stat st;
@@ -4548,8 +4544,8 @@ This calls `write-region-annotate-functions' at the start, and
4548 Lisp_Object visit_file; 4544 Lisp_Object visit_file;
4549 Lisp_Object annotations; 4545 Lisp_Object annotations;
4550 Lisp_Object encoded_filename; 4546 Lisp_Object encoded_filename;
4551 int visiting = (EQ (visit, Qt) || STRINGP (visit)); 4547 bool visiting = (EQ (visit, Qt) || STRINGP (visit));
4552 int quietly = !NILP (visit); 4548 bool quietly = !NILP (visit);
4553 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 4549 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
4554 struct buffer *given_buffer; 4550 struct buffer *given_buffer;
4555 struct coding_system coding; 4551 struct coding_system coding;
@@ -4713,37 +4709,27 @@ This calls `write-region-annotate-functions' at the start, and
4713 4709
4714 UNGCPRO; 4710 UNGCPRO;
4715 4711
4716 failure = 0;
4717 immediate_quit = 1; 4712 immediate_quit = 1;
4718 4713
4719 if (STRINGP (start)) 4714 if (STRINGP (start))
4720 { 4715 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)) 4716 else if (XINT (start) != XINT (end))
4726 { 4717 ok = a_write (desc, Qnil, XINT (start), XINT (end) - XINT (start),
4727 failure = 0 > a_write (desc, Qnil, 4718 &annotations, &coding);
4728 XINT (start), XINT (end) - XINT (start),
4729 &annotations, &coding);
4730 save_errno = errno;
4731 }
4732 else 4719 else
4733 { 4720 {
4734 /* If file was empty, still need to write the annotations */ 4721 /* If file was empty, still need to write the annotations. */
4735 coding.mode |= CODING_MODE_LAST_BLOCK; 4722 coding.mode |= CODING_MODE_LAST_BLOCK;
4736 failure = 0 > a_write (desc, Qnil, XINT (end), 0, &annotations, &coding); 4723 ok = a_write (desc, Qnil, XINT (end), 0, &annotations, &coding);
4737 save_errno = errno;
4738 } 4724 }
4725 save_errno = errno;
4739 4726
4740 if (CODING_REQUIRE_FLUSHING (&coding) 4727 if (ok && CODING_REQUIRE_FLUSHING (&coding)
4741 && !(coding.mode & CODING_MODE_LAST_BLOCK) 4728 && !(coding.mode & CODING_MODE_LAST_BLOCK))
4742 && ! failure)
4743 { 4729 {
4744 /* We have to flush out a data. */ 4730 /* We have to flush out a data. */
4745 coding.mode |= CODING_MODE_LAST_BLOCK; 4731 coding.mode |= CODING_MODE_LAST_BLOCK;
4746 failure = 0 > e_write (desc, Qnil, 1, 1, &coding); 4732 ok = e_write (desc, Qnil, 1, 1, &coding);
4747 save_errno = errno; 4733 save_errno = errno;
4748 } 4734 }
4749 4735
@@ -4760,13 +4746,13 @@ This calls `write-region-annotate-functions' at the start, and
4760 ignore EINVAL which happens when fsync is not supported on this 4746 ignore EINVAL which happens when fsync is not supported on this
4761 file. */ 4747 file. */
4762 if (errno != EINTR && errno != EINVAL) 4748 if (errno != EINTR && errno != EINVAL)
4763 failure = 1, save_errno = errno; 4749 ok = 0, save_errno = errno;
4764 } 4750 }
4765#endif 4751#endif
4766 4752
4767 /* NFS can report a write failure now. */ 4753 /* NFS can report a write failure now. */
4768 if (emacs_close (desc) < 0) 4754 if (emacs_close (desc) < 0)
4769 failure = 1, save_errno = errno; 4755 ok = 0, save_errno = errno;
4770 4756
4771 stat (fn, &st); 4757 stat (fn, &st);
4772 4758
@@ -4803,7 +4789,7 @@ This calls `write-region-annotate-functions' at the start, and
4803 current_buffer->modtime_size = st.st_size; 4789 current_buffer->modtime_size = st.st_size;
4804 } 4790 }
4805 4791
4806 if (failure) 4792 if (! ok)
4807 error ("IO error writing %s: %s", SDATA (filename), 4793 error ("IO error writing %s: %s", SDATA (filename),
4808 emacs_strerror (save_errno)); 4794 emacs_strerror (save_errno));
4809 4795
@@ -4859,7 +4845,8 @@ build_annotations (Lisp_Object start, Lisp_Object end)
4859 Lisp_Object p, res; 4845 Lisp_Object p, res;
4860 struct gcpro gcpro1, gcpro2; 4846 struct gcpro gcpro1, gcpro2;
4861 Lisp_Object original_buffer; 4847 Lisp_Object original_buffer;
4862 int i, used_global = 0; 4848 int i;
4849 bool used_global = 0;
4863 4850
4864 XSETBUFFER (original_buffer, current_buffer); 4851 XSETBUFFER (original_buffer, current_buffer);
4865 4852
@@ -4939,11 +4926,11 @@ build_annotations (Lisp_Object start, Lisp_Object end)
4939 4926
4940 We modify *ANNOT by discarding elements as we use them up. 4927 We modify *ANNOT by discarding elements as we use them up.
4941 4928
4942 The return value is negative in case of system call failure. */ 4929 Return true if successful. */
4943 4930
4944static int 4931static bool
4945a_write (int desc, Lisp_Object string, ptrdiff_t pos, 4932a_write (int desc, Lisp_Object string, ptrdiff_t pos,
4946 register ptrdiff_t nchars, Lisp_Object *annot, 4933 ptrdiff_t nchars, Lisp_Object *annot,
4947 struct coding_system *coding) 4934 struct coding_system *coding)
4948{ 4935{
4949 Lisp_Object tem; 4936 Lisp_Object tem;
@@ -4965,29 +4952,29 @@ a_write (int desc, Lisp_Object string, ptrdiff_t pos,
4965 /* Output buffer text up to the next annotation's position. */ 4952 /* Output buffer text up to the next annotation's position. */
4966 if (nextpos > pos) 4953 if (nextpos > pos)
4967 { 4954 {
4968 if (0 > e_write (desc, string, pos, nextpos, coding)) 4955 if (!e_write (desc, string, pos, nextpos, coding))
4969 return -1; 4956 return 0;
4970 pos = nextpos; 4957 pos = nextpos;
4971 } 4958 }
4972 /* Output the annotation. */ 4959 /* Output the annotation. */
4973 tem = Fcdr (Fcar (*annot)); 4960 tem = Fcdr (Fcar (*annot));
4974 if (STRINGP (tem)) 4961 if (STRINGP (tem))
4975 { 4962 {
4976 if (0 > e_write (desc, tem, 0, SCHARS (tem), coding)) 4963 if (!e_write (desc, tem, 0, SCHARS (tem), coding))
4977 return -1; 4964 return 0;
4978 } 4965 }
4979 *annot = Fcdr (*annot); 4966 *annot = Fcdr (*annot);
4980 } 4967 }
4981 return 0; 4968 return 1;
4982} 4969}
4983 4970
4984 4971
4985/* Write text in the range START and END into descriptor DESC, 4972/* Write text in the range START and END into descriptor DESC,
4986 encoding them with coding system CODING. If STRING is nil, START 4973 encoding them with coding system CODING. If STRING is nil, START
4987 and END are character positions of the current buffer, else they 4974 and END are character positions of the current buffer, else they
4988 are indexes to the string STRING. */ 4975 are indexes to the string STRING. Return true if successful. */
4989 4976
4990static int 4977static bool
4991e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, 4978e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
4992 struct coding_system *coding) 4979 struct coding_system *coding)
4993{ 4980{
@@ -5056,12 +5043,12 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
5056 coding->produced); 5043 coding->produced);
5057 5044
5058 if (coding->produced) 5045 if (coding->produced)
5059 return -1; 5046 return 0;
5060 } 5047 }
5061 start += coding->consumed_char; 5048 start += coding->consumed_char;
5062 } 5049 }
5063 5050
5064 return 0; 5051 return 1;
5065} 5052}
5066 5053
5067DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 5054DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
@@ -5300,12 +5287,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5300{ 5287{
5301 struct buffer *old = current_buffer, *b; 5288 struct buffer *old = current_buffer, *b;
5302 Lisp_Object tail, buf, hook; 5289 Lisp_Object tail, buf, hook;
5303 int auto_saved = 0; 5290 bool auto_saved = 0;
5304 int do_handled_files; 5291 int do_handled_files;
5305 Lisp_Object oquit; 5292 Lisp_Object oquit;
5306 FILE *stream = NULL; 5293 FILE *stream = NULL;
5307 ptrdiff_t count = SPECPDL_INDEX (); 5294 ptrdiff_t count = SPECPDL_INDEX ();
5308 int orig_minibuffer_auto_raise = minibuffer_auto_raise; 5295 bool orig_minibuffer_auto_raise = minibuffer_auto_raise;
5309 bool old_message_p = 0; 5296 bool old_message_p = 0;
5310 struct gcpro gcpro1, gcpro2; 5297 struct gcpro gcpro1, gcpro2;
5311 5298
@@ -5452,7 +5439,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5452 if (!auto_saved && NILP (no_message)) 5439 if (!auto_saved && NILP (no_message))
5453 message1 ("Auto-saving..."); 5440 message1 ("Auto-saving...");
5454 internal_condition_case (auto_save_1, Qt, auto_save_error); 5441 internal_condition_case (auto_save_1, Qt, auto_save_error);
5455 auto_saved++; 5442 auto_saved = 1;
5456 BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b); 5443 BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
5457 XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); 5444 XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
5458 set_buffer_internal (old); 5445 set_buffer_internal (old);
diff --git a/src/filelock.c b/src/filelock.c
index d21d8e7ba02..1f599c68912 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -100,10 +100,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
100/* Return the time of the last system boot. */ 100/* Return the time of the last system boot. */
101 101
102static time_t boot_time; 102static time_t boot_time;
103static int boot_time_initialized; 103static bool boot_time_initialized;
104 104
105#ifdef BOOT_TIME 105#ifdef BOOT_TIME
106static void get_boot_time_1 (const char *, int); 106static void get_boot_time_1 (const char *, bool);
107#endif 107#endif
108 108
109static time_t 109static time_t
@@ -170,7 +170,7 @@ get_boot_time (void)
170 { 170 {
171 char cmd_string[sizeof WTMP_FILE ".19.gz"]; 171 char cmd_string[sizeof WTMP_FILE ".19.gz"];
172 Lisp_Object tempname, filename; 172 Lisp_Object tempname, filename;
173 int delete_flag = 0; 173 bool delete_flag = 0;
174 174
175 filename = Qnil; 175 filename = Qnil;
176 176
@@ -225,13 +225,13 @@ get_boot_time (void)
225 225
226 If FILENAME is zero, use the same file as before; 226 If FILENAME is zero, use the same file as before;
227 if no FILENAME has ever been specified, this is the utmp file. 227 if no FILENAME has ever been specified, this is the utmp file.
228 Use the newest reboot record if NEWEST is nonzero, 228 Use the newest reboot record if NEWEST,
229 the first reboot record otherwise. 229 the first reboot record otherwise.
230 Ignore all reboot records on or before BOOT_TIME. 230 Ignore all reboot records on or before BOOT_TIME.
231 Success is indicated by setting BOOT_TIME to a larger value. */ 231 Success is indicated by setting BOOT_TIME to a larger value. */
232 232
233void 233void
234get_boot_time_1 (const char *filename, int newest) 234get_boot_time_1 (const char *filename, bool newest)
235{ 235{
236 struct utmp ut, *utp; 236 struct utmp ut, *utp;
237 int desc; 237 int desc;
@@ -331,11 +331,11 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
331} 331}
332 332
333/* Lock the lock file named LFNAME. 333/* Lock the lock file named LFNAME.
334 If FORCE is nonzero, we do so even if it is already locked. 334 If FORCE, do so even if it is already locked.
335 Return 1 if successful, 0 if not. */ 335 Return true if successful. */
336 336
337static int 337static bool
338lock_file_1 (char *lfname, int force) 338lock_file_1 (char *lfname, bool force)
339{ 339{
340 int err; 340 int err;
341 int symlink_errno; 341 int symlink_errno;
@@ -370,9 +370,9 @@ lock_file_1 (char *lfname, int force)
370 return err == 0; 370 return err == 0;
371} 371}
372 372
373/* Return 1 if times A and B are no more than one second apart. */ 373/* Return true if times A and B are no more than one second apart. */
374 374
375static int 375static bool
376within_one_second (time_t a, time_t b) 376within_one_second (time_t a, time_t b)
377{ 377{
378 return (a - b >= -1 && a - b <= 1); 378 return (a - b >= -1 && a - b <= 1);
@@ -491,7 +491,7 @@ current_lock_owner (lock_info_type *owner, char *lfname)
491static int 491static int
492lock_if_free (lock_info_type *clasher, register char *lfname) 492lock_if_free (lock_info_type *clasher, register char *lfname)
493{ 493{
494 while (lock_file_1 (lfname, 0) == 0) 494 while (! lock_file_1 (lfname, 0))
495 { 495 {
496 int locker; 496 int locker;
497 497
diff --git a/src/floatfns.c b/src/floatfns.c
index cad071f1e15..8a9a9fd0886 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -22,47 +22,23 @@ 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 these math.h functions:
26 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, 26 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod,
27 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh. 27 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh.
28
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 */ 28 */
49 29
50#include <config.h> 30#include <config.h>
51#include <signal.h>
52#include <setjmp.h> 31#include <setjmp.h>
53#include "lisp.h" 32#include "lisp.h"
54#include "syssignal.h" 33#include "syssignal.h"
55 34
56#include <float.h> 35#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 \ 36#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
60 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 37 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
61#define IEEE_FLOATING_POINT 1 38#define IEEE_FLOATING_POINT 1
62#else 39#else
63#define IEEE_FLOATING_POINT 0 40#define IEEE_FLOATING_POINT 0
64#endif 41#endif
65#endif
66 42
67#include <math.h> 43#include <math.h>
68 44
@@ -71,124 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
71extern double logb (double); 47extern double logb (double);
72#endif /* not HPUX and HAVE_LOGB and no logb macro */ 48#endif /* not HPUX and HAVE_LOGB and no logb macro */
73 49
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
84
85#ifdef HAVE_MATHERR
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
191
192/* Extract a Lisp number as a `double', or signal an error. */ 50/* Extract a Lisp number as a `double', or signal an error. */
193 51
194double 52double
@@ -205,27 +63,19 @@ extract_float (Lisp_Object num)
205 63
206DEFUN ("acos", Facos, Sacos, 1, 1, 0, 64DEFUN ("acos", Facos, Sacos, 1, 1, 0,
207 doc: /* Return the inverse cosine of ARG. */) 65 doc: /* Return the inverse cosine of ARG. */)
208 (register Lisp_Object arg) 66 (Lisp_Object arg)
209{ 67{
210 double d = extract_float (arg); 68 double d = extract_float (arg);
211#ifdef FLOAT_CHECK_DOMAIN 69 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); 70 return make_float (d);
217} 71}
218 72
219DEFUN ("asin", Fasin, Sasin, 1, 1, 0, 73DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
220 doc: /* Return the inverse sine of ARG. */) 74 doc: /* Return the inverse sine of ARG. */)
221 (register Lisp_Object arg) 75 (Lisp_Object arg)
222{ 76{
223 double d = extract_float (arg); 77 double d = extract_float (arg);
224#ifdef FLOAT_CHECK_DOMAIN 78 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); 79 return make_float (d);
230} 80}
231 81
@@ -235,50 +85,44 @@ 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 85If 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) 86divided by X, i.e. the angle in radians between the vector (X, Y)
237and the x-axis. */) 87and the x-axis. */)
238 (register Lisp_Object y, Lisp_Object x) 88 (Lisp_Object y, Lisp_Object x)
239{ 89{
240 double d = extract_float (y); 90 double d = extract_float (y);
241 91
242 if (NILP (x)) 92 if (NILP (x))
243 IN_FLOAT (d = atan (d), "atan", y); 93 d = atan (d);
244 else 94 else
245 { 95 {
246 double d2 = extract_float (x); 96 double d2 = extract_float (x);
247 97 d = atan2 (d, d2);
248 IN_FLOAT2 (d = atan2 (d, d2), "atan", y, x);
249 } 98 }
250 return make_float (d); 99 return make_float (d);
251} 100}
252 101
253DEFUN ("cos", Fcos, Scos, 1, 1, 0, 102DEFUN ("cos", Fcos, Scos, 1, 1, 0,
254 doc: /* Return the cosine of ARG. */) 103 doc: /* Return the cosine of ARG. */)
255 (register Lisp_Object arg) 104 (Lisp_Object arg)
256{ 105{
257 double d = extract_float (arg); 106 double d = extract_float (arg);
258 IN_FLOAT (d = cos (d), "cos", arg); 107 d = cos (d);
259 return make_float (d); 108 return make_float (d);
260} 109}
261 110
262DEFUN ("sin", Fsin, Ssin, 1, 1, 0, 111DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
263 doc: /* Return the sine of ARG. */) 112 doc: /* Return the sine of ARG. */)
264 (register Lisp_Object arg) 113 (Lisp_Object arg)
265{ 114{
266 double d = extract_float (arg); 115 double d = extract_float (arg);
267 IN_FLOAT (d = sin (d), "sin", arg); 116 d = sin (d);
268 return make_float (d); 117 return make_float (d);
269} 118}
270 119
271DEFUN ("tan", Ftan, Stan, 1, 1, 0, 120DEFUN ("tan", Ftan, Stan, 1, 1, 0,
272 doc: /* Return the tangent of ARG. */) 121 doc: /* Return the tangent of ARG. */)
273 (register Lisp_Object arg) 122 (Lisp_Object arg)
274{ 123{
275 double d = extract_float (arg); 124 double d = extract_float (arg);
276 double c = cos (d); 125 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); 126 return make_float (d);
283} 127}
284 128
@@ -349,61 +193,61 @@ Returns the floating point value resulting from multiplying SGNFCAND
349 193
350DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, 194DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
351 doc: /* Return the bessel function j0 of ARG. */) 195 doc: /* Return the bessel function j0 of ARG. */)
352 (register Lisp_Object arg) 196 (Lisp_Object arg)
353{ 197{
354 double d = extract_float (arg); 198 double d = extract_float (arg);
355 IN_FLOAT (d = j0 (d), "bessel-j0", arg); 199 d = j0 (d);
356 return make_float (d); 200 return make_float (d);
357} 201}
358 202
359DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0, 203DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
360 doc: /* Return the bessel function j1 of ARG. */) 204 doc: /* Return the bessel function j1 of ARG. */)
361 (register Lisp_Object arg) 205 (Lisp_Object arg)
362{ 206{
363 double d = extract_float (arg); 207 double d = extract_float (arg);
364 IN_FLOAT (d = j1 (d), "bessel-j1", arg); 208 d = j1 (d);
365 return make_float (d); 209 return make_float (d);
366} 210}
367 211
368DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0, 212DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
369 doc: /* Return the order N bessel function output jn of ARG. 213 doc: /* Return the order N bessel function output jn of ARG.
370The first arg (the order) is truncated to an integer. */) 214The first arg (the order) is truncated to an integer. */)
371 (register Lisp_Object n, Lisp_Object arg) 215 (Lisp_Object n, Lisp_Object arg)
372{ 216{
373 int i1 = extract_float (n); 217 int i1 = extract_float (n);
374 double f2 = extract_float (arg); 218 double f2 = extract_float (arg);
375 219
376 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", n); 220 f2 = jn (i1, f2);
377 return make_float (f2); 221 return make_float (f2);
378} 222}
379 223
380DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0, 224DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
381 doc: /* Return the bessel function y0 of ARG. */) 225 doc: /* Return the bessel function y0 of ARG. */)
382 (register Lisp_Object arg) 226 (Lisp_Object arg)
383{ 227{
384 double d = extract_float (arg); 228 double d = extract_float (arg);
385 IN_FLOAT (d = y0 (d), "bessel-y0", arg); 229 d = y0 (d);
386 return make_float (d); 230 return make_float (d);
387} 231}
388 232
389DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0, 233DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
390 doc: /* Return the bessel function y1 of ARG. */) 234 doc: /* Return the bessel function y1 of ARG. */)
391 (register Lisp_Object arg) 235 (Lisp_Object arg)
392{ 236{
393 double d = extract_float (arg); 237 double d = extract_float (arg);
394 IN_FLOAT (d = y1 (d), "bessel-y0", arg); 238 d = y1 (d);
395 return make_float (d); 239 return make_float (d);
396} 240}
397 241
398DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0, 242DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
399 doc: /* Return the order N bessel function output yn of ARG. 243 doc: /* Return the order N bessel function output yn of ARG.
400The first arg (the order) is truncated to an integer. */) 244The first arg (the order) is truncated to an integer. */)
401 (register Lisp_Object n, Lisp_Object arg) 245 (Lisp_Object n, Lisp_Object arg)
402{ 246{
403 int i1 = extract_float (n); 247 int i1 = extract_float (n);
404 double f2 = extract_float (arg); 248 double f2 = extract_float (arg);
405 249
406 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", n); 250 f2 = yn (i1, f2);
407 return make_float (f2); 251 return make_float (f2);
408} 252}
409 253
@@ -413,43 +257,43 @@ The first arg (the order) is truncated to an integer. */)
413 257
414DEFUN ("erf", Ferf, Serf, 1, 1, 0, 258DEFUN ("erf", Ferf, Serf, 1, 1, 0,
415 doc: /* Return the mathematical error function of ARG. */) 259 doc: /* Return the mathematical error function of ARG. */)
416 (register Lisp_Object arg) 260 (Lisp_Object arg)
417{ 261{
418 double d = extract_float (arg); 262 double d = extract_float (arg);
419 IN_FLOAT (d = erf (d), "erf", arg); 263 d = erf (d);
420 return make_float (d); 264 return make_float (d);
421} 265}
422 266
423DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, 267DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
424 doc: /* Return the complementary error function of ARG. */) 268 doc: /* Return the complementary error function of ARG. */)
425 (register Lisp_Object arg) 269 (Lisp_Object arg)
426{ 270{
427 double d = extract_float (arg); 271 double d = extract_float (arg);
428 IN_FLOAT (d = erfc (d), "erfc", arg); 272 d = erfc (d);
429 return make_float (d); 273 return make_float (d);
430} 274}
431 275
432DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, 276DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
433 doc: /* Return the log gamma of ARG. */) 277 doc: /* Return the log gamma of ARG. */)
434 (register Lisp_Object arg) 278 (Lisp_Object arg)
435{ 279{
436 double d = extract_float (arg); 280 double d = extract_float (arg);
437 IN_FLOAT (d = lgamma (d), "log-gamma", arg); 281 d = lgamma (d);
438 return make_float (d); 282 return make_float (d);
439} 283}
440 284
441DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, 285DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
442 doc: /* Return the cube root of ARG. */) 286 doc: /* Return the cube root of ARG. */)
443 (register Lisp_Object arg) 287 (Lisp_Object arg)
444{ 288{
445 double d = extract_float (arg); 289 double d = extract_float (arg);
446#ifdef HAVE_CBRT 290#ifdef HAVE_CBRT
447 IN_FLOAT (d = cbrt (d), "cube-root", arg); 291 d = cbrt (d);
448#else 292#else
449 if (d >= 0.0) 293 if (d >= 0.0)
450 IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg); 294 d = pow (d, 1.0/3.0);
451 else 295 else
452 IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg); 296 d = -pow (-d, 1.0/3.0);
453#endif 297#endif
454 return make_float (d); 298 return make_float (d);
455} 299}
@@ -458,23 +302,16 @@ DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
458 302
459DEFUN ("exp", Fexp, Sexp, 1, 1, 0, 303DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
460 doc: /* Return the exponential base e of ARG. */) 304 doc: /* Return the exponential base e of ARG. */)
461 (register Lisp_Object arg) 305 (Lisp_Object arg)
462{ 306{
463 double d = extract_float (arg); 307 double d = extract_float (arg);
464#ifdef FLOAT_CHECK_DOMAIN 308 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); 309 return make_float (d);
473} 310}
474 311
475DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, 312DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
476 doc: /* Return the exponential ARG1 ** ARG2. */) 313 doc: /* Return the exponential ARG1 ** ARG2. */)
477 (register Lisp_Object arg1, Lisp_Object arg2) 314 (Lisp_Object arg1, Lisp_Object arg2)
478{ 315{
479 double f1, f2, f3; 316 double f1, f2, f3;
480 317
@@ -503,72 +340,46 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
503 } 340 }
504 f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1); 341 f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1);
505 f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2); 342 f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2);
506 /* Really should check for overflow, too */ 343 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); 344 return make_float (f3);
518} 345}
519 346
520DEFUN ("log", Flog, Slog, 1, 2, 0, 347DEFUN ("log", Flog, Slog, 1, 2, 0,
521 doc: /* Return the natural logarithm of ARG. 348 doc: /* Return the natural logarithm of ARG.
522If the optional argument BASE is given, return log ARG using that base. */) 349If the optional argument BASE is given, return log ARG using that base. */)
523 (register Lisp_Object arg, Lisp_Object base) 350 (Lisp_Object arg, Lisp_Object base)
524{ 351{
525 double d = extract_float (arg); 352 double d = extract_float (arg);
526 353
527#ifdef FLOAT_CHECK_DOMAIN
528 if (d <= 0.0)
529 domain_error2 ("log", arg, base);
530#endif
531 if (NILP (base)) 354 if (NILP (base))
532 IN_FLOAT (d = log (d), "log", arg); 355 d = log (d);
533 else 356 else
534 { 357 {
535 double b = extract_float (base); 358 double b = extract_float (base);
536 359
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) 360 if (b == 10.0)
542 IN_FLOAT2 (d = log10 (d), "log", arg, base); 361 d = log10 (d);
543 else 362 else
544 IN_FLOAT2 (d = log (d) / log (b), "log", arg, base); 363 d = log (d) / log (b);
545 } 364 }
546 return make_float (d); 365 return make_float (d);
547} 366}
548 367
549DEFUN ("log10", Flog10, Slog10, 1, 1, 0, 368DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
550 doc: /* Return the logarithm base 10 of ARG. */) 369 doc: /* Return the logarithm base 10 of ARG. */)
551 (register Lisp_Object arg) 370 (Lisp_Object arg)
552{ 371{
553 double d = extract_float (arg); 372 double d = extract_float (arg);
554#ifdef FLOAT_CHECK_DOMAIN 373 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); 374 return make_float (d);
560} 375}
561 376
562DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, 377DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
563 doc: /* Return the square root of ARG. */) 378 doc: /* Return the square root of ARG. */)
564 (register Lisp_Object arg) 379 (Lisp_Object arg)
565{ 380{
566 double d = extract_float (arg); 381 double d = extract_float (arg);
567#ifdef FLOAT_CHECK_DOMAIN 382 d = sqrt (d);
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); 383 return make_float (d);
573} 384}
574 385
@@ -576,83 +387,55 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
576 387
577DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, 388DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
578 doc: /* Return the inverse hyperbolic cosine of ARG. */) 389 doc: /* Return the inverse hyperbolic cosine of ARG. */)
579 (register Lisp_Object arg) 390 (Lisp_Object arg)
580{ 391{
581 double d = extract_float (arg); 392 double d = extract_float (arg);
582#ifdef FLOAT_CHECK_DOMAIN 393 d = acosh (d);
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); 394 return make_float (d);
592} 395}
593 396
594DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, 397DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
595 doc: /* Return the inverse hyperbolic sine of ARG. */) 398 doc: /* Return the inverse hyperbolic sine of ARG. */)
596 (register Lisp_Object arg) 399 (Lisp_Object arg)
597{ 400{
598 double d = extract_float (arg); 401 double d = extract_float (arg);
599#ifdef HAVE_INVERSE_HYPERBOLIC 402 d = asinh (d);
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); 403 return make_float (d);
605} 404}
606 405
607DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, 406DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
608 doc: /* Return the inverse hyperbolic tangent of ARG. */) 407 doc: /* Return the inverse hyperbolic tangent of ARG. */)
609 (register Lisp_Object arg) 408 (Lisp_Object arg)
610{ 409{
611 double d = extract_float (arg); 410 double d = extract_float (arg);
612#ifdef FLOAT_CHECK_DOMAIN 411 d = atanh (d);
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); 412 return make_float (d);
622} 413}
623 414
624DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, 415DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
625 doc: /* Return the hyperbolic cosine of ARG. */) 416 doc: /* Return the hyperbolic cosine of ARG. */)
626 (register Lisp_Object arg) 417 (Lisp_Object arg)
627{ 418{
628 double d = extract_float (arg); 419 double d = extract_float (arg);
629#ifdef FLOAT_CHECK_DOMAIN 420 d = cosh (d);
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); 421 return make_float (d);
635} 422}
636 423
637DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, 424DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
638 doc: /* Return the hyperbolic sine of ARG. */) 425 doc: /* Return the hyperbolic sine of ARG. */)
639 (register Lisp_Object arg) 426 (Lisp_Object arg)
640{ 427{
641 double d = extract_float (arg); 428 double d = extract_float (arg);
642#ifdef FLOAT_CHECK_DOMAIN 429 d = sinh (d);
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); 430 return make_float (d);
648} 431}
649 432
650DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, 433DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
651 doc: /* Return the hyperbolic tangent of ARG. */) 434 doc: /* Return the hyperbolic tangent of ARG. */)
652 (register Lisp_Object arg) 435 (Lisp_Object arg)
653{ 436{
654 double d = extract_float (arg); 437 double d = extract_float (arg);
655 IN_FLOAT (d = tanh (d), "tanh", arg); 438 d = tanh (d);
656 return make_float (d); 439 return make_float (d);
657} 440}
658#endif 441#endif
@@ -697,33 +480,11 @@ This is the same as the exponent of a float. */)
697 else 480 else
698 { 481 {
699#ifdef HAVE_LOGB 482#ifdef HAVE_LOGB
700 IN_FLOAT (value = logb (f), "logb", arg); 483 value = logb (f);
701#else 484#else
702#ifdef HAVE_FREXP
703 int ivalue; 485 int ivalue;
704 IN_FLOAT (frexp (f, &ivalue), "logb", arg); 486 frexp (f, &ivalue);
705 value = ivalue - 1; 487 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 488#endif
728 } 489 }
729 XSETINT (val, value); 490 XSETINT (val, value);
@@ -756,8 +517,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor,
756 if (! IEEE_FLOATING_POINT && f2 == 0) 517 if (! IEEE_FLOATING_POINT && f2 == 0)
757 xsignal0 (Qarith_error); 518 xsignal0 (Qarith_error);
758 519
759 IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor); 520 f1 = (*double_round) (f1 / f2);
760 FLOAT_TO_INT2 (f1, arg, name, arg, divisor); 521 if (FIXNUM_OVERFLOW_P (f1))
522 xsignal3 (Qrange_error, build_string (name), arg, divisor);
523 arg = make_number (f1);
761 return arg; 524 return arg;
762 } 525 }
763 526
@@ -773,10 +536,10 @@ rounding_driver (Lisp_Object arg, Lisp_Object divisor,
773 536
774 if (FLOATP (arg)) 537 if (FLOATP (arg))
775 { 538 {
776 double d; 539 double d = (*double_round) (XFLOAT_DATA (arg));
777 540 if (FIXNUM_OVERFLOW_P (d))
778 IN_FLOAT (d = (*double_round) (XFLOAT_DATA (arg)), name, arg); 541 xsignal2 (Qrange_error, build_string (name), arg);
779 FLOAT_TO_INT (d, arg, name, arg); 542 arg = make_number (d);
780 } 543 }
781 544
782 return arg; 545 return arg;
@@ -893,125 +656,57 @@ fmod_float (Lisp_Object x, Lisp_Object y)
893 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x); 656 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x);
894 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y); 657 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y);
895 658
896 if (! IEEE_FLOATING_POINT && f2 == 0) 659 f1 = fmod (f1, f2);
897 xsignal0 (Qarith_error);
898 660
899 /* If the "remainder" comes out with the wrong sign, fix it. */ 661 /* If the "remainder" comes out with the wrong sign, fix it. */
900 IN_FLOAT2 ((f1 = fmod (f1, f2), 662 if (f2 < 0 ? 0 < f1 : f1 < 0)
901 f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1), 663 f1 += f2;
902 "mod", x, y); 664
903 return make_float (f1); 665 return make_float (f1);
904} 666}
905 667
906/* It's not clear these are worth adding. */
907
908DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0, 668DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0,
909 doc: /* Return the smallest integer no less than ARG, as a float. 669 doc: /* Return the smallest integer no less than ARG, as a float.
910\(Round toward +inf.\) */) 670\(Round toward +inf.\) */)
911 (register Lisp_Object arg) 671 (Lisp_Object arg)
912{ 672{
913 double d = extract_float (arg); 673 double d = extract_float (arg);
914 IN_FLOAT (d = ceil (d), "fceiling", arg); 674 d = ceil (d);
915 return make_float (d); 675 return make_float (d);
916} 676}
917 677
918DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0, 678DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0,
919 doc: /* Return the largest integer no greater than ARG, as a float. 679 doc: /* Return the largest integer no greater than ARG, as a float.
920\(Round towards -inf.\) */) 680\(Round towards -inf.\) */)
921 (register Lisp_Object arg) 681 (Lisp_Object arg)
922{ 682{
923 double d = extract_float (arg); 683 double d = extract_float (arg);
924 IN_FLOAT (d = floor (d), "ffloor", arg); 684 d = floor (d);
925 return make_float (d); 685 return make_float (d);
926} 686}
927 687
928DEFUN ("fround", Ffround, Sfround, 1, 1, 0, 688DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
929 doc: /* Return the nearest integer to ARG, as a float. */) 689 doc: /* Return the nearest integer to ARG, as a float. */)
930 (register Lisp_Object arg) 690 (Lisp_Object arg)
931{ 691{
932 double d = extract_float (arg); 692 double d = extract_float (arg);
933 IN_FLOAT (d = emacs_rint (d), "fround", arg); 693 d = emacs_rint (d);
934 return make_float (d); 694 return make_float (d);
935} 695}
936 696
937DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, 697DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
938 doc: /* Truncate a floating point number to an integral float value. 698 doc: /* Truncate a floating point number to an integral float value.
939Rounds the value toward zero. */) 699Rounds the value toward zero. */)
940 (register Lisp_Object arg) 700 (Lisp_Object arg)
941{ 701{
942 double d = extract_float (arg); 702 double d = extract_float (arg);
943 if (d >= 0.0) 703 if (d >= 0.0)
944 IN_FLOAT (d = floor (d), "ftruncate", arg); 704 d = floor (d);
945 else 705 else
946 IN_FLOAT (d = ceil (d), "ftruncate", arg); 706 d = ceil (d);
947 return make_float (d); 707 return make_float (d);
948} 708}
949 709
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 710void
1016syms_of_floatfns (void) 711syms_of_floatfns (void)
1017{ 712{
diff --git a/src/fns.c b/src/fns.c
index 4d82e4e6e1d..95450c5e911 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -51,7 +51,7 @@ static Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
51 51
52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512; 52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512;
53 53
54static int internal_equal (Lisp_Object , Lisp_Object, int, int); 54static bool internal_equal (Lisp_Object, Lisp_Object, int, bool);
55 55
56DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 56DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
57 doc: /* Return the argument unchanged. */) 57 doc: /* Return the argument unchanged. */)
@@ -352,7 +352,7 @@ Symbols are also allowed; their print names are used instead. */)
352} 352}
353 353
354static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, 354static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args,
355 enum Lisp_Type target_type, int last_special); 355 enum Lisp_Type target_type, bool last_special);
356 356
357/* ARGSUSED */ 357/* ARGSUSED */
358Lisp_Object 358Lisp_Object
@@ -450,19 +450,19 @@ struct textprop_rec
450 450
451static Lisp_Object 451static Lisp_Object
452concat (ptrdiff_t nargs, Lisp_Object *args, 452concat (ptrdiff_t nargs, Lisp_Object *args,
453 enum Lisp_Type target_type, int last_special) 453 enum Lisp_Type target_type, bool last_special)
454{ 454{
455 Lisp_Object val; 455 Lisp_Object val;
456 register Lisp_Object tail; 456 Lisp_Object tail;
457 register Lisp_Object this; 457 Lisp_Object this;
458 ptrdiff_t toindex; 458 ptrdiff_t toindex;
459 ptrdiff_t toindex_byte = 0; 459 ptrdiff_t toindex_byte = 0;
460 register EMACS_INT result_len; 460 EMACS_INT result_len;
461 register EMACS_INT result_len_byte; 461 EMACS_INT result_len_byte;
462 ptrdiff_t argnum; 462 ptrdiff_t argnum;
463 Lisp_Object last_tail; 463 Lisp_Object last_tail;
464 Lisp_Object prev; 464 Lisp_Object prev;
465 int some_multibyte; 465 bool some_multibyte;
466 /* When we make a multibyte string, we can't copy text properties 466 /* When we make a multibyte string, we can't copy text properties
467 while concatenating each string because the length of resulting 467 while concatenating each string because the length of resulting
468 string can't be decided until we finish the whole concatenation. 468 string can't be decided until we finish the whole concatenation.
@@ -1527,11 +1527,14 @@ The value is actually the first element of LIST whose cdr equals KEY. */)
1527} 1527}
1528 1528
1529DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0, 1529DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
1530 doc: /* Delete by side effect any occurrences of ELT as a member of LIST. 1530 doc: /* Delete members of LIST which are `eq' to ELT, and return the result.
1531The modified LIST is returned. Comparison is done with `eq'. 1531More precisely, this function skips any members `eq' to ELT at the
1532If the first member of LIST is ELT, there is no way to remove it by side effect; 1532front of LIST, then removes members `eq' to ELT from the remaining
1533therefore, write `(setq foo (delq element foo))' 1533sublist by modifying its list structure, then returns the resulting
1534to be sure of changing the value of `foo'. */) 1534list.
1535
1536Write `(setq foo (delq element foo))' to be sure of correctly changing
1537the value of a list `foo'. */)
1535 (register Lisp_Object elt, Lisp_Object list) 1538 (register Lisp_Object elt, Lisp_Object list)
1536{ 1539{
1537 register Lisp_Object tail, prev; 1540 register Lisp_Object tail, prev;
@@ -1559,13 +1562,19 @@ to be sure of changing the value of `foo'. */)
1559} 1562}
1560 1563
1561DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0, 1564DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0,
1562 doc: /* Delete by side effect any occurrences of ELT as a member of SEQ. 1565 doc: /* Delete members of SEQ which are `equal' to ELT, and return the result.
1563SEQ must be a list, a vector, or a string. 1566SEQ must be a sequence (i.e. a list, a vector, or a string).
1564The modified SEQ is returned. Comparison is done with `equal'. 1567The return value is a sequence of the same type.
1565If SEQ is not a list, or the first member of SEQ is ELT, deleting it 1568
1566is not a side effect; it is simply using a different sequence. 1569If SEQ is a list, this behaves like `delq', except that it compares
1567Therefore, write `(setq foo (delete element foo))' 1570with `equal' instead of `eq'. In particular, it may remove elements
1568to be sure of changing the value of `foo'. */) 1571by altering the list structure.
1572
1573If SEQ is not a list, deletion is never performed destructively;
1574instead this function creates and returns a new vector or string.
1575
1576Write `(setq foo (delete element foo))' to be sure of correctly
1577changing the value of a sequence `foo'. */)
1569 (Lisp_Object elt, Lisp_Object seq) 1578 (Lisp_Object elt, Lisp_Object seq)
1570{ 1579{
1571 if (VECTORP (seq)) 1580 if (VECTORP (seq))
@@ -1988,10 +1997,10 @@ of strings. (`equal' ignores text properties.) */)
1988 1997
1989/* DEPTH is current depth of recursion. Signal an error if it 1998/* DEPTH is current depth of recursion. Signal an error if it
1990 gets too deep. 1999 gets too deep.
1991 PROPS, if non-nil, means compare string text properties too. */ 2000 PROPS means compare string text properties too. */
1992 2001
1993static int 2002static bool
1994internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int props) 2003internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
1995{ 2004{
1996 if (depth > 200) 2005 if (depth > 200)
1997 error ("Stack overflow in equal"); 2006 error ("Stack overflow in equal");
@@ -2589,9 +2598,9 @@ Normally the return value is FEATURE.
2589The normal messages at start and end of loading FILENAME are suppressed. */) 2598The normal messages at start and end of loading FILENAME are suppressed. */)
2590 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror) 2599 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror)
2591{ 2600{
2592 register Lisp_Object tem; 2601 Lisp_Object tem;
2593 struct gcpro gcpro1, gcpro2; 2602 struct gcpro gcpro1, gcpro2;
2594 int from_file = load_in_progress; 2603 bool from_file = load_in_progress;
2595 2604
2596 CHECK_SYMBOL (feature); 2605 CHECK_SYMBOL (feature);
2597 2606
@@ -2917,8 +2926,8 @@ static const short base64_char_to_value[128] =
2917 base64 characters. */ 2926 base64 characters. */
2918 2927
2919 2928
2920static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, int, int); 2929static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, bool, bool);
2921static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, int, 2930static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, bool,
2922 ptrdiff_t *); 2931 ptrdiff_t *);
2923 2932
2924DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2933DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
@@ -2953,7 +2962,7 @@ into shorter lines. */)
2953 encoded, length, NILP (no_line_break), 2962 encoded, length, NILP (no_line_break),
2954 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 2963 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
2955 if (encoded_length > allength) 2964 if (encoded_length > allength)
2956 abort (); 2965 emacs_abort ();
2957 2966
2958 if (encoded_length < 0) 2967 if (encoded_length < 0)
2959 { 2968 {
@@ -3009,7 +3018,7 @@ into shorter lines. */)
3009 encoded, length, NILP (no_line_break), 3018 encoded, length, NILP (no_line_break),
3010 STRING_MULTIBYTE (string)); 3019 STRING_MULTIBYTE (string));
3011 if (encoded_length > allength) 3020 if (encoded_length > allength)
3012 abort (); 3021 emacs_abort ();
3013 3022
3014 if (encoded_length < 0) 3023 if (encoded_length < 0)
3015 { 3024 {
@@ -3026,7 +3035,7 @@ into shorter lines. */)
3026 3035
3027static ptrdiff_t 3036static ptrdiff_t
3028base64_encode_1 (const char *from, char *to, ptrdiff_t length, 3037base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3029 int line_break, int multibyte) 3038 bool line_break, bool multibyte)
3030{ 3039{
3031 int counter = 0; 3040 int counter = 0;
3032 ptrdiff_t i = 0; 3041 ptrdiff_t i = 0;
@@ -3133,7 +3142,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3133 ptrdiff_t old_pos = PT; 3142 ptrdiff_t old_pos = PT;
3134 ptrdiff_t decoded_length; 3143 ptrdiff_t decoded_length;
3135 ptrdiff_t inserted_chars; 3144 ptrdiff_t inserted_chars;
3136 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3145 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3137 USE_SAFE_ALLOCA; 3146 USE_SAFE_ALLOCA;
3138 3147
3139 validate_region (&beg, &end); 3148 validate_region (&beg, &end);
@@ -3154,7 +3163,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3154 decoded, length, 3163 decoded, length,
3155 multibyte, &inserted_chars); 3164 multibyte, &inserted_chars);
3156 if (decoded_length > allength) 3165 if (decoded_length > allength)
3157 abort (); 3166 emacs_abort ();
3158 3167
3159 if (decoded_length < 0) 3168 if (decoded_length < 0)
3160 { 3169 {
@@ -3204,7 +3213,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3204 decoded_length = base64_decode_1 (SSDATA (string), decoded, length, 3213 decoded_length = base64_decode_1 (SSDATA (string), decoded, length,
3205 0, NULL); 3214 0, NULL);
3206 if (decoded_length > length) 3215 if (decoded_length > length)
3207 abort (); 3216 emacs_abort ();
3208 else if (decoded_length >= 0) 3217 else if (decoded_length >= 0)
3209 decoded_string = make_unibyte_string (decoded, decoded_length); 3218 decoded_string = make_unibyte_string (decoded, decoded_length);
3210 else 3219 else
@@ -3218,13 +3227,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3218} 3227}
3219 3228
3220/* Base64-decode the data at FROM of LENGTH bytes into TO. If 3229/* Base64-decode the data at FROM of LENGTH bytes into TO. If
3221 MULTIBYTE is nonzero, the decoded result should be in multibyte 3230 MULTIBYTE, the decoded result should be in multibyte
3222 form. If NCHARS_RETURN is not NULL, store the number of produced 3231 form. If NCHARS_RETURN is not NULL, store the number of produced
3223 characters in *NCHARS_RETURN. */ 3232 characters in *NCHARS_RETURN. */
3224 3233
3225static ptrdiff_t 3234static ptrdiff_t
3226base64_decode_1 (const char *from, char *to, ptrdiff_t length, 3235base64_decode_1 (const char *from, char *to, ptrdiff_t length,
3227 int multibyte, ptrdiff_t *nchars_return) 3236 bool multibyte, ptrdiff_t *nchars_return)
3228{ 3237{
3229 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */ 3238 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3230 char *e = to; 3239 char *e = to;
@@ -3340,7 +3349,7 @@ static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3340static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); 3349static struct Lisp_Hash_Table *check_hash_table (Lisp_Object);
3341static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *); 3350static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *);
3342static void maybe_resize_hash_table (struct Lisp_Hash_Table *); 3351static void maybe_resize_hash_table (struct Lisp_Hash_Table *);
3343static int sweep_weak_table (struct Lisp_Hash_Table *, int); 3352static bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
3344 3353
3345 3354
3346 3355
@@ -3432,10 +3441,10 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
3432 ***********************************************************************/ 3441 ***********************************************************************/
3433 3442
3434/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3443/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3435 HASH2 in hash table H using `eql'. Value is non-zero if KEY1 and 3444 HASH2 in hash table H using `eql'. Value is true if KEY1 and
3436 KEY2 are the same. */ 3445 KEY2 are the same. */
3437 3446
3438static int 3447static bool
3439cmpfn_eql (struct Lisp_Hash_Table *h, 3448cmpfn_eql (struct Lisp_Hash_Table *h,
3440 Lisp_Object key1, EMACS_UINT hash1, 3449 Lisp_Object key1, EMACS_UINT hash1,
3441 Lisp_Object key2, EMACS_UINT hash2) 3450 Lisp_Object key2, EMACS_UINT hash2)
@@ -3447,10 +3456,10 @@ cmpfn_eql (struct Lisp_Hash_Table *h,
3447 3456
3448 3457
3449/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3458/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3450 HASH2 in hash table H using `equal'. Value is non-zero if KEY1 and 3459 HASH2 in hash table H using `equal'. Value is true if KEY1 and
3451 KEY2 are the same. */ 3460 KEY2 are the same. */
3452 3461
3453static int 3462static bool
3454cmpfn_equal (struct Lisp_Hash_Table *h, 3463cmpfn_equal (struct Lisp_Hash_Table *h,
3455 Lisp_Object key1, EMACS_UINT hash1, 3464 Lisp_Object key1, EMACS_UINT hash1,
3456 Lisp_Object key2, EMACS_UINT hash2) 3465 Lisp_Object key2, EMACS_UINT hash2)
@@ -3460,10 +3469,10 @@ cmpfn_equal (struct Lisp_Hash_Table *h,
3460 3469
3461 3470
3462/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code 3471/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code
3463 HASH2 in hash table H using H->user_cmp_function. Value is non-zero 3472 HASH2 in hash table H using H->user_cmp_function. Value is true
3464 if KEY1 and KEY2 are the same. */ 3473 if KEY1 and KEY2 are the same. */
3465 3474
3466static int 3475static bool
3467cmpfn_user_defined (struct Lisp_Hash_Table *h, 3476cmpfn_user_defined (struct Lisp_Hash_Table *h,
3468 Lisp_Object key1, EMACS_UINT hash1, 3477 Lisp_Object key1, EMACS_UINT hash1,
3469 Lisp_Object key2, EMACS_UINT hash2) 3478 Lisp_Object key2, EMACS_UINT hash2)
@@ -3923,16 +3932,16 @@ hash_clear (struct Lisp_Hash_Table *h)
3923 Weak Hash Tables 3932 Weak Hash Tables
3924 ************************************************************************/ 3933 ************************************************************************/
3925 3934
3926/* Sweep weak hash table H. REMOVE_ENTRIES_P non-zero means remove 3935/* Sweep weak hash table H. REMOVE_ENTRIES_P means remove
3927 entries from the table that don't survive the current GC. 3936 entries from the table that don't survive the current GC.
3928 REMOVE_ENTRIES_P zero means mark entries that are in use. Value is 3937 !REMOVE_ENTRIES_P means mark entries that are in use. Value is
3929 non-zero if anything was marked. */ 3938 true if anything was marked. */
3930 3939
3931static int 3940static bool
3932sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) 3941sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p)
3933{ 3942{
3934 ptrdiff_t bucket, n; 3943 ptrdiff_t bucket, n;
3935 int marked; 3944 bool marked;
3936 3945
3937 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; 3946 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
3938 marked = 0; 3947 marked = 0;
@@ -3949,7 +3958,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3949 ptrdiff_t i = XFASTINT (idx); 3958 ptrdiff_t i = XFASTINT (idx);
3950 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); 3959 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
3951 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); 3960 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
3952 int remove_p; 3961 bool remove_p;
3953 3962
3954 if (EQ (h->weak, Qkey)) 3963 if (EQ (h->weak, Qkey))
3955 remove_p = !key_known_to_survive_p; 3964 remove_p = !key_known_to_survive_p;
@@ -3960,7 +3969,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3960 else if (EQ (h->weak, Qkey_and_value)) 3969 else if (EQ (h->weak, Qkey_and_value))
3961 remove_p = !(key_known_to_survive_p && value_known_to_survive_p); 3970 remove_p = !(key_known_to_survive_p && value_known_to_survive_p);
3962 else 3971 else
3963 abort (); 3972 emacs_abort ();
3964 3973
3965 next = HASH_NEXT (h, i); 3974 next = HASH_NEXT (h, i);
3966 3975
@@ -4022,7 +4031,7 @@ void
4022sweep_weak_hash_tables (void) 4031sweep_weak_hash_tables (void)
4023{ 4032{
4024 struct Lisp_Hash_Table *h, *used, *next; 4033 struct Lisp_Hash_Table *h, *used, *next;
4025 int marked; 4034 bool marked;
4026 4035
4027 /* Mark all keys and values that are in use. Keep on marking until 4036 /* Mark all keys and values that are in use. Keep on marking until
4028 there is no more change. This is necessary for cases like 4037 there is no more change. This is necessary for cases like
@@ -4256,7 +4265,7 @@ sxhash (Lisp_Object obj, int depth)
4256 break; 4265 break;
4257 4266
4258 default: 4267 default:
4259 abort (); 4268 emacs_abort ();
4260 } 4269 }
4261 4270
4262 return hash; 4271 return hash;
@@ -4674,7 +4683,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4674 coding_system = Vcoding_system_for_write; 4683 coding_system = Vcoding_system_for_write;
4675 else 4684 else
4676 { 4685 {
4677 int force_raw_text = 0; 4686 bool force_raw_text = 0;
4678 4687
4679 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system); 4688 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
4680 if (NILP (coding_system) 4689 if (NILP (coding_system)
diff --git a/src/font.c b/src/font.c
index cf9964f08f3..49a09bced28 100644
--- a/src/font.c
+++ b/src/font.c
@@ -216,13 +216,12 @@ static int num_font_drivers;
216 216
217 217
218/* Return a Lispy value of a font property value at STR and LEN bytes. 218/* Return a Lispy value of a font property value at STR and LEN bytes.
219 If STR is "*", return nil. 219 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, 220 consist entirely of one or more digits, return a symbol interned
221 return an integer. Otherwise, return a symbol interned from 221 from STR. Otherwise, return an integer. */
222 STR. */
223 222
224Lisp_Object 223Lisp_Object
225font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) 224font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
226{ 225{
227 ptrdiff_t i; 226 ptrdiff_t i;
228 Lisp_Object tem; 227 Lisp_Object tem;
@@ -306,7 +305,8 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec)
306 VAL is an integer. */ 305 VAL is an integer. */
307 306
308int 307int
309font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror) 308font_style_to_value (enum font_property_index prop, Lisp_Object val,
309 bool noerror)
310{ 310{
311 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); 311 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX);
312 int len; 312 int len;
@@ -385,7 +385,8 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
385} 385}
386 386
387Lisp_Object 387Lisp_Object
388font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face) 388font_style_symbolic (Lisp_Object font, enum font_property_index prop,
389 bool for_face)
389{ 390{
390 Lisp_Object val = AREF (font, prop); 391 Lisp_Object val = AREF (font, prop);
391 Lisp_Object table, elt; 392 Lisp_Object table, elt;
@@ -1101,7 +1102,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font)
1101 } 1102 }
1102 else 1103 else
1103 { 1104 {
1104 int wild_card_found = 0; 1105 bool wild_card_found = 0;
1105 Lisp_Object prop[XLFD_LAST_INDEX]; 1106 Lisp_Object prop[XLFD_LAST_INDEX];
1106 1107
1107 if (FONT_ENTITY_P (font)) 1108 if (FONT_ENTITY_P (font))
@@ -1337,7 +1338,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font)
1337 } 1338 }
1338 else if (*p == '-') 1339 else if (*p == '-')
1339 { 1340 {
1340 int decimal = 0, size_found = 1; 1341 bool decimal = 0, size_found = 1;
1341 for (q = p + 1; *q && *q != ':'; q++) 1342 for (q = p + 1; *q && *q != ':'; q++)
1342 if (! c_isdigit (*q)) 1343 if (! c_isdigit (*q))
1343 { 1344 {
@@ -1938,7 +1939,7 @@ generate_otf_features (Lisp_Object spec, char *features)
1938{ 1939{
1939 Lisp_Object val; 1940 Lisp_Object val;
1940 char *p; 1941 char *p;
1941 int asterisk; 1942 bool asterisk;
1942 1943
1943 p = features; 1944 p = features;
1944 *p = '\0'; 1945 *p = '\0';
@@ -2302,11 +2303,12 @@ font_update_sort_order (int *order)
2302 } 2303 }
2303} 2304}
2304 2305
2305static int 2306static bool
2306font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table) 2307font_check_otf_features (Lisp_Object script, Lisp_Object langsys,
2308 Lisp_Object features, Lisp_Object table)
2307{ 2309{
2308 Lisp_Object val; 2310 Lisp_Object val;
2309 int negative; 2311 bool negative;
2310 2312
2311 table = assq_no_quit (script, table); 2313 table = assq_no_quit (script, table);
2312 if (NILP (table)) 2314 if (NILP (table))
@@ -2342,7 +2344,7 @@ font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object fe
2342 2344
2343/* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */ 2345/* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */
2344 2346
2345static int 2347static bool
2346font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) 2348font_check_otf (Lisp_Object spec, Lisp_Object otf_capability)
2347{ 2349{
2348 Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil; 2350 Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil;
@@ -2376,7 +2378,7 @@ font_check_otf (Lisp_Object spec, Lisp_Object otf_capability)
2376/* Check if FONT (font-entity or font-object) matches with the font 2378/* Check if FONT (font-entity or font-object) matches with the font
2377 specification SPEC. */ 2379 specification SPEC. */
2378 2380
2379int 2381bool
2380font_match_p (Lisp_Object spec, Lisp_Object font) 2382font_match_p (Lisp_Object spec, Lisp_Object font)
2381{ 2383{
2382 Lisp_Object prop[FONT_SPEC_MAX], *props; 2384 Lisp_Object prop[FONT_SPEC_MAX], *props;
@@ -2694,7 +2696,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec)
2694 Lisp_Object ftype, val; 2696 Lisp_Object ftype, val;
2695 Lisp_Object list = Qnil; 2697 Lisp_Object list = Qnil;
2696 int size; 2698 int size;
2697 int need_filtering = 0; 2699 bool need_filtering = 0;
2698 int i; 2700 int i;
2699 2701
2700 eassert (FONT_SPEC_P (spec)); 2702 eassert (FONT_SPEC_P (spec));
@@ -3036,15 +3038,14 @@ font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs,
3036{ 3038{
3037 Lisp_Object font_entity; 3039 Lisp_Object font_entity;
3038 Lisp_Object prefer; 3040 Lisp_Object prefer;
3039 int result, i; 3041 int i;
3040 FRAME_PTR f = XFRAME (frame); 3042 FRAME_PTR f = XFRAME (frame);
3041 3043
3042 if (NILP (XCDR (entities)) 3044 if (NILP (XCDR (entities))
3043 && ASIZE (XCAR (entities)) == 1) 3045 && ASIZE (XCAR (entities)) == 1)
3044 { 3046 {
3045 font_entity = AREF (XCAR (entities), 0); 3047 font_entity = AREF (XCAR (entities), 0);
3046 if (c < 0 3048 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; 3049 return font_entity;
3049 return Qnil; 3050 return Qnil;
3050 } 3051 }
@@ -3618,7 +3619,7 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3618 Lisp_Object string) 3619 Lisp_Object string)
3619{ 3620{
3620 FRAME_PTR f; 3621 FRAME_PTR f;
3621 int multibyte; 3622 bool multibyte;
3622 Lisp_Object font_object; 3623 Lisp_Object font_object;
3623 3624
3624 multibyte = (NILP (string) 3625 multibyte = (NILP (string)
diff --git a/src/font.h b/src/font.h
index 3b90bc2ab8a..0475eb665dd 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,
diff --git a/src/fontset.c b/src/fontset.c
index 01e38fe45e5..2b955fe6b11 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -185,21 +185,12 @@ void (*check_window_system_func) (void);
185 185
186 186
187/* Prototype declarations for static functions. */ 187/* 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); 188static 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 189
199/* Return 1 if ID is a valid fontset id, else return 0. 190/* Return true if ID is a valid fontset id.
200 Optimized away if ENABLE_CHECKING is not defined. */ 191 Optimized away if ENABLE_CHECKING is not defined. */
201 192
202static int 193static bool
203fontset_id_valid_p (int id) 194fontset_id_valid_p (int id)
204{ 195{
205 return (id >= 0 && id < ASIZE (Vfontset_table) - 1); 196 return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
@@ -413,7 +404,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
413 Lisp_Object vec, font_object; 404 Lisp_Object vec, font_object;
414 int size; 405 int size;
415 int i; 406 int i;
416 int score_changed = 0; 407 bool score_changed = 0;
417 408
418 if (font) 409 if (font)
419 XSETFONT (font_object, font); 410 XSETFONT (font_object, font);
@@ -544,10 +535,11 @@ fontset_get_font_group (Lisp_Object fontset, int c)
544 ID is a charset-id that must be preferred, or -1 meaning no 535 ID is a charset-id that must be preferred, or -1 meaning no
545 preference. 536 preference.
546 537
547 If FALLBACK is nonzero, search only fallback fonts. */ 538 If FALLBACK, search only fallback fonts. */
548 539
549static Lisp_Object 540static Lisp_Object
550fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback) 541fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id,
542 bool fallback)
551{ 543{
552 Lisp_Object vec, font_group; 544 Lisp_Object vec, font_group;
553 int i, charset_matched = 0, found_index; 545 int i, charset_matched = 0, found_index;
@@ -919,11 +911,11 @@ free_face_fontset (FRAME_PTR f, struct face *face)
919 911
920 912
921#if 0 913#if 0
922/* Return 1 if FACE is suitable for displaying character C. 914/* Return true if FACE is suitable for displaying character C.
923 Otherwise return 0. Called from the macro FACE_SUITABLE_FOR_CHAR_P 915 Called from the macro FACE_SUITABLE_FOR_CHAR_P
924 when C is not an ASCII character. */ 916 when C is not an ASCII character. */
925 917
926int 918bool
927face_suitable_for_char_p (struct face *face, int c) 919face_suitable_for_char_p (struct face *face, int c)
928{ 920{
929 Lisp_Object fontset, rfont_def; 921 Lisp_Object fontset, rfont_def;
@@ -1470,7 +1462,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1470 Lisp_Object range_list; 1462 Lisp_Object range_list;
1471 struct charset *charset = NULL; 1463 struct charset *charset = NULL;
1472 Lisp_Object fontname; 1464 Lisp_Object fontname;
1473 int ascii_changed = 0; 1465 bool ascii_changed = 0;
1474 1466
1475 fontset = check_fontset_name (name, &frame); 1467 fontset = check_fontset_name (name, &frame);
1476 1468
diff --git a/src/frame.c b/src/frame.c
index 968cb4905a2..9b12842bf89 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -214,7 +214,7 @@ See also `frame-live-p'. */)
214 case output_ns: 214 case output_ns:
215 return Qns; 215 return Qns;
216 default: 216 default:
217 abort (); 217 emacs_abort ();
218 } 218 }
219} 219}
220 220
@@ -620,7 +620,7 @@ affects all frames on the same terminal device. */)
620#ifdef MSDOS 620#ifdef MSDOS
621 if (sf->output_method != output_msdos_raw 621 if (sf->output_method != output_msdos_raw
622 && sf->output_method != output_termcap) 622 && sf->output_method != output_termcap)
623 abort (); 623 emacs_abort ();
624#else /* not MSDOS */ 624#else /* not MSDOS */
625 625
626#ifdef WINDOWSNT /* This should work now! */ 626#ifdef WINDOWSNT /* This should work now! */
@@ -767,7 +767,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
767 Lisp_Object focus; 767 Lisp_Object focus;
768 768
769 if (!FRAMEP (XCAR (tail))) 769 if (!FRAMEP (XCAR (tail)))
770 abort (); 770 emacs_abort ();
771 771
772 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); 772 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
773 773
@@ -897,7 +897,7 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
897 897
898 /* There must always be at least one frame in Vframe_list. */ 898 /* There must always be at least one frame in Vframe_list. */
899 if (! CONSP (Vframe_list)) 899 if (! CONSP (Vframe_list))
900 abort (); 900 emacs_abort ();
901 901
902 /* If this frame is dead, it won't be in Vframe_list, and we'll loop 902 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
903 forever. Forestall that. */ 903 forever. Forestall that. */
@@ -975,7 +975,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf)
975 975
976 /* There must always be at least one frame in Vframe_list. */ 976 /* There must always be at least one frame in Vframe_list. */
977 if (! CONSP (Vframe_list)) 977 if (! CONSP (Vframe_list))
978 abort (); 978 emacs_abort ();
979 979
980 prev = Qnil; 980 prev = Qnil;
981 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 981 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
@@ -984,7 +984,7 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf)
984 984
985 f = XCAR (tail); 985 f = XCAR (tail);
986 if (!FRAMEP (f)) 986 if (!FRAMEP (f))
987 abort (); 987 emacs_abort ();
988 988
989 if (EQ (frame, f) && !NILP (prev)) 989 if (EQ (frame, f) && !NILP (prev))
990 return prev; 990 return prev;
@@ -1385,7 +1385,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1385 1385
1386 this = XCAR (frames); 1386 this = XCAR (frames);
1387 if (!FRAMEP (this)) 1387 if (!FRAMEP (this))
1388 abort (); 1388 emacs_abort ();
1389 f1 = XFRAME (this); 1389 f1 = XFRAME (this);
1390 1390
1391 if (kb == FRAME_KBOARD (f1)) 1391 if (kb == FRAME_KBOARD (f1))
@@ -1421,7 +1421,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1421 1421
1422 this = XCAR (frames); 1422 this = XCAR (frames);
1423 if (!FRAMEP (this)) 1423 if (!FRAMEP (this))
1424 abort (); 1424 emacs_abort ();
1425 f1 = XFRAME (this); 1425 f1 = XFRAME (this);
1426 1426
1427 /* Consider only frames on the same kboard 1427 /* Consider only frames on the same kboard
@@ -1447,7 +1447,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1447 that is prohibited at the top; you can't delete surrogate 1447 that is prohibited at the top; you can't delete surrogate
1448 minibuffer frames. */ 1448 minibuffer frames. */
1449 if (NILP (frame_with_minibuf)) 1449 if (NILP (frame_with_minibuf))
1450 abort (); 1450 emacs_abort ();
1451 1451
1452 kset_default_minibuffer_frame (kb, frame_with_minibuf); 1452 kset_default_minibuffer_frame (kb, frame_with_minibuf);
1453 } 1453 }
@@ -2108,7 +2108,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2108 swap_in_global_binding (sym); 2108 swap_in_global_binding (sym);
2109 break; 2109 break;
2110 } 2110 }
2111 default: abort (); 2111 default: emacs_abort ();
2112 } 2112 }
2113 } 2113 }
2114 2114
@@ -3835,7 +3835,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
3835 } 3835 }
3836 3836
3837 default: 3837 default:
3838 abort (); 3838 emacs_abort ();
3839 } 3839 }
3840 } 3840 }
3841 else 3841 else
diff --git a/src/frame.h b/src/frame.h
index 1fe3ebd9182..661ea2ea67c 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..0c2109a0f8e 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -659,7 +659,14 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
659 { 659 {
660 /* If W has a vertical border to its left, don't draw over it. */ 660 /* If W has a vertical border to its left, don't draw over it. */
661 wd -= ((!WINDOW_LEFTMOST_P (w) 661 wd -= ((!WINDOW_LEFTMOST_P (w)
662 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) 662 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
663 /* But don't reduce the fringe width if the window
664 has a left margin, because that means we are not
665 in danger of drawing over the vertical border,
666 and OTOH leaving out that one pixel leaves behind
667 traces of the cursor, if it was in column zero
668 before drawing non-empty margin area. */
669 && NILP (w->left_margin_cols))
663 ? 1 : 0); 670 ? 1 : 0);
664 p.bx = x - wd; 671 p.bx = x - wd;
665 p.nx = wd; 672 p.nx = wd;
diff --git a/src/ftfont.c b/src/ftfont.c
index e16f967f596..a85773a9a21 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -45,7 +45,7 @@ static Lisp_Object Qfreetype;
45static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; 45static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
46 46
47/* Flag to tell if FcInit is already called or not. */ 47/* Flag to tell if FcInit is already called or not. */
48static int fc_initialized; 48static bool fc_initialized;
49 49
50/* Handle to a FreeType library instance. */ 50/* Handle to a FreeType library instance. */
51static FT_Library ft_library; 51static FT_Library ft_library;
@@ -65,7 +65,7 @@ struct ftfont_info
65#ifdef HAVE_LIBOTF 65#ifdef HAVE_LIBOTF
66 /* The following four members must be here in this order to be 66 /* The following four members must be here in this order to be
67 compatible with struct xftfont_info (in xftfont.c). */ 67 compatible with struct xftfont_info (in xftfont.c). */
68 int maybe_otf; /* Flag to tell if this may be OTF or not. */ 68 bool maybe_otf; /* Flag to tell if this may be OTF or not. */
69 OTF *otf; 69 OTF *otf;
70#endif /* HAVE_LIBOTF */ 70#endif /* HAVE_LIBOTF */
71 FT_Size ft_size; 71 FT_Size ft_size;
@@ -543,9 +543,9 @@ struct font_driver ftfont_driver =
543 /* We can't draw a text without device dependent functions. */ 543 /* We can't draw a text without device dependent functions. */
544 NULL, /* draw */ 544 NULL, /* draw */
545 ftfont_get_bitmap, 545 ftfont_get_bitmap,
546 NULL, /* get_bitmap */
547 NULL, /* free_bitmap */ 546 NULL, /* free_bitmap */
548 NULL, /* get_outline */ 547 NULL, /* get_outline */
548 NULL, /* free_outline */
549 ftfont_anchor_point, 549 ftfont_anchor_point,
550#ifdef HAVE_LIBOTF 550#ifdef HAVE_LIBOTF
551 ftfont_otf_capability, 551 ftfont_otf_capability,
@@ -661,7 +661,8 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
661{ 661{
662 struct OpenTypeSpec *spec = malloc (sizeof *spec); 662 struct OpenTypeSpec *spec = malloc (sizeof *spec);
663 Lisp_Object val; 663 Lisp_Object val;
664 int i, j, negative; 664 int i, j;
665 bool negative;
665 666
666 if (! spec) 667 if (! spec)
667 return NULL; 668 return NULL;
@@ -1185,7 +1186,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1185 FT_Size ft_size; 1186 FT_Size ft_size;
1186 FT_UInt size; 1187 FT_UInt size;
1187 Lisp_Object val, filename, idx, cache, font_object; 1188 Lisp_Object val, filename, idx, cache, font_object;
1188 int scalable; 1189 bool scalable;
1189 int spacing; 1190 int spacing;
1190 char name[256]; 1191 char name[256];
1191 int i, len; 1192 int i, len;
@@ -1243,7 +1244,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1243 ftfont_info->ft_size = ft_face->size; 1244 ftfont_info->ft_size = ft_face->size;
1244 ftfont_info->index = XINT (idx); 1245 ftfont_info->index = XINT (idx);
1245#ifdef HAVE_LIBOTF 1246#ifdef HAVE_LIBOTF
1246 ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; 1247 ftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
1247 ftfont_info->otf = NULL; 1248 ftfont_info->otf = NULL;
1248#endif /* HAVE_LIBOTF */ 1249#endif /* HAVE_LIBOTF */
1249 /* This means that there's no need of transformation. */ 1250 /* This means that there's no need of transformation. */
@@ -1392,7 +1393,8 @@ ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct
1392 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1393 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
1393 FT_Face ft_face = ftfont_info->ft_size->face; 1394 FT_Face ft_face = ftfont_info->ft_size->face;
1394 int width = 0; 1395 int width = 0;
1395 int i, first; 1396 int i;
1397 bool first;
1396 1398
1397 if (ftfont_info->ft_size != ft_face->size) 1399 if (ftfont_info->ft_size != ft_face->size)
1398 FT_Activate_Size (ftfont_info->ft_size); 1400 FT_Activate_Size (ftfont_info->ft_size);
@@ -1630,7 +1632,7 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring,
1630 FT_Glyph_Metrics *m; 1632 FT_Glyph_Metrics *m;
1631 1633
1632 if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) 1634 if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0)
1633 abort (); 1635 emacs_abort ();
1634 m = &ft_face->glyph->metrics; 1636 m = &ft_face->glyph->metrics;
1635 if (flt_font_ft->matrix) 1637 if (flt_font_ft->matrix)
1636 { 1638 {
@@ -1682,10 +1684,12 @@ ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec)
1682 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; 1684 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font;
1683 OTF *otf = flt_font_ft->otf; 1685 OTF *otf = flt_font_ft->otf;
1684 OTF_Tag *tags; 1686 OTF_Tag *tags;
1685 int i, n, negative; 1687 int i, n;
1688 bool negative;
1686 1689
1687 if (FEATURE_ANY (0) && FEATURE_ANY (1)) 1690 if (FEATURE_ANY (0) && FEATURE_ANY (1))
1688 /* Return 1 iff any of GSUB or GPOS support the script (and language). */ 1691 /* Return true iff any of GSUB or GPOS support the script (and
1692 language). */
1689 return (otf 1693 return (otf
1690 && (OTF_check_features (otf, 0, spec->script, spec->langsys, 1694 && (OTF_check_features (otf, 0, spec->script, spec->langsys,
1691 NULL, 0) > 0 1695 NULL, 0) > 0
@@ -2390,7 +2394,7 @@ ftfont_drive_otf (MFLTFont *font, MFLTOtfSpec *spec, MFLTGlyphString *in,
2390 2394
2391static MFLTGlyphString gstring; 2395static MFLTGlyphString gstring;
2392 2396
2393static int m17n_flt_initialized; 2397static bool m17n_flt_initialized;
2394 2398
2395static Lisp_Object 2399static Lisp_Object
2396ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, 2400ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
@@ -2400,7 +2404,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2400 ptrdiff_t i; 2404 ptrdiff_t i;
2401 struct MFLTFontFT flt_font_ft; 2405 struct MFLTFontFT flt_font_ft;
2402 MFLT *flt = NULL; 2406 MFLT *flt = NULL;
2403 int with_variation_selector = 0; 2407 bool with_variation_selector = 0;
2404 2408
2405 if (! m17n_flt_initialized) 2409 if (! m17n_flt_initialized)
2406 { 2410 {
@@ -2421,7 +2425,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2421 break; 2425 break;
2422 c = LGLYPH_CHAR (g); 2426 c = LGLYPH_CHAR (g);
2423 if (CHAR_VARIATION_SELECTOR_P (c)) 2427 if (CHAR_VARIATION_SELECTOR_P (c))
2424 with_variation_selector++; 2428 with_variation_selector = 1;
2425 } 2429 }
2426 2430
2427 len = i; 2431 len = i;
diff --git a/src/ftxfont.c b/src/ftxfont.c
index 6ebe0798b4e..c705ede62c4 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -43,14 +43,6 @@ static
43#endif 43#endif
44struct font_driver ftxfont_driver; 44struct font_driver ftxfont_driver;
45 45
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 46struct ftxfont_frame_data
55{ 47{
56 /* Background and foreground colors. */ 48 /* Background and foreground colors. */
@@ -143,7 +135,9 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba
143} 135}
144 136
145static int 137static 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) 138ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font,
139 unsigned int code, int x, int y, XPoint *p, int size,
140 int *n, bool flush)
147{ 141{
148 struct font_bitmap bitmap; 142 struct font_bitmap bitmap;
149 unsigned char *b; 143 unsigned char *b;
@@ -232,13 +226,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); 226 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
233} 227}
234 228
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 229static Lisp_Object
243ftxfont_list (Lisp_Object frame, Lisp_Object spec) 230ftxfont_list (Lisp_Object frame, Lisp_Object spec)
244{ 231{
@@ -280,7 +267,8 @@ ftxfont_close (FRAME_PTR f, struct font *font)
280} 267}
281 268
282static int 269static int
283ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 270ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
271 bool with_background)
284{ 272{
285 FRAME_PTR f = s->f; 273 FRAME_PTR f = s->f;
286 struct face *face = s->face; 274 struct face *face = s->face;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index f0d2c022f0c..884574e1062 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -21,7 +21,6 @@ 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> 25#include <setjmp.h>
27 26
@@ -254,7 +253,7 @@ void
254free_widget_value (widget_value *wv) 253free_widget_value (widget_value *wv)
255{ 254{
256 if (wv->free_list) 255 if (wv->free_list)
257 abort (); 256 emacs_abort ();
258 257
259 if (malloc_cpt > 25) 258 if (malloc_cpt > 25)
260 { 259 {
@@ -1979,7 +1978,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 1978 /* 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 1979 library linuxthreads hangs when the Gnome file chooser backend creates
1981 threads. */ 1980 threads. */
1982 sigblock (sigmask (__SIGRTMIN)); 1981 sigset_t blocked;
1982 sigemptyset (&blocked);
1983 sigaddset (&blocked, __SIGRTMIN);
1984 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1983#endif /* HAVE_PTHREAD */ 1985#endif /* HAVE_PTHREAD */
1984 1986
1985#ifdef HAVE_GTK_FILE_SELECTION_NEW 1987#ifdef HAVE_GTK_FILE_SELECTION_NEW
@@ -2001,7 +2003,7 @@ xg_get_file_name (FRAME_PTR f,
2001 filesel_done = xg_dialog_run (f, w); 2003 filesel_done = xg_dialog_run (f, w);
2002 2004
2003#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2005#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2004 sigunblock (sigmask (__SIGRTMIN)); 2006 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2005#endif 2007#endif
2006 2008
2007 if (filesel_done == GTK_RESPONSE_OK) 2009 if (filesel_done == GTK_RESPONSE_OK)
@@ -2057,7 +2059,10 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2057 Lisp_Object font = Qnil; 2059 Lisp_Object font = Qnil;
2058 2060
2059#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2061#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2060 sigblock (sigmask (__SIGRTMIN)); 2062 sigset_t blocked;
2063 sigemptyset (&blocked);
2064 sigaddset (&blocked, __SIGRTMIN);
2065 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2061#endif /* HAVE_PTHREAD */ 2066#endif /* HAVE_PTHREAD */
2062 2067
2063 w = gtk_font_chooser_dialog_new 2068 w = gtk_font_chooser_dialog_new
@@ -2086,7 +2091,7 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2086 done = xg_dialog_run (f, w); 2091 done = xg_dialog_run (f, w);
2087 2092
2088#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2093#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2089 sigunblock (sigmask (__SIGRTMIN)); 2094 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2090#endif 2095#endif
2091 2096
2092 if (done == GTK_RESPONSE_OK) 2097 if (done == GTK_RESPONSE_OK)
@@ -3519,7 +3524,7 @@ xg_store_widget_in_map (GtkWidget *w)
3519 } 3524 }
3520 3525
3521 /* Should never end up here */ 3526 /* Should never end up here */
3522 abort (); 3527 emacs_abort ();
3523} 3528}
3524 3529
3525/* Remove pointer at IDX from id_to_widget. 3530/* Remove pointer at IDX from id_to_widget.
@@ -4087,7 +4092,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
4087 else 4092 else
4088 { 4093 {
4089 fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n"); 4094 fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n");
4090 abort (); 4095 emacs_abort ();
4091 } 4096 }
4092 } 4097 }
4093 else if (store_type == GTK_IMAGE_ICON_NAME) 4098 else if (store_type == GTK_IMAGE_ICON_NAME)
@@ -4102,7 +4107,7 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
4102 else 4107 else
4103 { 4108 {
4104 fprintf (stderr, "internal error: store_type is %d\n", store_type); 4109 fprintf (stderr, "internal error: store_type is %d\n", store_type);
4105 abort (); 4110 emacs_abort ();
4106 } 4111 }
4107 } 4112 }
4108 if (wmenuimage) 4113 if (wmenuimage)
diff --git a/src/image.c b/src/image.c
index a067dae7737..4ec6105d72d 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
@@ -841,7 +840,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
841 break; 840 break;
842 841
843 default: 842 default:
844 abort (); 843 emacs_abort ();
845 break; 844 break;
846 } 845 }
847 846
@@ -5517,13 +5516,13 @@ init_png_functions (Lisp_Object libraries)
5517 5516
5518 5517
5519#if (PNG_LIBPNG_VER < 10500) 5518#if (PNG_LIBPNG_VER < 10500)
5520#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) 5519#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1))
5521#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5520#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5522#else 5521#else
5523/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ 5522/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
5524#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) 5523#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1))
5525#define PNG_JMPBUF(ptr) \ 5524#define PNG_JMPBUF(ptr) \
5526 (*fn_png_set_longjmp_fn ((ptr), longjmp, sizeof (jmp_buf))) 5525 (*fn_png_set_longjmp_fn ((ptr), _longjmp, sizeof (jmp_buf)))
5527#endif 5526#endif
5528 5527
5529/* Error and warning handlers installed when the PNG library 5528/* Error and warning handlers installed when the PNG library
@@ -5696,7 +5695,7 @@ png_load (struct frame *f, struct image *img)
5696 5695
5697 /* Set error jump-back. We come back here when the PNG library 5696 /* Set error jump-back. We come back here when the PNG library
5698 detects an error. */ 5697 detects an error. */
5699 if (setjmp (PNG_JMPBUF (png_ptr))) 5698 if (_setjmp (PNG_JMPBUF (png_ptr)))
5700 { 5699 {
5701 error: 5700 error:
5702 if (png_ptr) 5701 if (png_ptr)
@@ -6114,7 +6113,7 @@ static _Noreturn void
6114my_error_exit (j_common_ptr cinfo) 6113my_error_exit (j_common_ptr cinfo)
6115{ 6114{
6116 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6115 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6117 longjmp (mgr->setjmp_buffer, 1); 6116 _longjmp (mgr->setjmp_buffer, 1);
6118} 6117}
6119 6118
6120 6119
@@ -6365,7 +6364,7 @@ jpeg_load (struct frame *f, struct image *img)
6365 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6364 cinfo.err = fn_jpeg_std_error (&mgr.pub);
6366 mgr.pub.error_exit = my_error_exit; 6365 mgr.pub.error_exit = my_error_exit;
6367 6366
6368 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 6367 if ((rc = _setjmp (mgr.setjmp_buffer)) != 0)
6369 { 6368 {
6370 if (rc == 1) 6369 if (rc == 1)
6371 { 6370 {
@@ -6411,12 +6410,12 @@ jpeg_load (struct frame *f, struct image *img)
6411 if (!check_image_size (f, width, height)) 6410 if (!check_image_size (f, width, height))
6412 { 6411 {
6413 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6412 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
6414 longjmp (mgr.setjmp_buffer, 2); 6413 _longjmp (mgr.setjmp_buffer, 2);
6415 } 6414 }
6416 6415
6417 /* Create X image and pixmap. */ 6416 /* Create X image and pixmap. */
6418 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6417 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6419 longjmp (mgr.setjmp_buffer, 2); 6418 _longjmp (mgr.setjmp_buffer, 2);
6420 6419
6421 /* Allocate colors. When color quantization is used, 6420 /* Allocate colors. When color quantization is used,
6422 cinfo.actual_number_of_colors has been set with the number of 6421 cinfo.actual_number_of_colors has been set with the number of
diff --git a/src/indent.c b/src/indent.c
index 160b8c7479e..c60315a7f6e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -122,7 +122,7 @@ disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *w
122 int i; 122 int i;
123 123
124 if (widthtab->header.size != 256) 124 if (widthtab->header.size != 256)
125 abort (); 125 emacs_abort ();
126 126
127 for (i = 0; i < 256; i++) 127 for (i = 0; i < 256; i++)
128 if (character_width (i, disptab) 128 if (character_width (i, disptab)
@@ -144,7 +144,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))); 144 bset_width_table (buf, Fmake_vector (make_number (256), make_number (0)));
145 widthtab = XVECTOR (BVAR (buf, width_table)); 145 widthtab = XVECTOR (BVAR (buf, width_table));
146 if (widthtab->header.size != 256) 146 if (widthtab->header.size != 256)
147 abort (); 147 emacs_abort ();
148 148
149 for (i = 0; i < 256; i++) 149 for (i = 0; i < 256; i++)
150 XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); 150 XSETFASTINT (widthtab->contents[i], character_width (i, disptab));
diff --git a/src/insdel.c b/src/insdel.c
index da258c19a1e..604a9bbf3df 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -69,13 +69,13 @@ check_markers (void)
69 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) 69 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
70 { 70 {
71 if (tail->buffer->text != current_buffer->text) 71 if (tail->buffer->text != current_buffer->text)
72 abort (); 72 emacs_abort ();
73 if (tail->charpos > Z) 73 if (tail->charpos > Z)
74 abort (); 74 emacs_abort ();
75 if (tail->bytepos > Z_BYTE) 75 if (tail->bytepos > Z_BYTE)
76 abort (); 76 emacs_abort ();
77 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos))) 77 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos)))
78 abort (); 78 emacs_abort ();
79 } 79 }
80} 80}
81 81
@@ -808,7 +808,7 @@ insert_1_both (const char *string,
808#ifdef BYTE_COMBINING_DEBUG 808#ifdef BYTE_COMBINING_DEBUG
809 if (count_combining_before (string, nbytes, PT, PT_BYTE) 809 if (count_combining_before (string, nbytes, PT, PT_BYTE)
810 || count_combining_after (string, nbytes, PT, PT_BYTE)) 810 || count_combining_after (string, nbytes, PT, PT_BYTE))
811 abort (); 811 emacs_abort ();
812#endif 812#endif
813 813
814 /* Record deletion of the surrounding text that combines with 814 /* Record deletion of the surrounding text that combines with
@@ -943,7 +943,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. */ 943 the text that has been stored by copy_text. */
944 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) 944 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)
945 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) 945 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE))
946 abort (); 946 emacs_abort ();
947#endif 947#endif
948 948
949 record_insert (PT, nchars); 949 record_insert (PT, nchars);
@@ -1126,7 +1126,7 @@ insert_from_buffer_1 (struct buffer *buf,
1126 the text that has been stored by copy_text. */ 1126 the text that has been stored by copy_text. */
1127 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE) 1127 if (count_combining_before (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)
1128 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE)) 1128 || count_combining_after (GPT_ADDR, outgoing_nbytes, PT, PT_BYTE))
1129 abort (); 1129 emacs_abort ();
1130#endif 1130#endif
1131 1131
1132 record_insert (PT, nchars); 1132 record_insert (PT, nchars);
@@ -1187,7 +1187,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1187#ifdef BYTE_COMBINING_DEBUG 1187#ifdef BYTE_COMBINING_DEBUG
1188 if (count_combining_before (GPT_ADDR, len_byte, from, from_byte) 1188 if (count_combining_before (GPT_ADDR, len_byte, from, from_byte)
1189 || count_combining_after (GPT_ADDR, len_byte, from, from_byte)) 1189 || count_combining_after (GPT_ADDR, len_byte, from, from_byte))
1190 abort (); 1190 emacs_abort ();
1191#endif 1191#endif
1192 1192
1193 if (STRINGP (prev_text)) 1193 if (STRINGP (prev_text))
@@ -1370,7 +1370,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1370 the text that has been stored by copy_text. */ 1370 the text that has been stored by copy_text. */
1371 if (count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte) 1371 if (count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte)
1372 || count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte)) 1372 || count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte))
1373 abort (); 1373 emacs_abort ();
1374#endif 1374#endif
1375 1375
1376 if (! EQ (BVAR (current_buffer, undo_list), Qt)) 1376 if (! EQ (BVAR (current_buffer, undo_list), Qt))
@@ -1496,7 +1496,7 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1496 the text that has been stored by copy_text. */ 1496 the text that has been stored by copy_text. */
1497 if (count_combining_before (GPT_ADDR, insbytes, from, from_byte) 1497 if (count_combining_before (GPT_ADDR, insbytes, from, from_byte)
1498 || count_combining_after (GPT_ADDR, insbytes, from, from_byte)) 1498 || count_combining_after (GPT_ADDR, insbytes, from, from_byte))
1499 abort (); 1499 emacs_abort ();
1500#endif 1500#endif
1501 1501
1502 GAP_SIZE -= insbytes; 1502 GAP_SIZE -= insbytes;
@@ -1704,7 +1704,7 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1704#ifdef BYTE_COMBINING_DEBUG 1704#ifdef BYTE_COMBINING_DEBUG
1705 if (count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte), 1705 if (count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte),
1706 Z_BYTE - to_byte, from, from_byte)) 1706 Z_BYTE - to_byte, from, from_byte))
1707 abort (); 1707 emacs_abort ();
1708#endif 1708#endif
1709 1709
1710 if (ret_string || ! EQ (BVAR (current_buffer, undo_list), Qt)) 1710 if (ret_string || ! EQ (BVAR (current_buffer, undo_list), Qt))
diff --git a/src/intervals.c b/src/intervals.c
index 49d61b2f9b0..e508f968963 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -199,13 +199,13 @@ intervals_equal (INTERVAL i0, INTERVAL i1)
199 i0_sym = XCAR (i0_cdr); 199 i0_sym = XCAR (i0_cdr);
200 i0_cdr = XCDR (i0_cdr); 200 i0_cdr = XCDR (i0_cdr);
201 if (!CONSP (i0_cdr)) 201 if (!CONSP (i0_cdr))
202 return 0; /* abort (); */ 202 return 0;
203 i1_val = i1->plist; 203 i1_val = i1->plist;
204 while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym)) 204 while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym))
205 { 205 {
206 i1_val = XCDR (i1_val); 206 i1_val = XCDR (i1_val);
207 if (!CONSP (i1_val)) 207 if (!CONSP (i1_val))
208 return 0; /* abort (); */ 208 return 0;
209 i1_val = XCDR (i1_val); 209 i1_val = XCDR (i1_val);
210 } 210 }
211 211
@@ -223,7 +223,7 @@ intervals_equal (INTERVAL i0, INTERVAL i1)
223 223
224 i1_cdr = XCDR (i1_cdr); 224 i1_cdr = XCDR (i1_cdr);
225 if (!CONSP (i1_cdr)) 225 if (!CONSP (i1_cdr))
226 return 0; /* abort (); */ 226 return 0;
227 i1_cdr = XCDR (i1_cdr); 227 i1_cdr = XCDR (i1_cdr);
228 } 228 }
229 229
@@ -1253,7 +1253,7 @@ delete_interval (register INTERVAL i)
1253 else if (STRINGP (owner)) 1253 else if (STRINGP (owner))
1254 set_string_intervals (owner, parent); 1254 set_string_intervals (owner, parent);
1255 else 1255 else
1256 abort (); 1256 emacs_abort ();
1257 1257
1258 return; 1258 return;
1259 } 1259 }
@@ -1408,7 +1408,7 @@ offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length)
1408 start, length); 1408 start, length);
1409 else 1409 else
1410 { 1410 {
1411 IF_LINT (if (length < - TYPE_MAXIMUM (ptrdiff_t)) abort ();) 1411 lint_assume (- TYPE_MAXIMUM (ptrdiff_t) <= length);
1412 adjust_intervals_for_deletion (buffer, start, -length); 1412 adjust_intervals_for_deletion (buffer, start, -length);
1413 } 1413 }
1414} 1414}
@@ -1468,7 +1468,7 @@ merge_interval_right (register INTERVAL i)
1468 1468
1469 /* This must be the rightmost or last interval and cannot 1469 /* This must be the rightmost or last interval and cannot
1470 be merged right. The caller should have known. */ 1470 be merged right. The caller should have known. */
1471 abort (); 1471 emacs_abort ();
1472} 1472}
1473 1473
1474/* Merge interval I with its lexicographic predecessor. The resulting 1474/* Merge interval I with its lexicographic predecessor. The resulting
@@ -1524,7 +1524,7 @@ merge_interval_left (register INTERVAL i)
1524 1524
1525 /* This must be the leftmost or first interval and cannot 1525 /* This must be the leftmost or first interval and cannot
1526 be merged left. The caller should have known. */ 1526 be merged left. The caller should have known. */
1527 abort (); 1527 emacs_abort ();
1528} 1528}
1529 1529
1530/* Create a copy of SOURCE but with the default value of UP. */ 1530/* Create a copy of SOURCE but with the default value of UP. */
@@ -2170,7 +2170,7 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
2170 else if (STRINGP (object)) 2170 else if (STRINGP (object))
2171 i = find_interval (string_intervals (object), pos); 2171 i = find_interval (string_intervals (object), pos);
2172 else 2172 else
2173 abort (); 2173 emacs_abort ();
2174 2174
2175 if (!i || (i->position + LENGTH (i) <= pos)) 2175 if (!i || (i->position + LENGTH (i) <= pos))
2176 return 0; 2176 return 0;
@@ -2209,7 +2209,7 @@ get_local_map (register ptrdiff_t position, register struct buffer *buffer,
2209 2209
2210 /* Perhaps we should just change `position' to the limit. */ 2210 /* Perhaps we should just change `position' to the limit. */
2211 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) 2211 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer))
2212 abort (); 2212 emacs_abort ();
2213 2213
2214 /* Ignore narrowing, so that a local map continues to be valid even if 2214 /* Ignore narrowing, so that a local map continues to be valid even if
2215 the visible region contains no characters and hence no properties. */ 2215 the visible region contains no characters and hence no properties. */
diff --git a/src/keyboard.c b/src/keyboard.c
index 9d103d673b2..691a06d36cf 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -21,7 +21,6 @@ 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#include <setjmp.h>
27#include "lisp.h" 26#include "lisp.h"
@@ -452,9 +451,8 @@ static void restore_getcjmp (jmp_buf);
452static Lisp_Object apply_modifiers (int, Lisp_Object); 451static Lisp_Object apply_modifiers (int, Lisp_Object);
453static void clear_event (struct input_event *); 452static void clear_event (struct input_event *);
454static Lisp_Object restore_kboard_configuration (Lisp_Object); 453static Lisp_Object restore_kboard_configuration (Lisp_Object);
455static void interrupt_signal (int signalnum);
456#ifdef SIGIO 454#ifdef SIGIO
457static void input_available_signal (int signo); 455static void deliver_input_available_signal (int signo);
458#endif 456#endif
459static void handle_interrupt (void); 457static void handle_interrupt (void);
460static _Noreturn void quit_throw_to_read_char (int); 458static _Noreturn void quit_throw_to_read_char (int);
@@ -462,7 +460,7 @@ static void process_special_events (void);
462static void timer_start_idle (void); 460static void timer_start_idle (void);
463static void timer_stop_idle (void); 461static void timer_stop_idle (void);
464static void timer_resume_idle (void); 462static void timer_resume_idle (void);
465static void handle_user_signal (int); 463static void deliver_user_signal (int);
466static char *find_user_signal_name (int); 464static char *find_user_signal_name (int);
467static int store_user_signal_events (void); 465static int store_user_signal_events (void);
468 466
@@ -1026,7 +1024,7 @@ restore_kboard_configuration (Lisp_Object was_locked)
1026 pop_kboard (); 1024 pop_kboard ();
1027 /* The pop should not change the kboard. */ 1025 /* The pop should not change the kboard. */
1028 if (single_kboard && current_kboard != prev) 1026 if (single_kboard && current_kboard != prev)
1029 abort (); 1027 emacs_abort ();
1030 } 1028 }
1031 return Qnil; 1029 return Qnil;
1032} 1030}
@@ -2608,13 +2606,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2608 Lisp_Object last = KVAR (kb, kbd_queue); 2606 Lisp_Object last = KVAR (kb, kbd_queue);
2609 /* We shouldn't get here if we were in single-kboard mode! */ 2607 /* We shouldn't get here if we were in single-kboard mode! */
2610 if (single_kboard) 2608 if (single_kboard)
2611 abort (); 2609 emacs_abort ();
2612 if (CONSP (last)) 2610 if (CONSP (last))
2613 { 2611 {
2614 while (CONSP (XCDR (last))) 2612 while (CONSP (XCDR (last)))
2615 last = XCDR (last); 2613 last = XCDR (last);
2616 if (!NILP (XCDR (last))) 2614 if (!NILP (XCDR (last)))
2617 abort (); 2615 emacs_abort ();
2618 } 2616 }
2619 if (!CONSP (last)) 2617 if (!CONSP (last))
2620 kset_kbd_queue (kb, Fcons (c, Qnil)); 2618 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -2787,7 +2785,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2787 if (current_kboard->kbd_queue_has_data) 2785 if (current_kboard->kbd_queue_has_data)
2788 { 2786 {
2789 if (!CONSP (KVAR (current_kboard, kbd_queue))) 2787 if (!CONSP (KVAR (current_kboard, kbd_queue)))
2790 abort (); 2788 emacs_abort ();
2791 c = XCAR (KVAR (current_kboard, kbd_queue)); 2789 c = XCAR (KVAR (current_kboard, kbd_queue));
2792 kset_kbd_queue (current_kboard, 2790 kset_kbd_queue (current_kboard,
2793 XCDR (KVAR (current_kboard, kbd_queue))); 2791 XCDR (KVAR (current_kboard, kbd_queue)));
@@ -2854,7 +2852,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2854 while (CONSP (XCDR (last))) 2852 while (CONSP (XCDR (last)))
2855 last = XCDR (last); 2853 last = XCDR (last);
2856 if (!NILP (XCDR (last))) 2854 if (!NILP (XCDR (last)))
2857 abort (); 2855 emacs_abort ();
2858 } 2856 }
2859 if (!CONSP (last)) 2857 if (!CONSP (last))
2860 kset_kbd_queue (kb, Fcons (c, Qnil)); 2858 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -3563,7 +3561,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3563 struct input_event *hold_quit) 3561 struct input_event *hold_quit)
3564{ 3562{
3565 if (event->kind == NO_EVENT) 3563 if (event->kind == NO_EVENT)
3566 abort (); 3564 emacs_abort ();
3567 3565
3568 if (hold_quit && hold_quit->kind != NO_EVENT) 3566 if (hold_quit && hold_quit->kind != NO_EVENT)
3569 return; 3567 return;
@@ -3684,7 +3682,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3684 if (immediate_quit && NILP (Vinhibit_quit)) 3682 if (immediate_quit && NILP (Vinhibit_quit))
3685 { 3683 {
3686 immediate_quit = 0; 3684 immediate_quit = 0;
3687 sigfree (); 3685 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3688 QUIT; 3686 QUIT;
3689 } 3687 }
3690 } 3688 }
@@ -3836,7 +3834,11 @@ kbd_buffer_get_event (KBOARD **kbp,
3836 unhold_keyboard_input (); 3834 unhold_keyboard_input ();
3837#ifdef SIGIO 3835#ifdef SIGIO
3838 if (!noninteractive) 3836 if (!noninteractive)
3839 signal (SIGIO, input_available_signal); 3837 {
3838 struct sigaction action;
3839 emacs_sigaction_init (&action, deliver_input_available_signal);
3840 sigaction (SIGIO, &action, 0);
3841 }
3840#endif /* SIGIO */ 3842#endif /* SIGIO */
3841 start_polling (); 3843 start_polling ();
3842 } 3844 }
@@ -3958,7 +3960,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3958#else 3960#else
3959 /* We're getting selection request events, but we don't have 3961 /* We're getting selection request events, but we don't have
3960 a window system. */ 3962 a window system. */
3961 abort (); 3963 emacs_abort ();
3962#endif 3964#endif
3963 } 3965 }
3964 3966
@@ -4202,7 +4204,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4202 else 4204 else
4203 /* We were promised by the above while loop that there was 4205 /* We were promised by the above while loop that there was
4204 something for us to read! */ 4206 something for us to read! */
4205 abort (); 4207 emacs_abort ();
4206 4208
4207 input_pending = readable_events (0); 4209 input_pending = readable_events (0);
4208 4210
@@ -4271,7 +4273,7 @@ process_special_events (void)
4271#else 4273#else
4272 /* We're getting selection request events, but we don't have 4274 /* We're getting selection request events, but we don't have
4273 a window system. */ 4275 a window system. */
4274 abort (); 4276 emacs_abort ();
4275#endif 4277#endif
4276 } 4278 }
4277 } 4279 }
@@ -5624,7 +5626,7 @@ make_lispy_event (struct input_event *event)
5624 else if (FRAMEP (event->frame_or_window)) 5626 else if (FRAMEP (event->frame_or_window))
5625 f = XFRAME (event->frame_or_window); 5627 f = XFRAME (event->frame_or_window);
5626 else 5628 else
5627 abort (); 5629 emacs_abort ();
5628 5630
5629 if (FRAME_WINDOW_P (f)) 5631 if (FRAME_WINDOW_P (f))
5630 fuzz = double_click_fuzz; 5632 fuzz = double_click_fuzz;
@@ -5731,7 +5733,7 @@ make_lispy_event (struct input_event *event)
5731 else 5733 else
5732 /* Every mouse event should either have the down_modifier or 5734 /* Every mouse event should either have the down_modifier or
5733 the up_modifier set. */ 5735 the up_modifier set. */
5734 abort (); 5736 emacs_abort ();
5735 5737
5736 { 5738 {
5737 /* Get the symbol we should use for the mouse click. */ 5739 /* Get the symbol we should use for the mouse click. */
@@ -5792,7 +5794,7 @@ make_lispy_event (struct input_event *event)
5792 else if (FRAMEP (event->frame_or_window)) 5794 else if (FRAMEP (event->frame_or_window))
5793 fr = XFRAME (event->frame_or_window); 5795 fr = XFRAME (event->frame_or_window);
5794 else 5796 else
5795 abort (); 5797 emacs_abort ();
5796 5798
5797 fuzz = FRAME_WINDOW_P (fr) 5799 fuzz = FRAME_WINDOW_P (fr)
5798 ? double_click_fuzz : double_click_fuzz / 8; 5800 ? double_click_fuzz : double_click_fuzz / 8;
@@ -5812,7 +5814,7 @@ make_lispy_event (struct input_event *event)
5812 else 5814 else
5813 /* Every wheel event should either have the down_modifier or 5815 /* Every wheel event should either have the down_modifier or
5814 the up_modifier set. */ 5816 the up_modifier set. */
5815 abort (); 5817 emacs_abort ();
5816 5818
5817 if (event->kind == HORIZ_WHEEL_EVENT) 5819 if (event->kind == HORIZ_WHEEL_EVENT)
5818 symbol_num += 2; 5820 symbol_num += 2;
@@ -5981,7 +5983,7 @@ make_lispy_event (struct input_event *event)
5981 { 5983 {
5982 char *name = find_user_signal_name (event->code); 5984 char *name = find_user_signal_name (event->code);
5983 if (!name) 5985 if (!name)
5984 abort (); 5986 emacs_abort ();
5985 return intern (name); 5987 return intern (name);
5986 } 5988 }
5987 5989
@@ -6068,7 +6070,7 @@ make_lispy_event (struct input_event *event)
6068 6070
6069 /* The 'kind' field of the event is something we don't recognize. */ 6071 /* The 'kind' field of the event is something we don't recognize. */
6070 default: 6072 default:
6071 abort (); 6073 emacs_abort ();
6072 } 6074 }
6073} 6075}
6074 6076
@@ -6245,7 +6247,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_
6245 /* Only the event queue may use the `up' modifier; it should always 6247 /* Only the event queue may use the `up' modifier; it should always
6246 be turned into a click or drag event before presented to lisp code. */ 6248 be turned into a click or drag event before presented to lisp code. */
6247 if (modifiers & up_modifier) 6249 if (modifiers & up_modifier)
6248 abort (); 6250 emacs_abort ();
6249 6251
6250 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } 6252 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; }
6251 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } 6253 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
@@ -6340,7 +6342,7 @@ parse_modifiers (Lisp_Object symbol)
6340 Qnil); 6342 Qnil);
6341 6343
6342 if (modifiers & ~INTMASK) 6344 if (modifiers & ~INTMASK)
6343 abort (); 6345 emacs_abort ();
6344 XSETFASTINT (mask, modifiers); 6346 XSETFASTINT (mask, modifiers);
6345 elements = Fcons (unmodified, Fcons (mask, Qnil)); 6347 elements = Fcons (unmodified, Fcons (mask, Qnil));
6346 6348
@@ -6797,10 +6799,12 @@ gobble_input (int expected)
6797#ifdef SIGIO 6799#ifdef SIGIO
6798 if (interrupt_input) 6800 if (interrupt_input)
6799 { 6801 {
6800 SIGMASKTYPE mask; 6802 sigset_t blocked, procmask;
6801 mask = sigblock (sigmask (SIGIO)); 6803 sigemptyset (&blocked);
6804 sigaddset (&blocked, SIGIO);
6805 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6802 read_avail_input (expected); 6806 read_avail_input (expected);
6803 sigsetmask (mask); 6807 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6804 } 6808 }
6805 else 6809 else
6806#ifdef POLL_FOR_INPUT 6810#ifdef POLL_FOR_INPUT
@@ -6809,10 +6813,12 @@ gobble_input (int expected)
6809 it's always set. */ 6813 it's always set. */
6810 if (!interrupt_input && poll_suppress_count == 0) 6814 if (!interrupt_input && poll_suppress_count == 0)
6811 { 6815 {
6812 SIGMASKTYPE mask; 6816 sigset_t blocked, procmask;
6813 mask = sigblock (sigmask (SIGALRM)); 6817 sigemptyset (&blocked);
6818 sigaddset (&blocked, SIGALRM);
6819 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6814 read_avail_input (expected); 6820 read_avail_input (expected);
6815 sigsetmask (mask); 6821 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6816 } 6822 }
6817 else 6823 else
6818#endif 6824#endif
@@ -6848,10 +6854,12 @@ record_asynch_buffer_change (void)
6848#ifdef SIGIO 6854#ifdef SIGIO
6849 if (interrupt_input) 6855 if (interrupt_input)
6850 { 6856 {
6851 SIGMASKTYPE mask; 6857 sigset_t blocked, procmask;
6852 mask = sigblock (sigmask (SIGIO)); 6858 sigemptyset (&blocked);
6859 sigaddset (&blocked, SIGIO);
6860 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6853 kbd_buffer_store_event (&event); 6861 kbd_buffer_store_event (&event);
6854 sigsetmask (mask); 6862 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6855 } 6863 }
6856 else 6864 else
6857#endif 6865#endif
@@ -7017,7 +7025,7 @@ tty_read_avail_input (struct terminal *terminal,
7017 7025
7018 if (terminal->type != output_termcap 7026 if (terminal->type != output_termcap
7019 && terminal->type != output_msdos_raw) 7027 && terminal->type != output_msdos_raw)
7020 abort (); 7028 emacs_abort ();
7021 7029
7022 /* XXX I think the following code should be moved to separate hook 7030 /* XXX I think the following code should be moved to separate hook
7023 functions in system-dependent files. */ 7031 functions in system-dependent files. */
@@ -7252,12 +7260,8 @@ process_pending_signals (void)
7252/* Note SIGIO has been undef'd if FIONREAD is missing. */ 7260/* Note SIGIO has been undef'd if FIONREAD is missing. */
7253 7261
7254static void 7262static void
7255input_available_signal (int signo) 7263handle_input_available_signal (int sig)
7256{ 7264{
7257 /* Must preserve main program's value of errno. */
7258 int old_errno = errno;
7259 SIGNAL_THREAD_CHECK (signo);
7260
7261#ifdef SYNC_INPUT 7265#ifdef SYNC_INPUT
7262 interrupt_input_pending = 1; 7266 interrupt_input_pending = 1;
7263 pending_signals = 1; 7267 pending_signals = 1;
@@ -7269,8 +7273,12 @@ input_available_signal (int signo)
7269#ifndef SYNC_INPUT 7273#ifndef SYNC_INPUT
7270 handle_async_input (); 7274 handle_async_input ();
7271#endif 7275#endif
7276}
7272 7277
7273 errno = old_errno; 7278static void
7279deliver_input_available_signal (int sig)
7280{
7281 handle_on_main_thread (sig, handle_input_available_signal);
7274} 7282}
7275#endif /* SIGIO */ 7283#endif /* SIGIO */
7276 7284
@@ -7312,6 +7320,7 @@ static struct user_signal_info *user_signals = NULL;
7312void 7320void
7313add_user_signal (int sig, const char *name) 7321add_user_signal (int sig, const char *name)
7314{ 7322{
7323 struct sigaction action;
7315 struct user_signal_info *p; 7324 struct user_signal_info *p;
7316 7325
7317 for (p = user_signals; p; p = p->next) 7326 for (p = user_signals; p; p = p->next)
@@ -7326,18 +7335,16 @@ add_user_signal (int sig, const char *name)
7326 p->next = user_signals; 7335 p->next = user_signals;
7327 user_signals = p; 7336 user_signals = p;
7328 7337
7329 signal (sig, handle_user_signal); 7338 emacs_sigaction_init (&action, deliver_user_signal);
7339 sigaction (sig, &action, 0);
7330} 7340}
7331 7341
7332static void 7342static void
7333handle_user_signal (int sig) 7343handle_user_signal (int sig)
7334{ 7344{
7335 int old_errno = errno;
7336 struct user_signal_info *p; 7345 struct user_signal_info *p;
7337 const char *special_event_name = NULL; 7346 const char *special_event_name = NULL;
7338 7347
7339 SIGNAL_THREAD_CHECK (sig);
7340
7341 if (SYMBOLP (Vdebug_on_event)) 7348 if (SYMBOLP (Vdebug_on_event))
7342 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event)); 7349 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event));
7343 7350
@@ -7371,8 +7378,12 @@ handle_user_signal (int sig)
7371 } 7378 }
7372 break; 7379 break;
7373 } 7380 }
7381}
7374 7382
7375 errno = old_errno; 7383static void
7384deliver_user_signal (int sig)
7385{
7386 handle_on_main_thread (sig, handle_user_signal);
7376} 7387}
7377 7388
7378static char * 7389static char *
@@ -7397,7 +7408,7 @@ store_user_signal_events (void)
7397 for (p = user_signals; p; p = p->next) 7408 for (p = user_signals; p; p = p->next)
7398 if (p->npending > 0) 7409 if (p->npending > 0)
7399 { 7410 {
7400 SIGMASKTYPE mask; 7411 sigset_t blocked, procmask;
7401 7412
7402 if (nstored == 0) 7413 if (nstored == 0)
7403 { 7414 {
@@ -7407,7 +7418,10 @@ store_user_signal_events (void)
7407 } 7418 }
7408 nstored += p->npending; 7419 nstored += p->npending;
7409 7420
7410 mask = sigblock (sigmask (p->sig)); 7421 sigemptyset (&blocked);
7422 sigaddset (&blocked, p->sig);
7423 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
7424
7411 do 7425 do
7412 { 7426 {
7413 buf.code = p->sig; 7427 buf.code = p->sig;
@@ -7415,7 +7429,8 @@ store_user_signal_events (void)
7415 p->npending--; 7429 p->npending--;
7416 } 7430 }
7417 while (p->npending > 0); 7431 while (p->npending > 0);
7418 sigsetmask (mask); 7432
7433 pthread_sigmask (SIG_SETMASK, &procmask, 0);
7419 } 7434 }
7420 7435
7421 return nstored; 7436 return nstored;
@@ -10792,17 +10807,10 @@ clear_waiting_for_input (void)
10792 Otherwise, tell QUIT to kill Emacs. */ 10807 Otherwise, tell QUIT to kill Emacs. */
10793 10808
10794static void 10809static void
10795interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10810handle_interrupt_signal (int sig)
10796 /* compilers complain in signal calls. */
10797{ 10811{
10798 /* Must preserve main program's value of errno. */
10799 int old_errno = errno;
10800 struct terminal *terminal;
10801
10802 SIGNAL_THREAD_CHECK (signalnum);
10803
10804 /* See if we have an active terminal on our controlling tty. */ 10812 /* See if we have an active terminal on our controlling tty. */
10805 terminal = get_named_tty ("/dev/tty"); 10813 struct terminal *terminal = get_named_tty ("/dev/tty");
10806 if (!terminal) 10814 if (!terminal)
10807 { 10815 {
10808 /* If there are no frames there, let's pretend that we are a 10816 /* If there are no frames there, let's pretend that we are a
@@ -10823,10 +10831,15 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10823 10831
10824 handle_interrupt (); 10832 handle_interrupt ();
10825 } 10833 }
10834}
10826 10835
10827 errno = old_errno; 10836static void
10837deliver_interrupt_signal (int sig)
10838{
10839 handle_on_main_thread (sig, handle_interrupt_signal);
10828} 10840}
10829 10841
10842
10830/* If Emacs is stuck because `inhibit-quit' is true, then keep track 10843/* If Emacs is stuck because `inhibit-quit' is true, then keep track
10831 of the number of times C-g has been requested. If C-g is pressed 10844 of the number of times C-g has been requested. If C-g is pressed
10832 enough times, then quit anyway. See bug#6585. */ 10845 enough times, then quit anyway. See bug#6585. */
@@ -10856,7 +10869,10 @@ handle_interrupt (void)
10856 /* If SIGINT isn't blocked, don't let us be interrupted by 10869 /* If SIGINT isn't blocked, don't let us be interrupted by
10857 another SIGINT, it might be harmful due to non-reentrancy 10870 another SIGINT, it might be harmful due to non-reentrancy
10858 in I/O functions. */ 10871 in I/O functions. */
10859 sigblock (sigmask (SIGINT)); 10872 sigset_t blocked;
10873 sigemptyset (&blocked);
10874 sigaddset (&blocked, SIGINT);
10875 pthread_sigmask (SIG_BLOCK, &blocked, 0);
10860 10876
10861 fflush (stdout); 10877 fflush (stdout);
10862 reset_all_sys_modes (); 10878 reset_all_sys_modes ();
@@ -10918,7 +10934,7 @@ handle_interrupt (void)
10918#endif /* not MSDOS */ 10934#endif /* not MSDOS */
10919 fflush (stdout); 10935 fflush (stdout);
10920 if (((c = getchar ()) & ~040) == 'Y') 10936 if (((c = getchar ()) & ~040) == 'Y')
10921 abort (); 10937 emacs_abort ();
10922 while (c != '\n') c = getchar (); 10938 while (c != '\n') c = getchar ();
10923#ifdef MSDOS 10939#ifdef MSDOS
10924 printf ("\r\nContinuing...\r\n"); 10940 printf ("\r\nContinuing...\r\n");
@@ -10927,7 +10943,7 @@ handle_interrupt (void)
10927#endif /* not MSDOS */ 10943#endif /* not MSDOS */
10928 fflush (stdout); 10944 fflush (stdout);
10929 init_all_sys_modes (); 10945 init_all_sys_modes ();
10930 sigfree (); 10946 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10931 } 10947 }
10932 else 10948 else
10933 { 10949 {
@@ -10940,7 +10956,7 @@ handle_interrupt (void)
10940 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 10956 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
10941 10957
10942 immediate_quit = 0; 10958 immediate_quit = 0;
10943 sigfree (); 10959 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10944 saved = gl_state; 10960 saved = gl_state;
10945 GCPRO4 (saved.object, saved.global_code, 10961 GCPRO4 (saved.object, saved.global_code,
10946 saved.current_syntax_table, saved.old_prop); 10962 saved.current_syntax_table, saved.old_prop);
@@ -10985,7 +11001,7 @@ quit_throw_to_read_char (int from_signal)
10985 if (!from_signal && EQ (Vquit_flag, Qkill_emacs)) 11001 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
10986 Fkill_emacs (Qnil); 11002 Fkill_emacs (Qnil);
10987 11003
10988 sigfree (); 11004 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10989 /* Prevent another signal from doing this before we finish. */ 11005 /* Prevent another signal from doing this before we finish. */
10990 clear_waiting_for_input (); 11006 clear_waiting_for_input ();
10991 input_pending = 0; 11007 input_pending = 0;
@@ -10999,7 +11015,7 @@ quit_throw_to_read_char (int from_signal)
10999#ifdef POLL_FOR_INPUT 11015#ifdef POLL_FOR_INPUT
11000 /* May be > 1 if in recursive minibuffer. */ 11016 /* May be > 1 if in recursive minibuffer. */
11001 if (poll_suppress_count == 0) 11017 if (poll_suppress_count == 0)
11002 abort (); 11018 emacs_abort ();
11003#endif 11019#endif
11004#endif 11020#endif
11005 if (FRAMEP (internal_last_event_frame) 11021 if (FRAMEP (internal_last_event_frame)
@@ -11357,7 +11373,7 @@ delete_kboard (KBOARD *kb)
11357 11373
11358 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard) 11374 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard)
11359 if (*kbp == NULL) 11375 if (*kbp == NULL)
11360 abort (); 11376 emacs_abort ();
11361 *kbp = kb->next_kboard; 11377 *kbp = kb->next_kboard;
11362 11378
11363 /* Prevent a dangling reference to KB. */ 11379 /* Prevent a dangling reference to KB. */
@@ -11368,7 +11384,7 @@ delete_kboard (KBOARD *kb)
11368 current_kboard = FRAME_KBOARD (XFRAME (selected_frame)); 11384 current_kboard = FRAME_KBOARD (XFRAME (selected_frame));
11369 single_kboard = 0; 11385 single_kboard = 0;
11370 if (current_kboard == kb) 11386 if (current_kboard == kb)
11371 abort (); 11387 emacs_abort ();
11372 } 11388 }
11373 11389
11374 wipe_kboard (kb); 11390 wipe_kboard (kb);
@@ -11420,17 +11436,23 @@ init_keyboard (void)
11420 SIGINT. There is special code in interrupt_signal to exit 11436 SIGINT. There is special code in interrupt_signal to exit
11421 Emacs on SIGINT when there are no termcap frames on the 11437 Emacs on SIGINT when there are no termcap frames on the
11422 controlling terminal. */ 11438 controlling terminal. */
11423 signal (SIGINT, interrupt_signal); 11439 struct sigaction action;
11440 emacs_sigaction_init (&action, deliver_interrupt_signal);
11441 sigaction (SIGINT, &action, 0);
11424#ifndef DOS_NT 11442#ifndef DOS_NT
11425 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 11443 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
11426 SIGQUIT and we can't tell which one it will give us. */ 11444 SIGQUIT and we can't tell which one it will give us. */
11427 signal (SIGQUIT, interrupt_signal); 11445 sigaction (SIGQUIT, &action, 0);
11428#endif /* not DOS_NT */ 11446#endif /* not DOS_NT */
11429 } 11447 }
11430/* Note SIGIO has been undef'd if FIONREAD is missing. */ 11448/* Note SIGIO has been undef'd if FIONREAD is missing. */
11431#ifdef SIGIO 11449#ifdef SIGIO
11432 if (!noninteractive) 11450 if (!noninteractive)
11433 signal (SIGIO, input_available_signal); 11451 {
11452 struct sigaction action;
11453 emacs_sigaction_init (&action, deliver_input_available_signal);
11454 sigaction (SIGIO, &action, 0);
11455 }
11434#endif /* SIGIO */ 11456#endif /* SIGIO */
11435 11457
11436/* Use interrupt input by default, if it works and noninterrupt input 11458/* Use interrupt input by default, if it works and noninterrupt input
@@ -11442,7 +11464,7 @@ init_keyboard (void)
11442 interrupt_input = 0; 11464 interrupt_input = 0;
11443#endif 11465#endif
11444 11466
11445 sigfree (); 11467 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
11446 dribble = 0; 11468 dribble = 0;
11447 11469
11448 if (keyboard_init_hook) 11470 if (keyboard_init_hook)
diff --git a/src/keymap.c b/src/keymap.c
index 85c384b8180..d79ff89ed67 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -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 1fe6ebb13ab..0470e452899 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -325,7 +325,7 @@ enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 1 };
325typedef EMACS_INT Lisp_Object; 325typedef EMACS_INT Lisp_Object;
326#define XLI(o) (o) 326#define XLI(o) (o)
327#define XIL(i) (i) 327#define XIL(i) (i)
328#define LISP_MAKE_RVALUE(o) (0+(o)) 328#define LISP_MAKE_RVALUE(o) (0 + (o))
329#define LISP_INITIALLY_ZERO 0 329#define LISP_INITIALLY_ZERO 0
330enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 }; 330enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 };
331#endif /* CHECK_LISP_OBJECT_TYPE */ 331#endif /* CHECK_LISP_OBJECT_TYPE */
@@ -422,9 +422,9 @@ enum lsb_bits
422#define XINT(a) (XLI (a) >> INTTYPEBITS) 422#define XINT(a) (XLI (a) >> INTTYPEBITS)
423#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS) 423#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS)
424#define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS) 424#define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS)
425#define XSET(var, type, ptr) \ 425#define make_lisp_ptr(ptr, type) \
426 (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \ 426 (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \
427 (var) = XIL ((type) | (intptr_t) (ptr))) 427 XIL ((type) | (intptr_t) (ptr)))
428 428
429#define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK)) 429#define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK))
430#define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type))) 430#define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type)))
@@ -449,13 +449,13 @@ static EMACS_INT const VALMASK
449#define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK)) 449#define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK))
450#define make_number(N) XIL ((EMACS_INT) (N) & INTMASK) 450#define make_number(N) XIL ((EMACS_INT) (N) & INTMASK)
451 451
452#define XSET(var, type, ptr) \ 452#define make_lisp_ptr(ptr, type) \
453 ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ 453 (XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
454 + ((intptr_t) (ptr) & VALMASK))) 454 + ((intptr_t) (ptr) & VALMASK)))
455 455
456#if DATA_SEG_BITS 456#if DATA_SEG_BITS
457/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 457/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
458 which were stored in a Lisp_Object */ 458 which were stored in a Lisp_Object. */
459#define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) 459#define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS))
460#else 460#else
461#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK)) 461#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK))
@@ -559,16 +559,16 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
559 559
560/* Construct a Lisp_Object from a value or address. */ 560/* Construct a Lisp_Object from a value or address. */
561 561
562#define XSETINT(a, b) (a) = make_number (b) 562#define XSETINT(a, b) ((a) = make_number (b))
563#define XSETCONS(a, b) XSET (a, Lisp_Cons, b) 563#define XSETCONS(a, b) ((a) = make_lisp_ptr (b, Lisp_Cons))
564#define XSETVECTOR(a, b) XSET (a, Lisp_Vectorlike, b) 564#define XSETVECTOR(a, b) ((a) = make_lisp_ptr (b, Lisp_Vectorlike))
565#define XSETSTRING(a, b) XSET (a, Lisp_String, b) 565#define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String))
566#define XSETSYMBOL(a, b) XSET (a, Lisp_Symbol, b) 566#define XSETSYMBOL(a, b) ((a) = make_lisp_ptr (b, Lisp_Symbol))
567#define XSETFLOAT(a, b) XSET (a, Lisp_Float, b) 567#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float))
568 568
569/* Misc types. */ 569/* Misc types. */
570 570
571#define XSETMISC(a, b) XSET (a, Lisp_Misc, b) 571#define XSETMISC(a, b) ((a) = make_lisp_ptr (b, Lisp_Misc))
572#define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker) 572#define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker)
573 573
574/* Pseudovector types. */ 574/* Pseudovector types. */
@@ -914,14 +914,6 @@ enum
914 (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \ 914 (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \
915 : char_table_ref ((CT), (IDX))) 915 : char_table_ref ((CT), (IDX)))
916 916
917/* Almost equivalent to Faref (CT, IDX). However, if the result is
918 not a character, return IDX.
919
920 For these characters, do not check validity of CT
921 and do not follow parent. */
922#define CHAR_TABLE_TRANSLATE(CT, IDX) \
923 char_table_translate (CT, IDX)
924
925/* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and 917/* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and
926 8-bit European characters. Do not check validity of CT. */ 918 8-bit European characters. Do not check validity of CT. */
927#define CHAR_TABLE_SET(CT, IDX, VAL) \ 919#define CHAR_TABLE_SET(CT, IDX, VAL) \
@@ -1210,9 +1202,9 @@ struct Lisp_Hash_Table
1210 struct Lisp_Hash_Table *next_weak; 1202 struct Lisp_Hash_Table *next_weak;
1211 1203
1212 /* C function to compare two keys. */ 1204 /* C function to compare two keys. */
1213 int (*cmpfn) (struct Lisp_Hash_Table *, 1205 bool (*cmpfn) (struct Lisp_Hash_Table *,
1214 Lisp_Object, EMACS_UINT, 1206 Lisp_Object, EMACS_UINT,
1215 Lisp_Object, EMACS_UINT); 1207 Lisp_Object, EMACS_UINT);
1216 1208
1217 /* C function to compute hash code. */ 1209 /* C function to compute hash code. */
1218 EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object); 1210 EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object);
@@ -1632,7 +1624,7 @@ typedef struct {
1632 int mouse_face_image_state; 1624 int mouse_face_image_state;
1633} Mouse_HLInfo; 1625} Mouse_HLInfo;
1634 1626
1635/* Data type checking */ 1627/* Data type checking. */
1636 1628
1637#define NILP(x) EQ (x, Qnil) 1629#define NILP(x) EQ (x, Qnil)
1638 1630
@@ -2005,7 +1997,7 @@ struct specbinding
2005 { 1997 {
2006 Lisp_Object symbol, old_value; 1998 Lisp_Object symbol, old_value;
2007 specbinding_func func; 1999 specbinding_func func;
2008 Lisp_Object unused; /* Dividing by 16 is faster than by 12 */ 2000 Lisp_Object unused; /* Dividing by 16 is faster than by 12. */
2009 }; 2001 };
2010 2002
2011extern struct specbinding *specpdl; 2003extern struct specbinding *specpdl;
@@ -2293,7 +2285,7 @@ extern int gcpro_level;
2293 2285
2294#define UNGCPRO \ 2286#define UNGCPRO \
2295 ((--gcpro_level != gcpro1.level) \ 2287 ((--gcpro_level != gcpro1.level) \
2296 ? (abort (), 0) \ 2288 ? (emacs_abort (), 0) \
2297 : ((gcprolist = gcpro1.next), 0)) 2289 : ((gcprolist = gcpro1.next), 0))
2298 2290
2299#endif /* DEBUG_GCPRO */ 2291#endif /* DEBUG_GCPRO */
@@ -2584,10 +2576,10 @@ extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
2584 2576
2585EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST; 2577EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST;
2586 2578
2587/* Defined in frame.c */ 2579/* Defined in frame.c. */
2588extern Lisp_Object Qframep; 2580extern Lisp_Object Qframep;
2589 2581
2590/* Defined in data.c */ 2582/* Defined in data.c. */
2591extern Lisp_Object indirect_function (Lisp_Object); 2583extern Lisp_Object indirect_function (Lisp_Object);
2592extern Lisp_Object find_symbol_value (Lisp_Object); 2584extern Lisp_Object find_symbol_value (Lisp_Object);
2593 2585
@@ -2634,7 +2626,7 @@ extern void swap_in_global_binding (struct Lisp_Symbol *);
2634extern void syms_of_cmds (void); 2626extern void syms_of_cmds (void);
2635extern void keys_of_cmds (void); 2627extern void keys_of_cmds (void);
2636 2628
2637/* Defined in coding.c */ 2629/* Defined in coding.c. */
2638extern Lisp_Object Qcharset; 2630extern Lisp_Object Qcharset;
2639extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 2631extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
2640 ptrdiff_t, bool, bool, Lisp_Object); 2632 ptrdiff_t, bool, bool, Lisp_Object);
@@ -2642,7 +2634,7 @@ extern void init_coding (void);
2642extern void init_coding_once (void); 2634extern void init_coding_once (void);
2643extern void syms_of_coding (void); 2635extern void syms_of_coding (void);
2644 2636
2645/* Defined in character.c */ 2637/* Defined in character.c. */
2646EXFUN (Fmax_char, 0) ATTRIBUTE_CONST; 2638EXFUN (Fmax_char, 0) ATTRIBUTE_CONST;
2647extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t); 2639extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t);
2648extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t); 2640extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t);
@@ -2650,21 +2642,21 @@ extern int multibyte_char_to_unibyte (int) ATTRIBUTE_CONST;
2650extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST; 2642extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST;
2651extern void syms_of_character (void); 2643extern void syms_of_character (void);
2652 2644
2653/* Defined in charset.c */ 2645/* Defined in charset.c. */
2654extern void init_charset (void); 2646extern void init_charset (void);
2655extern void init_charset_once (void); 2647extern void init_charset_once (void);
2656extern void syms_of_charset (void); 2648extern void syms_of_charset (void);
2657/* Structure forward declarations. */ 2649/* Structure forward declarations. */
2658struct charset; 2650struct charset;
2659 2651
2660/* Defined in composite.c */ 2652/* Defined in composite.c. */
2661extern void syms_of_composite (void); 2653extern void syms_of_composite (void);
2662 2654
2663/* Defined in syntax.c */ 2655/* Defined in syntax.c. */
2664extern void init_syntax_once (void); 2656extern void init_syntax_once (void);
2665extern void syms_of_syntax (void); 2657extern void syms_of_syntax (void);
2666 2658
2667/* Defined in fns.c */ 2659/* Defined in fns.c. */
2668extern Lisp_Object QCrehash_size, QCrehash_threshold; 2660extern Lisp_Object QCrehash_size, QCrehash_threshold;
2669enum { NEXT_ALMOST_PRIME_LIMIT = 11 }; 2661enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
2670EXFUN (Fidentity, 1) ATTRIBUTE_CONST; 2662EXFUN (Fidentity, 1) ATTRIBUTE_CONST;
@@ -2698,13 +2690,12 @@ extern Lisp_Object string_to_multibyte (Lisp_Object);
2698extern Lisp_Object string_make_unibyte (Lisp_Object); 2690extern Lisp_Object string_make_unibyte (Lisp_Object);
2699extern void syms_of_fns (void); 2691extern void syms_of_fns (void);
2700 2692
2701/* Defined in floatfns.c */ 2693/* Defined in floatfns.c. */
2702extern double extract_float (Lisp_Object); 2694extern double extract_float (Lisp_Object);
2703extern void init_floatfns (void);
2704extern void syms_of_floatfns (void); 2695extern void syms_of_floatfns (void);
2705extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); 2696extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y);
2706 2697
2707/* Defined in fringe.c */ 2698/* Defined in fringe.c. */
2708extern void syms_of_fringe (void); 2699extern void syms_of_fringe (void);
2709extern void init_fringe (void); 2700extern void init_fringe (void);
2710#ifdef HAVE_WINDOW_SYSTEM 2701#ifdef HAVE_WINDOW_SYSTEM
@@ -2712,13 +2703,13 @@ extern void mark_fringe_data (void);
2712extern void init_fringe_once (void); 2703extern void init_fringe_once (void);
2713#endif /* HAVE_WINDOW_SYSTEM */ 2704#endif /* HAVE_WINDOW_SYSTEM */
2714 2705
2715/* Defined in image.c */ 2706/* Defined in image.c. */
2716extern Lisp_Object QCascent, QCmargin, QCrelief; 2707extern Lisp_Object QCascent, QCmargin, QCrelief;
2717extern Lisp_Object QCconversion; 2708extern Lisp_Object QCconversion;
2718extern int x_bitmap_mask (struct frame *, ptrdiff_t); 2709extern int x_bitmap_mask (struct frame *, ptrdiff_t);
2719extern void syms_of_image (void); 2710extern void syms_of_image (void);
2720 2711
2721/* Defined in insdel.c */ 2712/* Defined in insdel.c. */
2722extern Lisp_Object Qinhibit_modification_hooks; 2713extern Lisp_Object Qinhibit_modification_hooks;
2723extern void move_gap (ptrdiff_t); 2714extern void move_gap (ptrdiff_t);
2724extern void move_gap_both (ptrdiff_t, ptrdiff_t); 2715extern void move_gap_both (ptrdiff_t, ptrdiff_t);
@@ -2764,7 +2755,7 @@ extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
2764 const char *, ptrdiff_t, ptrdiff_t, bool); 2755 const char *, ptrdiff_t, ptrdiff_t, bool);
2765extern void syms_of_insdel (void); 2756extern void syms_of_insdel (void);
2766 2757
2767/* Defined in dispnew.c */ 2758/* Defined in dispnew.c. */
2768#if (defined PROFILING \ 2759#if (defined PROFILING \
2769 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) 2760 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
2770_Noreturn void __executable_start (void); 2761_Noreturn void __executable_start (void);
@@ -2775,7 +2766,7 @@ extern Lisp_Object sit_for (Lisp_Object, bool, int);
2775extern void init_display (void); 2766extern void init_display (void);
2776extern void syms_of_display (void); 2767extern void syms_of_display (void);
2777 2768
2778/* Defined in xdisp.c */ 2769/* Defined in xdisp.c. */
2779extern Lisp_Object Qinhibit_point_motion_hooks; 2770extern Lisp_Object Qinhibit_point_motion_hooks;
2780extern Lisp_Object Qinhibit_redisplay, Qdisplay; 2771extern Lisp_Object Qinhibit_redisplay, Qdisplay;
2781extern Lisp_Object Qmenu_bar_update_hook; 2772extern Lisp_Object Qmenu_bar_update_hook;
@@ -2826,13 +2817,13 @@ extern Lisp_Object safe_eval (Lisp_Object);
2826extern int pos_visible_p (struct window *, ptrdiff_t, int *, 2817extern int pos_visible_p (struct window *, ptrdiff_t, int *,
2827 int *, int *, int *, int *, int *); 2818 int *, int *, int *, int *, int *);
2828 2819
2829/* Defined in xsettings.c */ 2820/* Defined in xsettings.c. */
2830extern void syms_of_xsettings (void); 2821extern void syms_of_xsettings (void);
2831 2822
2832/* Defined in vm-limit.c. */ 2823/* Defined in vm-limit.c. */
2833extern void memory_warnings (void *, void (*warnfun) (const char *)); 2824extern void memory_warnings (void *, void (*warnfun) (const char *));
2834 2825
2835/* Defined in alloc.c */ 2826/* Defined in alloc.c. */
2836extern void check_pure_size (void); 2827extern void check_pure_size (void);
2837extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); 2828extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
2838extern void reset_malloc_hooks (void); 2829extern void reset_malloc_hooks (void);
@@ -2935,7 +2926,7 @@ extern void check_cons_list (void);
2935#endif 2926#endif
2936 2927
2937#ifdef REL_ALLOC 2928#ifdef REL_ALLOC
2938/* Defined in ralloc.c */ 2929/* Defined in ralloc.c. */
2939extern void *r_alloc (void **, size_t); 2930extern void *r_alloc (void **, size_t);
2940extern void r_alloc_free (void **); 2931extern void r_alloc_free (void **);
2941extern void *r_re_alloc (void **, size_t); 2932extern void *r_re_alloc (void **, size_t);
@@ -2943,7 +2934,7 @@ extern void r_alloc_reset_variable (void **, void **);
2943extern void r_alloc_inhibit_buffer_relocation (int); 2934extern void r_alloc_inhibit_buffer_relocation (int);
2944#endif 2935#endif
2945 2936
2946/* Defined in chartab.c */ 2937/* Defined in chartab.c. */
2947extern Lisp_Object copy_char_table (Lisp_Object); 2938extern Lisp_Object copy_char_table (Lisp_Object);
2948extern Lisp_Object char_table_ref (Lisp_Object, int); 2939extern Lisp_Object char_table_ref (Lisp_Object, int);
2949extern Lisp_Object char_table_ref_and_range (Lisp_Object, int, 2940extern Lisp_Object char_table_ref_and_range (Lisp_Object, int,
@@ -2961,7 +2952,7 @@ extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Ob
2961extern Lisp_Object uniprop_table (Lisp_Object); 2952extern Lisp_Object uniprop_table (Lisp_Object);
2962extern void syms_of_chartab (void); 2953extern void syms_of_chartab (void);
2963 2954
2964/* Defined in print.c */ 2955/* Defined in print.c. */
2965extern Lisp_Object Vprin1_to_string_buffer; 2956extern Lisp_Object Vprin1_to_string_buffer;
2966extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE; 2957extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE;
2967extern Lisp_Object Qstandard_output; 2958extern Lisp_Object Qstandard_output;
@@ -2978,7 +2969,7 @@ enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 };
2978extern int float_to_string (char *, double); 2969extern int float_to_string (char *, double);
2979extern void syms_of_print (void); 2970extern void syms_of_print (void);
2980 2971
2981/* Defined in doprnt.c */ 2972/* Defined in doprnt.c. */
2982extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *, 2973extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *,
2983 va_list); 2974 va_list);
2984extern ptrdiff_t esprintf (char *, char const *, ...) 2975extern ptrdiff_t esprintf (char *, char const *, ...)
@@ -3081,6 +3072,7 @@ extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
3081extern _Noreturn void verror (const char *, va_list) 3072extern _Noreturn void verror (const char *, va_list)
3082 ATTRIBUTE_FORMAT_PRINTF (1, 0); 3073 ATTRIBUTE_FORMAT_PRINTF (1, 0);
3083extern Lisp_Object un_autoload (Lisp_Object); 3074extern Lisp_Object un_autoload (Lisp_Object);
3075extern Lisp_Object call_debugger (Lisp_Object arg);
3084extern void init_eval_once (void); 3076extern void init_eval_once (void);
3085extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); 3077extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
3086extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); 3078extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
@@ -3143,7 +3135,7 @@ extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
3143extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t); 3135extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t);
3144extern void syms_of_marker (void); 3136extern void syms_of_marker (void);
3145 3137
3146/* Defined in fileio.c */ 3138/* Defined in fileio.c. */
3147 3139
3148extern Lisp_Object Qfile_error; 3140extern Lisp_Object Qfile_error;
3149extern Lisp_Object Qfile_exists_p; 3141extern Lisp_Object Qfile_exists_p;
@@ -3151,16 +3143,16 @@ extern Lisp_Object Qfile_directory_p;
3151extern Lisp_Object Qinsert_file_contents; 3143extern Lisp_Object Qinsert_file_contents;
3152extern Lisp_Object Qfile_name_history; 3144extern Lisp_Object Qfile_name_history;
3153extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); 3145extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
3154EXFUN (Fread_file_name, 6); /* not a normal DEFUN */ 3146EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
3155extern Lisp_Object close_file_unwind (Lisp_Object); 3147extern Lisp_Object close_file_unwind (Lisp_Object);
3156extern Lisp_Object restore_point_unwind (Lisp_Object); 3148extern Lisp_Object restore_point_unwind (Lisp_Object);
3157extern _Noreturn void report_file_error (const char *, Lisp_Object); 3149extern _Noreturn void report_file_error (const char *, Lisp_Object);
3158extern int internal_delete_file (Lisp_Object); 3150extern void internal_delete_file (Lisp_Object);
3159extern void syms_of_fileio (void); 3151extern void syms_of_fileio (void);
3160extern Lisp_Object make_temp_name (Lisp_Object, int); 3152extern Lisp_Object make_temp_name (Lisp_Object, bool);
3161extern Lisp_Object Qdelete_file; 3153extern Lisp_Object Qdelete_file;
3162 3154
3163/* Defined in search.c */ 3155/* Defined in search.c. */
3164extern void shrink_regexp_cache (void); 3156extern void shrink_regexp_cache (void);
3165extern void restore_search_regs (void); 3157extern void restore_search_regs (void);
3166extern void record_unwind_save_match_data (void); 3158extern void record_unwind_save_match_data (void);
@@ -3233,9 +3225,7 @@ extern void cmd_error_internal (Lisp_Object, const char *);
3233extern Lisp_Object command_loop_1 (void); 3225extern Lisp_Object command_loop_1 (void);
3234extern Lisp_Object recursive_edit_1 (void); 3226extern Lisp_Object recursive_edit_1 (void);
3235extern void record_auto_save (void); 3227extern void record_auto_save (void);
3236#ifdef SIGDANGER
3237extern void force_auto_save_soon (void); 3228extern void force_auto_save_soon (void);
3238#endif
3239extern void init_keyboard (void); 3229extern void init_keyboard (void);
3240extern void syms_of_keyboard (void); 3230extern void syms_of_keyboard (void);
3241extern void keys_of_keyboard (void); 3231extern void keys_of_keyboard (void);
@@ -3268,9 +3258,7 @@ extern bool display_arg;
3268extern Lisp_Object decode_env_path (const char *, const char *); 3258extern Lisp_Object decode_env_path (const char *, const char *);
3269extern Lisp_Object empty_unibyte_string, empty_multibyte_string; 3259extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
3270extern Lisp_Object Qfile_name_handler_alist; 3260extern Lisp_Object Qfile_name_handler_alist;
3271#ifdef FLOAT_CATCH_SIGILL 3261extern _Noreturn void fatal_error_backtrace (int, int);
3272extern void fatal_error_signal (int);
3273#endif
3274extern Lisp_Object Qkill_emacs; 3262extern Lisp_Object Qkill_emacs;
3275#if HAVE_SETLOCALE 3263#if HAVE_SETLOCALE
3276void fixup_locale (void); 3264void fixup_locale (void);
@@ -3339,14 +3327,14 @@ extern void init_callproc (void);
3339extern void set_initial_environment (void); 3327extern void set_initial_environment (void);
3340extern void syms_of_callproc (void); 3328extern void syms_of_callproc (void);
3341 3329
3342/* Defined in doc.c */ 3330/* Defined in doc.c. */
3343extern Lisp_Object Qfunction_documentation; 3331extern Lisp_Object Qfunction_documentation;
3344extern Lisp_Object read_doc_string (Lisp_Object); 3332extern Lisp_Object read_doc_string (Lisp_Object);
3345extern Lisp_Object get_doc_string (Lisp_Object, bool, bool); 3333extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
3346extern void syms_of_doc (void); 3334extern void syms_of_doc (void);
3347extern int read_bytecode_char (bool); 3335extern int read_bytecode_char (bool);
3348 3336
3349/* Defined in bytecode.c */ 3337/* Defined in bytecode.c. */
3350extern Lisp_Object Qbytecode; 3338extern Lisp_Object Qbytecode;
3351extern void syms_of_bytecode (void); 3339extern void syms_of_bytecode (void);
3352extern struct byte_stack *byte_stack_list; 3340extern struct byte_stack *byte_stack_list;
@@ -3357,12 +3345,12 @@ extern void unmark_byte_stack (void);
3357extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, 3345extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object,
3358 Lisp_Object, ptrdiff_t, Lisp_Object *); 3346 Lisp_Object, ptrdiff_t, Lisp_Object *);
3359 3347
3360/* Defined in macros.c */ 3348/* Defined in macros.c. */
3361extern Lisp_Object Qexecute_kbd_macro; 3349extern Lisp_Object Qexecute_kbd_macro;
3362extern void init_macros (void); 3350extern void init_macros (void);
3363extern void syms_of_macros (void); 3351extern void syms_of_macros (void);
3364 3352
3365/* Defined in undo.c */ 3353/* Defined in undo.c. */
3366extern Lisp_Object Qapply; 3354extern Lisp_Object Qapply;
3367extern Lisp_Object Qinhibit_read_only; 3355extern Lisp_Object Qinhibit_read_only;
3368extern void truncate_undo_list (struct buffer *); 3356extern void truncate_undo_list (struct buffer *);
@@ -3375,7 +3363,7 @@ extern void record_property_change (ptrdiff_t, ptrdiff_t,
3375 Lisp_Object, Lisp_Object, 3363 Lisp_Object, Lisp_Object,
3376 Lisp_Object); 3364 Lisp_Object);
3377extern void syms_of_undo (void); 3365extern void syms_of_undo (void);
3378/* Defined in textprop.c */ 3366/* Defined in textprop.c. */
3379extern Lisp_Object Qfont, Qmouse_face; 3367extern Lisp_Object Qfont, Qmouse_face;
3380extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks; 3368extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks;
3381extern Lisp_Object Qfront_sticky, Qrear_nonsticky; 3369extern Lisp_Object Qfront_sticky, Qrear_nonsticky;
@@ -3383,19 +3371,19 @@ extern Lisp_Object Qminibuffer_prompt;
3383 3371
3384extern void report_interval_modification (Lisp_Object, Lisp_Object); 3372extern void report_interval_modification (Lisp_Object, Lisp_Object);
3385 3373
3386/* Defined in menu.c */ 3374/* Defined in menu.c. */
3387extern void syms_of_menu (void); 3375extern void syms_of_menu (void);
3388 3376
3389/* Defined in xmenu.c */ 3377/* Defined in xmenu.c. */
3390extern void syms_of_xmenu (void); 3378extern void syms_of_xmenu (void);
3391 3379
3392/* Defined in termchar.h */ 3380/* Defined in termchar.h. */
3393struct tty_display_info; 3381struct tty_display_info;
3394 3382
3395/* Defined in termhooks.h */ 3383/* Defined in termhooks.h. */
3396struct terminal; 3384struct terminal;
3397 3385
3398/* Defined in sysdep.c */ 3386/* Defined in sysdep.c. */
3399#ifndef HAVE_GET_CURRENT_DIR_NAME 3387#ifndef HAVE_GET_CURRENT_DIR_NAME
3400extern char *get_current_dir_name (void); 3388extern char *get_current_dir_name (void);
3401#endif 3389#endif
@@ -3417,6 +3405,8 @@ extern int set_window_size (int, int, int);
3417extern EMACS_INT get_random (void); 3405extern EMACS_INT get_random (void);
3418extern void seed_random (void *, ptrdiff_t); 3406extern void seed_random (void *, ptrdiff_t);
3419extern void init_random (void); 3407extern void init_random (void);
3408extern void emacs_backtrace (int);
3409extern _Noreturn void emacs_abort (void) NO_INLINE;
3420extern int emacs_open (const char *, int, int); 3410extern int emacs_open (const char *, int, int);
3421extern int emacs_close (int); 3411extern int emacs_close (int);
3422extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 3412extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
@@ -3430,45 +3420,45 @@ extern void unlock_file (Lisp_Object);
3430extern void unlock_buffer (struct buffer *); 3420extern void unlock_buffer (struct buffer *);
3431extern void syms_of_filelock (void); 3421extern void syms_of_filelock (void);
3432 3422
3433/* Defined in sound.c */ 3423/* Defined in sound.c. */
3434extern void syms_of_sound (void); 3424extern void syms_of_sound (void);
3435 3425
3436/* Defined in category.c */ 3426/* Defined in category.c. */
3437extern void init_category_once (void); 3427extern void init_category_once (void);
3438extern Lisp_Object char_category_set (int); 3428extern Lisp_Object char_category_set (int);
3439extern void syms_of_category (void); 3429extern void syms_of_category (void);
3440 3430
3441/* Defined in ccl.c */ 3431/* Defined in ccl.c. */
3442extern void syms_of_ccl (void); 3432extern void syms_of_ccl (void);
3443 3433
3444/* Defined in dired.c */ 3434/* Defined in dired.c. */
3445extern void syms_of_dired (void); 3435extern void syms_of_dired (void);
3446extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, 3436extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
3447 Lisp_Object, Lisp_Object, 3437 Lisp_Object, Lisp_Object,
3448 bool, Lisp_Object); 3438 bool, Lisp_Object);
3449 3439
3450/* Defined in term.c */ 3440/* Defined in term.c. */
3451extern int *char_ins_del_vector; 3441extern int *char_ins_del_vector;
3452extern void syms_of_term (void); 3442extern void syms_of_term (void);
3453extern _Noreturn void fatal (const char *msgid, ...) 3443extern _Noreturn void fatal (const char *msgid, ...)
3454 ATTRIBUTE_FORMAT_PRINTF (1, 2); 3444 ATTRIBUTE_FORMAT_PRINTF (1, 2);
3455 3445
3456/* Defined in terminal.c */ 3446/* Defined in terminal.c. */
3457extern void syms_of_terminal (void); 3447extern void syms_of_terminal (void);
3458 3448
3459/* Defined in font.c */ 3449/* Defined in font.c. */
3460extern void syms_of_font (void); 3450extern void syms_of_font (void);
3461extern void init_font (void); 3451extern void init_font (void);
3462 3452
3463#ifdef HAVE_WINDOW_SYSTEM 3453#ifdef HAVE_WINDOW_SYSTEM
3464/* Defined in fontset.c */ 3454/* Defined in fontset.c. */
3465extern void syms_of_fontset (void); 3455extern void syms_of_fontset (void);
3466 3456
3467/* Defined in xfns.c, w32fns.c, or macfns.c */ 3457/* Defined in xfns.c, w32fns.c, or macfns.c. */
3468extern Lisp_Object Qfont_param; 3458extern Lisp_Object Qfont_param;
3469#endif 3459#endif
3470 3460
3471/* Defined in xfaces.c */ 3461/* Defined in xfaces.c. */
3472extern Lisp_Object Qdefault, Qtool_bar, Qfringe; 3462extern Lisp_Object Qdefault, Qtool_bar, Qfringe;
3473extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; 3463extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor;
3474extern Lisp_Object Qmode_line_inactive; 3464extern Lisp_Object Qmode_line_inactive;
@@ -3484,26 +3474,26 @@ extern Lisp_Object Vface_alternative_font_registry_alist;
3484extern void syms_of_xfaces (void); 3474extern void syms_of_xfaces (void);
3485 3475
3486#ifdef HAVE_X_WINDOWS 3476#ifdef HAVE_X_WINDOWS
3487/* Defined in xfns.c */ 3477/* Defined in xfns.c. */
3488extern void syms_of_xfns (void); 3478extern void syms_of_xfns (void);
3489 3479
3490/* Defined in xsmfns.c */ 3480/* Defined in xsmfns.c. */
3491extern void syms_of_xsmfns (void); 3481extern void syms_of_xsmfns (void);
3492 3482
3493/* Defined in xselect.c */ 3483/* Defined in xselect.c. */
3494extern void syms_of_xselect (void); 3484extern void syms_of_xselect (void);
3495 3485
3496/* Defined in xterm.c */ 3486/* Defined in xterm.c. */
3497extern void syms_of_xterm (void); 3487extern void syms_of_xterm (void);
3498#endif /* HAVE_X_WINDOWS */ 3488#endif /* HAVE_X_WINDOWS */
3499 3489
3500#ifdef HAVE_WINDOW_SYSTEM 3490#ifdef HAVE_WINDOW_SYSTEM
3501/* Defined in xterm.c, nsterm.m, w32term.c */ 3491/* Defined in xterm.c, nsterm.m, w32term.c. */
3502extern char *x_get_keysym_name (int); 3492extern char *x_get_keysym_name (int);
3503#endif /* HAVE_WINDOW_SYSTEM */ 3493#endif /* HAVE_WINDOW_SYSTEM */
3504 3494
3505#ifdef HAVE_LIBXML2 3495#ifdef HAVE_LIBXML2
3506/* Defined in xml.c */ 3496/* Defined in xml.c. */
3507extern void syms_of_xml (void); 3497extern void syms_of_xml (void);
3508extern void xml_cleanup_parser (void); 3498extern void xml_cleanup_parser (void);
3509#endif 3499#endif
@@ -3514,12 +3504,12 @@ extern int have_menus_p (void);
3514#endif 3504#endif
3515 3505
3516#ifdef HAVE_DBUS 3506#ifdef HAVE_DBUS
3517/* Defined in dbusbind.c */ 3507/* Defined in dbusbind.c. */
3518void syms_of_dbusbind (void); 3508void syms_of_dbusbind (void);
3519#endif 3509#endif
3520 3510
3521#ifdef DOS_NT 3511#ifdef DOS_NT
3522/* Defined in msdos.c, w32.c */ 3512/* Defined in msdos.c, w32.c. */
3523extern char *emacs_root_dir (void); 3513extern char *emacs_root_dir (void);
3524#endif /* DOS_NT */ 3514#endif /* DOS_NT */
3525 3515
@@ -3527,7 +3517,7 @@ extern char *emacs_root_dir (void);
3527 Used during startup to detect startup of dumped Emacs. */ 3517 Used during startup to detect startup of dumped Emacs. */
3528extern bool initialized; 3518extern bool initialized;
3529 3519
3530extern int immediate_quit; /* Nonzero means ^G can quit instantly */ 3520extern int immediate_quit; /* Nonzero means ^G can quit instantly. */
3531 3521
3532extern void *xmalloc (size_t); 3522extern void *xmalloc (size_t);
3533extern void *xzalloc (size_t); 3523extern void *xzalloc (size_t);
@@ -3557,36 +3547,10 @@ extern void init_system_name (void);
3557#define make_fixnum_or_float(val) \ 3547#define make_fixnum_or_float(val) \
3558 (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val)) 3548 (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val))
3559 3549
3560
3561/* Checks the `cycle check' variable CHECK to see if it indicates that
3562 EL is part of a cycle; CHECK must be either Qnil or a value returned
3563 by an earlier use of CYCLE_CHECK. SUSPICIOUS is the number of
3564 elements after which a cycle might be suspected; after that many
3565 elements, this macro begins consing in order to keep more precise
3566 track of elements.
3567
3568 Returns nil if a cycle was detected, otherwise a new value for CHECK
3569 that includes EL.
3570
3571 CHECK is evaluated multiple times, EL and SUSPICIOUS 0 or 1 times, so
3572 the caller should make sure that's ok. */
3573
3574#define CYCLE_CHECK(check, el, suspicious) \
3575 (NILP (check) \
3576 ? make_number (0) \
3577 : (INTEGERP (check) \
3578 ? (XFASTINT (check) < (suspicious) \
3579 ? make_number (XFASTINT (check) + 1) \
3580 : Fcons (el, Qnil)) \
3581 : (!NILP (Fmemq ((el), (check))) \
3582 ? Qnil \
3583 : Fcons ((el), (check)))))
3584
3585
3586/* SAFE_ALLOCA normally allocates memory on the stack, but if size is 3550/* SAFE_ALLOCA normally allocates memory on the stack, but if size is
3587 larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ 3551 larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */
3588 3552
3589enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; 3553enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
3590 3554
3591extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3555extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3592extern void *record_xmalloc (size_t); 3556extern 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 1dd6275684b..02b13affb6a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -50,7 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#endif 50#endif
51 51
52#include <unistd.h> 52#include <unistd.h>
53#include <math.h>
54 53
55#ifdef HAVE_SETLOCALE 54#ifdef HAVE_SETLOCALE
56#include <locale.h> 55#include <locale.h>
@@ -1680,6 +1679,17 @@ readevalloop (Lisp_Object readcharfun,
1680 int whole_buffer = 0; 1679 int whole_buffer = 0;
1681 /* 1 on the first time around. */ 1680 /* 1 on the first time around. */
1682 int first_sexp = 1; 1681 int first_sexp = 1;
1682 Lisp_Object macroexpand = intern ("internal-macroexpand-for-load");
1683
1684 if (NILP (Ffboundp (macroexpand))
1685 /* Don't macroexpand in .elc files, since it should have been done
1686 already. We actually don't know whether we're in a .elc file or not,
1687 so we use circumstancial evidence: .el files normally go through
1688 Vload_source_file_function -> load-with-code-conversion
1689 -> eval-buffer. */
1690 || EQ (readcharfun, Qget_file_char)
1691 || EQ (readcharfun, Qget_emacs_mule_file_char))
1692 macroexpand = Qnil;
1683 1693
1684 if (MARKERP (readcharfun)) 1694 if (MARKERP (readcharfun))
1685 { 1695 {
@@ -1694,7 +1704,7 @@ readevalloop (Lisp_Object readcharfun,
1694 1704
1695 /* We assume START is nil when input is not from a buffer. */ 1705 /* We assume START is nil when input is not from a buffer. */
1696 if (! NILP (start) && !b) 1706 if (! NILP (start) && !b)
1697 abort (); 1707 emacs_abort ();
1698 1708
1699 specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */ 1709 specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */
1700 specbind (Qcurrent_load_list, Qnil); 1710 specbind (Qcurrent_load_list, Qnil);
@@ -1809,6 +1819,8 @@ readevalloop (Lisp_Object readcharfun,
1809 unbind_to (count1, Qnil); 1819 unbind_to (count1, Qnil);
1810 1820
1811 /* Now eval what we just read. */ 1821 /* Now eval what we just read. */
1822 if (!NILP (macroexpand))
1823 val = call1 (macroexpand, val);
1812 val = eval_sub (val); 1824 val = eval_sub (val);
1813 1825
1814 if (printflag) 1826 if (printflag)
@@ -3671,7 +3683,7 @@ intern_c_string_1 (const char *str, ptrdiff_t len)
3671 /* Creating a non-pure string from a string literal not 3683 /* Creating a non-pure string from a string literal not
3672 implemented yet. We could just use make_string here and live 3684 implemented yet. We could just use make_string here and live
3673 with the extra copy. */ 3685 with the extra copy. */
3674 abort (); 3686 emacs_abort ();
3675 3687
3676 return Fintern (make_pure_c_string (str, len), obarray); 3688 return Fintern (make_pure_c_string (str, len), obarray);
3677} 3689}
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index a8dcf5f2ae8..7b9c67bf135 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1365,6 +1365,7 @@ $(BLD)/sysdep.$(O) : \
1365 $(NT_INC)/sys/stat.h \ 1365 $(NT_INC)/sys/stat.h \
1366 $(NT_INC)/unistd.h \ 1366 $(NT_INC)/unistd.h \
1367 $(GNU_LIB)/allocator.h \ 1367 $(GNU_LIB)/allocator.h \
1368 $(GNU_LIB)/execinfo.h \
1368 $(GNU_LIB)/ignore-value.h \ 1369 $(GNU_LIB)/ignore-value.h \
1369 $(GNU_LIB)/utimens.h \ 1370 $(GNU_LIB)/utimens.h \
1370 $(BLOCKINPUT_H) \ 1371 $(BLOCKINPUT_H) \
diff --git a/src/marker.c b/src/marker.c
index 4ea06c7cd57..de3c19c3bcb 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -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);
@@ -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 }
@@ -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 20770537326..bfdc68ca118 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -733,7 +733,7 @@ digest_single_submenu (int start, int end, int top_level_items)
733 733
734 /* All items should be contained in panes. */ 734 /* All items should be contained in panes. */
735 if (panes_seen == 0) 735 if (panes_seen == 0)
736 abort (); 736 emacs_abort ();
737 737
738 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 738 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
739 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 739 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
@@ -807,7 +807,7 @@ digest_single_submenu (int start, int end, int top_level_items)
807 else if (EQ (type, QCtoggle)) 807 else if (EQ (type, QCtoggle))
808 wv->button_type = BUTTON_TYPE_TOGGLE; 808 wv->button_type = BUTTON_TYPE_TOGGLE;
809 else 809 else
810 abort (); 810 emacs_abort ();
811 811
812 wv->selected = !NILP (selected); 812 wv->selected = !NILP (selected);
813 if (! STRINGP (help)) 813 if (! STRINGP (help))
diff --git a/src/minibuf.c b/src/minibuf.c
index 2035a3e3985..655a02f5eca 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -110,7 +110,7 @@ choose_minibuf_frame (void)
110 /* I don't think that any frames may validly have a null minibuffer 110 /* I don't think that any frames may validly have a null minibuffer
111 window anymore. */ 111 window anymore. */
112 if (NILP (sf->minibuffer_window)) 112 if (NILP (sf->minibuffer_window))
113 abort (); 113 emacs_abort ();
114 114
115 /* Under X, we come here with minibuf_window being the 115 /* Under X, we come here with minibuf_window being the
116 minibuffer window of the unused termcap window created in 116 minibuffer window of the unused termcap window created in
diff --git a/src/msdos.c b/src/msdos.c
index ac348e94375..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;
@@ -1393,7 +1393,7 @@ IT_insert_glyphs (struct frame *f, struct glyph *start, int len)
1393static void 1393static void
1394IT_delete_glyphs (struct frame *f, int n) 1394IT_delete_glyphs (struct frame *f, int n)
1395{ 1395{
1396 abort (); 1396 emacs_abort ();
1397} 1397}
1398 1398
1399/* set-window-configuration on window.c needs this. */ 1399/* set-window-configuration on window.c needs this. */
@@ -3013,7 +3013,7 @@ XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable)
3013 const char *p; 3013 const char *p;
3014 3014
3015 if (!enable) 3015 if (!enable)
3016 abort (); 3016 emacs_abort ();
3017 3017
3018 IT_menu_make_room (menu); 3018 IT_menu_make_room (menu);
3019 menu->submenu[menu->count] = IT_menu_create (); 3019 menu->submenu[menu->count] = IT_menu_create ();
@@ -4119,7 +4119,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4119 FD_ZERO (efds); 4119 FD_ZERO (efds);
4120 4120
4121 if (nfds != 1) 4121 if (nfds != 1)
4122 abort (); 4122 emacs_abort ();
4123 4123
4124 /* If we are looking only for the terminal, with no timeout, 4124 /* If we are looking only for the terminal, with no timeout,
4125 just read it and wait -- that's more efficient. */ 4125 just read it and wait -- that's more efficient. */
@@ -4214,26 +4214,8 @@ init_gettimeofday (void)
4214} 4214}
4215#endif 4215#endif
4216 4216
4217#ifdef abort
4218#undef abort
4219void 4217void
4220dos_abort (char *file, int line) 4218emacs_abort (void)
4221{
4222 char buffer1[200], buffer2[400];
4223 int i, j;
4224
4225 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line);
4226 for (i = j = 0; buffer1[i]; i++) {
4227 buffer2[j++] = buffer1[i];
4228 buffer2[j++] = 0x70;
4229 }
4230 dosmemput (buffer2, j, (int)ScreenPrimary);
4231 ScreenSetCursor (2, 0);
4232 abort ();
4233}
4234#else
4235void
4236abort (void)
4237{ 4219{
4238 dos_ttcooked (); 4220 dos_ttcooked ();
4239 ScreenSetCursor (10, 0); 4221 ScreenSetCursor (10, 0);
@@ -4249,7 +4231,6 @@ abort (void)
4249#endif /* __DJGPP_MINOR__ >= 2 */ 4231#endif /* __DJGPP_MINOR__ >= 2 */
4250 exit (2); 4232 exit (2);
4251} 4233}
4252#endif
4253 4234
4254void 4235void
4255syms_of_msdos (void) 4236syms_of_msdos (void)
diff --git a/src/nsfns.m b/src/nsfns.m
index e8b5d22077a..f73086eeee9 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -30,7 +30,6 @@ 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> 34#include <setjmp.h>
36#include <c-strcase.h> 35#include <c-strcase.h>
diff --git a/src/nsfont.m b/src/nsfont.m
index 412a6777c64..1c9976ec6cc 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -625,7 +625,7 @@ static unsigned int nsfont_encode_char (struct font *font, int c);
625static int nsfont_text_extents (struct font *font, unsigned int *code, 625static int nsfont_text_extents (struct font *font, unsigned int *code,
626 int nglyphs, struct font_metrics *metrics); 626 int nglyphs, struct font_metrics *metrics);
627static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, 627static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
628 int with_background); 628 bool with_background);
629 629
630struct font_driver nsfont_driver = 630struct font_driver nsfont_driver =
631 { 631 {
@@ -833,7 +833,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
833 font = (struct font *) font_info; 833 font = (struct font *) font_info;
834 font->pixel_size = [sfont pointSize]; 834 font->pixel_size = [sfont pointSize];
835 font->driver = &nsfont_driver; 835 font->driver = &nsfont_driver;
836 font->encoding_type = FONT_ENCODING_NOT_DECIDED;
837 font->encoding_charset = -1; 836 font->encoding_charset = -1;
838 font->repertory_charset = -1; 837 font->repertory_charset = -1;
839 font->default_ascent = 0; 838 font->default_ascent = 0;
@@ -1042,12 +1041,12 @@ nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
1042 1041
1043 1042
1044/* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel 1043/* 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 1044 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 1045 fill the background in advance. It is assured that WITH_BACKGROUND
1047 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ 1046 is false when (FROM > 0 || TO < S->nchars). */
1048static int 1047static int
1049nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, 1048nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1050 int with_background) 1049 bool with_background)
1051/* NOTE: focus and clip must be set 1050/* NOTE: focus and clip must be set
1052 also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ 1051 also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
1053{ 1052{
@@ -1330,7 +1329,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
1330 1329
1331 font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); 1330 font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short));
1332 if (!unichars || !(font_info->glyphs[block])) 1331 if (!unichars || !(font_info->glyphs[block]))
1333 abort (); 1332 emacs_abort ();
1334 1333
1335 /* create a string containing all Unicode characters in this block */ 1334 /* create a string containing all Unicode characters in this block */
1336 for (idx = block<<8, i = 0; i < 0x100; idx++, i++) 1335 for (idx = block<<8, i = 0; i < 0x100; idx++, i++)
@@ -1405,7 +1404,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
1405 1404
1406 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); 1405 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics));
1407 if (!(font_info->metrics[block])) 1406 if (!(font_info->metrics[block]))
1408 abort (); 1407 emacs_abort ();
1409 1408
1410 metrics = font_info->metrics[block]; 1409 metrics = font_info->metrics[block];
1411 for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) 1410 for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++)
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 9e290486213..d0f3e45e939 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -948,7 +948,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
948 else if (EQ (type, QCradio)) 948 else if (EQ (type, QCradio))
949 wv->button_type = BUTTON_TYPE_RADIO; 949 wv->button_type = BUTTON_TYPE_RADIO;
950 else 950 else
951 abort (); 951 emacs_abort ();
952 952
953 wv->selected = !NILP (selected); 953 wv->selected = !NILP (selected);
954 954
diff --git a/src/nsterm.h b/src/nsterm.h
index f0cae193005..b1836692b2c 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;
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..74a3d858710 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -650,7 +650,6 @@ ns_update_window_begin (struct window *w)
650 struct frame *f = XFRAME (WINDOW_FRAME (w)); 650 struct frame *f = XFRAME (WINDOW_FRAME (w));
651 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 651 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
652 NSTRACE (ns_update_window_begin); 652 NSTRACE (ns_update_window_begin);
653
654 updated_window = w; 653 updated_window = w;
655 set_output_cursor (&w->cursor); 654 set_output_cursor (&w->cursor);
656 655
@@ -871,25 +870,12 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, int area, BOOL gc)
871 870
872 window_box (w, area, &window_x, &window_y, &window_width, 0); 871 window_box (w, area, &window_x, &window_y, &window_width, 0);
873 872
874 clip_rect.origin.x = window_x - FRAME_INTERNAL_BORDER_WIDTH (f); 873 clip_rect.origin.x = window_x;
875 clip_rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y)); 874 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); 875 clip_rect.origin.y = max (clip_rect.origin.y, window_y);
877 clip_rect.size.width = window_width + 2 * FRAME_INTERNAL_BORDER_WIDTH (f); 876 clip_rect.size.width = window_width;
878 clip_rect.size.height = row->visible_height; 877 clip_rect.size.height = row->visible_height;
879 878
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); 879 ns_focus (f, &clip_rect, 1);
894} 880}
895 881
@@ -1237,18 +1223,10 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1237 NSRect wr = [window frame]; 1223 NSRect wr = [window frame];
1238 int tb = FRAME_EXTERNAL_TOOL_BAR (f); 1224 int tb = FRAME_EXTERNAL_TOOL_BAR (f);
1239 int pixelwidth, pixelheight; 1225 int pixelwidth, pixelheight;
1240 static int oldRows, oldCols, oldFontWidth, oldFontHeight;
1241 static int oldTB;
1242 static struct frame *oldF;
1243 1226
1244 NSTRACE (x_set_window_size); 1227 NSTRACE (x_set_window_size);
1245 1228
1246 if (view == nil || 1229 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; 1230 return;
1253 1231
1254/*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */ 1232/*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */
@@ -1256,12 +1234,6 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1256 BLOCK_INPUT; 1234 BLOCK_INPUT;
1257 1235
1258 check_frame_size (f, &rows, &cols); 1236 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 1237
1266 f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); 1238 f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
1267 compute_fringe_widths (f, 0); 1239 compute_fringe_widths (f, 0);
@@ -1939,7 +1911,7 @@ ns_redraw_scroll_bars (struct frame *f)
1939 int i; 1911 int i;
1940 id view; 1912 id view;
1941 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; 1913 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews];
1942 NSTRACE (ns_judge_scroll_bars); 1914 NSTRACE (ns_redraw_scroll_bars);
1943 for (i =[subviews count]-1; i >= 0; i--) 1915 for (i =[subviews count]-1; i >= 0; i--)
1944 { 1916 {
1945 view = [subviews objectAtIndex: i]; 1917 view = [subviews objectAtIndex: i];
@@ -2125,9 +2097,9 @@ ns_after_update_window_line (struct glyph_row *desired_row)
2125 desired_row->redraw_fringe_bitmaps_p = 1; 2097 desired_row->redraw_fringe_bitmaps_p = 1;
2126 2098
2127 /* When a window has disappeared, make sure that no rest of 2099 /* When a window has disappeared, make sure that no rest of
2128 full-width rows stays visible in the internal border. 2100 full-width rows stays visible in the internal border. */
2129 Under NS this is drawn inside the fringes. */
2130 if (windows_or_buffers_changed 2101 if (windows_or_buffers_changed
2102 && desired_row->full_width_p
2131 && (f = XFRAME (w->frame), 2103 && (f = XFRAME (w->frame),
2132 width = FRAME_INTERNAL_BORDER_WIDTH (f), 2104 width = FRAME_INTERNAL_BORDER_WIDTH (f),
2133 width != 0) 2105 width != 0)
@@ -2136,24 +2108,11 @@ ns_after_update_window_line (struct glyph_row *desired_row)
2136 { 2108 {
2137 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 2109 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
2138 2110
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; 2111 BLOCK_INPUT;
2146 if (!desired_row->full_width_p) 2112 ns_clear_frame_area (f, 0, y, width, height);
2147 { 2113 ns_clear_frame_area (f,
2148 int x1 = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w) 2114 FRAME_PIXEL_WIDTH (f) - width,
2149 + WINDOW_LEFT_FRINGE_WIDTH (w); 2115 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; 2116 UNBLOCK_INPUT;
2158 } 2117 }
2159} 2118}
@@ -2238,17 +2197,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2238 int rowY; 2197 int rowY;
2239 static EmacsImage **bimgs = NULL; 2198 static EmacsImage **bimgs = NULL;
2240 static int nBimgs = 0; 2199 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 2200
2253 /* grow bimgs if needed */ 2201 /* grow bimgs if needed */
2254 if (nBimgs < max_used_fringe_bitmap) 2202 if (nBimgs < max_used_fringe_bitmap)
@@ -2263,22 +2211,68 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2263 rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 2211 rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
2264 ns_clip_to_row (w, row, -1, YES); 2212 ns_clip_to_row (w, row, -1, YES);
2265 2213
2266 if (p->bx >= 0 && !p->overlay_p) 2214 if (!p->overlay_p)
2267 { 2215 {
2268 int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ? 2216 int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny;
2269 -FRAME_INTERNAL_BORDER_WIDTH (f) : 0; 2217
2270 int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ? 2218 /* If the fringe is adjacent to the left (right) scroll bar of a
2271 FRAME_INTERNAL_BORDER_WIDTH (f) : 0 2219 leftmost (rightmost, respectively) window, then extend its
2272 + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0); 2220 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); 2221 if ((WINDOW_LEFTMOST_P (w)
2274 NSRectClip (r); 2222 && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
2275 [ns_lookup_indexed_color(face->background, f) set]; 2223 || (WINDOW_RIGHTMOST_P (w)
2276 NSRectFill (r); 2224 && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)))
2225 {
2226 int sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
2227
2228 if (sb_width > 0)
2229 {
2230 int bar_area_x = WINDOW_SCROLL_BAR_AREA_X (w);
2231 int bar_area_width = (WINDOW_CONFIG_SCROLL_BAR_COLS (w)
2232 * FRAME_COLUMN_WIDTH (f));
2233
2234 if (bx < 0)
2235 {
2236 /* Bitmap fills the fringe. */
2237 if (bar_area_x + bar_area_width == p->x)
2238 bx = bar_area_x + sb_width;
2239 else if (p->x + p->wd == bar_area_x)
2240 bx = bar_area_x;
2241 if (bx >= 0)
2242 {
2243 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
2244
2245 nx = bar_area_width - sb_width;
2246 by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
2247 row->y));
2248 ny = row->visible_height;
2249 }
2250 }
2251 else
2252 {
2253 if (bar_area_x + bar_area_width == bx)
2254 {
2255 bx = bar_area_x + sb_width;
2256 nx += bar_area_width - sb_width;
2257 }
2258 else if (bx + nx == bar_area_x)
2259 nx += bar_area_width - sb_width;
2260 }
2261 }
2262 }
2263
2264 if (bx >= 0 && nx > 0)
2265 {
2266 NSRect r = NSMakeRect (bx, by, nx, ny);
2267 NSRectClip (r);
2268 [ns_lookup_indexed_color (face->background, f) set];
2269 NSRectFill (r);
2270 }
2277 } 2271 }
2278 2272
2279 if (p->which) 2273 if (p->which)
2280 { 2274 {
2281 NSRect r = NSMakeRect (p->x+xAdjust, p->y, p->wd, p->h); 2275 NSRect r = NSMakeRect (p->x, p->y, p->wd, p->h);
2282 EmacsImage *img = bimgs[p->which - 1]; 2276 EmacsImage *img = bimgs[p->which - 1];
2283 2277
2284 if (!img) 2278 if (!img)
@@ -2288,7 +2282,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2288 int i; 2282 int i;
2289 unsigned char *cbits = xmalloc (len); 2283 unsigned char *cbits = xmalloc (len);
2290 2284
2291 for (i =0; i<len; i++) 2285 for (i = 0; i < len; i++)
2292 cbits[i] = ~(bits[i] & 0xff); 2286 cbits[i] = ~(bits[i] & 0xff);
2293 img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h 2287 img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h
2294 flip: NO]; 2288 flip: NO];
@@ -2302,12 +2296,20 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2302 [ns_lookup_indexed_color(face->background, f) set]; 2296 [ns_lookup_indexed_color(face->background, f) set];
2303 NSRectFill (r); 2297 NSRectFill (r);
2304 [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)]; 2298 [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)];
2299#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
2305 [img drawInRect: r 2300 [img drawInRect: r
2306 fromRect: NSZeroRect 2301 fromRect: NSZeroRect
2307 operation: NSCompositeSourceOver 2302 operation: NSCompositeSourceOver
2308 fraction: 1.0 2303 fraction: 1.0
2309 respectFlipped: YES 2304 respectFlipped: YES
2310 hints: nil]; 2305 hints: nil];
2306#else
2307 {
2308 NSPoint pt = r.origin;
2309 pt.y += p->h;
2310 [img compositeToPoint: pt operation: NSCompositeSourceOver];
2311 }
2312#endif
2311 } 2313 }
2312 ns_unfocus (f); 2314 ns_unfocus (f);
2313} 2315}
@@ -2386,14 +2388,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2386 r.size.height = h; 2388 r.size.height = h;
2387 r.size.width = w->phys_cursor_width; 2389 r.size.width = w->phys_cursor_width;
2388 2390
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.. 2391 /* TODO: only needed in rare cases with last-resort font in HELLO..
2398 should we do this more efficiently? */ 2392 should we do this more efficiently? */
2399 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */ 2393 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
@@ -2517,31 +2511,6 @@ hide_hourglass (void)
2517 2511
2518 ========================================================================== */ 2512 ========================================================================== */
2519 2513
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 2514static int
2546ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) 2515ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2547/* -------------------------------------------------------------------------- 2516/* --------------------------------------------------------------------------
@@ -2551,14 +2520,6 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2551 -------------------------------------------------------------------------- */ 2520 -------------------------------------------------------------------------- */
2552{ 2521{
2553 int n = get_glyph_string_clip_rects (s, nr, 2); 2522 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; 2523 return n;
2563} 2524}
2564 2525
@@ -2883,11 +2844,6 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
2883 2844
2884 r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height); 2845 r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height);
2885 2846
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. */ 2847 /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */
2892 if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color) 2848 if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
2893 { 2849 {
@@ -2943,26 +2899,6 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
2943 NSRect r = NSMakeRect (s->x, s->y + box_line_width, 2899 NSRect r = NSMakeRect (s->x, s->y + box_line_width,
2944 s->background_width, 2900 s->background_width,
2945 s->height-2*box_line_width); 2901 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); 2902 NSRectFill (r);
2967 } 2903 }
2968 2904
@@ -3028,34 +2964,23 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
3028 br = NSMakeRect (x, y, s->slice.width, s->slice.height); 2964 br = NSMakeRect (x, y, s->slice.width, s->slice.height);
3029 } 2965 }
3030 2966
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); 2967 NSRectFill (br);
3050 2968
3051 /* Draw the image.. do we need to draw placeholder if img ==nil? */ 2969 /* Draw the image.. do we need to draw placeholder if img ==nil? */
3052 if (img != nil) 2970 if (img != nil)
2971 {
2972#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
3053 [img drawInRect: br 2973 [img drawInRect: br
3054 fromRect: NSZeroRect 2974 fromRect: NSZeroRect
3055 operation: NSCompositeSourceOver 2975 operation: NSCompositeSourceOver
3056 fraction: 1.0 2976 fraction: 1.0
3057 respectFlipped: YES 2977 respectFlipped: YES
3058 hints: nil]; 2978 hints: nil];
2979#else
2980 [img compositeToPoint: NSMakePoint (x, y + s->slice.height)
2981 operation: NSCompositeSourceOver];
2982#endif
2983 }
3059 2984
3060 if (s->hl == DRAW_CURSOR) 2985 if (s->hl == DRAW_CURSOR)
3061 { 2986 {
@@ -3143,7 +3068,7 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3143 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f); 3068 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3144 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); 3069 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3145 3070
3146 for (i=0; i<n; i++) 3071 for (i = 0; i < n; ++i)
3147 { 3072 {
3148 if (!s->row->full_width_p) 3073 if (!s->row->full_width_p)
3149 { 3074 {
@@ -3173,13 +3098,6 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3173 r[i].size.height = min (s->height, s->row->visible_height); 3098 r[i].size.height = min (s->height, s->row->visible_height);
3174 } 3099 }
3175 3100
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]; 3101 [bgCol set];
3184 3102
3185 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid 3103 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid
@@ -3340,7 +3258,7 @@ ns_draw_glyph_string (struct glyph_string *s)
3340 break; 3258 break;
3341 3259
3342 default: 3260 default:
3343 abort (); 3261 emacs_abort ();
3344 } 3262 }
3345 3263
3346 /* Draw box if not done already. */ 3264 /* Draw box if not done already. */
@@ -3475,7 +3393,7 @@ ns_read_socket (struct terminal *terminal, int expected,
3475 3393
3476 if (++apploopnr != 1) 3394 if (++apploopnr != 1)
3477 { 3395 {
3478 abort (); 3396 emacs_abort ();
3479 } 3397 }
3480 [NSApp run]; 3398 [NSApp run];
3481 --apploopnr; 3399 --apploopnr;
@@ -3515,7 +3433,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3515 [outerpool release]; 3433 [outerpool release];
3516 outerpool = [[NSAutoreleasePool alloc] init]; 3434 outerpool = [[NSAutoreleasePool alloc] init];
3517 3435
3518 3436
3519 send_appdefined = YES; 3437 send_appdefined = YES;
3520 if (nr > 0) 3438 if (nr > 0)
3521 { 3439 {
@@ -3568,7 +3486,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3568 emacs_event = &event; 3486 emacs_event = &event;
3569 if (++apploopnr != 1) 3487 if (++apploopnr != 1)
3570 { 3488 {
3571 abort(); 3489 emacs_abort ();
3572 } 3490 }
3573 [NSApp run]; 3491 [NSApp run];
3574 --apploopnr; 3492 --apploopnr;
@@ -3586,7 +3504,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3586 { 3504 {
3587 int t; 3505 int t;
3588 if ([ev type] != NSApplicationDefined) 3506 if ([ev type] != NSApplicationDefined)
3589 abort (); 3507 emacs_abort ();
3590 3508
3591 t = [ev data1]; 3509 t = [ev data1];
3592 last_appdefined_event = 0; 3510 last_appdefined_event = 0;
@@ -3639,9 +3557,9 @@ ns_set_vertical_scroll_bar (struct window *window,
3639 struct frame *f = XFRAME (WINDOW_FRAME (window)); 3557 struct frame *f = XFRAME (WINDOW_FRAME (window));
3640 EmacsView *view = FRAME_NS_VIEW (f); 3558 EmacsView *view = FRAME_NS_VIEW (f);
3641 int window_y, window_height; 3559 int window_y, window_height;
3642 BOOL barOnVeryLeft, barOnVeryRight;
3643 int top, left, height, width, sb_width, sb_left; 3560 int top, left, height, width, sb_width, sb_left;
3644 EmacsScroller *bar; 3561 EmacsScroller *bar;
3562 BOOL fringe_extended_p;
3645 3563
3646 /* optimization; display engine sends WAY too many of these.. */ 3564 /* optimization; display engine sends WAY too many of these.. */
3647 if (!NILP (window->vertical_scroll_bar)) 3565 if (!NILP (window->vertical_scroll_bar))
@@ -3668,26 +3586,27 @@ ns_set_vertical_scroll_bar (struct window *window,
3668 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f); 3586 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f);
3669 left = WINDOW_SCROLL_BAR_AREA_X (window); 3587 left = WINDOW_SCROLL_BAR_AREA_X (window);
3670 3588
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 */ 3589 /* allow for displaying a skinnier scrollbar than char area allotted */
3678 sb_width = (WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) > 0) ? 3590 sb_width = (WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) > 0) ?
3679 WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) : width; 3591 WINDOW_CONFIG_SCROLL_BAR_WIDTH (window) : width;
3680 3592 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 3593
3686 r = NSMakeRect (sb_left, top, sb_width, height); 3594 r = NSMakeRect (sb_left, top, sb_width, height);
3687 /* the parent view is flipped, so we need to flip y value */ 3595 /* the parent view is flipped, so we need to flip y value */
3688 v = [view frame]; 3596 v = [view frame];
3689 r.origin.y = (v.size.height - r.size.height - r.origin.y); 3597 r.origin.y = (v.size.height - r.size.height - r.origin.y);
3690 3598
3599 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (window))
3600 fringe_extended_p = (WINDOW_LEFTMOST_P (window)
3601 && WINDOW_LEFT_FRINGE_WIDTH (window)
3602 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window)
3603 || WINDOW_LEFT_MARGIN_COLS (window) == 0));
3604 else
3605 fringe_extended_p = (WINDOW_RIGHTMOST_P (window)
3606 && WINDOW_RIGHT_FRINGE_WIDTH (window)
3607 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (window)
3608 || WINDOW_RIGHT_MARGIN_COLS (window) == 0));
3609
3691 XSETWINDOW (win, window); 3610 XSETWINDOW (win, window);
3692 BLOCK_INPUT; 3611 BLOCK_INPUT;
3693 3612
@@ -3707,7 +3626,14 @@ ns_set_vertical_scroll_bar (struct window *window,
3707 3626
3708 if (NILP (window->vertical_scroll_bar)) 3627 if (NILP (window->vertical_scroll_bar))
3709 { 3628 {
3710 ns_clear_frame_area (f, sb_left, top, width, height); 3629 if (width > 0 && height > 0)
3630 {
3631 if (fringe_extended_p)
3632 ns_clear_frame_area (f, sb_left, top, sb_width, height);
3633 else
3634 ns_clear_frame_area (f, left, top, width, height);
3635 }
3636
3711 bar = [[EmacsScroller alloc] initFrame: r window: win]; 3637 bar = [[EmacsScroller alloc] initFrame: r window: win];
3712 wset_vertical_scroll_bar (window, make_save_value (bar, 0)); 3638 wset_vertical_scroll_bar (window, make_save_value (bar, 0));
3713 } 3639 }
@@ -3778,14 +3704,21 @@ ns_judge_scroll_bars (struct frame *f)
3778{ 3704{
3779 int i; 3705 int i;
3780 id view; 3706 id view;
3781 NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; 3707 EmacsView *eview = FRAME_NS_VIEW (f);
3708 NSArray *subviews = [[eview superview] subviews];
3709 BOOL removed = NO;
3710
3782 NSTRACE (ns_judge_scroll_bars); 3711 NSTRACE (ns_judge_scroll_bars);
3783 for (i =[subviews count]-1; i >= 0; i--) 3712 for (i = [subviews count]-1; i >= 0; --i)
3784 { 3713 {
3785 view = [subviews objectAtIndex: i]; 3714 view = [subviews objectAtIndex: i];
3786 if (![view isKindOfClass: [EmacsScroller class]]) continue; 3715 if (![view isKindOfClass: [EmacsScroller class]]) continue;
3787 [view judge]; 3716 [view judge];
3717 removed = YES;
3788 } 3718 }
3719
3720 if (removed)
3721 [eview updateFrameSize];
3789} 3722}
3790 3723
3791 3724
@@ -4053,7 +3986,7 @@ ns_term_init (Lisp_Object display_name)
4053 { 3986 {
4054 fprintf (stderr, "Failed to create pipe: %s\n", 3987 fprintf (stderr, "Failed to create pipe: %s\n",
4055 emacs_strerror (errno)); 3988 emacs_strerror (errno));
4056 abort (); 3989 emacs_abort ();
4057 } 3990 }
4058 3991
4059 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); 3992 fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL));
@@ -4273,7 +4206,7 @@ ns_term_shutdown (int sig)
4273 } 4206 }
4274 else // force a stack trace to happen 4207 else // force a stack trace to happen
4275 { 4208 {
4276 abort(); 4209 emacs_abort ();
4277 } 4210 }
4278} 4211}
4279 4212
@@ -4534,10 +4467,10 @@ not_in_argv (NSString *arg)
4534 /* Don't open files from the command line unconditionally, 4467 /* Don't open files from the command line unconditionally,
4535 Cocoa parses the command line wrong, --option value tries to open value 4468 Cocoa parses the command line wrong, --option value tries to open value
4536 if --option is the last option. */ 4469 if --option is the last option. */
4537 while ((file = [files nextObject]) != nil) 4470 while ((file = [files nextObject]) != nil)
4538 if (ns_do_open_file || not_in_argv (file)) 4471 if (ns_do_open_file || not_in_argv (file))
4539 [ns_pending_files addObject: file]; 4472 [ns_pending_files addObject: file];
4540 4473
4541 [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; 4474 [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
4542 4475
4543} 4476}
@@ -4604,7 +4537,7 @@ not_in_argv (NSString *arg)
4604 4537
4605 /* NSTRACE (fd_handler); */ 4538 /* NSTRACE (fd_handler); */
4606 4539
4607 for (;;) 4540 for (;;)
4608 { 4541 {
4609 [pool release]; 4542 [pool release];
4610 pool = [[NSAutoreleasePool alloc] init]; 4543 pool = [[NSAutoreleasePool alloc] init];
@@ -4889,7 +4822,7 @@ not_in_argv (NSString *arg)
4889 is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask; 4822 is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask;
4890 is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask 4823 is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask
4891 || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask); 4824 || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask);
4892 4825
4893 if (is_right_key) 4826 if (is_right_key)
4894 emacs_event->modifiers |= parse_solitary_modifier 4827 emacs_event->modifiers |= parse_solitary_modifier
4895 (EQ (ns_right_command_modifier, Qleft) 4828 (EQ (ns_right_command_modifier, Qleft)
@@ -5420,6 +5353,50 @@ not_in_argv (NSString *arg)
5420 return NO; 5353 return NO;
5421} 5354}
5422 5355
5356- (void) updateFrameSize
5357{
5358 NSWindow *window = [self window];
5359 NSRect wr = [window frame];
5360#ifdef NS_IMPL_GNUSTEP
5361 int extra = 3;
5362#else
5363 int extra = 0;
5364#endif
5365
5366 int oldc = cols, oldr = rows;
5367 int oldw = FRAME_PIXEL_WIDTH (emacsframe),
5368 oldh = FRAME_PIXEL_HEIGHT (emacsframe);
5369 int neww, newh;
5370
5371 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + extra);
5372
5373 if (cols < MINWIDTH)
5374 cols = MINWIDTH;
5375
5376 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES
5377 (emacsframe, wr.size.height
5378 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + extra
5379 - FRAME_TOOLBAR_HEIGHT (emacsframe));
5380
5381 if (rows < MINHEIGHT)
5382 rows = MINHEIGHT;
5383
5384 neww = (int)wr.size.width - emacsframe->border_width;
5385 newh = ((int)wr.size.height
5386 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
5387 - FRAME_TOOLBAR_HEIGHT (emacsframe));
5388
5389 if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
5390 {
5391 NSView *view = FRAME_NS_VIEW (emacsframe);
5392 FRAME_PIXEL_WIDTH (emacsframe) = neww;
5393 FRAME_PIXEL_HEIGHT (emacsframe) = newh;
5394 change_frame_size (emacsframe, rows, cols, 0, 0, 1);
5395 SET_FRAME_GARBAGED (emacsframe);
5396 cancel_mouse_face (emacsframe);
5397 [view setFrame: NSMakeRect (0, 0, neww, newh)];
5398 }
5399}
5423 5400
5424- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize 5401- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
5425/* normalize frame to gridded text size */ 5402/* normalize frame to gridded text size */
@@ -5517,16 +5494,7 @@ not_in_argv (NSString *arg)
5517 x_set_window_size (emacsframe, 0, cols, rows); 5494 x_set_window_size (emacsframe, 0, cols, rows);
5518 else 5495 else
5519 { 5496 {
5520 NSWindow *window = [self window]; 5497 [self updateFrameSize];
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 } 5498 }
5531 } 5499 }
5532#endif 5500#endif
@@ -5853,7 +5821,7 @@ not_in_argv (NSString *arg)
5853 NSTRACE (menuDown); 5821 NSTRACE (menuDown);
5854 if (context_menu_value == -1) 5822 if (context_menu_value == -1)
5855 context_menu_value = [sender tag]; 5823 context_menu_value = [sender tag];
5856 else 5824 else
5857 { 5825 {
5858 NSInteger tag = [sender tag]; 5826 NSInteger tag = [sender tag];
5859 find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used, 5827 find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used,
@@ -6180,7 +6148,7 @@ not_in_argv (NSString *arg)
6180 Lisp_Object str = Qnil; 6148 Lisp_Object str = Qnil;
6181 struct frame *f = SELECTED_FRAME (); 6149 struct frame *f = SELECTED_FRAME ();
6182 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); 6150 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer);
6183 6151
6184 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) 6152 if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
6185 return NSAccessibilityTextFieldRole; 6153 return NSAccessibilityTextFieldRole;
6186 6154
@@ -6193,13 +6161,13 @@ not_in_argv (NSString *arg)
6193 { 6161 {
6194 if (! NILP (BVAR (curbuf, mark_active))) 6162 if (! NILP (BVAR (curbuf, mark_active)))
6195 str = ns_get_local_selection (QPRIMARY, QUTF8_STRING); 6163 str = ns_get_local_selection (QPRIMARY, QUTF8_STRING);
6196 6164
6197 if (NILP (str)) 6165 if (NILP (str))
6198 { 6166 {
6199 ptrdiff_t start_byte = BUF_BEGV_BYTE (curbuf); 6167 ptrdiff_t start_byte = BUF_BEGV_BYTE (curbuf);
6200 ptrdiff_t byte_range = BUF_ZV_BYTE (curbuf) - start_byte; 6168 ptrdiff_t byte_range = BUF_ZV_BYTE (curbuf) - start_byte;
6201 ptrdiff_t range = BUF_ZV (curbuf) - BUF_BEGV (curbuf); 6169 ptrdiff_t range = BUF_ZV (curbuf) - BUF_BEGV (curbuf);
6202 6170
6203 if (! NILP (BVAR (curbuf, enable_multibyte_characters))) 6171 if (! NILP (BVAR (curbuf, enable_multibyte_characters)))
6204 str = make_uninit_multibyte_string (range, byte_range); 6172 str = make_uninit_multibyte_string (range, byte_range);
6205 else 6173 else
@@ -6209,9 +6177,9 @@ not_in_argv (NSString *arg)
6209 memcpy (SDATA (str), BYTE_POS_ADDR (start_byte), byte_range); 6177 memcpy (SDATA (str), BYTE_POS_ADDR (start_byte), byte_range);
6210 } 6178 }
6211 } 6179 }
6212 6180
6213 6181
6214 if (! NILP (str)) 6182 if (! NILP (str))
6215 { 6183 {
6216 if (CONSP (str) && SYMBOLP (XCAR (str))) 6184 if (CONSP (str) && SYMBOLP (XCAR (str)))
6217 { 6185 {
@@ -6226,7 +6194,7 @@ not_in_argv (NSString *arg)
6226 return nsStr; 6194 return nsStr;
6227 } 6195 }
6228 } 6196 }
6229 6197
6230 return [super accessibilityAttributeValue:attribute]; 6198 return [super accessibilityAttributeValue:attribute];
6231} 6199}
6232#endif /* NS_IMPL_COCOA */ 6200#endif /* NS_IMPL_COCOA */
@@ -6242,8 +6210,11 @@ not_in_argv (NSString *arg)
6242 NSTRACE (constrainFrameRect); 6210 NSTRACE (constrainFrameRect);
6243 6211
6244 if (nr_screens == 1) 6212 if (nr_screens == 1)
6245 return [super constrainFrameRect:frameRect toScreen:screen]; 6213 {
6246 6214 NSRect r = [super constrainFrameRect:frameRect toScreen:screen];
6215 return r;
6216 }
6217
6247 if (f->output_data.ns->dont_constrain 6218 if (f->output_data.ns->dont_constrain
6248 || ns_menu_bar_should_be_hidden ()) 6219 || ns_menu_bar_should_be_hidden ())
6249 return frameRect; 6220 return frameRect;
diff --git a/src/print.c b/src/print.c
index 911e009ad25..c1b60c97d9e 100644
--- a/src/print.c
+++ b/src/print.c
@@ -47,15 +47,9 @@ static Lisp_Object Qtemp_buffer_setup_hook;
47 47
48static Lisp_Object Qfloat_output_format; 48static Lisp_Object Qfloat_output_format;
49 49
50#include <math.h>
51#include <float.h> 50#include <float.h>
52#include <ftoastr.h> 51#include <ftoastr.h>
53 52
54/* Default to values appropriate for IEEE floating point. */
55#ifndef DBL_DIG
56#define DBL_DIG 15
57#endif
58
59/* Avoid actual stack overflow in print. */ 53/* Avoid actual stack overflow in print. */
60static ptrdiff_t print_depth; 54static ptrdiff_t print_depth;
61 55
@@ -2069,7 +2063,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2069 { 2063 {
2070 int len; 2064 int len;
2071 /* We're in trouble if this happens! 2065 /* We're in trouble if this happens!
2072 Probably should just abort () */ 2066 Probably should just emacs_abort (). */
2073 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); 2067 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun);
2074 if (MISCP (obj)) 2068 if (MISCP (obj))
2075 len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); 2069 len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj));
diff --git a/src/process.c b/src/process.c
index 04b6abe50a7..0cc9bc353a1 100644
--- a/src/process.c
+++ b/src/process.c
@@ -23,7 +23,6 @@ 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> 28#include <setjmp.h>
@@ -124,6 +123,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
124#include "xgselect.h" 123#include "xgselect.h"
125#endif 124#endif
126 125
126#ifndef WNOHANG
127# undef waitpid
128# define waitpid(pid, status, options) wait (status)
129#endif
130#ifndef WUNTRACED
131# define WUNTRACED 0
132#endif
133
127/* Work around GCC 4.7.0 bug with strict overflow checking; see 134/* Work around GCC 4.7.0 bug with strict overflow checking; see
128 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 135 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
129 These lines can be removed once the GCC bug is fixed. */ 136 These lines can be removed once the GCC bug is fixed. */
@@ -801,7 +808,7 @@ get_process (register Lisp_Object name)
801#ifdef SIGCHLD 808#ifdef SIGCHLD
802/* Fdelete_process promises to immediately forget about the process, but in 809/* Fdelete_process promises to immediately forget about the process, but in
803 reality, Emacs needs to remember those processes until they have been 810 reality, Emacs needs to remember those processes until they have been
804 treated by sigchld_handler; otherwise this handler would consider the 811 treated by the SIGCHLD handler; otherwise this handler would consider the
805 process as being synchronous and say that the synchronous process is 812 process as being synchronous and say that the synchronous process is
806 dead. */ 813 dead. */
807static Lisp_Object deleted_pid_list; 814static Lisp_Object deleted_pid_list;
@@ -849,7 +856,8 @@ nil, indicating the current buffer's process. */)
849#endif 856#endif
850 { 857 {
851 Fkill_process (process, Qnil); 858 Fkill_process (process, Qnil);
852 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 859 /* Do this now, since remove_process will make the
860 SIGCHLD handler do nothing. */
853 pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil))); 861 pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)));
854 p->tick = ++process_tick; 862 p->tick = ++process_tick;
855 status_notify (p); 863 status_notify (p);
@@ -1577,7 +1585,7 @@ static Lisp_Object
1577start_process_unwind (Lisp_Object proc) 1585start_process_unwind (Lisp_Object proc)
1578{ 1586{
1579 if (!PROCESSP (proc)) 1587 if (!PROCESSP (proc))
1580 abort (); 1588 emacs_abort ();
1581 1589
1582 /* Was PROC started successfully? 1590 /* Was PROC started successfully?
1583 -2 is used for a pty with no process, eg for gdb. */ 1591 -2 is used for a pty with no process, eg for gdb. */
@@ -1603,8 +1611,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1603#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1611#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1604 int wait_child_setup[2]; 1612 int wait_child_setup[2];
1605#endif 1613#endif
1606 sigset_t procmask; 1614 sigset_t blocked, procmask;
1607 sigset_t blocked;
1608 struct sigaction sigint_action; 1615 struct sigaction sigint_action;
1609 struct sigaction sigquit_action; 1616 struct sigaction sigquit_action;
1610 struct sigaction sigpipe_action; 1617 struct sigaction sigpipe_action;
@@ -1728,7 +1735,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1728 if (inchannel > max_process_desc) 1735 if (inchannel > max_process_desc)
1729 max_process_desc = inchannel; 1736 max_process_desc = inchannel;
1730 1737
1731 /* Until we store the proper pid, enable sigchld_handler 1738 /* Until we store the proper pid, enable the SIGCHLD handler
1732 to recognize an unknown pid as standing for this process. 1739 to recognize an unknown pid as standing for this process.
1733 It is very important not to let this `marker' value stay 1740 It is very important not to let this `marker' value stay
1734 in the table after this function has returned; if it does 1741 in the table after this function has returned; if it does
@@ -1756,12 +1763,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1756 int xforkin = forkin; 1763 int xforkin = forkin;
1757 int xforkout = forkout; 1764 int xforkout = forkout;
1758 1765
1759#if 0 /* This was probably a mistake--it duplicates code later on,
1760 but fails to handle all the cases. */
1761 /* Make sure SIGCHLD is not blocked in the child. */
1762 sigsetmask (SIGEMPTYMASK);
1763#endif
1764
1765 /* Make the pty be the controlling terminal of the process. */ 1766 /* Make the pty be the controlling terminal of the process. */
1766#ifdef HAVE_PTYS 1767#ifdef HAVE_PTYS
1767 /* First, disconnect its current controlling terminal. */ 1768 /* First, disconnect its current controlling terminal. */
@@ -2550,7 +2551,7 @@ static Lisp_Object
2550make_serial_process_unwind (Lisp_Object proc) 2551make_serial_process_unwind (Lisp_Object proc)
2551{ 2552{
2552 if (!PROCESSP (proc)) 2553 if (!PROCESSP (proc))
2553 abort (); 2554 emacs_abort ();
2554 remove_process (proc); 2555 remove_process (proc);
2555 return Qnil; 2556 return Qnil;
2556} 2557}
@@ -3387,7 +3388,7 @@ usage: (make-network-process &rest ARGS) */)
3387 if (socktype == SOCK_DGRAM) 3388 if (socktype == SOCK_DGRAM)
3388 { 3389 {
3389 if (datagram_address[s].sa) 3390 if (datagram_address[s].sa)
3390 abort (); 3391 emacs_abort ();
3391 datagram_address[s].sa = xmalloc (lres->ai_addrlen); 3392 datagram_address[s].sa = xmalloc (lres->ai_addrlen);
3392 datagram_address[s].len = lres->ai_addrlen; 3393 datagram_address[s].len = lres->ai_addrlen;
3393 if (is_server) 3394 if (is_server)
@@ -3973,7 +3974,7 @@ deactivate_process (Lisp_Object proc)
3973 FD_CLR (inchannel, &connect_wait_mask); 3974 FD_CLR (inchannel, &connect_wait_mask);
3974 FD_CLR (inchannel, &write_mask); 3975 FD_CLR (inchannel, &write_mask);
3975 if (--num_pending_connects < 0) 3976 if (--num_pending_connects < 0)
3976 abort (); 3977 emacs_abort ();
3977 } 3978 }
3978#endif 3979#endif
3979 if (inchannel == max_process_desc) 3980 if (inchannel == max_process_desc)
@@ -4752,7 +4753,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4752 Cleanup occurs c/o status_notify after SIGCLD. */ 4753 Cleanup occurs c/o status_notify after SIGCLD. */
4753 no_avail = 1; /* Cannot depend on values returned */ 4754 no_avail = 1; /* Cannot depend on values returned */
4754#else 4755#else
4755 abort (); 4756 emacs_abort ();
4756#endif 4757#endif
4757 } 4758 }
4758 else 4759 else
@@ -4956,8 +4957,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4956 4957
4957 if (p->pid == -2) 4958 if (p->pid == -2)
4958 { 4959 {
4959 /* If the EIO occurs on a pty, sigchld_handler's 4960 /* If the EIO occurs on a pty, the SIGCHLD handler's
4960 waitpid() will not find the process object to 4961 waitpid call will not find the process object to
4961 delete. Do it here. */ 4962 delete. Do it here. */
4962 p->tick = ++process_tick; 4963 p->tick = ++process_tick;
4963 pset_status (p, Qfailed); 4964 pset_status (p, Qfailed);
@@ -4993,7 +4994,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4993 FD_CLR (channel, &connect_wait_mask); 4994 FD_CLR (channel, &connect_wait_mask);
4994 FD_CLR (channel, &write_mask); 4995 FD_CLR (channel, &write_mask);
4995 if (--num_pending_connects < 0) 4996 if (--num_pending_connects < 0)
4996 abort (); 4997 emacs_abort ();
4997 4998
4998 proc = chan_process[channel]; 4999 proc = chan_process[channel];
4999 if (NILP (proc)) 5000 if (NILP (proc))
@@ -5422,16 +5423,20 @@ read_process_output (Lisp_Object proc, register int channel)
5422static jmp_buf send_process_frame; 5423static jmp_buf send_process_frame;
5423static Lisp_Object process_sent_to; 5424static Lisp_Object process_sent_to;
5424 5425
5425#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 5426static _Noreturn void
5426static _Noreturn void send_process_trap (int); 5427handle_pipe_signal (int sig)
5427#endif 5428{
5429 sigset_t unblocked;
5430 sigemptyset (&unblocked);
5431 sigaddset (&unblocked, SIGPIPE);
5432 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
5433 _longjmp (send_process_frame, 1);
5434}
5428 5435
5429static void 5436static void
5430send_process_trap (int ignore) 5437deliver_pipe_signal (int sig)
5431{ 5438{
5432 SIGNAL_THREAD_CHECK (SIGPIPE); 5439 handle_on_main_thread (sig, handle_pipe_signal);
5433 sigunblock (sigmask (SIGPIPE));
5434 longjmp (send_process_frame, 1);
5435} 5440}
5436 5441
5437/* In send_process, when a write fails temporarily, 5442/* In send_process, when a write fails temporarily,
@@ -5524,7 +5529,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5524 struct Lisp_Process *p = XPROCESS (proc); 5529 struct Lisp_Process *p = XPROCESS (proc);
5525 ssize_t rv; 5530 ssize_t rv;
5526 struct coding_system *coding; 5531 struct coding_system *coding;
5527 void (*volatile old_sigpipe) (int); 5532 struct sigaction old_sigpipe_action;
5528 5533
5529 if (p->raw_status_new) 5534 if (p->raw_status_new)
5530 update_status (p); 5535 update_status (p);
@@ -5634,7 +5639,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5634 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5639 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5635 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5640 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5636 when returning with longjmp despite being declared volatile. */ 5641 when returning with longjmp despite being declared volatile. */
5637 if (!setjmp (send_process_frame)) 5642 if (!_setjmp (send_process_frame))
5638 { 5643 {
5639 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5644 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5640 process_sent_to = proc; 5645 process_sent_to = proc;
@@ -5663,7 +5668,9 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5663 /* Send this batch, using one or more write calls. */ 5668 /* Send this batch, using one or more write calls. */
5664 ptrdiff_t written = 0; 5669 ptrdiff_t written = 0;
5665 int outfd = p->outfd; 5670 int outfd = p->outfd;
5666 old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap); 5671 struct sigaction action;
5672 emacs_sigaction_init (&action, deliver_pipe_signal);
5673 sigaction (SIGPIPE, &action, &old_sigpipe_action);
5667#ifdef DATAGRAM_SOCKETS 5674#ifdef DATAGRAM_SOCKETS
5668 if (DATAGRAM_CHAN_P (outfd)) 5675 if (DATAGRAM_CHAN_P (outfd))
5669 { 5676 {
@@ -5674,7 +5681,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5674 written = rv; 5681 written = rv;
5675 else if (errno == EMSGSIZE) 5682 else if (errno == EMSGSIZE)
5676 { 5683 {
5677 signal (SIGPIPE, old_sigpipe); 5684 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5678 report_file_error ("sending datagram", 5685 report_file_error ("sending datagram",
5679 Fcons (proc, Qnil)); 5686 Fcons (proc, Qnil));
5680 } 5687 }
@@ -5699,7 +5706,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5699 } 5706 }
5700#endif 5707#endif
5701 } 5708 }
5702 signal (SIGPIPE, old_sigpipe); 5709 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5703 5710
5704 if (rv < 0) 5711 if (rv < 0)
5705 { 5712 {
@@ -5759,7 +5766,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5759 } 5766 }
5760 else 5767 else
5761 { 5768 {
5762 signal (SIGPIPE, old_sigpipe); 5769 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5763 proc = process_sent_to; 5770 proc = process_sent_to;
5764 p = XPROCESS (proc); 5771 p = XPROCESS (proc);
5765 p->raw_status_new = 0; 5772 p->raw_status_new = 0;
@@ -6354,7 +6361,7 @@ process has been transmitted to the serial port. */)
6354#endif /* not HAVE_SHUTDOWN */ 6361#endif /* not HAVE_SHUTDOWN */
6355 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); 6362 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
6356 if (new_outfd < 0) 6363 if (new_outfd < 0)
6357 abort (); 6364 emacs_abort ();
6358 old_outfd = XPROCESS (proc)->outfd; 6365 old_outfd = XPROCESS (proc)->outfd;
6359 6366
6360 if (!proc_encode_coding_system[new_outfd]) 6367 if (!proc_encode_coding_system[new_outfd])
@@ -6397,143 +6404,135 @@ process has been transmitted to the serial port. */)
6397 indirectly; if it does, that is a bug */ 6404 indirectly; if it does, that is a bug */
6398 6405
6399#ifdef SIGCHLD 6406#ifdef SIGCHLD
6400static void 6407
6401sigchld_handler (int signo) 6408/* Record one child's changed status. Return true if a child was found. */
6409static bool
6410record_child_status_change (void)
6402{ 6411{
6403 int old_errno = errno;
6404 Lisp_Object proc; 6412 Lisp_Object proc;
6405 struct Lisp_Process *p; 6413 struct Lisp_Process *p;
6414 pid_t pid;
6415 int w;
6416 Lisp_Object tail;
6406 6417
6407 SIGNAL_THREAD_CHECK (signo); 6418 do
6408 6419 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6409 while (1) 6420 while (pid < 0 && errno == EINTR);
6410 {
6411 pid_t pid;
6412 int w;
6413 Lisp_Object tail;
6414
6415#ifdef WNOHANG
6416#ifndef WUNTRACED
6417#define WUNTRACED 0
6418#endif /* no WUNTRACED */
6419 /* Keep trying to get a status until we get a definitive result. */
6420 do
6421 {
6422 errno = 0;
6423 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6424 }
6425 while (pid < 0 && errno == EINTR);
6426
6427 if (pid <= 0)
6428 {
6429 /* PID == 0 means no processes found, PID == -1 means a real
6430 failure. We have done all our job, so return. */
6431 6421
6432 errno = old_errno; 6422 /* PID == 0 means no processes found, PID == -1 means a real failure.
6433 return; 6423 Either way, we have done all our job. */
6434 } 6424 if (pid <= 0)
6435#else 6425 return false;
6436 pid = wait (&w);
6437#endif /* no WNOHANG */
6438 6426
6439 /* Find the process that signaled us, and record its status. */ 6427 /* Find the process that signaled us, and record its status. */
6440 6428
6441 /* The process can have been deleted by Fdelete_process. */ 6429 /* The process can have been deleted by Fdelete_process. */
6442 for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) 6430 for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail))
6431 {
6432 Lisp_Object xpid = XCAR (tail);
6433 if ((INTEGERP (xpid) && pid == XINT (xpid))
6434 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid)))
6443 { 6435 {
6444 Lisp_Object xpid = XCAR (tail); 6436 XSETCAR (tail, Qnil);
6445 if ((INTEGERP (xpid) && pid == XINT (xpid)) 6437 return true;
6446 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid)))
6447 {
6448 XSETCAR (tail, Qnil);
6449 goto sigchld_end_of_loop;
6450 }
6451 } 6438 }
6439 }
6452 6440
6453 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ 6441 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */
6442 p = 0;
6443 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6444 {
6445 proc = XCDR (XCAR (tail));
6446 p = XPROCESS (proc);
6447 if (EQ (p->type, Qreal) && p->pid == pid)
6448 break;
6454 p = 0; 6449 p = 0;
6455 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6450 }
6456 {
6457 proc = XCDR (XCAR (tail));
6458 p = XPROCESS (proc);
6459 if (EQ (p->type, Qreal) && p->pid == pid)
6460 break;
6461 p = 0;
6462 }
6463
6464 /* Look for an asynchronous process whose pid hasn't been filled
6465 in yet. */
6466 if (p == 0)
6467 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6468 {
6469 proc = XCDR (XCAR (tail));
6470 p = XPROCESS (proc);
6471 if (p->pid == -1)
6472 break;
6473 p = 0;
6474 }
6475
6476 /* Change the status of the process that was found. */
6477 if (p != 0)
6478 {
6479 int clear_desc_flag = 0;
6480 6451
6481 p->tick = ++process_tick; 6452 /* Look for an asynchronous process whose pid hasn't been filled
6482 p->raw_status = w; 6453 in yet. */
6483 p->raw_status_new = 1; 6454 if (! p)
6455 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6456 {
6457 proc = XCDR (XCAR (tail));
6458 p = XPROCESS (proc);
6459 if (p->pid == -1)
6460 break;
6461 p = 0;
6462 }
6484 6463
6485 /* If process has terminated, stop waiting for its output. */ 6464 /* Change the status of the process that was found. */
6486 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6465 if (p)
6487 && p->infd >= 0) 6466 {
6488 clear_desc_flag = 1; 6467 int clear_desc_flag = 0;
6489 6468
6490 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ 6469 p->tick = ++process_tick;
6491 if (clear_desc_flag) 6470 p->raw_status = w;
6492 { 6471 p->raw_status_new = 1;
6493 FD_CLR (p->infd, &input_wait_mask);
6494 FD_CLR (p->infd, &non_keyboard_wait_mask);
6495 }
6496 6472
6497 /* Tell wait_reading_process_output that it needs to wake up and 6473 /* If process has terminated, stop waiting for its output. */
6498 look around. */ 6474 if ((WIFSIGNALED (w) || WIFEXITED (w))
6499 if (input_available_clear_time) 6475 && p->infd >= 0)
6500 *input_available_clear_time = make_emacs_time (0, 0); 6476 clear_desc_flag = 1;
6501 }
6502 6477
6503 /* There was no asynchronous process found for that pid: we have 6478 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */
6504 a synchronous process. */ 6479 if (clear_desc_flag)
6505 else
6506 { 6480 {
6507 synch_process_alive = 0; 6481 FD_CLR (p->infd, &input_wait_mask);
6508 6482 FD_CLR (p->infd, &non_keyboard_wait_mask);
6509 /* Report the status of the synchronous process. */
6510 if (WIFEXITED (w))
6511 synch_process_retcode = WEXITSTATUS (w);
6512 else if (WIFSIGNALED (w))
6513 synch_process_termsig = WTERMSIG (w);
6514
6515 /* Tell wait_reading_process_output that it needs to wake up and
6516 look around. */
6517 if (input_available_clear_time)
6518 *input_available_clear_time = make_emacs_time (0, 0);
6519 } 6483 }
6520 6484
6521 sigchld_end_of_loop: 6485 /* Tell wait_reading_process_output that it needs to wake up and
6522 ; 6486 look around. */
6487 if (input_available_clear_time)
6488 *input_available_clear_time = make_emacs_time (0, 0);
6489 }
6490 /* There was no asynchronous process found for that pid: we have
6491 a synchronous process. */
6492 else
6493 {
6494 synch_process_alive = 0;
6495
6496 /* Report the status of the synchronous process. */
6497 if (WIFEXITED (w))
6498 synch_process_retcode = WEXITSTATUS (w);
6499 else if (WIFSIGNALED (w))
6500 synch_process_termsig = WTERMSIG (w);
6501
6502 /* Tell wait_reading_process_output that it needs to wake up and
6503 look around. */
6504 if (input_available_clear_time)
6505 *input_available_clear_time = make_emacs_time (0, 0);
6506 }
6507
6508 return true;
6509}
6523 6510
6524 /* On some systems, we must return right away. 6511/* On some systems, the SIGCHLD handler must return right away. If
6525 If any more processes want to signal us, we will 6512 any more processes want to signal us, we will get another signal.
6526 get another signal. 6513 Otherwise, loop around to use up all the processes that have
6527 Otherwise (on systems that have WNOHANG), loop around 6514 something to tell us. */
6528 to use up all the processes that have something to tell us. */
6529#if (defined WINDOWSNT \ 6515#if (defined WINDOWSNT \
6530 || (defined USG && !defined GNU_LINUX \ 6516 || (defined USG && !defined GNU_LINUX \
6531 && !(defined HPUX && defined WNOHANG))) 6517 && !(defined HPUX && defined WNOHANG)))
6532 errno = old_errno; 6518enum { CAN_HANDLE_MULTIPLE_CHILDREN = 0 };
6533 return; 6519#else
6534#endif /* USG, but not HPUX with WNOHANG */ 6520enum { CAN_HANDLE_MULTIPLE_CHILDREN = 1 };
6535 } 6521#endif
6522
6523static void
6524handle_child_signal (int sig)
6525{
6526 while (record_child_status_change () && CAN_HANDLE_MULTIPLE_CHILDREN)
6527 continue;
6536} 6528}
6529
6530static void
6531deliver_child_signal (int sig)
6532{
6533 handle_on_main_thread (sig, handle_child_signal);
6534}
6535
6537#endif /* SIGCHLD */ 6536#endif /* SIGCHLD */
6538 6537
6539 6538
@@ -7387,7 +7386,11 @@ init_process_emacs (void)
7387#ifndef CANNOT_DUMP 7386#ifndef CANNOT_DUMP
7388 if (! noninteractive || initialized) 7387 if (! noninteractive || initialized)
7389#endif 7388#endif
7390 signal (SIGCHLD, sigchld_handler); 7389 {
7390 struct sigaction action;
7391 emacs_sigaction_init (&action, deliver_child_signal);
7392 sigaction (SIGCHLD, &action, 0);
7393 }
7391#endif 7394#endif
7392 7395
7393 FD_ZERO (&input_wait_mask); 7396 FD_ZERO (&input_wait_mask);
diff --git a/src/ralloc.c b/src/ralloc.c
index 3877e21d4f6..74834333aa3 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -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
diff --git a/src/regex.c b/src/regex.c
index 28813304c8a..472ef727979 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -5160,13 +5160,11 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
5160 { 5160 {
5161 /* 1 if this match ends in the same string (string1 or string2) 5161 /* 1 if this match ends in the same string (string1 or string2)
5162 as the best previous match. */ 5162 as the best previous match. */
5163 boolean same_str_p; 5163 boolean same_str_p = (FIRST_STRING_P (match_end)
5164 == FIRST_STRING_P (d));
5164 /* 1 if this match is the best seen so far. */ 5165 /* 1 if this match is the best seen so far. */
5165 boolean best_match_p; 5166 boolean best_match_p;
5166 5167
5167 same_str_p = (FIRST_STRING_P (match_end)
5168 == FIRST_STRING_P (d));
5169
5170 /* AIX compiler got confused when this was combined 5168 /* AIX compiler got confused when this was combined
5171 with the previous declaration. */ 5169 with the previous declaration. */
5172 if (same_str_p) 5170 if (same_str_p)
diff --git a/src/region-cache.c b/src/region-cache.c
index d2bba8c11b2..c3eb087aade 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -194,7 +194,7 @@ find_cache_boundary (struct region_cache *c, ptrdiff_t pos)
194 if (BOUNDARY_POS (c, low) > pos 194 if (BOUNDARY_POS (c, low) > pos
195 || (low + 1 < c->cache_len 195 || (low + 1 < c->cache_len
196 && BOUNDARY_POS (c, low + 1) <= pos)) 196 && BOUNDARY_POS (c, low + 1) <= pos))
197 abort (); 197 emacs_abort ();
198 198
199 return low; 199 return low;
200} 200}
@@ -217,12 +217,12 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
217 217
218 if (pos < 0 218 if (pos < 0
219 || pos > c->cache_len) 219 || pos > c->cache_len)
220 abort (); 220 emacs_abort ();
221 221
222 /* We mustn't ever try to put the gap before the dummy start 222 /* We mustn't ever try to put the gap before the dummy start
223 boundary. That must always be start-relative. */ 223 boundary. That must always be start-relative. */
224 if (pos == 0) 224 if (pos == 0)
225 abort (); 225 emacs_abort ();
226 226
227 /* Need we move the gap right? */ 227 /* Need we move the gap right? */
228 while (gap_start < pos) 228 while (gap_start < pos)
@@ -291,24 +291,24 @@ insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
291{ 291{
292 /* i must be a valid cache index. */ 292 /* i must be a valid cache index. */
293 if (i < 0 || i > c->cache_len) 293 if (i < 0 || i > c->cache_len)
294 abort (); 294 emacs_abort ();
295 295
296 /* We must never want to insert something before the dummy first 296 /* We must never want to insert something before the dummy first
297 boundary. */ 297 boundary. */
298 if (i == 0) 298 if (i == 0)
299 abort (); 299 emacs_abort ();
300 300
301 /* We must only be inserting things in order. */ 301 /* We must only be inserting things in order. */
302 if (! (BOUNDARY_POS (c, i - 1) < pos 302 if (! (BOUNDARY_POS (c, i - 1) < pos
303 && (i == c->cache_len 303 && (i == c->cache_len
304 || pos < BOUNDARY_POS (c, i)))) 304 || pos < BOUNDARY_POS (c, i))))
305 abort (); 305 emacs_abort ();
306 306
307 /* The value must be different from the ones around it. However, we 307 /* The value must be different from the ones around it. However, we
308 temporarily create boundaries that establish the same value as 308 temporarily create boundaries that establish the same value as
309 the subsequent boundary, so we're not going to flag that case. */ 309 the subsequent boundary, so we're not going to flag that case. */
310 if (BOUNDARY_VALUE (c, i - 1) == value) 310 if (BOUNDARY_VALUE (c, i - 1) == value)
311 abort (); 311 emacs_abort ();
312 312
313 move_cache_gap (c, i, 1); 313 move_cache_gap (c, i, 1);
314 314
@@ -331,16 +331,16 @@ delete_cache_boundaries (struct region_cache *c,
331 /* Gotta be in range. */ 331 /* Gotta be in range. */
332 if (start < 0 332 if (start < 0
333 || end > c->cache_len) 333 || end > c->cache_len)
334 abort (); 334 emacs_abort ();
335 335
336 /* Gotta be in order. */ 336 /* Gotta be in order. */
337 if (start > end) 337 if (start > end)
338 abort (); 338 emacs_abort ();
339 339
340 /* Can't delete the dummy entry. */ 340 /* Can't delete the dummy entry. */
341 if (start == 0 341 if (start == 0
342 && end >= 1) 342 && end >= 1)
343 abort (); 343 emacs_abort ();
344 344
345 /* Minimize gap motion. If we're deleting nothing, do nothing. */ 345 /* Minimize gap motion. If we're deleting nothing, do nothing. */
346 if (len == 0) 346 if (len == 0)
@@ -380,10 +380,10 @@ set_cache_region (struct region_cache *c,
380 ptrdiff_t start, ptrdiff_t end, int value) 380 ptrdiff_t start, ptrdiff_t end, int value)
381{ 381{
382 if (start > end) 382 if (start > end)
383 abort (); 383 emacs_abort ();
384 if (start < c->buffer_beg 384 if (start < c->buffer_beg
385 || end > c->buffer_end) 385 || end > c->buffer_end)
386 abort (); 386 emacs_abort ();
387 387
388 /* Eliminate this case; then we can assume that start and end-1 are 388 /* Eliminate this case; then we can assume that start and end-1 are
389 both the locations of real characters in the buffer. */ 389 both the locations of real characters in the buffer. */
diff --git a/src/scroll.c b/src/scroll.c
index 78ebe65bdcc..79dd464b29e 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -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..72bd5605709 100644
--- a/src/search.c
+++ b/src/search.c
@@ -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/sound.c b/src/sound.c
index 403f08240ce..5729d704b6a 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -48,7 +48,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
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
@@ -316,7 +315,12 @@ sound_perror (const char *msg)
316 315
317 turn_on_atimers (1); 316 turn_on_atimers (1);
318#ifdef SIGIO 317#ifdef 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 SIGIO
736 sigset_t blocked;
737#endif
731 738
732 eassert (sd->fd >= 0); 739 eassert (sd->fd >= 0);
733 740
@@ -736,7 +743,9 @@ vox_configure (struct sound_device *sd)
736 troubles. */ 743 troubles. */
737 turn_on_atimers (0); 744 turn_on_atimers (0);
738#ifdef SIGIO 745#ifdef 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;
@@ -770,7 +779,7 @@ vox_configure (struct sound_device *sd)
770 779
771 turn_on_atimers (1); 780 turn_on_atimers (1);
772#ifdef SIGIO 781#ifdef SIGIO
773 sigunblock (sigmask (SIGIO)); 782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
774#endif 783#endif
775} 784}
776 785
@@ -786,7 +795,10 @@ vox_close (struct sound_device *sd)
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 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
@@ -795,7 +807,7 @@ vox_close (struct sound_device *sd)
795 807
796 turn_on_atimers (1); 808 turn_on_atimers (1);
797#ifdef SIGIO 809#ifdef 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..fdd9353bb87 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -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..0f16d1a7645 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -21,7 +21,7 @@ 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> 26#include <setjmp.h>
27#ifdef HAVE_PWD_H 27#ifdef HAVE_PWD_H
@@ -302,27 +302,34 @@ wait_for_termination_1 (pid_t pid, int interruptible)
302 termination of subprocesses, perhaps involving a kernel bug too, 302 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 303 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. */ 304 if that causes the problem to go away or get worse. */
305 sigsetmask (sigmask (SIGCHLD)); 305 sigset_t sigchild_mask;
306 sigemptyset (&sigchild_mask);
307 sigaddset (&sigchild_mask, SIGCHLD);
308 pthread_sigmask (SIG_SETMASK, &sigchild_mask, 0);
309
306 if (0 > kill (pid, 0)) 310 if (0 > kill (pid, 0))
307 { 311 {
308 sigsetmask (SIGEMPTYMASK); 312 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
309 kill (getpid (), SIGCHLD); 313 kill (getpid (), SIGCHLD);
310 break; 314 break;
311 } 315 }
312 if (wait_debugging) 316 if (wait_debugging)
313 sleep (1); 317 sleep (1);
314 else 318 else
315 sigpause (SIGEMPTYMASK); 319 sigsuspend (&empty_mask);
316#else /* not BSD_SYSTEM, and not HPUX version >= 6 */ 320#else /* not BSD_SYSTEM, and not HPUX version >= 6 */
317#ifdef WINDOWSNT 321#ifdef WINDOWSNT
318 wait (0); 322 wait (0);
319 break; 323 break;
320#else /* not WINDOWSNT */ 324#else /* not WINDOWSNT */
321 sigblock (sigmask (SIGCHLD)); 325 sigset_t blocked;
326 sigemptyset (&blocked);
327 sigaddset (&blocked, SIGCHLD);
328 pthread_sigmask (SIG_BLOCK, &blocked, 0);
322 errno = 0; 329 errno = 0;
323 if (kill (pid, 0) == -1 && errno == ESRCH) 330 if (kill (pid, 0) == -1 && errno == ESRCH)
324 { 331 {
325 sigunblock (sigmask (SIGCHLD)); 332 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
326 break; 333 break;
327 } 334 }
328 335
@@ -456,11 +463,11 @@ child_setup_tty (int out)
456#endif /* not MSDOS */ 463#endif /* not MSDOS */
457 464
458 465
459/* Record a signal code and the handler for it. */ 466/* Record a signal code and the action for it. */
460struct save_signal 467struct save_signal
461{ 468{
462 int code; 469 int code;
463 void (*handler) (int); 470 struct sigaction action;
464}; 471};
465 472
466static void save_signal_handlers (struct save_signal *); 473static void save_signal_handlers (struct save_signal *);
@@ -618,8 +625,9 @@ save_signal_handlers (struct save_signal *saved_handlers)
618{ 625{
619 while (saved_handlers->code) 626 while (saved_handlers->code)
620 { 627 {
621 saved_handlers->handler 628 struct sigaction action;
622 = (void (*) (int)) signal (saved_handlers->code, SIG_IGN); 629 emacs_sigaction_init (&action, SIG_IGN);
630 sigaction (saved_handlers->code, &action, &saved_handlers->action);
623 saved_handlers++; 631 saved_handlers++;
624 } 632 }
625} 633}
@@ -629,7 +637,7 @@ restore_signal_handlers (struct save_signal *saved_handlers)
629{ 637{
630 while (saved_handlers->code) 638 while (saved_handlers->code)
631 { 639 {
632 signal (saved_handlers->code, saved_handlers->handler); 640 sigaction (saved_handlers->code, &saved_handlers->action, 0);
633 saved_handlers++; 641 saved_handlers++;
634 } 642 }
635} 643}
@@ -686,13 +694,17 @@ reset_sigio (int fd)
686void 694void
687request_sigio (void) 695request_sigio (void)
688{ 696{
697 sigset_t unblocked;
698
689 if (noninteractive) 699 if (noninteractive)
690 return; 700 return;
691 701
702 sigemptyset (&unblocked);
692#ifdef SIGWINCH 703#ifdef SIGWINCH
693 sigunblock (sigmask (SIGWINCH)); 704 sigaddset (&unblocked, SIGWINCH);
694#endif 705#endif
695 sigunblock (sigmask (SIGIO)); 706 sigaddset (&unblocked, SIGIO);
707 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
696 708
697 interrupts_deferred = 0; 709 interrupts_deferred = 0;
698} 710}
@@ -700,6 +712,8 @@ request_sigio (void)
700void 712void
701unrequest_sigio (void) 713unrequest_sigio (void)
702{ 714{
715 sigset_t blocked;
716
703 if (noninteractive) 717 if (noninteractive)
704 return; 718 return;
705 719
@@ -708,10 +722,12 @@ unrequest_sigio (void)
708 return; 722 return;
709#endif 723#endif
710 724
725 sigemptyset (&blocked);
711#ifdef SIGWINCH 726#ifdef SIGWINCH
712 sigblock (sigmask (SIGWINCH)); 727 sigaddset (&blocked, SIGWINCH);
713#endif 728#endif
714 sigblock (sigmask (SIGIO)); 729 sigaddset (&blocked, SIGIO);
730 pthread_sigmask (SIG_BLOCK, &blocked, 0);
715 interrupts_deferred = 1; 731 interrupts_deferred = 1;
716} 732}
717 733
@@ -1470,20 +1486,16 @@ init_system_name (void)
1470 } 1486 }
1471} 1487}
1472 1488
1473/* POSIX signals support - DJB */
1474/* Anyone with POSIX signals should have ANSI C declarations */
1475
1476sigset_t empty_mask; 1489sigset_t empty_mask;
1477 1490
1478#ifndef WINDOWSNT 1491/* Store into *ACTION a signal action suitable for Emacs, with handler
1479 1492 HANDLER. */
1480signal_handler_t 1493void
1481sys_signal (int signal_number, signal_handler_t action) 1494emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1482{ 1495{
1483 struct sigaction new_action, old_action; 1496 sigemptyset (&action->sa_mask);
1484 sigemptyset (&new_action.sa_mask); 1497 action->sa_handler = handler;
1485 new_action.sa_handler = action; 1498 action->sa_flags = 0;
1486 new_action.sa_flags = 0;
1487#if defined (SA_RESTART) 1499#if defined (SA_RESTART)
1488 /* Emacs mostly works better with restartable system services. If this 1500 /* Emacs mostly works better with restartable system services. If this
1489 flag exists, we probably want to turn it on here. 1501 flag exists, we probably want to turn it on here.
@@ -1500,56 +1512,44 @@ sys_signal (int signal_number, signal_handler_t action)
1500# if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT) 1512# if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT)
1501 if (noninteractive) 1513 if (noninteractive)
1502# endif 1514# endif
1503 new_action.sa_flags = SA_RESTART; 1515 action->sa_flags = SA_RESTART;
1504#endif 1516#endif
1505 sigaction (signal_number, &new_action, &old_action);
1506 return (old_action.sa_handler);
1507} 1517}
1508 1518
1509#endif /* WINDOWSNT */ 1519#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1510 1520pthread_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 1521#endif
1523 1522
1524/* I'd like to have these guys return pointers to the mask storage in here, 1523/* 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 1524 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 1525 this thread. POSIX says any thread can receive a signal that is
1527 anyhow. - DJB */ 1526 associated with a process, process group, or asynchronous event.
1528 1527 On GNU/Linux that is not true, but for other systems (FreeBSD at
1529sigset_t 1528 least) it is. */
1530sys_sigblock (sigset_t new_mask) 1529void
1530handle_on_main_thread (int sig, signal_handler_t handler)
1531{ 1531{
1532 sigset_t old_mask; 1532 /* Preserve errno, to avoid race conditions with signal handlers that
1533 pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); 1533 might change errno. Races can occur even in single-threaded hosts. */
1534 return (old_mask); 1534 int old_errno = errno;
1535}
1536 1535
1537sigset_t 1536 bool on_main_thread = true;
1538sys_sigunblock (sigset_t new_mask) 1537#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1539{ 1538 if (! pthread_equal (pthread_self (), main_thread))
1540 sigset_t old_mask; 1539 {
1541 pthread_sigmask (SIG_UNBLOCK, &new_mask, &old_mask); 1540 sigset_t blocked;
1542 return (old_mask); 1541 sigemptyset (&blocked);
1543} 1542 sigaddset (&blocked, sig);
1543 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1544 pthread_kill (main_thread, sig);
1545 on_main_thread = false;
1546 }
1547#endif
1548 if (on_main_thread)
1549 handler (sig);
1544 1550
1545sigset_t 1551 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} 1552}
1552
1553 1553
1554#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1554#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1555static char *my_sys_siglist[NSIG]; 1555static char *my_sys_siglist[NSIG];
@@ -1564,6 +1564,10 @@ init_signals (void)
1564{ 1564{
1565 sigemptyset (&empty_mask); 1565 sigemptyset (&empty_mask);
1566 1566
1567#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1568 main_thread = pthread_self ();
1569#endif
1570
1567#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1571#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1568 if (! initialized) 1572 if (! initialized)
1569 { 1573 {
@@ -1856,6 +1860,33 @@ snprintf (char *buf, size_t bufsize, char const *format, ...)
1856} 1860}
1857#endif 1861#endif
1858 1862
1863/* If a backtrace is available, output the top lines of it to stderr.
1864 Do not output more than BACKTRACE_LIMIT or BACKTRACE_LIMIT_MAX lines.
1865 This function may be called from a signal handler, so it should
1866 not invoke async-unsafe functions like malloc. */
1867void
1868emacs_backtrace (int backtrace_limit)
1869{
1870 enum { BACKTRACE_LIMIT_MAX = 500 };
1871 void *buffer[BACKTRACE_LIMIT_MAX + 1];
1872 int bounded_limit = min (backtrace_limit, BACKTRACE_LIMIT_MAX);
1873 int npointers = backtrace (buffer, bounded_limit + 1);
1874 if (npointers)
1875 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12));
1876 backtrace_symbols_fd (buffer, bounded_limit, STDERR_FILENO);
1877 if (bounded_limit < npointers)
1878 ignore_value (write (STDERR_FILENO, "...\n", 4));
1879}
1880
1881#ifndef HAVE_NTGUI
1882/* Using emacs_abort lets GDB return from a breakpoint here. */
1883void
1884emacs_abort (void)
1885{
1886 fatal_error_backtrace (SIGABRT, 10);
1887}
1888#endif
1889
1859int 1890int
1860emacs_open (const char *path, int oflag, int mode) 1891emacs_open (const char *path, int oflag, int mode)
1861{ 1892{
diff --git a/src/syssignal.h b/src/syssignal.h
index 71151ed4c6a..c5529ae718a 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,66 +28,22 @@ 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); 36
76sigset_t sys_sigunblock (sigset_t new_mask);
77sigset_t sys_sigsetmask (sigset_t new_mask);
78#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN) 37#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN)
79_Noreturn void croak (char *); 38_Noreturn void croak (char *);
80#endif 39#endif
81 40
82#define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG) 41/* Interrupt input is not used if there is no FIONREAD. */
83 42#include <sys/ioctl.h>
84#define sigfree() sigsetmask (SIGEMPTYMASK) 43#if defined BROKEN_SIGIO || ! defined FIONREAD || defined BROKEN_FIONREAD
85
86#if defined (SIGIO) && defined (BROKEN_SIGIO)
87# undef SIGIO 44# undef SIGIO
88#endif 45#endif
46
89/* These are only used by AIX */ 47/* These are only used by AIX */
90#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) 48#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
91#undef SIGPOLL 49#undef SIGPOLL
@@ -97,12 +55,8 @@ _Noreturn void croak (char *);
97#undef SIGPTY 55#undef SIGPTY
98#endif 56#endif
99 57
100
101/* FIXME? Emacs only defines NSIG_MINIMUM on some platforms? */
102#if NSIG < NSIG_MINIMUM 58#if NSIG < NSIG_MINIMUM
103# ifdef NSIG 59# undef NSIG
104# undef NSIG
105# endif
106# define NSIG NSIG_MINIMUM 60# define NSIG NSIG_MINIMUM
107#endif 61#endif
108 62
@@ -133,24 +87,6 @@ char *strsignal (int);
133 87
134#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 88#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
135extern pthread_t main_thread; 89extern pthread_t main_thread;
136#define SIGNAL_THREAD_CHECK(signo) \ 90#endif
137 do { \ 91
138 if (!pthread_equal (pthread_self (), main_thread)) \ 92void handle_on_main_thread (int, signal_handler_t);
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..b660441a91e 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -47,11 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#undef ASYNC 47#undef ASYNC
48#endif 48#endif
49 49
50/* Interrupt input is not used if there is no FIONREAD. */
51#ifndef FIONREAD
52#undef SIGIO
53#endif
54
55 50
56/* Try to establish the correct character to disable terminal functions 51/* Try to establish the correct character to disable terminal functions
57 in a system-independent manner. Note that USG (at least) define 52 in a system-independent manner. Note that USG (at least) define
diff --git a/src/term.c b/src/term.c
index f1a09b39cf9..0eaf76a13df 100644
--- a/src/term.c
+++ b/src/term.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 <sys/time.h> 26#include <sys/time.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <signal.h>
29#include <setjmp.h> 28#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
@@ -1498,7 +1497,7 @@ append_glyph (struct it *it)
1498 { 1497 {
1499 glyph->resolved_level = it->bidi_it.resolved_level; 1498 glyph->resolved_level = it->bidi_it.resolved_level;
1500 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1499 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1501 abort (); 1500 emacs_abort ();
1502 glyph->bidi_type = it->bidi_it.type; 1501 glyph->bidi_type = it->bidi_it.type;
1503 } 1502 }
1504 else 1503 else
@@ -1695,7 +1694,7 @@ append_composite_glyph (struct it *it)
1695 { 1694 {
1696 glyph->resolved_level = it->bidi_it.resolved_level; 1695 glyph->resolved_level = it->bidi_it.resolved_level;
1697 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1696 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1698 abort (); 1697 emacs_abort ();
1699 glyph->bidi_type = it->bidi_it.type; 1698 glyph->bidi_type = it->bidi_it.type;
1700 } 1699 }
1701 else 1700 else
@@ -1780,7 +1779,7 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1780 { 1779 {
1781 glyph->resolved_level = it->bidi_it.resolved_level; 1780 glyph->resolved_level = it->bidi_it.resolved_level;
1782 if ((it->bidi_it.type & 7) != it->bidi_it.type) 1781 if ((it->bidi_it.type & 7) != it->bidi_it.type)
1783 abort (); 1782 emacs_abort ();
1784 glyph->bidi_type = it->bidi_it.type; 1783 glyph->bidi_type = it->bidi_it.type;
1785 } 1784 }
1786 else 1785 else
@@ -2250,7 +2249,7 @@ get_named_tty (const char *name)
2250 struct terminal *t; 2249 struct terminal *t;
2251 2250
2252 if (!name) 2251 if (!name)
2253 abort (); 2252 emacs_abort ();
2254 2253
2255 for (t = terminal_list; t; t = t->next_terminal) 2254 for (t = terminal_list; t; t = t->next_terminal)
2256 { 2255 {
@@ -2798,7 +2797,7 @@ create_tty_output (struct frame *f)
2798 struct tty_output *t = xzalloc (sizeof *t); 2797 struct tty_output *t = xzalloc (sizeof *t);
2799 2798
2800 if (! FRAME_TERMCAP_P (f)) 2799 if (! FRAME_TERMCAP_P (f))
2801 abort (); 2800 emacs_abort ();
2802 2801
2803 t->display_info = FRAME_TERMINAL (f)->display_info.tty; 2802 t->display_info = FRAME_TERMINAL (f)->display_info.tty;
2804 2803
@@ -2811,7 +2810,7 @@ static void
2811tty_free_frame_resources (struct frame *f) 2810tty_free_frame_resources (struct frame *f)
2812{ 2811{
2813 if (! FRAME_TERMCAP_P (f)) 2812 if (! FRAME_TERMCAP_P (f))
2814 abort (); 2813 emacs_abort ();
2815 2814
2816 if (FRAME_FACE_CACHE (f)) 2815 if (FRAME_FACE_CACHE (f))
2817 free_frame_faces (f); 2816 free_frame_faces (f);
@@ -2827,7 +2826,7 @@ static void
2827tty_free_frame_resources (struct frame *f) 2826tty_free_frame_resources (struct frame *f)
2828{ 2827{
2829 if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f)) 2828 if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f))
2830 abort (); 2829 emacs_abort ();
2831 2830
2832 if (FRAME_FACE_CACHE (f)) 2831 if (FRAME_FACE_CACHE (f))
2833 free_frame_faces (f); 2832 free_frame_faces (f);
@@ -2932,7 +2931,10 @@ dissociate_if_controlling_tty (int fd)
2932 no_controlling_tty = 1; 2931 no_controlling_tty = 1;
2933#else 2932#else
2934#ifdef TIOCNOTTY /* Try BSD ioctls. */ 2933#ifdef TIOCNOTTY /* Try BSD ioctls. */
2935 sigblock (sigmask (SIGTTOU)); 2934 sigset_t blocked;
2935 sigemptyset (&blocked);
2936 sigaddset (&blocked, SIGTTOU);
2937 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2936 fd = emacs_open (DEV_TTY, O_RDWR, 0); 2938 fd = emacs_open (DEV_TTY, O_RDWR, 0);
2937 if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1) 2939 if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1)
2938 { 2940 {
@@ -2940,7 +2942,7 @@ dissociate_if_controlling_tty (int fd)
2940 } 2942 }
2941 if (fd != -1) 2943 if (fd != -1)
2942 emacs_close (fd); 2944 emacs_close (fd);
2943 sigunblock (sigmask (SIGTTOU)); 2945 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2944#else 2946#else
2945 /* Unknown system. */ 2947 /* Unknown system. */
2946 croak (); 2948 croak ();
@@ -3074,9 +3076,14 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3074 3076
3075 /* On some systems, tgetent tries to access the controlling 3077 /* On some systems, tgetent tries to access the controlling
3076 terminal. */ 3078 terminal. */
3077 sigblock (sigmask (SIGTTOU)); 3079 {
3078 status = tgetent (tty->termcap_term_buffer, terminal_type); 3080 sigset_t blocked;
3079 sigunblock (sigmask (SIGTTOU)); 3081 sigemptyset (&blocked);
3082 sigaddset (&blocked, SIGTTOU);
3083 pthread_sigmask (SIG_BLOCK, &blocked, 0);
3084 status = tgetent (tty->termcap_term_buffer, terminal_type);
3085 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
3086 }
3080 3087
3081 if (status < 0) 3088 if (status < 0)
3082 { 3089 {
@@ -3108,7 +3115,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3108 3115
3109#ifndef TERMINFO 3116#ifndef TERMINFO
3110 if (strlen (tty->termcap_term_buffer) >= buffer_size) 3117 if (strlen (tty->termcap_term_buffer) >= buffer_size)
3111 abort (); 3118 emacs_abort ();
3112 buffer_size = strlen (tty->termcap_term_buffer); 3119 buffer_size = strlen (tty->termcap_term_buffer);
3113#endif 3120#endif
3114 tty->termcap_strings_buffer = area = xmalloc (buffer_size); 3121 tty->termcap_strings_buffer = area = xmalloc (buffer_size);
@@ -3467,7 +3474,7 @@ maybe_fatal (int must_succeed, struct terminal *terminal,
3467 verror (str1, ap); 3474 verror (str1, ap);
3468 3475
3469 va_end (ap); 3476 va_end (ap);
3470 abort (); 3477 emacs_abort ();
3471} 3478}
3472 3479
3473void 3480void
@@ -3494,7 +3501,7 @@ delete_tty (struct terminal *terminal)
3494 return; 3501 return;
3495 3502
3496 if (terminal->type != output_termcap) 3503 if (terminal->type != output_termcap)
3497 abort (); 3504 emacs_abort ();
3498 3505
3499 tty = terminal->display_info.tty; 3506 tty = terminal->display_info.tty;
3500 3507
@@ -3508,7 +3515,7 @@ delete_tty (struct terminal *terminal)
3508 3515
3509 if (! p) 3516 if (! p)
3510 /* This should not happen. */ 3517 /* This should not happen. */
3511 abort (); 3518 emacs_abort ();
3512 3519
3513 p->next = tty->next; 3520 p->next = tty->next;
3514 tty->next = 0; 3521 tty->next = 0;
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..c51a18dfa61 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -294,7 +294,7 @@ delete_terminal (struct terminal *terminal)
294 294
295 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal) 295 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
296 if (! *tp) 296 if (! *tp)
297 abort (); 297 emacs_abort ();
298 *tp = terminal->next_terminal; 298 *tp = terminal->next_terminal;
299 299
300 xfree (terminal->keyboard_coding); 300 xfree (terminal->keyboard_coding);
@@ -411,7 +411,7 @@ possible return values. */)
411 case output_ns: 411 case output_ns:
412 return Qns; 412 return Qns;
413 default: 413 default:
414 abort (); 414 emacs_abort ();
415 } 415 }
416} 416}
417 417
@@ -519,7 +519,7 @@ struct terminal *
519init_initial_terminal (void) 519init_initial_terminal (void)
520{ 520{
521 if (initialized || terminal_list || tty_list) 521 if (initialized || terminal_list || tty_list)
522 abort (); 522 emacs_abort ();
523 523
524 initial_terminal = create_terminal (); 524 initial_terminal = create_terminal ();
525 initial_terminal->type = output_initial; 525 initial_terminal->type = output_initial;
@@ -538,7 +538,7 @@ static void
538delete_initial_terminal (struct terminal *terminal) 538delete_initial_terminal (struct terminal *terminal)
539{ 539{
540 if (terminal != initial_terminal) 540 if (terminal != initial_terminal)
541 abort (); 541 emacs_abort ();
542 542
543 delete_terminal (terminal); 543 delete_terminal (terminal);
544 initial_terminal = NULL; 544 initial_terminal = NULL;
diff --git a/src/terminfo.c b/src/terminfo.c
index dce7af77bcf..ca2d89a000b 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -46,7 +46,7 @@ tparam (const char *string, char *outstring, int len,
46 46
47 /* Emacs always should pass a null OUTSTRING and zero LEN. */ 47 /* Emacs always should pass a null OUTSTRING and zero LEN. */
48 if (outstring || len) 48 if (outstring || len)
49 abort (); 49 emacs_abort ();
50 50
51 temp = tparm (string, arg1, arg2, arg3, arg4); 51 temp = tparm (string, arg1, arg2, arg3, arg4);
52 return xstrdup (temp); 52 return xstrdup (temp);
diff --git a/src/textprop.c b/src/textprop.c
index b6895fc426a..2a9efba1c45 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -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..58a825c90d7 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -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/w32.c b/src/w32.c
index fe612687f48..04f7471577c 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1273,9 +1273,9 @@ init_user_info (void)
1273 1273
1274 /* Ensure HOME and SHELL are defined. */ 1274 /* Ensure HOME and SHELL are defined. */
1275 if (getenv ("HOME") == NULL) 1275 if (getenv ("HOME") == NULL)
1276 abort (); 1276 emacs_abort ();
1277 if (getenv ("SHELL") == NULL) 1277 if (getenv ("SHELL") == NULL)
1278 abort (); 1278 emacs_abort ();
1279 1279
1280 /* Set dir and shell from environment variables. */ 1280 /* Set dir and shell from environment variables. */
1281 strcpy (dflt_passwd.pw_dir, getenv ("HOME")); 1281 strcpy (dflt_passwd.pw_dir, getenv ("HOME"));
@@ -1530,34 +1530,10 @@ is_unc_volume (const char *filename)
1530} 1530}
1531 1531
1532/* Routines that are no-ops on NT but are defined to get Emacs to compile. */ 1532/* Routines that are no-ops on NT but are defined to get Emacs to compile. */
1533
1534int
1535sigsetmask (int signal_mask)
1536{
1537 return 0;
1538}
1539
1540int
1541sigmask (int sig)
1542{
1543 return 0;
1544}
1545
1546int
1547sigblock (int sig)
1548{
1549 return 0;
1550}
1551
1552int
1553sigunblock (int sig)
1554{
1555 return 0;
1556}
1557
1558int 1533int
1559sigemptyset (sigset_t *set) 1534sigemptyset (sigset_t *set)
1560{ 1535{
1536 *set = 0;
1561 return 0; 1537 return 0;
1562} 1538}
1563 1539
@@ -1788,9 +1764,9 @@ init_environment (char ** argv)
1788 char modname[MAX_PATH]; 1764 char modname[MAX_PATH];
1789 1765
1790 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 1766 if (!GetModuleFileName (NULL, modname, MAX_PATH))
1791 abort (); 1767 emacs_abort ();
1792 if ((p = strrchr (modname, '\\')) == NULL) 1768 if ((p = strrchr (modname, '\\')) == NULL)
1793 abort (); 1769 emacs_abort ();
1794 *p = 0; 1770 *p = 0;
1795 1771
1796 if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0) 1772 if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0)
@@ -1902,13 +1878,13 @@ init_environment (char ** argv)
1902 /* FIXME: Do we need to resolve possible symlinks in startup_dir? 1878 /* FIXME: Do we need to resolve possible symlinks in startup_dir?
1903 Does it matter anywhere in Emacs? */ 1879 Does it matter anywhere in Emacs? */
1904 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) 1880 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))
1905 abort (); 1881 emacs_abort ();
1906 1882
1907 { 1883 {
1908 static char modname[MAX_PATH]; 1884 static char modname[MAX_PATH];
1909 1885
1910 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 1886 if (!GetModuleFileName (NULL, modname, MAX_PATH))
1911 abort (); 1887 emacs_abort ();
1912 argv[0] = modname; 1888 argv[0] = modname;
1913 } 1889 }
1914 1890
@@ -1930,7 +1906,7 @@ emacs_root_dir (void)
1930 1906
1931 p = getenv ("emacs_dir"); 1907 p = getenv ("emacs_dir");
1932 if (p == NULL) 1908 if (p == NULL)
1933 abort (); 1909 emacs_abort ();
1934 strcpy (root_dir, p); 1910 strcpy (root_dir, p);
1935 root_dir[parse_root (root_dir, NULL)] = '\0'; 1911 root_dir[parse_root (root_dir, NULL)] = '\0';
1936 dostounix_filename (root_dir); 1912 dostounix_filename (root_dir);
@@ -3287,7 +3263,7 @@ generate_inode_val (const char * name)
3287 doesn't resolve aliasing due to subst commands, or recognize hard 3263 doesn't resolve aliasing due to subst commands, or recognize hard
3288 links. */ 3264 links. */
3289 if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH)) 3265 if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH))
3290 abort (); 3266 emacs_abort ();
3291 3267
3292 parse_root (fullname, &p); 3268 parse_root (fullname, &p);
3293 /* Normal W32 filesystems are still case insensitive. */ 3269 /* Normal W32 filesystems are still case insensitive. */
@@ -5587,7 +5563,7 @@ socket_to_fd (SOCKET s)
5587 if (fd_info[ fd ].cp != NULL) 5563 if (fd_info[ fd ].cp != NULL)
5588 { 5564 {
5589 DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd)); 5565 DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd));
5590 abort (); 5566 emacs_abort ();
5591 } 5567 }
5592 5568
5593 fd_info[ fd ].cp = cp; 5569 fd_info[ fd ].cp = cp;
@@ -5966,7 +5942,7 @@ sys_close (int fd)
5966 { 5942 {
5967 if (fd_info[fd].flags & FILE_SOCKET) 5943 if (fd_info[fd].flags & FILE_SOCKET)
5968 { 5944 {
5969 if (winsock_lib == NULL) abort (); 5945 if (winsock_lib == NULL) emacs_abort ();
5970 5946
5971 pfn_shutdown (SOCK_HANDLE (fd), 2); 5947 pfn_shutdown (SOCK_HANDLE (fd), 2);
5972 rc = pfn_closesocket (SOCK_HANDLE (fd)); 5948 rc = pfn_closesocket (SOCK_HANDLE (fd));
@@ -6084,7 +6060,7 @@ _sys_read_ahead (int fd)
6084 || (fd_info[fd].flags & FILE_READ) == 0) 6060 || (fd_info[fd].flags & FILE_READ) == 0)
6085 { 6061 {
6086 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe, serial port, or socket!\n", fd)); 6062 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe, serial port, or socket!\n", fd));
6087 abort (); 6063 emacs_abort ();
6088 } 6064 }
6089 6065
6090 cp->status = STATUS_READ_IN_PROGRESS; 6066 cp->status = STATUS_READ_IN_PROGRESS;
@@ -6220,7 +6196,7 @@ sys_read (int fd, char * buffer, unsigned int count)
6220 /* re-read CR carried over from last read */ 6196 /* re-read CR carried over from last read */
6221 if (fd_info[fd].flags & FILE_LAST_CR) 6197 if (fd_info[fd].flags & FILE_LAST_CR)
6222 { 6198 {
6223 if (fd_info[fd].flags & FILE_BINARY) abort (); 6199 if (fd_info[fd].flags & FILE_BINARY) emacs_abort ();
6224 *buffer++ = 0x0d; 6200 *buffer++ = 0x0d;
6225 count--; 6201 count--;
6226 nchars++; 6202 nchars++;
@@ -6323,7 +6299,7 @@ sys_read (int fd, char * buffer, unsigned int count)
6323 } 6299 }
6324 else /* FILE_SOCKET */ 6300 else /* FILE_SOCKET */
6325 { 6301 {
6326 if (winsock_lib == NULL) abort (); 6302 if (winsock_lib == NULL) emacs_abort ();
6327 6303
6328 /* do the equivalent of a non-blocking read */ 6304 /* do the equivalent of a non-blocking read */
6329 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting); 6305 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting);
@@ -6474,7 +6450,7 @@ sys_write (int fd, const void * buffer, unsigned int count)
6474 else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) 6450 else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
6475 { 6451 {
6476 unsigned long nblock = 0; 6452 unsigned long nblock = 0;
6477 if (winsock_lib == NULL) abort (); 6453 if (winsock_lib == NULL) emacs_abort ();
6478 6454
6479 /* TODO: implement select() properly so non-blocking I/O works. */ 6455 /* TODO: implement select() properly so non-blocking I/O works. */
6480 /* For now, make sure the write blocks. */ 6456 /* For now, make sure the write blocks. */
@@ -6640,8 +6616,7 @@ check_windows_init_file (void)
6640 buffer, 6616 buffer,
6641 "Emacs Abort Dialog", 6617 "Emacs Abort Dialog",
6642 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); 6618 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
6643 /* Use the low-level Emacs abort. */ 6619 /* Use the low-level system abort. */
6644#undef abort
6645 abort (); 6620 abort ();
6646 } 6621 }
6647 else 6622 else
diff --git a/src/w32fns.c b/src/w32fns.c
index 5a1b6dfabab..ec1acbd89d9 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2280,7 +2280,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2280 CoInitialize (NULL); 2280 CoInitialize (NULL);
2281 w32_createwindow ((struct frame *) msg.wParam); 2281 w32_createwindow ((struct frame *) msg.wParam);
2282 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2282 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2283 abort (); 2283 emacs_abort ();
2284 break; 2284 break;
2285 case WM_EMACS_SETLOCALE: 2285 case WM_EMACS_SETLOCALE:
2286 SetThreadLocale (msg.wParam); 2286 SetThreadLocale (msg.wParam);
@@ -2290,7 +2290,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2290 result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0); 2290 result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
2291 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 2291 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
2292 result, 0)) 2292 result, 0))
2293 abort (); 2293 emacs_abort ();
2294 break; 2294 break;
2295 case WM_EMACS_REGISTER_HOT_KEY: 2295 case WM_EMACS_REGISTER_HOT_KEY:
2296 focus_window = GetFocus (); 2296 focus_window = GetFocus ();
@@ -2311,7 +2311,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2311 GC. */ 2311 GC. */
2312 XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil); 2312 XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil);
2313 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2313 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2314 abort (); 2314 emacs_abort ();
2315 break; 2315 break;
2316 case WM_EMACS_TOGGLE_LOCK_KEY: 2316 case WM_EMACS_TOGGLE_LOCK_KEY:
2317 { 2317 {
@@ -2343,7 +2343,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2343 } 2343 }
2344 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 2344 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
2345 cur_state, 0)) 2345 cur_state, 0))
2346 abort (); 2346 emacs_abort ();
2347 } 2347 }
2348 break; 2348 break;
2349#ifdef MSG_DEBUG 2349#ifdef MSG_DEBUG
@@ -2398,11 +2398,11 @@ send_deferred_msg (deferred_msg * msg_buf,
2398{ 2398{
2399 /* Only input thread can send deferred messages. */ 2399 /* Only input thread can send deferred messages. */
2400 if (GetCurrentThreadId () != dwWindowsThreadId) 2400 if (GetCurrentThreadId () != dwWindowsThreadId)
2401 abort (); 2401 emacs_abort ();
2402 2402
2403 /* It is an error to send a message that is already deferred. */ 2403 /* It is an error to send a message that is already deferred. */
2404 if (find_deferred_msg (hwnd, msg) != NULL) 2404 if (find_deferred_msg (hwnd, msg) != NULL)
2405 abort (); 2405 emacs_abort ();
2406 2406
2407 /* Enforced synchronization is not needed because this is the only 2407 /* Enforced synchronization is not needed because this is the only
2408 function that alters deferred_msg_head, and the following critical 2408 function that alters deferred_msg_head, and the following critical
@@ -2475,7 +2475,7 @@ w32_msg_worker (void *arg)
2475 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); 2475 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
2476 2476
2477 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2477 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2478 abort (); 2478 emacs_abort ();
2479 2479
2480 memset (&dummy_buf, 0, sizeof (dummy_buf)); 2480 memset (&dummy_buf, 0, sizeof (dummy_buf));
2481 dummy_buf.w32msg.msg.hwnd = NULL; 2481 dummy_buf.w32msg.msg.hwnd = NULL;
@@ -3136,7 +3136,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3136 msg = WM_MBUTTONUP; 3136 msg = WM_MBUTTONUP;
3137 button_state &= ~MMOUSE; 3137 button_state &= ~MMOUSE;
3138 3138
3139 if (button_state) abort (); 3139 if (button_state) emacs_abort ();
3140 } 3140 }
3141 else 3141 else
3142 return 0; 3142 return 0;
@@ -3367,7 +3367,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3367 /* Detect if message has already been deferred; in this case 3367 /* Detect if message has already been deferred; in this case
3368 we cannot return any sensible value to ignore this. */ 3368 we cannot return any sensible value to ignore this. */
3369 if (find_deferred_msg (hwnd, msg) != NULL) 3369 if (find_deferred_msg (hwnd, msg) != NULL)
3370 abort (); 3370 emacs_abort ();
3371 3371
3372 menubar_in_use = 1; 3372 menubar_in_use = 1;
3373 3373
@@ -3842,7 +3842,7 @@ my_create_window (struct frame * f)
3842 MSG msg; 3842 MSG msg;
3843 3843
3844 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0)) 3844 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0))
3845 abort (); 3845 emacs_abort ();
3846 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 3846 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
3847} 3847}
3848 3848
@@ -6287,7 +6287,7 @@ w32_parse_hot_key (Lisp_Object key)
6287 lisp_modifiers = XINT (Fcar (Fcdr (c))); 6287 lisp_modifiers = XINT (Fcar (Fcdr (c)));
6288 c = Fcar (c); 6288 c = Fcar (c);
6289 if (!SYMBOLP (c)) 6289 if (!SYMBOLP (c))
6290 abort (); 6290 emacs_abort ();
6291 vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c))); 6291 vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c)));
6292 } 6292 }
6293 else if (INTEGERP (c)) 6293 else if (INTEGERP (c))
@@ -7194,10 +7194,8 @@ globals_of_w32fns (void)
7194 syms_of_w32uniscribe (); 7194 syms_of_w32uniscribe ();
7195} 7195}
7196 7196
7197#undef abort
7198
7199void 7197void
7200w32_abort (void) 7198emacs_abort (void)
7201{ 7199{
7202 int button; 7200 int button;
7203 button = MessageBox (NULL, 7201 button = MessageBox (NULL,
diff --git a/src/w32font.c b/src/w32font.c
index cfd453282dd..8b3a0e4312e 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -635,9 +635,9 @@ w32font_text_extents (struct font *font, unsigned *code,
635/* w32 implementation of draw for font backend. 635/* w32 implementation of draw for font backend.
636 Optional. 636 Optional.
637 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
638 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,
639 is nonzero, fill the background in advance. It is assured that 639 fill the background in advance. It is assured that WITH_BACKGROUND
640 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). 640 is false when (FROM > 0 || TO < S->nchars).
641 641
642 TODO: Currently this assumes that the colors and fonts are already 642 TODO: Currently this assumes that the colors and fonts are already
643 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
@@ -647,7 +647,7 @@ w32font_text_extents (struct font *font, unsigned *code,
647 647
648int 648int
649w32font_draw (struct glyph_string *s, int from, int to, 649w32font_draw (struct glyph_string *s, int from, int to,
650 int x, int y, int with_background) 650 int x, int y, bool with_background)
651{ 651{
652 UINT options; 652 UINT options;
653 HRGN orig_clip = NULL; 653 HRGN orig_clip = NULL;
@@ -804,7 +804,7 @@ static int
804w32font_otf_drive (struct font *font, Lisp_Object features, 804w32font_otf_drive (struct font *font, Lisp_Object features,
805 Lisp_Object gstring_in, int from, int to, 805 Lisp_Object gstring_in, int from, int to,
806 Lisp_Object gstring_out, int idx, 806 Lisp_Object gstring_out, int idx,
807 int alternate_subst); 807 bool alternate_subst);
808 */ 808 */
809 809
810/* Internal implementation of w32font_list. 810/* Internal implementation of w32font_list.
@@ -987,7 +987,6 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity,
987 font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth; 987 font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;
988 988
989 font->vertical_centering = 0; 989 font->vertical_centering = 0;
990 font->encoding_type = 0;
991 font->baseline_offset = 0; 990 font->baseline_offset = 0;
992 font->relative_compose = 0; 991 font->relative_compose = 0;
993 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/w32menu.c b/src/w32menu.c
index 3aa4c8bc96d..d4de73a0de7 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -820,7 +820,7 @@ w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
820 else if (EQ (type, QCradio)) 820 else if (EQ (type, QCradio))
821 wv->button_type = BUTTON_TYPE_RADIO; 821 wv->button_type = BUTTON_TYPE_RADIO;
822 else 822 else
823 abort (); 823 emacs_abort ();
824 824
825 wv->selected = !NILP (selected); 825 wv->selected = !NILP (selected);
826 826
diff --git a/src/w32proc.c b/src/w32proc.c
index 33aed5eb8e3..b9239cbb99a 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -103,6 +103,29 @@ sys_signal (int sig, signal_handler handler)
103 return old; 103 return old;
104} 104}
105 105
106/* Emulate sigaction. */
107int
108sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
109{
110 signal_handler old;
111
112 if (sig != SIGCHLD)
113 {
114 errno = EINVAL;
115 return -1;
116 }
117 old = sig_handlers[sig];
118 if (act)
119 sig_handlers[sig] = act->sa_handler;
120 if (oact)
121 {
122 oact->sa_handler = old;
123 oact->sa_flags = 0;
124 oact->sa_mask = empty_mask;
125 }
126 return 0;
127}
128
106/* Defined in <process.h> which conflicts with the local copy */ 129/* Defined in <process.h> which conflicts with the local copy */
107#define _P_NOWAIT 1 130#define _P_NOWAIT 1
108 131
@@ -176,7 +199,7 @@ delete_child (child_process *cp)
176 /* Should not be deleting a child that is still needed. */ 199 /* Should not be deleting a child that is still needed. */
177 for (i = 0; i < MAXDESC; i++) 200 for (i = 0; i < MAXDESC; i++)
178 if (fd_info[i].cp == cp) 201 if (fd_info[i].cp == cp)
179 abort (); 202 emacs_abort ();
180 203
181 if (!CHILD_ACTIVE (cp)) 204 if (!CHILD_ACTIVE (cp))
182 return; 205 return;
@@ -316,7 +339,7 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
316 DWORD flags; 339 DWORD flags;
317 char dir[ MAXPATHLEN ]; 340 char dir[ MAXPATHLEN ];
318 341
319 if (cp == NULL) abort (); 342 if (cp == NULL) emacs_abort ();
320 343
321 memset (&start, 0, sizeof (start)); 344 memset (&start, 0, sizeof (start));
322 start.cb = sizeof (start); 345 start.cb = sizeof (start);
@@ -405,7 +428,7 @@ register_child (int pid, int fd)
405 if (fd_info[fd].cp != NULL) 428 if (fd_info[fd].cp != NULL)
406 { 429 {
407 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd)); 430 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd));
408 abort (); 431 emacs_abort ();
409 } 432 }
410 433
411 fd_info[fd].cp = cp; 434 fd_info[fd].cp = cp;
@@ -459,7 +482,7 @@ sys_wait (int *status)
459 /* We want to wait for a specific child */ 482 /* We want to wait for a specific child */
460 wait_hnd[nh] = dead_child->procinfo.hProcess; 483 wait_hnd[nh] = dead_child->procinfo.hProcess;
461 cps[nh] = dead_child; 484 cps[nh] = dead_child;
462 if (!wait_hnd[nh]) abort (); 485 if (!wait_hnd[nh]) emacs_abort ();
463 nh++; 486 nh++;
464 active = 0; 487 active = 0;
465 goto get_result; 488 goto get_result;
@@ -507,7 +530,7 @@ sys_wait (int *status)
507 active -= WAIT_ABANDONED_0; 530 active -= WAIT_ABANDONED_0;
508 } 531 }
509 else 532 else
510 abort (); 533 emacs_abort ();
511 534
512get_result: 535get_result:
513 if (!GetExitCodeProcess (wait_hnd[active], &retval)) 536 if (!GetExitCodeProcess (wait_hnd[active], &retval))
@@ -1189,7 +1212,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
1189#endif 1212#endif
1190 wait_hnd[nh] = cp->char_avail; 1213 wait_hnd[nh] = cp->char_avail;
1191 fdindex[nh] = i; 1214 fdindex[nh] = i;
1192 if (!wait_hnd[nh]) abort (); 1215 if (!wait_hnd[nh]) emacs_abort ();
1193 nh++; 1216 nh++;
1194#ifdef FULL_DEBUG 1217#ifdef FULL_DEBUG
1195 DebPrint (("select waiting on child %d fd %d\n", 1218 DebPrint (("select waiting on child %d fd %d\n",
@@ -1276,7 +1299,7 @@ count_children:
1276 active -= WAIT_ABANDONED_0; 1299 active -= WAIT_ABANDONED_0;
1277 } 1300 }
1278 else 1301 else
1279 abort (); 1302 emacs_abort ();
1280 1303
1281 /* Loop over all handles after active (now officially documented as 1304 /* Loop over all handles after active (now officially documented as
1282 being the first signaled handle in the array). We do this to 1305 being the first signaled handle in the array). We do this to
diff --git a/src/w32select.c b/src/w32select.c
index 59ff4405368..3fb88d4f17f 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -394,7 +394,7 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
394 394
395 BLOCK_INPUT; 395 BLOCK_INPUT;
396 396
397 /* Fsignal calls abort() if it sees that waiting_for_input is 397 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
398 set. */ 398 set. */
399 owfi = waiting_for_input; 399 owfi = waiting_for_input;
400 waiting_for_input = 0; 400 waiting_for_input = 0;
diff --git a/src/w32term.c b/src/w32term.c
index 6948a98998e..571db3cbe8e 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2426,7 +2426,7 @@ x_draw_glyph_string (struct glyph_string *s)
2426 break; 2426 break;
2427 2427
2428 default: 2428 default:
2429 abort (); 2429 emacs_abort ();
2430 } 2430 }
2431 2431
2432 if (!s->for_overlaps) 2432 if (!s->for_overlaps)
@@ -2626,7 +2626,7 @@ x_delete_glyphs (struct frame *f, register int n)
2626 if (! FRAME_W32_P (f)) 2626 if (! FRAME_W32_P (f))
2627 return; 2627 return;
2628 2628
2629 abort (); 2629 emacs_abort ();
2630} 2630}
2631 2631
2632 2632
@@ -2709,7 +2709,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n)
2709 if (! FRAME_W32_P (f)) 2709 if (! FRAME_W32_P (f))
2710 return; 2710 return;
2711 2711
2712 abort (); 2712 emacs_abort ();
2713} 2713}
2714 2714
2715 2715
@@ -3431,7 +3431,7 @@ x_window_to_scroll_bar (Window window_id)
3431 frame = XCAR (tail); 3431 frame = XCAR (tail);
3432 /* All elements of Vframe_list should be frames. */ 3432 /* All elements of Vframe_list should be frames. */
3433 if (! FRAMEP (frame)) 3433 if (! FRAMEP (frame))
3434 abort (); 3434 emacs_abort ();
3435 3435
3436 /* Scan this frame's scroll bar list for a scroll bar with the 3436 /* Scan this frame's scroll bar list for a scroll bar with the
3437 right window ID. */ 3437 right window ID. */
@@ -3854,7 +3854,7 @@ w32_redeem_scroll_bar (struct window *window)
3854 3854
3855 /* We can't redeem this window's scroll bar if it doesn't have one. */ 3855 /* We can't redeem this window's scroll bar if it doesn't have one. */
3856 if (NILP (window->vertical_scroll_bar)) 3856 if (NILP (window->vertical_scroll_bar))
3857 abort (); 3857 emacs_abort ();
3858 3858
3859 bar = XSCROLL_BAR (window->vertical_scroll_bar); 3859 bar = XSCROLL_BAR (window->vertical_scroll_bar);
3860 3860
@@ -3873,7 +3873,7 @@ w32_redeem_scroll_bar (struct window *window)
3873 else 3873 else
3874 /* If its prev pointer is nil, it must be at the front of 3874 /* If its prev pointer is nil, it must be at the front of
3875 one or the other! */ 3875 one or the other! */
3876 abort (); 3876 emacs_abort ();
3877 } 3877 }
3878 else 3878 else
3879 XSCROLL_BAR (bar->prev)->next = bar->next; 3879 XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -3928,7 +3928,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
3928 struct input_event *emacs_event) 3928 struct input_event *emacs_event)
3929{ 3929{
3930 if (! WINDOWP (bar->window)) 3930 if (! WINDOWP (bar->window))
3931 abort (); 3931 emacs_abort ();
3932 3932
3933 emacs_event->kind = SCROLL_BAR_CLICK_EVENT; 3933 emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
3934 emacs_event->code = 0; 3934 emacs_event->code = 0;
@@ -5233,7 +5233,7 @@ w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
5233 break; 5233 break;
5234 5234
5235 default: 5235 default:
5236 abort (); 5236 emacs_abort ();
5237 } 5237 }
5238 } 5238 }
5239} 5239}
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index bc45e2c648c..cf99d14dc77 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -454,7 +454,11 @@ uniscribe_shape (Lisp_Object lgstring)
454 } 454 }
455 else 455 else
456 ASET (vec, 0, make_number (offsets[j].du + adj_offset)); 456 ASET (vec, 0, make_number (offsets[j].du + adj_offset));
457 ASET (vec, 1, make_number (offsets[j].dv)); 457 /* In the font definition coordinate system, the
458 Y coordinate points up, while in our screen
459 coordinates Y grows downwards. So we need to
460 reverse the sign of Y-OFFSET here. */
461 ASET (vec, 1, make_number (-offsets[j].dv));
458 /* Based on what ftfont.c does... */ 462 /* Based on what ftfont.c does... */
459 ASET (vec, 2, make_number (advances[j])); 463 ASET (vec, 2, make_number (advances[j]));
460 LGLYPH_SET_ADJUSTMENT (lglyph, vec); 464 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 62e45dd987b..820dbcc76c6 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -122,7 +122,7 @@ get_frame_dc (FRAME_PTR f)
122 HDC hdc; 122 HDC hdc;
123 123
124 if (f->output_method != output_w32) 124 if (f->output_method != output_w32)
125 abort (); 125 emacs_abort ();
126 126
127 enter_crit (); 127 enter_crit ();
128 128
diff --git a/src/widget.c b/src/widget.c
index ea9bdb61b13..0100acc8143 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -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. */
@@ -677,8 +674,8 @@ EmacsFrameDestroy (Widget widget)
677 EmacsFrame ew = (EmacsFrame) widget; 674 EmacsFrame ew = (EmacsFrame) widget;
678 struct frame* s = ew->emacs_frame.frame; 675 struct frame* s = ew->emacs_frame.frame;
679 676
680 if (! s) abort (); 677 if (! s) emacs_abort ();
681 if (! s->output_data.x) abort (); 678 if (! s->output_data.x) emacs_abort ();
682 679
683 BLOCK_INPUT; 680 BLOCK_INPUT;
684 x_free_gcs (s); 681 x_free_gcs (s);
diff --git a/src/window.c b/src/window.c
index 93fef54c95f..87429b51448 100644
--- a/src/window.c
+++ b/src/window.c
@@ -387,7 +387,7 @@ the first window of that frame. */)
387 else if (! NILP (XWINDOW (window)->vchild)) 387 else if (! NILP (XWINDOW (window)->vchild))
388 window = XWINDOW (window)->vchild; 388 window = XWINDOW (window)->vchild;
389 else 389 else
390 abort (); 390 emacs_abort ();
391 } 391 }
392 392
393 return window; 393 return window;
@@ -1290,7 +1290,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1290 return Qnil; 1290 return Qnil;
1291 1291
1292 default: 1292 default:
1293 abort (); 1293 emacs_abort ();
1294 } 1294 }
1295} 1295}
1296 1296
@@ -1949,7 +1949,7 @@ unshow_buffer (register struct window *w)
1949 buf = w->buffer; 1949 buf = w->buffer;
1950 b = XBUFFER (buf); 1950 b = XBUFFER (buf);
1951 if (b != XMARKER (w->pointm)->buffer) 1951 if (b != XMARKER (w->pointm)->buffer)
1952 abort (); 1952 emacs_abort ();
1953 1953
1954#if 0 1954#if 0
1955 if (w == XWINDOW (selected_window) 1955 if (w == XWINDOW (selected_window)
@@ -2670,7 +2670,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2670 case CHECK_ALL_WINDOWS: 2670 case CHECK_ALL_WINDOWS:
2671 if (! NILP (w->buffer) 2671 if (! NILP (w->buffer)
2672 && NILP (BVAR (XBUFFER (w->buffer), name))) 2672 && NILP (BVAR (XBUFFER (w->buffer), name)))
2673 abort (); 2673 emacs_abort ();
2674 break; 2674 break;
2675 2675
2676 case WINDOW_LOOP_UNUSED: 2676 case WINDOW_LOOP_UNUSED:
@@ -6580,15 +6580,17 @@ freeze_window_starts (struct frame *f, int freeze_p)
6580/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 6580/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2
6581 describe the same state of affairs. This is used by Fequal. 6581 describe the same state of affairs. This is used by Fequal.
6582 6582
6583 ignore_positions non-zero means ignore non-matching scroll positions 6583 IGNORE_POSITIONS means ignore non-matching scroll positions
6584 and the like. 6584 and the like.
6585 6585
6586 This ignores a couple of things like the dedication status of 6586 This ignores a couple of things like the dedication status of
6587 window, combination_limit and the like. This might have to be 6587 window, combination_limit and the like. This might have to be
6588 fixed. */ 6588 fixed. */
6589 6589
6590int 6590bool
6591compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions) 6591compare_window_configurations (Lisp_Object configuration1,
6592 Lisp_Object configuration2,
6593 bool ignore_positions)
6592{ 6594{
6593 register struct save_window_data *d1, *d2; 6595 register struct save_window_data *d1, *d2;
6594 struct Lisp_Vector *sws1, *sws2; 6596 struct Lisp_Vector *sws1, *sws2;
diff --git a/src/window.h b/src/window.h
index dfb88b2cf3c..a70bc55bac5 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.
@@ -973,7 +971,7 @@ extern Lisp_Object Qwindowp, Qwindow_live_p;
973extern Lisp_Object Vwindow_list; 971extern Lisp_Object Vwindow_list;
974 972
975extern struct window *decode_live_window (Lisp_Object); 973extern struct window *decode_live_window (Lisp_Object);
976extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); 974extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool);
977extern void mark_window_cursors_off (struct window *); 975extern void mark_window_cursors_off (struct window *);
978extern int window_internal_height (struct window *); 976extern int window_internal_height (struct window *);
979extern int window_body_cols (struct window *w); 977extern int window_body_cols (struct window *w);
diff --git a/src/xdisp.c b/src/xdisp.c
index fcd76c94681..df402cd106e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -366,6 +366,7 @@ static Lisp_Object Qslice;
366Lisp_Object Qcenter; 366Lisp_Object Qcenter;
367static Lisp_Object Qmargin, Qpointer; 367static Lisp_Object Qmargin, Qpointer;
368static Lisp_Object Qline_height; 368static Lisp_Object Qline_height;
369Lisp_Object Qinhibit_debug_on_message;
369 370
370/* These setters are used only in this file, so they can be private. */ 371/* These setters are used only in this file, so they can be private. */
371static inline void 372static inline void
@@ -7347,7 +7348,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
7347#endif 7348#endif
7348 default: 7349 default:
7349 /* There are no other methods defined, so this should be a bug. */ 7350 /* There are no other methods defined, so this should be a bug. */
7350 abort (); 7351 emacs_abort ();
7351 } 7352 }
7352 7353
7353 eassert (it->method != GET_FROM_STRING 7354 eassert (it->method != GET_FROM_STRING
@@ -7815,7 +7816,7 @@ compute_stop_pos_backwards (struct it *it)
7815 compute_stop_pos (it); 7816 compute_stop_pos (it);
7816 /* We must advance forward, right? */ 7817 /* We must advance forward, right? */
7817 if (it->stop_charpos <= charpos) 7818 if (it->stop_charpos <= charpos)
7818 abort (); 7819 emacs_abort ();
7819 } 7820 }
7820 while (charpos > BEGV && it->stop_charpos >= it->end_charpos); 7821 while (charpos > BEGV && it->stop_charpos >= it->end_charpos);
7821 7822
@@ -7864,7 +7865,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
7864 compute_stop_pos (it); 7865 compute_stop_pos (it);
7865 /* We must advance forward, right? */ 7866 /* We must advance forward, right? */
7866 if (it->stop_charpos <= it->prev_stop) 7867 if (it->stop_charpos <= it->prev_stop)
7867 abort (); 7868 emacs_abort ();
7868 charpos = it->stop_charpos; 7869 charpos = it->stop_charpos;
7869 } 7870 }
7870 while (charpos <= where_we_are); 7871 while (charpos <= where_we_are);
@@ -8952,7 +8953,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
8952 break; 8953 break;
8953 8954
8954 default: 8955 default:
8955 abort (); 8956 emacs_abort ();
8956 } 8957 }
8957 8958
8958 /* Reset/increment for the next run. */ 8959 /* Reset/increment for the next run. */
@@ -10586,7 +10587,7 @@ void
10586check_message_stack (void) 10587check_message_stack (void)
10587{ 10588{
10588 if (!NILP (Vmessage_stack)) 10589 if (!NILP (Vmessage_stack))
10589 abort (); 10590 emacs_abort ();
10590} 10591}
10591 10592
10592 10593
@@ -10625,7 +10626,6 @@ truncate_message_1 (ptrdiff_t nchars, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4
10625 return 0; 10626 return 0;
10626} 10627}
10627 10628
10628
10629/* Set the current message to a substring of S or STRING. 10629/* Set the current message to a substring of S or STRING.
10630 10630
10631 If STRING is a Lisp string, set the message to the first NBYTES 10631 If STRING is a Lisp string, set the message to the first NBYTES
@@ -10644,6 +10644,8 @@ static void
10644set_message (const char *s, Lisp_Object string, 10644set_message (const char *s, Lisp_Object string,
10645 ptrdiff_t nbytes, int multibyte_p) 10645 ptrdiff_t nbytes, int multibyte_p)
10646{ 10646{
10647 ptrdiff_t count = SPECPDL_INDEX ();
10648
10647 message_enable_multibyte 10649 message_enable_multibyte
10648 = ((s && multibyte_p) 10650 = ((s && multibyte_p)
10649 || (STRINGP (string) && STRING_MULTIBYTE (string))); 10651 || (STRINGP (string) && STRING_MULTIBYTE (string)));
@@ -10652,6 +10654,15 @@ set_message (const char *s, Lisp_Object string,
10652 (intptr_t) s, string, nbytes, multibyte_p); 10654 (intptr_t) s, string, nbytes, multibyte_p);
10653 message_buf_print = 0; 10655 message_buf_print = 0;
10654 help_echo_showing_p = 0; 10656 help_echo_showing_p = 0;
10657
10658 if (NILP (Vinhibit_debug_on_message) && STRINGP (Vdebug_on_message)
10659 && fast_string_match (Vdebug_on_message, string) >= 0)
10660 {
10661 specbind (Qinhibit_debug_on_message, Qt);
10662 call_debugger (list2 (Qerror, string));
10663 }
10664
10665 unbind_to (count, Qnil);
10655} 10666}
10656 10667
10657 10668
@@ -13572,10 +13583,9 @@ redisplay_internal (void)
13572 } 13583 }
13573 else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf)) 13584 else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf))
13574 { 13585 {
13575 Lisp_Object mini_window; 13586 Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf);
13576 struct frame *mini_frame; 13587 struct frame *mini_frame;
13577 13588
13578 mini_window = FRAME_MINIBUF_WINDOW (sf);
13579 displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); 13589 displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer);
13580 /* Use list_of_error, not Qerror, so that 13590 /* Use list_of_error, not Qerror, so that
13581 we catch only errors and don't run the debugger. */ 13591 we catch only errors and don't run the debugger. */
@@ -14477,7 +14487,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14477 for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) 14487 for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++)
14478 { 14488 {
14479 if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]) 14489 if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA])
14480 abort (); 14490 emacs_abort ();
14481 x += g->pixel_width; 14491 x += g->pixel_width;
14482 } 14492 }
14483 } 14493 }
@@ -14598,7 +14608,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14598 SET_MARKER_FROM_TEXT_POS (w->start, startp); 14608 SET_MARKER_FROM_TEXT_POS (w->start, startp);
14599 14609
14600 if (current_buffer != XBUFFER (w->buffer)) 14610 if (current_buffer != XBUFFER (w->buffer))
14601 abort (); 14611 emacs_abort ();
14602 14612
14603 if (!NILP (Vwindow_scroll_functions)) 14613 if (!NILP (Vwindow_scroll_functions))
14604 { 14614 {
@@ -15567,9 +15577,9 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15567 /* Some sanity checks. */ 15577 /* Some sanity checks. */
15568 CHECK_WINDOW_END (w); 15578 CHECK_WINDOW_END (w);
15569 if (Z == Z_BYTE && CHARPOS (opoint) != BYTEPOS (opoint)) 15579 if (Z == Z_BYTE && CHARPOS (opoint) != BYTEPOS (opoint))
15570 abort (); 15580 emacs_abort ();
15571 if (BYTEPOS (opoint) < CHARPOS (opoint)) 15581 if (BYTEPOS (opoint) < CHARPOS (opoint))
15572 abort (); 15582 emacs_abort ();
15573 15583
15574 /* If %c is in mode line, update it if needed. */ 15584 /* If %c is in mode line, update it if needed. */
15575 if (!NILP (w->column_number_displayed) 15585 if (!NILP (w->column_number_displayed)
@@ -15781,7 +15791,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15781 goto try_to_scroll; 15791 goto try_to_scroll;
15782 15792
15783 default: 15793 default:
15784 abort (); 15794 emacs_abort ();
15785 } 15795 }
15786 } 15796 }
15787 /* If current starting point was originally the beginning of a line 15797 /* If current starting point was originally the beginning of a line
@@ -15944,7 +15954,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15944 break; 15954 break;
15945 15955
15946 default: 15956 default:
15947 abort (); 15957 emacs_abort ();
15948 } 15958 }
15949 } 15959 }
15950 15960
@@ -17413,7 +17423,7 @@ try_window_id (struct window *w)
17413 if (row) 17423 if (row)
17414 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); 17424 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
17415 else 17425 else
17416 abort (); 17426 emacs_abort ();
17417 return 1; 17427 return 1;
17418 } 17428 }
17419 } 17429 }
@@ -17457,7 +17467,7 @@ try_window_id (struct window *w)
17457 if (row) 17467 if (row)
17458 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); 17468 set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
17459 else 17469 else
17460 abort (); 17470 emacs_abort ();
17461 return 2; 17471 return 2;
17462 } 17472 }
17463 } 17473 }
@@ -17946,7 +17956,7 @@ try_window_id (struct window *w)
17946 IF_DEBUG (debug_method_add (w, "C")); 17956 IF_DEBUG (debug_method_add (w, "C"));
17947 } 17957 }
17948 else 17958 else
17949 abort (); 17959 emacs_abort ();
17950 17960
17951 IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos); 17961 IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos);
17952 debug_end_vpos = XFASTINT (w->window_end_vpos)); 17962 debug_end_vpos = XFASTINT (w->window_end_vpos));
@@ -19346,7 +19356,7 @@ find_row_edges (struct it *it, struct glyph_row *row,
19346 /* A line that is entirely from a string/image/stretch... */ 19356 /* A line that is entirely from a string/image/stretch... */
19347 row->maxpos = row->minpos; 19357 row->maxpos = row->minpos;
19348 else 19358 else
19349 abort (); 19359 emacs_abort ();
19350 } 19360 }
19351 else 19361 else
19352 row->maxpos = it->current.pos; 19362 row->maxpos = it->current.pos;
@@ -20187,7 +20197,7 @@ See also `bidi-paragraph-direction'. */)
20187 return Qright_to_left; 20197 return Qright_to_left;
20188 break; 20198 break;
20189 default: 20199 default:
20190 abort (); 20200 emacs_abort ();
20191 } 20201 }
20192 } 20202 }
20193} 20203}
@@ -22100,7 +22110,7 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st
22100 { 22110 {
22101 /* Glyph is off the left margin of the display area. 22111 /* Glyph is off the left margin of the display area.
22102 Should not happen. */ 22112 Should not happen. */
22103 abort (); 22113 emacs_abort ();
22104 } 22114 }
22105 22115
22106 row->ascent = max (row->ascent, it->max_ascent); 22116 row->ascent = max (row->ascent, it->max_ascent);
@@ -23507,7 +23517,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
23507 break; \ 23517 break; \
23508 \ 23518 \
23509 default: \ 23519 default: \
23510 abort (); \ 23520 emacs_abort (); \
23511 } \ 23521 } \
23512 \ 23522 \
23513 if (s) \ 23523 if (s) \
@@ -23860,7 +23870,7 @@ append_glyph (struct it *it)
23860 { 23870 {
23861 glyph->resolved_level = it->bidi_it.resolved_level; 23871 glyph->resolved_level = it->bidi_it.resolved_level;
23862 if ((it->bidi_it.type & 7) != it->bidi_it.type) 23872 if ((it->bidi_it.type & 7) != it->bidi_it.type)
23863 abort (); 23873 emacs_abort ();
23864 glyph->bidi_type = it->bidi_it.type; 23874 glyph->bidi_type = it->bidi_it.type;
23865 } 23875 }
23866 else 23876 else
@@ -23934,7 +23944,7 @@ append_composite_glyph (struct it *it)
23934 { 23944 {
23935 glyph->resolved_level = it->bidi_it.resolved_level; 23945 glyph->resolved_level = it->bidi_it.resolved_level;
23936 if ((it->bidi_it.type & 7) != it->bidi_it.type) 23946 if ((it->bidi_it.type & 7) != it->bidi_it.type)
23937 abort (); 23947 emacs_abort ();
23938 glyph->bidi_type = it->bidi_it.type; 23948 glyph->bidi_type = it->bidi_it.type;
23939 } 23949 }
23940 ++it->glyph_row->used[area]; 23950 ++it->glyph_row->used[area];
@@ -24113,7 +24123,7 @@ produce_image_glyph (struct it *it)
24113 { 24123 {
24114 glyph->resolved_level = it->bidi_it.resolved_level; 24124 glyph->resolved_level = it->bidi_it.resolved_level;
24115 if ((it->bidi_it.type & 7) != it->bidi_it.type) 24125 if ((it->bidi_it.type & 7) != it->bidi_it.type)
24116 abort (); 24126 emacs_abort ();
24117 glyph->bidi_type = it->bidi_it.type; 24127 glyph->bidi_type = it->bidi_it.type;
24118 } 24128 }
24119 ++it->glyph_row->used[area]; 24129 ++it->glyph_row->used[area];
@@ -24257,7 +24267,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object,
24257 { 24267 {
24258 glyph->resolved_level = it->bidi_it.resolved_level; 24268 glyph->resolved_level = it->bidi_it.resolved_level;
24259 if ((it->bidi_it.type & 7) != it->bidi_it.type) 24269 if ((it->bidi_it.type & 7) != it->bidi_it.type)
24260 abort (); 24270 emacs_abort ();
24261 glyph->bidi_type = it->bidi_it.type; 24271 glyph->bidi_type = it->bidi_it.type;
24262 } 24272 }
24263 else 24273 else
@@ -24512,7 +24522,7 @@ produce_special_glyphs (struct it *it, enum display_element_type what)
24512 } 24522 }
24513 } 24523 }
24514 else 24524 else
24515 abort (); 24525 emacs_abort ();
24516 24526
24517#ifdef HAVE_WINDOW_SYSTEM 24527#ifdef HAVE_WINDOW_SYSTEM
24518 /* On a GUI frame, when the right fringe (left fringe for R2L rows) 24528 /* On a GUI frame, when the right fringe (left fringe for R2L rows)
@@ -24709,7 +24719,7 @@ append_glyphless_glyph (struct it *it, int face_id, int for_no_font, int len,
24709 { 24719 {
24710 glyph->resolved_level = it->bidi_it.resolved_level; 24720 glyph->resolved_level = it->bidi_it.resolved_level;
24711 if ((it->bidi_it.type & 7) != it->bidi_it.type) 24721 if ((it->bidi_it.type & 7) != it->bidi_it.type)
24712 abort (); 24722 emacs_abort ();
24713 glyph->bidi_type = it->bidi_it.type; 24723 glyph->bidi_type = it->bidi_it.type;
24714 } 24724 }
24715 ++it->glyph_row->used[area]; 24725 ++it->glyph_row->used[area];
@@ -29552,6 +29562,15 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
29552 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil); 29562 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
29553 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0), 29563 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
29554 Qempty_box); 29564 Qempty_box);
29565
29566 DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
29567 doc: /* If non-nil, debug if a message matching this regexp is displayed. */);
29568 Vdebug_on_message = Qnil;
29569
29570 DEFVAR_LISP ("inhibit-debug-on-message", Vinhibit_debug_on_message,
29571 doc: /* If non-nil, inhibit `debug-on-message' from entering the debugger. */);
29572 Vinhibit_debug_on_message = Qnil;
29573 DEFSYM(Qinhibit_debug_on_message, "inhibit-debug-on-message");
29555} 29574}
29556 29575
29557 29576
diff --git a/src/xfaces.c b/src/xfaces.c
index 4df5caf6f2a..aee5158036f 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -510,7 +510,7 @@ unregister_color (unsigned long pixel)
510 if (color_count[pixel] > 0) 510 if (color_count[pixel] > 0)
511 --color_count[pixel]; 511 --color_count[pixel];
512 else 512 else
513 abort (); 513 emacs_abort ();
514} 514}
515 515
516 516
@@ -727,7 +727,7 @@ init_frame_faces (struct frame *f)
727 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) 727 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f))
728#endif 728#endif
729 if (!realize_basic_faces (f)) 729 if (!realize_basic_faces (f))
730 abort (); 730 emacs_abort ();
731} 731}
732 732
733 733
@@ -771,7 +771,7 @@ recompute_basic_faces (struct frame *f)
771 { 771 {
772 clear_face_cache (0); 772 clear_face_cache (0);
773 if (!realize_basic_faces (f)) 773 if (!realize_basic_faces (f))
774 abort (); 774 emacs_abort ();
775 } 775 }
776} 776}
777 777
@@ -1108,7 +1108,7 @@ defined_color (struct frame *f, const char *color_name, XColor *color_def,
1108 return ns_defined_color (f, color_name, color_def, alloc, 1); 1108 return ns_defined_color (f, color_name, color_def, alloc, 1);
1109#endif 1109#endif
1110 else 1110 else
1111 abort (); 1111 emacs_abort ();
1112} 1112}
1113 1113
1114 1114
@@ -1304,7 +1304,7 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
1304 break; 1304 break;
1305 1305
1306 default: 1306 default:
1307 abort (); 1307 emacs_abort ();
1308 } 1308 }
1309 } 1309 }
1310#ifdef GLYPH_DEBUG 1310#ifdef GLYPH_DEBUG
@@ -4548,7 +4548,7 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, int signal_p)
4548 return -1; 4548 return -1;
4549 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 4549 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
4550 if (default_face == NULL) 4550 if (default_face == NULL)
4551 abort (); /* realize_basic_faces must have set it up */ 4551 emacs_abort (); /* realize_basic_faces must have set it up */
4552 } 4552 }
4553 4553
4554 if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) 4554 if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
@@ -4591,7 +4591,7 @@ lookup_basic_face (struct frame *f, int face_id)
4591 case MENU_FACE_ID: name = Qmenu; break; 4591 case MENU_FACE_ID: name = Qmenu; break;
4592 4592
4593 default: 4593 default:
4594 abort (); /* the caller is supposed to pass us a basic face id */ 4594 emacs_abort (); /* the caller is supposed to pass us a basic face id */
4595 } 4595 }
4596 4596
4597 /* Do a quick scan through Vface_remapping_alist, and return immediately 4597 /* Do a quick scan through Vface_remapping_alist, and return immediately
@@ -4712,7 +4712,7 @@ lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id,
4712 struct face *default_face = FACE_FROM_ID (f, face_id); 4712 struct face *default_face = FACE_FROM_ID (f, face_id);
4713 4713
4714 if (!default_face) 4714 if (!default_face)
4715 abort (); 4715 emacs_abort ();
4716 4716
4717 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) 4717 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
4718 return -1; 4718 return -1;
@@ -5102,7 +5102,7 @@ face for italic. */)
5102 error ("Cannot realize default face"); 5102 error ("Cannot realize default face");
5103 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 5103 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
5104 if (def_face == NULL) 5104 if (def_face == NULL)
5105 abort (); /* realize_basic_faces must have set it up */ 5105 emacs_abort (); /* realize_basic_faces must have set it up */
5106 } 5106 }
5107 5107
5108 /* Dispatch to the appropriate handler. */ 5108 /* Dispatch to the appropriate handler. */
@@ -5387,7 +5387,7 @@ realize_default_face (struct frame *f)
5387 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) 5387 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5388 ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg)); 5388 ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg));
5389 else 5389 else
5390 abort (); 5390 emacs_abort ();
5391 } 5391 }
5392 5392
5393 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) 5393 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
@@ -5402,7 +5402,7 @@ realize_default_face (struct frame *f)
5402 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) 5402 else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5403 ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg)); 5403 ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg));
5404 else 5404 else
5405 abort (); 5405 emacs_abort ();
5406 } 5406 }
5407 5407
5408 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) 5408 if (UNSPECIFIEDP (LFACE_STIPPLE (lface)))
@@ -5502,7 +5502,7 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id)
5502 face = make_realized_face (attrs); 5502 face = make_realized_face (attrs);
5503 } 5503 }
5504 else 5504 else
5505 abort (); 5505 emacs_abort ();
5506 5506
5507 /* Insert the new face. */ 5507 /* Insert the new face. */
5508 cache_face (cache, face, lface_hash (attrs)); 5508 cache_face (cache, face, lface_hash (attrs));
@@ -5597,7 +5597,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
5597 if (default_face) 5597 if (default_face)
5598 fontset = default_face->fontset; 5598 fontset = default_face->fontset;
5599 if (fontset == -1) 5599 if (fontset == -1)
5600 abort (); 5600 emacs_abort ();
5601 } 5601 }
5602 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX])) 5602 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
5603 attrs[LFACE_FONT_INDEX] 5603 attrs[LFACE_FONT_INDEX]
diff --git a/src/xfont.c b/src/xfont.c
index be9556d585a..7755b780815 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -126,7 +126,7 @@ static int xfont_has_char (Lisp_Object, int);
126static unsigned xfont_encode_char (struct font *, int); 126static unsigned xfont_encode_char (struct font *, int);
127static int xfont_text_extents (struct font *, unsigned *, int, 127static int xfont_text_extents (struct font *, unsigned *, int,
128 struct font_metrics *); 128 struct font_metrics *);
129static int xfont_draw (struct glyph_string *, int, int, int, int, int); 129static int xfont_draw (struct glyph_string *, int, int, int, int, bool);
130static int xfont_check (FRAME_PTR, struct font *); 130static int xfont_check (FRAME_PTR, struct font *);
131 131
132struct font_driver xfont_driver = 132struct font_driver xfont_driver =
@@ -217,9 +217,9 @@ xfont_encode_coding_xlfd (char *xlfd)
217/* Check if CHARS (cons or vector) is supported by XFONT whose 217/* Check if CHARS (cons or vector) is supported by XFONT whose
218 encoding charset is ENCODING (XFONT is NULL) or by a font whose 218 encoding charset is ENCODING (XFONT is NULL) or by a font whose
219 registry corresponds to ENCODING and REPERTORY. 219 registry corresponds to ENCODING and REPERTORY.
220 Return 1 if supported, return 0 otherwise. */ 220 Return true if supported. */
221 221
222static int 222static bool
223xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, 223xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
224 struct charset *encoding, struct charset *repertory) 224 struct charset *encoding, struct charset *repertory)
225{ 225{
@@ -1019,7 +1019,8 @@ xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct f
1019} 1019}
1020 1020
1021static int 1021static int
1022xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 1022xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1023 bool with_background)
1023{ 1024{
1024 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; 1025 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont;
1025 int len = to - from; 1026 int len = to - from;
@@ -1040,7 +1041,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_bac
1040 for (i = 0; i < len ; i++) 1041 for (i = 0; i < len ; i++)
1041 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); 1042 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
1042 BLOCK_INPUT; 1043 BLOCK_INPUT;
1043 if (with_background > 0) 1044 if (with_background)
1044 { 1045 {
1045 if (s->padding_p) 1046 if (s->padding_p)
1046 for (i = 0; i < len; i++) 1047 for (i = 0; i < len; i++)
@@ -1066,7 +1067,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_bac
1066 } 1067 }
1067 1068
1068 BLOCK_INPUT; 1069 BLOCK_INPUT;
1069 if (with_background > 0) 1070 if (with_background)
1070 { 1071 {
1071 if (s->padding_p) 1072 if (s->padding_p)
1072 for (i = 0; i < len; i++) 1073 for (i = 0; i < len; i++)
diff --git a/src/xftfont.c b/src/xftfont.c
index 5e60ab0c4d3..404b9124099 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -52,7 +52,7 @@ struct xftfont_info
52 /* The following five members must be here in this order to be 52 /* The following five members must be here in this order to be
53 compatible with struct ftfont_info (in ftfont.c). */ 53 compatible with struct ftfont_info (in ftfont.c). */
54#ifdef HAVE_LIBOTF 54#ifdef HAVE_LIBOTF
55 int maybe_otf; /* Flag to tell if this may be OTF or not. */ 55 bool maybe_otf; /* Flag to tell if this may be OTF or not. */
56 OTF *otf; 56 OTF *otf;
57#endif /* HAVE_LIBOTF */ 57#endif /* HAVE_LIBOTF */
58 FT_Size ft_size; 58 FT_Size ft_size;
@@ -92,7 +92,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
92 else 92 else
93 { 93 {
94 XGCValues xgcv; 94 XGCValues xgcv;
95 int fg_done = 0, bg_done = 0; 95 bool fg_done = 0, bg_done = 0;
96 96
97 BLOCK_INPUT; 97 BLOCK_INPUT;
98 XGetGCValues (FRAME_X_DISPLAY (f), gc, 98 XGetGCValues (FRAME_X_DISPLAY (f), gc,
@@ -111,7 +111,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
111 *bg = xftface_info->xft_fg, bg_done = 1; 111 *bg = xftface_info->xft_fg, bg_done = 1;
112 } 112 }
113 113
114 if (fg_done + bg_done < 2) 114 if (! (fg_done & bg_done))
115 { 115 {
116 XColor colors[2]; 116 XColor colors[2];
117 117
@@ -137,19 +137,6 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
137} 137}
138 138
139 139
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; 140struct font_driver xftfont_driver;
154 141
155static Lisp_Object 142static Lisp_Object
@@ -470,7 +457,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
470 font->underline_thickness = 0; 457 font->underline_thickness = 0;
471 } 458 }
472#ifdef HAVE_LIBOTF 459#ifdef HAVE_LIBOTF
473 xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; 460 xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
474 xftfont_info->otf = NULL; 461 xftfont_info->otf = NULL;
475#endif /* HAVE_LIBOTF */ 462#endif /* HAVE_LIBOTF */
476 xftfont_info->ft_size = ft_face->size; 463 xftfont_info->ft_size = ft_face->size;
@@ -630,7 +617,8 @@ xftfont_get_xft_draw (FRAME_PTR f)
630} 617}
631 618
632static int 619static int
633xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) 620xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
621 bool with_background)
634{ 622{
635 FRAME_PTR f = s->f; 623 FRAME_PTR f = s->f;
636 struct face *face = s->face; 624 struct face *face = s->face;
@@ -711,15 +699,17 @@ xftfont_end_for_frame (FRAME_PTR f)
711 return 0; 699 return 0;
712} 700}
713 701
714static int 702static bool
715xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity) 703xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
704 Lisp_Object entity)
716{ 705{
717 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object); 706 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object);
718 FcPattern *oldpat = info->xftfont->pattern; 707 FcPattern *oldpat = info->xftfont->pattern;
719 Display *display = FRAME_X_DISPLAY (f); 708 Display *display = FRAME_X_DISPLAY (f);
720 FcPattern *pat = FcPatternCreate (); 709 FcPattern *pat = FcPatternCreate ();
721 FcBool b1, b2; 710 FcBool b1, b2;
722 int ok = 0, i1, i2, r1, r2; 711 bool ok = 0;
712 int i1, i2, r1, r2;
723 713
724 xftfont_add_rendering_parameters (pat, entity); 714 xftfont_add_rendering_parameters (pat, entity);
725 XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); 715 XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
diff --git a/src/xmenu.c b/src/xmenu.c
index 54a7849218a..605db13e149 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -32,11 +32,6 @@ 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> 36#include <setjmp.h>
42 37
@@ -169,7 +164,7 @@ mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
169 int dummy; 164 int dummy;
170 165
171 if (! FRAME_X_P (f)) 166 if (! FRAME_X_P (f))
172 abort (); 167 emacs_abort ();
173 168
174 BLOCK_INPUT; 169 BLOCK_INPUT;
175 170
@@ -636,7 +631,7 @@ void
636x_activate_menubar (FRAME_PTR f) 631x_activate_menubar (FRAME_PTR f)
637{ 632{
638 if (! FRAME_X_P (f)) 633 if (! FRAME_X_P (f))
639 abort (); 634 emacs_abort ();
640 635
641 if (!f->output_data.x->saved_menu_event->type) 636 if (!f->output_data.x->saved_menu_event->type)
642 return; 637 return;
@@ -852,7 +847,7 @@ update_frame_menubar (FRAME_PTR f)
852 int columns, rows; 847 int columns, rows;
853 848
854 if (! FRAME_X_P (f)) 849 if (! FRAME_X_P (f))
855 abort (); 850 emacs_abort ();
856 851
857 x = f->output_data.x; 852 x = f->output_data.x;
858 853
@@ -940,7 +935,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
940 int *submenu_top_level_items, *submenu_n_panes; 935 int *submenu_top_level_items, *submenu_n_panes;
941 936
942 if (! FRAME_X_P (f)) 937 if (! FRAME_X_P (f))
943 abort (); 938 emacs_abort ();
944 939
945 menubar_widget = f->output_data.x->menubar_widget; 940 menubar_widget = f->output_data.x->menubar_widget;
946 941
@@ -1299,7 +1294,7 @@ free_frame_menubar (FRAME_PTR f)
1299 Widget menubar_widget; 1294 Widget menubar_widget;
1300 1295
1301 if (! FRAME_X_P (f)) 1296 if (! FRAME_X_P (f))
1302 abort (); 1297 emacs_abort ();
1303 1298
1304 menubar_widget = f->output_data.x->menubar_widget; 1299 menubar_widget = f->output_data.x->menubar_widget;
1305 1300
@@ -1450,7 +1445,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y,
1450#endif 1445#endif
1451 1446
1452 if (! FRAME_X_P (f)) 1447 if (! FRAME_X_P (f))
1453 abort (); 1448 emacs_abort ();
1454 1449
1455 xg_crazy_callback_abort = 1; 1450 xg_crazy_callback_abort = 1;
1456 menu = xg_create_widget ("popup", first_wv->name, f, first_wv, 1451 menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
@@ -1557,7 +1552,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
1557 Widget menu; 1552 Widget menu;
1558 1553
1559 if (! FRAME_X_P (f)) 1554 if (! FRAME_X_P (f))
1560 abort (); 1555 emacs_abort ();
1561 1556
1562#ifdef USE_LUCID 1557#ifdef USE_LUCID
1563 apply_systemfont_to_menu (f, f->output_data.x->widget); 1558 apply_systemfont_to_menu (f, f->output_data.x->widget);
@@ -1646,7 +1641,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1646 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 1641 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
1647 1642
1648 if (! FRAME_X_P (f)) 1643 if (! FRAME_X_P (f))
1649 abort (); 1644 emacs_abort ();
1650 1645
1651 *error_name = NULL; 1646 *error_name = NULL;
1652 1647
@@ -1792,7 +1787,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1792 else if (EQ (type, QCradio)) 1787 else if (EQ (type, QCradio))
1793 wv->button_type = BUTTON_TYPE_RADIO; 1788 wv->button_type = BUTTON_TYPE_RADIO;
1794 else 1789 else
1795 abort (); 1790 emacs_abort ();
1796 1791
1797 wv->selected = !NILP (selected); 1792 wv->selected = !NILP (selected);
1798 1793
@@ -1930,7 +1925,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
1930 GtkWidget *menu; 1925 GtkWidget *menu;
1931 1926
1932 if (! FRAME_X_P (f)) 1927 if (! FRAME_X_P (f))
1933 abort (); 1928 emacs_abort ();
1934 1929
1935 menu = xg_create_widget ("dialog", first_wv->name, f, first_wv, 1930 menu = xg_create_widget ("dialog", first_wv->name, f, first_wv,
1936 G_CALLBACK (dialog_selection_callback), 1931 G_CALLBACK (dialog_selection_callback),
@@ -1977,7 +1972,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
1977 LWLIB_ID dialog_id; 1972 LWLIB_ID dialog_id;
1978 1973
1979 if (!FRAME_X_P (f)) 1974 if (!FRAME_X_P (f))
1980 abort (); 1975 emacs_abort ();
1981 1976
1982 dialog_id = widget_id_tick++; 1977 dialog_id = widget_id_tick++;
1983#ifdef USE_LUCID 1978#ifdef USE_LUCID
@@ -2036,7 +2031,7 @@ xdialog_show (FRAME_PTR f,
2036 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 2031 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
2037 2032
2038 if (! FRAME_X_P (f)) 2033 if (! FRAME_X_P (f))
2039 abort (); 2034 emacs_abort ();
2040 2035
2041 *error_name = NULL; 2036 *error_name = NULL;
2042 2037
@@ -2301,7 +2296,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
2301 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 2296 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
2302 2297
2303 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f)) 2298 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
2304 abort (); 2299 emacs_abort ();
2305 2300
2306 *error_name = 0; 2301 *error_name = 0;
2307 if (menu_items_n_panes == 0) 2302 if (menu_items_n_panes == 0)
diff --git a/src/xselect.c b/src/xselect.c
index 463bd6e37b0..5a3b7452c6d 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -193,7 +193,7 @@ static void
193x_start_queuing_selection_requests (void) 193x_start_queuing_selection_requests (void)
194{ 194{
195 if (x_queue_selection_requests) 195 if (x_queue_selection_requests)
196 abort (); 196 emacs_abort ();
197 197
198 x_queue_selection_requests++; 198 x_queue_selection_requests++;
199 TRACE1 ("x_start_queuing_selection_requests %d", x_queue_selection_requests); 199 TRACE1 ("x_start_queuing_selection_requests %d", x_queue_selection_requests);
@@ -245,7 +245,7 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym)
245 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; 245 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP;
246 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; 246 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS;
247 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; 247 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL;
248 if (!SYMBOLP (sym)) abort (); 248 if (!SYMBOLP (sym)) emacs_abort ();
249 249
250 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); 250 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
251 BLOCK_INPUT; 251 BLOCK_INPUT;
@@ -1138,7 +1138,7 @@ wait_for_property_change (struct prop_location *location)
1138 ptrdiff_t count = SPECPDL_INDEX (); 1138 ptrdiff_t count = SPECPDL_INDEX ();
1139 1139
1140 if (property_change_reply_object) 1140 if (property_change_reply_object)
1141 abort (); 1141 emacs_abort ();
1142 1142
1143 /* Make sure to do unexpect_property_change if we quit or err. */ 1143 /* Make sure to do unexpect_property_change if we quit or err. */
1144 record_unwind_protect (wait_for_property_change_unwind, 1144 record_unwind_protect (wait_for_property_change_unwind,
diff --git a/src/xterm.c b/src/xterm.c
index 23cc72305ba..4ce87142c1a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21,7 +21,6 @@ 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> 25#include <setjmp.h>
27 26
@@ -29,9 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 28
30#include "lisp.h" 29#include "lisp.h"
31#include "blockinput.h" 30#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" 31#include "syssignal.h"
36 32
37/* This may include sys/types.h, and that somehow loses 33/* This may include sys/types.h, and that somehow loses
@@ -1470,7 +1466,7 @@ x_frame_of_widget (Widget widget)
1470 && f->output_data.x->widget == widget) 1466 && f->output_data.x->widget == widget)
1471 return f; 1467 return f;
1472 1468
1473 abort (); 1469 emacs_abort ();
1474} 1470}
1475 1471
1476/* Allocate a color which is lighter or darker than *PIXEL by FACTOR 1472/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
@@ -2699,7 +2695,7 @@ x_draw_underwave (struct glyph_string *s)
2699 y2 += dy; 2695 y2 += dy;
2700 2696
2701 if (INT_MAX - dx < xmax) 2697 if (INT_MAX - dx < xmax)
2702 abort (); 2698 emacs_abort ();
2703 2699
2704 while (x1 <= xmax) 2700 while (x1 <= xmax)
2705 { 2701 {
@@ -2814,7 +2810,7 @@ x_draw_glyph_string (struct glyph_string *s)
2814 break; 2810 break;
2815 2811
2816 default: 2812 default:
2817 abort (); 2813 emacs_abort ();
2818 } 2814 }
2819 2815
2820 if (!s->for_overlaps) 2816 if (!s->for_overlaps)
@@ -3014,7 +3010,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height,
3014static void 3010static void
3015x_delete_glyphs (struct frame *f, register int n) 3011x_delete_glyphs (struct frame *f, register int n)
3016{ 3012{
3017 abort (); 3013 emacs_abort ();
3018} 3014}
3019 3015
3020 3016
@@ -3287,7 +3283,7 @@ XTset_terminal_window (struct frame *f, int n)
3287static void 3283static void
3288x_ins_del_lines (struct frame *f, int vpos, int n) 3284x_ins_del_lines (struct frame *f, int vpos, int n)
3289{ 3285{
3290 abort (); 3286 emacs_abort ();
3291} 3287}
3292 3288
3293 3289
@@ -4124,7 +4120,7 @@ x_window_to_scroll_bar (Display *display, Window window_id)
4124 frame = XCAR (tail); 4120 frame = XCAR (tail);
4125 /* All elements of Vframe_list should be frames. */ 4121 /* All elements of Vframe_list should be frames. */
4126 if (! FRAMEP (frame)) 4122 if (! FRAMEP (frame))
4127 abort (); 4123 emacs_abort ();
4128 4124
4129 if (! FRAME_X_P (XFRAME (frame))) 4125 if (! FRAME_X_P (XFRAME (frame)))
4130 continue; 4126 continue;
@@ -5443,7 +5439,7 @@ XTredeem_scroll_bar (struct window *window)
5443 5439
5444 /* We can't redeem this window's scroll bar if it doesn't have one. */ 5440 /* We can't redeem this window's scroll bar if it doesn't have one. */
5445 if (NILP (window->vertical_scroll_bar)) 5441 if (NILP (window->vertical_scroll_bar))
5446 abort (); 5442 emacs_abort ();
5447 5443
5448 bar = XSCROLL_BAR (window->vertical_scroll_bar); 5444 bar = XSCROLL_BAR (window->vertical_scroll_bar);
5449 5445
@@ -5462,7 +5458,7 @@ XTredeem_scroll_bar (struct window *window)
5462 else 5458 else
5463 /* If its prev pointer is nil, it must be at the front of 5459 /* If its prev pointer is nil, it must be at the front of
5464 one or the other! */ 5460 one or the other! */
5465 abort (); 5461 emacs_abort ();
5466 } 5462 }
5467 else 5463 else
5468 XSCROLL_BAR (bar->prev)->next = bar->next; 5464 XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -5560,7 +5556,7 @@ static void
5560x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) 5556x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event)
5561{ 5557{
5562 if (! WINDOWP (bar->window)) 5558 if (! WINDOWP (bar->window))
5563 abort (); 5559 emacs_abort ();
5564 5560
5565 emacs_event->kind = SCROLL_BAR_CLICK_EVENT; 5561 emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
5566 emacs_event->code = event->xbutton.button - Button1; 5562 emacs_event->code = event->xbutton.button - Button1;
@@ -6466,7 +6462,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6466 } 6462 }
6467 else if (status_return != XLookupKeySym 6463 else if (status_return != XLookupKeySym
6468 && status_return != XLookupBoth) 6464 && status_return != XLookupBoth)
6469 abort (); 6465 emacs_abort ();
6470 } 6466 }
6471 else 6467 else
6472 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr, 6468 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr,
@@ -7510,7 +7506,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int
7510 break; 7506 break;
7511 7507
7512 default: 7508 default:
7513 abort (); 7509 emacs_abort ();
7514 } 7510 }
7515 } 7511 }
7516 7512
@@ -7780,7 +7776,9 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */
7780#ifdef USG 7776#ifdef USG
7781 /* USG systems forget handlers when they are used; 7777 /* USG systems forget handlers when they are used;
7782 must reestablish each time */ 7778 must reestablish each time */
7783 signal (signalnum, x_connection_signal); 7779 struct sigaction action;
7780 emacs_sigaction_init (&action, x_connection_signal);
7781 sigaction (signalnum, &action, 0);
7784#endif /* USG */ 7782#endif /* USG */
7785} 7783}
7786 7784
@@ -7863,7 +7861,7 @@ When compiled with GTK, Emacs cannot recover from X disconnects.\n\
7863This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 7861This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
7864For details, see etc/PROBLEMS.\n", 7862For details, see etc/PROBLEMS.\n",
7865 error_msg); 7863 error_msg);
7866 abort (); 7864 emacs_abort ();
7867#endif /* USE_GTK */ 7865#endif /* USE_GTK */
7868 7866
7869 /* Indicate that this display is dead. */ 7867 /* Indicate that this display is dead. */
@@ -7873,7 +7871,7 @@ For details, see etc/PROBLEMS.\n",
7873 dpyinfo->terminal->reference_count--; 7871 dpyinfo->terminal->reference_count--;
7874 if (dpyinfo->reference_count != 0) 7872 if (dpyinfo->reference_count != 0)
7875 /* We have just closed all frames on this display. */ 7873 /* We have just closed all frames on this display. */
7876 abort (); 7874 emacs_abort ();
7877 7875
7878 { 7876 {
7879 Lisp_Object tmp; 7877 Lisp_Object tmp;
@@ -7890,10 +7888,15 @@ For details, see etc/PROBLEMS.\n",
7890 } 7888 }
7891 7889
7892 /* Ordinary stack unwind doesn't deal with these. */ 7890 /* Ordinary stack unwind doesn't deal with these. */
7891 {
7892 sigset_t unblocked;
7893 sigemptyset (&unblocked);
7893#ifdef SIGIO 7894#ifdef SIGIO
7894 sigunblock (sigmask (SIGIO)); 7895 sigaddset (&unblocked, SIGIO);
7895#endif 7896#endif
7896 sigunblock (sigmask (SIGALRM)); 7897 sigaddset (&unblocked, SIGALRM);
7898 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
7899 }
7897 TOTALLY_UNBLOCK_INPUT; 7900 TOTALLY_UNBLOCK_INPUT;
7898 7901
7899 unbind_to (idx, Qnil); 7902 unbind_to (idx, Qnil);
@@ -10454,7 +10457,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10454 to.addr = (XPointer)&font; 10457 to.addr = (XPointer)&font;
10455 x_catch_errors (dpy); 10458 x_catch_errors (dpy);
10456 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) 10459 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
10457 abort (); 10460 emacs_abort ();
10458 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) 10461 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
10459 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); 10462 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
10460 x_uncatch_errors (); 10463 x_uncatch_errors ();
@@ -10777,6 +10780,8 @@ x_create_terminal (struct x_display_info *dpyinfo)
10777void 10780void
10778x_initialize (void) 10781x_initialize (void)
10779{ 10782{
10783 struct sigaction action;
10784
10780 baud_rate = 19200; 10785 baud_rate = 19200;
10781 10786
10782 x_noop_count = 0; 10787 x_noop_count = 0;
@@ -10823,7 +10828,8 @@ x_initialize (void)
10823 XSetErrorHandler (x_error_handler); 10828 XSetErrorHandler (x_error_handler);
10824 XSetIOErrorHandler (x_io_error_quitter); 10829 XSetIOErrorHandler (x_io_error_quitter);
10825 10830
10826 signal (SIGPIPE, x_connection_signal); 10831 emacs_sigaction_init (&action, x_connection_signal);
10832 sigaction (SIGPIPE, &action, 0);
10827} 10833}
10828 10834
10829 10835