aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2012-09-30 23:39:46 +0900
committerKenichi Handa2012-09-30 23:39:46 +0900
commitc194970e15b6d6efa07697679a25dfab3aa76442 (patch)
tree49aec8be9d2dcc74ad3c81f562e48308d8e27b75 /src
parent95402d5faa114a311cabfb8c64cf22a93787a066 (diff)
parentdd946752ab8810149a66a3eff469eb128709972d (diff)
downloademacs-c194970e15b6d6efa07697679a25dfab3aa76442.tar.gz
emacs-c194970e15b6d6efa07697679a25dfab3aa76442.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit4
-rw-r--r--src/ChangeLog575
-rw-r--r--src/ChangeLog.112
-rw-r--r--src/ChangeLog.22
-rw-r--r--src/ChangeLog.32
-rw-r--r--src/Makefile.in6
-rw-r--r--src/alloc.c77
-rw-r--r--src/atimer.c86
-rw-r--r--src/blockinput.h118
-rw-r--r--src/buffer.c24
-rw-r--r--src/bytecode.c2
-rw-r--r--src/callproc.c12
-rw-r--r--src/character.c4
-rw-r--r--src/character.h17
-rw-r--r--src/charset.c10
-rw-r--r--src/charset.h1
-rw-r--r--src/chartab.c10
-rw-r--r--src/coding.c63
-rw-r--r--src/data.c37
-rw-r--r--src/dired.c20
-rw-r--r--src/dispextern.h14
-rw-r--r--src/dispnew.c26
-rw-r--r--src/dosfns.c4
-rw-r--r--src/editfns.c48
-rw-r--r--src/emacs.c190
-rw-r--r--src/eval.c107
-rw-r--r--src/fileio.c24
-rw-r--r--src/floatfns.c9
-rw-r--r--src/fns.c12
-rw-r--r--src/fontset.c4
-rw-r--r--src/frame.c4
-rw-r--r--src/frame.h7
-rw-r--r--src/fringe.c2
-rw-r--r--src/ftxfont.c16
-rw-r--r--src/gnutls.c29
-rw-r--r--src/gtkutil.c245
-rw-r--r--src/gtkutil.h38
-rw-r--r--src/image.c553
-rw-r--r--src/indent.c65
-rw-r--r--src/indent.h6
-rw-r--r--src/keyboard.c274
-rw-r--r--src/keyboard.h2
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h47
-rw-r--r--src/lread.c45
-rw-r--r--src/makefile.w32-in115
-rw-r--r--src/menu.c12
-rw-r--r--src/msdos.c8
-rw-r--r--src/nsfns.m44
-rw-r--r--src/nsfont.m12
-rw-r--r--src/nsimage.m2
-rw-r--r--src/nsmenu.m40
-rw-r--r--src/nsterm.h28
-rw-r--r--src/nsterm.m437
-rw-r--r--src/print.c4
-rw-r--r--src/process.c574
-rw-r--r--src/profiler.c518
-rw-r--r--src/ralloc.c4
-rw-r--r--src/search.c2
-rw-r--r--src/sysdep.c415
-rw-r--r--src/syssignal.h14
-rw-r--r--src/syswait.h7
-rw-r--r--src/term.c12
-rw-r--r--src/termhooks.h3
-rw-r--r--src/w16select.c8
-rw-r--r--src/w32.c43
-rw-r--r--src/w32.h8
-rw-r--r--src/w32fns.c110
-rw-r--r--src/w32inevt.c15
-rw-r--r--src/w32menu.c16
-rw-r--r--src/w32proc.c47
-rw-r--r--src/w32reg.c4
-rw-r--r--src/w32select.c17
-rw-r--r--src/w32term.c130
-rw-r--r--src/widget.c4
-rw-r--r--src/window.c54
-rw-r--r--src/xdisp.c77
-rw-r--r--src/xfaces.c64
-rw-r--r--src/xfns.c197
-rw-r--r--src/xfont.c40
-rw-r--r--src/xftfont.c34
-rw-r--r--src/xmenu.c65
-rw-r--r--src/xml.c8
-rw-r--r--src/xselect.c100
-rw-r--r--src/xsettings.c4
-rw-r--r--src/xterm.c342
-rw-r--r--src/xterm.h10
87 files changed, 3799 insertions, 2696 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index 74f44cc1007..7a6bfb07fed 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -1214,8 +1214,8 @@ show environment DISPLAY
1214show environment TERM 1214show environment TERM
1215 1215
1216# When debugging, it is handy to be able to "return" from 1216# When debugging, it is handy to be able to "return" from
1217# fatal_error_backtrace when an assertion failure is non-fatal. 1217# terminate_due_to_signal when an assertion failure is non-fatal.
1218break fatal_error_backtrace 1218break terminate_due_to_signal
1219 1219
1220# x_error_quitter is defined only on X. But window-system is set up 1220# x_error_quitter is defined only on X. But window-system is set up
1221# only at run time, during Emacs startup, so we need to defer setting 1221# only at run time, during Emacs startup, so we need to defer setting
diff --git a/src/ChangeLog b/src/ChangeLog
index 508ac9925a8..f69ab42bd90 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,547 @@
3 * coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention 3 * coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention
4 to the buffer relocation which may be caused by ccl_driver. 4 to the buffer relocation which may be caused by ccl_driver.
5 5
62012-09-30 Jan Djärv <jan.h.d@swipnet.se>
7
8 * nsfns.m (ns_frame_parm_handlers): Add x_set_fullscreen.
9
10 * nsterm.m (NEW_STYLE_FS): New define.
11 (ns_fullscreen_hook, windowWillEnterFullScreen)
12 (windowDidEnterFullScreen, windowWillExitFullScreen)
13 (windowDidExitFullScreen, toggleFullScreen, handleFS)
14 (setFSValue): New functions.
15 (EmacsFSWindow): New implementation.
16 (canBecomeKeyWindow): New function for EmacsFSWindow.
17 (ns_create_terminal): Set fullscreen_hook to ns_fullscreen_hook.
18 (dealloc): Release nonfs_window if in fullscreen.
19 (updateFrameSize:): Call windowDidMove to update top/left.
20 (windowWillResize:toSize:): Check if frame is still maximized.
21 (initFrameFromEmacs:): Initialize fs_state, fs_before_fs,
22 next_maximized, maximized_width, maximized_height and nonfs_window.
23 Call setCollectionBehavior if NEW_STYLE_FS. Initialize bwidth and
24 tbar_height.
25 (windowWillUseStandardFrame:defaultFrame:): Update frame parameter
26 fullscreen. Set maximized_width/height. Act on next_maximized.
27
28 * nsterm.h (MAC_OS_X_VERSION_10_7, MAC_OS_X_VERSION_10_8): New.
29 (EmacsView): Add variables for fullscreen.
30 (handleFS, setFSValue, toggleFullScreen): New in EmacsView.
31 (EmacsFSWindow): New interface for fullscreen.
32
332012-09-30 Juanma Barranquero <lekktu@gmail.com>
34
35 * makefile.w32-in ($(BLD)/profiler.$(O)): Update dependencies.
36
372012-09-30 Chong Yidong <cyd@gnu.org>
38
39 * fns.c (Frandom): Doc fix.
40
412012-09-30 Martin Rudalics <rudalics@gmx.at>
42
43 * window.c (Vwindow_combination_limit): New default value.
44 (Qwindow_size): New symbol replacing Qtemp_buffer_resize.
45
462012-09-30 Paul Eggert <eggert@cs.ucla.edu>
47
48 * syssignal.h (PROFILER_CPU_SUPPORT): Don't define if PROFILING.
49 Suggested by Eli Zaretskii in
50 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00811.html>.
51
522012-09-30 Eli Zaretskii <eliz@gnu.org>
53
54 * profiler.c (Fprofiler_cpu_stop): Use timer_settime only if
55 HAVE_TIMER_SETTIME is defined.
56
572012-09-30 Paul Eggert <eggert@cs.ucla.edu>
58
59 Profiler improvements: more-accurate timers, overflow checks.
60 * profiler.c: Don't include stdio.h, limits.h, sys/time.h,
61 signal.h, setjmp.h. Include systime.h instead.
62 (saturated_add): New function.
63 (record_backtrace, current_sample_interval): Use EMACS_INT, not size_t.
64 (record_backtrace, handle_profiler_signal): Saturate on fixnum overflow.
65 (profiler_timer, profiler_timer_ok) [HAVE_TIMER_SETTIME]:
66 New static vars.
67 (enum profiler_cpu_running): New enum.
68 (profiler_cpu_running): Now of that enum type, not bool.
69 All uses changed to store the new value.
70 (handle_profiler_signal): Rename from sigprof_handler_1,
71 for consistency with other handlers. Do not check whether
72 cpu_log is a hash-table if garbage collecting, since it
73 doesn't matter in that case.
74 (deliver_profiler_signal): Rename from sigprof_handler,
75 for consistency with other handlers.
76 (setup_cpu_timer): New function, with much of what used to be in
77 Fprofiler_cpu_start. Check for out-of-range argument.
78 Prefer timer_settime if available, and prefer
79 thread cputime clocks, then process cputime clocks, then
80 monotonic clocks, to the old realtime clock. Use make_timeval
81 to round more-correctly when falling back to setitimer.
82 (Fprofiler_cpu_start): Use it.
83 (Fprofiler_cpu_stop): Prefer timer_settime if available.
84 Don't assume that passing NULL as the 2nd argument of setitimer
85 is the same as passing a pointer to all-zero storage.
86 Ignore SIGPROF afterwards.
87 (malloc_probe): Saturate at MOST_POSITIVE_FIXNUM.
88 * sysdep.c (emacs_sigaction_init): Also mask out SIGPROF in
89 non-fatal signal handlers. Ignore SIGPROF on startup.
90 * syssignal.h (PROFILER_CPU_SUPPORT): Define this macro here, not
91 in profiler.c, since sysdep.c now uses it.
92
93 * sysdep.c (handle_fatal_signal): Bump backtrace size to 40.
94 Suggested by Eli Zaretskii in
95 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00796.html>.
96
972012-09-29 Juanma Barranquero <lekktu@gmail.com>
98
99 * makefile.w32-in ($(BLD)/profiler.$(O)): Update dependencies.
100
1012012-09-29 Stefan Monnier <monnier@iro.umontreal.ca>
102
103 * lisp.h (struct backtrace): Remove indirection for `function' field.
104 * xdisp.c (redisplay_internal):
105 * profiler.c (record_backtrace, sigprof_handler_1):
106 * alloc.c (Fgarbage_collect):
107 * eval.c (interactive_p, Fsignal, eval_sub, Ffuncall, Fbacktrace)
108 (Fbacktrace_frame): Adjust accordingly.
109
1102012-09-28 Glenn Morris <rgm@gnu.org>
111
112 * eval.c (Frun_hook_with_args, Frun_hook_with_args_until_success)
113 (Frun_hook_with_args_until_failure): Doc fixes.
114
1152012-09-28 Eli Zaretskii <eliz@gnu.org>
116
117 * xdisp.c (syms_of_xdisp) <Qredisplay_internal>: Rename from
118 Qautomatic_redisplay and change the symbol name. All users changed.
119
1202012-09-28 Tomohiro Matsuyama <tomo@cx4a.org>
121
122 * profiler.c (sigprof_handler): Fix race condition.
123
1242012-09-28 Glenn Morris <rgm@gnu.org>
125
126 * lread.c (lisp_file_lexically_bound_p): Handle #! lines. (Bug#12528)
127
1282012-09-27 Paul Eggert <eggert@cs.ucla.edu>
129
130 Check more robustly for timer_settime.
131 * Makefile.in (LIB_TIMER_TIME): New macro.
132 (LIBES): Add it.
133 * atimer.c (alarm_timer, alarm_timer_ok, set_alarm, init_atimer):
134 Use HAVE_TIMER_SETTIME, not SIGEV_SIGNAL, to decide whether to
135 call timer_settime.
136
1372012-09-26 Tomohiro Matsuyama <tomo@cx4a.org>
138
139 * profiler.c (Fprofiler_cpu_start): Remove unnecessary flag SA_SIGINFO.
140
1412012-09-26 Juanma Barranquero <lekktu@gmail.com>
142
143 * makefile.w32-in ($(BLD)/profiler.$(O)): Update dependencies.
144
1452012-09-26 Paul Eggert <eggert@cs.ucla.edu>
146
147 * character.h (MAYBE_UNIFY_CHAR): Remove.
148 * charset.c, charset.h (maybe_unify_char): Now static.
149 * charset.c (decode_char): Use maybe_unify_char, not MAYBE_UNIFY_CHAR.
150 Since this stuff is now private to charset.c, there's no need for
151 a public macro and no need to inline by hand.
152
1532012-09-26 Tomohiro Matsuyama <tomo@cx4a.org>
154 Stefan Monnier <monnier@iro.umontreal.ca>
155 Juanma Barranquero <lekktu@gmail.com>
156
157 * profiler.c: New file.
158 * Makefile.in (base_obj): Add profiler.o.
159 * makefile.w32-in (OBJ2, GLOBAL_SOURCES): Add profiler.c.
160 ($(BLD)/profiler.$(O)): New target.
161 * emacs.c (main): Call syms_of_profiler.
162 * alloc.c (Qautomatic_gc): New constant.
163 (MALLOC_PROBE): New macro.
164 (xmalloc, xzalloc, xrealloc, lisp_malloc, lisp_align_malloc): Use it.
165 (total_bytes_of_live_objects): New function.
166 (Fgarbage_collect): Use it. Record itself in backtrace_list.
167 Call malloc_probe for the memory profiler.
168 (syms_of_alloc): Define Qautomatic_gc.
169 * eval.c (eval_sub, Ffuncall): Reorder assignments to avoid
170 race condition.
171 (struct backtrace): Move definition...
172 * lisp.h (struct backtrace): ..here.
173 (Qautomatic_gc, profiler_memory_running): Declare vars.
174 (malloc_probe, syms_of_profiler): Declare functions.
175 * xdisp.c (Qautomatic_redisplay): New constant.
176 (redisplay_internal): Record itself in backtrace_list.
177 (syms_of_xdisp): Define Qautomatic_redisplay.
178
1792012-09-25 Eli Zaretskii <eliz@gnu.org>
1802012-09-25 Juanma Barranquero <lekktu@gmail.com>
181
182 * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies.
183
1842012-09-25 Paul Eggert <eggert@cs.ucla.edu>
185
186 Prefer POSIX timers if available.
187 They avoid a race if the timer is too close to the current time.
188 * atimer.c (alarm_timer, alarm_timer_ok) [SIGEV_SIGNAL]: New static vars.
189 (set_alarm) [SIGEV_SIGNAL]: Use POSIX timers if available.
190 (init_atimer) [SIGEV_SIGNAL]: Initialize them.
191
1922012-09-25 Eli Zaretskii <eliz@gnu.org>
193
194 * coding.c (CHAR_STRING_ADVANCE_NO_UNIFY): Make it an alias of
195 CHAR_STRING_ADVANCE.
196 (STRING_CHAR_ADVANCE_NO_UNIFY): Make it an alias of
197 STRING_CHAR_ADVANCE.
198
1992012-09-25 Juanma Barranquero <lekktu@gmail.com>
200
201 Move Vlibrary_cache to emacs.c and reset before dumping.
202
203 * lisp.h (reset_image_types): Declare.
204 [WINDOWSNT] (Vlibrary_cache): Declare.
205
206 * image.c (reset_image_types): New function.
207
208 * emacs.c [WINDOWSNT] (Vlibrary_cache): Move from w32.c.
209 (syms_of_emacs) [WINDOWSNT] <Vlibrary_cache>: Initialize and staticpro.
210 (Fdump_emacs): Reset Vlibrary_cache and image_types.
211
212 * w32.c (Vlibrary_cache): Do not define; moved to emacs.c
213 (globals_of_w32) <Vlibrary_cache>: Do not initialize.
214
215 * w32.h (Vlibrary_cache): Do not declare.
216
2172012-09-25 Eli Zaretskii <eliz@gnu.org>
218
219 * w32proc.c (sys_signal): Handle all signals defined by the
220 MS-Windows runtime, not just SIGCHLD. Actually install the signal
221 handlers for signals supported by Windows. Don't override
222 term_ntproc as the handler for SIGABRT.
223 (sigaction): Rewrite to call sys_signal instead of duplicating its
224 code.
225 (sys_kill): Improve commentary.
226
227 * w32.c (term_ntproc): Accept (and ignore) one argument, for
228 consistency with a signature of a signal handler. All callers
229 changed.
230 (init_ntproc): Accept an argument DUMPING. If dumping, don't
231 install term_ntproc as a signal handler for SIGABRT, as that
232 should be done by the dumped Emacs.
233
234 * w32.h (init_ntproc, term_ntproc): Adjust prototypes.
235
236 * w32select.c (term_w32select): Protect against repeated
237 invocation by setting clipboard_owner to NULL after calling
238 DestroyWindow.
239
240 * emacs.c (shut_down_emacs, main): Adapt the calls to init_ntproc
241 and term_ntproc to their modified signatures.
242
243 * character.c (char_string, string_char): Remove calls to
244 MAYBE_UNIFY_CHAR. See the discussion starting at
245 http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00433.html
246 for the details.
247
2482012-09-25 Chong Yidong <cyd@gnu.org>
249
250 * xdisp.c (mode_line_inverse_video): Delete obsolete variable.
251
2522012-09-24 Stefan Monnier <monnier@iro.umontreal.ca>
253
254 * bytecode.c (exec_byte_code): Signal an error instead of aborting,
255 when encountering an unknown bytecode.
256
2572012-09-24 Paul Eggert <eggert@cs.ucla.edu>
258
259 image.c, indent.c: Use bool for booleans.
260 * dispextern.h (struct image_type): Members valid_p, load, init
261 now return bool, not int. All uses changed.
262 * image.c: Omit unnecessary static decls.
263 (x_create_bitmap_mask, x_build_heuristic_mask):
264 Return void, not int, since callers don't care about the return value.
265 (x_create_bitmap_mask, define_image_type, valid_image_p)
266 (struct image_keyword, parse_image_spec, image_spec_value)
267 (check_image_size, image_background)
268 (image_background_transparent, x_clear_image_1)
269 (postprocess_image, lookup_image, x_check_image_size)
270 (x_create_x_image_and_pixmap, xbm_image_p)
271 (Create_Pixmap_From_Bitmap_Data, xbm_read_bitmap_data)
272 (xbm_load_image, xbm_file_p, xbm_load, xpm_lookup_color)
273 (init_xpm_functions, xpm_valid_color_symbols_p, xpm_image_p)
274 (xpm_load, xpm_load_image, lookup_rgb_color, lookup_pixel_color)
275 (x_to_xcolors, x_build_heuristic_mask, pbm_image_p, pbm_load)
276 (png_image_p, init_png_functions, png_load_body, png_load)
277 (jpeg_image_p, init_jpeg_functions, jpeg_load_body, jpeg_load)
278 (tiff_image_p, init_tiff_functions, tiff_load, gif_image_p)
279 (init_gif_functions, gif_load, imagemagick_image_p)
280 (imagemagick_load_image, imagemagick_load, svg_image_p)
281 (init_svg_functions, svg_load, svg_load_image, gs_image_p)
282 (gs_load):
283 * nsimage.m (ns_load_image):
284 * nsterm.m (ns_defined_color):
285 * xfaces.c (tty_lookup_color, tty_defined_color, defined_color):
286 * xfns.c (x_defined_color):
287 * xterm.c (x_alloc_lighter_color_for_widget)
288 (x_alloc_nearest_color_1, x_alloc_nearest_color)
289 (x_alloc_lighter_color):
290 * indent.c (disptab_matches_widthtab, current_column)
291 (scan_for_column, string_display_width, indented_beyond_p)
292 (compute_motion, vmotion, Fvertical_motion):
293 Use bool for booleans.
294
2952012-09-24 Chong Yidong <cyd@gnu.org>
296
297 * chartab.c (Fset_char_table_default): Obsolete function removed.
298
2992012-09-23 Paul Eggert <eggert@cs.ucla.edu>
300
301 Move pid_t related decls out of lisp.h.
302 * lisp.h, syswait.h (record_child_status_change, wait_for_termination)
303 (interruptible_wait_for_termination):
304 Move these decls from lisp.h to syswait.h, since they use pid_t.
305 Needed on FreeBSD; see Herbert J. Skuhra in
306 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00571.html>.
307 * callproc.c: Include syswait.h.
308
309 gnutls.c, gtkutil.c: Use bool for boolean.
310 * gnutls.c (gnutls_global_initialized, init_gnutls_functions)
311 (emacs_gnutls_handle_error):
312 * gtkutil.c (xg_check_special_colors, xg_prepare_tooltip)
313 (xg_hide_tooltip, xg_create_frame_widgets)
314 (create_dialog, xg_uses_old_file_dialog)
315 (xg_get_file_with_chooser, xg_get_file_with_selection)
316 (xg_get_file_name, xg_have_tear_offs, create_menus, xg_create_widget)
317 (xg_item_label_same_p, xg_update_menubar)
318 (xg_modify_menubar_widgets, xg_event_is_for_menubar)
319 (xg_ignore_gtk_scrollbar, xg_set_toolkit_scroll_bar_thumb)
320 (xg_event_is_for_scrollbar, xg_pack_tool_bar, xg_make_tool_item)
321 (is_box_type, xg_tool_item_stale_p, xg_update_tool_bar_sizes)
322 (update_frame_tool_bar, free_frame_tool_bar):
323 * gtkutil.c, w32term.c, xterm.c (x_wm_set_size_hint):
324 * nsmenu.m (ns_update_menubar):
325 * nsmenu.m, w32menu.c, xmenu.c (set_frame_menubar):
326 * xfns.c (Fx_show_tip) [USE_GTK]:
327 Use bool for boolean.
328 * gtkutil.c (xg_update_frame_menubar):
329 * xmenu.c (update_frame_menubar):
330 Return void, not int, since caller ignores return value.
331 * gtkutil.c (xg_change_toolbar_position):
332 Return void, not 1.
333
3342012-09-23 Juanma Barranquero <lekktu@gmail.com>
335
336 * makefile.w32-in (BLOCKINPUT_H): Remove.
337 (SYSSIGNAL_H): New macro.
338 ($(BLD)/alloc.$(O), $(BLD)/atimer.$(O), $(BLD)/buffer.$(O))
339 ($(BLD)/callproc.$(O), $(BLD)/data.$(O), $(BLD)/dired.$(O))
340 ($(BLD)/dispnew.$(O), $(BLD)/editfns.$(O), $(BLD)/emacs.$(O))
341 ($(BLD)/eval.$(O), $(BLD)/fileio.$(O), $(BLD)/floatfns.$(O))
342 ($(BLD)/fns.$(O), $(BLD)/fontset.$(O), $(BLD)/frame.$(O))
343 ($(BLD)/fringe.$(O), $(BLD)/image.$(O), $(BLD)/insdel.$(O))
344 ($(BLD)/keyboard.$(O), $(BLD)/keymap.$(O), $(BLD)/lread.$(O))
345 ($(BLD)/menu.$(O), $(BLD)/w32inevt.$(O), $(BLD)/w32proc.$(O))
346 ($(BLD)/print.$(O), $(BLD)/process.$(O), $(BLD)/ralloc.$(O))
347 ($(BLD)/search.$(O), $(BLD)/sound.$(O), $(BLD)/sysdep.$(O))
348 ($(BLD)/term.$(O), $(BLD)/window.$(O), $(BLD)/xdisp.$(O))
349 ($(BLD)/xfaces.$(O), $(BLD)/w32fns.$(O), $(BLD)/w32menu.$(O))
350 ($(BLD)/w32term.$(O), $(BLD)/w32select.$(O), $(BLD)/w32reg.$(O))
351 ($(BLD)/w32xfns.$(O)): Update dependencies.
352
3532012-09-23 Eli Zaretskii <eliz@gnu.org>
354
355 * .gdbinit: Set breakpoint on terminate_due_to_signal, not on
356 fatal_error_backtrace.
357
358 * w32proc.c (sys_kill): Undo last change: don't do anything when
359 invoked to deliver SIGABRT to our own process. This is now
360 handled by emacs_raise.
361
3622012-09-23 Juanma Barranquero <lekktu@gmail.com>
363
364 * w32term.c (w32_read_socket): Remove leftover reference to
365 interrupt_input_pending.
366
3672012-09-23 Paul Eggert <eggert@cs.ucla.edu>
368
369 Do not use SA_NODEFER.
370 Problem reported by Dani Moncayo in
371 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00557.html>.
372 * alloc.c (die):
373 * sysdep.c (emacs_abort): Do not reset signal handler.
374 * emacs.c (terminate_due_to_signal): Reset signal handler here.
375 * sysdep.c (init_signals): Do not use SA_NODEFER. It wasn't
376 wanted even on POSIXish hosts, and it doesn't work on Windows.
377
3782012-09-23 Jan Djärv <jan.h.d@swipnet.se>
379
380 * xterm.c (x_term_init): Call fixup_locale before and after calling
381 gtk_init (Bug#12392).
382
3832012-09-23 Chong Yidong <cyd@gnu.org>
384
385 * w32.c (w32_delayed_load): Remove LIBRARIES argument; always use
386 Vdynamic_library_alist.
387
388 * gnutls.c (init_gnutls_functions): Caller changed; remove arg.
389 (Fgnutls_available_p): Caller changed.
390
391 * xml.c (init_libxml2_functions, Flibxml_parse_html_region)
392 (Flibxml_parse_xml_region): Likewise.
393
394 * dispextern.h (struct image_type): Remove arg from init function.
395
396 * image.c (Finit_image_library, lookup_image_type)
397 (define_image_type): Remove now-unneeded second arg.
398 (init_xpm_functions, init_png_functions, init_jpeg_functions)
399 (init_tiff_functions, init_gif_functions, init_svg_functions):
400 Arglist and w32_delayed_load calling convention changed.
401 (gs_type): Remove init_gs_functions; there is no such function.
402 (valid_image_p, make_image): Fix caller to lookup_image_type.
403
4042012-09-23 Paul Eggert <eggert@cs.ucla.edu>
405
406 Simplify and avoid signal-handling races (Bug#12471).
407 * alloc.c (die):
408 * sysdep.c (emacs_abort) [HAVE_NTGUI]:
409 Avoid recursive loop if there's a fatal error in the function itself.
410 * atimer.c (pending_atimers):
411 * blockinput.h: Don't include "atimer.h"; no longer needed.
412 (interrupt_input_pending): Remove. All uses removed.
413 pending_signals now counts both atimers and ordinary interrupts.
414 This is less racy than having three separate pending-signal flags.
415 (block_input, unblock_input, totally_unblock_input, unblock_input_to)
416 (input_blocked_p):
417 Rename from their upper-case counterparts BLOCK_INPUT,
418 UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_TO,
419 INPUT_BLOCKED_P, and turn into functions. All uses changed.
420 This makes it easier to access volatile variables more accurately.
421 (BLOCK_INPUT_RESIGNAL): Remove. All uses replaced by unblock_input ().
422 (input_blocked_p): Prefer this to 'interrupt_input_blocked', as
423 that's more reliable if the code is buggy and sets
424 interrupt_input_blocked to a negative value. All uses changed.
425 * atimer.c (deliver_alarm_signal):
426 Remove. No need to deliver this to the parent; any thread can
427 handle this signal now. All uses replaced by underlying handler.
428 * atimer.c (turn_on_atimers):
429 * dispnew.c (handle_window_change_signal):
430 * emacs.c (handle_danger_signal):
431 * keyboard.c (kbd_buffer_get_event):
432 Don't reestablish signal handler; not needed with sigaction.
433 * blockinput.h (UNBLOCK_INPUT_TO, TOTALLY_UNBLOCK_INPUT)
434 (UNBLOCK_INPUT_TO):
435 Rework to avoid unnecessary accesses to volatile variables.
436 (UNBLOCK_INPUT_TO): Now a function.
437 (totally_unblock_input, unblock_input): New decls.
438 * data.c (handle_arith_signal, deliver_arith_signal): Move to sysdep.c
439 (init_data): Remove. Necessary stuff now done in init_signal.
440 * emacs.c, xdisp.c: Include "atimer.h", since we invoke atimer functions.
441 * emacs.c (handle_fatal_signal, deliver_fatal_signal): Move to sysdep.c.
442 (fatal_error_code): Remove; no longer needed.
443 (terminate_due_to_signal): Rename from fatal_error_backtrace, since
444 it doesn't always backtrace. All uses changed. No need to reset
445 signal to default, since sigaction and/or die does that for us now.
446 Use emacs_raise (FOO), not kill (getpid (), FOO).
447 (main): Check more-accurately whether we're dumping.
448 Move fatal-error setup to sysdep.c
449 * floatfns.c: Do not include "syssignal.h"; no longer needed.
450 * gtkutil.c (xg_get_file_name, xg_get_font):
451 Remove no-longer-needed signal-mask manipulation.
452 * keyboard.c, process.c (POLL_FOR_INPUT):
453 Don't depend on USE_ASYNC_EVENTS, a symbol that is never defined.
454 * keyboard.c (read_avail_input): Remove.
455 All uses replaced by gobble_input.
456 (Ftop_level): Use TOTALLY_UNBLOCK_INPUT rather than open code.
457 (kbd_buffer_store_event_hold, gobble_input):
458 (record_asynch_buffer_change) [USABLE_SIGIO]:
459 (store_user_signal_events):
460 No need to mess with signal mask.
461 (gobble_input): If blocking input and there are terminals, simply
462 set pending_signals to 1 and return. All hooks changed to not
463 worry about whether input is blocked.
464 (process_pending_signals): Clear pending_signals before processing
465 them, in case a signal comes in while we're processing.
466 By convention callers now test pending_signals before calling us.
467 (UNBLOCK_INPUT_TO, unblock_input, totally_unblock_input):
468 New functions, to support changes to blockinput.h.
469 (handle_input_available_signal): Now extern.
470 (reinvoke_input_signal): Remove. All uses replaced by
471 handle_async_input.
472 (quit_count): Now volatile, since a signal handler uses it.
473 (handle_interrupt): Now takes bool IN_SIGNAL_HANDLER as arg.
474 All callers changed. Block SIGINT only if not already blocked.
475 Clear sigmask reliably, even if Fsignal returns, which it can.
476 Omit unnecessary accesses to volatile var.
477 (quit_throw_to_read_char): No need to restore sigmask.
478 * keyboard.c (gobble_input, handle_user_signal):
479 * process.c (wait_reading_process_output):
480 Call signal-handling code rather than killing ourselves.
481 * lisp.h: Include <float.h>, for...
482 (IEEE_FLOATING_POINT): New macro, moved here to avoid duplication.
483 (pending_signals): Now volatile.
484 (syms_of_data): Now const if IEEE floating point.
485 (handle_input_available_signal) [USABLE_SIGIO]:
486 (terminate_due_to_signal, record_child_status_change): New decls.
487 * process.c (create_process): Avoid disaster if memory is exhausted
488 while we're processing a vfork, by tightening the critical section
489 around the vfork.
490 (send_process_frame, process_sent_to, handle_pipe_signal)
491 (deliver_pipe_signal): Remove. No longer needed, as Emacs now
492 ignores SIGPIPE.
493 (send_process): No need for setjmp/longjmp any more, since the
494 SIGPIPE stuff is now gone. Instead, report an error if errno
495 is EPIPE.
496 (record_child_status_change): Now extern. PID and W are now args.
497 Return void, not bool. All callers changed.
498 * sysdep.c (wait_debugging) [(BSD_SYSTEM || HPUX) && !defined (__GNU__)]:
499 Remove. All uses removed. This bug should be fixed now in a
500 different way.
501 (wait_for_termination_1): Use waitpid rather than sigsuspend,
502 and record the child status change directly. This avoids the
503 need to futz with the signal mask.
504 (process_fatal_action): Move here from emacs.c.
505 (emacs_sigaction_flags): New function, containing
506 much of what used to be in emacs_sigaction_init.
507 (emacs_sigaction_init): Use it. Block nonfatal system signals that are
508 caught by emacs, to make races less likely.
509 (deliver_process_signal): Rename from handle_on_main_thread.
510 All uses changed.
511 (BACKTRACE_LIMIT_MAX): Now at top level.
512 (thread_backtrace_buffer, threadback_backtrace_pointers):
513 New static vars.
514 (deliver_thread_signal, deliver_fatal_thread_signal):
515 New functions, for more-accurate delivery of thread-specific signals.
516 (handle_fatal_signal, deliver_fatal_signal): Move here from emacs.c.
517 (deliver_arith_signal): Handle in this thread, not
518 in the main thread, since it's triggered by this thread.
519 (maybe_fatal_sig): New function.
520 (init_signals): New arg DUMPING so that we can be more accurate
521 about whether we're dumping. Caller changed.
522 Treat thread-specific signals differently from process-general signals.
523 Block all signals while handling fatal error; that's safer.
524 xsignal from SIGFPE only on non-IEEE hosts, treating it as fatal
525 on IEEE hosts.
526 When batch, ignore SIGHUP, SIGINT, SIGTERM if they were already ignored.
527 Ignore SIGPIPE unless batch.
528 (emacs_backtrace): Output backtrace for the appropriate thread,
529 which is not necessarily the main thread.
530 * syssignal.h: Include <stdbool.h>.
531 (emacs_raise): New macro.
532 * xterm.c (x_connection_signal): Remove; no longer needed
533 now that we use sigaction.
534 (x_connection_closed): No need to mess with sigmask now.
535 (x_initialize): No need to reset SIGPIPE handler here, since
536 init_signals does this for us now.
537
5382012-09-23 Jan Djärv <jan.h.d@swipnet.se>
539
540 * nsterm.m (ns_dumpglyphs_image): dr is a new rect to draw image into,
541 background rect may be larger (Bug#12245).
542
5432012-09-23 Chong Yidong <cyd@gnu.org>
544
545 * keyboard.c (timer_check): Avoid quitting during Fcopy_sequence.
546
62012-09-22 Paul Eggert <eggert@cs.ucla.edu> 5472012-09-22 Paul Eggert <eggert@cs.ucla.edu>
7 548
8 * .gdbinit: Just stop at fatal_error_backtrace. 549 * .gdbinit: Just stop at fatal_error_backtrace.
@@ -30,8 +571,8 @@
30 if it is defined. Arguments and return value changed. 571 if it is defined. Arguments and return value changed.
31 (valid_image_p, make_image): Callers changed. 572 (valid_image_p, make_image): Callers changed.
32 (xbm_type, xpm_type, pbm_type, png_type, jpeg_type, tiff_type) 573 (xbm_type, xpm_type, pbm_type, png_type, jpeg_type, tiff_type)
33 (gif_type, imagemagick_type, svg_type, gs_type): Add 574 (gif_type, imagemagick_type, svg_type, gs_type):
34 initialization functions. 575 Add initialization functions.
35 (Finit_image_library): Call lookup_image_type. 576 (Finit_image_library): Call lookup_image_type.
36 (CHECK_LIB_AVAILABLE): Macro deleted. 577 (CHECK_LIB_AVAILABLE): Macro deleted.
37 (lookup_image_type): Call define_image_type here, rather than via 578 (lookup_image_type): Call define_image_type here, rather than via
@@ -53,8 +594,8 @@
53 * window.c (Fsplit_window_internal): Handle only Qt value of 594 * window.c (Fsplit_window_internal): Handle only Qt value of
54 Vwindow_combination_limit separately. 595 Vwindow_combination_limit separately.
55 (Qtemp_buffer_resize): New symbol. 596 (Qtemp_buffer_resize): New symbol.
56 (Vwindow_combination_limit): New default value. Rewrite 597 (Vwindow_combination_limit): New default value.
57 doc-string. 598 Rewrite doc-string.
58 599
592012-09-22 Eli Zaretskii <eliz@gnu.org> 6002012-09-22 Eli Zaretskii <eliz@gnu.org>
60 601
@@ -153,7 +694,7 @@
153 (Fx_create_frame): Call x_set_offset to correctly interpret 694 (Fx_create_frame): Call x_set_offset to correctly interpret
154 top_pos in geometry. 695 top_pos in geometry.
155 696
156 * frame.c (read_integer, XParseGeometry): Moved from w32xfns.c. 697 * frame.c (read_integer, XParseGeometry): Move from w32xfns.c.
157 (Fx_parse_geometry): If there is a space in string, call 698 (Fx_parse_geometry): If there is a space in string, call
158 Qns_parse_geometry, otherwise do as on other terms (Bug#12368). 699 Qns_parse_geometry, otherwise do as on other terms (Bug#12368).
159 700
@@ -254,8 +795,8 @@
254 795
2552012-09-16 Martin Rudalics <rudalics@gmx.at> 7962012-09-16 Martin Rudalics <rudalics@gmx.at>
256 797
257 * window.c (Fwindow_parameter, Fset_window_parameter): Accept 798 * window.c (Fwindow_parameter, Fset_window_parameter):
258 any window as argument (Bug#12452). 799 Accept any window as argument (Bug#12452).
259 800
2602012-09-16 Jan Djärv <jan.h.d@swipnet.se> 8012012-09-16 Jan Djärv <jan.h.d@swipnet.se>
261 802
@@ -330,8 +871,8 @@
3302012-09-14 Dmitry Antipov <dmantipov@yandex.ru> 8712012-09-14 Dmitry Antipov <dmantipov@yandex.ru>
331 872
332 Avoid out-of-range marker position (Bug#12426). 873 Avoid out-of-range marker position (Bug#12426).
333 * insdel.c (replace_range, replace_range_2): Adjust 874 * insdel.c (replace_range, replace_range_2):
334 markers before overlays, as suggested by comments. 875 Adjust markers before overlays, as suggested by comments.
335 (insert_1_both, insert_from_buffer_1, adjust_after_replace): 876 (insert_1_both, insert_from_buffer_1, adjust_after_replace):
336 Remove redundant check before calling offset_intervals. 877 Remove redundant check before calling offset_intervals.
337 878
@@ -630,8 +1171,8 @@
630 in the internal border. 1171 in the internal border.
631 (x_set_window_size): Remove static variables and their usage. 1172 (x_set_window_size): Remove static variables and their usage.
632 (ns_redraw_scroll_bars): Fix NSTRACE arg. 1173 (ns_redraw_scroll_bars): Fix NSTRACE arg.
633 (ns_after_update_window_line, ns_draw_fringe_bitmap): Remove 1174 (ns_after_update_window_line, ns_draw_fringe_bitmap):
634 fringe/internal border adjustment (Bug#11052). 1175 Remove fringe/internal border adjustment (Bug#11052).
635 (ns_draw_fringe_bitmap): Make code more like other terms (xterm.c). 1176 (ns_draw_fringe_bitmap): Make code more like other terms (xterm.c).
636 (ns_draw_window_cursor): Remove fringe/internal border adjustment. 1177 (ns_draw_window_cursor): Remove fringe/internal border adjustment.
637 (ns_fix_rect_ibw): Remove. 1178 (ns_fix_rect_ibw): Remove.
@@ -848,8 +1389,8 @@
848 (init_signals) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Initialize it; 1389 (init_signals) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Initialize it;
849 code moved here from emacs.c's main function. 1390 code moved here from emacs.c's main function.
850 * sysdep.c, syssignal.h (handle_on_main_thread): New function, 1391 * sysdep.c, syssignal.h (handle_on_main_thread): New function,
851 replacing the old SIGNAL_THREAD_CHECK. All uses changed. This 1392 replacing the old SIGNAL_THREAD_CHECK. All uses changed.
852 lets callers save and restore errno properly. 1393 This lets callers save and restore errno properly.
853 1394
8542012-09-05 Dmitry Antipov <dmantipov@yandex.ru> 13952012-09-05 Dmitry Antipov <dmantipov@yandex.ru>
855 1396
@@ -1158,8 +1699,8 @@
1158 * process.c: Include TERM_HEADER instead of listing all possible 1699 * process.c: Include TERM_HEADER instead of listing all possible
1159 window-system headers. 1700 window-system headers.
1160 1701
1161 * nsterm.h: Remove declarations now in frame.h. Define 1702 * nsterm.h: Remove declarations now in frame.h.
1162 FRAME_X_SCREEN, FRAME_X_VISUAL. 1703 Define FRAME_X_SCREEN, FRAME_X_VISUAL.
1163 1704
1164 * menu.c: Include TERM_HEADER instead of listing all possible 1705 * menu.c: Include TERM_HEADER instead of listing all possible
1165 window-system headers. 1706 window-system headers.
@@ -1355,8 +1896,8 @@
1355 1896
1356 * nsterm.h (NSPanel): New class variable dialog_return. 1897 * nsterm.h (NSPanel): New class variable dialog_return.
1357 1898
1358 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize 1899 * nsmenu.m (initWithContentRect:styleMask:backing:defer:):
1359 dialog_return. 1900 Initialize dialog_return.
1360 (windowShouldClose:): Use stop instead of stopModalWithCode. 1901 (windowShouldClose:): Use stop instead of stopModalWithCode.
1361 (clicked:): Ditto, and also set dialog_return (Bug#12258). 1902 (clicked:): Ditto, and also set dialog_return (Bug#12258).
1362 (timeout_handler:): Use stop instead of abortModal. Send a dummy 1903 (timeout_handler:): Use stop instead of abortModal. Send a dummy
diff --git a/src/ChangeLog.11 b/src/ChangeLog.11
index d3b0a8284b5..1f444b9292c 100644
--- a/src/ChangeLog.11
+++ b/src/ChangeLog.11
@@ -5532,7 +5532,7 @@
5532 (update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar 5532 (update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
5533 height, call xg_update_tool_bar_sizes instead. 5533 height, call xg_update_tool_bar_sizes instead.
5534 (free_frame_tool_bar): Remove from hbox or vbox depending on 5534 (free_frame_tool_bar): Remove from hbox or vbox depending on
5535 toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero. 5535 toolbar_in_hbox. Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
5536 (xg_change_toolbar_position): New function. 5536 (xg_change_toolbar_position): New function.
5537 5537
5538 * frame.h (struct frame): Add tool_bar_position. 5538 * frame.h (struct frame): Add tool_bar_position.
diff --git a/src/ChangeLog.2 b/src/ChangeLog.2
index 1a9728f6896..0806106836e 100644
--- a/src/ChangeLog.2
+++ b/src/ChangeLog.2
@@ -2680,7 +2680,7 @@
2680 2680
26811986-12-11 Richard Mlynarik (mly@prep) 26811986-12-11 Richard Mlynarik (mly@prep)
2682 2682
2683 * emacs.c, dispnew.c: 2683 * emacs.c, dispnew.c:
2684 Rename inhibit_x_windows inhibit_window_system. 2684 Rename inhibit_x_windows inhibit_window_system.
2685 Understand "-nw" command-line option. 2685 Understand "-nw" command-line option.
2686 Reorganize init_display a little to make other window-system 2686 Reorganize init_display a little to make other window-system
diff --git a/src/ChangeLog.3 b/src/ChangeLog.3
index 6c580fe4b52..4f6e02ff8d3 100644
--- a/src/ChangeLog.3
+++ b/src/ChangeLog.3
@@ -11154,7 +11154,7 @@
11154 (classify_object): Removed code to look up a function key in the 11154 (classify_object): Removed code to look up a function key in the
11155 global and local function key keymaps, since this will be done 11155 global and local function key keymaps, since this will be done
11156 more generally. 11156 more generally.
11157 (Fexecute_mouse_event): Elided this function with a #if 0; I 11157 (Fexecute_mouse_event): Elided this function with a #if 0; I
11158 think it will go away once the more general keymap stuff is 11158 think it will go away once the more general keymap stuff is
11159 implemented, but I'm not sure. 11159 implemented, but I'm not sure.
11160 (syms_of_keyboard): Removed defsubr for Sexecute_mouse_event. 11160 (syms_of_keyboard): Removed defsubr for Sexecute_mouse_event.
diff --git a/src/Makefile.in b/src/Makefile.in
index 37da170edbd..f8da0091711 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -153,6 +153,7 @@ M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@
153M17N_FLT_LIBS = @M17N_FLT_LIBS@ 153M17N_FLT_LIBS = @M17N_FLT_LIBS@
154 154
155LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@ 155LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
156LIB_TIMER_TIME=@LIB_TIMER_TIME@
156 157
157DBUS_CFLAGS = @DBUS_CFLAGS@ 158DBUS_CFLAGS = @DBUS_CFLAGS@
158DBUS_LIBS = @DBUS_LIBS@ 159DBUS_LIBS = @DBUS_LIBS@
@@ -339,6 +340,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
339 process.o gnutls.o callproc.o \ 340 process.o gnutls.o callproc.o \
340 region-cache.o sound.o atimer.o \ 341 region-cache.o sound.o atimer.o \
341 doprnt.o intervals.o textprop.o composite.o xml.o \ 342 doprnt.o intervals.o textprop.o composite.o xml.o \
343 profiler.o \
342 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ 344 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
343 $(WINDOW_SYSTEM_OBJ) 345 $(WINDOW_SYSTEM_OBJ)
344obj = $(base_obj) $(NS_OBJC_OBJ) 346obj = $(base_obj) $(NS_OBJC_OBJ)
@@ -384,8 +386,8 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
384## duplicated symbols. If the standard libraries were compiled 386## duplicated symbols. If the standard libraries were compiled
385## with GCC, we might need LIB_GCC again after them. 387## with GCC, we might need LIB_GCC again after them.
386LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ 388LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
387 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \ 389 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(LIB_TIMER_TIME) \
388 $(LIB_EXECINFO) \ 390 $(DBUS_LIBS) $(LIB_EXECINFO) \
389 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 391 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
390 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 392 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
391 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 393 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
diff --git a/src/alloc.c b/src/alloc.c
index 02ba2f5f9e3..df166b4924a 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -205,6 +205,7 @@ static Lisp_Object Qintervals;
205static Lisp_Object Qbuffers; 205static Lisp_Object Qbuffers;
206static Lisp_Object Qstring_bytes, Qvector_slots, Qheap; 206static Lisp_Object Qstring_bytes, Qvector_slots, Qheap;
207static Lisp_Object Qgc_cons_threshold; 207static Lisp_Object Qgc_cons_threshold;
208Lisp_Object Qautomatic_gc;
208Lisp_Object Qchar_table_extra_slots; 209Lisp_Object Qchar_table_extra_slots;
209 210
210/* Hook run after GC has finished. */ 211/* Hook run after GC has finished. */
@@ -633,13 +634,13 @@ static void
633malloc_block_input (void) 634malloc_block_input (void)
634{ 635{
635 if (block_input_in_memory_allocators) 636 if (block_input_in_memory_allocators)
636 BLOCK_INPUT; 637 block_input ();
637} 638}
638static void 639static void
639malloc_unblock_input (void) 640malloc_unblock_input (void)
640{ 641{
641 if (block_input_in_memory_allocators) 642 if (block_input_in_memory_allocators)
642 UNBLOCK_INPUT; 643 unblock_input ();
643} 644}
644# define MALLOC_BLOCK_INPUT malloc_block_input () 645# define MALLOC_BLOCK_INPUT malloc_block_input ()
645# define MALLOC_UNBLOCK_INPUT malloc_unblock_input () 646# define MALLOC_UNBLOCK_INPUT malloc_unblock_input ()
@@ -648,6 +649,13 @@ malloc_unblock_input (void)
648# define MALLOC_UNBLOCK_INPUT ((void) 0) 649# define MALLOC_UNBLOCK_INPUT ((void) 0)
649#endif 650#endif
650 651
652#define MALLOC_PROBE(size) \
653 do { \
654 if (profiler_memory_running) \
655 malloc_probe (size); \
656 } while (0)
657
658
651/* Like malloc but check for no memory and block interrupt input.. */ 659/* Like malloc but check for no memory and block interrupt input.. */
652 660
653void * 661void *
@@ -661,6 +669,7 @@ xmalloc (size_t size)
661 669
662 if (!val && size) 670 if (!val && size)
663 memory_full (size); 671 memory_full (size);
672 MALLOC_PROBE (size);
664 return val; 673 return val;
665} 674}
666 675
@@ -678,6 +687,7 @@ xzalloc (size_t size)
678 if (!val && size) 687 if (!val && size)
679 memory_full (size); 688 memory_full (size);
680 memset (val, 0, size); 689 memset (val, 0, size);
690 MALLOC_PROBE (size);
681 return val; 691 return val;
682} 692}
683 693
@@ -699,6 +709,7 @@ xrealloc (void *block, size_t size)
699 709
700 if (!val && size) 710 if (!val && size)
701 memory_full (size); 711 memory_full (size);
712 MALLOC_PROBE (size);
702 return val; 713 return val;
703} 714}
704 715
@@ -888,6 +899,7 @@ lisp_malloc (size_t nbytes, enum mem_type type)
888 MALLOC_UNBLOCK_INPUT; 899 MALLOC_UNBLOCK_INPUT;
889 if (!val && nbytes) 900 if (!val && nbytes)
890 memory_full (nbytes); 901 memory_full (nbytes);
902 MALLOC_PROBE (nbytes);
891 return val; 903 return val;
892} 904}
893 905
@@ -1093,6 +1105,8 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
1093 1105
1094 MALLOC_UNBLOCK_INPUT; 1106 MALLOC_UNBLOCK_INPUT;
1095 1107
1108 MALLOC_PROBE (nbytes);
1109
1096 eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN); 1110 eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
1097 return val; 1111 return val;
1098} 1112}
@@ -5043,6 +5057,23 @@ bounded_number (EMACS_INT number)
5043 return make_number (min (MOST_POSITIVE_FIXNUM, number)); 5057 return make_number (min (MOST_POSITIVE_FIXNUM, number));
5044} 5058}
5045 5059
5060/* Calculate total bytes of live objects. */
5061
5062static size_t
5063total_bytes_of_live_objects (void)
5064{
5065 size_t tot = 0;
5066 tot += total_conses * sizeof (struct Lisp_Cons);
5067 tot += total_symbols * sizeof (struct Lisp_Symbol);
5068 tot += total_markers * sizeof (union Lisp_Misc);
5069 tot += total_string_bytes;
5070 tot += total_vector_slots * word_size;
5071 tot += total_floats * sizeof (struct Lisp_Float);
5072 tot += total_intervals * sizeof (struct interval);
5073 tot += total_strings * sizeof (struct Lisp_String);
5074 return tot;
5075}
5076
5046DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", 5077DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
5047 doc: /* Reclaim storage for Lisp objects no longer needed. 5078 doc: /* Reclaim storage for Lisp objects no longer needed.
5048Garbage collection happens automatically if you cons more than 5079Garbage collection happens automatically if you cons more than
@@ -5068,6 +5099,8 @@ See Info node `(elisp)Garbage Collection'. */)
5068 ptrdiff_t count = SPECPDL_INDEX (); 5099 ptrdiff_t count = SPECPDL_INDEX ();
5069 EMACS_TIME start; 5100 EMACS_TIME start;
5070 Lisp_Object retval = Qnil; 5101 Lisp_Object retval = Qnil;
5102 size_t tot_before = 0;
5103 struct backtrace backtrace;
5071 5104
5072 if (abort_on_gc) 5105 if (abort_on_gc)
5073 emacs_abort (); 5106 emacs_abort ();
@@ -5077,6 +5110,14 @@ See Info node `(elisp)Garbage Collection'. */)
5077 if (pure_bytes_used_before_overflow) 5110 if (pure_bytes_used_before_overflow)
5078 return Qnil; 5111 return Qnil;
5079 5112
5113 /* Record this function, so it appears on the profiler's backtraces. */
5114 backtrace.next = backtrace_list;
5115 backtrace.function = Qautomatic_gc;
5116 backtrace.args = &Qnil;
5117 backtrace.nargs = 0;
5118 backtrace.debug_on_exit = 0;
5119 backtrace_list = &backtrace;
5120
5080 check_cons_list (); 5121 check_cons_list ();
5081 5122
5082 /* Don't keep undo information around forever. 5123 /* Don't keep undo information around forever.
@@ -5084,6 +5125,9 @@ See Info node `(elisp)Garbage Collection'. */)
5084 FOR_EACH_BUFFER (nextb) 5125 FOR_EACH_BUFFER (nextb)
5085 compact_buffer (nextb); 5126 compact_buffer (nextb);
5086 5127
5128 if (profiler_memory_running)
5129 tot_before = total_bytes_of_live_objects ();
5130
5087 start = current_emacs_time (); 5131 start = current_emacs_time ();
5088 5132
5089 /* In case user calls debug_print during GC, 5133 /* In case user calls debug_print during GC,
@@ -5125,7 +5169,7 @@ See Info node `(elisp)Garbage Collection'. */)
5125 if (garbage_collection_messages) 5169 if (garbage_collection_messages)
5126 message1_nolog ("Garbage collecting..."); 5170 message1_nolog ("Garbage collecting...");
5127 5171
5128 BLOCK_INPUT; 5172 block_input ();
5129 5173
5130 shrink_regexp_cache (); 5174 shrink_regexp_cache ();
5131 5175
@@ -5242,7 +5286,7 @@ See Info node `(elisp)Garbage Collection'. */)
5242 dump_zombies (); 5286 dump_zombies ();
5243#endif 5287#endif
5244 5288
5245 UNBLOCK_INPUT; 5289 unblock_input ();
5246 5290
5247 check_cons_list (); 5291 check_cons_list ();
5248 5292
@@ -5255,16 +5299,7 @@ See Info node `(elisp)Garbage Collection'. */)
5255 gc_relative_threshold = 0; 5299 gc_relative_threshold = 0;
5256 if (FLOATP (Vgc_cons_percentage)) 5300 if (FLOATP (Vgc_cons_percentage))
5257 { /* Set gc_cons_combined_threshold. */ 5301 { /* Set gc_cons_combined_threshold. */
5258 double tot = 0; 5302 double tot = total_bytes_of_live_objects ();
5259
5260 tot += total_conses * sizeof (struct Lisp_Cons);
5261 tot += total_symbols * sizeof (struct Lisp_Symbol);
5262 tot += total_markers * sizeof (union Lisp_Misc);
5263 tot += total_string_bytes;
5264 tot += total_vector_slots * word_size;
5265 tot += total_floats * sizeof (struct Lisp_Float);
5266 tot += total_intervals * sizeof (struct interval);
5267 tot += total_strings * sizeof (struct Lisp_String);
5268 5303
5269 tot *= XFLOAT_DATA (Vgc_cons_percentage); 5304 tot *= XFLOAT_DATA (Vgc_cons_percentage);
5270 if (0 < tot) 5305 if (0 < tot)
@@ -5367,6 +5402,17 @@ See Info node `(elisp)Garbage Collection'. */)
5367 5402
5368 gcs_done++; 5403 gcs_done++;
5369 5404
5405 /* Collect profiling data. */
5406 if (profiler_memory_running)
5407 {
5408 size_t swept = 0;
5409 size_t tot_after = total_bytes_of_live_objects ();
5410 if (tot_before > tot_after)
5411 swept = tot_before - tot_after;
5412 malloc_probe (swept);
5413 }
5414
5415 backtrace_list = backtrace.next;
5370 return retval; 5416 return retval;
5371} 5417}
5372 5418
@@ -6395,7 +6441,7 @@ die (const char *msg, const char *file, int line)
6395{ 6441{
6396 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", 6442 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6397 file, line, msg); 6443 file, line, msg);
6398 fatal_error_backtrace (SIGABRT, INT_MAX); 6444 terminate_due_to_signal (SIGABRT, INT_MAX);
6399} 6445}
6400#endif 6446#endif
6401 6447
@@ -6527,6 +6573,7 @@ do hash-consing of the objects allocated to pure space. */);
6527 DEFSYM (Qstring_bytes, "string-bytes"); 6573 DEFSYM (Qstring_bytes, "string-bytes");
6528 DEFSYM (Qvector_slots, "vector-slots"); 6574 DEFSYM (Qvector_slots, "vector-slots");
6529 DEFSYM (Qheap, "heap"); 6575 DEFSYM (Qheap, "heap");
6576 DEFSYM (Qautomatic_gc, "Automatic GC");
6530 6577
6531 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); 6578 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold");
6532 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); 6579 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots");
diff --git a/src/atimer.c b/src/atimer.c
index 5dbd807872a..048c62798ef 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -40,13 +40,12 @@ static struct atimer *stopped_atimers;
40 40
41static struct atimer *atimers; 41static struct atimer *atimers;
42 42
43/* Non-zero means alarm signal handler has found ripe timers but 43/* The alarm timer and whether it was properly initialized, if
44 interrupt_input_blocked was non-zero. In this case, timer 44 POSIX timers are available. */
45 functions are not called until the next UNBLOCK_INPUT because timer 45#ifdef HAVE_TIMER_SETTIME
46 functions are expected to call X, and X cannot be assumed to be 46static timer_t alarm_timer;
47 reentrant. */ 47static bool alarm_timer_ok;
48 48#endif
49int pending_atimers;
50 49
51/* Block/unblock SIGALRM. */ 50/* Block/unblock SIGALRM. */
52 51
@@ -295,14 +294,25 @@ set_alarm (void)
295#ifdef HAVE_SETITIMER 294#ifdef HAVE_SETITIMER
296 struct itimerval it; 295 struct itimerval it;
297#endif 296#endif
297 EMACS_TIME now, interval;
298 298
299 /* Determine s/us till the next timer is ripe. */ 299#ifdef HAVE_TIMER_SETTIME
300 EMACS_TIME now = current_emacs_time (); 300 if (alarm_timer_ok)
301 {
302 struct itimerspec ispec;
303 ispec.it_value = atimers->expiration;
304 ispec.it_interval.tv_sec = ispec.it_interval.tv_nsec = 0;
305 if (timer_settime (alarm_timer, 0, &ispec, 0) == 0)
306 return;
307 }
308#endif
301 309
302 /* Don't set the interval to 0; this disables the timer. */ 310 /* Determine interval till the next timer is ripe.
303 EMACS_TIME interval = (EMACS_TIME_LE (atimers->expiration, now) 311 Don't set the interval to 0; this disables the timer. */
304 ? make_emacs_time (0, 1000 * 1000) 312 now = current_emacs_time ();
305 : sub_emacs_time (atimers->expiration, now)); 313 interval = (EMACS_TIME_LE (atimers->expiration, now)
314 ? make_emacs_time (0, 1000 * 1000)
315 : sub_emacs_time (atimers->expiration, now));
306 316
307#ifdef HAVE_SETITIMER 317#ifdef HAVE_SETITIMER
308 318
@@ -341,16 +351,11 @@ schedule_atimer (struct atimer *t)
341static void 351static void
342run_timers (void) 352run_timers (void)
343{ 353{
344 EMACS_TIME now; 354 EMACS_TIME now = current_emacs_time ();
345 355
346 while (atimers 356 while (atimers && EMACS_TIME_LE (atimers->expiration, now))
347 && (pending_atimers = interrupt_input_blocked) == 0
348 && (now = current_emacs_time (),
349 EMACS_TIME_LE (atimers->expiration, now)))
350 { 357 {
351 struct atimer *t; 358 struct atimer *t = atimers;
352
353 t = atimers;
354 atimers = atimers->next; 359 atimers = atimers->next;
355 t->fn (t); 360 t->fn (t);
356 361
@@ -366,16 +371,7 @@ run_timers (void)
366 } 371 }
367 } 372 }
368 373
369 if (! atimers) 374 set_alarm ();
370 pending_atimers = 0;
371
372 if (pending_atimers)
373 pending_signals = 1;
374 else
375 {
376 pending_signals = interrupt_input_pending;
377 set_alarm ();
378 }
379} 375}
380 376
381 377
@@ -385,23 +381,16 @@ run_timers (void)
385static void 381static void
386handle_alarm_signal (int sig) 382handle_alarm_signal (int sig)
387{ 383{
388 pending_atimers = 1;
389 pending_signals = 1; 384 pending_signals = 1;
390} 385}
391 386
392static void
393deliver_alarm_signal (int sig)
394{
395 handle_on_main_thread (sig, handle_alarm_signal);
396}
397
398 387
399/* Call alarm signal handler for pending timers. */ 388/* Do pending timers. */
400 389
401void 390void
402do_pending_atimers (void) 391do_pending_atimers (void)
403{ 392{
404 if (pending_atimers) 393 if (atimers)
405 { 394 {
406 block_atimers (); 395 block_atimers ();
407 run_timers (); 396 run_timers ();
@@ -417,12 +406,7 @@ void
417turn_on_atimers (bool on) 406turn_on_atimers (bool on)
418{ 407{
419 if (on) 408 if (on)
420 { 409 set_alarm ();
421 struct sigaction action;
422 emacs_sigaction_init (&action, deliver_alarm_signal);
423 sigaction (SIGALRM, &action, 0);
424 set_alarm ();
425 }
426 else 410 else
427 alarm (0); 411 alarm (0);
428} 412}
@@ -432,9 +416,15 @@ void
432init_atimer (void) 416init_atimer (void)
433{ 417{
434 struct sigaction action; 418 struct sigaction action;
419#ifdef HAVE_TIMER_SETTIME
420 struct sigevent sigev;
421 sigev.sigev_notify = SIGEV_SIGNAL;
422 sigev.sigev_signo = SIGALRM;
423 sigev.sigev_value.sival_ptr = &alarm_timer;
424 alarm_timer_ok = timer_create (CLOCK_REALTIME, &sigev, &alarm_timer) == 0;
425#endif
435 free_atimers = stopped_atimers = atimers = NULL; 426 free_atimers = stopped_atimers = atimers = NULL;
436 pending_atimers = 0;
437 /* pending_signals is initialized in init_keyboard.*/ 427 /* pending_signals is initialized in init_keyboard.*/
438 emacs_sigaction_init (&action, deliver_alarm_signal); 428 emacs_sigaction_init (&action, handle_alarm_signal);
439 sigaction (SIGALRM, &action, 0); 429 sigaction (SIGALRM, &action, 0);
440} 430}
diff --git a/src/blockinput.h b/src/blockinput.h
index 7501bfc91a0..70822e29be7 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -19,103 +19,57 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#ifndef EMACS_BLOCKINPUT_H 19#ifndef EMACS_BLOCKINPUT_H
20#define EMACS_BLOCKINPUT_H 20#define EMACS_BLOCKINPUT_H
21 21
22#include "atimer.h" 22INLINE_HEADER_BEGIN
23#ifndef BLOCKINPUT_INLINE
24# define BLOCKINPUT_INLINE INLINE
25#endif
23 26
24/* When Emacs is using signal-driven input, the processing of those 27/* Emacs should avoid doing anything hairy in a signal handler, because
25 input signals can get pretty hairy. For example, when Emacs is 28 so many system functions are non-reentrant. For example, malloc
26 running under X windows, handling an input signal can entail 29 and the Xlib functions aren't usually re-entrant, so if they were
27 retrieving events from the X event queue, or making other X calls. 30 used by the SIGIO handler, we'd lose.
28
29 If an input signal occurs while Emacs is in the midst of some
30 non-reentrant code, and the signal processing invokes that same
31 code, we lose. For example, malloc and the Xlib functions aren't
32 usually re-entrant, and both are used by the X input signal handler
33 - if we try to process an input signal in the midst of executing
34 any of these functions, we'll lose.
35 31
36 To avoid this, we make the following requirements: 32 To avoid this, we make the following requirements:
37 33
38 * Everyone must evaluate BLOCK_INPUT before entering these functions, 34 * Everyone must evaluate BLOCK_INPUT before performing actions that
39 and then call UNBLOCK_INPUT after performing them. Calls 35 might conflict with a signal handler, and then call UNBLOCK_INPUT
40 BLOCK_INPUT and UNBLOCK_INPUT may be nested. 36 after performing them. Calls BLOCK_INPUT and UNBLOCK_INPUT may be
37 nested.
41 38
42 * Any complicated interrupt handling code should test 39 * Any complicated interrupt handling code should test
43 interrupt_input_blocked, and put off its work until later. 40 INPUT_BLOCKED_P, and put off its work until later.
44 41
45 * If the interrupt handling code wishes, it may set 42 * If the interrupt handling code wishes, it may set
46 interrupt_input_pending to a non-zero value. If that flag is set 43 pending_signals to a non-zero value. If that flag is set
47 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */ 44 when input becomes unblocked, UNBLOCK_INPUT will then read
48 45 input and process timers.
49extern volatile int interrupt_input_blocked;
50
51/* Nonzero means an input interrupt has arrived
52 during the current critical section. */
53extern int interrupt_input_pending;
54 46
47 Historically, Emacs signal handlers did much more than they do now,
48 and this caused many BLOCK_INPUT calls to be sprinkled around the code.
49 FIXME: Remove calls that aren't needed now. */
55 50
56/* Non-zero means asynchronous timers should be run when input is 51extern volatile int interrupt_input_blocked;
57 unblocked. */
58 52
59extern int pending_atimers; 53/* Begin critical section. */
60 54
55BLOCKINPUT_INLINE void
56block_input (void)
57{
58 interrupt_input_blocked++;
59}
61 60
62/* Begin critical section. */ 61extern void unblock_input (void);
63#define BLOCK_INPUT (interrupt_input_blocked++) 62extern void totally_unblock_input (void);
64 63extern void unblock_input_to (int);
65/* End critical section.
66
67 If doing signal-driven input, and a signal came in when input was
68 blocked, reinvoke the signal handler now to deal with it.
69
70 Always test interrupt_input_pending; that's not too expensive, and
71 it'll never get set if we don't need to resignal. This is simpler
72 than dealing here with every configuration option that might affect
73 whether interrupt_input_pending can be nonzero. */
74
75#define UNBLOCK_INPUT \
76 do \
77 { \
78 --interrupt_input_blocked; \
79 if (interrupt_input_blocked == 0) \
80 { \
81 if (interrupt_input_pending) \
82 reinvoke_input_signal (); \
83 if (pending_atimers) \
84 do_pending_atimers (); \
85 } \
86 else if (interrupt_input_blocked < 0) \
87 emacs_abort (); \
88 } \
89 while (0)
90
91/* Undo any number of BLOCK_INPUT calls,
92 and also reinvoke any pending signal. */
93
94#define TOTALLY_UNBLOCK_INPUT \
95 do if (interrupt_input_blocked != 0) \
96 { \
97 interrupt_input_blocked = 1; \
98 UNBLOCK_INPUT; \
99 } \
100 while (0)
101
102/* Undo any number of BLOCK_INPUT calls down to level LEVEL,
103 and also (if the level is now 0) reinvoke any pending signal. */
104
105#define UNBLOCK_INPUT_TO(LEVEL) \
106 do \
107 { \
108 interrupt_input_blocked = (LEVEL) + 1; \
109 UNBLOCK_INPUT; \
110 } \
111 while (0)
112
113#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
114 64
115/* In critical section ? */ 65/* In critical section ? */
116#define INPUT_BLOCKED_P (interrupt_input_blocked > 0)
117 66
118/* Defined in keyboard.c */ 67BLOCKINPUT_INLINE bool
119extern void reinvoke_input_signal (void); 68input_blocked_p (void)
69{
70 return 0 < interrupt_input_blocked;
71}
72
73INLINE_HEADER_END
120 74
121#endif /* EMACS_BLOCKINPUT_H */ 75#endif /* EMACS_BLOCKINPUT_H */
diff --git a/src/buffer.c b/src/buffer.c
index 22624e33a4b..356a308fce6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -550,11 +550,11 @@ even if it is dead. The return value is never nil. */)
550 b->indirections = 0; 550 b->indirections = 0;
551 551
552 BUF_GAP_SIZE (b) = 20; 552 BUF_GAP_SIZE (b) = 20;
553 BLOCK_INPUT; 553 block_input ();
554 /* We allocate extra 1-byte at the tail and keep it always '\0' for 554 /* We allocate extra 1-byte at the tail and keep it always '\0' for
555 anchoring a search. */ 555 anchoring a search. */
556 alloc_buffer_text (b, BUF_GAP_SIZE (b) + 1); 556 alloc_buffer_text (b, BUF_GAP_SIZE (b) + 1);
557 UNBLOCK_INPUT; 557 unblock_input ();
558 if (! BUF_BEG_ADDR (b)) 558 if (! BUF_BEG_ADDR (b))
559 buffer_memory_full (BUF_GAP_SIZE (b) + 1); 559 buffer_memory_full (BUF_GAP_SIZE (b) + 1);
560 560
@@ -1923,7 +1923,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1923 1923
1924 bset_name (b, Qnil); 1924 bset_name (b, Qnil);
1925 1925
1926 BLOCK_INPUT; 1926 block_input ();
1927 if (b->base_buffer) 1927 if (b->base_buffer)
1928 { 1928 {
1929 /* Notify our base buffer that we don't share the text anymore. */ 1929 /* Notify our base buffer that we don't share the text anymore. */
@@ -1946,7 +1946,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1946 b->width_run_cache = 0; 1946 b->width_run_cache = 0;
1947 } 1947 }
1948 bset_width_table (b, Qnil); 1948 bset_width_table (b, Qnil);
1949 UNBLOCK_INPUT; 1949 unblock_input ();
1950 bset_undo_list (b, Qnil); 1950 bset_undo_list (b, Qnil);
1951 1951
1952 /* Run buffer-list-update-hook. */ 1952 /* Run buffer-list-update-hook. */
@@ -5032,7 +5032,7 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes)
5032{ 5032{
5033 void *p; 5033 void *p;
5034 5034
5035 BLOCK_INPUT; 5035 block_input ();
5036#if defined USE_MMAP_FOR_BUFFERS 5036#if defined USE_MMAP_FOR_BUFFERS
5037 p = mmap_alloc ((void **) &b->text->beg, nbytes); 5037 p = mmap_alloc ((void **) &b->text->beg, nbytes);
5038#elif defined REL_ALLOC 5038#elif defined REL_ALLOC
@@ -5043,12 +5043,12 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes)
5043 5043
5044 if (p == NULL) 5044 if (p == NULL)
5045 { 5045 {
5046 UNBLOCK_INPUT; 5046 unblock_input ();
5047 memory_full (nbytes); 5047 memory_full (nbytes);
5048 } 5048 }
5049 5049
5050 b->text->beg = (unsigned char *) p; 5050 b->text->beg = (unsigned char *) p;
5051 UNBLOCK_INPUT; 5051 unblock_input ();
5052} 5052}
5053 5053
5054/* Enlarge buffer B's text buffer by DELTA bytes. DELTA < 0 means 5054/* Enlarge buffer B's text buffer by DELTA bytes. DELTA < 0 means
@@ -5060,7 +5060,7 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
5060 void *p; 5060 void *p;
5061 ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 5061 ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1
5062 + delta); 5062 + delta);
5063 BLOCK_INPUT; 5063 block_input ();
5064#if defined USE_MMAP_FOR_BUFFERS 5064#if defined USE_MMAP_FOR_BUFFERS
5065 p = mmap_realloc ((void **) &b->text->beg, nbytes); 5065 p = mmap_realloc ((void **) &b->text->beg, nbytes);
5066#elif defined REL_ALLOC 5066#elif defined REL_ALLOC
@@ -5071,12 +5071,12 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
5071 5071
5072 if (p == NULL) 5072 if (p == NULL)
5073 { 5073 {
5074 UNBLOCK_INPUT; 5074 unblock_input ();
5075 memory_full (nbytes); 5075 memory_full (nbytes);
5076 } 5076 }
5077 5077
5078 BUF_BEG_ADDR (b) = (unsigned char *) p; 5078 BUF_BEG_ADDR (b) = (unsigned char *) p;
5079 UNBLOCK_INPUT; 5079 unblock_input ();
5080} 5080}
5081 5081
5082 5082
@@ -5085,7 +5085,7 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
5085static void 5085static void
5086free_buffer_text (struct buffer *b) 5086free_buffer_text (struct buffer *b)
5087{ 5087{
5088 BLOCK_INPUT; 5088 block_input ();
5089 5089
5090#if defined USE_MMAP_FOR_BUFFERS 5090#if defined USE_MMAP_FOR_BUFFERS
5091 mmap_free ((void **) &b->text->beg); 5091 mmap_free ((void **) &b->text->beg);
@@ -5096,7 +5096,7 @@ free_buffer_text (struct buffer *b)
5096#endif 5096#endif
5097 5097
5098 BUF_BEG_ADDR (b) = NULL; 5098 BUF_BEG_ADDR (b) = NULL;
5099 UNBLOCK_INPUT; 5099 unblock_input ();
5100} 5100}
5101 5101
5102 5102
diff --git a/src/bytecode.c b/src/bytecode.c
index 5f4fdcc5eff..648813aed86 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1876,7 +1876,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1876 /* Actually this is Bstack_ref with offset 0, but we use Bdup 1876 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1877 for that instead. */ 1877 for that instead. */
1878 /* CASE (Bstack_ref): */ 1878 /* CASE (Bstack_ref): */
1879 emacs_abort (); 1879 error ("Invalid byte opcode");
1880 1880
1881 /* Handy byte-codes for lexical binding. */ 1881 /* Handy byte-codes for lexical binding. */
1882 CASE (Bstack_ref1): 1882 CASE (Bstack_ref1):
diff --git a/src/callproc.c b/src/callproc.c
index 2604d295f3e..b33882e54c2 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -51,6 +51,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51#include "process.h" 51#include "process.h"
52#include "syssignal.h" 52#include "syssignal.h"
53#include "systty.h" 53#include "systty.h"
54#include "syswait.h"
54#include "blockinput.h" 55#include "blockinput.h"
55#include "frame.h" 56#include "frame.h"
56#include "termhooks.h" 57#include "termhooks.h"
@@ -582,7 +583,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
582 0, current_dir); 583 0, current_dir);
583#else /* not WINDOWSNT */ 584#else /* not WINDOWSNT */
584 585
585 BLOCK_INPUT; 586 block_input ();
586 587
587 /* vfork, and prevent local vars from being clobbered by the vfork. */ 588 /* vfork, and prevent local vars from being clobbered by the vfork. */
588 { 589 {
@@ -626,15 +627,14 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
626 setpgrp (pid, pid); 627 setpgrp (pid, pid);
627#endif /* USG */ 628#endif /* USG */
628 629
629 /* GConf causes us to ignore SIGPIPE, make sure it is restored 630 /* Emacs ignores SIGPIPE, but the child should not. */
630 in the child. */
631 signal (SIGPIPE, SIG_DFL); 631 signal (SIGPIPE, SIG_DFL);
632 632
633 child_setup (filefd, fd1, fd_error, (char **) new_argv, 633 child_setup (filefd, fd1, fd_error, (char **) new_argv,
634 0, current_dir); 634 0, current_dir);
635 } 635 }
636 636
637 UNBLOCK_INPUT; 637 unblock_input ();
638 638
639#endif /* not WINDOWSNT */ 639#endif /* not WINDOWSNT */
640 640
@@ -976,9 +976,9 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
976 { 976 {
977 int fd; 977 int fd;
978 978
979 BLOCK_INPUT; 979 block_input ();
980 fd = mkstemp (tempfile); 980 fd = mkstemp (tempfile);
981 UNBLOCK_INPUT; 981 unblock_input ();
982 if (fd == -1) 982 if (fd == -1)
983 report_file_error ("Failed to open temporary file", 983 report_file_error ("Failed to open temporary file",
984 Fcons (build_string (tempfile), Qnil)); 984 Fcons (build_string (tempfile), Qnil));
diff --git a/src/character.c b/src/character.c
index def1ad090fd..5808d48a235 100644
--- a/src/character.c
+++ b/src/character.c
@@ -126,8 +126,6 @@ char_string (unsigned int c, unsigned char *p)
126 c &= ~CHAR_MODIFIER_MASK; 126 c &= ~CHAR_MODIFIER_MASK;
127 } 127 }
128 128
129 MAYBE_UNIFY_CHAR (c);
130
131 if (c <= MAX_3_BYTE_CHAR) 129 if (c <= MAX_3_BYTE_CHAR)
132 { 130 {
133 bytes = CHAR_STRING (c, p); 131 bytes = CHAR_STRING (c, p);
@@ -195,8 +193,6 @@ string_char (const unsigned char *p, const unsigned char **advanced, int *len)
195 p += 5; 193 p += 5;
196 } 194 }
197 195
198 MAYBE_UNIFY_CHAR (c);
199
200 if (len) 196 if (len)
201 *len = p - saved_p; 197 *len = p - saved_p;
202 if (advanced) 198 if (advanced)
diff --git a/src/character.h b/src/character.h
index 70d4e67a978..b2cdcb76699 100644
--- a/src/character.h
+++ b/src/character.h
@@ -554,23 +554,6 @@ INLINE_HEADER_BEGIN
554 } while (0) 554 } while (0)
555 555
556 556
557/* If C is a character to be unified with a Unicode character, return
558 the unified Unicode character. */
559
560#define MAYBE_UNIFY_CHAR(c) \
561 do { \
562 if (c > MAX_UNICODE_CHAR && c <= MAX_5_BYTE_CHAR) \
563 { \
564 Lisp_Object val; \
565 val = CHAR_TABLE_REF (Vchar_unify_table, c); \
566 if (INTEGERP (val)) \
567 c = XFASTINT (val); \
568 else if (! NILP (val)) \
569 c = maybe_unify_char (c, val); \
570 } \
571 } while (0)
572
573
574/* Return a non-outlandish value for the tab width. */ 557/* Return a non-outlandish value for the tab width. */
575 558
576#define SANE_TAB_WIDTH(buf) \ 559#define SANE_TAB_WIDTH(buf) \
diff --git a/src/charset.c b/src/charset.c
index d8c38e5ea3b..b0915ffde9c 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1617,7 +1617,7 @@ only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
1617/* Return a unified character code for C (>= 0x110000). VAL is a 1617/* Return a unified character code for C (>= 0x110000). VAL is a
1618 value of Vchar_unify_table for C; i.e. it is nil, an integer, or a 1618 value of Vchar_unify_table for C; i.e. it is nil, an integer, or a
1619 charset symbol. */ 1619 charset symbol. */
1620int 1620static int
1621maybe_unify_char (int c, Lisp_Object val) 1621maybe_unify_char (int c, Lisp_Object val)
1622{ 1622{
1623 struct charset *charset; 1623 struct charset *charset;
@@ -1723,8 +1723,12 @@ decode_char (struct charset *charset, unsigned int code)
1723 { 1723 {
1724 c = char_index + CHARSET_CODE_OFFSET (charset); 1724 c = char_index + CHARSET_CODE_OFFSET (charset);
1725 if (CHARSET_UNIFIED_P (charset) 1725 if (CHARSET_UNIFIED_P (charset)
1726 && c > MAX_UNICODE_CHAR) 1726 && MAX_UNICODE_CHAR < c && c <= MAX_5_BYTE_CHAR)
1727 MAYBE_UNIFY_CHAR (c); 1727 {
1728 /* Unify C with a Unicode character if possible. */
1729 Lisp_Object val = CHAR_TABLE_REF (Vchar_unify_table, c);
1730 c = maybe_unify_char (c, val);
1731 }
1728 } 1732 }
1729 } 1733 }
1730 1734
diff --git a/src/charset.h b/src/charset.h
index 50d230489fe..b5fa36290c8 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -538,7 +538,6 @@ extern int charset_unibyte;
538extern struct charset *char_charset (int, Lisp_Object, unsigned *); 538extern struct charset *char_charset (int, Lisp_Object, unsigned *);
539extern Lisp_Object charset_attributes (int); 539extern Lisp_Object charset_attributes (int);
540 540
541extern int maybe_unify_char (int, Lisp_Object);
542extern int decode_char (struct charset *, unsigned); 541extern int decode_char (struct charset *, unsigned);
543extern unsigned encode_char (struct charset *, int); 542extern unsigned encode_char (struct charset *, int);
544extern int string_xstring_p (Lisp_Object); 543extern int string_xstring_p (Lisp_Object);
diff --git a/src/chartab.c b/src/chartab.c
index e864514e336..7430235b4af 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -655,15 +655,6 @@ or a character code. Return VALUE. */)
655 return value; 655 return value;
656} 656}
657 657
658DEFUN ("set-char-table-default", Fset_char_table_default,
659 Sset_char_table_default, 3, 3, 0,
660 doc: /*
661This function is obsolete and has no effect. */)
662 (Lisp_Object char_table, Lisp_Object ch, Lisp_Object value)
663{
664 return Qnil;
665}
666
667/* Look up the element in TABLE at index CH, and return it as an 658/* Look up the element in TABLE at index CH, and return it as an
668 integer. If the element is not a character, return CH itself. */ 659 integer. If the element is not a character, return CH itself. */
669 660
@@ -1415,7 +1406,6 @@ syms_of_chartab (void)
1415 defsubr (&Sset_char_table_extra_slot); 1406 defsubr (&Sset_char_table_extra_slot);
1416 defsubr (&Schar_table_range); 1407 defsubr (&Schar_table_range);
1417 defsubr (&Sset_char_table_range); 1408 defsubr (&Sset_char_table_range);
1418 defsubr (&Sset_char_table_default);
1419 defsubr (&Soptimize_char_table); 1409 defsubr (&Soptimize_char_table);
1420 defsubr (&Smap_char_table); 1410 defsubr (&Smap_char_table);
1421 defsubr (&Sunicode_property_table_internal); 1411 defsubr (&Sunicode_property_table_internal);
diff --git a/src/coding.c b/src/coding.c
index 40e67b9a6c8..32d300b9923 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -920,65 +920,18 @@ record_conversion_result (struct coding_system *coding,
920 920
921 921
922/* Store multibyte form of the character C in P, and advance P to the 922/* Store multibyte form of the character C in P, and advance P to the
923 end of the multibyte form. This is like CHAR_STRING_ADVANCE but it 923 end of the multibyte form. This used to be like CHAR_STRING_ADVANCE
924 never calls MAYBE_UNIFY_CHAR. */ 924 without ever calling MAYBE_UNIFY_CHAR, but nowadays we don't call
925 925 MAYBE_UNIFY_CHAR in CHAR_STRING_ADVANCE. */
926#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \
927 do { \
928 if ((c) <= MAX_1_BYTE_CHAR) \
929 *(p)++ = (c); \
930 else if ((c) <= MAX_2_BYTE_CHAR) \
931 *(p)++ = (0xC0 | ((c) >> 6)), \
932 *(p)++ = (0x80 | ((c) & 0x3F)); \
933 else if ((c) <= MAX_3_BYTE_CHAR) \
934 *(p)++ = (0xE0 | ((c) >> 12)), \
935 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \
936 *(p)++ = (0x80 | ((c) & 0x3F)); \
937 else if ((c) <= MAX_4_BYTE_CHAR) \
938 *(p)++ = (0xF0 | (c >> 18)), \
939 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \
940 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \
941 *(p)++ = (0x80 | (c & 0x3F)); \
942 else if ((c) <= MAX_5_BYTE_CHAR) \
943 *(p)++ = 0xF8, \
944 *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \
945 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \
946 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \
947 *(p)++ = (0x80 | (c & 0x3F)); \
948 else \
949 (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \
950 } while (0)
951 926
927#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) CHAR_STRING_ADVANCE(c, p)
952 928
953/* Return the character code of character whose multibyte form is at 929/* Return the character code of character whose multibyte form is at
954 P, and advance P to the end of the multibyte form. This is like 930 P, and advance P to the end of the multibyte form. This used to be
955 STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ 931 like STRING_CHAR_ADVANCE without ever calling MAYBE_UNIFY_CHAR, but
956 932 nowadays STRING_CHAR_ADVANCE doesn't call MAYBE_UNIFY_CHAR. */
957#define STRING_CHAR_ADVANCE_NO_UNIFY(p) \
958 (!((p)[0] & 0x80) \
959 ? *(p)++ \
960 : ! ((p)[0] & 0x20) \
961 ? ((p) += 2, \
962 ((((p)[-2] & 0x1F) << 6) \
963 | ((p)[-1] & 0x3F) \
964 | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \
965 : ! ((p)[0] & 0x10) \
966 ? ((p) += 3, \
967 ((((p)[-3] & 0x0F) << 12) \
968 | (((p)[-2] & 0x3F) << 6) \
969 | ((p)[-1] & 0x3F))) \
970 : ! ((p)[0] & 0x08) \
971 ? ((p) += 4, \
972 ((((p)[-4] & 0xF) << 18) \
973 | (((p)[-3] & 0x3F) << 12) \
974 | (((p)[-2] & 0x3F) << 6) \
975 | ((p)[-1] & 0x3F))) \
976 : ((p) += 5, \
977 ((((p)[-4] & 0x3F) << 18) \
978 | (((p)[-3] & 0x3F) << 12) \
979 | (((p)[-2] & 0x3F) << 6) \
980 | ((p)[-1] & 0x3F))))
981 933
934#define STRING_CHAR_ADVANCE_NO_UNIFY(p) STRING_CHAR_ADVANCE(p)
982 935
983/* Set coding->source from coding->src_object. */ 936/* Set coding->source from coding->src_object. */
984 937
diff --git a/src/data.c b/src/data.c
index 72d7c8ccf9a..abcdd4dca0d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -34,14 +34,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34#include "font.h" 34#include "font.h"
35#include "keymap.h" 35#include "keymap.h"
36 36
37#include <float.h>
38#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
39 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
40#define IEEE_FLOATING_POINT 1
41#else
42#define IEEE_FLOATING_POINT 0
43#endif
44
45Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; 37Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
46static Lisp_Object Qsubr; 38static Lisp_Object Qsubr;
47Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; 39Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
@@ -3179,32 +3171,3 @@ syms_of_data (void)
3179 Vmost_negative_fixnum = make_number (MOST_NEGATIVE_FIXNUM); 3171 Vmost_negative_fixnum = make_number (MOST_NEGATIVE_FIXNUM);
3180 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; 3172 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1;
3181} 3173}
3182
3183static _Noreturn void
3184handle_arith_signal (int sig)
3185{
3186 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3187 xsignal0 (Qarith_error);
3188}
3189
3190static void
3191deliver_arith_signal (int sig)
3192{
3193 handle_on_main_thread (sig, handle_arith_signal);
3194}
3195
3196void
3197init_data (void)
3198{
3199 struct sigaction action;
3200 /* Don't do this if just dumping out.
3201 We don't want to call `signal' in this case
3202 so that we don't have trouble with dumping
3203 signal-delivering routines in an inconsistent state. */
3204#ifndef CANNOT_DUMP
3205 if (!initialized)
3206 return;
3207#endif /* CANNOT_DUMP */
3208 emacs_sigaction_init (&action, deliver_arith_signal);
3209 sigaction (SIGFPE, &action, 0);
3210}
diff --git a/src/dired.c b/src/dired.c
index 3aa27ecf920..4986f845101 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -101,9 +101,9 @@ static Lisp_Object
101directory_files_internal_unwind (Lisp_Object dh) 101directory_files_internal_unwind (Lisp_Object dh)
102{ 102{
103 DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; 103 DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer;
104 BLOCK_INPUT; 104 block_input ();
105 closedir (d); 105 closedir (d);
106 UNBLOCK_INPUT; 106 unblock_input ();
107 return Qnil; 107 return Qnil;
108} 108}
109 109
@@ -164,9 +164,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
164 /* Now *bufp is the compiled form of MATCH; don't call anything 164 /* Now *bufp is the compiled form of MATCH; don't call anything
165 which might compile a new regexp until we're done with the loop! */ 165 which might compile a new regexp until we're done with the loop! */
166 166
167 BLOCK_INPUT; 167 block_input ();
168 d = opendir (SSDATA (dirfilename)); 168 d = opendir (SSDATA (dirfilename));
169 UNBLOCK_INPUT; 169 unblock_input ();
170 if (d == NULL) 170 if (d == NULL)
171 report_file_error ("Opening directory", Fcons (directory, Qnil)); 171 report_file_error ("Opening directory", Fcons (directory, Qnil));
172 172
@@ -310,9 +310,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
310 } 310 }
311 } 311 }
312 312
313 BLOCK_INPUT; 313 block_input ();
314 closedir (d); 314 closedir (d);
315 UNBLOCK_INPUT; 315 unblock_input ();
316#ifdef WINDOWSNT 316#ifdef WINDOWSNT
317 if (attrs) 317 if (attrs)
318 Vw32_get_true_file_attributes = w32_save; 318 Vw32_get_true_file_attributes = w32_save;
@@ -486,9 +486,9 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
486 486
487 encoded_dir = ENCODE_FILE (dirname); 487 encoded_dir = ENCODE_FILE (dirname);
488 488
489 BLOCK_INPUT; 489 block_input ();
490 d = opendir (SSDATA (Fdirectory_file_name (encoded_dir))); 490 d = opendir (SSDATA (Fdirectory_file_name (encoded_dir)));
491 UNBLOCK_INPUT; 491 unblock_input ();
492 if (!d) 492 if (!d)
493 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 493 report_file_error ("Opening directory", Fcons (dirname, Qnil));
494 494
@@ -962,10 +962,10 @@ so last access time will always be midnight of that day. */)
962 962
963 if (!(NILP (id_format) || EQ (id_format, Qinteger))) 963 if (!(NILP (id_format) || EQ (id_format, Qinteger)))
964 { 964 {
965 BLOCK_INPUT; 965 block_input ();
966 uname = stat_uname (&s); 966 uname = stat_uname (&s);
967 gname = stat_gname (&s); 967 gname = stat_gname (&s);
968 UNBLOCK_INPUT; 968 unblock_input ();
969 } 969 }
970 if (uname) 970 if (uname)
971 values[2] = DECODE_SYSTEM (build_string (uname)); 971 values[2] = DECODE_SYSTEM (build_string (uname));
diff --git a/src/dispextern.h b/src/dispextern.h
index 1faeeb19d5b..3c42d7abb9d 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2757,19 +2757,19 @@ struct image_type
2757 Lisp_Object *type; 2757 Lisp_Object *type;
2758 2758
2759 /* Check that SPEC is a valid image specification for the given 2759 /* Check that SPEC is a valid image specification for the given
2760 image type. Value is non-zero if SPEC is valid. */ 2760 image type. Value is true if SPEC is valid. */
2761 int (* valid_p) (Lisp_Object spec); 2761 bool (* valid_p) (Lisp_Object spec);
2762 2762
2763 /* Load IMG which is used on frame F from information contained in 2763 /* Load IMG which is used on frame F from information contained in
2764 IMG->spec. Value is non-zero if successful. */ 2764 IMG->spec. Value is true if successful. */
2765 int (* load) (struct frame *f, struct image *img); 2765 bool (* load) (struct frame *f, struct image *img);
2766 2766
2767 /* Free resources of image IMG which is used on frame F. */ 2767 /* Free resources of image IMG which is used on frame F. */
2768 void (* free) (struct frame *f, struct image *img); 2768 void (* free) (struct frame *f, struct image *img);
2769 2769
2770 /* Initialization function (used for dynamic loading of image 2770 /* Initialization function (used for dynamic loading of image
2771 libraries on Windows), or NULL if none. */ 2771 libraries on Windows), or NULL if none. */
2772 int (* init) (Lisp_Object); 2772 bool (* init) (void);
2773 2773
2774 /* Next in list of all supported image types. */ 2774 /* Next in list of all supported image types. */
2775 struct image_type *next; 2775 struct image_type *next;
@@ -3169,7 +3169,7 @@ extern ptrdiff_t x_create_bitmap_from_xpm_data (struct frame *, const char **);
3169extern void x_destroy_bitmap (struct frame *, ptrdiff_t); 3169extern void x_destroy_bitmap (struct frame *, ptrdiff_t);
3170#endif 3170#endif
3171extern void x_destroy_all_bitmaps (Display_Info *); 3171extern void x_destroy_all_bitmaps (Display_Info *);
3172extern int x_create_bitmap_mask (struct frame *, ptrdiff_t); 3172extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
3173extern Lisp_Object x_find_image_file (Lisp_Object); 3173extern Lisp_Object x_find_image_file (Lisp_Object);
3174 3174
3175void x_kill_gs_process (Pixmap, struct frame *); 3175void x_kill_gs_process (Pixmap, struct frame *);
@@ -3177,7 +3177,7 @@ struct image_cache *make_image_cache (void);
3177void free_image_cache (struct frame *); 3177void free_image_cache (struct frame *);
3178void clear_image_caches (Lisp_Object); 3178void clear_image_caches (Lisp_Object);
3179void mark_image_cache (struct image_cache *); 3179void mark_image_cache (struct image_cache *);
3180int valid_image_p (Lisp_Object); 3180bool valid_image_p (Lisp_Object);
3181void prepare_image_for_display (struct frame *, struct image *); 3181void prepare_image_for_display (struct frame *, struct image *);
3182ptrdiff_t lookup_image (struct frame *, Lisp_Object); 3182ptrdiff_t lookup_image (struct frame *, Lisp_Object);
3183 3183
diff --git a/src/dispnew.c b/src/dispnew.c
index fc966581adb..555136d785c 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1834,7 +1834,7 @@ adjust_glyphs (struct frame *f)
1834{ 1834{
1835 /* Block input so that expose events and other events that access 1835 /* Block input so that expose events and other events that access
1836 glyph matrices are not processed while we are changing them. */ 1836 glyph matrices are not processed while we are changing them. */
1837 BLOCK_INPUT; 1837 block_input ();
1838 1838
1839 if (f) 1839 if (f)
1840 adjust_frame_glyphs (f); 1840 adjust_frame_glyphs (f);
@@ -1846,7 +1846,7 @@ adjust_glyphs (struct frame *f)
1846 adjust_frame_glyphs (XFRAME (lisp_frame)); 1846 adjust_frame_glyphs (XFRAME (lisp_frame));
1847 } 1847 }
1848 1848
1849 UNBLOCK_INPUT; 1849 unblock_input ();
1850} 1850}
1851 1851
1852 1852
@@ -2242,7 +2242,7 @@ free_glyphs (struct frame *f)
2242 { 2242 {
2243 /* Block interrupt input so that we don't get surprised by an X 2243 /* Block interrupt input so that we don't get surprised by an X
2244 event while we're in an inconsistent state. */ 2244 event while we're in an inconsistent state. */
2245 BLOCK_INPUT; 2245 block_input ();
2246 f->glyphs_initialized_p = 0; 2246 f->glyphs_initialized_p = 0;
2247 2247
2248 /* Release window sub-matrices. */ 2248 /* Release window sub-matrices. */
@@ -2287,7 +2287,7 @@ free_glyphs (struct frame *f)
2287 f->desired_pool = f->current_pool = NULL; 2287 f->desired_pool = f->current_pool = NULL;
2288 } 2288 }
2289 2289
2290 UNBLOCK_INPUT; 2290 unblock_input ();
2291 } 2291 }
2292} 2292}
2293 2293
@@ -5563,10 +5563,6 @@ handle_window_change_signal (int sig)
5563 int width, height; 5563 int width, height;
5564 struct tty_display_info *tty; 5564 struct tty_display_info *tty;
5565 5565
5566 struct sigaction action;
5567 emacs_sigaction_init (&action, deliver_window_change_signal);
5568 sigaction (SIGWINCH, &action, 0);
5569
5570 /* The frame size change obviously applies to a single 5566 /* The frame size change obviously applies to a single
5571 termcap-controlled terminal, but we can't decide which. 5567 termcap-controlled terminal, but we can't decide which.
5572 Therefore, we resize the frames corresponding to each tty. 5568 Therefore, we resize the frames corresponding to each tty.
@@ -5599,7 +5595,7 @@ handle_window_change_signal (int sig)
5599static void 5595static void
5600deliver_window_change_signal (int sig) 5596deliver_window_change_signal (int sig)
5601{ 5597{
5602 handle_on_main_thread (sig, handle_window_change_signal); 5598 deliver_process_signal (sig, handle_window_change_signal);
5603} 5599}
5604#endif /* SIGWINCH */ 5600#endif /* SIGWINCH */
5605 5601
@@ -5708,7 +5704,7 @@ change_frame_size_1 (struct frame *f, int newheight, int newwidth,
5708 && new_frame_total_cols == FRAME_TOTAL_COLS (f)) 5704 && new_frame_total_cols == FRAME_TOTAL_COLS (f))
5709 return; 5705 return;
5710 5706
5711 BLOCK_INPUT; 5707 block_input ();
5712 5708
5713#ifdef MSDOS 5709#ifdef MSDOS
5714 /* We only can set screen dimensions to certain values supported 5710 /* We only can set screen dimensions to certain values supported
@@ -5760,7 +5756,7 @@ change_frame_size_1 (struct frame *f, int newheight, int newwidth,
5760 SET_FRAME_GARBAGED (f); 5756 SET_FRAME_GARBAGED (f);
5761 f->resized_p = 1; 5757 f->resized_p = 1;
5762 5758
5763 UNBLOCK_INPUT; 5759 unblock_input ();
5764 5760
5765 record_unwind_current_buffer (); 5761 record_unwind_current_buffer ();
5766 5762
@@ -5791,9 +5787,9 @@ FILE = nil means just close any termscript file currently open. */)
5791 5787
5792 if (tty->termscript != 0) 5788 if (tty->termscript != 0)
5793 { 5789 {
5794 BLOCK_INPUT; 5790 block_input ();
5795 fclose (tty->termscript); 5791 fclose (tty->termscript);
5796 UNBLOCK_INPUT; 5792 unblock_input ();
5797 } 5793 }
5798 tty->termscript = 0; 5794 tty->termscript = 0;
5799 5795
@@ -5824,7 +5820,7 @@ when TERMINAL is nil. */)
5824 5820
5825 /* ??? Perhaps we should do something special for multibyte strings here. */ 5821 /* ??? Perhaps we should do something special for multibyte strings here. */
5826 CHECK_STRING (string); 5822 CHECK_STRING (string);
5827 BLOCK_INPUT; 5823 block_input ();
5828 5824
5829 if (!t) 5825 if (!t)
5830 error ("Unknown terminal device"); 5826 error ("Unknown terminal device");
@@ -5849,7 +5845,7 @@ when TERMINAL is nil. */)
5849 } 5845 }
5850 fwrite (SDATA (string), 1, SBYTES (string), out); 5846 fwrite (SDATA (string), 1, SBYTES (string), out);
5851 fflush (out); 5847 fflush (out);
5852 UNBLOCK_INPUT; 5848 unblock_input ();
5853 return Qnil; 5849 return Qnil;
5854} 5850}
5855 5851
diff --git a/src/dosfns.c b/src/dosfns.c
index 3c649f4d534..ce1ec4a4f93 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -480,9 +480,9 @@ x_set_title (struct frame *f, Lisp_Object name)
480 480
481 if (FRAME_MSDOS_P (f)) 481 if (FRAME_MSDOS_P (f))
482 { 482 {
483 BLOCK_INPUT; 483 block_input ();
484 w95_set_virtual_machine_title (SDATA (name)); 484 w95_set_virtual_machine_title (SDATA (name));
485 UNBLOCK_INPUT; 485 unblock_input ();
486 } 486 }
487} 487}
488#endif /* !HAVE_X_WINDOWS */ 488#endif /* !HAVE_X_WINDOWS */
diff --git a/src/editfns.c b/src/editfns.c
index acf9c48e7a0..fc6465a3d46 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1219,9 +1219,9 @@ of the user with that uid, or nil if there is no such user. */)
1219 return Vuser_login_name; 1219 return Vuser_login_name;
1220 1220
1221 CONS_TO_INTEGER (uid, uid_t, id); 1221 CONS_TO_INTEGER (uid, uid_t, id);
1222 BLOCK_INPUT; 1222 block_input ();
1223 pw = getpwuid (id); 1223 pw = getpwuid (id);
1224 UNBLOCK_INPUT; 1224 unblock_input ();
1225 return (pw ? build_string (pw->pw_name) : Qnil); 1225 return (pw ? build_string (pw->pw_name) : Qnil);
1226} 1226}
1227 1227
@@ -1279,15 +1279,15 @@ name, or nil if there is no such user. */)
1279 { 1279 {
1280 uid_t u; 1280 uid_t u;
1281 CONS_TO_INTEGER (uid, uid_t, u); 1281 CONS_TO_INTEGER (uid, uid_t, u);
1282 BLOCK_INPUT; 1282 block_input ();
1283 pw = getpwuid (u); 1283 pw = getpwuid (u);
1284 UNBLOCK_INPUT; 1284 unblock_input ();
1285 } 1285 }
1286 else if (STRINGP (uid)) 1286 else if (STRINGP (uid))
1287 { 1287 {
1288 BLOCK_INPUT; 1288 block_input ();
1289 pw = getpwnam (SSDATA (uid)); 1289 pw = getpwnam (SSDATA (uid));
1290 UNBLOCK_INPUT; 1290 unblock_input ();
1291 } 1291 }
1292 else 1292 else
1293 error ("Invalid UID specification"); 1293 error ("Invalid UID specification");
@@ -1763,14 +1763,14 @@ format_time_string (char const *format, ptrdiff_t formatlen,
1763 while (1) 1763 while (1)
1764 { 1764 {
1765 time_t *taddr = emacs_secs_addr (&t); 1765 time_t *taddr = emacs_secs_addr (&t);
1766 BLOCK_INPUT; 1766 block_input ();
1767 1767
1768 synchronize_system_time_locale (); 1768 synchronize_system_time_locale ();
1769 1769
1770 tm = ut ? gmtime (taddr) : localtime (taddr); 1770 tm = ut ? gmtime (taddr) : localtime (taddr);
1771 if (! tm) 1771 if (! tm)
1772 { 1772 {
1773 UNBLOCK_INPUT; 1773 unblock_input ();
1774 time_overflow (); 1774 time_overflow ();
1775 } 1775 }
1776 *tmp = *tm; 1776 *tmp = *tm;
@@ -1782,14 +1782,14 @@ format_time_string (char const *format, ptrdiff_t formatlen,
1782 1782
1783 /* Buffer was too small, so make it bigger and try again. */ 1783 /* Buffer was too small, so make it bigger and try again. */
1784 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tm, ut, ns); 1784 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tm, ut, ns);
1785 UNBLOCK_INPUT; 1785 unblock_input ();
1786 if (STRING_BYTES_BOUND <= len) 1786 if (STRING_BYTES_BOUND <= len)
1787 string_overflow (); 1787 string_overflow ();
1788 size = len + 1; 1788 size = len + 1;
1789 buf = SAFE_ALLOCA (size); 1789 buf = SAFE_ALLOCA (size);
1790 } 1790 }
1791 1791
1792 UNBLOCK_INPUT; 1792 unblock_input ();
1793 bufstring = make_unibyte_string (buf, len); 1793 bufstring = make_unibyte_string (buf, len);
1794 SAFE_FREE (); 1794 SAFE_FREE ();
1795 return code_convert_string_norecord (bufstring, Vlocale_coding_system, 0); 1795 return code_convert_string_norecord (bufstring, Vlocale_coding_system, 0);
@@ -1817,11 +1817,11 @@ DOW and ZONE.) */)
1817 struct tm *decoded_time; 1817 struct tm *decoded_time;
1818 Lisp_Object list_args[9]; 1818 Lisp_Object list_args[9];
1819 1819
1820 BLOCK_INPUT; 1820 block_input ();
1821 decoded_time = localtime (&time_spec); 1821 decoded_time = localtime (&time_spec);
1822 if (decoded_time) 1822 if (decoded_time)
1823 save_tm = *decoded_time; 1823 save_tm = *decoded_time;
1824 UNBLOCK_INPUT; 1824 unblock_input ();
1825 if (! (decoded_time 1825 if (! (decoded_time
1826 && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= save_tm.tm_year 1826 && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= save_tm.tm_year
1827 && save_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE)) 1827 && save_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE))
@@ -1837,13 +1837,13 @@ DOW and ZONE.) */)
1837 XSETFASTINT (list_args[6], save_tm.tm_wday); 1837 XSETFASTINT (list_args[6], save_tm.tm_wday);
1838 list_args[7] = save_tm.tm_isdst ? Qt : Qnil; 1838 list_args[7] = save_tm.tm_isdst ? Qt : Qnil;
1839 1839
1840 BLOCK_INPUT; 1840 block_input ();
1841 decoded_time = gmtime (&time_spec); 1841 decoded_time = gmtime (&time_spec);
1842 if (decoded_time == 0) 1842 if (decoded_time == 0)
1843 list_args[8] = Qnil; 1843 list_args[8] = Qnil;
1844 else 1844 else
1845 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); 1845 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time));
1846 UNBLOCK_INPUT; 1846 unblock_input ();
1847 return Flist (9, list_args); 1847 return Flist (9, list_args);
1848} 1848}
1849 1849
@@ -1901,9 +1901,9 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1901 zone = XCAR (zone); 1901 zone = XCAR (zone);
1902 if (NILP (zone)) 1902 if (NILP (zone))
1903 { 1903 {
1904 BLOCK_INPUT; 1904 block_input ();
1905 value = mktime (&tm); 1905 value = mktime (&tm);
1906 UNBLOCK_INPUT; 1906 unblock_input ();
1907 } 1907 }
1908 else 1908 else
1909 { 1909 {
@@ -1928,7 +1928,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1928 else 1928 else
1929 error ("Invalid time zone specification"); 1929 error ("Invalid time zone specification");
1930 1930
1931 BLOCK_INPUT; 1931 block_input ();
1932 1932
1933 /* Set TZ before calling mktime; merely adjusting mktime's returned 1933 /* Set TZ before calling mktime; merely adjusting mktime's returned
1934 value doesn't suffice, since that would mishandle leap seconds. */ 1934 value doesn't suffice, since that would mishandle leap seconds. */
@@ -1942,7 +1942,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1942#ifdef LOCALTIME_CACHE 1942#ifdef LOCALTIME_CACHE
1943 tzset (); 1943 tzset ();
1944#endif 1944#endif
1945 UNBLOCK_INPUT; 1945 unblock_input ();
1946 1946
1947 xfree (newenv); 1947 xfree (newenv);
1948 } 1948 }
@@ -1978,7 +1978,7 @@ but this is considered obsolete. */)
1978 newline, and without the 4-digit year limit. Don't use asctime 1978 newline, and without the 4-digit year limit. Don't use asctime
1979 or ctime, as they might dump core if the year is outside the 1979 or ctime, as they might dump core if the year is outside the
1980 range -999 .. 9999. */ 1980 range -999 .. 9999. */
1981 BLOCK_INPUT; 1981 block_input ();
1982 tm = localtime (&value); 1982 tm = localtime (&value);
1983 if (tm) 1983 if (tm)
1984 { 1984 {
@@ -1994,7 +1994,7 @@ but this is considered obsolete. */)
1994 tm->tm_hour, tm->tm_min, tm->tm_sec, 1994 tm->tm_hour, tm->tm_min, tm->tm_sec,
1995 tm->tm_year + year_base); 1995 tm->tm_year + year_base);
1996 } 1996 }
1997 UNBLOCK_INPUT; 1997 unblock_input ();
1998 if (! tm) 1998 if (! tm)
1999 time_overflow (); 1999 time_overflow ();
2000 2000
@@ -2050,11 +2050,11 @@ the data it can't find. */)
2050 zone_offset = Qnil; 2050 zone_offset = Qnil;
2051 value = make_emacs_time (lisp_seconds_argument (specified_time), 0); 2051 value = make_emacs_time (lisp_seconds_argument (specified_time), 0);
2052 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm); 2052 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm);
2053 BLOCK_INPUT; 2053 block_input ();
2054 t = gmtime (emacs_secs_addr (&value)); 2054 t = gmtime (emacs_secs_addr (&value));
2055 if (t) 2055 if (t)
2056 offset = tm_diff (&localtm, t); 2056 offset = tm_diff (&localtm, t);
2057 UNBLOCK_INPUT; 2057 unblock_input ();
2058 2058
2059 if (t) 2059 if (t)
2060 { 2060 {
@@ -2101,7 +2101,7 @@ only the former. */)
2101 if (! (NILP (tz) || EQ (tz, Qt))) 2101 if (! (NILP (tz) || EQ (tz, Qt)))
2102 CHECK_STRING (tz); 2102 CHECK_STRING (tz);
2103 2103
2104 BLOCK_INPUT; 2104 block_input ();
2105 2105
2106 /* When called for the first time, save the original TZ. */ 2106 /* When called for the first time, save the original TZ. */
2107 old_environbuf = environbuf; 2107 old_environbuf = environbuf;
@@ -2118,7 +2118,7 @@ only the former. */)
2118 set_time_zone_rule (tzstring); 2118 set_time_zone_rule (tzstring);
2119 environbuf = environ; 2119 environbuf = environ;
2120 2120
2121 UNBLOCK_INPUT; 2121 unblock_input ();
2122 2122
2123 xfree (old_environbuf); 2123 xfree (old_environbuf);
2124 return Qnil; 2124 return Qnil;
diff --git a/src/emacs.c b/src/emacs.c
index 52f38925b32..05affeefde7 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -54,6 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
54#include "window.h" 54#include "window.h"
55 55
56#include "systty.h" 56#include "systty.h"
57#include "atimer.h"
57#include "blockinput.h" 58#include "blockinput.h"
58#include "syssignal.h" 59#include "syssignal.h"
59#include "process.h" 60#include "process.h"
@@ -95,6 +96,11 @@ static const char emacs_copyright[] = COPYRIGHT;
95/* Empty lisp strings. To avoid having to build any others. */ 96/* Empty lisp strings. To avoid having to build any others. */
96Lisp_Object empty_unibyte_string, empty_multibyte_string; 97Lisp_Object empty_unibyte_string, empty_multibyte_string;
97 98
99#ifdef WINDOWSNT
100/* Cache for externally loaded libraries. */
101Lisp_Object Vlibrary_cache;
102#endif
103
98/* Set after Emacs has started up the first time. 104/* Set after Emacs has started up the first time.
99 Prevents reinitialization of the Lisp world and keymaps 105 Prevents reinitialization of the Lisp world and keymaps
100 on subsequent starts. */ 106 on subsequent starts. */
@@ -269,9 +275,6 @@ Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\
269section of the Emacs manual or the file BUGS.\n" 275section of the Emacs manual or the file BUGS.\n"
270 276
271 277
272/* Signal code for the fatal signal that was received. */
273static int fatal_error_code;
274
275/* True if handling a fatal error already. */ 278/* True if handling a fatal error already. */
276bool fatal_error_in_progress; 279bool fatal_error_in_progress;
277 280
@@ -282,28 +285,13 @@ static void *ns_pool;
282 285
283 286
284 287
285/* Handle bus errors, invalid instruction, etc. */
286static void
287handle_fatal_signal (int sig)
288{
289 fatal_error_backtrace (sig, 10);
290}
291
292static void
293deliver_fatal_signal (int sig)
294{
295 handle_on_main_thread (sig, handle_fatal_signal);
296}
297
298/* Report a fatal error due to signal SIG, output a backtrace of at 288/* Report a fatal error due to signal SIG, output a backtrace of at
299 most BACKTRACE_LIMIT lines, and exit. */ 289 most BACKTRACE_LIMIT lines, and exit. */
300_Noreturn void 290_Noreturn void
301fatal_error_backtrace (int sig, int backtrace_limit) 291terminate_due_to_signal (int sig, int backtrace_limit)
302{ 292{
303 fatal_error_code = sig;
304 signal (sig, SIG_DFL); 293 signal (sig, SIG_DFL);
305 294 totally_unblock_input ();
306 TOTALLY_UNBLOCK_INPUT;
307 295
308 /* If fatal error occurs in code below, avoid infinite recursion. */ 296 /* If fatal error occurs in code below, avoid infinite recursion. */
309 if (! fatal_error_in_progress) 297 if (! fatal_error_in_progress)
@@ -318,19 +306,18 @@ fatal_error_backtrace (int sig, int backtrace_limit)
318 } 306 }
319 307
320 /* Signal the same code; this time it will really be fatal. 308 /* Signal the same code; this time it will really be fatal.
321 Remember that since we're in a signal handler, the signal we're 309 Since we're in a signal handler, the signal is blocked, so we
322 going to send is probably blocked, so we have to unblock it if we 310 have to unblock it if we want to really receive it. */
323 want to really receive it. */
324#ifndef MSDOS 311#ifndef MSDOS
325 { 312 {
326 sigset_t unblocked; 313 sigset_t unblocked;
327 sigemptyset (&unblocked); 314 sigemptyset (&unblocked);
328 sigaddset (&unblocked, fatal_error_code); 315 sigaddset (&unblocked, sig);
329 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); 316 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
330 } 317 }
331#endif 318#endif
332 319
333 kill (getpid (), fatal_error_code); 320 emacs_raise (sig);
334 321
335 /* This shouldn't be executed, but it prevents a warning. */ 322 /* This shouldn't be executed, but it prevents a warning. */
336 exit (1); 323 exit (1);
@@ -339,15 +326,9 @@ fatal_error_backtrace (int sig, int backtrace_limit)
339#ifdef SIGDANGER 326#ifdef SIGDANGER
340 327
341/* Handler for SIGDANGER. */ 328/* Handler for SIGDANGER. */
342static void deliver_danger_signal (int);
343
344static void 329static void
345handle_danger_signal (int sig) 330handle_danger_signal (int sig)
346{ 331{
347 struct sigaction action;
348 emacs_sigaction_init (&action, deliver_danger_signal);
349 sigaction (sig, &action, 0);
350
351 malloc_warning ("Operating system warns that virtual memory is running low.\n"); 332 malloc_warning ("Operating system warns that virtual memory is running low.\n");
352 333
353 /* It might be unsafe to call do_auto_save now. */ 334 /* It might be unsafe to call do_auto_save now. */
@@ -357,7 +338,7 @@ handle_danger_signal (int sig)
357static void 338static void
358deliver_danger_signal (int sig) 339deliver_danger_signal (int sig)
359{ 340{
360 handle_on_main_thread (sig, handle_danger_signal); 341 deliver_process_signal (sig, handle_danger_signal);
361} 342}
362#endif 343#endif
363 344
@@ -680,6 +661,7 @@ main (int argc, char **argv)
680#endif 661#endif
681 char stack_bottom_variable; 662 char stack_bottom_variable;
682 bool do_initial_setlocale; 663 bool do_initial_setlocale;
664 bool dumping;
683 int skip_args = 0; 665 int skip_args = 0;
684#ifdef HAVE_SETRLIMIT 666#ifdef HAVE_SETRLIMIT
685 struct rlimit rlim; 667 struct rlimit rlim;
@@ -691,7 +673,6 @@ main (int argc, char **argv)
691 char dname_arg2[80]; 673 char dname_arg2[80];
692#endif 674#endif
693 char *ch_to_dir; 675 char *ch_to_dir;
694 struct sigaction fatal_error_action;
695 676
696#if GC_MARK_STACK 677#if GC_MARK_STACK
697 stack_base = &dummy; 678 stack_base = &dummy;
@@ -777,12 +758,11 @@ main (int argc, char **argv)
777 exit (1); 758 exit (1);
778 } 759 }
779 760
761 dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
762 || strcmp (argv[argc - 1], "bootstrap") == 0);
780 763
781#ifdef HAVE_PERSONALITY_LINUX32 764#ifdef HAVE_PERSONALITY_LINUX32
782 if (!initialized 765 if (dumping && ! getenv ("EMACS_HEAP_EXEC"))
783 && (strcmp (argv[argc-1], "dump") == 0
784 || strcmp (argv[argc-1], "bootstrap") == 0)
785 && ! getenv ("EMACS_HEAP_EXEC"))
786 { 766 {
787 static char heapexec[] = "EMACS_HEAP_EXEC=true"; 767 static char heapexec[] = "EMACS_HEAP_EXEC=true";
788 /* Set this so we only do this once. */ 768 /* Set this so we only do this once. */
@@ -1107,119 +1087,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1107#endif 1087#endif
1108 } 1088 }
1109 1089
1110 init_signals (); 1090 init_signals (dumping);
1111 emacs_sigaction_init (&fatal_error_action, deliver_fatal_signal);
1112
1113 /* Don't catch SIGHUP if dumping. */
1114 if (1
1115#ifndef CANNOT_DUMP
1116 && initialized
1117#endif
1118 )
1119 {
1120 /* In --batch mode, don't catch SIGHUP if already ignored.
1121 That makes nohup work. */
1122 bool catch_SIGHUP = !noninteractive;
1123 if (!catch_SIGHUP)
1124 {
1125 struct sigaction old_action;
1126 sigaction (SIGHUP, 0, &old_action);
1127 catch_SIGHUP = old_action.sa_handler != SIG_IGN;
1128 }
1129 if (catch_SIGHUP)
1130 sigaction (SIGHUP, &fatal_error_action, 0);
1131 }
1132
1133 if (
1134#ifndef CANNOT_DUMP
1135 ! noninteractive || initialized
1136#else
1137 1
1138#endif
1139 )
1140 {
1141 /* Don't catch these signals in batch mode if dumping.
1142 On some machines, this sets static data that would make
1143 signal fail to work right when the dumped Emacs is run. */
1144 sigaction (SIGQUIT, &fatal_error_action, 0);
1145 sigaction (SIGILL, &fatal_error_action, 0);
1146 sigaction (SIGTRAP, &fatal_error_action, 0);
1147#ifdef SIGUSR1
1148 add_user_signal (SIGUSR1, "sigusr1");
1149#endif
1150#ifdef SIGUSR2
1151 add_user_signal (SIGUSR2, "sigusr2");
1152#endif
1153#ifdef SIGABRT
1154 sigaction (SIGABRT, &fatal_error_action, 0);
1155#endif
1156#ifdef SIGHWE
1157 sigaction (SIGHWE, &fatal_error_action, 0);
1158#endif
1159#ifdef SIGPRE
1160 sigaction (SIGPRE, &fatal_error_action, 0);
1161#endif
1162#ifdef SIGORE
1163 sigaction (SIGORE, &fatal_error_action, 0);
1164#endif
1165#ifdef SIGUME
1166 sigaction (SIGUME, &fatal_error_action, 0);
1167#endif
1168#ifdef SIGDLK
1169 sigaction (SIGDLK, &fatal_error_action, 0);
1170#endif
1171#ifdef SIGCPULIM
1172 sigaction (SIGCPULIM, &fatal_error_action, 0);
1173#endif
1174#ifdef SIGIOT
1175 /* This is missing on some systems - OS/2, for example. */
1176 sigaction (SIGIOT, &fatal_error_action, 0);
1177#endif
1178#ifdef SIGEMT
1179 sigaction (SIGEMT, &fatal_error_action, 0);
1180#endif
1181 sigaction (SIGFPE, &fatal_error_action, 0);
1182#ifdef SIGBUS
1183 sigaction (SIGBUS, &fatal_error_action, 0);
1184#endif
1185 sigaction (SIGSEGV, &fatal_error_action, 0);
1186#ifdef SIGSYS
1187 sigaction (SIGSYS, &fatal_error_action, 0);
1188#endif
1189 /* May need special treatment on MS-Windows. See
1190 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
1191 Please update the doc of kill-emacs, kill-emacs-hook, and
1192 NEWS if you change this.
1193 */
1194 if (noninteractive)
1195 sigaction (SIGINT, &fatal_error_action, 0);
1196 sigaction (SIGTERM, &fatal_error_action, 0);
1197#ifdef SIGXCPU
1198 sigaction (SIGXCPU, &fatal_error_action, 0);
1199#endif
1200#ifdef SIGXFSZ
1201 sigaction (SIGXFSZ, &fatal_error_action, 0);
1202#endif /* SIGXFSZ */
1203
1204#ifdef SIGDANGER
1205 /* This just means available memory is getting low. */
1206 {
1207 struct sigaction action;
1208 emacs_sigaction_init (&action, deliver_danger_signal);
1209 sigaction (SIGDANGER, &action, 0);
1210 }
1211#endif
1212
1213#ifdef AIX
1214/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
1215 sigaction (SIGXCPU, &fatal_error_action, 0);
1216 sigaction (SIGIOINT, &fatal_error_action, 0);
1217 sigaction (SIGGRANT, &fatal_error_action, 0);
1218 sigaction (SIGRETRACT, &fatal_error_action, 0);
1219 sigaction (SIGSOUND, &fatal_error_action, 0);
1220 sigaction (SIGMSG, &fatal_error_action, 0);
1221#endif /* AIX */
1222 }
1223 1091
1224 noninteractive1 = noninteractive; 1092 noninteractive1 = noninteractive;
1225 1093
@@ -1281,7 +1149,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1281 } 1149 }
1282 1150
1283 init_eval (); 1151 init_eval ();
1284 init_data ();
1285 init_atimer (); 1152 init_atimer ();
1286 running_asynch_code = 0; 1153 running_asynch_code = 0;
1287 init_random (); 1154 init_random ();
@@ -1396,7 +1263,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1396 globals_of_w32 (); 1263 globals_of_w32 ();
1397 /* Initialize environment from registry settings. */ 1264 /* Initialize environment from registry settings. */
1398 init_environment (argv); 1265 init_environment (argv);
1399 init_ntproc (); /* must precede init_editfns. */ 1266 init_ntproc (dumping); /* must precede init_editfns. */
1400#endif 1267#endif
1401 1268
1402 /* Initialize and GC-protect Vinitial_environment and 1269 /* Initialize and GC-protect Vinitial_environment and
@@ -1407,8 +1274,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1407 /* egetenv is a pretty low-level facility, which may get called in 1274 /* egetenv is a pretty low-level facility, which may get called in
1408 many circumstances; it seems flimsy to put off initializing it 1275 many circumstances; it seems flimsy to put off initializing it
1409 until calling init_callproc. Do not do it when dumping. */ 1276 until calling init_callproc. Do not do it when dumping. */
1410 if (initialized || ((strcmp (argv[argc-1], "dump") != 0 1277 if (! dumping)
1411 && strcmp (argv[argc-1], "bootstrap") != 0)))
1412 set_initial_environment (); 1278 set_initial_environment ();
1413 1279
1414 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4 1280 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
@@ -1553,6 +1419,8 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1553 syms_of_ntterm (); 1419 syms_of_ntterm ();
1554#endif /* WINDOWSNT */ 1420#endif /* WINDOWSNT */
1555 1421
1422 syms_of_profiler ();
1423
1556 keys_of_casefiddle (); 1424 keys_of_casefiddle ();
1557 keys_of_cmds (); 1425 keys_of_cmds ();
1558 keys_of_buffer (); 1426 keys_of_buffer ();
@@ -2045,7 +1913,7 @@ shut_down_emacs (int sig, Lisp_Object stuff)
2045 ignore_sigio (); 1913 ignore_sigio ();
2046 1914
2047#ifdef WINDOWSNT 1915#ifdef WINDOWSNT
2048 term_ntproc (); 1916 term_ntproc (0);
2049#endif 1917#endif
2050 1918
2051 /* Do this only if terminating normally, we want glyph matrices 1919 /* Do this only if terminating normally, we want glyph matrices
@@ -2164,6 +2032,13 @@ You must run Emacs in batch mode in order to dump it. */)
2164 free (malloc_state_ptr); 2032 free (malloc_state_ptr);
2165#endif 2033#endif
2166 2034
2035#ifdef WINDOWSNT
2036 Vlibrary_cache = Qnil;
2037#endif
2038#ifdef HAVE_WINDOW_SYSTEM
2039 reset_image_types ();
2040#endif
2041
2167 Vpurify_flag = tem; 2042 Vpurify_flag = tem;
2168 2043
2169 return unbind_to (count, Qnil); 2044 return unbind_to (count, Qnil);
@@ -2496,6 +2371,11 @@ libraries; only those already known by Emacs will be loaded. */);
2496 Vdynamic_library_alist = Qnil; 2371 Vdynamic_library_alist = Qnil;
2497 Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt); 2372 Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt);
2498 2373
2374#ifdef WINDOWSNT
2375 Vlibrary_cache = Qnil;
2376 staticpro (&Vlibrary_cache);
2377#endif
2378
2499 /* Make sure IS_DAEMON starts up as false. */ 2379 /* Make sure IS_DAEMON starts up as false. */
2500 daemon_pipe[1] = 0; 2380 daemon_pipe[1] = 0;
2501} 2381}
diff --git a/src/eval.c b/src/eval.c
index e47478bb1f1..561ba922482 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -31,17 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include "xterm.h" 31#include "xterm.h"
32#endif 32#endif
33 33
34struct backtrace 34struct backtrace *backtrace_list;
35{
36 struct backtrace *next;
37 Lisp_Object *function;
38 Lisp_Object *args; /* Points to vector of args. */
39 ptrdiff_t nargs; /* Length of vector. */
40 /* Nonzero means call value of debugger when done with this operation. */
41 unsigned int debug_on_exit : 1;
42};
43
44static struct backtrace *backtrace_list;
45 35
46#if !BYTE_MARK_STACK 36#if !BYTE_MARK_STACK
47static 37static
@@ -562,7 +552,7 @@ interactive_p (void)
562 552
563 /* If this isn't a byte-compiled function, there may be a frame at 553 /* If this isn't a byte-compiled function, there may be a frame at
564 the top for Finteractive_p. If so, skip it. */ 554 the top for Finteractive_p. If so, skip it. */
565 fun = Findirect_function (*btp->function, Qnil); 555 fun = Findirect_function (btp->function, Qnil);
566 if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p 556 if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p
567 || XSUBR (fun) == &Scalled_interactively_p)) 557 || XSUBR (fun) == &Scalled_interactively_p))
568 btp = btp->next; 558 btp = btp->next;
@@ -575,7 +565,7 @@ interactive_p (void)
575 If this isn't a byte-compiled function, then we may now be 565 If this isn't a byte-compiled function, then we may now be
576 looking at several frames for special forms. Skip past them. */ 566 looking at several frames for special forms. Skip past them. */
577 while (btp 567 while (btp
578 && (EQ (*btp->function, Qbytecode) 568 && (EQ (btp->function, Qbytecode)
579 || btp->nargs == UNEVALLED)) 569 || btp->nargs == UNEVALLED))
580 btp = btp->next; 570 btp = btp->next;
581 571
@@ -583,13 +573,13 @@ interactive_p (void)
583 a special form, ignoring frames for Finteractive_p and/or 573 a special form, ignoring frames for Finteractive_p and/or
584 Fbytecode at the top. If this frame is for a built-in function 574 Fbytecode at the top. If this frame is for a built-in function
585 (such as load or eval-region) return false. */ 575 (such as load or eval-region) return false. */
586 fun = Findirect_function (*btp->function, Qnil); 576 fun = Findirect_function (btp->function, Qnil);
587 if (SUBRP (fun)) 577 if (SUBRP (fun))
588 return 0; 578 return 0;
589 579
590 /* `btp' points to the frame of a Lisp function that called interactive-p. 580 /* `btp' points to the frame of a Lisp function that called interactive-p.
591 Return t if that function was called interactively. */ 581 Return t if that function was called interactively. */
592 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) 582 if (btp && btp->next && EQ (btp->next->function, Qcall_interactively))
593 return 1; 583 return 1;
594 return 0; 584 return 0;
595} 585}
@@ -1076,7 +1066,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1076/* Unwind the specbind, catch, and handler stacks back to CATCH, and 1066/* Unwind the specbind, catch, and handler stacks back to CATCH, and
1077 jump to that CATCH, returning VALUE as the value of that catch. 1067 jump to that CATCH, returning VALUE as the value of that catch.
1078 1068
1079 This is the guts Fthrow and Fsignal; they differ only in the way 1069 This is the guts of Fthrow and Fsignal; they differ only in the way
1080 they choose the catch tag to throw to. A catch tag for a 1070 they choose the catch tag to throw to. A catch tag for a
1081 condition-case form has a TAG of Qnil. 1071 condition-case form has a TAG of Qnil.
1082 1072
@@ -1085,7 +1075,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1085 the handler stack as we go, so that the proper handlers are in 1075 the handler stack as we go, so that the proper handlers are in
1086 effect for each unwind-protect clause we run. At the end, restore 1076 effect for each unwind-protect clause we run. At the end, restore
1087 some static info saved in CATCH, and longjmp to the location 1077 some static info saved in CATCH, and longjmp to the location
1088 specified in the 1078 specified there.
1089 1079
1090 This is used for correct unwinding in Fthrow and Fsignal. */ 1080 This is used for correct unwinding in Fthrow and Fsignal. */
1091 1081
@@ -1099,7 +1089,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1099 1089
1100 /* Restore certain special C variables. */ 1090 /* Restore certain special C variables. */
1101 set_poll_suppress_count (catch->poll_suppress_count); 1091 set_poll_suppress_count (catch->poll_suppress_count);
1102 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked); 1092 unblock_input_to (catch->interrupt_input_blocked);
1103 immediate_quit = 0; 1093 immediate_quit = 0;
1104 1094
1105 do 1095 do
@@ -1114,16 +1104,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1114 } 1104 }
1115 while (! last_time); 1105 while (! last_time);
1116 1106
1117#if HAVE_X_WINDOWS
1118 /* If x_catch_errors was done, turn it off now.
1119 (First we give unbind_to a chance to do that.) */
1120#if 0 /* This would disable x_catch_errors after x_connection_closed.
1121 The catch must remain in effect during that delicate
1122 state. --lorentey */
1123 x_fully_uncatch_errors ();
1124#endif
1125#endif
1126
1127 byte_stack_list = catch->byte_stack; 1107 byte_stack_list = catch->byte_stack;
1128 gcprolist = catch->gcpro; 1108 gcprolist = catch->gcpro;
1129#ifdef DEBUG_GCPRO 1109#ifdef DEBUG_GCPRO
@@ -1516,10 +1496,10 @@ See also the function `condition-case'. */)
1516 if (backtrace_list && !NILP (error_symbol)) 1496 if (backtrace_list && !NILP (error_symbol))
1517 { 1497 {
1518 bp = backtrace_list->next; 1498 bp = backtrace_list->next;
1519 if (bp && bp->function && EQ (*bp->function, Qerror)) 1499 if (bp && EQ (bp->function, Qerror))
1520 bp = bp->next; 1500 bp = bp->next;
1521 if (bp && bp->function) 1501 if (bp)
1522 Vsignaling_function = *bp->function; 1502 Vsignaling_function = bp->function;
1523 } 1503 }
1524 1504
1525 for (h = handlerlist; h; h = h->next) 1505 for (h = handlerlist; h; h = h->next)
@@ -1530,7 +1510,7 @@ See also the function `condition-case'. */)
1530 } 1510 }
1531 1511
1532 if (/* Don't run the debugger for a memory-full error. 1512 if (/* Don't run the debugger for a memory-full error.
1533 (There is no room in memory to do that!) */ 1513 (There is no room in memory to do that!) */
1534 !NILP (error_symbol) 1514 !NILP (error_symbol)
1535 && (!NILP (Vdebug_on_signal) 1515 && (!NILP (Vdebug_on_signal)
1536 /* If no handler is present now, try to run the debugger. */ 1516 /* If no handler is present now, try to run the debugger. */
@@ -1713,7 +1693,7 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
1713 if ( 1693 if (
1714 /* Don't try to run the debugger with interrupts blocked. 1694 /* Don't try to run the debugger with interrupts blocked.
1715 The editing loop would return anyway. */ 1695 The editing loop would return anyway. */
1716 ! INPUT_BLOCKED_P 1696 ! input_blocked_p ()
1717 && NILP (Vinhibit_debugger) 1697 && NILP (Vinhibit_debugger)
1718 /* Does user want to enter debugger for this kind of error? */ 1698 /* Does user want to enter debugger for this kind of error? */
1719 && (EQ (sig, Qquit) 1699 && (EQ (sig, Qquit)
@@ -2065,11 +2045,11 @@ eval_sub (Lisp_Object form)
2065 original_args = XCDR (form); 2045 original_args = XCDR (form);
2066 2046
2067 backtrace.next = backtrace_list; 2047 backtrace.next = backtrace_list;
2068 backtrace_list = &backtrace; 2048 backtrace.function = original_fun; /* This also protects them from gc. */
2069 backtrace.function = &original_fun; /* This also protects them from gc. */
2070 backtrace.args = &original_args; 2049 backtrace.args = &original_args;
2071 backtrace.nargs = UNEVALLED; 2050 backtrace.nargs = UNEVALLED;
2072 backtrace.debug_on_exit = 0; 2051 backtrace.debug_on_exit = 0;
2052 backtrace_list = &backtrace;
2073 2053
2074 if (debug_on_next_call) 2054 if (debug_on_next_call)
2075 do_debug_on_call (Qt); 2055 do_debug_on_call (Qt);
@@ -2371,14 +2351,10 @@ usage: (run-hooks &rest HOOKS) */)
2371DEFUN ("run-hook-with-args", Frun_hook_with_args, 2351DEFUN ("run-hook-with-args", Frun_hook_with_args,
2372 Srun_hook_with_args, 1, MANY, 0, 2352 Srun_hook_with_args, 1, MANY, 0,
2373 doc: /* Run HOOK with the specified arguments ARGS. 2353 doc: /* Run HOOK with the specified arguments ARGS.
2374HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2354HOOK should be a symbol, a hook variable. The value of HOOK
2375value, that value may be a function or a list of functions to be 2355may be nil, a function, or a list of functions. Call each
2376called to run the hook. If the value is a function, it is called with 2356function in order with arguments ARGS. The final return value
2377the given arguments and its return value is returned. If it is a list 2357is unspecified.
2378of functions, those functions are called, in order,
2379with the given arguments ARGS.
2380It is best not to depend on the value returned by `run-hook-with-args',
2381as that may change.
2382 2358
2383Do not use `make-local-variable' to make a hook variable buffer-local. 2359Do not use `make-local-variable' to make a hook variable buffer-local.
2384Instead, use `add-hook' and specify t for the LOCAL argument. 2360Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2388,18 +2364,18 @@ usage: (run-hook-with-args HOOK &rest ARGS) */)
2388 return run_hook_with_args (nargs, args, funcall_nil); 2364 return run_hook_with_args (nargs, args, funcall_nil);
2389} 2365}
2390 2366
2367/* NB this one still documents a specific non-nil return value.
2368 (As did run-hook-with-args and run-hook-with-args-until-failure
2369 until they were changed in 24.1.) */
2391DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, 2370DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success,
2392 Srun_hook_with_args_until_success, 1, MANY, 0, 2371 Srun_hook_with_args_until_success, 1, MANY, 0,
2393 doc: /* Run HOOK with the specified arguments ARGS. 2372 doc: /* Run HOOK with the specified arguments ARGS.
2394HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2373HOOK should be a symbol, a hook variable. The value of HOOK
2395value, that value may be a function or a list of functions to be 2374may be nil, a function, or a list of functions. Call each
2396called to run the hook. If the value is a function, it is called with 2375function in order with arguments ARGS, stopping at the first
2397the given arguments and its return value is returned. 2376one that returns non-nil, and return that value. Otherwise (if
2398If it is a list of functions, those functions are called, in order, 2377all functions return nil, or if there are no functions to call),
2399with the given arguments ARGS, until one of them 2378return nil.
2400returns a non-nil value. Then we return that value.
2401However, if they all return nil, we return nil.
2402If the value of HOOK is nil, this function returns nil.
2403 2379
2404Do not use `make-local-variable' to make a hook variable buffer-local. 2380Do not use `make-local-variable' to make a hook variable buffer-local.
2405Instead, use `add-hook' and specify t for the LOCAL argument. 2381Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2418,15 +2394,12 @@ funcall_not (ptrdiff_t nargs, Lisp_Object *args)
2418DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, 2394DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure,
2419 Srun_hook_with_args_until_failure, 1, MANY, 0, 2395 Srun_hook_with_args_until_failure, 1, MANY, 0,
2420 doc: /* Run HOOK with the specified arguments ARGS. 2396 doc: /* Run HOOK with the specified arguments ARGS.
2421HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2397HOOK should be a symbol, a hook variable. The value of HOOK
2422value, that value may be a function or a list of functions to be 2398may be nil, a function, or a list of functions. Call each
2423called to run the hook. If the value is a function, it is called with 2399function in order with arguments ARGS, stopping at the first
2424the given arguments. Then we return nil if the function returns nil, 2400one that returns nil, and return nil. Otherwise (if all functions
2425and t if it returns non-nil. 2401return non-nil, or if there are no functions to call), return non-nil
2426If it is a list of functions, those functions are called, in order, 2402\(do not rely on the precise return value in this case).
2427with the given arguments ARGS, until one of them returns nil.
2428Then we return nil. However, if they all return non-nil, we return t.
2429If the value of HOOK is nil, this function returns t.
2430 2403
2431Do not use `make-local-variable' to make a hook variable buffer-local. 2404Do not use `make-local-variable' to make a hook variable buffer-local.
2432Instead, use `add-hook' and specify t for the LOCAL argument. 2405Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2740,11 +2713,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2740 } 2713 }
2741 2714
2742 backtrace.next = backtrace_list; 2715 backtrace.next = backtrace_list;
2743 backtrace_list = &backtrace; 2716 backtrace.function = args[0];
2744 backtrace.function = &args[0];
2745 backtrace.args = &args[1]; /* This also GCPROs them. */ 2717 backtrace.args = &args[1]; /* This also GCPROs them. */
2746 backtrace.nargs = nargs - 1; 2718 backtrace.nargs = nargs - 1;
2747 backtrace.debug_on_exit = 0; 2719 backtrace.debug_on_exit = 0;
2720 backtrace_list = &backtrace;
2748 2721
2749 /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ 2722 /* Call GC after setting up the backtrace, so the latter GCPROs the args. */
2750 maybe_gc (); 2723 maybe_gc ();
@@ -3316,12 +3289,12 @@ Output stream used is value of `standard-output'. */)
3316 write_string (backlist->debug_on_exit ? "* " : " ", 2); 3289 write_string (backlist->debug_on_exit ? "* " : " ", 2);
3317 if (backlist->nargs == UNEVALLED) 3290 if (backlist->nargs == UNEVALLED)
3318 { 3291 {
3319 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); 3292 Fprin1 (Fcons (backlist->function, *backlist->args), Qnil);
3320 write_string ("\n", -1); 3293 write_string ("\n", -1);
3321 } 3294 }
3322 else 3295 else
3323 { 3296 {
3324 tem = *backlist->function; 3297 tem = backlist->function;
3325 Fprin1 (tem, Qnil); /* This can QUIT. */ 3298 Fprin1 (tem, Qnil); /* This can QUIT. */
3326 write_string ("(", -1); 3299 write_string ("(", -1);
3327 if (backlist->nargs == MANY) 3300 if (backlist->nargs == MANY)
@@ -3379,7 +3352,7 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3379 if (!backlist) 3352 if (!backlist)
3380 return Qnil; 3353 return Qnil;
3381 if (backlist->nargs == UNEVALLED) 3354 if (backlist->nargs == UNEVALLED)
3382 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); 3355 return Fcons (Qnil, Fcons (backlist->function, *backlist->args));
3383 else 3356 else
3384 { 3357 {
3385 if (backlist->nargs == MANY) /* FIXME: Can this happen? */ 3358 if (backlist->nargs == MANY) /* FIXME: Can this happen? */
@@ -3387,7 +3360,7 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3387 else 3360 else
3388 tem = Flist (backlist->nargs, backlist->args); 3361 tem = Flist (backlist->nargs, backlist->args);
3389 3362
3390 return Fcons (Qt, Fcons (*backlist->function, tem)); 3363 return Fcons (Qt, Fcons (backlist->function, tem));
3391 } 3364 }
3392} 3365}
3393 3366
diff --git a/src/fileio.c b/src/fileio.c
index 6c4e34d7312..9d8a0dc8b45 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1025,9 +1025,9 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1025 memcpy (o, nm, p - nm); 1025 memcpy (o, nm, p - nm);
1026 o [p - nm] = 0; 1026 o [p - nm] = 0;
1027 1027
1028 BLOCK_INPUT; 1028 block_input ();
1029 pw = (struct passwd *) getpwnam (o + 1); 1029 pw = (struct passwd *) getpwnam (o + 1);
1030 UNBLOCK_INPUT; 1030 unblock_input ();
1031 if (pw) 1031 if (pw)
1032 { 1032 {
1033 newdir = pw->pw_dir; 1033 newdir = pw->pw_dir;
@@ -1413,9 +1413,9 @@ See also the function `substitute-in-file-name'.")
1413 o[len] = 0; 1413 o[len] = 0;
1414 1414
1415 /* Look up the user name. */ 1415 /* Look up the user name. */
1416 BLOCK_INPUT; 1416 block_input ();
1417 pw = (struct passwd *) getpwnam (o + 1); 1417 pw = (struct passwd *) getpwnam (o + 1);
1418 UNBLOCK_INPUT; 1418 unblock_input ();
1419 if (!pw) 1419 if (!pw)
1420 error ("\"%s\" isn't a registered user", o + 1); 1420 error ("\"%s\" isn't a registered user", o + 1);
1421 1421
@@ -1531,9 +1531,9 @@ search_embedded_absfilename (char *nm, char *endp)
1531 /* If we have ~user and `user' exists, discard 1531 /* If we have ~user and `user' exists, discard
1532 everything up to ~. But if `user' does not exist, leave 1532 everything up to ~. But if `user' does not exist, leave
1533 ~user alone, it might be a literal file name. */ 1533 ~user alone, it might be a literal file name. */
1534 BLOCK_INPUT; 1534 block_input ();
1535 pw = getpwnam (o + 1); 1535 pw = getpwnam (o + 1);
1536 UNBLOCK_INPUT; 1536 unblock_input ();
1537 if (pw) 1537 if (pw)
1538 return p; 1538 return p;
1539 } 1539 }
@@ -2999,10 +2999,10 @@ The value is an integer. */)
2999 mode_t realmask; 2999 mode_t realmask;
3000 Lisp_Object value; 3000 Lisp_Object value;
3001 3001
3002 BLOCK_INPUT; 3002 block_input ();
3003 realmask = umask (0); 3003 realmask = umask (0);
3004 umask (realmask); 3004 umask (realmask);
3005 UNBLOCK_INPUT; 3005 unblock_input ();
3006 3006
3007 XSETINT (value, (~ realmask) & 0777); 3007 XSETINT (value, (~ realmask) & 0777);
3008 return value; 3008 return value;
@@ -5235,9 +5235,9 @@ do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */
5235 auto_saving = 0; 5235 auto_saving = 0;
5236 if (stream != NULL) 5236 if (stream != NULL)
5237 { 5237 {
5238 BLOCK_INPUT; 5238 block_input ();
5239 fclose (stream); 5239 fclose (stream);
5240 UNBLOCK_INPUT; 5240 unblock_input ();
5241 } 5241 }
5242 return Qnil; 5242 return Qnil;
5243} 5243}
@@ -5368,7 +5368,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5368 if (STRINGP (BVAR (b, auto_save_file_name)) 5368 if (STRINGP (BVAR (b, auto_save_file_name))
5369 && stream != NULL && do_handled_files == 0) 5369 && stream != NULL && do_handled_files == 0)
5370 { 5370 {
5371 BLOCK_INPUT; 5371 block_input ();
5372 if (!NILP (BVAR (b, filename))) 5372 if (!NILP (BVAR (b, filename)))
5373 { 5373 {
5374 fwrite (SDATA (BVAR (b, filename)), 1, 5374 fwrite (SDATA (BVAR (b, filename)), 1,
@@ -5378,7 +5378,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5378 fwrite (SDATA (BVAR (b, auto_save_file_name)), 1, 5378 fwrite (SDATA (BVAR (b, auto_save_file_name)), 1,
5379 SBYTES (BVAR (b, auto_save_file_name)), stream); 5379 SBYTES (BVAR (b, auto_save_file_name)), stream);
5380 putc ('\n', stream); 5380 putc ('\n', stream);
5381 UNBLOCK_INPUT; 5381 unblock_input ();
5382 } 5382 }
5383 5383
5384 if (!NILP (current_only) 5384 if (!NILP (current_only)
diff --git a/src/floatfns.c b/src/floatfns.c
index 4fe209fcb61..645a5957609 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -31,15 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <config.h> 31#include <config.h>
32 32
33#include "lisp.h" 33#include "lisp.h"
34#include "syssignal.h"
35
36#include <float.h>
37#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
38 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
39#define IEEE_FLOATING_POINT 1
40#else
41#define IEEE_FLOATING_POINT 0
42#endif
43 34
44#include <math.h> 35#include <math.h>
45 36
diff --git a/src/fns.c b/src/fns.c
index 42c4f817f29..6d6f019b311 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -61,8 +61,9 @@ DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
61 61
62DEFUN ("random", Frandom, Srandom, 0, 1, 0, 62DEFUN ("random", Frandom, Srandom, 0, 1, 0,
63 doc: /* Return a pseudo-random number. 63 doc: /* Return a pseudo-random number.
64All integers representable in Lisp are equally likely. 64All integers representable in Lisp, i.e. between `most-negative-fixnum'
65 On most systems, this is 29 bits' worth. 65and `most-positive-fixnum', inclusive, are equally likely.
66
66With positive integer LIMIT, return random number in interval [0,LIMIT). 67With positive integer LIMIT, return random number in interval [0,LIMIT).
67With argument t, set the random number seed from the current time and pid. 68With argument t, set the random number seed from the current time and pid.
68Other values of LIMIT are ignored. */) 69Other values of LIMIT are ignored. */)
@@ -1838,13 +1839,6 @@ properties on the list. This function never signals an error. */)
1838 halftail = XCDR (halftail); 1839 halftail = XCDR (halftail);
1839 if (EQ (tail, halftail)) 1840 if (EQ (tail, halftail))
1840 break; 1841 break;
1841
1842#if 0 /* Unsafe version. */
1843 /* This function can be called asynchronously
1844 (setup_coding_system). Don't QUIT in that case. */
1845 if (!interrupt_input_blocked)
1846 QUIT;
1847#endif
1848 } 1842 }
1849 1843
1850 return Qnil; 1844 return Qnil;
diff --git a/src/fontset.c b/src/fontset.c
index 35d4bfb367e..7b051cbe1f3 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1275,7 +1275,7 @@ free_realized_fontsets (Lisp_Object base)
1275 doesn't remove FACE from a cache. Until we find a solution, we 1275 doesn't remove FACE from a cache. Until we find a solution, we
1276 suppress this code, and simply use Fclear_face_cache even though 1276 suppress this code, and simply use Fclear_face_cache even though
1277 that is not efficient. */ 1277 that is not efficient. */
1278 BLOCK_INPUT; 1278 block_input ();
1279 for (id = 0; id < ASIZE (Vfontset_table); id++) 1279 for (id = 0; id < ASIZE (Vfontset_table); id++)
1280 { 1280 {
1281 Lisp_Object this = AREF (Vfontset_table, id); 1281 Lisp_Object this = AREF (Vfontset_table, id);
@@ -1296,7 +1296,7 @@ free_realized_fontsets (Lisp_Object base)
1296 } 1296 }
1297 } 1297 }
1298 } 1298 }
1299 UNBLOCK_INPUT; 1299 unblock_input ();
1300#else /* not 0 */ 1300#else /* not 0 */
1301 /* But, we don't have to call Fclear_face_cache if no fontset has 1301 /* But, we don't have to call Fclear_face_cache if no fontset has
1302 been realized from BASE. */ 1302 been realized from BASE. */
diff --git a/src/frame.c b/src/frame.c
index f3d16171516..4bcacef39c5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3533,9 +3533,9 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3533 f->alpha[i] = newval[i]; 3533 f->alpha[i] = newval[i];
3534 3534
3535#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) 3535#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3536 BLOCK_INPUT; 3536 block_input ();
3537 x_set_frame_alpha (f); 3537 x_set_frame_alpha (f);
3538 UNBLOCK_INPUT; 3538 unblock_input ();
3539#endif 3539#endif
3540 3540
3541 return; 3541 return;
diff --git a/src/frame.h b/src/frame.h
index 661ea2ea67c..26235cc036e 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1203,7 +1203,7 @@ extern Lisp_Object Qrun_hook_with_args;
1203extern void x_set_scroll_bar_default_width (struct frame *); 1203extern void x_set_scroll_bar_default_width (struct frame *);
1204extern void x_set_offset (struct frame *, int, int, int); 1204extern void x_set_offset (struct frame *, int, int, int);
1205extern void x_wm_set_icon_position (struct frame *, int, int); 1205extern void x_wm_set_icon_position (struct frame *, int, int);
1206extern void x_wm_set_size_hint (FRAME_PTR f, long flags, int user_position); 1206extern void x_wm_set_size_hint (FRAME_PTR f, long flags, bool user_position);
1207 1207
1208extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int); 1208extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1209 1209
@@ -1249,7 +1249,7 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
1249 Lisp_Object component, 1249 Lisp_Object component,
1250 Lisp_Object subclass); 1250 Lisp_Object subclass);
1251 1251
1252extern void set_frame_menubar (struct frame *f, int first_time, int deep_p); 1252extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1253extern void x_set_window_size (struct frame *f, int change_grav, 1253extern void x_set_window_size (struct frame *f, int change_grav,
1254 int cols, int rows); 1254 int cols, int rows);
1255extern void x_sync (struct frame *); 1255extern void x_sync (struct frame *);
@@ -1283,9 +1283,6 @@ extern char *x_get_resource_string (const char *, const char *);
1283 1283
1284extern void x_query_colors (struct frame *f, XColor *, int); 1284extern void x_query_colors (struct frame *f, XColor *, int);
1285 1285
1286/* In xmenu.c */
1287extern void set_frame_menubar (FRAME_PTR, int, int);
1288
1289#endif /* HAVE_WINDOW_SYSTEM */ 1286#endif /* HAVE_WINDOW_SYSTEM */
1290 1287
1291INLINE_HEADER_END 1288INLINE_HEADER_END
diff --git a/src/fringe.c b/src/fringe.c
index 6e6deeddb08..d788503e91e 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -872,7 +872,7 @@ draw_fringe_bitmap (struct window *w, struct glyph_row *row, int left_p)
872void 872void
873draw_row_fringe_bitmaps (struct window *w, struct glyph_row *row) 873draw_row_fringe_bitmaps (struct window *w, struct glyph_row *row)
874{ 874{
875 eassert (interrupt_input_blocked); 875 eassert (input_blocked_p ());
876 876
877 /* If row is completely invisible, because of vscrolling, we 877 /* If row is completely invisible, because of vscrolling, we
878 don't have to draw anything. */ 878 don't have to draw anything. */
diff --git a/src/ftxfont.c b/src/ftxfont.c
index 466250bd43f..5effe6e9104 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -98,7 +98,7 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba
98 new->colors[0].pixel = background; 98 new->colors[0].pixel = background;
99 new->colors[1].pixel = foreground; 99 new->colors[1].pixel = foreground;
100 100
101 BLOCK_INPUT; 101 block_input ();
102 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), new->colors, 2); 102 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), new->colors, 2);
103 for (i = 1; i < 7; i++) 103 for (i = 1; i < 7; i++)
104 { 104 {
@@ -115,14 +115,14 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba
115 new->gcs[i - 1] = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 115 new->gcs[i - 1] = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
116 GCForeground, &xgcv); 116 GCForeground, &xgcv);
117 } 117 }
118 UNBLOCK_INPUT; 118 unblock_input ();
119 119
120 if (i < 7) 120 if (i < 7)
121 { 121 {
122 BLOCK_INPUT; 122 block_input ();
123 for (i--; i >= 0; i--) 123 for (i--; i >= 0; i--)
124 XFreeGC (FRAME_X_DISPLAY (f), new->gcs[i]); 124 XFreeGC (FRAME_X_DISPLAY (f), new->gcs[i]);
125 UNBLOCK_INPUT; 125 unblock_input ();
126 if (prev) 126 if (prev)
127 prev->next = new->next; 127 prev->next = new->next;
128 else if (data) 128 else if (data)
@@ -282,7 +282,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
282 282
283 n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; 283 n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0;
284 284
285 BLOCK_INPUT; 285 block_input ();
286 if (with_background) 286 if (with_background)
287 ftxfont_draw_background (f, font, s->gc, x, y, s->width); 287 ftxfont_draw_background (f, font, s->gc, x, y, s->width);
288 code = alloca (sizeof (unsigned) * len); 288 code = alloca (sizeof (unsigned) * len);
@@ -332,7 +332,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
332 } 332 }
333 } 333 }
334 334
335 UNBLOCK_INPUT; 335 unblock_input ();
336 336
337 return len; 337 return len;
338} 338}
@@ -342,7 +342,7 @@ ftxfont_end_for_frame (FRAME_PTR f)
342{ 342{
343 struct ftxfont_frame_data *data = font_get_frame_data (f, &ftxfont_driver); 343 struct ftxfont_frame_data *data = font_get_frame_data (f, &ftxfont_driver);
344 344
345 BLOCK_INPUT; 345 block_input ();
346 while (data) 346 while (data)
347 { 347 {
348 struct ftxfont_frame_data *next = data->next; 348 struct ftxfont_frame_data *next = data->next;
@@ -353,7 +353,7 @@ ftxfont_end_for_frame (FRAME_PTR f)
353 free (data); 353 free (data);
354 data = next; 354 data = next;
355 } 355 }
356 UNBLOCK_INPUT; 356 unblock_input ();
357 font_put_frame_data (f, &ftxfont_driver, NULL); 357 font_put_frame_data (f, &ftxfont_driver, NULL);
358 return 0; 358 return 0;
359} 359}
diff --git a/src/gnutls.c b/src/gnutls.c
index 1c4693aee32..e3d84a0b61b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -30,15 +30,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include "w32.h" 30#include "w32.h"
31#endif 31#endif
32 32
33static int 33static bool emacs_gnutls_handle_error (gnutls_session_t, int);
34emacs_gnutls_handle_error (gnutls_session_t, int err);
35 34
36static Lisp_Object Qgnutls_dll; 35static Lisp_Object Qgnutls_dll;
37static Lisp_Object Qgnutls_code; 36static Lisp_Object Qgnutls_code;
38static Lisp_Object Qgnutls_anon, Qgnutls_x509pki; 37static Lisp_Object Qgnutls_anon, Qgnutls_x509pki;
39static Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again, 38static Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again,
40 Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake; 39 Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake;
41static int gnutls_global_initialized; 40static bool gnutls_global_initialized;
42 41
43/* The following are for the property list of `gnutls-boot'. */ 42/* The following are for the property list of `gnutls-boot'. */
44static Lisp_Object QCgnutls_bootprop_priority; 43static Lisp_Object QCgnutls_bootprop_priority;
@@ -141,13 +140,13 @@ DEF_GNUTLS_FN (int, gnutls_x509_crt_import,
141 gnutls_x509_crt_fmt_t)); 140 gnutls_x509_crt_fmt_t));
142DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); 141DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *));
143 142
144static int 143static bool
145init_gnutls_functions (Lisp_Object libraries) 144init_gnutls_functions (void)
146{ 145{
147 HMODULE library; 146 HMODULE library;
148 int max_log_level = 1; 147 int max_log_level = 1;
149 148
150 if (!(library = w32_delayed_load (libraries, Qgnutls_dll))) 149 if (!(library = w32_delayed_load (Qgnutls_dll)))
151 { 150 {
152 GNUTLS_LOG (1, max_log_level, "GnuTLS library not found"); 151 GNUTLS_LOG (1, max_log_level, "GnuTLS library not found");
153 return 0; 152 return 0;
@@ -438,7 +437,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
438 else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) 437 else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
439 /* The peer closed the connection. */ 438 /* The peer closed the connection. */
440 return 0; 439 return 0;
441 else if (emacs_gnutls_handle_error (state, rtnval) == 0) 440 else if (emacs_gnutls_handle_error (state, rtnval))
442 /* non-fatal error */ 441 /* non-fatal error */
443 return -1; 442 return -1;
444 else { 443 else {
@@ -447,19 +446,19 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
447 } 446 }
448} 447}
449 448
450/* report a GnuTLS error to the user. 449/* Report a GnuTLS error to the user.
451 Returns zero if the error code was successfully handled. */ 450 Return true if the error code was successfully handled. */
452static int 451static bool
453emacs_gnutls_handle_error (gnutls_session_t session, int err) 452emacs_gnutls_handle_error (gnutls_session_t session, int err)
454{ 453{
455 int max_log_level = 0; 454 int max_log_level = 0;
456 455
457 int ret; 456 bool ret;
458 const char *str; 457 const char *str;
459 458
460 /* TODO: use a Lisp_Object generated by gnutls_make_error? */ 459 /* TODO: use a Lisp_Object generated by gnutls_make_error? */
461 if (err >= 0) 460 if (err >= 0)
462 return 0; 461 return 1;
463 462
464 max_log_level = global_gnutls_log_level; 463 max_log_level = global_gnutls_log_level;
465 464
@@ -471,12 +470,12 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err)
471 470
472 if (fn_gnutls_error_is_fatal (err)) 471 if (fn_gnutls_error_is_fatal (err))
473 { 472 {
474 ret = err; 473 ret = 0;
475 GNUTLS_LOG2 (0, max_log_level, "fatal error:", str); 474 GNUTLS_LOG2 (0, max_log_level, "fatal error:", str);
476 } 475 }
477 else 476 else
478 { 477 {
479 ret = 0; 478 ret = 1;
480 GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str); 479 GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str);
481 /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2. */ 480 /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2. */
482 } 481 }
@@ -656,7 +655,7 @@ DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0,
656 else 655 else
657 { 656 {
658 Lisp_Object status; 657 Lisp_Object status;
659 status = init_gnutls_functions (Vdynamic_library_alist) ? Qt : Qnil; 658 status = init_gnutls_functions () ? Qt : Qnil;
660 Vlibrary_cache = Fcons (Fcons (Qgnutls_dll, status), Vlibrary_cache); 659 Vlibrary_cache = Fcons (Fcons (Qgnutls_dll, status), Vlibrary_cache);
661 return status; 660 return status;
662 } 661 }
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 1eb4b2cabdf..1bf2b533b41 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -576,21 +576,21 @@ get_utf8_string (const char *str)
576 576
577/* Check for special colors used in face spec for region face. 577/* Check for special colors used in face spec for region face.
578 The colors are fetched from the Gtk+ theme. 578 The colors are fetched from the Gtk+ theme.
579 Return 1 if color was found, 0 if not. */ 579 Return true if color was found, false if not. */
580 580
581int 581bool
582xg_check_special_colors (struct frame *f, 582xg_check_special_colors (struct frame *f,
583 const char *color_name, 583 const char *color_name,
584 XColor *color) 584 XColor *color)
585{ 585{
586 int success_p = 0; 586 bool success_p = 0;
587 int get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0; 587 bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0;
588 int get_fg = !get_bg && strcmp ("gtk_selection_fg_color", color_name) == 0; 588 bool get_fg = !get_bg && strcmp ("gtk_selection_fg_color", color_name) == 0;
589 589
590 if (! FRAME_GTK_WIDGET (f) || ! (get_bg || get_fg)) 590 if (! FRAME_GTK_WIDGET (f) || ! (get_bg || get_fg))
591 return success_p; 591 return success_p;
592 592
593 BLOCK_INPUT; 593 block_input ();
594 { 594 {
595#ifdef HAVE_GTK3 595#ifdef HAVE_GTK3
596 GtkStyleContext *gsty 596 GtkStyleContext *gsty
@@ -604,8 +604,9 @@ xg_check_special_colors (struct frame *f,
604 gtk_style_context_get_background_color (gsty, state, &col); 604 gtk_style_context_get_background_color (gsty, state, &col);
605 605
606 sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue); 606 sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
607 success_p = XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), 607 success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
608 buf, color); 608 buf, color)
609 != 0);
609#else 610#else
610 GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); 611 GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
611 GdkColor *grgb = get_bg 612 GdkColor *grgb = get_bg
@@ -620,7 +621,7 @@ xg_check_special_colors (struct frame *f,
620#endif 621#endif
621 622
622 } 623 }
623 UNBLOCK_INPUT; 624 unblock_input ();
624 return success_p; 625 return success_p;
625} 626}
626 627
@@ -703,9 +704,9 @@ qttip_cb (GtkWidget *widget,
703#endif /* USE_GTK_TOOLTIP */ 704#endif /* USE_GTK_TOOLTIP */
704 705
705/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT. 706/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT.
706 Return zero if no system tooltip available, non-zero otherwise. */ 707 Return true if a system tooltip is available. */
707 708
708int 709bool
709xg_prepare_tooltip (FRAME_PTR f, 710xg_prepare_tooltip (FRAME_PTR f,
710 Lisp_Object string, 711 Lisp_Object string,
711 int *width, 712 int *width,
@@ -725,7 +726,7 @@ xg_prepare_tooltip (FRAME_PTR f,
725 726
726 if (!x->ttip_lbl) return 0; 727 if (!x->ttip_lbl) return 0;
727 728
728 BLOCK_INPUT; 729 block_input ();
729 encoded_string = ENCODE_UTF_8 (string); 730 encoded_string = ENCODE_UTF_8 (string);
730 widget = GTK_WIDGET (x->ttip_lbl); 731 widget = GTK_WIDGET (x->ttip_lbl);
731 gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window)); 732 gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window));
@@ -753,7 +754,7 @@ xg_prepare_tooltip (FRAME_PTR f,
753 if (width) *width = req.width; 754 if (width) *width = req.width;
754 if (height) *height = req.height; 755 if (height) *height = req.height;
755 756
756 UNBLOCK_INPUT; 757 unblock_input ();
757 758
758 return 1; 759 return 1;
759#endif /* USE_GTK_TOOLTIP */ 760#endif /* USE_GTK_TOOLTIP */
@@ -769,27 +770,27 @@ xg_show_tooltip (FRAME_PTR f, int root_x, int root_y)
769 struct x_output *x = f->output_data.x; 770 struct x_output *x = f->output_data.x;
770 if (x->ttip_window) 771 if (x->ttip_window)
771 { 772 {
772 BLOCK_INPUT; 773 block_input ();
773 gtk_window_move (x->ttip_window, root_x, root_y); 774 gtk_window_move (x->ttip_window, root_x, root_y);
774 gtk_widget_show_all (GTK_WIDGET (x->ttip_window)); 775 gtk_widget_show_all (GTK_WIDGET (x->ttip_window));
775 UNBLOCK_INPUT; 776 unblock_input ();
776 } 777 }
777#endif 778#endif
778} 779}
779 780
780/* Hide tooltip if shown. Do nothing if not shown. 781/* Hide tooltip if shown. Do nothing if not shown.
781 Return non-zero if tip was hidden, non-zero if not (i.e. not using 782 Return true if tip was hidden, false if not (i.e. not using
782 system tooltips). */ 783 system tooltips). */
783 784
784int 785bool
785xg_hide_tooltip (FRAME_PTR f) 786xg_hide_tooltip (FRAME_PTR f)
786{ 787{
787 int ret = 0; 788 bool ret = 0;
788#ifdef USE_GTK_TOOLTIP 789#ifdef USE_GTK_TOOLTIP
789 if (f->output_data.x->ttip_window) 790 if (f->output_data.x->ttip_window)
790 { 791 {
791 GtkWindow *win = f->output_data.x->ttip_window; 792 GtkWindow *win = f->output_data.x->ttip_window;
792 BLOCK_INPUT; 793 block_input ();
793 gtk_widget_hide (GTK_WIDGET (win)); 794 gtk_widget_hide (GTK_WIDGET (win));
794 795
795 if (g_object_get_data (G_OBJECT (win), "restore-tt")) 796 if (g_object_get_data (G_OBJECT (win), "restore-tt"))
@@ -799,7 +800,7 @@ xg_hide_tooltip (FRAME_PTR f)
799 GtkSettings *settings = gtk_settings_get_for_screen (screen); 800 GtkSettings *settings = gtk_settings_get_for_screen (screen);
800 g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL); 801 g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL);
801 } 802 }
802 UNBLOCK_INPUT; 803 unblock_input ();
803 804
804 ret = 1; 805 ret = 1;
805 } 806 }
@@ -1007,7 +1008,7 @@ xg_win_to_widget (Display *dpy, Window wdesc)
1007 gpointer gdkwin; 1008 gpointer gdkwin;
1008 GtkWidget *gwdesc = 0; 1009 GtkWidget *gwdesc = 0;
1009 1010
1010 BLOCK_INPUT; 1011 block_input ();
1011 1012
1012 gdkwin = gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (dpy), 1013 gdkwin = gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (dpy),
1013 wdesc); 1014 wdesc);
@@ -1019,7 +1020,7 @@ xg_win_to_widget (Display *dpy, Window wdesc)
1019 gwdesc = gtk_get_event_widget (&event); 1020 gwdesc = gtk_get_event_widget (&event);
1020 } 1021 }
1021 1022
1022 UNBLOCK_INPUT; 1023 unblock_input ();
1023 return gwdesc; 1024 return gwdesc;
1024} 1025}
1025 1026
@@ -1110,9 +1111,9 @@ delete_cb (GtkWidget *widget,
1110} 1111}
1111 1112
1112/* Create and set up the GTK widgets for frame F. 1113/* Create and set up the GTK widgets for frame F.
1113 Return 0 if creation failed, non-zero otherwise. */ 1114 Return true if creation succeeded. */
1114 1115
1115int 1116bool
1116xg_create_frame_widgets (FRAME_PTR f) 1117xg_create_frame_widgets (FRAME_PTR f)
1117{ 1118{
1118 GtkWidget *wtop; 1119 GtkWidget *wtop;
@@ -1123,7 +1124,7 @@ xg_create_frame_widgets (FRAME_PTR f)
1123#endif 1124#endif
1124 char *title = 0; 1125 char *title = 0;
1125 1126
1126 BLOCK_INPUT; 1127 block_input ();
1127 1128
1128 if (FRAME_X_EMBEDDED_P (f)) 1129 if (FRAME_X_EMBEDDED_P (f))
1129 { 1130 {
@@ -1161,7 +1162,7 @@ xg_create_frame_widgets (FRAME_PTR f)
1161 if (whbox) gtk_widget_destroy (whbox); 1162 if (whbox) gtk_widget_destroy (whbox);
1162 if (wfixed) gtk_widget_destroy (wfixed); 1163 if (wfixed) gtk_widget_destroy (wfixed);
1163 1164
1164 UNBLOCK_INPUT; 1165 unblock_input ();
1165 return 0; 1166 return 0;
1166 } 1167 }
1167 1168
@@ -1275,7 +1276,7 @@ xg_create_frame_widgets (FRAME_PTR f)
1275 } 1276 }
1276 } 1277 }
1277 1278
1278 UNBLOCK_INPUT; 1279 unblock_input ();
1279 1280
1280 return 1; 1281 return 1;
1281} 1282}
@@ -1309,11 +1310,11 @@ xg_free_frame_widgets (FRAME_PTR f)
1309/* Set the normal size hints for the window manager, for frame F. 1310/* Set the normal size hints for the window manager, for frame F.
1310 FLAGS is the flags word to use--or 0 meaning preserve the flags 1311 FLAGS is the flags word to use--or 0 meaning preserve the flags
1311 that the window now has. 1312 that the window now has.
1312 If USER_POSITION is nonzero, we set the User Position 1313 If USER_POSITION, set the User Position
1313 flag (this is useful when FLAGS is 0). */ 1314 flag (this is useful when FLAGS is 0). */
1314 1315
1315void 1316void
1316x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position) 1317x_wm_set_size_hint (FRAME_PTR f, long int flags, bool user_position)
1317{ 1318{
1318 /* Must use GTK routines here, otherwise GTK resets the size hints 1319 /* Must use GTK routines here, otherwise GTK resets the size hints
1319 to its own defaults. */ 1320 to its own defaults. */
@@ -1397,12 +1398,12 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position)
1397 &f->output_data.x->size_hints, 1398 &f->output_data.x->size_hints,
1398 sizeof (size_hints)) != 0) 1399 sizeof (size_hints)) != 0)
1399 { 1400 {
1400 BLOCK_INPUT; 1401 block_input ();
1401 gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1402 gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1402 NULL, &size_hints, hint_flags); 1403 NULL, &size_hints, hint_flags);
1403 f->output_data.x->size_hints = size_hints; 1404 f->output_data.x->size_hints = size_hints;
1404 f->output_data.x->hint_flags = hint_flags; 1405 f->output_data.x->hint_flags = hint_flags;
1405 UNBLOCK_INPUT; 1406 unblock_input ();
1406 } 1407 }
1407} 1408}
1408 1409
@@ -1417,9 +1418,9 @@ xg_set_background_color (FRAME_PTR f, long unsigned int bg)
1417{ 1418{
1418 if (FRAME_GTK_WIDGET (f)) 1419 if (FRAME_GTK_WIDGET (f))
1419 { 1420 {
1420 BLOCK_INPUT; 1421 block_input ();
1421 xg_set_widget_bg (f, FRAME_GTK_WIDGET (f), FRAME_BACKGROUND_PIXEL (f)); 1422 xg_set_widget_bg (f, FRAME_GTK_WIDGET (f), FRAME_BACKGROUND_PIXEL (f));
1422 UNBLOCK_INPUT; 1423 unblock_input ();
1423 } 1424 }
1424} 1425}
1425 1426
@@ -1519,7 +1520,7 @@ create_dialog (widget_value *wv,
1519 1520
1520 /* If the number of buttons is greater than 4, make two rows of buttons 1521 /* If the number of buttons is greater than 4, make two rows of buttons
1521 instead. This looks better. */ 1522 instead. This looks better. */
1522 int make_two_rows = total_buttons > 4; 1523 bool make_two_rows = total_buttons > 4;
1523 1524
1524 if (right_buttons == 0) right_buttons = total_buttons/2; 1525 if (right_buttons == 0) right_buttons = total_buttons/2;
1525 left_buttons = total_buttons - right_buttons; 1526 left_buttons = total_buttons - right_buttons;
@@ -1637,14 +1638,14 @@ pop_down_dialog (Lisp_Object arg)
1637 struct Lisp_Save_Value *p = XSAVE_VALUE (arg); 1638 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1638 struct xg_dialog_data *dd = (struct xg_dialog_data *) p->pointer; 1639 struct xg_dialog_data *dd = (struct xg_dialog_data *) p->pointer;
1639 1640
1640 BLOCK_INPUT; 1641 block_input ();
1641 if (dd->w) gtk_widget_destroy (dd->w); 1642 if (dd->w) gtk_widget_destroy (dd->w);
1642 if (dd->timerid != 0) g_source_remove (dd->timerid); 1643 if (dd->timerid != 0) g_source_remove (dd->timerid);
1643 1644
1644 g_main_loop_quit (dd->loop); 1645 g_main_loop_quit (dd->loop);
1645 g_main_loop_unref (dd->loop); 1646 g_main_loop_unref (dd->loop);
1646 1647
1647 UNBLOCK_INPUT; 1648 unblock_input ();
1648 1649
1649 return Qnil; 1650 return Qnil;
1650} 1651}
@@ -1716,10 +1717,9 @@ xg_dialog_run (FRAME_PTR f, GtkWidget *w)
1716/*********************************************************************** 1717/***********************************************************************
1717 File dialog functions 1718 File dialog functions
1718 ***********************************************************************/ 1719 ***********************************************************************/
1719/* Return non-zero if the old file selection dialog is being used. 1720/* Return true if the old file selection dialog is being used. */
1720 Return zero if not. */
1721 1721
1722int 1722bool
1723xg_uses_old_file_dialog (void) 1723xg_uses_old_file_dialog (void)
1724{ 1724{
1725#ifdef HAVE_GTK_FILE_SELECTION_NEW 1725#ifdef HAVE_GTK_FILE_SELECTION_NEW
@@ -1790,7 +1790,7 @@ xg_toggle_notify_cb (GObject *gobject, GParamSpec *arg1, gpointer user_data)
1790 F is the current frame. 1790 F is the current frame.
1791 PROMPT is a prompt to show to the user. May not be NULL. 1791 PROMPT is a prompt to show to the user. May not be NULL.
1792 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. 1792 DEFAULT_FILENAME is a default selection to be displayed. May be NULL.
1793 If MUSTMATCH_P is non-zero, the returned file name must be an existing 1793 If MUSTMATCH_P, the returned file name must be an existing
1794 file. (Actually, this only has cosmetic effects, the user can 1794 file. (Actually, this only has cosmetic effects, the user can
1795 still enter a non-existing file.) *FUNC is set to a function that 1795 still enter a non-existing file.) *FUNC is set to a function that
1796 can be used to retrieve the selected file name from the returned widget. 1796 can be used to retrieve the selected file name from the returned widget.
@@ -1801,7 +1801,7 @@ static GtkWidget *
1801xg_get_file_with_chooser (FRAME_PTR f, 1801xg_get_file_with_chooser (FRAME_PTR f,
1802 char *prompt, 1802 char *prompt,
1803 char *default_filename, 1803 char *default_filename,
1804 int mustmatch_p, int only_dir_p, 1804 bool mustmatch_p, bool only_dir_p,
1805 xg_get_file_func *func) 1805 xg_get_file_func *func)
1806{ 1806{
1807 char msgbuf[1024]; 1807 char msgbuf[1024];
@@ -1913,7 +1913,7 @@ xg_get_file_name_from_selector (GtkWidget *w)
1913 F is the current frame. 1913 F is the current frame.
1914 PROMPT is a prompt to show to the user. May not be NULL. 1914 PROMPT is a prompt to show to the user. May not be NULL.
1915 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. 1915 DEFAULT_FILENAME is a default selection to be displayed. May be NULL.
1916 If MUSTMATCH_P is non-zero, the returned file name must be an existing 1916 If MUSTMATCH_P, the returned file name must be an existing
1917 file. *FUNC is set to a function that can be used to retrieve the 1917 file. *FUNC is set to a function that can be used to retrieve the
1918 selected file name from the returned widget. 1918 selected file name from the returned widget.
1919 1919
@@ -1923,7 +1923,7 @@ static GtkWidget *
1923xg_get_file_with_selection (FRAME_PTR f, 1923xg_get_file_with_selection (FRAME_PTR f,
1924 char *prompt, 1924 char *prompt,
1925 char *default_filename, 1925 char *default_filename,
1926 int mustmatch_p, int only_dir_p, 1926 bool mustmatch_p, bool only_dir_p,
1927 xg_get_file_func *func) 1927 xg_get_file_func *func)
1928{ 1928{
1929 GtkWidget *filewin; 1929 GtkWidget *filewin;
@@ -1955,7 +1955,7 @@ xg_get_file_with_selection (FRAME_PTR f,
1955 F is the current frame. 1955 F is the current frame.
1956 PROMPT is a prompt to show to the user. May not be NULL. 1956 PROMPT is a prompt to show to the user. May not be NULL.
1957 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. 1957 DEFAULT_FILENAME is a default selection to be displayed. May be NULL.
1958 If MUSTMATCH_P is non-zero, the returned file name must be an existing 1958 If MUSTMATCH_P, the returned file name must be an existing
1959 file. 1959 file.
1960 1960
1961 Returns a file name or NULL if no file was selected. 1961 Returns a file name or NULL if no file was selected.
@@ -1965,24 +1965,14 @@ char *
1965xg_get_file_name (FRAME_PTR f, 1965xg_get_file_name (FRAME_PTR f,
1966 char *prompt, 1966 char *prompt,
1967 char *default_filename, 1967 char *default_filename,
1968 int mustmatch_p, 1968 bool mustmatch_p,
1969 int only_dir_p) 1969 bool only_dir_p)
1970{ 1970{
1971 GtkWidget *w = 0; 1971 GtkWidget *w = 0;
1972 char *fn = 0; 1972 char *fn = 0;
1973 int filesel_done = 0; 1973 int filesel_done = 0;
1974 xg_get_file_func func; 1974 xg_get_file_func func;
1975 1975
1976#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
1977 /* I really don't know why this is needed, but without this the GLIBC add on
1978 library linuxthreads hangs when the Gnome file chooser backend creates
1979 threads. */
1980 sigset_t blocked;
1981 sigemptyset (&blocked);
1982 sigaddset (&blocked, __SIGRTMIN);
1983 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1984#endif /* HAVE_PTHREAD */
1985
1986#ifdef HAVE_GTK_FILE_SELECTION_NEW 1976#ifdef HAVE_GTK_FILE_SELECTION_NEW
1987 1977
1988 if (xg_uses_old_file_dialog ()) 1978 if (xg_uses_old_file_dialog ())
@@ -2000,11 +1990,6 @@ xg_get_file_name (FRAME_PTR f,
2000 gtk_widget_set_name (w, "emacs-filedialog"); 1990 gtk_widget_set_name (w, "emacs-filedialog");
2001 1991
2002 filesel_done = xg_dialog_run (f, w); 1992 filesel_done = xg_dialog_run (f, w);
2003
2004#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2005 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2006#endif
2007
2008 if (filesel_done == GTK_RESPONSE_OK) 1993 if (filesel_done == GTK_RESPONSE_OK)
2009 fn = (*func) (w); 1994 fn = (*func) (w);
2010 1995
@@ -2057,13 +2042,6 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2057 int done = 0; 2042 int done = 0;
2058 Lisp_Object font = Qnil; 2043 Lisp_Object font = Qnil;
2059 2044
2060#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2061 sigset_t blocked;
2062 sigemptyset (&blocked);
2063 sigaddset (&blocked, __SIGRTMIN);
2064 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2065#endif /* HAVE_PTHREAD */
2066
2067 w = gtk_font_chooser_dialog_new 2045 w = gtk_font_chooser_dialog_new
2068 ("Pick a font", GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 2046 ("Pick a font", GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
2069 2047
@@ -2088,11 +2066,6 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2088 2066
2089 gtk_widget_set_name (w, "emacs-fontdialog"); 2067 gtk_widget_set_name (w, "emacs-fontdialog");
2090 done = xg_dialog_run (f, w); 2068 done = xg_dialog_run (f, w);
2091
2092#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2093 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2094#endif
2095
2096 if (done == GTK_RESPONSE_OK) 2069 if (done == GTK_RESPONSE_OK)
2097 { 2070 {
2098#if USE_NEW_GTK_FONT_CHOOSER 2071#if USE_NEW_GTK_FONT_CHOOSER
@@ -2430,9 +2403,9 @@ make_menu_item (const char *utf8_label,
2430 2403
2431static int xg_detached_menus; 2404static int xg_detached_menus;
2432 2405
2433/* Returns non-zero if there are detached menus. */ 2406/* Return true if there are detached menus. */
2434 2407
2435int 2408bool
2436xg_have_tear_offs (void) 2409xg_have_tear_offs (void)
2437{ 2410{
2438 return xg_detached_menus > 0; 2411 return xg_detached_menus > 0;
@@ -2536,10 +2509,9 @@ xg_create_one_menuitem (widget_value *item,
2536 SELECT_CB is the callback to use when a menu item is selected. 2509 SELECT_CB is the callback to use when a menu item is selected.
2537 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. 2510 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore.
2538 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 2511 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
2539 POP_UP_P is non-zero if we shall create a popup menu. 2512 If POP_UP_P, create a popup menu.
2540 MENU_BAR_P is non-zero if we shall create a menu bar. 2513 If MENU_BAR_P, create a menu bar.
2541 ADD_TEAROFF_P is non-zero if we shall add a tearoff menu item. Ignored 2514 If ADD_TEAROFF_P, add a tearoff menu item. Ignored if MENU_BAR_P.
2542 if MENU_BAR_P is non-zero.
2543 TOPMENU is the topmost GtkWidget that others shall be placed under. 2515 TOPMENU is the topmost GtkWidget that others shall be placed under.
2544 It may be NULL, in that case we create the appropriate widget 2516 It may be NULL, in that case we create the appropriate widget
2545 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P) 2517 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P)
@@ -2559,9 +2531,9 @@ create_menus (widget_value *data,
2559 GCallback select_cb, 2531 GCallback select_cb,
2560 GCallback deactivate_cb, 2532 GCallback deactivate_cb,
2561 GCallback highlight_cb, 2533 GCallback highlight_cb,
2562 int pop_up_p, 2534 bool pop_up_p,
2563 int menu_bar_p, 2535 bool menu_bar_p,
2564 int add_tearoff_p, 2536 bool add_tearoff_p,
2565 GtkWidget *topmenu, 2537 GtkWidget *topmenu,
2566 xg_menu_cb_data *cl_data, 2538 xg_menu_cb_data *cl_data,
2567 const char *name) 2539 const char *name)
@@ -2701,8 +2673,8 @@ xg_create_widget (const char *type, const char *name, FRAME_PTR f, widget_value
2701 GCallback highlight_cb) 2673 GCallback highlight_cb)
2702{ 2674{
2703 GtkWidget *w = 0; 2675 GtkWidget *w = 0;
2704 int menu_bar_p = strcmp (type, "menubar") == 0; 2676 bool menu_bar_p = strcmp (type, "menubar") == 0;
2705 int pop_up_p = strcmp (type, "popup") == 0; 2677 bool pop_up_p = strcmp (type, "popup") == 0;
2706 2678
2707 if (strcmp (type, "dialog") == 0) 2679 if (strcmp (type, "dialog") == 0)
2708 { 2680 {
@@ -2755,12 +2727,12 @@ xg_get_menu_item_label (GtkMenuItem *witem)
2755 return gtk_label_get_label (wlabel); 2727 return gtk_label_get_label (wlabel);
2756} 2728}
2757 2729
2758/* Return non-zero if the menu item WITEM has the text LABEL. */ 2730/* Return true if the menu item WITEM has the text LABEL. */
2759 2731
2760static int 2732static bool
2761xg_item_label_same_p (GtkMenuItem *witem, const char *label) 2733xg_item_label_same_p (GtkMenuItem *witem, const char *label)
2762{ 2734{
2763 int is_same = 0; 2735 bool is_same = 0;
2764 char *utf8_label = get_utf8_string (label); 2736 char *utf8_label = get_utf8_string (label);
2765 const char *old_label = witem ? xg_get_menu_item_label (witem) : 0; 2737 const char *old_label = witem ? xg_get_menu_item_label (witem) : 0;
2766 2738
@@ -2851,8 +2823,8 @@ xg_update_menubar (GtkWidget *menubar,
2851 { 2823 {
2852 GtkMenuItem *witem = GTK_MENU_ITEM (iter->data); 2824 GtkMenuItem *witem = GTK_MENU_ITEM (iter->data);
2853 GtkMenuItem *witem2 = 0; 2825 GtkMenuItem *witem2 = 0;
2854 int val_in_menubar = 0; 2826 bool val_in_menubar = 0;
2855 int iter_in_new_menubar = 0; 2827 bool iter_in_new_menubar = 0;
2856 GList *iter2; 2828 GList *iter2;
2857 widget_value *cur; 2829 widget_value *cur;
2858 2830
@@ -3130,7 +3102,7 @@ xg_update_submenu (GtkWidget *submenu,
3130 GList *list = 0; 3102 GList *list = 0;
3131 GList *iter; 3103 GList *iter;
3132 widget_value *cur; 3104 widget_value *cur;
3133 int has_tearoff_p = 0; 3105 bool has_tearoff_p = 0;
3134 GList *first_radio = 0; 3106 GList *first_radio = 0;
3135 3107
3136 if (submenu) 3108 if (submenu)
@@ -3252,7 +3224,7 @@ xg_update_submenu (GtkWidget *submenu,
3252/* Update the MENUBAR. 3224/* Update the MENUBAR.
3253 F is the frame the menu bar belongs to. 3225 F is the frame the menu bar belongs to.
3254 VAL describes the contents of the menu bar. 3226 VAL describes the contents of the menu bar.
3255 If DEEP_P is non-zero, rebuild all but the top level menu names in 3227 If DEEP_P, rebuild all but the top level menu names in
3256 the MENUBAR. If DEEP_P is zero, just rebuild the names in the menubar. 3228 the MENUBAR. If DEEP_P is zero, just rebuild the names in the menubar.
3257 SELECT_CB is the callback to use when a menu item is selected. 3229 SELECT_CB is the callback to use when a menu item is selected.
3258 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. 3230 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore.
@@ -3260,7 +3232,7 @@ xg_update_submenu (GtkWidget *submenu,
3260 3232
3261void 3233void
3262xg_modify_menubar_widgets (GtkWidget *menubar, FRAME_PTR f, widget_value *val, 3234xg_modify_menubar_widgets (GtkWidget *menubar, FRAME_PTR f, widget_value *val,
3263 int deep_p, 3235 bool deep_p,
3264 GCallback select_cb, GCallback deactivate_cb, 3236 GCallback select_cb, GCallback deactivate_cb,
3265 GCallback highlight_cb) 3237 GCallback highlight_cb)
3266{ 3238{
@@ -3344,21 +3316,21 @@ menubar_map_cb (GtkWidget *w, gpointer user_data)
3344} 3316}
3345 3317
3346/* Recompute all the widgets of frame F, when the menu bar has been 3318/* Recompute all the widgets of frame F, when the menu bar has been
3347 changed. Value is non-zero if widgets were updated. */ 3319 changed. */
3348 3320
3349int 3321void
3350xg_update_frame_menubar (FRAME_PTR f) 3322xg_update_frame_menubar (FRAME_PTR f)
3351{ 3323{
3352 struct x_output *x = f->output_data.x; 3324 struct x_output *x = f->output_data.x;
3353 GtkRequisition req; 3325 GtkRequisition req;
3354 3326
3355 if (!x->menubar_widget || gtk_widget_get_mapped (x->menubar_widget)) 3327 if (!x->menubar_widget || gtk_widget_get_mapped (x->menubar_widget))
3356 return 0; 3328 return;
3357 3329
3358 if (x->menubar_widget && gtk_widget_get_parent (x->menubar_widget)) 3330 if (x->menubar_widget && gtk_widget_get_parent (x->menubar_widget))
3359 return 0; /* Already done this, happens for frames created invisible. */ 3331 return; /* Already done this, happens for frames created invisible. */
3360 3332
3361 BLOCK_INPUT; 3333 block_input ();
3362 3334
3363 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->menubar_widget, 3335 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->menubar_widget,
3364 FALSE, FALSE, 0); 3336 FALSE, FALSE, 0);
@@ -3378,9 +3350,7 @@ xg_update_frame_menubar (FRAME_PTR f)
3378 FRAME_MENUBAR_HEIGHT (f) = req.height; 3350 FRAME_MENUBAR_HEIGHT (f) = req.height;
3379 xg_height_or_width_changed (f); 3351 xg_height_or_width_changed (f);
3380 } 3352 }
3381 UNBLOCK_INPUT; 3353 unblock_input ();
3382
3383 return 1;
3384} 3354}
3385 3355
3386/* Get rid of the menu bar of frame F, and free its storage. 3356/* Get rid of the menu bar of frame F, and free its storage.
@@ -3393,7 +3363,7 @@ free_frame_menubar (FRAME_PTR f)
3393 3363
3394 if (x->menubar_widget) 3364 if (x->menubar_widget)
3395 { 3365 {
3396 BLOCK_INPUT; 3366 block_input ();
3397 3367
3398 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), x->menubar_widget); 3368 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), x->menubar_widget);
3399 /* The menubar and its children shall be deleted when removed from 3369 /* The menubar and its children shall be deleted when removed from
@@ -3401,11 +3371,11 @@ free_frame_menubar (FRAME_PTR f)
3401 x->menubar_widget = 0; 3371 x->menubar_widget = 0;
3402 FRAME_MENUBAR_HEIGHT (f) = 0; 3372 FRAME_MENUBAR_HEIGHT (f) = 0;
3403 xg_height_or_width_changed (f); 3373 xg_height_or_width_changed (f);
3404 UNBLOCK_INPUT; 3374 unblock_input ();
3405 } 3375 }
3406} 3376}
3407 3377
3408int 3378bool
3409xg_event_is_for_menubar (FRAME_PTR f, XEvent *event) 3379xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
3410{ 3380{
3411 struct x_output *x = f->output_data.x; 3381 struct x_output *x = f->output_data.x;
@@ -3452,7 +3422,7 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
3452 break; 3422 break;
3453 } 3423 }
3454 g_list_free (list); 3424 g_list_free (list);
3455 return iter == 0 ? 0 : 1; 3425 return iter != 0;
3456} 3426}
3457 3427
3458 3428
@@ -3465,7 +3435,7 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
3465/* Setting scroll bar values invokes the callback. Use this variable 3435/* Setting scroll bar values invokes the callback. Use this variable
3466 to indicate that callback should do nothing. */ 3436 to indicate that callback should do nothing. */
3467 3437
3468int xg_ignore_gtk_scrollbar; 3438bool xg_ignore_gtk_scrollbar;
3469 3439
3470/* The width of the scroll bar for the current theme. */ 3440/* The width of the scroll bar for the current theme. */
3471 3441
@@ -3791,7 +3761,7 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
3791 int size, value; 3761 int size, value;
3792 int old_size; 3762 int old_size;
3793 int new_step; 3763 int new_step;
3794 int changed = 0; 3764 bool changed = 0;
3795 3765
3796 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll)); 3766 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll));
3797 3767
@@ -3838,7 +3808,7 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
3838 3808
3839 if (changed || int_gtk_range_get_value (GTK_RANGE (wscroll)) != value) 3809 if (changed || int_gtk_range_get_value (GTK_RANGE (wscroll)) != value)
3840 { 3810 {
3841 BLOCK_INPUT; 3811 block_input ();
3842 3812
3843 /* gtk_range_set_value invokes the callback. Set 3813 /* gtk_range_set_value invokes the callback. Set
3844 ignore_gtk_scrollbar to make the callback do nothing */ 3814 ignore_gtk_scrollbar to make the callback do nothing */
@@ -3851,22 +3821,20 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
3851 3821
3852 xg_ignore_gtk_scrollbar = 0; 3822 xg_ignore_gtk_scrollbar = 0;
3853 3823
3854 UNBLOCK_INPUT; 3824 unblock_input ();
3855 } 3825 }
3856 } 3826 }
3857} 3827}
3858 3828
3859/* Return non-zero if EVENT is for a scroll bar in frame F. 3829/* Return true if EVENT is for a scroll bar in frame F.
3860 When the same X window is used for several Gtk+ widgets, we cannot 3830 When the same X window is used for several Gtk+ widgets, we cannot
3861 say for sure based on the X window alone if an event is for the 3831 say for sure based on the X window alone if an event is for the
3862 frame. This function does additional checks. 3832 frame. This function does additional checks. */
3863 3833
3864 Return non-zero if the event is for a scroll bar, zero otherwise. */ 3834bool
3865
3866int
3867xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event) 3835xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event)
3868{ 3836{
3869 int retval = 0; 3837 bool retval = 0;
3870 3838
3871 if (f && event->type == ButtonPress && event->xbutton.button < 4) 3839 if (f && event->type == ButtonPress && event->xbutton.button < 4)
3872 { 3840 {
@@ -4297,7 +4265,7 @@ static void
4297xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos) 4265xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
4298{ 4266{
4299 struct x_output *x = f->output_data.x; 4267 struct x_output *x = f->output_data.x;
4300 int into_hbox = EQ (pos, Qleft) || EQ (pos, Qright); 4268 bool into_hbox = EQ (pos, Qleft) || EQ (pos, Qright);
4301 4269
4302 toolbar_set_orientation (x->toolbar_widget, 4270 toolbar_set_orientation (x->toolbar_widget,
4303 into_hbox 4271 into_hbox
@@ -4329,7 +4297,7 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
4329 } 4297 }
4330 else 4298 else
4331 { 4299 {
4332 int vbox_pos = x->menubar_widget ? 1 : 0; 4300 bool vbox_pos = x->menubar_widget != 0;
4333 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), 4301 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
4334 GTK_POS_LEFT); 4302 GTK_POS_LEFT);
4335 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, 4303 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget,
@@ -4420,7 +4388,7 @@ xg_make_tool_item (FRAME_PTR f,
4420 GtkWidget *wimage, 4388 GtkWidget *wimage,
4421 GtkWidget **wbutton, 4389 GtkWidget **wbutton,
4422 const char *label, 4390 const char *label,
4423 int i, int horiz, int text_image) 4391 int i, bool horiz, bool text_image)
4424{ 4392{
4425 GtkToolItem *ti = gtk_tool_item_new (); 4393 GtkToolItem *ti = gtk_tool_item_new ();
4426 GtkWidget *vb = gtk_box_new (horiz 4394 GtkWidget *vb = gtk_box_new (horiz
@@ -4515,11 +4483,11 @@ xg_make_tool_item (FRAME_PTR f,
4515 return ti; 4483 return ti;
4516} 4484}
4517 4485
4518static int 4486static bool
4519is_box_type (GtkWidget *vb, int is_horizontal) 4487is_box_type (GtkWidget *vb, bool is_horizontal)
4520{ 4488{
4521#ifdef HAVE_GTK3 4489#ifdef HAVE_GTK3
4522 int ret = 0; 4490 bool ret = 0;
4523 if (GTK_IS_BOX (vb)) 4491 if (GTK_IS_BOX (vb))
4524 { 4492 {
4525 GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE (vb)); 4493 GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE (vb));
@@ -4533,10 +4501,10 @@ is_box_type (GtkWidget *vb, int is_horizontal)
4533} 4501}
4534 4502
4535 4503
4536static int 4504static bool
4537xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name, 4505xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
4538 const char *icon_name, const struct image *img, 4506 const char *icon_name, const struct image *img,
4539 const char *label, int horiz) 4507 const char *label, bool horiz)
4540{ 4508{
4541 gpointer old; 4509 gpointer old;
4542 GtkWidget *wimage; 4510 GtkWidget *wimage;
@@ -4578,7 +4546,7 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
4578 return 0; 4546 return 0;
4579} 4547}
4580 4548
4581static int 4549static bool
4582xg_update_tool_bar_sizes (FRAME_PTR f) 4550xg_update_tool_bar_sizes (FRAME_PTR f)
4583{ 4551{
4584 struct x_output *x = f->output_data.x; 4552 struct x_output *x = f->output_data.x;
@@ -4634,15 +4602,15 @@ update_frame_tool_bar (FRAME_PTR f)
4634 GtkToolbar *wtoolbar; 4602 GtkToolbar *wtoolbar;
4635 GtkToolItem *ti; 4603 GtkToolItem *ti;
4636 GtkTextDirection dir; 4604 GtkTextDirection dir;
4637 int pack_tool_bar = x->handlebox_widget == NULL; 4605 bool pack_tool_bar = x->handlebox_widget == NULL;
4638 Lisp_Object style; 4606 Lisp_Object style;
4639 int text_image, horiz; 4607 bool text_image, horiz;
4640 struct xg_frame_tb_info *tbinfo; 4608 struct xg_frame_tb_info *tbinfo;
4641 4609
4642 if (! FRAME_GTK_WIDGET (f)) 4610 if (! FRAME_GTK_WIDGET (f))
4643 return; 4611 return;
4644 4612
4645 BLOCK_INPUT; 4613 block_input ();
4646 4614
4647 if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) 4615 if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX))
4648 { 4616 {
@@ -4684,7 +4652,7 @@ update_frame_tool_bar (FRAME_PTR f)
4684 && ! NILP (Fequal (tbinfo->style, style)) 4652 && ! NILP (Fequal (tbinfo->style, style))
4685 && ! NILP (Fequal (tbinfo->last_tool_bar, f->tool_bar_items))) 4653 && ! NILP (Fequal (tbinfo->last_tool_bar, f->tool_bar_items)))
4686 { 4654 {
4687 UNBLOCK_INPUT; 4655 unblock_input ();
4688 return; 4656 return;
4689 } 4657 }
4690 4658
@@ -4700,8 +4668,8 @@ update_frame_tool_bar (FRAME_PTR f)
4700 4668
4701 for (i = j = 0; i < f->n_tool_bar_items; ++i) 4669 for (i = j = 0; i < f->n_tool_bar_items; ++i)
4702 { 4670 {
4703 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); 4671 bool enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
4704 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); 4672 bool selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
4705 int idx; 4673 int idx;
4706 ptrdiff_t img_id; 4674 ptrdiff_t img_id;
4707 int icon_size = 0; 4675 int icon_size = 0;
@@ -4714,7 +4682,7 @@ update_frame_tool_bar (FRAME_PTR f)
4714 Lisp_Object rtl; 4682 Lisp_Object rtl;
4715 GtkWidget *wbutton = NULL; 4683 GtkWidget *wbutton = NULL;
4716 Lisp_Object specified_file; 4684 Lisp_Object specified_file;
4717 int vert_only = ! NILP (PROP (TOOL_BAR_ITEM_VERT_ONLY)); 4685 bool vert_only = ! NILP (PROP (TOOL_BAR_ITEM_VERT_ONLY));
4718 const char *label 4686 const char *label
4719 = (EQ (style, Qimage) || (vert_only && horiz)) ? NULL 4687 = (EQ (style, Qimage) || (vert_only && horiz)) ? NULL
4720 : STRINGP (PROP (TOOL_BAR_ITEM_LABEL)) 4688 : STRINGP (PROP (TOOL_BAR_ITEM_LABEL))
@@ -4895,7 +4863,7 @@ update_frame_tool_bar (FRAME_PTR f)
4895 xg_height_or_width_changed (f); 4863 xg_height_or_width_changed (f);
4896 } 4864 }
4897 4865
4898 UNBLOCK_INPUT; 4866 unblock_input ();
4899} 4867}
4900 4868
4901/* Deallocate all resources for the tool bar on frame F. 4869/* Deallocate all resources for the tool bar on frame F.
@@ -4909,8 +4877,8 @@ free_frame_tool_bar (FRAME_PTR f)
4909 if (x->toolbar_widget) 4877 if (x->toolbar_widget)
4910 { 4878 {
4911 struct xg_frame_tb_info *tbinfo; 4879 struct xg_frame_tb_info *tbinfo;
4912 int is_packed = x->handlebox_widget != 0; 4880 bool is_packed = x->handlebox_widget != 0;
4913 BLOCK_INPUT; 4881 block_input ();
4914 /* We may have created the toolbar_widget in xg_create_tool_bar, but 4882 /* We may have created the toolbar_widget in xg_create_tool_bar, but
4915 not the x->handlebox_widget which is created in xg_pack_tool_bar. */ 4883 not the x->handlebox_widget which is created in xg_pack_tool_bar. */
4916 if (is_packed) 4884 if (is_packed)
@@ -4942,19 +4910,19 @@ free_frame_tool_bar (FRAME_PTR f)
4942 4910
4943 xg_height_or_width_changed (f); 4911 xg_height_or_width_changed (f);
4944 4912
4945 UNBLOCK_INPUT; 4913 unblock_input ();
4946 } 4914 }
4947} 4915}
4948 4916
4949int 4917void
4950xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos) 4918xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos)
4951{ 4919{
4952 struct x_output *x = f->output_data.x; 4920 struct x_output *x = f->output_data.x;
4953 4921
4954 if (! x->toolbar_widget || ! x->handlebox_widget) 4922 if (! x->toolbar_widget || ! x->handlebox_widget)
4955 return 1; 4923 return;
4956 4924
4957 BLOCK_INPUT; 4925 block_input ();
4958 g_object_ref (x->handlebox_widget); 4926 g_object_ref (x->handlebox_widget);
4959 if (x->toolbar_in_hbox) 4927 if (x->toolbar_in_hbox)
4960 gtk_container_remove (GTK_CONTAINER (x->hbox_widget), 4928 gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
@@ -4967,8 +4935,7 @@ xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos)
4967 if (xg_update_tool_bar_sizes (f)) 4935 if (xg_update_tool_bar_sizes (f))
4968 xg_height_or_width_changed (f); 4936 xg_height_or_width_changed (f);
4969 4937
4970 UNBLOCK_INPUT; 4938 unblock_input ();
4971 return 1;
4972} 4939}
4973 4940
4974 4941
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 926478dd728..43f2b237a68 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -79,13 +79,13 @@ struct _widget_value;
79extern struct _widget_value *malloc_widget_value (void); 79extern struct _widget_value *malloc_widget_value (void);
80extern void free_widget_value (struct _widget_value *); 80extern void free_widget_value (struct _widget_value *);
81 81
82extern int xg_uses_old_file_dialog (void) ATTRIBUTE_CONST; 82extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
83 83
84extern char *xg_get_file_name (FRAME_PTR f, 84extern char *xg_get_file_name (FRAME_PTR f,
85 char *prompt, 85 char *prompt,
86 char *default_filename, 86 char *default_filename,
87 int mustmatch_p, 87 bool mustmatch_p,
88 int only_dir_p); 88 bool only_dir_p);
89 89
90extern Lisp_Object xg_get_font (FRAME_PTR f, const char *); 90extern Lisp_Object xg_get_font (FRAME_PTR f, const char *);
91 91
@@ -100,16 +100,16 @@ extern GtkWidget *xg_create_widget (const char *type,
100extern void xg_modify_menubar_widgets (GtkWidget *menubar, 100extern void xg_modify_menubar_widgets (GtkWidget *menubar,
101 FRAME_PTR f, 101 FRAME_PTR f,
102 struct _widget_value *val, 102 struct _widget_value *val,
103 int deep_p, 103 bool deep_p,
104 GCallback select_cb, 104 GCallback select_cb,
105 GCallback deactivate_cb, 105 GCallback deactivate_cb,
106 GCallback highlight_cb); 106 GCallback highlight_cb);
107 107
108extern int xg_update_frame_menubar (FRAME_PTR f); 108extern void xg_update_frame_menubar (FRAME_PTR f);
109 109
110extern int xg_event_is_for_menubar (FRAME_PTR f, XEvent *event); 110extern bool xg_event_is_for_menubar (FRAME_PTR f, XEvent *event);
111 111
112extern int xg_have_tear_offs (void); 112extern bool xg_have_tear_offs (void);
113 113
114extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid); 114extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
115 115
@@ -131,12 +131,12 @@ extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
131 int portion, 131 int portion,
132 int position, 132 int position,
133 int whole); 133 int whole);
134extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); 134extern bool xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event);
135extern int xg_get_default_scrollbar_width (void); 135extern int xg_get_default_scrollbar_width (void);
136 136
137extern void update_frame_tool_bar (FRAME_PTR f); 137extern void update_frame_tool_bar (FRAME_PTR f);
138extern void free_frame_tool_bar (FRAME_PTR f); 138extern void free_frame_tool_bar (FRAME_PTR f);
139extern int xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos); 139extern void xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos);
140 140
141extern void xg_frame_resized (FRAME_PTR f, 141extern void xg_frame_resized (FRAME_PTR f,
142 int pixelwidth, 142 int pixelwidth,
@@ -148,23 +148,23 @@ extern void xg_display_open (char *display_name, Display **dpy);
148extern void xg_display_close (Display *dpy); 148extern void xg_display_close (Display *dpy);
149extern GdkCursor * xg_create_default_cursor (Display *dpy); 149extern GdkCursor * xg_create_default_cursor (Display *dpy);
150 150
151extern int xg_create_frame_widgets (FRAME_PTR f); 151extern bool xg_create_frame_widgets (FRAME_PTR f);
152extern void xg_free_frame_widgets (FRAME_PTR f); 152extern void xg_free_frame_widgets (FRAME_PTR f);
153extern void xg_set_background_color (FRAME_PTR f, unsigned long bg); 153extern void xg_set_background_color (FRAME_PTR f, unsigned long bg);
154extern int xg_check_special_colors (struct frame *f, 154extern bool xg_check_special_colors (struct frame *f,
155 const char *color_name, 155 const char *color_name,
156 XColor *color); 156 XColor *color);
157 157
158extern void xg_set_frame_icon (FRAME_PTR f, 158extern void xg_set_frame_icon (FRAME_PTR f,
159 Pixmap icon_pixmap, 159 Pixmap icon_pixmap,
160 Pixmap icon_mask); 160 Pixmap icon_mask);
161 161
162extern int xg_prepare_tooltip (FRAME_PTR f, 162extern bool xg_prepare_tooltip (FRAME_PTR f,
163 Lisp_Object string, 163 Lisp_Object string,
164 int *width, 164 int *width,
165 int *height); 165 int *height);
166extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y); 166extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y);
167extern int xg_hide_tooltip (FRAME_PTR f); 167extern bool xg_hide_tooltip (FRAME_PTR f);
168 168
169 169
170/* Mark all callback data that are Lisp_object:s during GC. */ 170/* Mark all callback data that are Lisp_object:s during GC. */
@@ -175,7 +175,7 @@ extern void xg_initialize (void);
175 175
176/* Setting scrollbar values invokes the callback. Use this variable 176/* Setting scrollbar values invokes the callback. Use this variable
177 to indicate that the callback should do nothing. */ 177 to indicate that the callback should do nothing. */
178extern int xg_ignore_gtk_scrollbar; 178extern bool xg_ignore_gtk_scrollbar;
179 179
180#endif /* USE_GTK */ 180#endif /* USE_GTK */
181#endif /* GTKUTIL_H */ 181#endif /* GTKUTIL_H */
diff --git a/src/image.c b/src/image.c
index 0060d0d4148..7901b95f236 100644
--- a/src/image.c
+++ b/src/image.c
@@ -407,9 +407,9 @@ x_destroy_bitmap (FRAME_PTR f, ptrdiff_t id)
407 407
408 if (--bm->refcount == 0) 408 if (--bm->refcount == 0)
409 { 409 {
410 BLOCK_INPUT; 410 block_input ();
411 free_bitmap_record (dpyinfo, bm); 411 free_bitmap_record (dpyinfo, bm);
412 UNBLOCK_INPUT; 412 unblock_input ();
413 } 413 }
414 } 414 }
415} 415}
@@ -429,6 +429,9 @@ x_destroy_all_bitmaps (Display_Info *dpyinfo)
429 dpyinfo->bitmaps_last = 0; 429 dpyinfo->bitmaps_last = 0;
430} 430}
431 431
432static bool x_create_x_image_and_pixmap (struct frame *, int, int, int,
433 XImagePtr *, Pixmap *);
434static void x_destroy_x_image (XImagePtr ximg);
432 435
433#ifdef HAVE_X_WINDOWS 436#ifdef HAVE_X_WINDOWS
434 437
@@ -440,23 +443,17 @@ static unsigned long four_corners_best (XImagePtr ximg,
440 unsigned long width, 443 unsigned long width,
441 unsigned long height); 444 unsigned long height);
442 445
443static int x_create_x_image_and_pixmap (struct frame *f, int width, int height,
444 int depth, XImagePtr *ximg,
445 Pixmap *pixmap);
446
447static void x_destroy_x_image (XImagePtr ximg);
448
449 446
450/* Create a mask of a bitmap. Note is this not a perfect mask. 447/* Create a mask of a bitmap. Note is this not a perfect mask.
451 It's nicer with some borders in this context */ 448 It's nicer with some borders in this context */
452 449
453int 450void
454x_create_bitmap_mask (struct frame *f, ptrdiff_t id) 451x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
455{ 452{
456 Pixmap pixmap, mask; 453 Pixmap pixmap, mask;
457 XImagePtr ximg, mask_img; 454 XImagePtr ximg, mask_img;
458 unsigned long width, height; 455 unsigned long width, height;
459 int result; 456 bool result;
460 unsigned long bg; 457 unsigned long bg;
461 unsigned long x, y, xp, xm, yp, ym; 458 unsigned long x, y, xp, xm, yp, ym;
462 GC gc; 459 GC gc;
@@ -464,29 +461,29 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
464 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 461 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
465 462
466 if (!(id > 0)) 463 if (!(id > 0))
467 return -1; 464 return;
468 465
469 pixmap = x_bitmap_pixmap (f, id); 466 pixmap = x_bitmap_pixmap (f, id);
470 width = x_bitmap_width (f, id); 467 width = x_bitmap_width (f, id);
471 height = x_bitmap_height (f, id); 468 height = x_bitmap_height (f, id);
472 469
473 BLOCK_INPUT; 470 block_input ();
474 ximg = XGetImage (FRAME_X_DISPLAY (f), pixmap, 0, 0, width, height, 471 ximg = XGetImage (FRAME_X_DISPLAY (f), pixmap, 0, 0, width, height,
475 ~0, ZPixmap); 472 ~0, ZPixmap);
476 473
477 if (!ximg) 474 if (!ximg)
478 { 475 {
479 UNBLOCK_INPUT; 476 unblock_input ();
480 return -1; 477 return;
481 } 478 }
482 479
483 result = x_create_x_image_and_pixmap (f, width, height, 1, &mask_img, &mask); 480 result = x_create_x_image_and_pixmap (f, width, height, 1, &mask_img, &mask);
484 481
485 UNBLOCK_INPUT; 482 unblock_input ();
486 if (!result) 483 if (!result)
487 { 484 {
488 XDestroyImage (ximg); 485 XDestroyImage (ximg);
489 return -1; 486 return;
490 } 487 }
491 488
492 bg = four_corners_best (ximg, NULL, width, height); 489 bg = four_corners_best (ximg, NULL, width, height);
@@ -514,7 +511,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
514 } 511 }
515 } 512 }
516 513
517 eassert (interrupt_input_blocked); 514 eassert (input_blocked_p ());
518 gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL); 515 gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL);
519 XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0, 516 XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0,
520 width, height); 517 width, height);
@@ -525,8 +522,6 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
525 522
526 XDestroyImage (ximg); 523 XDestroyImage (ximg);
527 x_destroy_x_image (mask_img); 524 x_destroy_x_image (mask_img);
528
529 return 0;
530} 525}
531 526
532#endif /* HAVE_X_WINDOWS */ 527#endif /* HAVE_X_WINDOWS */
@@ -559,15 +554,13 @@ static Lisp_Object QCcrop, QCrotation;
559static Lisp_Object Qcount, Qextension_data, Qdelay; 554static Lisp_Object Qcount, Qextension_data, Qdelay;
560static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic; 555static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
561 556
562/* Function prototypes. */ 557/* Forward function prototypes. */
563 558
564static struct image_type *define_image_type (struct image_type *, Lisp_Object); 559static struct image_type *lookup_image_type (Lisp_Object);
565static struct image_type *lookup_image_type (Lisp_Object, Lisp_Object);
566static void image_error (const char *format, Lisp_Object, Lisp_Object);
567static void x_laplace (struct frame *, struct image *); 560static void x_laplace (struct frame *, struct image *);
568static void x_emboss (struct frame *, struct image *); 561static void x_emboss (struct frame *, struct image *);
569static int x_build_heuristic_mask (struct frame *, struct image *, 562static void x_build_heuristic_mask (struct frame *, struct image *,
570 Lisp_Object); 563 Lisp_Object);
571#ifdef HAVE_NTGUI 564#ifdef HAVE_NTGUI
572#define CACHE_IMAGE_TYPE(type, status) \ 565#define CACHE_IMAGE_TYPE(type, status) \
573 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) 566 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
@@ -579,21 +572,16 @@ static int x_build_heuristic_mask (struct frame *, struct image *,
579 do { Vimage_types = Fcons (type, Vimage_types); } while (0) 572 do { Vimage_types = Fcons (type, Vimage_types); } while (0)
580 573
581/* Define a new image type from TYPE. This adds a copy of TYPE to 574/* Define a new image type from TYPE. This adds a copy of TYPE to
582 image_types and caches the loading status of TYPE. 575 image_types and caches the loading status of TYPE. */
583
584 LIBRARIES is an alist associating dynamic libraries to external
585 files implementing them, which is passed to the image library
586 initialization function if necessary. A nil value defaults to
587 Vdynamic_library_alist. */
588 576
589static struct image_type * 577static struct image_type *
590define_image_type (struct image_type *type, Lisp_Object libraries) 578define_image_type (struct image_type *type)
591{ 579{
592 struct image_type *p = NULL; 580 struct image_type *p = NULL;
593 Lisp_Object target_type = *type->type; 581 Lisp_Object target_type = *type->type;
594 int type_valid = 1; 582 bool type_valid = 1;
595 583
596 BLOCK_INPUT; 584 block_input ();
597 585
598 for (p = image_types; p; p = p->next) 586 for (p = image_types; p; p = p->next)
599 if (EQ (*p->type, target_type)) 587 if (EQ (*p->type, target_type))
@@ -609,7 +597,7 @@ define_image_type (struct image_type *type, Lisp_Object libraries)
609 else 597 else
610#endif 598#endif
611 { 599 {
612 type_valid = type->init (libraries); 600 type_valid = type->init ();
613 CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil); 601 CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
614 } 602 }
615 } 603 }
@@ -625,22 +613,22 @@ define_image_type (struct image_type *type, Lisp_Object libraries)
625 } 613 }
626 614
627 done: 615 done:
628 UNBLOCK_INPUT; 616 unblock_input ();
629 return p; 617 return p;
630} 618}
631 619
632 620
633/* Value is non-zero if OBJECT is a valid Lisp image specification. A 621/* Value is true if OBJECT is a valid Lisp image specification. A
634 valid image specification is a list whose car is the symbol 622 valid image specification is a list whose car is the symbol
635 `image', and whose rest is a property list. The property list must 623 `image', and whose rest is a property list. The property list must
636 contain a value for key `:type'. That value must be the name of a 624 contain a value for key `:type'. That value must be the name of a
637 supported image type. The rest of the property list depends on the 625 supported image type. The rest of the property list depends on the
638 image type. */ 626 image type. */
639 627
640int 628bool
641valid_image_p (Lisp_Object object) 629valid_image_p (Lisp_Object object)
642{ 630{
643 int valid_p = 0; 631 bool valid_p = 0;
644 632
645 if (IMAGEP (object)) 633 if (IMAGEP (object))
646 { 634 {
@@ -653,7 +641,7 @@ valid_image_p (Lisp_Object object)
653 if (CONSP (tem) && SYMBOLP (XCAR (tem))) 641 if (CONSP (tem) && SYMBOLP (XCAR (tem)))
654 { 642 {
655 struct image_type *type; 643 struct image_type *type;
656 type = lookup_image_type (XCAR (tem), Qnil); 644 type = lookup_image_type (XCAR (tem));
657 if (type) 645 if (type)
658 valid_p = type->valid_p (object); 646 valid_p = type->valid_p (object);
659 } 647 }
@@ -710,8 +698,8 @@ struct image_keyword
710 /* The type of value allowed. */ 698 /* The type of value allowed. */
711 enum image_value_type type; 699 enum image_value_type type;
712 700
713 /* Non-zero means key must be present. */ 701 /* True means key must be present. */
714 int mandatory_p; 702 bool mandatory_p;
715 703
716 /* Used to recognize duplicate keywords in a property list. */ 704 /* Used to recognize duplicate keywords in a property list. */
717 int count; 705 int count;
@@ -721,18 +709,13 @@ struct image_keyword
721}; 709};
722 710
723 711
724static int parse_image_spec (Lisp_Object, struct image_keyword *,
725 int, Lisp_Object);
726static Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, int *);
727
728
729/* Parse image spec SPEC according to KEYWORDS. A valid image spec 712/* Parse image spec SPEC according to KEYWORDS. A valid image spec
730 has the format (image KEYWORD VALUE ...). One of the keyword/ 713 has the format (image KEYWORD VALUE ...). One of the keyword/
731 value pairs must be `:type TYPE'. KEYWORDS is a vector of 714 value pairs must be `:type TYPE'. KEYWORDS is a vector of
732 image_keywords structures of size NKEYWORDS describing other 715 image_keywords structures of size NKEYWORDS describing other
733 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ 716 allowed keyword/value pairs. Value is true if SPEC is valid. */
734 717
735static int 718static bool
736parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, 719parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
737 int nkeywords, Lisp_Object type) 720 int nkeywords, Lisp_Object type)
738{ 721{
@@ -864,11 +847,11 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
864 847
865 848
866/* Return the value of KEY in image specification SPEC. Value is nil 849/* Return the value of KEY in image specification SPEC. Value is nil
867 if KEY is not present in SPEC. if FOUND is not null, set *FOUND 850 if KEY is not present in SPEC. Set *FOUND depending on whether KEY
868 to 1 if KEY was found in SPEC, set it to 0 otherwise. */ 851 was found in SPEC. */
869 852
870static Lisp_Object 853static Lisp_Object
871image_spec_value (Lisp_Object spec, Lisp_Object key, int *found) 854image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
872{ 855{
873 Lisp_Object tail; 856 Lisp_Object tail;
874 857
@@ -972,8 +955,6 @@ or omitted means use the selected frame. */)
972 Image type independent image structures 955 Image type independent image structures
973 ***********************************************************************/ 956 ***********************************************************************/
974 957
975static void free_image (struct frame *f, struct image *img);
976
977#define MAX_IMAGE_SIZE 10.0 958#define MAX_IMAGE_SIZE 10.0
978/* Allocate and return a new image structure for image specification 959/* Allocate and return a new image structure for image specification
979 SPEC. SPEC has a hash value of HASH. */ 960 SPEC. SPEC has a hash value of HASH. */
@@ -986,7 +967,7 @@ make_image (Lisp_Object spec, EMACS_UINT hash)
986 967
987 eassert (valid_image_p (spec)); 968 eassert (valid_image_p (spec));
988 img->dependencies = NILP (file) ? Qnil : list1 (file); 969 img->dependencies = NILP (file) ? Qnil : list1 (file);
989 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL), Qnil); 970 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
990 eassert (img->type != NULL); 971 eassert (img->type != NULL);
991 img->spec = spec; 972 img->spec = spec;
992 img->lisp_data = Qnil; 973 img->lisp_data = Qnil;
@@ -1023,10 +1004,9 @@ free_image (struct frame *f, struct image *img)
1023 } 1004 }
1024} 1005}
1025 1006
1026/* Return 1 if the given widths and heights are valid for display; 1007/* Return true if the given widths and heights are valid for display. */
1027 otherwise, return 0. */
1028 1008
1029static int 1009static bool
1030check_image_size (struct frame *f, int width, int height) 1010check_image_size (struct frame *f, int width, int height)
1031{ 1011{
1032 int w, h; 1012 int w, h;
@@ -1065,7 +1045,7 @@ prepare_image_for_display (struct frame *f, struct image *img)
1065 /* If IMG doesn't have a pixmap yet, load it now, using the image 1045 /* If IMG doesn't have a pixmap yet, load it now, using the image
1066 type dependent loader function. */ 1046 type dependent loader function. */
1067 if (img->pixmap == NO_PIXMAP && !img->load_failed_p) 1047 if (img->pixmap == NO_PIXMAP && !img->load_failed_p)
1068 img->load_failed_p = img->type->load (f, img) == 0; 1048 img->load_failed_p = ! img->type->load (f, img);
1069 1049
1070} 1050}
1071 1051
@@ -1198,7 +1178,7 @@ image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
1198 if (! img->background_valid) 1178 if (! img->background_valid)
1199 /* IMG doesn't have a background yet, try to guess a reasonable value. */ 1179 /* IMG doesn't have a background yet, try to guess a reasonable value. */
1200 { 1180 {
1201 int free_ximg = !ximg; 1181 bool free_ximg = !ximg;
1202#ifdef HAVE_NTGUI 1182#ifdef HAVE_NTGUI
1203 HGDIOBJ prev; 1183 HGDIOBJ prev;
1204#endif /* HAVE_NTGUI */ 1184#endif /* HAVE_NTGUI */
@@ -1239,7 +1219,7 @@ image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_D
1239 { 1219 {
1240 if (img->mask) 1220 if (img->mask)
1241 { 1221 {
1242 int free_mask = !mask; 1222 bool free_mask = !mask;
1243#ifdef HAVE_NTGUI 1223#ifdef HAVE_NTGUI
1244 HGDIOBJ prev; 1224 HGDIOBJ prev;
1245#endif /* HAVE_NTGUI */ 1225#endif /* HAVE_NTGUI */
@@ -1277,23 +1257,13 @@ image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_D
1277 Helper functions for X image types 1257 Helper functions for X image types
1278 ***********************************************************************/ 1258 ***********************************************************************/
1279 1259
1280static void x_clear_image_1 (struct frame *, struct image *, int, 1260/* Clear X resources of image IMG on frame F. PIXMAP_P means free the
1281 int, int); 1261 pixmap if any. MASK_P means clear the mask pixmap if any.
1282static void x_clear_image (struct frame *f, struct image *img); 1262 COLORS_P means free colors allocated for the image, if any. */
1283static unsigned long x_alloc_image_color (struct frame *f,
1284 struct image *img,
1285 Lisp_Object color_name,
1286 unsigned long dflt);
1287
1288
1289/* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means
1290 free the pixmap if any. MASK_P non-zero means clear the mask
1291 pixmap if any. COLORS_P non-zero means free colors allocated for
1292 the image, if any. */
1293 1263
1294static void 1264static void
1295x_clear_image_1 (struct frame *f, struct image *img, int pixmap_p, int mask_p, 1265x_clear_image_1 (struct frame *f, struct image *img, bool pixmap_p,
1296 int colors_p) 1266 bool mask_p, bool colors_p)
1297{ 1267{
1298 if (pixmap_p && img->pixmap) 1268 if (pixmap_p && img->pixmap)
1299 { 1269 {
@@ -1328,9 +1298,9 @@ x_clear_image_1 (struct frame *f, struct image *img, int pixmap_p, int mask_p,
1328static void 1298static void
1329x_clear_image (struct frame *f, struct image *img) 1299x_clear_image (struct frame *f, struct image *img)
1330{ 1300{
1331 BLOCK_INPUT; 1301 block_input ();
1332 x_clear_image_1 (f, img, 1, 1, 1); 1302 x_clear_image_1 (f, img, 1, 1, 1);
1333 UNBLOCK_INPUT; 1303 unblock_input ();
1334} 1304}
1335 1305
1336 1306
@@ -1373,7 +1343,6 @@ x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name,
1373 ***********************************************************************/ 1343 ***********************************************************************/
1374 1344
1375static void cache_image (struct frame *f, struct image *img); 1345static void cache_image (struct frame *f, struct image *img);
1376static void postprocess_image (struct frame *, struct image *);
1377 1346
1378/* Return a new, initialized image cache that is allocated from the 1347/* Return a new, initialized image cache that is allocated from the
1379 heap. Call free_image_cache to free an image cache. */ 1348 heap. Call free_image_cache to free an image cache. */
@@ -1485,7 +1454,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter)
1485 1454
1486 /* Block input so that we won't be interrupted by a SIGIO 1455 /* Block input so that we won't be interrupted by a SIGIO
1487 while being in an inconsistent state. */ 1456 while being in an inconsistent state. */
1488 BLOCK_INPUT; 1457 block_input ();
1489 1458
1490 if (!NILP (filter)) 1459 if (!NILP (filter))
1491 { 1460 {
@@ -1551,7 +1520,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter)
1551 ++windows_or_buffers_changed; 1520 ++windows_or_buffers_changed;
1552 } 1521 }
1553 1522
1554 UNBLOCK_INPUT; 1523 unblock_input ();
1555 } 1524 }
1556} 1525}
1557 1526
@@ -1646,7 +1615,7 @@ postprocess_image (struct frame *f, struct image *img)
1646 x_build_heuristic_mask (f, img, mask); 1615 x_build_heuristic_mask (f, img, mask);
1647 else 1616 else
1648 { 1617 {
1649 int found_p; 1618 bool found_p;
1650 1619
1651 mask = image_spec_value (spec, QCmask, &found_p); 1620 mask = image_spec_value (spec, QCmask, &found_p);
1652 1621
@@ -1716,10 +1685,10 @@ lookup_image (struct frame *f, Lisp_Object spec)
1716 /* If not found, create a new image and cache it. */ 1685 /* If not found, create a new image and cache it. */
1717 if (img == NULL) 1686 if (img == NULL)
1718 { 1687 {
1719 BLOCK_INPUT; 1688 block_input ();
1720 img = make_image (spec, hash); 1689 img = make_image (spec, hash);
1721 cache_image (f, img); 1690 cache_image (f, img);
1722 img->load_failed_p = img->type->load (f, img) == 0; 1691 img->load_failed_p = ! img->type->load (f, img);
1723 img->frame_foreground = FRAME_FOREGROUND_PIXEL (f); 1692 img->frame_foreground = FRAME_FOREGROUND_PIXEL (f);
1724 img->frame_background = FRAME_BACKGROUND_PIXEL (f); 1693 img->frame_background = FRAME_BACKGROUND_PIXEL (f);
1725 1694
@@ -1787,7 +1756,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
1787 postprocess_image (f, img); 1756 postprocess_image (f, img);
1788 } 1757 }
1789 1758
1790 UNBLOCK_INPUT; 1759 unblock_input ();
1791 } 1760 }
1792 1761
1793 /* We're using IMG, so set its timestamp to `now'. */ 1762 /* We're using IMG, so set its timestamp to `now'. */
@@ -1878,16 +1847,11 @@ mark_image_cache (struct image_cache *c)
1878 1847
1879#endif /* HAVE_NTGUI */ 1848#endif /* HAVE_NTGUI */
1880 1849
1881static int x_create_x_image_and_pixmap (struct frame *, int, int, int, 1850/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the
1882 XImagePtr *, Pixmap *);
1883static void x_destroy_x_image (XImagePtr);
1884static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int);
1885
1886/* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break the
1887 windowing system. 1851 windowing system.
1888 WIDTH and HEIGHT must both be positive. 1852 WIDTH and HEIGHT must both be positive.
1889 If XIMG is null, assume it is a bitmap. */ 1853 If XIMG is null, assume it is a bitmap. */
1890static int 1854static bool
1891x_check_image_size (XImagePtr ximg, int width, int height) 1855x_check_image_size (XImagePtr ximg, int width, int height)
1892{ 1856{
1893#ifdef HAVE_X_WINDOWS 1857#ifdef HAVE_X_WINDOWS
@@ -1926,12 +1890,12 @@ x_check_image_size (XImagePtr ximg, int width, int height)
1926 frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created. 1890 frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created.
1927 Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated 1891 Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated
1928 via xmalloc. Print error messages via image_error if an error 1892 via xmalloc. Print error messages via image_error if an error
1929 occurs. Value is non-zero if successful. 1893 occurs. Value is true if successful.
1930 1894
1931 On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH 1895 On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH
1932 should indicate the bit depth of the image. */ 1896 should indicate the bit depth of the image. */
1933 1897
1934static int 1898static bool
1935x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, 1899x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
1936 XImagePtr *ximg, Pixmap *pixmap) 1900 XImagePtr *ximg, Pixmap *pixmap)
1937{ 1901{
@@ -1940,7 +1904,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
1940 Window window = FRAME_X_WINDOW (f); 1904 Window window = FRAME_X_WINDOW (f);
1941 Screen *screen = FRAME_X_SCREEN (f); 1905 Screen *screen = FRAME_X_SCREEN (f);
1942 1906
1943 eassert (interrupt_input_blocked); 1907 eassert (input_blocked_p ());
1944 1908
1945 if (depth <= 0) 1909 if (depth <= 0)
1946 depth = DefaultDepthOfScreen (screen); 1910 depth = DefaultDepthOfScreen (screen);
@@ -2078,7 +2042,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2078static void 2042static void
2079x_destroy_x_image (XImagePtr ximg) 2043x_destroy_x_image (XImagePtr ximg)
2080{ 2044{
2081 eassert (interrupt_input_blocked); 2045 eassert (input_blocked_p ());
2082 if (ximg) 2046 if (ximg)
2083 { 2047 {
2084#ifdef HAVE_X_WINDOWS 2048#ifdef HAVE_X_WINDOWS
@@ -2107,7 +2071,7 @@ x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int he
2107#ifdef HAVE_X_WINDOWS 2071#ifdef HAVE_X_WINDOWS
2108 GC gc; 2072 GC gc;
2109 2073
2110 eassert (interrupt_input_blocked); 2074 eassert (input_blocked_p ());
2111 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL); 2075 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
2112 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height); 2076 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);
2113 XFreeGC (FRAME_X_DISPLAY (f), gc); 2077 XFreeGC (FRAME_X_DISPLAY (f), gc);
@@ -2203,15 +2167,9 @@ slurp_file (char *file, ptrdiff_t *size)
2203 XBM images 2167 XBM images
2204 ***********************************************************************/ 2168 ***********************************************************************/
2205 2169
2206static int xbm_scan (unsigned char **, unsigned char *, char *, int *); 2170static bool xbm_load (struct frame *f, struct image *img);
2207static int xbm_load (struct frame *f, struct image *img); 2171static bool xbm_image_p (Lisp_Object object);
2208static int xbm_load_image (struct frame *f, struct image *img, 2172static bool xbm_file_p (Lisp_Object);
2209 unsigned char *, unsigned char *);
2210static int xbm_image_p (Lisp_Object object);
2211static int xbm_read_bitmap_data (struct frame *f,
2212 unsigned char *, unsigned char *,
2213 int *, int *, char **, int);
2214static int xbm_file_p (Lisp_Object);
2215 2173
2216 2174
2217/* Indices of image specification fields in xbm_format, below. */ 2175/* Indices of image specification fields in xbm_format, below. */
@@ -2275,10 +2233,10 @@ enum xbm_token
2275}; 2233};
2276 2234
2277 2235
2278/* Return non-zero if OBJECT is a valid XBM-type image specification. 2236/* Return true if OBJECT is a valid XBM-type image specification.
2279 A valid specification is a list starting with the symbol `image' 2237 A valid specification is a list starting with the symbol `image'
2280 The rest of the list is a property list which must contain an 2238 The rest of the list is a property list which must contain an
2281 entry `:type xbm.. 2239 entry `:type xbm'.
2282 2240
2283 If the specification specifies a file to load, it must contain 2241 If the specification specifies a file to load, it must contain
2284 an entry `:file FILENAME' where FILENAME is a string. 2242 an entry `:file FILENAME' where FILENAME is a string.
@@ -2304,7 +2262,7 @@ enum xbm_token
2304 foreground and background of the frame on which the image is 2262 foreground and background of the frame on which the image is
2305 displayed is used. */ 2263 displayed is used. */
2306 2264
2307static int 2265static bool
2308xbm_image_p (Lisp_Object object) 2266xbm_image_p (Lisp_Object object)
2309{ 2267{
2310 struct image_keyword kw[XBM_LAST]; 2268 struct image_keyword kw[XBM_LAST];
@@ -2562,7 +2520,7 @@ convert_mono_to_color_image (struct frame *f, struct image *img,
2562static void 2520static void
2563Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, 2521Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
2564 RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg, 2522 RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg,
2565 int non_default_colors) 2523 bool non_default_colors)
2566{ 2524{
2567#ifdef HAVE_NTGUI 2525#ifdef HAVE_NTGUI
2568 img->pixmap 2526 img->pixmap
@@ -2594,20 +2552,20 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
2594 X versions. CONTENTS is a pointer to a buffer to parse; END is the 2552 X versions. CONTENTS is a pointer to a buffer to parse; END is the
2595 buffer's end. Set *WIDTH and *HEIGHT to the width and height of 2553 buffer's end. Set *WIDTH and *HEIGHT to the width and height of
2596 the image. Return in *DATA the bitmap data allocated with xmalloc. 2554 the image. Return in *DATA the bitmap data allocated with xmalloc.
2597 Value is non-zero if successful. DATA null means just test if 2555 Value is true if successful. DATA null means just test if
2598 CONTENTS looks like an in-memory XBM file. If INHIBIT_IMAGE_ERROR 2556 CONTENTS looks like an in-memory XBM file. If INHIBIT_IMAGE_ERROR,
2599 is non-zero, inhibit the call to image_error when the image size is 2557 inhibit the call to image_error when the image size is invalid (the
2600 invalid (the bitmap remains unread). */ 2558 bitmap remains unread). */
2601 2559
2602static int 2560static bool
2603xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end, 2561xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end,
2604 int *width, int *height, char **data, 2562 int *width, int *height, char **data,
2605 int inhibit_image_error) 2563 bool inhibit_image_error)
2606{ 2564{
2607 unsigned char *s = contents; 2565 unsigned char *s = contents;
2608 char buffer[BUFSIZ]; 2566 char buffer[BUFSIZ];
2609 int padding_p = 0; 2567 bool padding_p = 0;
2610 int v10 = 0; 2568 bool v10 = 0;
2611 int bytes_per_line, i, nbytes; 2569 int bytes_per_line, i, nbytes;
2612 char *p; 2570 char *p;
2613 int value; 2571 int value;
@@ -2754,16 +2712,16 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
2754 2712
2755 2713
2756/* Load XBM image IMG which will be displayed on frame F from buffer 2714/* Load XBM image IMG which will be displayed on frame F from buffer
2757 CONTENTS. END is the end of the buffer. Value is non-zero if 2715 CONTENTS. END is the end of the buffer. Value is true if
2758 successful. */ 2716 successful. */
2759 2717
2760static int 2718static bool
2761xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, 2719xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2762 unsigned char *end) 2720 unsigned char *end)
2763{ 2721{
2764 int rc; 2722 bool rc;
2765 char *data; 2723 char *data;
2766 int success_p = 0; 2724 bool success_p = 0;
2767 2725
2768 rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height, 2726 rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height,
2769 &data, 0); 2727 &data, 0);
@@ -2771,7 +2729,7 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2771 { 2729 {
2772 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); 2730 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
2773 unsigned long background = FRAME_BACKGROUND_PIXEL (f); 2731 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
2774 int non_default_colors = 0; 2732 bool non_default_colors = 0;
2775 Lisp_Object value; 2733 Lisp_Object value;
2776 2734
2777 eassert (img->width > 0 && img->height > 0); 2735 eassert (img->width > 0 && img->height > 0);
@@ -2812,9 +2770,9 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2812} 2770}
2813 2771
2814 2772
2815/* Value is non-zero if DATA looks like an in-memory XBM file. */ 2773/* Value is true if DATA looks like an in-memory XBM file. */
2816 2774
2817static int 2775static bool
2818xbm_file_p (Lisp_Object data) 2776xbm_file_p (Lisp_Object data)
2819{ 2777{
2820 int w, h; 2778 int w, h;
@@ -2826,12 +2784,12 @@ xbm_file_p (Lisp_Object data)
2826 2784
2827 2785
2828/* Fill image IMG which is used on frame F with pixmap data. Value is 2786/* Fill image IMG which is used on frame F with pixmap data. Value is
2829 non-zero if successful. */ 2787 true if successful. */
2830 2788
2831static int 2789static bool
2832xbm_load (struct frame *f, struct image *img) 2790xbm_load (struct frame *f, struct image *img)
2833{ 2791{
2834 int success_p = 0; 2792 bool success_p = 0;
2835 Lisp_Object file_name; 2793 Lisp_Object file_name;
2836 2794
2837 eassert (xbm_image_p (img->spec)); 2795 eassert (xbm_image_p (img->spec));
@@ -2867,10 +2825,10 @@ xbm_load (struct frame *f, struct image *img)
2867 Lisp_Object data; 2825 Lisp_Object data;
2868 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); 2826 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
2869 unsigned long background = FRAME_BACKGROUND_PIXEL (f); 2827 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
2870 int non_default_colors = 0; 2828 bool non_default_colors = 0;
2871 char *bits; 2829 char *bits;
2872 int parsed_p; 2830 bool parsed_p;
2873 int in_memory_file_p = 0; 2831 bool in_memory_file_p = 0;
2874 2832
2875 /* See if data looks like an in-memory XBM file. */ 2833 /* See if data looks like an in-memory XBM file. */
2876 data = image_spec_value (img->spec, QCdata, NULL); 2834 data = image_spec_value (img->spec, QCdata, NULL);
@@ -2879,7 +2837,6 @@ xbm_load (struct frame *f, struct image *img)
2879 /* Parse the image specification. */ 2837 /* Parse the image specification. */
2880 memcpy (fmt, xbm_format, sizeof fmt); 2838 memcpy (fmt, xbm_format, sizeof fmt);
2881 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); 2839 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm);
2882 (void) parsed_p;
2883 eassert (parsed_p); 2840 eassert (parsed_p);
2884 2841
2885 /* Get specified width, and height. */ 2842 /* Get specified width, and height. */
@@ -2984,9 +2941,8 @@ xbm_load (struct frame *f, struct image *img)
2984 2941
2985#if defined (HAVE_XPM) || defined (HAVE_NS) 2942#if defined (HAVE_XPM) || defined (HAVE_NS)
2986 2943
2987static int xpm_image_p (Lisp_Object object); 2944static bool xpm_image_p (Lisp_Object object);
2988static int xpm_load (struct frame *f, struct image *img); 2945static bool xpm_load (struct frame *f, struct image *img);
2989static int xpm_valid_color_symbols_p (Lisp_Object);
2990 2946
2991#endif /* HAVE_XPM || HAVE_NS */ 2947#endif /* HAVE_XPM || HAVE_NS */
2992 2948
@@ -3053,7 +3009,7 @@ static const struct image_keyword xpm_format[XPM_LAST] =
3053}; 3009};
3054 3010
3055#ifdef HAVE_NTGUI 3011#ifdef HAVE_NTGUI
3056static int init_xpm_functions (Lisp_Object); 3012static bool init_xpm_functions (void);
3057#else 3013#else
3058#define init_xpm_functions NULL 3014#define init_xpm_functions NULL
3059#endif 3015#endif
@@ -3084,10 +3040,6 @@ static struct image_type xpm_type =
3084 3040
3085#ifdef ALLOC_XPM_COLORS 3041#ifdef ALLOC_XPM_COLORS
3086 3042
3087static void xpm_init_color_cache (struct frame *, XpmAttributes *);
3088static void xpm_free_color_cache (void);
3089static int xpm_lookup_color (struct frame *, char *, XColor *);
3090static int xpm_color_bucket (char *);
3091static struct xpm_cached_color *xpm_cache_color (struct frame *, char *, 3043static struct xpm_cached_color *xpm_cache_color (struct frame *, char *,
3092 XColor *, int); 3044 XColor *, int);
3093 3045
@@ -3194,10 +3146,10 @@ xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket)
3194 3146
3195/* Look up color COLOR_NAME for frame F in the color cache. If found, 3147/* Look up color COLOR_NAME for frame F in the color cache. If found,
3196 return the cached definition in *COLOR. Otherwise, make a new 3148 return the cached definition in *COLOR. Otherwise, make a new
3197 entry in the cache and allocate the color. Value is zero if color 3149 entry in the cache and allocate the color. Value is false if color
3198 allocation failed. */ 3150 allocation failed. */
3199 3151
3200static int 3152static bool
3201xpm_lookup_color (struct frame *f, char *color_name, XColor *color) 3153xpm_lookup_color (struct frame *f, char *color_name, XColor *color)
3202{ 3154{
3203 struct xpm_cached_color *p; 3155 struct xpm_cached_color *p;
@@ -3266,12 +3218,12 @@ DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **,
3266 xpm_XImage **, XpmAttributes *)); 3218 xpm_XImage **, XpmAttributes *));
3267DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *)); 3219DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *));
3268 3220
3269static int 3221static bool
3270init_xpm_functions (Lisp_Object libraries) 3222init_xpm_functions (void)
3271{ 3223{
3272 HMODULE library; 3224 HMODULE library;
3273 3225
3274 if (!(library = w32_delayed_load (libraries, Qxpm))) 3226 if (!(library = w32_delayed_load (Qxpm)))
3275 return 0; 3227 return 0;
3276 3228
3277 LOAD_IMGLIB_FN (library, XpmFreeAttributes); 3229 LOAD_IMGLIB_FN (library, XpmFreeAttributes);
@@ -3284,11 +3236,11 @@ init_xpm_functions (Lisp_Object libraries)
3284#endif /* HAVE_NTGUI */ 3236#endif /* HAVE_NTGUI */
3285 3237
3286 3238
3287/* Value is non-zero if COLOR_SYMBOLS is a valid color symbols list 3239/* Value is true if COLOR_SYMBOLS is a valid color symbols list
3288 for XPM images. Such a list must consist of conses whose car and 3240 for XPM images. Such a list must consist of conses whose car and
3289 cdr are strings. */ 3241 cdr are strings. */
3290 3242
3291static int 3243static bool
3292xpm_valid_color_symbols_p (Lisp_Object color_symbols) 3244xpm_valid_color_symbols_p (Lisp_Object color_symbols)
3293{ 3245{
3294 while (CONSP (color_symbols)) 3246 while (CONSP (color_symbols))
@@ -3305,9 +3257,9 @@ xpm_valid_color_symbols_p (Lisp_Object color_symbols)
3305} 3257}
3306 3258
3307 3259
3308/* Value is non-zero if OBJECT is a valid XPM image specification. */ 3260/* Value is true if OBJECT is a valid XPM image specification. */
3309 3261
3310static int 3262static bool
3311xpm_image_p (Lisp_Object object) 3263xpm_image_p (Lisp_Object object)
3312{ 3264{
3313 struct image_keyword fmt[XPM_LAST]; 3265 struct image_keyword fmt[XPM_LAST];
@@ -3364,11 +3316,11 @@ x_create_bitmap_from_xpm_data (struct frame *f, const char **bits)
3364#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */ 3316#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
3365 3317
3366/* Load image IMG which will be displayed on frame F. Value is 3318/* Load image IMG which will be displayed on frame F. Value is
3367 non-zero if successful. */ 3319 true if successful. */
3368 3320
3369#ifdef HAVE_XPM 3321#ifdef HAVE_XPM
3370 3322
3371static int 3323static bool
3372xpm_load (struct frame *f, struct image *img) 3324xpm_load (struct frame *f, struct image *img)
3373{ 3325{
3374 int rc; 3326 int rc;
@@ -3822,7 +3774,7 @@ xpm_str_to_color_key (const char *s)
3822 return -1; 3774 return -1;
3823} 3775}
3824 3776
3825static int 3777static bool
3826xpm_load_image (struct frame *f, 3778xpm_load_image (struct frame *f,
3827 struct image *img, 3779 struct image *img,
3828 const unsigned char *contents, 3780 const unsigned char *contents,
@@ -3837,7 +3789,8 @@ xpm_load_image (struct frame *f,
3837 void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object); 3789 void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object);
3838 Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int); 3790 Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int);
3839 Lisp_Object frame, color_symbols, color_table; 3791 Lisp_Object frame, color_symbols, color_table;
3840 int best_key, have_mask = 0; 3792 int best_key;
3793 bool have_mask = 0;
3841 XImagePtr ximg = NULL, mask_img = NULL; 3794 XImagePtr ximg = NULL, mask_img = NULL;
3842 3795
3843#define match() \ 3796#define match() \
@@ -4057,11 +4010,11 @@ xpm_load_image (struct frame *f,
4057#undef expect_ident 4010#undef expect_ident
4058} 4011}
4059 4012
4060static int 4013static bool
4061xpm_load (struct frame *f, 4014xpm_load (struct frame *f,
4062 struct image *img) 4015 struct image *img)
4063{ 4016{
4064 int success_p = 0; 4017 bool success_p = 0;
4065 Lisp_Object file_name; 4018 Lisp_Object file_name;
4066 4019
4067 /* If IMG->spec specifies a file name, create a non-file spec from it. */ 4020 /* If IMG->spec specifies a file name, create a non-file spec from it. */
@@ -4232,7 +4185,7 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
4232#ifdef HAVE_X_WINDOWS 4185#ifdef HAVE_X_WINDOWS
4233 XColor color; 4186 XColor color;
4234 Colormap cmap; 4187 Colormap cmap;
4235 int rc; 4188 bool rc;
4236#else 4189#else
4237 COLORREF color; 4190 COLORREF color;
4238#endif 4191#endif
@@ -4300,7 +4253,7 @@ lookup_pixel_color (struct frame *f, unsigned long pixel)
4300 { 4253 {
4301 XColor color; 4254 XColor color;
4302 Colormap cmap; 4255 Colormap cmap;
4303 int rc; 4256 bool rc;
4304 4257
4305 if (ct_colors_allocated_max <= ct_colors_allocated) 4258 if (ct_colors_allocated_max <= ct_colors_allocated)
4306 return FRAME_FOREGROUND_PIXEL (f); 4259 return FRAME_FOREGROUND_PIXEL (f);
@@ -4311,12 +4264,12 @@ lookup_pixel_color (struct frame *f, unsigned long pixel)
4311 x_query_color (f, &color); 4264 x_query_color (f, &color);
4312 rc = x_alloc_nearest_color (f, cmap, &color); 4265 rc = x_alloc_nearest_color (f, cmap, &color);
4313#else 4266#else
4314 BLOCK_INPUT; 4267 block_input ();
4315 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 4268 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
4316 color.pixel = pixel; 4269 color.pixel = pixel;
4317 XQueryColor (NULL, cmap, &color); 4270 XQueryColor (NULL, cmap, &color);
4318 rc = x_alloc_nearest_color (f, cmap, &color); 4271 rc = x_alloc_nearest_color (f, cmap, &color);
4319 UNBLOCK_INPUT; 4272 unblock_input ();
4320#endif /* HAVE_X_WINDOWS */ 4273#endif /* HAVE_X_WINDOWS */
4321 4274
4322 if (rc) 4275 if (rc)
@@ -4394,14 +4347,6 @@ init_color_table (void)
4394 Algorithms 4347 Algorithms
4395 ***********************************************************************/ 4348 ***********************************************************************/
4396 4349
4397static XColor *x_to_xcolors (struct frame *, struct image *, int);
4398static void x_from_xcolors (struct frame *, struct image *, XColor *);
4399static void x_detect_edges (struct frame *, struct image *, int[9], int);
4400
4401#ifdef HAVE_NTGUI
4402static void XPutPixel (XImagePtr , int, int, COLORREF);
4403#endif /* HAVE_NTGUI */
4404
4405/* Edge detection matrices for different edge-detection 4350/* Edge detection matrices for different edge-detection
4406 strategies. */ 4351 strategies. */
4407 4352
@@ -4427,12 +4372,12 @@ static int laplace_matrix[9] = {
4427 4372
4428/* On frame F, return an array of XColor structures describing image 4373/* On frame F, return an array of XColor structures describing image
4429 IMG->pixmap. Each XColor structure has its pixel color set. RGB_P 4374 IMG->pixmap. Each XColor structure has its pixel color set. RGB_P
4430 non-zero means also fill the red/green/blue members of the XColor 4375 means also fill the red/green/blue members of the XColor
4431 structures. Value is a pointer to the array of XColors structures, 4376 structures. Value is a pointer to the array of XColors structures,
4432 allocated with xmalloc; it must be freed by the caller. */ 4377 allocated with xmalloc; it must be freed by the caller. */
4433 4378
4434static XColor * 4379static XColor *
4435x_to_xcolors (struct frame *f, struct image *img, int rgb_p) 4380x_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
4436{ 4381{
4437 int x, y; 4382 int x, y;
4438 XColor *colors, *p; 4383 XColor *colors, *p;
@@ -4808,9 +4753,9 @@ x_disable_image (struct frame *f, struct image *img)
4808 determine the background color of IMG. If it is a list '(R G B)', 4753 determine the background color of IMG. If it is a list '(R G B)',
4809 with R, G, and B being integers >= 0, take that as the color of the 4754 with R, G, and B being integers >= 0, take that as the color of the
4810 background. Otherwise, determine the background color of IMG 4755 background. Otherwise, determine the background color of IMG
4811 heuristically. Value is non-zero if successful. */ 4756 heuristically. */
4812 4757
4813static int 4758static void
4814x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) 4759x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4815{ 4760{
4816 XImagePtr_or_DC ximg; 4761 XImagePtr_or_DC ximg;
@@ -4822,7 +4767,8 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4822 char *mask_img; 4767 char *mask_img;
4823 int row_width; 4768 int row_width;
4824#endif /* HAVE_NTGUI */ 4769#endif /* HAVE_NTGUI */
4825 int x, y, rc, use_img_background; 4770 int x, y;
4771 bool rc, use_img_background;
4826 unsigned long bg = 0; 4772 unsigned long bg = 0;
4827 4773
4828 if (img->mask) 4774 if (img->mask)
@@ -4838,7 +4784,7 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4838 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, 4784 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
4839 &mask_img, &img->mask); 4785 &mask_img, &img->mask);
4840 if (!rc) 4786 if (!rc)
4841 return 0; 4787 return;
4842#endif /* !HAVE_NS */ 4788#endif /* !HAVE_NS */
4843 4789
4844 /* Get the X image of IMG->pixmap. */ 4790 /* Get the X image of IMG->pixmap. */
@@ -4928,8 +4874,6 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4928#endif /* HAVE_NTGUI */ 4874#endif /* HAVE_NTGUI */
4929 4875
4930 Destroy_Image (ximg, prev); 4876 Destroy_Image (ximg, prev);
4931
4932 return 1;
4933} 4877}
4934 4878
4935 4879
@@ -4937,9 +4881,8 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4937 PBM (mono, gray, color) 4881 PBM (mono, gray, color)
4938 ***********************************************************************/ 4882 ***********************************************************************/
4939 4883
4940static int pbm_image_p (Lisp_Object object); 4884static bool pbm_image_p (Lisp_Object object);
4941static int pbm_load (struct frame *f, struct image *img); 4885static bool pbm_load (struct frame *f, struct image *img);
4942static int pbm_scan_number (unsigned char **, unsigned char *);
4943 4886
4944/* The symbol `pbm' identifying images of this type. */ 4887/* The symbol `pbm' identifying images of this type. */
4945 4888
@@ -4994,9 +4937,9 @@ static struct image_type pbm_type =
4994}; 4937};
4995 4938
4996 4939
4997/* Return non-zero if OBJECT is a valid PBM image specification. */ 4940/* Return true if OBJECT is a valid PBM image specification. */
4998 4941
4999static int 4942static bool
5000pbm_image_p (Lisp_Object object) 4943pbm_image_p (Lisp_Object object)
5001{ 4944{
5002 struct image_keyword fmt[PBM_LAST]; 4945 struct image_keyword fmt[PBM_LAST];
@@ -5089,10 +5032,11 @@ pbm_read_file (Lisp_Object file, int *size)
5089 5032
5090/* Load PBM image IMG for use on frame F. */ 5033/* Load PBM image IMG for use on frame F. */
5091 5034
5092static int 5035static bool
5093pbm_load (struct frame *f, struct image *img) 5036pbm_load (struct frame *f, struct image *img)
5094{ 5037{
5095 int raw_p, x, y; 5038 bool raw_p;
5039 int x, y;
5096 int width, height, max_color_idx = 0; 5040 int width, height, max_color_idx = 0;
5097 XImagePtr ximg; 5041 XImagePtr ximg;
5098 Lisp_Object file, specified_file; 5042 Lisp_Object file, specified_file;
@@ -5355,8 +5299,8 @@ pbm_load (struct frame *f, struct image *img)
5355 5299
5356/* Function prototypes. */ 5300/* Function prototypes. */
5357 5301
5358static int png_image_p (Lisp_Object object); 5302static bool png_image_p (Lisp_Object object);
5359static int png_load (struct frame *f, struct image *img); 5303static bool png_load (struct frame *f, struct image *img);
5360 5304
5361/* The symbol `png' identifying images of this type. */ 5305/* The symbol `png' identifying images of this type. */
5362 5306
@@ -5397,7 +5341,7 @@ static const struct image_keyword png_format[PNG_LAST] =
5397}; 5341};
5398 5342
5399#ifdef HAVE_NTGUI 5343#ifdef HAVE_NTGUI
5400static int init_png_functions (Lisp_Object); 5344static bool init_png_functions (void);
5401#else 5345#else
5402#define init_png_functions NULL 5346#define init_png_functions NULL
5403#endif 5347#endif
@@ -5414,9 +5358,9 @@ static struct image_type png_type =
5414 NULL 5358 NULL
5415}; 5359};
5416 5360
5417/* Return non-zero if OBJECT is a valid PNG image specification. */ 5361/* Return true if OBJECT is a valid PNG image specification. */
5418 5362
5419static int 5363static bool
5420png_image_p (Lisp_Object object) 5364png_image_p (Lisp_Object object)
5421{ 5365{
5422 struct image_keyword fmt[PNG_LAST]; 5366 struct image_keyword fmt[PNG_LAST];
@@ -5468,12 +5412,12 @@ DEF_IMGLIB_FN (void, png_longjmp, (png_structp, int));
5468DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t)); 5412DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t));
5469#endif /* libpng version >= 1.5 */ 5413#endif /* libpng version >= 1.5 */
5470 5414
5471static int 5415static bool
5472init_png_functions (Lisp_Object libraries) 5416init_png_functions (void)
5473{ 5417{
5474 HMODULE library; 5418 HMODULE library;
5475 5419
5476 if (!(library = w32_delayed_load (libraries, Qpng))) 5420 if (!(library = w32_delayed_load (Qpng)))
5477 return 0; 5421 return 0;
5478 5422
5479 LOAD_IMGLIB_FN (library, png_get_io_ptr); 5423 LOAD_IMGLIB_FN (library, png_get_io_ptr);
@@ -5619,7 +5563,7 @@ png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length)
5619} 5563}
5620 5564
5621 5565
5622/* Load PNG image IMG for use on frame F. Value is non-zero if 5566/* Load PNG image IMG for use on frame F. Value is true if
5623 successful. */ 5567 successful. */
5624 5568
5625struct png_load_context 5569struct png_load_context
@@ -5633,7 +5577,7 @@ struct png_load_context
5633 png_byte **rows; 5577 png_byte **rows;
5634}; 5578};
5635 5579
5636static int 5580static bool
5637png_load_body (struct frame *f, struct image *img, struct png_load_context *c) 5581png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5638{ 5582{
5639 Lisp_Object file, specified_file; 5583 Lisp_Object file, specified_file;
@@ -5651,7 +5595,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5651 int bit_depth, color_type, interlace_type; 5595 int bit_depth, color_type, interlace_type;
5652 png_byte channels; 5596 png_byte channels;
5653 png_uint_32 row_bytes; 5597 png_uint_32 row_bytes;
5654 int transparent_p; 5598 bool transparent_p;
5655 struct png_memory_storage tbr; /* Data to be read */ 5599 struct png_memory_storage tbr; /* Data to be read */
5656 5600
5657 /* Find out what file to load. */ 5601 /* Find out what file to load. */
@@ -5984,7 +5928,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5984 return 1; 5928 return 1;
5985} 5929}
5986 5930
5987static int 5931static bool
5988png_load (struct frame *f, struct image *img) 5932png_load (struct frame *f, struct image *img)
5989{ 5933{
5990 struct png_load_context c; 5934 struct png_load_context c;
@@ -5994,7 +5938,7 @@ png_load (struct frame *f, struct image *img)
5994#else /* HAVE_PNG */ 5938#else /* HAVE_PNG */
5995 5939
5996#ifdef HAVE_NS 5940#ifdef HAVE_NS
5997static int 5941static bool
5998png_load (struct frame *f, struct image *img) 5942png_load (struct frame *f, struct image *img)
5999{ 5943{
6000 return ns_load_image (f, img, 5944 return ns_load_image (f, img,
@@ -6014,8 +5958,8 @@ png_load (struct frame *f, struct image *img)
6014 5958
6015#if defined (HAVE_JPEG) || defined (HAVE_NS) 5959#if defined (HAVE_JPEG) || defined (HAVE_NS)
6016 5960
6017static int jpeg_image_p (Lisp_Object object); 5961static bool jpeg_image_p (Lisp_Object object);
6018static int jpeg_load (struct frame *f, struct image *img); 5962static bool jpeg_load (struct frame *f, struct image *img);
6019 5963
6020/* The symbol `jpeg' identifying images of this type. */ 5964/* The symbol `jpeg' identifying images of this type. */
6021 5965
@@ -6056,7 +6000,7 @@ static const struct image_keyword jpeg_format[JPEG_LAST] =
6056}; 6000};
6057 6001
6058#ifdef HAVE_NTGUI 6002#ifdef HAVE_NTGUI
6059static int init_jpeg_functions (Lisp_Object); 6003static bool init_jpeg_functions (void);
6060#else 6004#else
6061#define init_jpeg_functions NULL 6005#define init_jpeg_functions NULL
6062#endif 6006#endif
@@ -6073,9 +6017,9 @@ static struct image_type jpeg_type =
6073 NULL 6017 NULL
6074}; 6018};
6075 6019
6076/* Return non-zero if OBJECT is a valid JPEG image specification. */ 6020/* Return true if OBJECT is a valid JPEG image specification. */
6077 6021
6078static int 6022static bool
6079jpeg_image_p (Lisp_Object object) 6023jpeg_image_p (Lisp_Object object)
6080{ 6024{
6081 struct image_keyword fmt[JPEG_LAST]; 6025 struct image_keyword fmt[JPEG_LAST];
@@ -6124,12 +6068,12 @@ DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, J
6124DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *)); 6068DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *));
6125DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); 6069DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int));
6126 6070
6127static int 6071static bool
6128init_jpeg_functions (Lisp_Object libraries) 6072init_jpeg_functions (void)
6129{ 6073{
6130 HMODULE library; 6074 HMODULE library;
6131 6075
6132 if (!(library = w32_delayed_load (libraries, Qjpeg))) 6076 if (!(library = w32_delayed_load (Qjpeg)))
6133 return 0; 6077 return 0;
6134 6078
6135 LOAD_IMGLIB_FN (library, jpeg_finish_decompress); 6079 LOAD_IMGLIB_FN (library, jpeg_finish_decompress);
@@ -6394,7 +6338,7 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
6394/* Load image IMG for use on frame F. Patterned after example.c 6338/* Load image IMG for use on frame F. Patterned after example.c
6395 from the JPEG lib. */ 6339 from the JPEG lib. */
6396 6340
6397static int 6341static bool
6398jpeg_load_body (struct frame *f, struct image *img, 6342jpeg_load_body (struct frame *f, struct image *img,
6399 struct my_jpeg_error_mgr *mgr) 6343 struct my_jpeg_error_mgr *mgr)
6400{ 6344{
@@ -6575,7 +6519,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6575 return 1; 6519 return 1;
6576} 6520}
6577 6521
6578static int 6522static bool
6579jpeg_load (struct frame *f, struct image *img) 6523jpeg_load (struct frame *f, struct image *img)
6580{ 6524{
6581 struct my_jpeg_error_mgr mgr; 6525 struct my_jpeg_error_mgr mgr;
@@ -6585,7 +6529,7 @@ jpeg_load (struct frame *f, struct image *img)
6585#else /* HAVE_JPEG */ 6529#else /* HAVE_JPEG */
6586 6530
6587#ifdef HAVE_NS 6531#ifdef HAVE_NS
6588static int 6532static bool
6589jpeg_load (struct frame *f, struct image *img) 6533jpeg_load (struct frame *f, struct image *img)
6590{ 6534{
6591 return ns_load_image (f, img, 6535 return ns_load_image (f, img,
@@ -6604,8 +6548,8 @@ jpeg_load (struct frame *f, struct image *img)
6604 6548
6605#if defined (HAVE_TIFF) || defined (HAVE_NS) 6549#if defined (HAVE_TIFF) || defined (HAVE_NS)
6606 6550
6607static int tiff_image_p (Lisp_Object object); 6551static bool tiff_image_p (Lisp_Object object);
6608static int tiff_load (struct frame *f, struct image *img); 6552static bool tiff_load (struct frame *f, struct image *img);
6609 6553
6610/* The symbol `tiff' identifying images of this type. */ 6554/* The symbol `tiff' identifying images of this type. */
6611 6555
@@ -6648,7 +6592,7 @@ static const struct image_keyword tiff_format[TIFF_LAST] =
6648}; 6592};
6649 6593
6650#ifdef HAVE_NTGUI 6594#ifdef HAVE_NTGUI
6651static int init_tiff_functions (Lisp_Object); 6595static bool init_tiff_functions (void);
6652#else 6596#else
6653#define init_tiff_functions NULL 6597#define init_tiff_functions NULL
6654#endif 6598#endif
@@ -6665,9 +6609,9 @@ static struct image_type tiff_type =
6665 NULL 6609 NULL
6666}; 6610};
6667 6611
6668/* Return non-zero if OBJECT is a valid TIFF image specification. */ 6612/* Return true if OBJECT is a valid TIFF image specification. */
6669 6613
6670static int 6614static bool
6671tiff_image_p (Lisp_Object object) 6615tiff_image_p (Lisp_Object object)
6672{ 6616{
6673 struct image_keyword fmt[TIFF_LAST]; 6617 struct image_keyword fmt[TIFF_LAST];
@@ -6701,12 +6645,12 @@ DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int));
6701DEF_IMGLIB_FN (void, TIFFClose, (TIFF *)); 6645DEF_IMGLIB_FN (void, TIFFClose, (TIFF *));
6702DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); 6646DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t));
6703 6647
6704static int 6648static bool
6705init_tiff_functions (Lisp_Object libraries) 6649init_tiff_functions (void)
6706{ 6650{
6707 HMODULE library; 6651 HMODULE library;
6708 6652
6709 if (!(library = w32_delayed_load (libraries, Qtiff))) 6653 if (!(library = w32_delayed_load (Qtiff)))
6710 return 0; 6654 return 0;
6711 6655
6712 LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); 6656 LOAD_IMGLIB_FN (library, TIFFSetErrorHandler);
@@ -6871,10 +6815,10 @@ tiff_warning_handler (const char *title, const char *format, va_list ap)
6871} 6815}
6872 6816
6873 6817
6874/* Load TIFF image IMG for use on frame F. Value is non-zero if 6818/* Load TIFF image IMG for use on frame F. Value is true if
6875 successful. */ 6819 successful. */
6876 6820
6877static int 6821static bool
6878tiff_load (struct frame *f, struct image *img) 6822tiff_load (struct frame *f, struct image *img)
6879{ 6823{
6880 Lisp_Object file, specified_file; 6824 Lisp_Object file, specified_file;
@@ -7039,7 +6983,7 @@ tiff_load (struct frame *f, struct image *img)
7039#else /* HAVE_TIFF */ 6983#else /* HAVE_TIFF */
7040 6984
7041#ifdef HAVE_NS 6985#ifdef HAVE_NS
7042static int 6986static bool
7043tiff_load (struct frame *f, struct image *img) 6987tiff_load (struct frame *f, struct image *img)
7044{ 6988{
7045 return ns_load_image (f, img, 6989 return ns_load_image (f, img,
@@ -7058,8 +7002,8 @@ tiff_load (struct frame *f, struct image *img)
7058 7002
7059#if defined (HAVE_GIF) || defined (HAVE_NS) 7003#if defined (HAVE_GIF) || defined (HAVE_NS)
7060 7004
7061static int gif_image_p (Lisp_Object object); 7005static bool gif_image_p (Lisp_Object object);
7062static int gif_load (struct frame *f, struct image *img); 7006static bool gif_load (struct frame *f, struct image *img);
7063static void gif_clear_image (struct frame *f, struct image *img); 7007static void gif_clear_image (struct frame *f, struct image *img);
7064 7008
7065/* The symbol `gif' identifying images of this type. */ 7009/* The symbol `gif' identifying images of this type. */
@@ -7103,7 +7047,7 @@ static const struct image_keyword gif_format[GIF_LAST] =
7103}; 7047};
7104 7048
7105#ifdef HAVE_NTGUI 7049#ifdef HAVE_NTGUI
7106static int init_gif_functions (Lisp_Object); 7050static bool init_gif_functions (void);
7107#else 7051#else
7108#define init_gif_functions NULL 7052#define init_gif_functions NULL
7109#endif 7053#endif
@@ -7129,9 +7073,9 @@ gif_clear_image (struct frame *f, struct image *img)
7129 x_clear_image (f, img); 7073 x_clear_image (f, img);
7130} 7074}
7131 7075
7132/* Return non-zero if OBJECT is a valid GIF image specification. */ 7076/* Return true if OBJECT is a valid GIF image specification. */
7133 7077
7134static int 7078static bool
7135gif_image_p (Lisp_Object object) 7079gif_image_p (Lisp_Object object)
7136{ 7080{
7137 struct image_keyword fmt[GIF_LAST]; 7081 struct image_keyword fmt[GIF_LAST];
@@ -7174,12 +7118,12 @@ DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *));
7174DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); 7118DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc));
7175DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *)); 7119DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *));
7176 7120
7177static int 7121static bool
7178init_gif_functions (Lisp_Object libraries) 7122init_gif_functions (void)
7179{ 7123{
7180 HMODULE library; 7124 HMODULE library;
7181 7125
7182 if (!(library = w32_delayed_load (libraries, Qgif))) 7126 if (!(library = w32_delayed_load (Qgif)))
7183 return 0; 7127 return 0;
7184 7128
7185 LOAD_IMGLIB_FN (library, DGifCloseFile); 7129 LOAD_IMGLIB_FN (library, DGifCloseFile);
@@ -7228,7 +7172,7 @@ gif_read_from_memory (GifFileType *file, GifByteType *buf, int len)
7228} 7172}
7229 7173
7230 7174
7231/* Load GIF image IMG for use on frame F. Value is non-zero if 7175/* Load GIF image IMG for use on frame F. Value is true if
7232 successful. */ 7176 successful. */
7233 7177
7234static const int interlace_start[] = {0, 4, 2, 1}; 7178static const int interlace_start[] = {0, 4, 2, 1};
@@ -7236,7 +7180,7 @@ static const int interlace_increment[] = {8, 8, 4, 2};
7236 7180
7237#define GIF_LOCAL_DESCRIPTOR_EXTENSION 249 7181#define GIF_LOCAL_DESCRIPTOR_EXTENSION 249
7238 7182
7239static int 7183static bool
7240gif_load (struct frame *f, struct image *img) 7184gif_load (struct frame *f, struct image *img)
7241{ 7185{
7242 Lisp_Object file; 7186 Lisp_Object file;
@@ -7534,7 +7478,7 @@ gif_load (struct frame *f, struct image *img)
7534#else /* !HAVE_GIF */ 7478#else /* !HAVE_GIF */
7535 7479
7536#ifdef HAVE_NS 7480#ifdef HAVE_NS
7537static int 7481static bool
7538gif_load (struct frame *f, struct image *img) 7482gif_load (struct frame *f, struct image *img)
7539{ 7483{
7540 return ns_load_image (f, img, 7484 return ns_load_image (f, img,
@@ -7553,8 +7497,8 @@ gif_load (struct frame *f, struct image *img)
7553 7497
7554static Lisp_Object Qimagemagick; 7498static Lisp_Object Qimagemagick;
7555 7499
7556static int imagemagick_image_p (Lisp_Object); 7500static bool imagemagick_image_p (Lisp_Object);
7557static int imagemagick_load (struct frame *, struct image *); 7501static bool imagemagick_load (struct frame *, struct image *);
7558static void imagemagick_clear_image (struct frame *, struct image *); 7502static void imagemagick_clear_image (struct frame *, struct image *);
7559 7503
7560/* Indices of image specification fields in imagemagick_format. */ 7504/* Indices of image specification fields in imagemagick_format. */
@@ -7600,7 +7544,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] =
7600 }; 7544 };
7601 7545
7602#ifdef HAVE_NTGUI 7546#ifdef HAVE_NTGUI
7603static int init_imagemagick_functions (Lisp_Object); 7547static bool init_imagemagick_functions (void);
7604#else 7548#else
7605#define init_imagemagick_functions NULL 7549#define init_imagemagick_functions NULL
7606#endif 7550#endif
@@ -7627,11 +7571,11 @@ imagemagick_clear_image (struct frame *f,
7627 x_clear_image (f, img); 7571 x_clear_image (f, img);
7628} 7572}
7629 7573
7630/* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do 7574/* Return true if OBJECT is a valid IMAGEMAGICK image specification. Do
7631 this by calling parse_image_spec and supplying the keywords that 7575 this by calling parse_image_spec and supplying the keywords that
7632 identify the IMAGEMAGICK format. */ 7576 identify the IMAGEMAGICK format. */
7633 7577
7634static int 7578static bool
7635imagemagick_image_p (Lisp_Object object) 7579imagemagick_image_p (Lisp_Object object)
7636{ 7580{
7637 struct image_keyword fmt[IMAGEMAGICK_LAST]; 7581 struct image_keyword fmt[IMAGEMAGICK_LAST];
@@ -7683,9 +7627,9 @@ imagemagick_error (MagickWand *wand)
7683 be parsed; SIZE is the number of bytes of data; and FILENAME is 7627 be parsed; SIZE is the number of bytes of data; and FILENAME is
7684 either the file name or the image data. 7628 either the file name or the image data.
7685 7629
7686 Return non-zero if successful. */ 7630 Return true if successful. */
7687 7631
7688static int 7632static bool
7689imagemagick_load_image (struct frame *f, struct image *img, 7633imagemagick_load_image (struct frame *f, struct image *img,
7690 unsigned char *contents, unsigned int size, 7634 unsigned char *contents, unsigned int size,
7691 char *filename) 7635 char *filename)
@@ -8023,14 +7967,14 @@ imagemagick_load_image (struct frame *f, struct image *img,
8023} 7967}
8024 7968
8025 7969
8026/* Load IMAGEMAGICK image IMG for use on frame F. Value is non-zero if 7970/* Load IMAGEMAGICK image IMG for use on frame F. Value is true if
8027 successful. this function will go into the imagemagick_type structure, and 7971 successful. this function will go into the imagemagick_type structure, and
8028 the prototype thus needs to be compatible with that structure. */ 7972 the prototype thus needs to be compatible with that structure. */
8029 7973
8030static int 7974static bool
8031imagemagick_load (struct frame *f, struct image *img) 7975imagemagick_load (struct frame *f, struct image *img)
8032{ 7976{
8033 int success_p = 0; 7977 bool success_p = 0;
8034 Lisp_Object file_name; 7978 Lisp_Object file_name;
8035 7979
8036 /* If IMG->spec specifies a file name, create a non-file spec from it. */ 7980 /* If IMG->spec specifies a file name, create a non-file spec from it. */
@@ -8109,11 +8053,11 @@ and `imagemagick-types-inhibit'. */)
8109 8053
8110/* Function prototypes. */ 8054/* Function prototypes. */
8111 8055
8112static int svg_image_p (Lisp_Object object); 8056static bool svg_image_p (Lisp_Object object);
8113static int svg_load (struct frame *f, struct image *img); 8057static bool svg_load (struct frame *f, struct image *img);
8114 8058
8115static int svg_load_image (struct frame *, struct image *, 8059static bool svg_load_image (struct frame *, struct image *,
8116 unsigned char *, ptrdiff_t); 8060 unsigned char *, ptrdiff_t);
8117 8061
8118/* The symbol `svg' identifying images of this type. */ 8062/* The symbol `svg' identifying images of this type. */
8119 8063
@@ -8154,7 +8098,7 @@ static const struct image_keyword svg_format[SVG_LAST] =
8154}; 8098};
8155 8099
8156#ifdef HAVE_NTGUI 8100#ifdef HAVE_NTGUI
8157static int init_svg_functions (Lisp_Object); 8101static bool init_svg_functions (void);
8158#else 8102#else
8159#define init_svg_functions NULL 8103#define init_svg_functions NULL
8160#endif 8104#endif
@@ -8174,11 +8118,11 @@ static struct image_type svg_type =
8174}; 8118};
8175 8119
8176 8120
8177/* Return non-zero if OBJECT is a valid SVG image specification. Do 8121/* Return true if OBJECT is a valid SVG image specification. Do
8178 this by calling parse_image_spec and supplying the keywords that 8122 this by calling parse_image_spec and supplying the keywords that
8179 identify the SVG format. */ 8123 identify the SVG format. */
8180 8124
8181static int 8125static bool
8182svg_image_p (Lisp_Object object) 8126svg_image_p (Lisp_Object object)
8183{ 8127{
8184 struct image_keyword fmt[SVG_LAST]; 8128 struct image_keyword fmt[SVG_LAST];
@@ -8217,15 +8161,15 @@ DEF_IMGLIB_FN (void, g_error_free);
8217 8161
8218Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; 8162Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
8219 8163
8220static int 8164static bool
8221init_svg_functions (Lisp_Object libraries) 8165init_svg_functions (void)
8222{ 8166{
8223 HMODULE library, gdklib, glib, gobject; 8167 HMODULE library, gdklib, glib, gobject;
8224 8168
8225 if (!(glib = w32_delayed_load (libraries, Qglib)) 8169 if (!(glib = w32_delayed_load (Qglib))
8226 || !(gobject = w32_delayed_load (libraries, Qgobject)) 8170 || !(gobject = w32_delayed_load (Qgobject))
8227 || !(gdklib = w32_delayed_load (libraries, Qgdk_pixbuf)) 8171 || !(gdklib = w32_delayed_load (Qgdk_pixbuf))
8228 || !(library = w32_delayed_load (libraries, Qsvg))) 8172 || !(library = w32_delayed_load (Qsvg)))
8229 return 0; 8173 return 0;
8230 8174
8231 LOAD_IMGLIB_FN (library, rsvg_handle_new); 8175 LOAD_IMGLIB_FN (library, rsvg_handle_new);
@@ -8273,14 +8217,13 @@ init_svg_functions (Lisp_Object libraries)
8273#define fn_g_error_free g_error_free 8217#define fn_g_error_free g_error_free
8274#endif /* !HAVE_NTGUI */ 8218#endif /* !HAVE_NTGUI */
8275 8219
8276/* Load SVG image IMG for use on frame F. Value is non-zero if 8220/* Load SVG image IMG for use on frame F. Value is true if
8277 successful. this function will go into the svg_type structure, and 8221 successful. */
8278 the prototype thus needs to be compatible with that structure. */
8279 8222
8280static int 8223static bool
8281svg_load (struct frame *f, struct image *img) 8224svg_load (struct frame *f, struct image *img)
8282{ 8225{
8283 int success_p = 0; 8226 bool success_p = 0;
8284 Lisp_Object file_name; 8227 Lisp_Object file_name;
8285 8228
8286 /* If IMG->spec specifies a file name, create a non-file spec from it. */ 8229 /* If IMG->spec specifies a file name, create a non-file spec from it. */
@@ -8333,8 +8276,8 @@ svg_load (struct frame *f, struct image *img)
8333 8276
8334 Uses librsvg to do most of the image processing. 8277 Uses librsvg to do most of the image processing.
8335 8278
8336 Returns non-zero when successful. */ 8279 Returns true when successful. */
8337static int 8280static bool
8338svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ 8281svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */
8339 struct image *img, /* Pointer to emacs image structure. */ 8282 struct image *img, /* Pointer to emacs image structure. */
8340 unsigned char *contents, /* String containing the SVG XML data to be parsed. */ 8283 unsigned char *contents, /* String containing the SVG XML data to be parsed. */
@@ -8501,8 +8444,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8501 8444
8502#ifdef HAVE_GHOSTSCRIPT 8445#ifdef HAVE_GHOSTSCRIPT
8503 8446
8504static int gs_image_p (Lisp_Object object); 8447static bool gs_image_p (Lisp_Object object);
8505static int gs_load (struct frame *f, struct image *img); 8448static bool gs_load (struct frame *f, struct image *img);
8506static void gs_clear_image (struct frame *f, struct image *img); 8449static void gs_clear_image (struct frame *f, struct image *img);
8507 8450
8508/* Keyword symbols. */ 8451/* Keyword symbols. */
@@ -8549,12 +8492,6 @@ static const struct image_keyword gs_format[GS_LAST] =
8549 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 8492 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
8550}; 8493};
8551 8494
8552#ifdef HAVE_NTGUI
8553static int init_gs_functions (Lisp_Object);
8554#else
8555#define init_gs_functions NULL
8556#endif
8557
8558/* Structure describing the image type `ghostscript'. */ 8495/* Structure describing the image type `ghostscript'. */
8559 8496
8560static struct image_type gs_type = 8497static struct image_type gs_type =
@@ -8563,7 +8500,7 @@ static struct image_type gs_type =
8563 gs_image_p, 8500 gs_image_p,
8564 gs_load, 8501 gs_load,
8565 gs_clear_image, 8502 gs_clear_image,
8566 init_gs_functions, 8503 NULL,
8567 NULL 8504 NULL
8568}; 8505};
8569 8506
@@ -8577,10 +8514,10 @@ gs_clear_image (struct frame *f, struct image *img)
8577} 8514}
8578 8515
8579 8516
8580/* Return non-zero if OBJECT is a valid Ghostscript image 8517/* Return true if OBJECT is a valid Ghostscript image
8581 specification. */ 8518 specification. */
8582 8519
8583static int 8520static bool
8584gs_image_p (Lisp_Object object) 8521gs_image_p (Lisp_Object object)
8585{ 8522{
8586 struct image_keyword fmt[GS_LAST]; 8523 struct image_keyword fmt[GS_LAST];
@@ -8617,10 +8554,10 @@ gs_image_p (Lisp_Object object)
8617} 8554}
8618 8555
8619 8556
8620/* Load Ghostscript image IMG for use on frame F. Value is non-zero 8557/* Load Ghostscript image IMG for use on frame F. Value is true
8621 if successful. */ 8558 if successful. */
8622 8559
8623static int 8560static bool
8624gs_load (struct frame *f, struct image *img) 8561gs_load (struct frame *f, struct image *img)
8625{ 8562{
8626 uprintmax_t printnum1, printnum2; 8563 uprintmax_t printnum1, printnum2;
@@ -8656,11 +8593,11 @@ gs_load (struct frame *f, struct image *img)
8656 if (x_check_image_size (0, img->width, img->height)) 8593 if (x_check_image_size (0, img->width, img->height))
8657 { 8594 {
8658 /* Only W32 version did BLOCK_INPUT here. ++kfs */ 8595 /* Only W32 version did BLOCK_INPUT here. ++kfs */
8659 BLOCK_INPUT; 8596 block_input ();
8660 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 8597 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
8661 img->width, img->height, 8598 img->width, img->height,
8662 DefaultDepthOfScreen (FRAME_X_SCREEN (f))); 8599 DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
8663 UNBLOCK_INPUT; 8600 unblock_input ();
8664 } 8601 }
8665 8602
8666 if (!img->pixmap) 8603 if (!img->pixmap)
@@ -8736,7 +8673,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
8736 { 8673 {
8737 XImagePtr ximg; 8674 XImagePtr ximg;
8738 8675
8739 BLOCK_INPUT; 8676 block_input ();
8740 8677
8741 /* Try to get an XImage for img->pixmep. */ 8678 /* Try to get an XImage for img->pixmep. */
8742 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, 8679 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
@@ -8779,15 +8716,15 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
8779 image_error ("Cannot get X image of `%s'; colors will not be freed", 8716 image_error ("Cannot get X image of `%s'; colors will not be freed",
8780 img->spec, Qnil); 8717 img->spec, Qnil);
8781 8718
8782 UNBLOCK_INPUT; 8719 unblock_input ();
8783 } 8720 }
8784#endif /* HAVE_X_WINDOWS */ 8721#endif /* HAVE_X_WINDOWS */
8785 8722
8786 /* Now that we have the pixmap, compute mask and transform the 8723 /* Now that we have the pixmap, compute mask and transform the
8787 image if requested. */ 8724 image if requested. */
8788 BLOCK_INPUT; 8725 block_input ();
8789 postprocess_image (f, img); 8726 postprocess_image (f, img);
8790 UNBLOCK_INPUT; 8727 unblock_input ();
8791} 8728}
8792 8729
8793#endif /* HAVE_GHOSTSCRIPT */ 8730#endif /* HAVE_GHOSTSCRIPT */
@@ -8826,88 +8763,92 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
8826 Initialization 8763 Initialization
8827 ***********************************************************************/ 8764 ***********************************************************************/
8828 8765
8829DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0, 8766DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
8830 doc: /* Initialize image library implementing image type TYPE. 8767 doc: /* Initialize image library implementing image type TYPE.
8831Return non-nil if TYPE is a supported image type. 8768Return non-nil if TYPE is a supported image type.
8832 8769
8833Image types pbm and xbm are prebuilt; other types are loaded here. 8770If image libraries are loaded dynamically (currently only the case on
8834Libraries to load are specified in alist LIBRARIES (usually, the value 8771MS-Windows), load the library for TYPE if it is not yet loaded, using
8835of `dynamic-library-alist', which see). */) 8772the library file(s) specified by `dynamic-library-alist'. */)
8836 (Lisp_Object type, Lisp_Object libraries) 8773 (Lisp_Object type)
8837{ 8774{
8838 return lookup_image_type (type, libraries) ? Qt : Qnil; 8775 return lookup_image_type (type) ? Qt : Qnil;
8839} 8776}
8840 8777
8841/* Look up image type TYPE, and return a pointer to its image_type 8778/* Look up image type TYPE, and return a pointer to its image_type
8842 structure. Return 0 if TYPE is not a known image type. 8779 structure. Return 0 if TYPE is not a known image type. */
8843
8844 LIBRARIES is an alist associating dynamic libraries to external
8845 files implementing them, which is passed to the image library
8846 initialization function if necessary. A nil value defaults to
8847 Vdynamic_library_alist. */
8848 8780
8849static struct image_type * 8781static struct image_type *
8850lookup_image_type (Lisp_Object type, Lisp_Object libraries) 8782lookup_image_type (Lisp_Object type)
8851{ 8783{
8852 if (NILP (libraries))
8853 libraries = Vdynamic_library_alist;
8854
8855 /* Types pbm and xbm are built-in and always available. */ 8784 /* Types pbm and xbm are built-in and always available. */
8856 if (EQ (type, Qpbm)) 8785 if (EQ (type, Qpbm))
8857 return define_image_type (&pbm_type, libraries); 8786 return define_image_type (&pbm_type);
8858 8787
8859 if (EQ (type, Qxbm)) 8788 if (EQ (type, Qxbm))
8860 return define_image_type (&xbm_type, libraries); 8789 return define_image_type (&xbm_type);
8861 8790
8862#if defined (HAVE_XPM) || defined (HAVE_NS) 8791#if defined (HAVE_XPM) || defined (HAVE_NS)
8863 if (EQ (type, Qxpm)) 8792 if (EQ (type, Qxpm))
8864 return define_image_type (&xpm_type, libraries); 8793 return define_image_type (&xpm_type);
8865#endif 8794#endif
8866 8795
8867#if defined (HAVE_JPEG) || defined (HAVE_NS) 8796#if defined (HAVE_JPEG) || defined (HAVE_NS)
8868 if (EQ (type, Qjpeg)) 8797 if (EQ (type, Qjpeg))
8869 return define_image_type (&jpeg_type, libraries); 8798 return define_image_type (&jpeg_type);
8870#endif 8799#endif
8871 8800
8872#if defined (HAVE_TIFF) || defined (HAVE_NS) 8801#if defined (HAVE_TIFF) || defined (HAVE_NS)
8873 if (EQ (type, Qtiff)) 8802 if (EQ (type, Qtiff))
8874 return define_image_type (&tiff_type, libraries); 8803 return define_image_type (&tiff_type);
8875#endif 8804#endif
8876 8805
8877#if defined (HAVE_GIF) || defined (HAVE_NS) 8806#if defined (HAVE_GIF) || defined (HAVE_NS)
8878 if (EQ (type, Qgif)) 8807 if (EQ (type, Qgif))
8879 return define_image_type (&gif_type, libraries); 8808 return define_image_type (&gif_type);
8880#endif 8809#endif
8881 8810
8882#if defined (HAVE_PNG) || defined (HAVE_NS) 8811#if defined (HAVE_PNG) || defined (HAVE_NS)
8883 if (EQ (type, Qpng)) 8812 if (EQ (type, Qpng))
8884 return define_image_type (&png_type, libraries); 8813 return define_image_type (&png_type);
8885#endif 8814#endif
8886 8815
8887#if defined (HAVE_RSVG) 8816#if defined (HAVE_RSVG)
8888 if (EQ (type, Qsvg)) 8817 if (EQ (type, Qsvg))
8889 return define_image_type (&svg_type, libraries); 8818 return define_image_type (&svg_type);
8890#endif 8819#endif
8891 8820
8892#if defined (HAVE_IMAGEMAGICK) 8821#if defined (HAVE_IMAGEMAGICK)
8893 if (EQ (type, Qimagemagick)) 8822 if (EQ (type, Qimagemagick))
8894 return define_image_type (&imagemagick_type, libraries); 8823 return define_image_type (&imagemagick_type);
8895#endif 8824#endif
8896 8825
8897#ifdef HAVE_GHOSTSCRIPT 8826#ifdef HAVE_GHOSTSCRIPT
8898 if (EQ (type, Qpostscript)) 8827 if (EQ (type, Qpostscript))
8899 return define_image_type (&gs_type, libraries); 8828 return define_image_type (&gs_type);
8900#endif 8829#endif
8901 8830
8902 return NULL; 8831 return NULL;
8903} 8832}
8904 8833
8834/* Reset image_types before dumping.
8835 Called from Fdump_emacs. */
8836
8837void
8838reset_image_types (void)
8839{
8840 while (image_types)
8841 {
8842 struct image_type *next = image_types->next;
8843 xfree (image_types);
8844 image_types = next;
8845 }
8846}
8847
8905void 8848void
8906syms_of_image (void) 8849syms_of_image (void)
8907{ 8850{
8908 /* Initialize this only once, since that's what we do with Vimage_types 8851 /* Initialize this only once; it will be reset before dumping. */
8909 and they are supposed to be in sync. Initializing here gives correct
8910 operation on GNU/Linux of calling dump-emacs after loading some images. */
8911 image_types = NULL; 8852 image_types = NULL;
8912 8853
8913 /* Must be defined now because we're going to update it below, while 8854 /* Must be defined now because we're going to update it below, while
diff --git a/src/indent.c b/src/indent.c
index 053643e6319..b368a7aeb09 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -115,7 +115,7 @@ character_width (int c, struct Lisp_Char_Table *dp)
115 for characters as WIDTHTAB. We use this to decide when to 115 for characters as WIDTHTAB. We use this to decide when to
116 invalidate the buffer's width_run_cache. */ 116 invalidate the buffer's width_run_cache. */
117 117
118int 118bool
119disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *widthtab) 119disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *widthtab)
120{ 120{
121 int i; 121 int i;
@@ -320,14 +320,14 @@ invalidate_current_column (void)
320ptrdiff_t 320ptrdiff_t
321current_column (void) 321current_column (void)
322{ 322{
323 register ptrdiff_t col; 323 ptrdiff_t col;
324 register unsigned char *ptr, *stop; 324 unsigned char *ptr, *stop;
325 register int tab_seen; 325 bool tab_seen;
326 ptrdiff_t post_tab; 326 ptrdiff_t post_tab;
327 register int c; 327 int c;
328 int tab_width = SANE_TAB_WIDTH (current_buffer); 328 int tab_width = SANE_TAB_WIDTH (current_buffer);
329 int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 329 bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
330 register struct Lisp_Char_Table *dp = buffer_display_table (); 330 struct Lisp_Char_Table *dp = buffer_display_table ();
331 331
332 if (PT == last_known_column_point 332 if (PT == last_known_column_point
333 && MODIFF == last_known_column_modified) 333 && MODIFF == last_known_column_modified)
@@ -512,9 +512,9 @@ static void
512scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol) 512scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol)
513{ 513{
514 int tab_width = SANE_TAB_WIDTH (current_buffer); 514 int tab_width = SANE_TAB_WIDTH (current_buffer);
515 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 515 bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
516 register struct Lisp_Char_Table *dp = buffer_display_table (); 516 struct Lisp_Char_Table *dp = buffer_display_table ();
517 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 517 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
518 struct composition_it cmp_it; 518 struct composition_it cmp_it;
519 Lisp_Object window; 519 Lisp_Object window;
520 struct window *w; 520 struct window *w;
@@ -722,14 +722,14 @@ current_column_1 (void)
722static double 722static double
723string_display_width (Lisp_Object string, Lisp_Object beg, Lisp_Object end) 723string_display_width (Lisp_Object string, Lisp_Object beg, Lisp_Object end)
724{ 724{
725 register int col; 725 int col;
726 register unsigned char *ptr, *stop; 726 unsigned char *ptr, *stop;
727 register int tab_seen; 727 bool tab_seen;
728 int post_tab; 728 int post_tab;
729 register int c; 729 int c;
730 int tab_width = SANE_TAB_WIDTH (current_buffer); 730 int tab_width = SANE_TAB_WIDTH (current_buffer);
731 int ctl_arrow = !NILP (current_buffer->ctl_arrow); 731 bool ctl_arrow = !NILP (current_buffer->ctl_arrow);
732 register struct Lisp_Char_Table *dp = buffer_display_table (); 732 struct Lisp_Char_Table *dp = buffer_display_table ();
733 int b, e; 733 int b, e;
734 734
735 if (NILP (end)) 735 if (NILP (end))
@@ -945,7 +945,7 @@ position_indentation (ptrdiff_t pos_byte)
945 Blank lines are treated as if they had the same indentation as the 945 Blank lines are treated as if they had the same indentation as the
946 preceding line. */ 946 preceding line. */
947 947
948int 948bool
949indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column) 949indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column)
950{ 950{
951 ptrdiff_t val; 951 ptrdiff_t val;
@@ -1047,11 +1047,11 @@ static struct position val_compute_motion;
1047 can't hit the requested column exactly (because of a tab or other 1047 can't hit the requested column exactly (because of a tab or other
1048 multi-column character), overshoot. 1048 multi-column character), overshoot.
1049 1049
1050 DID_MOTION is 1 if FROMHPOS has already accounted for overlay strings 1050 DID_MOTION is true if FROMHPOS has already accounted for overlay strings
1051 at FROM. This is the case if FROMVPOS and FROMVPOS came from an 1051 at FROM. This is the case if FROMVPOS and FROMVPOS came from an
1052 earlier call to compute_motion. The other common case is that FROMHPOS 1052 earlier call to compute_motion. The other common case is that FROMHPOS
1053 is zero and FROM is a position that "belongs" at column zero, but might 1053 is zero and FROM is a position that "belongs" at column zero, but might
1054 be shifted by overlay strings; in this case DID_MOTION should be 0. 1054 be shifted by overlay strings; in this case DID_MOTION should be false.
1055 1055
1056 WIDTH is the number of columns available to display text; 1056 WIDTH is the number of columns available to display text;
1057 compute_motion uses this to handle continuation lines and such. 1057 compute_motion uses this to handle continuation lines and such.
@@ -1104,17 +1104,20 @@ static struct position val_compute_motion;
1104 the scroll bars if they are turned on. */ 1104 the scroll bars if they are turned on. */
1105 1105
1106struct position * 1106struct position *
1107compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_motion, ptrdiff_t to, EMACS_INT tovpos, EMACS_INT tohpos, EMACS_INT width, ptrdiff_t hscroll, int tab_offset, struct window *win) 1107compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos,
1108 bool did_motion, ptrdiff_t to,
1109 EMACS_INT tovpos, EMACS_INT tohpos, EMACS_INT width,
1110 ptrdiff_t hscroll, int tab_offset, struct window *win)
1108{ 1111{
1109 register EMACS_INT hpos = fromhpos; 1112 EMACS_INT hpos = fromhpos;
1110 register EMACS_INT vpos = fromvpos; 1113 EMACS_INT vpos = fromvpos;
1111 1114
1112 register ptrdiff_t pos; 1115 ptrdiff_t pos;
1113 ptrdiff_t pos_byte; 1116 ptrdiff_t pos_byte;
1114 register int c = 0; 1117 int c = 0;
1115 int tab_width = SANE_TAB_WIDTH (current_buffer); 1118 int tab_width = SANE_TAB_WIDTH (current_buffer);
1116 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 1119 bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
1117 register struct Lisp_Char_Table *dp = window_display_table (win); 1120 struct Lisp_Char_Table *dp = window_display_table (win);
1118 EMACS_INT selective 1121 EMACS_INT selective
1119 = (INTEGERP (BVAR (current_buffer, selective_display)) 1122 = (INTEGERP (BVAR (current_buffer, selective_display))
1120 ? XINT (BVAR (current_buffer, selective_display)) 1123 ? XINT (BVAR (current_buffer, selective_display))
@@ -1139,7 +1142,7 @@ compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1139 ptrdiff_t next_width_run = from; 1142 ptrdiff_t next_width_run = from;
1140 Lisp_Object window; 1143 Lisp_Object window;
1141 1144
1142 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 1145 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
1143 /* If previous char scanned was a wide character, 1146 /* If previous char scanned was a wide character,
1144 this is the column where it ended. Otherwise, this is 0. */ 1147 this is the column where it ended. Otherwise, this is 0. */
1145 EMACS_INT wide_column_end_hpos = 0; 1148 EMACS_INT wide_column_end_hpos = 0;
@@ -1308,7 +1311,7 @@ compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1308 if (hpos > width) 1311 if (hpos > width)
1309 { 1312 {
1310 EMACS_INT total_width = width + continuation_glyph_width; 1313 EMACS_INT total_width = width + continuation_glyph_width;
1311 int truncate = 0; 1314 bool truncate = 0;
1312 1315
1313 if (!NILP (Vtruncate_partial_width_windows) 1316 if (!NILP (Vtruncate_partial_width_windows)
1314 && (total_width < FRAME_COLS (XFRAME (WINDOW_FRAME (win))))) 1317 && (total_width < FRAME_COLS (XFRAME (WINDOW_FRAME (win)))))
@@ -1827,7 +1830,7 @@ vmotion (register ptrdiff_t from, register EMACS_INT vtarget, struct window *w)
1827 PTRDIFF_MAX) 1830 PTRDIFF_MAX)
1828 : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0); 1831 : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
1829 Lisp_Object window; 1832 Lisp_Object window;
1830 int did_motion; 1833 bool did_motion;
1831 /* This is the object we use for fetching character properties. */ 1834 /* This is the object we use for fetching character properties. */
1832 Lisp_Object text_prop_object; 1835 Lisp_Object text_prop_object;
1833 1836
@@ -2017,8 +2020,8 @@ whether or not it is currently displayed in some window. */)
2017 { 2020 {
2018 ptrdiff_t it_start, it_overshoot_count = 0; 2021 ptrdiff_t it_start, it_overshoot_count = 0;
2019 int first_x; 2022 int first_x;
2020 int overshoot_handled = 0; 2023 bool overshoot_handled = 0;
2021 int disp_string_at_start_p = 0; 2024 bool disp_string_at_start_p = 0;
2022 2025
2023 itdata = bidi_shelve_cache (); 2026 itdata = bidi_shelve_cache ();
2024 SET_TEXT_POS (pt, PT, PT_BYTE); 2027 SET_TEXT_POS (pt, PT, PT_BYTE);
diff --git a/src/indent.h b/src/indent.h
index e198137a756..abcd06036d1 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -27,7 +27,7 @@ struct position
27 }; 27 };
28 28
29struct position *compute_motion (ptrdiff_t from, EMACS_INT fromvpos, 29struct position *compute_motion (ptrdiff_t from, EMACS_INT fromvpos,
30 EMACS_INT fromhpos, int did_motion, 30 EMACS_INT fromhpos, bool did_motion,
31 ptrdiff_t to, EMACS_INT tovpos, 31 ptrdiff_t to, EMACS_INT tovpos,
32 EMACS_INT tohpos, 32 EMACS_INT tohpos,
33 EMACS_INT width, ptrdiff_t hscroll, 33 EMACS_INT width, ptrdiff_t hscroll,
@@ -45,8 +45,8 @@ extern ptrdiff_t last_known_column_point;
45/* Return true if the display table DISPTAB specifies the same widths 45/* Return true if the display table DISPTAB specifies the same widths
46 for characters as WIDTHTAB. We use this to decide when to 46 for characters as WIDTHTAB. We use this to decide when to
47 invalidate the buffer's column_cache. */ 47 invalidate the buffer's column_cache. */
48int disptab_matches_widthtab (struct Lisp_Char_Table *disptab, 48bool disptab_matches_widthtab (struct Lisp_Char_Table *disptab,
49 struct Lisp_Vector *widthtab); 49 struct Lisp_Vector *widthtab);
50 50
51/* Recompute BUF's width table, using the display table DISPTAB. */ 51/* Recompute BUF's width table, using the display table DISPTAB. */
52void recompute_width_table (struct buffer *buf, 52void recompute_width_table (struct buffer *buf,
diff --git a/src/keyboard.c b/src/keyboard.c
index 8b1113a026a..f3d7df5e98f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#define BLOCKINPUT_INLINE EXTERN_INLINE
22#define KEYBOARD_INLINE EXTERN_INLINE 23#define KEYBOARD_INLINE EXTERN_INLINE
23 24
24#include <stdio.h> 25#include <stdio.h>
@@ -72,19 +73,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
72 73
73/* Variables for blockinput.h: */ 74/* Variables for blockinput.h: */
74 75
75/* Non-zero if interrupt input is blocked right now. */ 76/* Positive if interrupt input is blocked right now. */
76volatile int interrupt_input_blocked; 77volatile int interrupt_input_blocked;
77 78
78/* Nonzero means an input interrupt has arrived 79/* Nonzero means an input interrupt or alarm signal has arrived.
79 during the current critical section. */ 80 The QUIT macro checks this. */
80int interrupt_input_pending; 81volatile int pending_signals;
81
82/* This var should be (interrupt_input_pending || pending_atimers).
83 The QUIT macro checks this instead of interrupt_input_pending and
84 pending_atimers separately, to reduce code size. So, any code that
85 changes interrupt_input_pending or pending_atimers should update
86 this too. */
87int pending_signals;
88 82
89#define KBD_BUFFER_SIZE 4096 83#define KBD_BUFFER_SIZE 4096
90 84
@@ -225,7 +219,11 @@ static Lisp_Object last_point_position_window;
225 last event came from a macro. We use this to determine when to 219 last event came from a macro. We use this to determine when to
226 generate switch-frame events. This may be cleared by functions 220 generate switch-frame events. This may be cleared by functions
227 like Fselect_frame, to make sure that a switch-frame event is 221 like Fselect_frame, to make sure that a switch-frame event is
228 generated by the next character. */ 222 generated by the next character.
223
224 FIXME: This is modified by a signal handler so it should be volatile.
225 It's exported to Lisp, though, so it can't simply be marked
226 'volatile' here. */
229Lisp_Object internal_last_event_frame; 227Lisp_Object internal_last_event_frame;
230 228
231/* The timestamp of the last input event we received from the X server. 229/* The timestamp of the last input event we received from the X server.
@@ -389,7 +387,7 @@ int interrupts_deferred;
389 387
390/* If we support a window system, turn on the code to poll periodically 388/* If we support a window system, turn on the code to poll periodically
391 to detect C-g. It isn't actually used when doing interrupt input. */ 389 to detect C-g. It isn't actually used when doing interrupt input. */
392#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 390#ifdef HAVE_WINDOW_SYSTEM
393#define POLL_FOR_INPUT 391#define POLL_FOR_INPUT
394#endif 392#endif
395 393
@@ -413,7 +411,6 @@ static EMACS_TIME timer_last_idleness_start_time;
413/* Function for init_keyboard to call with no args (if nonzero). */ 411/* Function for init_keyboard to call with no args (if nonzero). */
414static void (*keyboard_init_hook) (void); 412static void (*keyboard_init_hook) (void);
415 413
416static int read_avail_input (void);
417static void get_input_pending (int *, int); 414static void get_input_pending (int *, int);
418static int readable_events (int); 415static int readable_events (int);
419static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, 416static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *,
@@ -440,7 +437,7 @@ static Lisp_Object restore_kboard_configuration (Lisp_Object);
440#ifdef USABLE_SIGIO 437#ifdef USABLE_SIGIO
441static void deliver_input_available_signal (int signo); 438static void deliver_input_available_signal (int signo);
442#endif 439#endif
443static void handle_interrupt (void); 440static void handle_interrupt (bool);
444static _Noreturn void quit_throw_to_read_char (int); 441static _Noreturn void quit_throw_to_read_char (int);
445static void process_special_events (void); 442static void process_special_events (void);
446static void timer_start_idle (void); 443static void timer_start_idle (void);
@@ -823,7 +820,7 @@ This function is called by the editor initialization to begin editing. */)
823 820
824 /* If we enter while input is blocked, don't lock up here. 821 /* If we enter while input is blocked, don't lock up here.
825 This may happen through the debugger during redisplay. */ 822 This may happen through the debugger during redisplay. */
826 if (INPUT_BLOCKED_P) 823 if (input_blocked_p ())
827 return Qnil; 824 return Qnil;
828 825
829 command_loop_level++; 826 command_loop_level++;
@@ -1216,8 +1213,7 @@ This also exits all active minibuffers. */)
1216 1213
1217 /* Unblock input if we enter with input blocked. This may happen if 1214 /* Unblock input if we enter with input blocked. This may happen if
1218 redisplay traps e.g. during tool-bar update with input blocked. */ 1215 redisplay traps e.g. during tool-bar update with input blocked. */
1219 while (INPUT_BLOCKED_P) 1216 totally_unblock_input ();
1220 UNBLOCK_INPUT;
1221 1217
1222 Fthrow (Qtop_level, Qnil); 1218 Fthrow (Qtop_level, Qnil);
1223} 1219}
@@ -1460,15 +1456,6 @@ command_loop_1 (void)
1460 } 1456 }
1461 } 1457 }
1462 1458
1463#if 0
1464 /* Select the frame that the last event came from. Usually,
1465 switch-frame events will take care of this, but if some lisp
1466 code swallows a switch-frame event, we'll fix things up here.
1467 Is this a good idea? */
1468 if (FRAMEP (internal_last_event_frame)
1469 && !EQ (internal_last_event_frame, selected_frame))
1470 Fselect_frame (internal_last_event_frame, Qnil);
1471#endif
1472 /* If it has changed current-menubar from previous value, 1459 /* If it has changed current-menubar from previous value,
1473 really recompute the menubar from the value. */ 1460 really recompute the menubar from the value. */
1474 if (! NILP (Vlucid_menu_bar_dirty_flag) 1461 if (! NILP (Vlucid_menu_bar_dirty_flag)
@@ -2008,9 +1995,9 @@ static struct atimer *poll_timer;
2008void 1995void
2009poll_for_input_1 (void) 1996poll_for_input_1 (void)
2010{ 1997{
2011 if (interrupt_input_blocked == 0 1998 if (! input_blocked_p ()
2012 && !waiting_for_input) 1999 && !waiting_for_input)
2013 read_avail_input (); 2000 gobble_input ();
2014} 2001}
2015 2002
2016/* Timer callback function for poll_timer. TIMER is equal to 2003/* Timer callback function for poll_timer. TIMER is equal to
@@ -2020,10 +2007,7 @@ static void
2020poll_for_input (struct atimer *timer) 2007poll_for_input (struct atimer *timer)
2021{ 2008{
2022 if (poll_suppress_count == 0) 2009 if (poll_suppress_count == 0)
2023 { 2010 pending_signals = 1;
2024 interrupt_input_pending = 1;
2025 pending_signals = 1;
2026 }
2027} 2011}
2028 2012
2029#endif /* POLL_FOR_INPUT */ 2013#endif /* POLL_FOR_INPUT */
@@ -3344,7 +3328,7 @@ record_char (Lisp_Object c)
3344 If you, dear reader, have a better idea, you've got the source. :-) */ 3328 If you, dear reader, have a better idea, you've got the source. :-) */
3345 if (dribble) 3329 if (dribble)
3346 { 3330 {
3347 BLOCK_INPUT; 3331 block_input ();
3348 if (INTEGERP (c)) 3332 if (INTEGERP (c))
3349 { 3333 {
3350 if (XUINT (c) < 0x100) 3334 if (XUINT (c) < 0x100)
@@ -3370,7 +3354,7 @@ record_char (Lisp_Object c)
3370 } 3354 }
3371 3355
3372 fflush (dribble); 3356 fflush (dribble);
3373 UNBLOCK_INPUT; 3357 unblock_input ();
3374 } 3358 }
3375} 3359}
3376 3360
@@ -3514,10 +3498,8 @@ kbd_buffer_store_event (register struct input_event *event)
3514 Else, if EVENT is a quit event, store the quit event 3498 Else, if EVENT is a quit event, store the quit event
3515 in HOLD_QUIT, and return (thus ignoring further events). 3499 in HOLD_QUIT, and return (thus ignoring further events).
3516 3500
3517 This is used in read_avail_input to postpone the processing 3501 This is used to postpone the processing of the quit event until all
3518 of the quit event until all subsequent input events have been 3502 subsequent input events have been parsed (and discarded). */
3519 parsed (and discarded).
3520 */
3521 3503
3522void 3504void
3523kbd_buffer_store_event_hold (register struct input_event *event, 3505kbd_buffer_store_event_hold (register struct input_event *event,
@@ -3587,7 +3569,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3587 } 3569 }
3588 3570
3589 last_event_timestamp = event->timestamp; 3571 last_event_timestamp = event->timestamp;
3590 handle_interrupt (); 3572
3573 handle_interrupt (0);
3591 return; 3574 return;
3592 } 3575 }
3593 3576
@@ -3643,7 +3626,6 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3643 if (immediate_quit && NILP (Vinhibit_quit)) 3626 if (immediate_quit && NILP (Vinhibit_quit))
3644 { 3627 {
3645 immediate_quit = 0; 3628 immediate_quit = 0;
3646 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3647 QUIT; 3629 QUIT;
3648 } 3630 }
3649 } 3631 }
@@ -3793,14 +3775,6 @@ kbd_buffer_get_event (KBOARD **kbp,
3793 /* Start reading input again, we have processed enough so we can 3775 /* Start reading input again, we have processed enough so we can
3794 accept new events again. */ 3776 accept new events again. */
3795 unhold_keyboard_input (); 3777 unhold_keyboard_input ();
3796#ifdef USABLE_SIGIO
3797 if (!noninteractive)
3798 {
3799 struct sigaction action;
3800 emacs_sigaction_init (&action, deliver_input_available_signal);
3801 sigaction (SIGIO, &action, 0);
3802 }
3803#endif
3804 start_polling (); 3778 start_polling ();
3805 } 3779 }
3806#endif /* subprocesses */ 3780#endif /* subprocesses */
@@ -3869,7 +3843,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3869 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); 3843 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0);
3870 3844
3871 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) 3845 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr)
3872 read_avail_input (); 3846 gobble_input ();
3873 } 3847 }
3874 3848
3875 if (CONSP (Vunread_command_events)) 3849 if (CONSP (Vunread_command_events))
@@ -4496,6 +4470,9 @@ timer_check (void)
4496 Lisp_Object timers, idle_timers; 4470 Lisp_Object timers, idle_timers;
4497 struct gcpro gcpro1, gcpro2; 4471 struct gcpro gcpro1, gcpro2;
4498 4472
4473 Lisp_Object tem = Vinhibit_quit;
4474 Vinhibit_quit = Qt;
4475
4499 /* We use copies of the timers' lists to allow a timer to add itself 4476 /* We use copies of the timers' lists to allow a timer to add itself
4500 again, without locking up Emacs if the newly added timer is 4477 again, without locking up Emacs if the newly added timer is
4501 already ripe when added. */ 4478 already ripe when added. */
@@ -4508,6 +4485,8 @@ timer_check (void)
4508 else 4485 else
4509 idle_timers = Qnil; 4486 idle_timers = Qnil;
4510 4487
4488 Vinhibit_quit = tem;
4489
4511 GCPRO2 (timers, idle_timers); 4490 GCPRO2 (timers, idle_timers);
4512 4491
4513 do 4492 do
@@ -6747,41 +6726,6 @@ get_input_pending (int *addr, int flags)
6747 *addr = (!NILP (Vquit_flag) || readable_events (flags)); 6726 *addr = (!NILP (Vquit_flag) || readable_events (flags));
6748} 6727}
6749 6728
6750/* Interface to read_avail_input, blocking SIGIO or SIGALRM if necessary. */
6751
6752void
6753gobble_input (void)
6754{
6755#ifdef USABLE_SIGIO
6756 if (interrupt_input)
6757 {
6758 sigset_t blocked, procmask;
6759 sigemptyset (&blocked);
6760 sigaddset (&blocked, SIGIO);
6761 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6762 read_avail_input ();
6763 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6764 }
6765 else
6766#ifdef POLL_FOR_INPUT
6767 /* XXX This condition was (read_socket_hook && !interrupt_input),
6768 but read_socket_hook is not global anymore. Let's pretend that
6769 it's always set. */
6770 if (!interrupt_input && poll_suppress_count == 0)
6771 {
6772 sigset_t blocked, procmask;
6773 sigemptyset (&blocked);
6774 sigaddset (&blocked, SIGALRM);
6775 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6776 read_avail_input ();
6777 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6778 }
6779 else
6780#endif
6781#endif
6782 read_avail_input ();
6783}
6784
6785/* Put a BUFFER_SWITCH_EVENT in the buffer 6729/* Put a BUFFER_SWITCH_EVENT in the buffer
6786 so that read_key_sequence will notice the new current buffer. */ 6730 so that read_key_sequence will notice the new current buffer. */
6787 6731
@@ -6809,14 +6753,7 @@ record_asynch_buffer_change (void)
6809 /* Make sure no interrupt happens while storing the event. */ 6753 /* Make sure no interrupt happens while storing the event. */
6810#ifdef USABLE_SIGIO 6754#ifdef USABLE_SIGIO
6811 if (interrupt_input) 6755 if (interrupt_input)
6812 { 6756 kbd_buffer_store_event (&event);
6813 sigset_t blocked, procmask;
6814 sigemptyset (&blocked);
6815 sigaddset (&blocked, SIGIO);
6816 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6817 kbd_buffer_store_event (&event);
6818 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6819 }
6820 else 6757 else
6821#endif 6758#endif
6822 { 6759 {
@@ -6829,13 +6766,11 @@ record_asynch_buffer_change (void)
6829/* Read any terminal input already buffered up by the system 6766/* Read any terminal input already buffered up by the system
6830 into the kbd_buffer, but do not wait. 6767 into the kbd_buffer, but do not wait.
6831 6768
6832 EXPECTED should be nonzero if the caller knows there is some input. 6769 Return the number of keyboard chars read, or -1 meaning
6833
6834 Returns the number of keyboard chars read, or -1 meaning
6835 this is a bad time to try to read input. */ 6770 this is a bad time to try to read input. */
6836 6771
6837static int 6772int
6838read_avail_input (void) 6773gobble_input (void)
6839{ 6774{
6840 int nread = 0; 6775 int nread = 0;
6841 int err = 0; 6776 int err = 0;
@@ -6855,11 +6790,17 @@ read_avail_input (void)
6855 int nr; 6790 int nr;
6856 struct input_event hold_quit; 6791 struct input_event hold_quit;
6857 6792
6793 if (input_blocked_p ())
6794 {
6795 pending_signals = 1;
6796 break;
6797 }
6798
6858 EVENT_INIT (hold_quit); 6799 EVENT_INIT (hold_quit);
6859 hold_quit.kind = NO_EVENT; 6800 hold_quit.kind = NO_EVENT;
6860 6801
6861 /* No need for FIONREAD or fcntl; just say don't wait. */ 6802 /* No need for FIONREAD or fcntl; just say don't wait. */
6862 while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit))) 6803 while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit)))
6863 nread += nr; 6804 nread += nr;
6864 6805
6865 if (nr == -1) /* Not OK to read input now. */ 6806 if (nr == -1) /* Not OK to read input now. */
@@ -6880,7 +6821,7 @@ read_avail_input (void)
6880 this process rather than to the whole process 6821 this process rather than to the whole process
6881 group? Perhaps on systems with FIONREAD Emacs is 6822 group? Perhaps on systems with FIONREAD Emacs is
6882 alone in its group. */ 6823 alone in its group. */
6883 kill (getpid (), SIGHUP); 6824 terminate_due_to_signal (SIGHUP, 10);
6884 6825
6885 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */ 6826 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */
6886 { 6827 {
@@ -7169,34 +7110,68 @@ tty_read_avail_input (struct terminal *terminal,
7169static void 7110static void
7170handle_async_input (void) 7111handle_async_input (void)
7171{ 7112{
7172 interrupt_input_pending = 0; 7113#ifdef USABLE_SIGIO
7173 pending_signals = pending_atimers;
7174
7175 while (1) 7114 while (1)
7176 { 7115 {
7177 int nread = read_avail_input (); 7116 int nread = gobble_input ();
7178 /* -1 means it's not ok to read the input now. 7117 /* -1 means it's not ok to read the input now.
7179 UNBLOCK_INPUT will read it later; now, avoid infinite loop. 7118 UNBLOCK_INPUT will read it later; now, avoid infinite loop.
7180 0 means there was no keyboard input available. */ 7119 0 means there was no keyboard input available. */
7181 if (nread <= 0) 7120 if (nread <= 0)
7182 break; 7121 break;
7183 } 7122 }
7123#endif
7184} 7124}
7185 7125
7186void 7126void
7187process_pending_signals (void) 7127process_pending_signals (void)
7188{ 7128{
7189 if (interrupt_input_pending) 7129 pending_signals = 0;
7190 handle_async_input (); 7130 handle_async_input ();
7191 do_pending_atimers (); 7131 do_pending_atimers ();
7192} 7132}
7193 7133
7134/* Undo any number of BLOCK_INPUT calls down to level LEVEL,
7135 and also (if the level is now 0) reinvoke any pending signal. */
7136
7137void
7138unblock_input_to (int level)
7139{
7140 interrupt_input_blocked = level;
7141 if (level == 0)
7142 {
7143 if (pending_signals)
7144 process_pending_signals ();
7145 }
7146 else if (level < 0)
7147 emacs_abort ();
7148}
7149
7150/* End critical section.
7151
7152 If doing signal-driven input, and a signal came in when input was
7153 blocked, reinvoke the signal handler now to deal with it. */
7154
7155void
7156unblock_input (void)
7157{
7158 unblock_input_to (interrupt_input_blocked - 1);
7159}
7160
7161/* Undo any number of BLOCK_INPUT calls,
7162 and also reinvoke any pending signal. */
7163
7164void
7165totally_unblock_input (void)
7166{
7167 unblock_input_to (0);
7168}
7169
7194#ifdef USABLE_SIGIO 7170#ifdef USABLE_SIGIO
7195 7171
7196static void 7172void
7197handle_input_available_signal (int sig) 7173handle_input_available_signal (int sig)
7198{ 7174{
7199 interrupt_input_pending = 1;
7200 pending_signals = 1; 7175 pending_signals = 1;
7201 7176
7202 if (input_available_clear_time) 7177 if (input_available_clear_time)
@@ -7206,25 +7181,10 @@ handle_input_available_signal (int sig)
7206static void 7181static void
7207deliver_input_available_signal (int sig) 7182deliver_input_available_signal (int sig)
7208{ 7183{
7209 handle_on_main_thread (sig, handle_input_available_signal); 7184 deliver_process_signal (sig, handle_input_available_signal);
7210} 7185}
7211#endif /* USABLE_SIGIO */ 7186#endif /* USABLE_SIGIO */
7212 7187
7213/* Send ourselves a SIGIO.
7214
7215 This function exists so that the UNBLOCK_INPUT macro in
7216 blockinput.h can have some way to take care of input we put off
7217 dealing with, without assuming that every file which uses
7218 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */
7219void
7220reinvoke_input_signal (void)
7221{
7222#ifdef USABLE_SIGIO
7223 handle_async_input ();
7224#endif
7225}
7226
7227
7228 7188
7229/* User signal events. */ 7189/* User signal events. */
7230 7190
@@ -7295,7 +7255,7 @@ handle_user_signal (int sig)
7295 p->npending++; 7255 p->npending++;
7296#ifdef USABLE_SIGIO 7256#ifdef USABLE_SIGIO
7297 if (interrupt_input) 7257 if (interrupt_input)
7298 kill (getpid (), SIGIO); 7258 handle_input_available_signal (sig);
7299 else 7259 else
7300#endif 7260#endif
7301 { 7261 {
@@ -7311,7 +7271,7 @@ handle_user_signal (int sig)
7311static void 7271static void
7312deliver_user_signal (int sig) 7272deliver_user_signal (int sig)
7313{ 7273{
7314 handle_on_main_thread (sig, handle_user_signal); 7274 deliver_process_signal (sig, handle_user_signal);
7315} 7275}
7316 7276
7317static char * 7277static char *
@@ -7336,8 +7296,6 @@ store_user_signal_events (void)
7336 for (p = user_signals; p; p = p->next) 7296 for (p = user_signals; p; p = p->next)
7337 if (p->npending > 0) 7297 if (p->npending > 0)
7338 { 7298 {
7339 sigset_t blocked, procmask;
7340
7341 if (! buf_initialized) 7299 if (! buf_initialized)
7342 { 7300 {
7343 memset (&buf, 0, sizeof buf); 7301 memset (&buf, 0, sizeof buf);
@@ -7346,10 +7304,6 @@ store_user_signal_events (void)
7346 buf_initialized = 1; 7304 buf_initialized = 1;
7347 } 7305 }
7348 7306
7349 sigemptyset (&blocked);
7350 sigaddset (&blocked, p->sig);
7351 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
7352
7353 do 7307 do
7354 { 7308 {
7355 buf.code = p->sig; 7309 buf.code = p->sig;
@@ -7357,8 +7311,6 @@ store_user_signal_events (void)
7357 p->npending--; 7311 p->npending--;
7358 } 7312 }
7359 while (p->npending > 0); 7313 while (p->npending > 0);
7360
7361 pthread_sigmask (SIG_SETMASK, &procmask, 0);
7362 } 7314 }
7363} 7315}
7364 7316
@@ -10563,9 +10515,9 @@ The file will be closed when Emacs exits. */)
10563{ 10515{
10564 if (dribble) 10516 if (dribble)
10565 { 10517 {
10566 BLOCK_INPUT; 10518 block_input ();
10567 fclose (dribble); 10519 fclose (dribble);
10568 UNBLOCK_INPUT; 10520 unblock_input ();
10569 dribble = 0; 10521 dribble = 0;
10570 } 10522 }
10571 if (!NILP (file)) 10523 if (!NILP (file))
@@ -10754,21 +10706,21 @@ handle_interrupt_signal (int sig)
10754 from the controlling tty. */ 10706 from the controlling tty. */
10755 internal_last_event_frame = terminal->display_info.tty->top_frame; 10707 internal_last_event_frame = terminal->display_info.tty->top_frame;
10756 10708
10757 handle_interrupt (); 10709 handle_interrupt (1);
10758 } 10710 }
10759} 10711}
10760 10712
10761static void 10713static void
10762deliver_interrupt_signal (int sig) 10714deliver_interrupt_signal (int sig)
10763{ 10715{
10764 handle_on_main_thread (sig, handle_interrupt_signal); 10716 deliver_process_signal (sig, handle_interrupt_signal);
10765} 10717}
10766 10718
10767 10719
10768/* If Emacs is stuck because `inhibit-quit' is true, then keep track 10720/* If Emacs is stuck because `inhibit-quit' is true, then keep track
10769 of the number of times C-g has been requested. If C-g is pressed 10721 of the number of times C-g has been requested. If C-g is pressed
10770 enough times, then quit anyway. See bug#6585. */ 10722 enough times, then quit anyway. See bug#6585. */
10771static int force_quit_count; 10723static int volatile force_quit_count;
10772 10724
10773/* This routine is called at interrupt level in response to C-g. 10725/* This routine is called at interrupt level in response to C-g.
10774 10726
@@ -10782,7 +10734,7 @@ static int force_quit_count;
10782 non-nil, it stops the job right away. */ 10734 non-nil, it stops the job right away. */
10783 10735
10784static void 10736static void
10785handle_interrupt (void) 10737handle_interrupt (bool in_signal_handler)
10786{ 10738{
10787 char c; 10739 char c;
10788 10740
@@ -10791,13 +10743,16 @@ handle_interrupt (void)
10791 /* XXX This code needs to be revised for multi-tty support. */ 10743 /* XXX This code needs to be revised for multi-tty support. */
10792 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty")) 10744 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty"))
10793 { 10745 {
10794 /* If SIGINT isn't blocked, don't let us be interrupted by 10746 if (! in_signal_handler)
10795 another SIGINT, it might be harmful due to non-reentrancy 10747 {
10796 in I/O functions. */ 10748 /* If SIGINT isn't blocked, don't let us be interrupted by
10797 sigset_t blocked; 10749 a SIGINT. It might be harmful due to non-reentrancy
10798 sigemptyset (&blocked); 10750 in I/O functions. */
10799 sigaddset (&blocked, SIGINT); 10751 sigset_t blocked;
10800 pthread_sigmask (SIG_BLOCK, &blocked, 0); 10752 sigemptyset (&blocked);
10753 sigaddset (&blocked, SIGINT);
10754 pthread_sigmask (SIG_BLOCK, &blocked, 0);
10755 }
10801 10756
10802 fflush (stdout); 10757 fflush (stdout);
10803 reset_all_sys_modes (); 10758 reset_all_sys_modes ();
@@ -10868,7 +10823,6 @@ handle_interrupt (void)
10868#endif /* not MSDOS */ 10823#endif /* not MSDOS */
10869 fflush (stdout); 10824 fflush (stdout);
10870 init_all_sys_modes (); 10825 init_all_sys_modes ();
10871 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10872 } 10826 }
10873 else 10827 else
10874 { 10828 {
@@ -10886,15 +10840,14 @@ handle_interrupt (void)
10886 GCPRO4 (saved.object, saved.global_code, 10840 GCPRO4 (saved.object, saved.global_code,
10887 saved.current_syntax_table, saved.old_prop); 10841 saved.current_syntax_table, saved.old_prop);
10888 Fsignal (Qquit, Qnil); 10842 Fsignal (Qquit, Qnil);
10889 /* FIXME: AFAIK, `quit' can never return, so this code is dead! */
10890 gl_state = saved; 10843 gl_state = saved;
10891 UNGCPRO; 10844 UNGCPRO;
10892 } 10845 }
10893 else 10846 else
10894 { /* Else request quit when it's safe. */ 10847 { /* Else request quit when it's safe. */
10895 if (NILP (Vquit_flag)) 10848 int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1;
10896 force_quit_count = 0; 10849 force_quit_count = count;
10897 if (++force_quit_count == 3) 10850 if (count == 3)
10898 { 10851 {
10899 immediate_quit = 1; 10852 immediate_quit = 1;
10900 Vinhibit_quit = Qnil; 10853 Vinhibit_quit = Qnil;
@@ -10903,6 +10856,8 @@ handle_interrupt (void)
10903 } 10856 }
10904 } 10857 }
10905 10858
10859 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10860
10906/* TODO: The longjmp in this call throws the NS event loop integration off, 10861/* TODO: The longjmp in this call throws the NS event loop integration off,
10907 and it seems to do fine without this. Probably some attention 10862 and it seems to do fine without this. Probably some attention
10908 needs to be paid to the setting of waiting_for_input in 10863 needs to be paid to the setting of waiting_for_input in
@@ -10912,7 +10867,7 @@ handle_interrupt (void)
10912 separate event loop thread like W32. */ 10867 separate event loop thread like W32. */
10913#ifndef HAVE_NS 10868#ifndef HAVE_NS
10914 if (waiting_for_input && !echoing) 10869 if (waiting_for_input && !echoing)
10915 quit_throw_to_read_char (1); 10870 quit_throw_to_read_char (in_signal_handler);
10916#endif 10871#endif
10917} 10872}
10918 10873
@@ -10926,22 +10881,12 @@ quit_throw_to_read_char (int from_signal)
10926 if (!from_signal && EQ (Vquit_flag, Qkill_emacs)) 10881 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
10927 Fkill_emacs (Qnil); 10882 Fkill_emacs (Qnil);
10928 10883
10929 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10930 /* Prevent another signal from doing this before we finish. */ 10884 /* Prevent another signal from doing this before we finish. */
10931 clear_waiting_for_input (); 10885 clear_waiting_for_input ();
10932 input_pending = 0; 10886 input_pending = 0;
10933 10887
10934 Vunread_command_events = Qnil; 10888 Vunread_command_events = Qnil;
10935 10889
10936#if 0 /* Currently, sit_for is called from read_char without turning
10937 off polling. And that can call set_waiting_for_input.
10938 It seems to be harmless. */
10939#ifdef POLL_FOR_INPUT
10940 /* May be > 1 if in recursive minibuffer. */
10941 if (poll_suppress_count == 0)
10942 emacs_abort ();
10943#endif
10944#endif
10945 if (FRAMEP (internal_last_event_frame) 10890 if (FRAMEP (internal_last_event_frame)
10946 && !EQ (internal_last_event_frame, selected_frame)) 10891 && !EQ (internal_last_event_frame, selected_frame))
10947 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 10892 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
@@ -11332,7 +11277,6 @@ init_keyboard (void)
11332#endif 11277#endif
11333 input_pending = 0; 11278 input_pending = 0;
11334 interrupt_input_blocked = 0; 11279 interrupt_input_blocked = 0;
11335 interrupt_input_pending = 0;
11336 pending_signals = 0; 11280 pending_signals = 0;
11337 11281
11338 /* This means that command_loop_1 won't try to select anything the first 11282 /* This means that command_loop_1 won't try to select anything the first
@@ -11353,7 +11297,7 @@ init_keyboard (void)
11353 /* Before multi-tty support, these handlers used to be installed 11297 /* Before multi-tty support, these handlers used to be installed
11354 only if the current session was a tty session. Now an Emacs 11298 only if the current session was a tty session. Now an Emacs
11355 session may have multiple display types, so we always handle 11299 session may have multiple display types, so we always handle
11356 SIGINT. There is special code in interrupt_signal to exit 11300 SIGINT. There is special code in handle_interrupt_signal to exit
11357 Emacs on SIGINT when there are no termcap frames on the 11301 Emacs on SIGINT when there are no termcap frames on the
11358 controlling terminal. */ 11302 controlling terminal. */
11359 struct sigaction action; 11303 struct sigaction action;
diff --git a/src/keyboard.h b/src/keyboard.h
index 3601f68be9f..bc35bba4ecc 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -523,7 +523,7 @@ extern void input_poll_signal (int);
523extern void start_polling (void); 523extern void start_polling (void);
524extern void stop_polling (void); 524extern void stop_polling (void);
525extern void set_poll_suppress_count (int); 525extern void set_poll_suppress_count (int);
526extern void gobble_input (void); 526extern int gobble_input (void);
527extern int input_polling_used (void); 527extern int input_polling_used (void);
528extern void clear_input_pending (void); 528extern void clear_input_pending (void);
529extern int requeued_events_pending_p (void); 529extern int requeued_events_pending_p (void);
diff --git a/src/keymap.c b/src/keymap.c
index 66fb52061f9..6ea142651bf 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1477,7 +1477,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1477 1477
1478 /* Use malloc here. See the comment above this function. 1478 /* Use malloc here. See the comment above this function.
1479 Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ 1479 Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */
1480 BLOCK_INPUT; 1480 block_input ();
1481 newmodes = malloc (allocsize); 1481 newmodes = malloc (allocsize);
1482 if (newmodes) 1482 if (newmodes)
1483 { 1483 {
@@ -1501,7 +1501,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1501 } 1501 }
1502 cmm_maps = newmaps; 1502 cmm_maps = newmaps;
1503 } 1503 }
1504 UNBLOCK_INPUT; 1504 unblock_input ();
1505 1505
1506 if (newmodes == NULL || newmaps == NULL) 1506 if (newmodes == NULL || newmaps == NULL)
1507 break; 1507 break;
diff --git a/src/lisp.h b/src/lisp.h
index 3a473a60b48..c3cabe0af29 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -25,6 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include <stdarg.h> 25#include <stdarg.h>
26#include <stdbool.h> 26#include <stdbool.h>
27#include <stddef.h> 27#include <stddef.h>
28#include <float.h>
28#include <inttypes.h> 29#include <inttypes.h>
29#include <limits.h> 30#include <limits.h>
30 31
@@ -1487,6 +1488,16 @@ struct Lisp_Float
1487#define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data : XFLOAT (f)->u.data) 1488#define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data : XFLOAT (f)->u.data)
1488#define XFLOAT_INIT(f, n) (XFLOAT (f)->u.data = (n)) 1489#define XFLOAT_INIT(f, n) (XFLOAT (f)->u.data = (n))
1489 1490
1491/* Most hosts nowadays use IEEE floating point, so they use IEC 60559
1492 representations, have infinities and NaNs, and do not trap on
1493 exceptions. Define IEEE_FLOATING_POINT if this host is one of the
1494 typical ones. The C11 macro __STDC_IEC_559__ is close to what is
1495 wanted here, but is not quite right because Emacs does not require
1496 all the features of C11 Annex F (and does not require C11 at all,
1497 for that matter). */
1498#define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
1499 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
1500
1490/* A character, declared with the following typedef, is a member 1501/* A character, declared with the following typedef, is a member
1491 of some character set associated with the current buffer. */ 1502 of some character set associated with the current buffer. */
1492#ifndef _UCHAR_T /* Protect against something in ctab.h on AIX. */ 1503#ifndef _UCHAR_T /* Protect against something in ctab.h on AIX. */
@@ -2020,6 +2031,18 @@ extern ptrdiff_t specpdl_size;
2020 2031
2021#define SPECPDL_INDEX() (specpdl_ptr - specpdl) 2032#define SPECPDL_INDEX() (specpdl_ptr - specpdl)
2022 2033
2034struct backtrace
2035{
2036 struct backtrace *next;
2037 Lisp_Object function;
2038 Lisp_Object *args; /* Points to vector of args. */
2039 ptrdiff_t nargs; /* Length of vector. */
2040 /* Nonzero means call value of debugger when done with this operation. */
2041 unsigned int debug_on_exit : 1;
2042};
2043
2044extern struct backtrace *backtrace_list;
2045
2023/* Everything needed to describe an active condition case. 2046/* Everything needed to describe an active condition case.
2024 2047
2025 Members are volatile if their values need to survive _longjmp when 2048 Members are volatile if their values need to survive _longjmp when
@@ -2108,7 +2131,7 @@ extern char *stack_bottom;
2108 a request to exit Emacs when it is safe to do. */ 2131 a request to exit Emacs when it is safe to do. */
2109 2132
2110extern void process_pending_signals (void); 2133extern void process_pending_signals (void);
2111extern int pending_signals; 2134extern int volatile pending_signals;
2112 2135
2113extern void process_quit_flag (void); 2136extern void process_quit_flag (void);
2114#define QUIT \ 2137#define QUIT \
@@ -2633,7 +2656,6 @@ extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
2633extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); 2656extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *);
2634extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool); 2657extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool);
2635extern void syms_of_data (void); 2658extern void syms_of_data (void);
2636extern void init_data (void);
2637extern void swap_in_global_binding (struct Lisp_Symbol *); 2659extern void swap_in_global_binding (struct Lisp_Symbol *);
2638 2660
2639/* Defined in cmds.c */ 2661/* Defined in cmds.c */
@@ -2721,6 +2743,7 @@ extern void init_fringe_once (void);
2721extern Lisp_Object QCascent, QCmargin, QCrelief; 2743extern Lisp_Object QCascent, QCmargin, QCrelief;
2722extern Lisp_Object QCconversion; 2744extern Lisp_Object QCconversion;
2723extern int x_bitmap_mask (struct frame *, ptrdiff_t); 2745extern int x_bitmap_mask (struct frame *, ptrdiff_t);
2746extern void reset_image_types (void);
2724extern void syms_of_image (void); 2747extern void syms_of_image (void);
2725 2748
2726/* Defined in insdel.c. */ 2749/* Defined in insdel.c. */
@@ -2905,6 +2928,7 @@ build_string (const char *str)
2905 2928
2906extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); 2929extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
2907extern void make_byte_code (struct Lisp_Vector *); 2930extern void make_byte_code (struct Lisp_Vector *);
2931extern Lisp_Object Qautomatic_gc;
2908extern Lisp_Object Qchar_table_extra_slots; 2932extern Lisp_Object Qchar_table_extra_slots;
2909extern struct Lisp_Vector *allocate_vector (EMACS_INT); 2933extern struct Lisp_Vector *allocate_vector (EMACS_INT);
2910extern struct Lisp_Vector *allocate_pseudovector (int memlen, int lisplen, int tag); 2934extern struct Lisp_Vector *allocate_pseudovector (int memlen, int lisplen, int tag);
@@ -3227,6 +3251,9 @@ extern int input_pending;
3227extern Lisp_Object menu_bar_items (Lisp_Object); 3251extern Lisp_Object menu_bar_items (Lisp_Object);
3228extern Lisp_Object tool_bar_items (Lisp_Object, int *); 3252extern Lisp_Object tool_bar_items (Lisp_Object, int *);
3229extern void discard_mouse_events (void); 3253extern void discard_mouse_events (void);
3254#ifdef USABLE_SIGIO
3255void handle_input_available_signal (int);
3256#endif
3230extern Lisp_Object pending_funcalls; 3257extern Lisp_Object pending_funcalls;
3231extern int detect_input_pending (void); 3258extern int detect_input_pending (void);
3232extern int detect_input_pending_ignore_squeezables (void); 3259extern int detect_input_pending_ignore_squeezables (void);
@@ -3244,7 +3271,7 @@ extern void keys_of_keyboard (void);
3244/* Defined in indent.c. */ 3271/* Defined in indent.c. */
3245extern ptrdiff_t current_column (void); 3272extern ptrdiff_t current_column (void);
3246extern void invalidate_current_column (void); 3273extern void invalidate_current_column (void);
3247extern int indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT); 3274extern bool indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT);
3248extern void syms_of_indent (void); 3275extern void syms_of_indent (void);
3249 3276
3250/* Defined in frame.c. */ 3277/* Defined in frame.c. */
@@ -3269,8 +3296,11 @@ extern bool display_arg;
3269extern Lisp_Object decode_env_path (const char *, const char *); 3296extern Lisp_Object decode_env_path (const char *, const char *);
3270extern Lisp_Object empty_unibyte_string, empty_multibyte_string; 3297extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
3271extern Lisp_Object Qfile_name_handler_alist; 3298extern Lisp_Object Qfile_name_handler_alist;
3272extern _Noreturn void fatal_error_backtrace (int, int); 3299extern _Noreturn void terminate_due_to_signal (int, int);
3273extern Lisp_Object Qkill_emacs; 3300extern Lisp_Object Qkill_emacs;
3301#ifdef WINDOWSNT
3302extern Lisp_Object Vlibrary_cache;
3303#endif
3274#if HAVE_SETLOCALE 3304#if HAVE_SETLOCALE
3275void fixup_locale (void); 3305void fixup_locale (void);
3276void synchronize_system_messages_locale (void); 3306void synchronize_system_messages_locale (void);
@@ -3407,8 +3437,6 @@ extern void init_sys_modes (struct tty_display_info *);
3407extern void reset_sys_modes (struct tty_display_info *); 3437extern void reset_sys_modes (struct tty_display_info *);
3408extern void init_all_sys_modes (void); 3438extern void init_all_sys_modes (void);
3409extern void reset_all_sys_modes (void); 3439extern void reset_all_sys_modes (void);
3410extern void wait_for_termination (pid_t);
3411extern void interruptible_wait_for_termination (pid_t);
3412extern void flush_pending_output (int) ATTRIBUTE_CONST; 3440extern void flush_pending_output (int) ATTRIBUTE_CONST;
3413extern void child_setup_tty (int); 3441extern void child_setup_tty (int);
3414extern void setup_pty (int); 3442extern void setup_pty (int);
@@ -3519,6 +3547,13 @@ extern int have_menus_p (void);
3519void syms_of_dbusbind (void); 3547void syms_of_dbusbind (void);
3520#endif 3548#endif
3521 3549
3550
3551/* Defined in profiler.c. */
3552extern bool profiler_memory_running;
3553extern void malloc_probe (size_t);
3554extern void syms_of_profiler (void);
3555
3556
3522#ifdef DOS_NT 3557#ifdef DOS_NT
3523/* Defined in msdos.c, w32.c. */ 3558/* Defined in msdos.c, w32.c. */
3524extern char *emacs_root_dir (void); 3559extern char *emacs_root_dir (void);
diff --git a/src/lread.c b/src/lread.c
index 08d5f97292b..d22011be7c8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -408,9 +408,9 @@ unreadchar (Lisp_Object readcharfun, int c)
408 { 408 {
409 if (load_each_byte) 409 if (load_each_byte)
410 { 410 {
411 BLOCK_INPUT; 411 block_input ();
412 ungetc (c, instream); 412 ungetc (c, instream);
413 UNBLOCK_INPUT; 413 unblock_input ();
414 } 414 }
415 else 415 else
416 unread_char = c; 416 unread_char = c;
@@ -431,28 +431,28 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
431{ 431{
432 if (c >= 0) 432 if (c >= 0)
433 { 433 {
434 BLOCK_INPUT; 434 block_input ();
435 ungetc (c, instream); 435 ungetc (c, instream);
436 UNBLOCK_INPUT; 436 unblock_input ();
437 return 0; 437 return 0;
438 } 438 }
439 439
440 BLOCK_INPUT; 440 block_input ();
441 c = getc (instream); 441 c = getc (instream);
442 442
443#ifdef EINTR 443#ifdef EINTR
444 /* Interrupted reads have been observed while reading over the network. */ 444 /* Interrupted reads have been observed while reading over the network. */
445 while (c == EOF && ferror (instream) && errno == EINTR) 445 while (c == EOF && ferror (instream) && errno == EINTR)
446 { 446 {
447 UNBLOCK_INPUT; 447 unblock_input ();
448 QUIT; 448 QUIT;
449 BLOCK_INPUT; 449 block_input ();
450 clearerr (instream); 450 clearerr (instream);
451 c = getc (instream); 451 c = getc (instream);
452 } 452 }
453#endif 453#endif
454 454
455 UNBLOCK_INPUT; 455 unblock_input ();
456 456
457 return (c == EOF ? -1 : c); 457 return (c == EOF ? -1 : c);
458} 458}
@@ -753,9 +753,9 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
753 (void) 753 (void)
754{ 754{
755 register Lisp_Object val; 755 register Lisp_Object val;
756 BLOCK_INPUT; 756 block_input ();
757 XSETINT (val, getc (instream)); 757 XSETINT (val, getc (instream));
758 UNBLOCK_INPUT; 758 unblock_input ();
759 return val; 759 return val;
760} 760}
761 761
@@ -764,13 +764,30 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
764 764
765/* Return true if the lisp code read using READCHARFUN defines a non-nil 765/* Return true if the lisp code read using READCHARFUN defines a non-nil
766 `lexical-binding' file variable. After returning, the stream is 766 `lexical-binding' file variable. After returning, the stream is
767 positioned following the first line, if it is a comment, otherwise 767 positioned following the first line, if it is a comment or #! line,
768 nothing is read. */ 768 otherwise nothing is read. */
769 769
770static int 770static int
771lisp_file_lexically_bound_p (Lisp_Object readcharfun) 771lisp_file_lexically_bound_p (Lisp_Object readcharfun)
772{ 772{
773 int ch = READCHAR; 773 int ch = READCHAR;
774
775 if (ch == '#')
776 {
777 ch = READCHAR;
778 if (ch != '!')
779 {
780 UNREAD (ch);
781 UNREAD ('#');
782 return 0;
783 }
784 while (ch != '\n' && ch != EOF)
785 ch = READCHAR;
786 if (ch == '\n') ch = READCHAR;
787 /* It is OK to leave the position after a #! line, since
788 that is what read1 does. */
789 }
790
774 if (ch != ';') 791 if (ch != ';')
775 /* The first line isn't a comment, just give up. */ 792 /* The first line isn't a comment, just give up. */
776 { 793 {
@@ -1350,9 +1367,9 @@ load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */
1350 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; 1367 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
1351 if (stream != NULL) 1368 if (stream != NULL)
1352 { 1369 {
1353 BLOCK_INPUT; 1370 block_input ();
1354 fclose (stream); 1371 fclose (stream);
1355 UNBLOCK_INPUT; 1372 unblock_input ();
1356 } 1373 }
1357 return Qnil; 1374 return Qnil;
1358} 1375}
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 24ecb2676da..3d1464cc742 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -125,6 +125,7 @@ OBJ2 = $(BLD)/sysdep.$(O) \
125 $(BLD)/terminal.$(O) \ 125 $(BLD)/terminal.$(O) \
126 $(BLD)/menu.$(O) \ 126 $(BLD)/menu.$(O) \
127 $(BLD)/xml.$(O) \ 127 $(BLD)/xml.$(O) \
128 $(BLD)/profiler.$(O) \
128 $(BLD)/w32term.$(O) \ 129 $(BLD)/w32term.$(O) \
129 $(BLD)/w32xfns.$(O) \ 130 $(BLD)/w32xfns.$(O) \
130 $(BLD)/w32fns.$(O) \ 131 $(BLD)/w32fns.$(O) \
@@ -222,7 +223,7 @@ GLOBAL_SOURCES = dosfns.c msdos.c \
222 process.c callproc.c unexw32.c \ 223 process.c callproc.c unexw32.c \
223 region-cache.c sound.c atimer.c \ 224 region-cache.c sound.c atimer.c \
224 doprnt.c intervals.c textprop.c composite.c \ 225 doprnt.c intervals.c textprop.c composite.c \
225 gnutls.c xml.c 226 gnutls.c xml.c profiler.c
226SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ 227SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
227 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o dbusbind.o 228 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o dbusbind.o
228obj = $(GLOBAL_SOURCES:.c=.o) 229obj = $(GLOBAL_SOURCES:.c=.o)
@@ -392,8 +393,6 @@ SYSTIME_H = $(SRC)/systime.h \
392ATIMER_H = $(SRC)/atimer.h \ 393ATIMER_H = $(SRC)/atimer.h \
393 $(NT_INC)/stdbool.h \ 394 $(NT_INC)/stdbool.h \
394 $(SYSTIME_H) 395 $(SYSTIME_H)
395BLOCKINPUT_H = $(SRC)/blockinput.h \
396 $(ATIMER_H)
397BUFFER_H = $(SRC)/buffer.h \ 396BUFFER_H = $(SRC)/buffer.h \
398 $(SYSTIME_H) 397 $(SYSTIME_H)
399C_CTYPE_H = $(GNU_LIB)/c-ctype.h \ 398C_CTYPE_H = $(GNU_LIB)/c-ctype.h \
@@ -467,6 +466,8 @@ SOCKET_H = $(NT_INC)/sys/socket.h \
467 $(SRC)/w32.h 466 $(SRC)/w32.h
468STAT_TIME_H = $(GNU_LIB)/stat-time.h \ 467STAT_TIME_H = $(GNU_LIB)/stat-time.h \
469 $(NT_INC)/sys/stat.h 468 $(NT_INC)/sys/stat.h
469SYSSIGNAL_H = $(SRC)/syssignal.h \
470 $(NT_INC)/stdbool.h
470SYSTTY_H = $(SRC)/systty.h \ 471SYSTTY_H = $(SRC)/systty.h \
471 $(NT_INC)/sys/ioctl.h \ 472 $(NT_INC)/sys/ioctl.h \
472 $(NT_INC)/unistd.h 473 $(NT_INC)/unistd.h
@@ -481,11 +482,11 @@ WINDOW_H = $(SRC)/window.h \
481 482
482$(BLD)/alloc.$(O) : \ 483$(BLD)/alloc.$(O) : \
483 $(SRC)/alloc.c \ 484 $(SRC)/alloc.c \
485 $(SRC)/blockinput.h \
484 $(SRC)/puresize.h \ 486 $(SRC)/puresize.h \
485 $(SRC)/w32.h \ 487 $(SRC)/w32.h \
486 $(NT_INC)/unistd.h \ 488 $(NT_INC)/unistd.h \
487 $(GNU_LIB)/verify.h \ 489 $(GNU_LIB)/verify.h \
488 $(BLOCKINPUT_H) \
489 $(BUFFER_H) \ 490 $(BUFFER_H) \
490 $(CHARACTER_H) \ 491 $(CHARACTER_H) \
491 $(CONFIG_H) \ 492 $(CONFIG_H) \
@@ -499,12 +500,12 @@ $(BLD)/alloc.$(O) : \
499 500
500$(BLD)/atimer.$(O) : \ 501$(BLD)/atimer.$(O) : \
501 $(SRC)/atimer.c \ 502 $(SRC)/atimer.c \
502 $(SRC)/syssignal.h \ 503 $(SRC)/blockinput.h \
503 $(NT_INC)/unistd.h \ 504 $(NT_INC)/unistd.h \
504 $(ATIMER_H) \ 505 $(ATIMER_H) \
505 $(BLOCKINPUT_H) \
506 $(CONFIG_H) \ 506 $(CONFIG_H) \
507 $(LISP_H) \ 507 $(LISP_H) \
508 $(SYSSIGNAL_H) \
508 $(SYSTIME_H) 509 $(SYSTIME_H)
509 510
510$(BLD)/bidi.$(O) : \ 511$(BLD)/bidi.$(O) : \
@@ -517,6 +518,7 @@ $(BLD)/bidi.$(O) : \
517 518
518$(BLD)/buffer.$(O) : \ 519$(BLD)/buffer.$(O) : \
519 $(SRC)/buffer.c \ 520 $(SRC)/buffer.c \
521 $(SRC)/blockinput.h \
520 $(SRC)/commands.h \ 522 $(SRC)/commands.h \
521 $(SRC)/indent.h \ 523 $(SRC)/indent.h \
522 $(SRC)/keymap.h \ 524 $(SRC)/keymap.h \
@@ -525,7 +527,6 @@ $(BLD)/buffer.$(O) : \
525 $(NT_INC)/sys/stat.h \ 527 $(NT_INC)/sys/stat.h \
526 $(NT_INC)/unistd.h \ 528 $(NT_INC)/unistd.h \
527 $(GNU_LIB)/verify.h \ 529 $(GNU_LIB)/verify.h \
528 $(BLOCKINPUT_H) \
529 $(BUFFER_H) \ 530 $(BUFFER_H) \
530 $(CHARACTER_H) \ 531 $(CHARACTER_H) \
531 $(CONFIG_H) \ 532 $(CONFIG_H) \
@@ -557,14 +558,14 @@ $(BLD)/callint.$(O) : \
557 558
558$(BLD)/callproc.$(O) : \ 559$(BLD)/callproc.$(O) : \
559 $(SRC)/callproc.c \ 560 $(SRC)/callproc.c \
561 $(SRC)/blockinput.h \
560 $(SRC)/commands.h \ 562 $(SRC)/commands.h \
561 $(SRC)/composite.h \ 563 $(SRC)/composite.h \
562 $(SRC)/epaths.h \ 564 $(SRC)/epaths.h \
563 $(SRC)/syssignal.h \ 565 $(SRC)/syswait.h \
564 $(SRC)/w32.h \ 566 $(SRC)/w32.h \
565 $(NT_INC)/sys/file.h \ 567 $(NT_INC)/sys/file.h \
566 $(NT_INC)/unistd.h \ 568 $(NT_INC)/unistd.h \
567 $(BLOCKINPUT_H) \
568 $(BUFFER_H) \ 569 $(BUFFER_H) \
569 $(CCL_H) \ 570 $(CCL_H) \
570 $(CHARACTER_H) \ 571 $(CHARACTER_H) \
@@ -573,6 +574,7 @@ $(BLD)/callproc.$(O) : \
573 $(FRAME_H) \ 574 $(FRAME_H) \
574 $(LISP_H) \ 575 $(LISP_H) \
575 $(PROCESS_H) \ 576 $(PROCESS_H) \
577 $(SYSSIGNAL_H) \
576 $(SYSTTY_H) \ 578 $(SYSTTY_H) \
577 $(TERMHOOKS_H) 579 $(TERMHOOKS_H)
578 580
@@ -690,7 +692,6 @@ $(BLD)/data.$(O) : \
690 $(SRC)/data.c \ 692 $(SRC)/data.c \
691 $(SRC)/keymap.h \ 693 $(SRC)/keymap.h \
692 $(SRC)/puresize.h \ 694 $(SRC)/puresize.h \
693 $(SRC)/syssignal.h \
694 $(GNU_LIB)/intprops.h \ 695 $(GNU_LIB)/intprops.h \
695 $(BUFFER_H) \ 696 $(BUFFER_H) \
696 $(CHARACTER_H) \ 697 $(CHARACTER_H) \
@@ -699,16 +700,17 @@ $(BLD)/data.$(O) : \
699 $(FRAME_H) \ 700 $(FRAME_H) \
700 $(KEYBOARD_H) \ 701 $(KEYBOARD_H) \
701 $(LISP_H) \ 702 $(LISP_H) \
703 $(SYSSIGNAL_H) \
702 $(TERMHOOKS_H) 704 $(TERMHOOKS_H)
703 705
704$(BLD)/dired.$(O) : \ 706$(BLD)/dired.$(O) : \
705 $(SRC)/dired.c \ 707 $(SRC)/dired.c \
708 $(SRC)/blockinput.h \
706 $(SRC)/commands.h \ 709 $(SRC)/commands.h \
707 $(SRC)/regex.h \ 710 $(SRC)/regex.h \
708 $(NT_INC)/pwd.h \ 711 $(NT_INC)/pwd.h \
709 $(NT_INC)/sys/stat.h \ 712 $(NT_INC)/sys/stat.h \
710 $(NT_INC)/unistd.h \ 713 $(NT_INC)/unistd.h \
711 $(BLOCKINPUT_H) \
712 $(BUFFER_H) \ 714 $(BUFFER_H) \
713 $(CHARACTER_H) \ 715 $(CHARACTER_H) \
714 $(CHARSET_H) \ 716 $(CHARSET_H) \
@@ -723,15 +725,14 @@ $(BLD)/dired.$(O) : \
723 725
724$(BLD)/dispnew.$(O) : \ 726$(BLD)/dispnew.$(O) : \
725 $(SRC)/dispnew.c \ 727 $(SRC)/dispnew.c \
728 $(SRC)/blockinput.h \
726 $(SRC)/cm.h \ 729 $(SRC)/cm.h \
727 $(SRC)/commands.h \ 730 $(SRC)/commands.h \
728 $(SRC)/disptab.h \ 731 $(SRC)/disptab.h \
729 $(SRC)/indent.h \ 732 $(SRC)/indent.h \
730 $(SRC)/syssignal.h \
731 $(SRC)/termchar.h \ 733 $(SRC)/termchar.h \
732 $(SRC)/termopts.h \ 734 $(SRC)/termopts.h \
733 $(NT_INC)/unistd.h \ 735 $(NT_INC)/unistd.h \
734 $(BLOCKINPUT_H) \
735 $(BUFFER_H) \ 736 $(BUFFER_H) \
736 $(CHARACTER_H) \ 737 $(CHARACTER_H) \
737 $(CONFIG_H) \ 738 $(CONFIG_H) \
@@ -741,6 +742,7 @@ $(BLD)/dispnew.$(O) : \
741 $(KEYBOARD_H) \ 742 $(KEYBOARD_H) \
742 $(LISP_H) \ 743 $(LISP_H) \
743 $(PROCESS_H) \ 744 $(PROCESS_H) \
745 $(SYSSIGNAL_H) \
744 $(SYSTIME_H) \ 746 $(SYSTIME_H) \
745 $(TERMHOOKS_H) \ 747 $(TERMHOOKS_H) \
746 $(W32TERM_H) \ 748 $(W32TERM_H) \
@@ -768,12 +770,12 @@ $(BLD)/doprnt.$(O) : \
768 770
769$(BLD)/editfns.$(O) : \ 771$(BLD)/editfns.$(O) : \
770 $(SRC)/editfns.c \ 772 $(SRC)/editfns.c \
773 $(SRC)/blockinput.h \
771 $(NT_INC)/pwd.h \ 774 $(NT_INC)/pwd.h \
772 $(NT_INC)/unistd.h \ 775 $(NT_INC)/unistd.h \
773 $(GNU_LIB)/intprops.h \ 776 $(GNU_LIB)/intprops.h \
774 $(GNU_LIB)/strftime.h \ 777 $(GNU_LIB)/strftime.h \
775 $(GNU_LIB)/verify.h \ 778 $(GNU_LIB)/verify.h \
776 $(BLOCKINPUT_H) \
777 $(BUFFER_H) \ 779 $(BUFFER_H) \
778 $(CHARACTER_H) \ 780 $(CHARACTER_H) \
779 $(CODING_H) \ 781 $(CODING_H) \
@@ -786,16 +788,17 @@ $(BLD)/editfns.$(O) : \
786 788
787$(BLD)/emacs.$(O) : \ 789$(BLD)/emacs.$(O) : \
788 $(SRC)/emacs.c \ 790 $(SRC)/emacs.c \
791 $(SRC)/blockinput.h \
789 $(SRC)/commands.h \ 792 $(SRC)/commands.h \
790 $(SRC)/gnutls.h \ 793 $(SRC)/gnutls.h \
791 $(SRC)/keymap.h \ 794 $(SRC)/keymap.h \
792 $(SRC)/syssignal.h \
793 $(SRC)/unexec.h \ 795 $(SRC)/unexec.h \
794 $(SRC)/w32.h \ 796 $(SRC)/w32.h \
795 $(SRC)/w32heap.h \ 797 $(SRC)/w32heap.h \
796 $(NT_INC)/sys/file.h \ 798 $(NT_INC)/sys/file.h \
797 $(NT_INC)/unistd.h \ 799 $(NT_INC)/unistd.h \
798 $(BLOCKINPUT_H) \ 800 $(GNU_LIB)/ignore-value.h \
801 $(ATIMER_H) \
799 $(BUFFER_H) \ 802 $(BUFFER_H) \
800 $(CHARACTER_H) \ 803 $(CHARACTER_H) \
801 $(CONFIG_H) \ 804 $(CONFIG_H) \
@@ -804,6 +807,7 @@ $(BLD)/emacs.$(O) : \
804 $(KEYBOARD_H) \ 807 $(KEYBOARD_H) \
805 $(LISP_H) \ 808 $(LISP_H) \
806 $(PROCESS_H) \ 809 $(PROCESS_H) \
810 $(SYSSIGNAL_H) \
807 $(SYSTTY_H) \ 811 $(SYSTTY_H) \
808 $(TERMHOOKS_H) \ 812 $(TERMHOOKS_H) \
809 $(W32TERM_H) \ 813 $(W32TERM_H) \
@@ -811,8 +815,8 @@ $(BLD)/emacs.$(O) : \
811 815
812$(BLD)/eval.$(O) : \ 816$(BLD)/eval.$(O) : \
813 $(SRC)/eval.c \ 817 $(SRC)/eval.c \
818 $(SRC)/blockinput.h \
814 $(SRC)/commands.h \ 819 $(SRC)/commands.h \
815 $(BLOCKINPUT_H) \
816 $(CONFIG_H) \ 820 $(CONFIG_H) \
817 $(DISPEXTERN_H) \ 821 $(DISPEXTERN_H) \
818 $(FRAME_H) \ 822 $(FRAME_H) \
@@ -821,11 +825,11 @@ $(BLD)/eval.$(O) : \
821 825
822$(BLD)/fileio.$(O) : \ 826$(BLD)/fileio.$(O) : \
823 $(SRC)/fileio.c \ 827 $(SRC)/fileio.c \
828 $(SRC)/blockinput.h \
824 $(SRC)/commands.h \ 829 $(SRC)/commands.h \
825 $(NT_INC)/pwd.h \ 830 $(NT_INC)/pwd.h \
826 $(NT_INC)/sys/stat.h \ 831 $(NT_INC)/sys/stat.h \
827 $(NT_INC)/unistd.h \ 832 $(NT_INC)/unistd.h \
828 $(BLOCKINPUT_H) \
829 $(BUFFER_H) \ 833 $(BUFFER_H) \
830 $(CHARACTER_H) \ 834 $(CHARACTER_H) \
831 $(CODING_H) \ 835 $(CODING_H) \
@@ -858,17 +862,16 @@ $(BLD)/firstfile.$(O) : \
858 862
859$(BLD)/floatfns.$(O) : \ 863$(BLD)/floatfns.$(O) : \
860 $(SRC)/floatfns.c \ 864 $(SRC)/floatfns.c \
861 $(SRC)/syssignal.h \
862 $(CONFIG_H) \ 865 $(CONFIG_H) \
863 $(LISP_H) 866 $(LISP_H)
864 867
865$(BLD)/fns.$(O) : \ 868$(BLD)/fns.$(O) : \
866 $(SRC)/fns.c \ 869 $(SRC)/fns.c \
870 $(SRC)/blockinput.h \
867 $(SRC)/commands.h \ 871 $(SRC)/commands.h \
868 $(SRC)/keymap.h \ 872 $(SRC)/keymap.h \
869 $(NT_INC)/unistd.h \ 873 $(NT_INC)/unistd.h \
870 $(GNU_LIB)/intprops.h \ 874 $(GNU_LIB)/intprops.h \
871 $(BLOCKINPUT_H) \
872 $(BUFFER_H) \ 875 $(BUFFER_H) \
873 $(CHARACTER_H) \ 876 $(CHARACTER_H) \
874 $(CODING_H) \ 877 $(CODING_H) \
@@ -902,8 +905,8 @@ $(BLD)/font.$(O) : \
902 905
903$(BLD)/fontset.$(O) : \ 906$(BLD)/fontset.$(O) : \
904 $(SRC)/fontset.c \ 907 $(SRC)/fontset.c \
908 $(SRC)/blockinput.h \
905 $(SRC)/fontset.h \ 909 $(SRC)/fontset.h \
906 $(BLOCKINPUT_H) \
907 $(BUFFER_H) \ 910 $(BUFFER_H) \
908 $(CCL_H) \ 911 $(CCL_H) \
909 $(CHARACTER_H) \ 912 $(CHARACTER_H) \
@@ -921,10 +924,10 @@ $(BLD)/fontset.$(O) : \
921 924
922$(BLD)/frame.$(O) : \ 925$(BLD)/frame.$(O) : \
923 $(SRC)/frame.c \ 926 $(SRC)/frame.c \
927 $(SRC)/blockinput.h \
924 $(SRC)/commands.h \ 928 $(SRC)/commands.h \
925 $(SRC)/fontset.h \ 929 $(SRC)/fontset.h \
926 $(SRC)/termchar.h \ 930 $(SRC)/termchar.h \
927 $(BLOCKINPUT_H) \
928 $(BUFFER_H) \ 931 $(BUFFER_H) \
929 $(CHARACTER_H) \ 932 $(CHARACTER_H) \
930 $(CONFIG_H) \ 933 $(CONFIG_H) \
@@ -940,7 +943,7 @@ $(BLD)/frame.$(O) : \
940 943
941$(BLD)/fringe.$(O) : \ 944$(BLD)/fringe.$(O) : \
942 $(SRC)/fringe.c \ 945 $(SRC)/fringe.c \
943 $(BLOCKINPUT_H) \ 946 $(SRC)/blockinput.h \
944 $(BUFFER_H) \ 947 $(BUFFER_H) \
945 $(CHARACTER_H) \ 948 $(CHARACTER_H) \
946 $(CONFIG_H) \ 949 $(CONFIG_H) \
@@ -971,12 +974,19 @@ $(BLD)/xml.$(O) : \
971 $(CONFIG_H) \ 974 $(CONFIG_H) \
972 $(LISP_H) 975 $(LISP_H)
973 976
977$(BLD)/profiler.$(O) : \
978 $(SRC)/profiler.c \
979 $(CONFIG_H) \
980 $(LISP_H) \
981 $(SYSSIGNAL_H) \
982 $(SYSTIME_H)
983
974$(BLD)/image.$(O) : \ 984$(BLD)/image.$(O) : \
975 $(SRC)/image.c \ 985 $(SRC)/image.c \
986 $(SRC)/blockinput.h \
976 $(SRC)/epaths.h \ 987 $(SRC)/epaths.h \
977 $(SRC)/w32.h \ 988 $(SRC)/w32.h \
978 $(NT_INC)/unistd.h \ 989 $(NT_INC)/unistd.h \
979 $(BLOCKINPUT_H) \
980 $(CHARACTER_H) \ 990 $(CHARACTER_H) \
981 $(CODING_H) \ 991 $(CODING_H) \
982 $(CONFIG_H) \ 992 $(CONFIG_H) \
@@ -1011,9 +1021,9 @@ $(BLD)/indent.$(O) : \
1011 1021
1012$(BLD)/insdel.$(O) : \ 1022$(BLD)/insdel.$(O) : \
1013 $(SRC)/insdel.c \ 1023 $(SRC)/insdel.c \
1024 $(SRC)/blockinput.h \
1014 $(SRC)/region-cache.h \ 1025 $(SRC)/region-cache.h \
1015 $(GNU_LIB)/intprops.h \ 1026 $(GNU_LIB)/intprops.h \
1016 $(BLOCKINPUT_H) \
1017 $(BUFFER_H) \ 1027 $(BUFFER_H) \
1018 $(CHARACTER_H) \ 1028 $(CHARACTER_H) \
1019 $(CONFIG_H) \ 1029 $(CONFIG_H) \
@@ -1035,19 +1045,18 @@ $(BLD)/intervals.$(O) : \
1035 1045
1036$(BLD)/keyboard.$(O) : \ 1046$(BLD)/keyboard.$(O) : \
1037 $(SRC)/keyboard.c \ 1047 $(SRC)/keyboard.c \
1048 $(SRC)/blockinput.h \
1038 $(SRC)/commands.h \ 1049 $(SRC)/commands.h \
1039 $(SRC)/disptab.h \ 1050 $(SRC)/disptab.h \
1040 $(SRC)/keymap.h \ 1051 $(SRC)/keymap.h \
1041 $(SRC)/macros.h \ 1052 $(SRC)/macros.h \
1042 $(SRC)/puresize.h \ 1053 $(SRC)/puresize.h \
1043 $(SRC)/syntax.h \ 1054 $(SRC)/syntax.h \
1044 $(SRC)/syssignal.h \
1045 $(SRC)/termchar.h \ 1055 $(SRC)/termchar.h \
1046 $(SRC)/termopts.h \ 1056 $(SRC)/termopts.h \
1047 $(NT_INC)/sys/ioctl.h \ 1057 $(NT_INC)/sys/ioctl.h \
1048 $(NT_INC)/unistd.h \ 1058 $(NT_INC)/unistd.h \
1049 $(ATIMER_H) \ 1059 $(ATIMER_H) \
1050 $(BLOCKINPUT_H) \
1051 $(BUFFER_H) \ 1060 $(BUFFER_H) \
1052 $(CHARACTER_H) \ 1061 $(CHARACTER_H) \
1053 $(CONFIG_H) \ 1062 $(CONFIG_H) \
@@ -1057,6 +1066,7 @@ $(BLD)/keyboard.$(O) : \
1057 $(KEYBOARD_H) \ 1066 $(KEYBOARD_H) \
1058 $(LISP_H) \ 1067 $(LISP_H) \
1059 $(PROCESS_H) \ 1068 $(PROCESS_H) \
1069 $(SYSSIGNAL_H) \
1060 $(SYSTIME_H) \ 1070 $(SYSTIME_H) \
1061 $(TERMHOOKS_H) \ 1071 $(TERMHOOKS_H) \
1062 $(W32TERM_H) \ 1072 $(W32TERM_H) \
@@ -1064,10 +1074,10 @@ $(BLD)/keyboard.$(O) : \
1064 1074
1065$(BLD)/keymap.$(O) : \ 1075$(BLD)/keymap.$(O) : \
1066 $(SRC)/keymap.c \ 1076 $(SRC)/keymap.c \
1077 $(SRC)/blockinput.h \
1067 $(SRC)/commands.h \ 1078 $(SRC)/commands.h \
1068 $(SRC)/keymap.h \ 1079 $(SRC)/keymap.h \
1069 $(SRC)/puresize.h \ 1080 $(SRC)/puresize.h \
1070 $(BLOCKINPUT_H) \
1071 $(BUFFER_H) \ 1081 $(BUFFER_H) \
1072 $(CHARACTER_H) \ 1082 $(CHARACTER_H) \
1073 $(CHARSET_H) \ 1083 $(CHARSET_H) \
@@ -1085,12 +1095,12 @@ $(BLD)/lastfile.$(O) : \
1085 1095
1086$(BLD)/lread.$(O) : \ 1096$(BLD)/lread.$(O) : \
1087 $(SRC)/lread.c \ 1097 $(SRC)/lread.c \
1098 $(SRC)/blockinput.h \
1088 $(SRC)/commands.h \ 1099 $(SRC)/commands.h \
1089 $(SRC)/epaths.h \ 1100 $(SRC)/epaths.h \
1090 $(NT_INC)/sys/file.h \ 1101 $(NT_INC)/sys/file.h \
1091 $(NT_INC)/sys/stat.h \ 1102 $(NT_INC)/sys/stat.h \
1092 $(NT_INC)/unistd.h \ 1103 $(NT_INC)/unistd.h \
1093 $(BLOCKINPUT_H) \
1094 $(BUFFER_H) \ 1104 $(BUFFER_H) \
1095 $(CHARACTER_H) \ 1105 $(CHARACTER_H) \
1096 $(CHARSET_H) \ 1106 $(CHARSET_H) \
@@ -1123,8 +1133,8 @@ $(BLD)/marker.$(O) : \
1123 1133
1124$(BLD)/menu.$(O) : \ 1134$(BLD)/menu.$(O) : \
1125 $(SRC)/menu.c \ 1135 $(SRC)/menu.c \
1136 $(SRC)/blockinput.h \
1126 $(SRC)/keymap.h \ 1137 $(SRC)/keymap.h \
1127 $(BLOCKINPUT_H) \
1128 $(CONFIG_H) \ 1138 $(CONFIG_H) \
1129 $(DISPEXTERN_H) \ 1139 $(DISPEXTERN_H) \
1130 $(FRAME_H) \ 1140 $(FRAME_H) \
@@ -1178,10 +1188,10 @@ $(BLD)/w32heap.$(O) : \
1178 1188
1179$(BLD)/w32inevt.$(O) : \ 1189$(BLD)/w32inevt.$(O) : \
1180 $(SRC)/w32inevt.c \ 1190 $(SRC)/w32inevt.c \
1191 $(SRC)/blockinput.h \
1181 $(SRC)/termchar.h \ 1192 $(SRC)/termchar.h \
1182 $(SRC)/w32heap.h \ 1193 $(SRC)/w32heap.h \
1183 $(SRC)/w32inevt.h \ 1194 $(SRC)/w32inevt.h \
1184 $(BLOCKINPUT_H) \
1185 $(CONFIG_H) \ 1195 $(CONFIG_H) \
1186 $(DISPEXTERN_H) \ 1196 $(DISPEXTERN_H) \
1187 $(FRAME_H) \ 1197 $(FRAME_H) \
@@ -1193,7 +1203,6 @@ $(BLD)/w32inevt.$(O) : \
1193 1203
1194$(BLD)/w32proc.$(O) : \ 1204$(BLD)/w32proc.$(O) : \
1195 $(SRC)/w32proc.c \ 1205 $(SRC)/w32proc.c \
1196 $(SRC)/syssignal.h \
1197 $(SRC)/syswait.h \ 1206 $(SRC)/syswait.h \
1198 $(SRC)/w32.h \ 1207 $(SRC)/w32.h \
1199 $(SRC)/w32heap.h \ 1208 $(SRC)/w32heap.h \
@@ -1205,6 +1214,7 @@ $(BLD)/w32proc.$(O) : \
1205 $(LANGINFO_H) \ 1214 $(LANGINFO_H) \
1206 $(LISP_H) \ 1215 $(LISP_H) \
1207 $(PROCESS_H) \ 1216 $(PROCESS_H) \
1217 $(SYSSIGNAL_H) \
1208 $(SYSTIME_H) \ 1218 $(SYSTIME_H) \
1209 $(W32TERM_H) 1219 $(W32TERM_H)
1210 1220
@@ -1225,8 +1235,8 @@ $(BLD)/w32console.$(O) : \
1225 1235
1226$(BLD)/print.$(O) : \ 1236$(BLD)/print.$(O) : \
1227 $(SRC)/print.c \ 1237 $(SRC)/print.c \
1238 $(SRC)/blockinput.h \
1228 $(SRC)/termchar.h \ 1239 $(SRC)/termchar.h \
1229 $(BLOCKINPUT_H) \
1230 $(BUFFER_H) \ 1240 $(BUFFER_H) \
1231 $(CHARACTER_H) \ 1241 $(CHARACTER_H) \
1232 $(CHARSET_H) \ 1242 $(CHARSET_H) \
@@ -1244,11 +1254,11 @@ $(BLD)/print.$(O) : \
1244 1254
1245$(BLD)/process.$(O) : \ 1255$(BLD)/process.$(O) : \
1246 $(SRC)/process.c \ 1256 $(SRC)/process.c \
1257 $(SRC)/blockinput.h \
1247 $(SRC)/commands.h \ 1258 $(SRC)/commands.h \
1248 $(SRC)/composite.h \ 1259 $(SRC)/composite.h \
1249 $(SRC)/gnutls.h \ 1260 $(SRC)/gnutls.h \
1250 $(SRC)/sysselect.h \ 1261 $(SRC)/sysselect.h \
1251 $(SRC)/syssignal.h \
1252 $(SRC)/syswait.h \ 1262 $(SRC)/syswait.h \
1253 $(SRC)/termopts.h \ 1263 $(SRC)/termopts.h \
1254 $(NT_INC)/arpa/inet.h \ 1264 $(NT_INC)/arpa/inet.h \
@@ -1259,7 +1269,6 @@ $(BLD)/process.$(O) : \
1259 $(NT_INC)/sys/stat.h \ 1269 $(NT_INC)/sys/stat.h \
1260 $(NT_INC)/unistd.h \ 1270 $(NT_INC)/unistd.h \
1261 $(ATIMER_H) \ 1271 $(ATIMER_H) \
1262 $(BLOCKINPUT_H) \
1263 $(BUFFER_H) \ 1272 $(BUFFER_H) \
1264 $(CHARACTER_H) \ 1273 $(CHARACTER_H) \
1265 $(CODING_H) \ 1274 $(CODING_H) \
@@ -1270,6 +1279,7 @@ $(BLD)/process.$(O) : \
1270 $(LISP_H) \ 1279 $(LISP_H) \
1271 $(PROCESS_H) \ 1280 $(PROCESS_H) \
1272 $(SOCKET_H) \ 1281 $(SOCKET_H) \
1282 $(SYSSIGNAL_H) \
1273 $(SYSTIME_H) \ 1283 $(SYSTIME_H) \
1274 $(SYSTTY_H) \ 1284 $(SYSTTY_H) \
1275 $(TERMHOOKS_H) \ 1285 $(TERMHOOKS_H) \
@@ -1278,9 +1288,9 @@ $(BLD)/process.$(O) : \
1278 1288
1279$(BLD)/ralloc.$(O) : \ 1289$(BLD)/ralloc.$(O) : \
1280 $(SRC)/ralloc.c \ 1290 $(SRC)/ralloc.c \
1291 $(SRC)/blockinput.h \
1281 $(SRC)/getpagesize.h \ 1292 $(SRC)/getpagesize.h \
1282 $(NT_INC)/unistd.h \ 1293 $(NT_INC)/unistd.h \
1283 $(BLOCKINPUT_H) \
1284 $(CONFIG_H) \ 1294 $(CONFIG_H) \
1285 $(LISP_H) 1295 $(LISP_H)
1286 1296
@@ -1315,12 +1325,12 @@ $(BLD)/scroll.$(O) : \
1315 1325
1316$(BLD)/search.$(O) : \ 1326$(BLD)/search.$(O) : \
1317 $(SRC)/search.c \ 1327 $(SRC)/search.c \
1328 $(SRC)/blockinput.h \
1318 $(SRC)/category.h \ 1329 $(SRC)/category.h \
1319 $(SRC)/commands.h \ 1330 $(SRC)/commands.h \
1320 $(SRC)/regex.h \ 1331 $(SRC)/regex.h \
1321 $(SRC)/region-cache.h \ 1332 $(SRC)/region-cache.h \
1322 $(SRC)/syntax.h \ 1333 $(SRC)/syntax.h \
1323 $(BLOCKINPUT_H) \
1324 $(BUFFER_H) \ 1334 $(BUFFER_H) \
1325 $(CHARACTER_H) \ 1335 $(CHARACTER_H) \
1326 $(CHARSET_H) \ 1336 $(CHARSET_H) \
@@ -1330,12 +1340,12 @@ $(BLD)/search.$(O) : \
1330 1340
1331$(BLD)/sound.$(O) : \ 1341$(BLD)/sound.$(O) : \
1332 $(SRC)/sound.c \ 1342 $(SRC)/sound.c \
1333 $(SRC)/syssignal.h \
1334 $(NT_INC)/unistd.h \ 1343 $(NT_INC)/unistd.h \
1335 $(ATIMER_H) \ 1344 $(ATIMER_H) \
1336 $(CONFIG_H) \ 1345 $(CONFIG_H) \
1337 $(DISPEXTERN_H) \ 1346 $(DISPEXTERN_H) \
1338 $(LISP_H) 1347 $(LISP_H) \
1348 $(SYSSIGNAL_H)
1339 1349
1340$(BLD)/syntax.$(O) : \ 1350$(BLD)/syntax.$(O) : \
1341 $(SRC)/syntax.c \ 1351 $(SRC)/syntax.c \
@@ -1352,9 +1362,9 @@ $(BLD)/syntax.$(O) : \
1352 1362
1353$(BLD)/sysdep.$(O) : \ 1363$(BLD)/sysdep.$(O) : \
1354 $(SRC)/sysdep.c \ 1364 $(SRC)/sysdep.c \
1365 $(SRC)/blockinput.h \
1355 $(SRC)/cm.h \ 1366 $(SRC)/cm.h \
1356 $(SRC)/sysselect.h \ 1367 $(SRC)/sysselect.h \
1357 $(SRC)/syssignal.h \
1358 $(SRC)/syswait.h \ 1368 $(SRC)/syswait.h \
1359 $(SRC)/termchar.h \ 1369 $(SRC)/termchar.h \
1360 $(SRC)/termopts.h \ 1370 $(SRC)/termopts.h \
@@ -1367,7 +1377,6 @@ $(BLD)/sysdep.$(O) : \
1367 $(GNU_LIB)/execinfo.h \ 1377 $(GNU_LIB)/execinfo.h \
1368 $(GNU_LIB)/ignore-value.h \ 1378 $(GNU_LIB)/ignore-value.h \
1369 $(GNU_LIB)/utimens.h \ 1379 $(GNU_LIB)/utimens.h \
1370 $(BLOCKINPUT_H) \
1371 $(CAREADLINKAT_H) \ 1380 $(CAREADLINKAT_H) \
1372 $(CONFIG_H) \ 1381 $(CONFIG_H) \
1373 $(C_CTYPE_H) \ 1382 $(C_CTYPE_H) \
@@ -1378,6 +1387,7 @@ $(BLD)/sysdep.$(O) : \
1378 $(LISP_H) \ 1387 $(LISP_H) \
1379 $(PROCESS_H) \ 1388 $(PROCESS_H) \
1380 $(SOCKET_H) \ 1389 $(SOCKET_H) \
1390 $(SYSSIGNAL_H) \
1381 $(SYSTIME_H) \ 1391 $(SYSTIME_H) \
1382 $(SYSTTY_H) \ 1392 $(SYSTTY_H) \
1383 $(TERMHOOKS_H) \ 1393 $(TERMHOOKS_H) \
@@ -1385,18 +1395,17 @@ $(BLD)/sysdep.$(O) : \
1385 1395
1386$(BLD)/term.$(O) : \ 1396$(BLD)/term.$(O) : \
1387 $(SRC)/term.c \ 1397 $(SRC)/term.c \
1398 $(SRC)/blockinput.h \
1388 $(SRC)/cm.h \ 1399 $(SRC)/cm.h \
1389 $(SRC)/composite.h \ 1400 $(SRC)/composite.h \
1390 $(SRC)/disptab.h \ 1401 $(SRC)/disptab.h \
1391 $(SRC)/keymap.h \ 1402 $(SRC)/keymap.h \
1392 $(SRC)/syssignal.h \
1393 $(SRC)/termchar.h \ 1403 $(SRC)/termchar.h \
1394 $(SRC)/termopts.h \ 1404 $(SRC)/termopts.h \
1395 $(SRC)/tparam.h \ 1405 $(SRC)/tparam.h \
1396 $(NT_INC)/sys/file.h \ 1406 $(NT_INC)/sys/file.h \
1397 $(NT_INC)/sys/time.h \ 1407 $(NT_INC)/sys/time.h \
1398 $(NT_INC)/unistd.h \ 1408 $(NT_INC)/unistd.h \
1399 $(BLOCKINPUT_H) \
1400 $(BUFFER_H) \ 1409 $(BUFFER_H) \
1401 $(CHARACTER_H) \ 1410 $(CHARACTER_H) \
1402 $(CHARSET_H) \ 1411 $(CHARSET_H) \
@@ -1407,6 +1416,7 @@ $(BLD)/term.$(O) : \
1407 $(INTERVALS_H) \ 1416 $(INTERVALS_H) \
1408 $(KEYBOARD_H) \ 1417 $(KEYBOARD_H) \
1409 $(LISP_H) \ 1418 $(LISP_H) \
1419 $(SYSSIGNAL_H) \
1410 $(SYSTTY_H) \ 1420 $(SYSTTY_H) \
1411 $(TERMHOOKS_H) \ 1421 $(TERMHOOKS_H) \
1412 $(WINDOW_H) 1422 $(WINDOW_H)
@@ -1461,12 +1471,12 @@ $(BLD)/vm-limit.$(O) : \
1461 1471
1462$(BLD)/window.$(O) : \ 1472$(BLD)/window.$(O) : \
1463 $(SRC)/window.c \ 1473 $(SRC)/window.c \
1474 $(SRC)/blockinput.h \
1464 $(SRC)/commands.h \ 1475 $(SRC)/commands.h \
1465 $(SRC)/disptab.h \ 1476 $(SRC)/disptab.h \
1466 $(SRC)/indent.h \ 1477 $(SRC)/indent.h \
1467 $(SRC)/keymap.h \ 1478 $(SRC)/keymap.h \
1468 $(SRC)/termchar.h \ 1479 $(SRC)/termchar.h \
1469 $(BLOCKINPUT_H) \
1470 $(BUFFER_H) \ 1480 $(BUFFER_H) \
1471 $(CHARACTER_H) \ 1481 $(CHARACTER_H) \
1472 $(CONFIG_H) \ 1482 $(CONFIG_H) \
@@ -1481,6 +1491,7 @@ $(BLD)/window.$(O) : \
1481 1491
1482$(BLD)/xdisp.$(O) : \ 1492$(BLD)/xdisp.$(O) : \
1483 $(SRC)/xdisp.c \ 1493 $(SRC)/xdisp.c \
1494 $(SRC)/blockinput.h \
1484 $(SRC)/commands.h \ 1495 $(SRC)/commands.h \
1485 $(SRC)/disptab.h \ 1496 $(SRC)/disptab.h \
1486 $(SRC)/fontset.h \ 1497 $(SRC)/fontset.h \
@@ -1490,7 +1501,7 @@ $(BLD)/xdisp.$(O) : \
1490 $(SRC)/region-cache.h \ 1501 $(SRC)/region-cache.h \
1491 $(SRC)/termchar.h \ 1502 $(SRC)/termchar.h \
1492 $(SRC)/termopts.h \ 1503 $(SRC)/termopts.h \
1493 $(BLOCKINPUT_H) \ 1504 $(ATIMER_H) \
1494 $(BUFFER_H) \ 1505 $(BUFFER_H) \
1495 $(CHARACTER_H) \ 1506 $(CHARACTER_H) \
1496 $(CHARSET_H) \ 1507 $(CHARSET_H) \
@@ -1509,10 +1520,10 @@ $(BLD)/xdisp.$(O) : \
1509 1520
1510$(BLD)/xfaces.$(O) : \ 1521$(BLD)/xfaces.$(O) : \
1511 $(SRC)/xfaces.c \ 1522 $(SRC)/xfaces.c \
1523 $(SRC)/blockinput.h \
1512 $(SRC)/fontset.h \ 1524 $(SRC)/fontset.h \
1513 $(SRC)/termchar.h \ 1525 $(SRC)/termchar.h \
1514 $(NT_INC)/sys/stat.h \ 1526 $(NT_INC)/sys/stat.h \
1515 $(BLOCKINPUT_H) \
1516 $(BUFFER_H) \ 1527 $(BUFFER_H) \
1517 $(CHARACTER_H) \ 1528 $(CHARACTER_H) \
1518 $(CHARSET_H) \ 1529 $(CHARSET_H) \
@@ -1530,11 +1541,11 @@ $(BLD)/xfaces.$(O) : \
1530 1541
1531$(BLD)/w32fns.$(O) : \ 1542$(BLD)/w32fns.$(O) : \
1532 $(SRC)/w32fns.c \ 1543 $(SRC)/w32fns.c \
1544 $(SRC)/blockinput.h \
1533 $(SRC)/epaths.h \ 1545 $(SRC)/epaths.h \
1534 $(SRC)/fontset.h \ 1546 $(SRC)/fontset.h \
1535 $(SRC)/w32.h \ 1547 $(SRC)/w32.h \
1536 $(SRC)/w32heap.h \ 1548 $(SRC)/w32heap.h \
1537 $(BLOCKINPUT_H) \
1538 $(BUFFER_H) \ 1549 $(BUFFER_H) \
1539 $(CCL_H) \ 1550 $(CCL_H) \
1540 $(CHARACTER_H) \ 1551 $(CHARACTER_H) \
@@ -1555,9 +1566,9 @@ $(BLD)/w32fns.$(O) : \
1555 1566
1556$(BLD)/w32menu.$(O) : \ 1567$(BLD)/w32menu.$(O) : \
1557 $(SRC)/w32menu.c \ 1568 $(SRC)/w32menu.c \
1569 $(SRC)/blockinput.h \
1558 $(SRC)/keymap.h \ 1570 $(SRC)/keymap.h \
1559 $(SRC)/w32heap.h \ 1571 $(SRC)/w32heap.h \
1560 $(BLOCKINPUT_H) \
1561 $(BUFFER_H) \ 1572 $(BUFFER_H) \
1562 $(CHARACTER_H) \ 1573 $(CHARACTER_H) \
1563 $(CHARSET_H) \ 1574 $(CHARSET_H) \
@@ -1574,6 +1585,7 @@ $(BLD)/w32menu.$(O) : \
1574 1585
1575$(BLD)/w32term.$(O) : \ 1586$(BLD)/w32term.$(O) : \
1576 $(SRC)/w32term.c \ 1587 $(SRC)/w32term.c \
1588 $(SRC)/blockinput.h \
1577 $(SRC)/disptab.h \ 1589 $(SRC)/disptab.h \
1578 $(SRC)/fontset.h \ 1590 $(SRC)/fontset.h \
1579 $(SRC)/keymap.h \ 1591 $(SRC)/keymap.h \
@@ -1582,7 +1594,6 @@ $(BLD)/w32term.$(O) : \
1582 $(SRC)/w32heap.h \ 1594 $(SRC)/w32heap.h \
1583 $(NT_INC)/sys/stat.h \ 1595 $(NT_INC)/sys/stat.h \
1584 $(ATIMER_H) \ 1596 $(ATIMER_H) \
1585 $(BLOCKINPUT_H) \
1586 $(BUFFER_H) \ 1597 $(BUFFER_H) \
1587 $(CCL_H) \ 1598 $(CCL_H) \
1588 $(CHARACTER_H) \ 1599 $(CHARACTER_H) \
@@ -1605,9 +1616,9 @@ $(BLD)/w32term.$(O) : \
1605 1616
1606$(BLD)/w32select.$(O) : \ 1617$(BLD)/w32select.$(O) : \
1607 $(SRC)/w32select.c \ 1618 $(SRC)/w32select.c \
1619 $(SRC)/blockinput.h \
1608 $(SRC)/composite.h \ 1620 $(SRC)/composite.h \
1609 $(SRC)/w32heap.h \ 1621 $(SRC)/w32heap.h \
1610 $(BLOCKINPUT_H) \
1611 $(CHARSET_H) \ 1622 $(CHARSET_H) \
1612 $(CODING_H) \ 1623 $(CODING_H) \
1613 $(CONFIG_H) \ 1624 $(CONFIG_H) \
@@ -1616,15 +1627,15 @@ $(BLD)/w32select.$(O) : \
1616 1627
1617$(BLD)/w32reg.$(O) : \ 1628$(BLD)/w32reg.$(O) : \
1618 $(SRC)/w32reg.c \ 1629 $(SRC)/w32reg.c \
1619 $(BLOCKINPUT_H) \ 1630 $(SRC)/blockinput.h \
1620 $(CONFIG_H) \ 1631 $(CONFIG_H) \
1621 $(LISP_H) \ 1632 $(LISP_H) \
1622 $(W32TERM_H) 1633 $(W32TERM_H)
1623 1634
1624$(BLD)/w32xfns.$(O) : \ 1635$(BLD)/w32xfns.$(O) : \
1625 $(SRC)/w32xfns.c \ 1636 $(SRC)/w32xfns.c \
1637 $(SRC)/blockinput.h \
1626 $(SRC)/fontset.h \ 1638 $(SRC)/fontset.h \
1627 $(BLOCKINPUT_H) \
1628 $(CHARSET_H) \ 1639 $(CHARSET_H) \
1629 $(CONFIG_H) \ 1640 $(CONFIG_H) \
1630 $(FRAME_H) \ 1641 $(FRAME_H) \
diff --git a/src/menu.c b/src/menu.c
index 7b01d1faefc..5374aa9157a 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -573,9 +573,9 @@ xmalloc_widget_value (void)
573{ 573{
574 widget_value *value; 574 widget_value *value;
575 575
576 BLOCK_INPUT; 576 block_input ();
577 value = malloc_widget_value (); 577 value = malloc_widget_value ();
578 UNBLOCK_INPUT; 578 unblock_input ();
579 579
580 return value; 580 return value;
581} 581}
@@ -602,9 +602,9 @@ free_menubar_widget_value_tree (widget_value *wv)
602 free_menubar_widget_value_tree (wv->next); 602 free_menubar_widget_value_tree (wv->next);
603 wv->next = (widget_value *) 0xDEADBEEF; 603 wv->next = (widget_value *) 0xDEADBEEF;
604 } 604 }
605 BLOCK_INPUT; 605 block_input ();
606 free_widget_value (wv); 606 free_widget_value (wv);
607 UNBLOCK_INPUT; 607 unblock_input ();
608} 608}
609 609
610/* Create a tree of widget_value objects 610/* Create a tree of widget_value objects
@@ -1313,7 +1313,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1313#endif 1313#endif
1314 1314
1315 /* Display them in a menu. */ 1315 /* Display them in a menu. */
1316 BLOCK_INPUT; 1316 block_input ();
1317 1317
1318 /* FIXME: Use a terminal hook! */ 1318 /* FIXME: Use a terminal hook! */
1319#if defined HAVE_NTGUI 1319#if defined HAVE_NTGUI
@@ -1332,7 +1332,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1332 last_event_timestamp); 1332 last_event_timestamp);
1333#endif 1333#endif
1334 1334
1335 UNBLOCK_INPUT; 1335 unblock_input ();
1336 1336
1337#ifdef HAVE_NS 1337#ifdef HAVE_NS
1338 unbind_to (specpdl_count, Qnil); 1338 unbind_to (specpdl_count, Qnil);
diff --git a/src/msdos.c b/src/msdos.c
index ed5d3240aa1..bac6b977fdf 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1229,7 +1229,7 @@ IT_update_begin (struct frame *f)
1229 if (display_info->termscript) 1229 if (display_info->termscript)
1230 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN"); 1230 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN");
1231 1231
1232 BLOCK_INPUT; 1232 block_input ();
1233 1233
1234 if (f && f == mouse_face_frame) 1234 if (f && f == mouse_face_frame)
1235 { 1235 {
@@ -1279,7 +1279,7 @@ IT_update_begin (struct frame *f)
1279 hlinfo->mouse_face_mouse_frame = NULL; 1279 hlinfo->mouse_face_mouse_frame = NULL;
1280 } 1280 }
1281 1281
1282 UNBLOCK_INPUT; 1282 unblock_input ();
1283} 1283}
1284 1284
1285static void 1285static void
@@ -1302,13 +1302,13 @@ IT_frame_up_to_date (struct frame *f)
1302 if (hlinfo->mouse_face_deferred_gc 1302 if (hlinfo->mouse_face_deferred_gc
1303 || (f && f == hlinfo->mouse_face_mouse_frame)) 1303 || (f && f == hlinfo->mouse_face_mouse_frame))
1304 { 1304 {
1305 BLOCK_INPUT; 1305 block_input ();
1306 if (hlinfo->mouse_face_mouse_frame) 1306 if (hlinfo->mouse_face_mouse_frame)
1307 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, 1307 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
1308 hlinfo->mouse_face_mouse_x, 1308 hlinfo->mouse_face_mouse_x,
1309 hlinfo->mouse_face_mouse_y); 1309 hlinfo->mouse_face_mouse_y);
1310 hlinfo->mouse_face_deferred_gc = 0; 1310 hlinfo->mouse_face_deferred_gc = 0;
1311 UNBLOCK_INPUT; 1311 unblock_input ();
1312 } 1312 }
1313 1313
1314 /* Set the cursor type to whatever they wanted. In a minibuffer 1314 /* Set the cursor type to whatever they wanted. In a minibuffer
diff --git a/src/nsfns.m b/src/nsfns.m
index e2c8c3722c0..c96ec99ed2e 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -615,7 +615,7 @@ ns_set_name_as_filename (struct frame *f)
615 if (f->explicit_name || ! NILP (f->title) || ns_in_resize) 615 if (f->explicit_name || ! NILP (f->title) || ns_in_resize)
616 return; 616 return;
617 617
618 BLOCK_INPUT; 618 block_input ();
619 pool = [[NSAutoreleasePool alloc] init]; 619 pool = [[NSAutoreleasePool alloc] init];
620 filename = BVAR (XBUFFER (buf), filename); 620 filename = BVAR (XBUFFER (buf), filename);
621 name = BVAR (XBUFFER (buf), name); 621 name = BVAR (XBUFFER (buf), name);
@@ -640,7 +640,7 @@ ns_set_name_as_filename (struct frame *f)
640 if (title && (! strcmp (title, SSDATA (encoded_name)))) 640 if (title && (! strcmp (title, SSDATA (encoded_name))))
641 { 641 {
642 [pool release]; 642 [pool release];
643 UNBLOCK_INPUT; 643 unblock_input ();
644 return; 644 return;
645 } 645 }
646 646
@@ -678,7 +678,7 @@ ns_set_name_as_filename (struct frame *f)
678 } 678 }
679 679
680 [pool release]; 680 [pool release];
681 UNBLOCK_INPUT; 681 unblock_input ();
682} 682}
683 683
684 684
@@ -689,11 +689,11 @@ ns_set_doc_edited (struct frame *f, Lisp_Object arg)
689 NSAutoreleasePool *pool; 689 NSAutoreleasePool *pool;
690 if (!MINI_WINDOW_P (XWINDOW (f->selected_window))) 690 if (!MINI_WINDOW_P (XWINDOW (f->selected_window)))
691 { 691 {
692 BLOCK_INPUT; 692 block_input ();
693 pool = [[NSAutoreleasePool alloc] init]; 693 pool = [[NSAutoreleasePool alloc] init];
694 [[view window] setDocumentEdited: !NILP (arg)]; 694 [[view window] setDocumentEdited: !NILP (arg)];
695 [pool release]; 695 [pool release];
696 UNBLOCK_INPUT; 696 unblock_input ();
697 } 697 }
698} 698}
699 699
@@ -771,14 +771,14 @@ ns_implicitly_set_icon_type (struct frame *f)
771 771
772 NSTRACE (ns_implicitly_set_icon_type); 772 NSTRACE (ns_implicitly_set_icon_type);
773 773
774 BLOCK_INPUT; 774 block_input ();
775 pool = [[NSAutoreleasePool alloc] init]; 775 pool = [[NSAutoreleasePool alloc] init];
776 if (f->output_data.ns->miniimage 776 if (f->output_data.ns->miniimage
777 && [[NSString stringWithUTF8String: SSDATA (f->name)] 777 && [[NSString stringWithUTF8String: SSDATA (f->name)]
778 isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]]) 778 isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]])
779 { 779 {
780 [pool release]; 780 [pool release];
781 UNBLOCK_INPUT; 781 unblock_input ();
782 return; 782 return;
783 } 783 }
784 784
@@ -786,7 +786,7 @@ ns_implicitly_set_icon_type (struct frame *f)
786 if (CONSP (tem) && ! NILP (XCDR (tem))) 786 if (CONSP (tem) && ! NILP (XCDR (tem)))
787 { 787 {
788 [pool release]; 788 [pool release];
789 UNBLOCK_INPUT; 789 unblock_input ();
790 return; 790 return;
791 } 791 }
792 792
@@ -826,7 +826,7 @@ ns_implicitly_set_icon_type (struct frame *f)
826 f->output_data.ns->miniimage = image; 826 f->output_data.ns->miniimage = image;
827 [view setMiniwindowImage: setMini]; 827 [view setMiniwindowImage: setMini];
828 [pool release]; 828 [pool release];
829 UNBLOCK_INPUT; 829 unblock_input ();
830} 830}
831 831
832 832
@@ -1018,7 +1018,7 @@ frame_parm_handler ns_frame_parm_handlers[] =
1018 x_set_fringe_width, /* generic OK */ 1018 x_set_fringe_width, /* generic OK */
1019 x_set_fringe_width, /* generic OK */ 1019 x_set_fringe_width, /* generic OK */
1020 0, /* x_set_wait_for_wm, will ignore */ 1020 0, /* x_set_wait_for_wm, will ignore */
1021 0, /* x_set_fullscreen will ignore */ 1021 x_set_fullscreen, /* generic OK */
1022 x_set_font_backend, /* generic OK */ 1022 x_set_font_backend, /* generic OK */
1023 x_set_alpha, 1023 x_set_alpha,
1024 0, /* x_set_sticky */ 1024 0, /* x_set_sticky */
@@ -1232,7 +1232,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1232 f->resx = dpyinfo->resx; 1232 f->resx = dpyinfo->resx;
1233 f->resy = dpyinfo->resy; 1233 f->resy = dpyinfo->resy;
1234 1234
1235 BLOCK_INPUT; 1235 block_input ();
1236 register_font_driver (&nsfont_driver, f); 1236 register_font_driver (&nsfont_driver, f);
1237 x_default_parameter (f, parms, Qfont_backend, Qnil, 1237 x_default_parameter (f, parms, Qfont_backend, Qnil,
1238 "fontBackend", "FontBackend", RES_TYPE_STRING); 1238 "fontBackend", "FontBackend", RES_TYPE_STRING);
@@ -1247,7 +1247,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1247 build_string ([[font fontName] UTF8String]), 1247 build_string ([[font fontName] UTF8String]),
1248 "font", "Font", RES_TYPE_STRING); 1248 "font", "Font", RES_TYPE_STRING);
1249 } 1249 }
1250 UNBLOCK_INPUT; 1250 unblock_input ();
1251 1251
1252 x_default_parameter (f, parms, Qborder_width, make_number (0), 1252 x_default_parameter (f, parms, Qborder_width, make_number (0),
1253 "borderwidth", "BorderWidth", RES_TYPE_NUMBER); 1253 "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
@@ -1411,10 +1411,10 @@ FRAME nil means use the selected frame. */)
1411 if (dpyinfo->x_focus_frame != f) 1411 if (dpyinfo->x_focus_frame != f)
1412 { 1412 {
1413 EmacsView *view = FRAME_NS_VIEW (f); 1413 EmacsView *view = FRAME_NS_VIEW (f);
1414 BLOCK_INPUT; 1414 block_input ();
1415 [NSApp activateIgnoringOtherApps: YES]; 1415 [NSApp activateIgnoringOtherApps: YES];
1416 [[view window] makeKeyAndOrderFront: view]; 1416 [[view window] makeKeyAndOrderFront: view];
1417 UNBLOCK_INPUT; 1417 unblock_input ();
1418 } 1418 }
1419 1419
1420 return Qnil; 1420 return Qnil;
@@ -1511,7 +1511,7 @@ Optional arg INIT, if non-nil, provides a default file name to use. */)
1511 [panel setDelegate: fileDelegate]; 1511 [panel setDelegate: fileDelegate];
1512 1512
1513 panelOK = 0; 1513 panelOK = 0;
1514 BLOCK_INPUT; 1514 block_input ();
1515 if (NILP (mustmatch)) 1515 if (NILP (mustmatch))
1516 { 1516 {
1517 ret = [panel runModalForDirectory: dirS file: initS]; 1517 ret = [panel runModalForDirectory: dirS file: initS];
@@ -1528,7 +1528,7 @@ Optional arg INIT, if non-nil, provides a default file name to use. */)
1528 fname = build_string ([[panel filename] UTF8String]); 1528 fname = build_string ([[panel filename] UTF8String]);
1529 1529
1530 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; 1530 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
1531 UNBLOCK_INPUT; 1531 unblock_input ();
1532 1532
1533 return ret ? fname : Qnil; 1533 return ret ? fname : Qnil;
1534} 1534}
@@ -1899,7 +1899,7 @@ The optional argument FRAME is currently ignored. */)
1899 error ("non-Nextstep frame used in `ns-list-colors'"); 1899 error ("non-Nextstep frame used in `ns-list-colors'");
1900 } 1900 }
1901 1901
1902 BLOCK_INPUT; 1902 block_input ();
1903 1903
1904 colorlists = [[NSColorList availableColorLists] objectEnumerator]; 1904 colorlists = [[NSColorList availableColorLists] objectEnumerator];
1905 while ((clist = [colorlists nextObject])) 1905 while ((clist = [colorlists nextObject]))
@@ -1917,7 +1917,7 @@ The optional argument FRAME is currently ignored. */)
1917 } 1917 }
1918 } 1918 }
1919 1919
1920 UNBLOCK_INPUT; 1920 unblock_input ();
1921 1921
1922 return list; 1922 return list;
1923} 1923}
@@ -2115,7 +2115,7 @@ In case the execution fails, an error is signaled. */)
2115 CHECK_STRING (script); 2115 CHECK_STRING (script);
2116 check_ns (); 2116 check_ns ();
2117 2117
2118 BLOCK_INPUT; 2118 block_input ();
2119 2119
2120 as_script = script; 2120 as_script = script;
2121 as_result = &result; 2121 as_result = &result;
@@ -2141,7 +2141,7 @@ In case the execution fails, an error is signaled. */)
2141 as_status = 0; 2141 as_status = 0;
2142 as_script = Qnil; 2142 as_script = Qnil;
2143 as_result = 0; 2143 as_result = 0;
2144 UNBLOCK_INPUT; 2144 unblock_input ();
2145 if (status == 0) 2145 if (status == 0)
2146 return result; 2146 return result;
2147 else if (!STRINGP (result)) 2147 else if (!STRINGP (result))
@@ -2548,7 +2548,7 @@ Text larger than the specified size is clipped. */)
2548 else 2548 else
2549 CHECK_NUMBER (dy); 2549 CHECK_NUMBER (dy);
2550 2550
2551 BLOCK_INPUT; 2551 block_input ();
2552 if (ns_tooltip == nil) 2552 if (ns_tooltip == nil)
2553 ns_tooltip = [[EmacsTooltip alloc] init]; 2553 ns_tooltip = [[EmacsTooltip alloc] init];
2554 else 2554 else
@@ -2563,7 +2563,7 @@ Text larger than the specified size is clipped. */)
2563 &root_x, &root_y); 2563 &root_x, &root_y);
2564 2564
2565 [ns_tooltip showAtX: root_x Y: root_y for: XINT (timeout)]; 2565 [ns_tooltip showAtX: root_x Y: root_y for: XINT (timeout)];
2566 UNBLOCK_INPUT; 2566 unblock_input ();
2567 2567
2568 UNGCPRO; 2568 UNGCPRO;
2569 return unbind_to (count, Qnil); 2569 return unbind_to (count, Qnil);
diff --git a/src/nsfont.m b/src/nsfont.m
index eba1eb04765..b13c96aa6ed 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -821,7 +821,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
821 font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); 821 font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
822 font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); 822 font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics);
823 823
824 BLOCK_INPUT; 824 block_input ();
825 825
826 /* for metrics */ 826 /* for metrics */
827 sfont = [nsfont screenFont]; 827 sfont = [nsfont screenFont];
@@ -932,7 +932,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
932 font->props[FONT_FULLNAME_INDEX] = 932 font->props[FONT_FULLNAME_INDEX] =
933 make_unibyte_string (font_info->name, strlen (font_info->name)); 933 make_unibyte_string (font_info->name, strlen (font_info->name));
934 } 934 }
935 UNBLOCK_INPUT; 935 unblock_input ();
936 936
937 return font_object; 937 return font_object;
938} 938}
@@ -1316,7 +1316,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
1316 fprintf (stderr, "%p\tFinding glyphs for glyphs in block %d\n", 1316 fprintf (stderr, "%p\tFinding glyphs for glyphs in block %d\n",
1317 font_info, block); 1317 font_info, block);
1318 1318
1319 BLOCK_INPUT; 1319 block_input ();
1320 1320
1321#ifdef NS_IMPL_COCOA 1321#ifdef NS_IMPL_COCOA
1322 if (firstTime) 1322 if (firstTime)
@@ -1373,7 +1373,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
1373#endif 1373#endif
1374 } 1374 }
1375 1375
1376 UNBLOCK_INPUT; 1376 unblock_input ();
1377 xfree (unichars); 1377 xfree (unichars);
1378} 1378}
1379 1379
@@ -1398,7 +1398,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
1398 numGlyphs = 0x10000; 1398 numGlyphs = 0x10000;
1399#endif 1399#endif
1400 1400
1401 BLOCK_INPUT; 1401 block_input ();
1402 sfont = [font_info->nsfont screenFont]; 1402 sfont = [font_info->nsfont screenFont];
1403 1403
1404 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); 1404 font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics));
@@ -1427,7 +1427,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
1427 metrics->ascent = r.size.height - metrics->descent; 1427 metrics->ascent = r.size.height - metrics->descent;
1428/*-lrint (hshrink* [sfont descender] - expand * hd/2); */ 1428/*-lrint (hshrink* [sfont descender] - expand * hd/2); */
1429 } 1429 }
1430 UNBLOCK_INPUT; 1430 unblock_input ();
1431} 1431}
1432 1432
1433 1433
diff --git a/src/nsimage.m b/src/nsimage.m
index 668664c7a20..370cf832c7c 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -78,7 +78,7 @@ ns_image_from_file (Lisp_Object file)
78 return [EmacsImage allocInitFromFile: file]; 78 return [EmacsImage allocInitFromFile: file];
79} 79}
80 80
81int 81bool
82ns_load_image (struct frame *f, struct image *img, 82ns_load_image (struct frame *f, struct image *img,
83 Lisp_Object spec_file, Lisp_Object spec_data) 83 Lisp_Object spec_file, Lisp_Object spec_data)
84{ 84{
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 907d3eac622..b60cc005c5f 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -115,13 +115,13 @@ popup_activated (void)
115 115
116/* -------------------------------------------------------------------------- 116/* --------------------------------------------------------------------------
117 Update menubar. Three cases: 117 Update menubar. Three cases:
118 1) deep_p = 0, submenu = nil: Fresh switch onto a frame -- either set up 118 1) ! deep_p, submenu = nil: Fresh switch onto a frame -- either set up
119 just top-level menu strings (OS X), or goto case (2) (GNUstep). 119 just top-level menu strings (OS X), or goto case (2) (GNUstep).
120 2) deep_p = 1, submenu = nil: Recompute all submenus. 120 2) deep_p, submenu = nil: Recompute all submenus.
121 3) deep_p = 1, submenu = non-nil: Update contents of a single submenu. 121 3) deep_p, submenu = non-nil: Update contents of a single submenu.
122 -------------------------------------------------------------------------- */ 122 -------------------------------------------------------------------------- */
123void 123void
124ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) 124ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
125{ 125{
126 NSAutoreleasePool *pool; 126 NSAutoreleasePool *pool;
127 id menu = [NSApp mainMenu]; 127 id menu = [NSApp mainMenu];
@@ -146,7 +146,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
146 XSETFRAME (Vmenu_updating_frame, f); 146 XSETFRAME (Vmenu_updating_frame, f);
147/*fprintf (stderr, "ns_update_menubar: frame: %p\tdeep: %d\tsub: %p\n", f, deep_p, submenu); */ 147/*fprintf (stderr, "ns_update_menubar: frame: %p\tdeep: %d\tsub: %p\n", f, deep_p, submenu); */
148 148
149 BLOCK_INPUT; 149 block_input ();
150 pool = [[NSAutoreleasePool alloc] init]; 150 pool = [[NSAutoreleasePool alloc] init];
151 151
152 /* Menu may have been created automatically; if so, discard it. */ 152 /* Menu may have been created automatically; if so, discard it. */
@@ -271,7 +271,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
271 discard_menu_items (); 271 discard_menu_items ();
272 unbind_to (specpdl_count, Qnil); 272 unbind_to (specpdl_count, Qnil);
273 [pool release]; 273 [pool release];
274 UNBLOCK_INPUT; 274 unblock_input ();
275 return; 275 return;
276 } 276 }
277 277
@@ -333,7 +333,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
333 discard_menu_items (); 333 discard_menu_items ();
334 unbind_to (specpdl_count, Qnil); 334 unbind_to (specpdl_count, Qnil);
335 [pool release]; 335 [pool release];
336 UNBLOCK_INPUT; 336 unblock_input ();
337 return; 337 return;
338 } 338 }
339 } 339 }
@@ -404,7 +404,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
404 { 404 {
405 free_menubar_widget_value_tree (first_wv); 405 free_menubar_widget_value_tree (first_wv);
406 [pool release]; 406 [pool release];
407 UNBLOCK_INPUT; 407 unblock_input ();
408 return; 408 return;
409 } 409 }
410 410
@@ -435,7 +435,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
435 { 435 {
436 free_menubar_widget_value_tree (first_wv); 436 free_menubar_widget_value_tree (first_wv);
437 [pool release]; 437 [pool release];
438 UNBLOCK_INPUT; 438 unblock_input ();
439 return; 439 return;
440 } 440 }
441 } 441 }
@@ -498,7 +498,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
498 [NSApp setMainMenu: menu]; 498 [NSApp setMainMenu: menu];
499 499
500 [pool release]; 500 [pool release];
501 UNBLOCK_INPUT; 501 unblock_input ();
502 502
503} 503}
504 504
@@ -507,7 +507,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
507 frame's menus have changed, and the *step representation should be updated 507 frame's menus have changed, and the *step representation should be updated
508 from Lisp. */ 508 from Lisp. */
509void 509void
510set_frame_menubar (struct frame *f, int first_time, int deep_p) 510set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
511{ 511{
512 ns_update_menubar (f, deep_p, nil); 512 ns_update_menubar (f, deep_p, nil);
513} 513}
@@ -1012,10 +1012,10 @@ free_frame_tool_bar (FRAME_PTR f)
1012 Under NS we just hide the toolbar until it might be needed again. 1012 Under NS we just hide the toolbar until it might be needed again.
1013 -------------------------------------------------------------------------- */ 1013 -------------------------------------------------------------------------- */
1014{ 1014{
1015 BLOCK_INPUT; 1015 block_input ();
1016 [[FRAME_NS_VIEW (f) toolbar] setVisible: NO]; 1016 [[FRAME_NS_VIEW (f) toolbar] setVisible: NO];
1017 FRAME_TOOLBAR_HEIGHT (f) = 0; 1017 FRAME_TOOLBAR_HEIGHT (f) = 0;
1018 UNBLOCK_INPUT; 1018 unblock_input ();
1019} 1019}
1020 1020
1021void 1021void
@@ -1029,7 +1029,7 @@ update_frame_tool_bar (FRAME_PTR f)
1029 NSWindow *window = [view window]; 1029 NSWindow *window = [view window];
1030 EmacsToolbar *toolbar = [view toolbar]; 1030 EmacsToolbar *toolbar = [view toolbar];
1031 1031
1032 BLOCK_INPUT; 1032 block_input ();
1033 [toolbar clearActive]; 1033 [toolbar clearActive];
1034 1034
1035 /* update EmacsToolbar as in GtkUtils, build items list */ 1035 /* update EmacsToolbar as in GtkUtils, build items list */
@@ -1115,7 +1115,7 @@ update_frame_tool_bar (FRAME_PTR f)
1115 FRAME_TOOLBAR_HEIGHT (f) = 1115 FRAME_TOOLBAR_HEIGHT (f) =
1116 NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) 1116 NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
1117 - FRAME_NS_TITLEBAR_HEIGHT (f); 1117 - FRAME_NS_TITLEBAR_HEIGHT (f);
1118 UNBLOCK_INPUT; 1118 unblock_input ();
1119} 1119}
1120 1120
1121 1121
@@ -1355,7 +1355,7 @@ pop_down_menu (Lisp_Object arg)
1355 struct Lisp_Save_Value *p = XSAVE_VALUE (arg); 1355 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1356 struct Popdown_data *unwind_data = (struct Popdown_data *) p->pointer; 1356 struct Popdown_data *unwind_data = (struct Popdown_data *) p->pointer;
1357 1357
1358 BLOCK_INPUT; 1358 block_input ();
1359 if (popup_activated_flag) 1359 if (popup_activated_flag)
1360 { 1360 {
1361 EmacsDialogPanel *panel = unwind_data->dialog; 1361 EmacsDialogPanel *panel = unwind_data->dialog;
@@ -1366,7 +1366,7 @@ pop_down_menu (Lisp_Object arg)
1366 } 1366 }
1367 1367
1368 xfree (unwind_data); 1368 xfree (unwind_data);
1369 UNBLOCK_INPUT; 1369 unblock_input ();
1370 1370
1371 return Qnil; 1371 return Qnil;
1372} 1372}
@@ -1434,7 +1434,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1434 the dialog. */ 1434 the dialog. */
1435 contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil)); 1435 contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil));
1436 1436
1437 BLOCK_INPUT; 1437 block_input ();
1438 pool = [[NSAutoreleasePool alloc] init]; 1438 pool = [[NSAutoreleasePool alloc] init];
1439 dialog = [[EmacsDialogPanel alloc] initFromContents: contents 1439 dialog = [[EmacsDialogPanel alloc] initFromContents: contents
1440 isQuestion: isQ]; 1440 isQuestion: isQ];
@@ -1452,7 +1452,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1452 unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ 1452 unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */
1453 } 1453 }
1454 1454
1455 UNBLOCK_INPUT; 1455 unblock_input ();
1456 1456
1457 return tem; 1457 return tem;
1458} 1458}
@@ -1766,7 +1766,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1766} 1766}
1767 1767
1768 1768
1769 1769
1770- (void)timeout_handler: (NSTimer *)timedEntry 1770- (void)timeout_handler: (NSTimer *)timedEntry
1771{ 1771{
1772 NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined 1772 NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined
diff --git a/src/nsterm.h b/src/nsterm.h
index f3adab883a1..f06e0cb0f7f 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -38,6 +38,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#ifndef MAC_OS_X_VERSION_10_6 38#ifndef MAC_OS_X_VERSION_10_6
39#define MAC_OS_X_VERSION_10_6 1060 39#define MAC_OS_X_VERSION_10_6 1060
40#endif 40#endif
41#ifndef MAC_OS_X_VERSION_10_7
42#define MAC_OS_X_VERSION_10_7 1070
43#endif
44#ifndef MAC_OS_X_VERSION_10_8
45#define MAC_OS_X_VERSION_10_8 1080
46#endif
41#endif /* NS_IMPL_COCOA */ 47#endif /* NS_IMPL_COCOA */
42 48
43#ifdef __OBJC__ 49#ifdef __OBJC__
@@ -80,6 +86,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
80 BOOL windowClosing; 86 BOOL windowClosing;
81 NSString *workingText; 87 NSString *workingText;
82 BOOL processingCompose; 88 BOOL processingCompose;
89 int fs_state, fs_before_fs, next_maximized, tbar_height, bwidth;
90 int maximized_width, maximized_height;
91 NSWindow *nonfs_window;
83@public 92@public
84 struct frame *emacsframe; 93 struct frame *emacsframe;
85 int rows, cols; 94 int rows, cols;
@@ -104,6 +113,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
104- (EmacsToolbar *) toolbar; 113- (EmacsToolbar *) toolbar;
105- (void) deleteWorkingText; 114- (void) deleteWorkingText;
106- (void) updateFrameSize: (BOOL) delay; 115- (void) updateFrameSize: (BOOL) delay;
116- (void) handleFS;
117- (void) setFSValue: (int)value;
118- (void) toggleFullScreen: (id) sender;
107 119
108#ifdef NS_IMPL_GNUSTEP 120#ifdef NS_IMPL_GNUSTEP
109/* Not declared, but useful. */ 121/* Not declared, but useful. */
@@ -120,6 +132,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
120@end 132@end
121 133
122 134
135/* Fullscreen version of the above. */
136@interface EmacsFSWindow : EmacsWindow
137{
138}
139@end
140
123/* ========================================================================== 141/* ==========================================================================
124 142
125 The main menu implementation 143 The main menu implementation
@@ -749,11 +767,11 @@ extern Lisp_Object ns_cursor_type_to_lisp (int arg);
749extern void ns_set_name_as_filename (struct frame *f); 767extern void ns_set_name_as_filename (struct frame *f);
750extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg); 768extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg);
751 769
752extern int 770extern bool
753ns_defined_color (struct frame *f, 771ns_defined_color (struct frame *f,
754 const char *name, 772 const char *name,
755 XColor *color_def, int alloc, 773 XColor *color_def, bool alloc,
756 char makeIndex); 774 bool makeIndex);
757extern void 775extern void
758ns_query_color (void *col, XColor *color_def, int setPixel); 776ns_query_color (void *col, XColor *color_def, int setPixel);
759 777
@@ -799,8 +817,8 @@ struct image;
799extern void *ns_image_from_XBM (unsigned char *bits, int width, int height); 817extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
800extern void *ns_image_for_XPM (int width, int height, int depth); 818extern void *ns_image_for_XPM (int width, int height, int depth);
801extern void *ns_image_from_file (Lisp_Object file); 819extern void *ns_image_from_file (Lisp_Object file);
802extern int ns_load_image (struct frame *f, struct image *img, 820extern bool ns_load_image (struct frame *f, struct image *img,
803 Lisp_Object spec_file, Lisp_Object spec_data); 821 Lisp_Object spec_file, Lisp_Object spec_data);
804extern int ns_image_width (void *img); 822extern int ns_image_width (void *img);
805extern int ns_image_height (void *img); 823extern int ns_image_height (void *img);
806extern unsigned long ns_get_pixel (void *img, int x, int y); 824extern unsigned long ns_get_pixel (void *img, int x, int y);
diff --git a/src/nsterm.m b/src/nsterm.m
index aa869e3ff44..d41c38f4e40 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -72,6 +72,11 @@ int term_trace_num = 0;
72#define NSTRACE(x) 72#define NSTRACE(x)
73#endif 73#endif
74 74
75#if defined (NS_IMPL_COCOA) && \
76 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
77#define NEW_STYLE_FS
78#endif
79
75extern NSString *NSMenuDidBeginTrackingNotification; 80extern NSString *NSMenuDidBeginTrackingNotification;
76 81
77/* ========================================================================== 82/* ==========================================================================
@@ -581,7 +586,7 @@ ns_update_auto_hide_menu_bar (void)
581#endif 586#endif
582#ifdef NS_IMPL_COCOA 587#ifdef NS_IMPL_COCOA
583#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 588#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
584 BLOCK_INPUT; 589 block_input ();
585 590
586 NSTRACE (ns_update_auto_hide_menu_bar); 591 NSTRACE (ns_update_auto_hide_menu_bar);
587 592
@@ -612,7 +617,7 @@ ns_update_auto_hide_menu_bar (void)
612 } 617 }
613 } 618 }
614 619
615 UNBLOCK_INPUT; 620 unblock_input ();
616#endif 621#endif
617#endif 622#endif
618} 623}
@@ -662,7 +667,7 @@ ns_update_window_begin (struct window *w)
662 updated_window = w; 667 updated_window = w;
663 set_output_cursor (&w->cursor); 668 set_output_cursor (&w->cursor);
664 669
665 BLOCK_INPUT; 670 block_input ();
666 671
667 if (f == hlinfo->mouse_face_mouse_frame) 672 if (f == hlinfo->mouse_face_mouse_frame)
668 { 673 {
@@ -677,7 +682,7 @@ ns_update_window_begin (struct window *w)
677 /* (further code for mouse faces ifdef'd out in other terms elided) */ 682 /* (further code for mouse faces ifdef'd out in other terms elided) */
678 } 683 }
679 684
680 UNBLOCK_INPUT; 685 unblock_input ();
681} 686}
682 687
683 688
@@ -694,7 +699,7 @@ ns_update_window_end (struct window *w, int cursor_on_p,
694 /* note: this fn is nearly identical in all terms */ 699 /* note: this fn is nearly identical in all terms */
695 if (!w->pseudo_window_p) 700 if (!w->pseudo_window_p)
696 { 701 {
697 BLOCK_INPUT; 702 block_input ();
698 703
699 if (cursor_on_p) 704 if (cursor_on_p)
700 display_and_set_cursor (w, 1, 705 display_and_set_cursor (w, 1,
@@ -704,7 +709,7 @@ ns_update_window_end (struct window *w, int cursor_on_p,
704 if (draw_window_fringes (w, 1)) 709 if (draw_window_fringes (w, 1))
705 x_draw_vertical_border (w); 710 x_draw_vertical_border (w);
706 711
707 UNBLOCK_INPUT; 712 unblock_input ();
708 } 713 }
709 714
710 /* If a row with mouse-face was overwritten, arrange for 715 /* If a row with mouse-face was overwritten, arrange for
@@ -733,7 +738,7 @@ ns_update_end (struct frame *f)
733/* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ 738/* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
734 MOUSE_HL_INFO (f)->mouse_face_defer = 0; 739 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
735 740
736 BLOCK_INPUT; 741 block_input ();
737 742
738#ifdef NS_IMPL_GNUSTEP 743#ifdef NS_IMPL_GNUSTEP
739 /* trigger flush only in the rectangle we tracked as being drawn */ 744 /* trigger flush only in the rectangle we tracked as being drawn */
@@ -745,7 +750,7 @@ ns_update_end (struct frame *f)
745 [view unlockFocus]; 750 [view unlockFocus];
746 [[view window] flushWindow]; 751 [[view window] flushWindow];
747 752
748 UNBLOCK_INPUT; 753 unblock_input ();
749 ns_updating_frame = NULL; 754 ns_updating_frame = NULL;
750 NSTRACE (ns_update_end); 755 NSTRACE (ns_update_end);
751} 756}
@@ -902,7 +907,7 @@ ns_ring_bell (struct frame *f)
902 struct frame *frame = SELECTED_FRAME (); 907 struct frame *frame = SELECTED_FRAME ();
903 NSView *view; 908 NSView *view;
904 909
905 BLOCK_INPUT; 910 block_input ();
906 pool = [[NSAutoreleasePool alloc] init]; 911 pool = [[NSAutoreleasePool alloc] init];
907 912
908 view = FRAME_NS_VIEW (frame); 913 view = FRAME_NS_VIEW (frame);
@@ -929,7 +934,7 @@ ns_ring_bell (struct frame *f)
929 ns_unfocus (frame); 934 ns_unfocus (frame);
930 } 935 }
931 [pool release]; 936 [pool release];
932 UNBLOCK_INPUT; 937 unblock_input ();
933 } 938 }
934 else 939 else
935 { 940 {
@@ -970,13 +975,13 @@ ns_raise_frame (struct frame *f)
970{ 975{
971 NSView *view = FRAME_NS_VIEW (f); 976 NSView *view = FRAME_NS_VIEW (f);
972 check_ns (); 977 check_ns ();
973 BLOCK_INPUT; 978 block_input ();
974 FRAME_SAMPLE_VISIBILITY (f); 979 FRAME_SAMPLE_VISIBILITY (f);
975 if (FRAME_VISIBLE_P (f)) 980 if (FRAME_VISIBLE_P (f))
976 { 981 {
977 [[view window] makeKeyAndOrderFront: NSApp]; 982 [[view window] makeKeyAndOrderFront: NSApp];
978 } 983 }
979 UNBLOCK_INPUT; 984 unblock_input ();
980} 985}
981 986
982 987
@@ -988,9 +993,9 @@ ns_lower_frame (struct frame *f)
988{ 993{
989 NSView *view = FRAME_NS_VIEW (f); 994 NSView *view = FRAME_NS_VIEW (f);
990 check_ns (); 995 check_ns ();
991 BLOCK_INPUT; 996 block_input ();
992 [[view window] orderBack: NSApp]; 997 [[view window] orderBack: NSApp];
993 UNBLOCK_INPUT; 998 unblock_input ();
994} 999}
995 1000
996 1001
@@ -1126,7 +1131,7 @@ x_free_frame_resources (struct frame *f)
1126 1131
1127 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */ 1132 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */
1128 1133
1129 BLOCK_INPUT; 1134 block_input ();
1130 1135
1131 free_frame_menubar (f); 1136 free_frame_menubar (f);
1132 1137
@@ -1154,7 +1159,7 @@ x_free_frame_resources (struct frame *f)
1154 1159
1155 xfree (f->output_data.ns); 1160 xfree (f->output_data.ns);
1156 1161
1157 UNBLOCK_INPUT; 1162 unblock_input ();
1158} 1163}
1159 1164
1160void 1165void
@@ -1183,7 +1188,7 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1183 1188
1184 NSTRACE (x_set_offset); 1189 NSTRACE (x_set_offset);
1185 1190
1186 BLOCK_INPUT; 1191 block_input ();
1187 1192
1188 f->left_pos = xoff; 1193 f->left_pos = xoff;
1189 f->top_pos = yoff; 1194 f->top_pos = yoff;
@@ -1215,7 +1220,7 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1215 f->size_hint_flags &= ~(XNegative|YNegative); 1220 f->size_hint_flags &= ~(XNegative|YNegative);
1216 } 1221 }
1217 1222
1218 UNBLOCK_INPUT; 1223 unblock_input ();
1219} 1224}
1220 1225
1221 1226
@@ -1240,7 +1245,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1240 1245
1241/*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */ 1246/*fprintf (stderr, "\tsetWindowSize: %d x %d, font size %d x %d\n", cols, rows, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f)); */
1242 1247
1243 BLOCK_INPUT; 1248 block_input ();
1244 1249
1245 check_frame_size (f, &rows, &cols); 1250 check_frame_size (f, &rows, &cols);
1246 1251
@@ -1302,10 +1307,21 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1302 mark_window_cursors_off (XWINDOW (f->root_window)); 1307 mark_window_cursors_off (XWINDOW (f->root_window));
1303 cancel_mouse_face (f); 1308 cancel_mouse_face (f);
1304 1309
1305 UNBLOCK_INPUT; 1310 unblock_input ();
1306} 1311}
1307 1312
1308 1313
1314static void
1315ns_fullscreen_hook (FRAME_PTR f)
1316{
1317 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1318
1319 if (! f->async_visible) return;
1320
1321 block_input ();
1322 [view handleFS];
1323 unblock_input ();
1324}
1309 1325
1310/* ========================================================================== 1326/* ==========================================================================
1311 1327
@@ -1414,7 +1430,7 @@ ns_get_color (const char *name, NSColor **col)
1414 NSString *nsname = [NSString stringWithUTF8String: name]; 1430 NSString *nsname = [NSString stringWithUTF8String: name];
1415 1431
1416/*fprintf (stderr, "ns_get_color: '%s'\n", name); */ 1432/*fprintf (stderr, "ns_get_color: '%s'\n", name); */
1417 BLOCK_INPUT; 1433 block_input ();
1418 1434
1419 if ([nsname isEqualToString: @"ns_selection_color"]) 1435 if ([nsname isEqualToString: @"ns_selection_color"])
1420 { 1436 {
@@ -1461,7 +1477,7 @@ ns_get_color (const char *name, NSColor **col)
1461 if (r >= 0.0) 1477 if (r >= 0.0)
1462 { 1478 {
1463 *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0]; 1479 *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0];
1464 UNBLOCK_INPUT; 1480 unblock_input ();
1465 return 0; 1481 return 0;
1466 } 1482 }
1467 1483
@@ -1493,7 +1509,7 @@ ns_get_color (const char *name, NSColor **col)
1493 1509
1494 if (new) 1510 if (new)
1495 *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; 1511 *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
1496 UNBLOCK_INPUT; 1512 unblock_input ();
1497 return new ? 0 : 1; 1513 return new ? 0 : 1;
1498} 1514}
1499 1515
@@ -1524,12 +1540,12 @@ ns_color_to_lisp (NSColor *col)
1524 const char *str; 1540 const char *str;
1525 NSTRACE (ns_color_to_lisp); 1541 NSTRACE (ns_color_to_lisp);
1526 1542
1527 BLOCK_INPUT; 1543 block_input ();
1528 if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace]) 1544 if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace])
1529 1545
1530 if ((str =[[col colorNameComponent] UTF8String])) 1546 if ((str =[[col colorNameComponent] UTF8String]))
1531 { 1547 {
1532 UNBLOCK_INPUT; 1548 unblock_input ();
1533 return build_string ((char *)str); 1549 return build_string ((char *)str);
1534 } 1550 }
1535 1551
@@ -1541,14 +1557,14 @@ ns_color_to_lisp (NSColor *col)
1541 getWhite: &gray alpha: &alpha]; 1557 getWhite: &gray alpha: &alpha];
1542 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", 1558 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
1543 lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff)); 1559 lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
1544 UNBLOCK_INPUT; 1560 unblock_input ();
1545 return build_string (buf); 1561 return build_string (buf);
1546 } 1562 }
1547 1563
1548 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", 1564 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
1549 lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); 1565 lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
1550 1566
1551 UNBLOCK_INPUT; 1567 unblock_input ();
1552 return build_string (buf); 1568 return build_string (buf);
1553} 1569}
1554 1570
@@ -1575,33 +1591,33 @@ ns_query_color(void *col, XColor *color_def, int setPixel)
1575} 1591}
1576 1592
1577 1593
1578int 1594bool
1579ns_defined_color (struct frame *f, 1595ns_defined_color (struct frame *f,
1580 const char *name, 1596 const char *name,
1581 XColor *color_def, 1597 XColor *color_def,
1582 int alloc, 1598 bool alloc,
1583 char makeIndex) 1599 bool makeIndex)
1584/* -------------------------------------------------------------------------- 1600/* --------------------------------------------------------------------------
1585 Return 1 if named color found, and set color_def rgb accordingly. 1601 Return true if named color found, and set color_def rgb accordingly.
1586 If makeIndex and alloc are nonzero put the color in the color_table, 1602 If makeIndex and alloc are nonzero put the color in the color_table,
1587 and set color_def pixel to the resulting index. 1603 and set color_def pixel to the resulting index.
1588 If makeIndex is zero, set color_def pixel to ARGB. 1604 If makeIndex is zero, set color_def pixel to ARGB.
1589 Return 0 if not found 1605 Return false if not found
1590 -------------------------------------------------------------------------- */ 1606 -------------------------------------------------------------------------- */
1591{ 1607{
1592 NSColor *col; 1608 NSColor *col;
1593 NSTRACE (ns_defined_color); 1609 NSTRACE (ns_defined_color);
1594 1610
1595 BLOCK_INPUT; 1611 block_input ();
1596 if (ns_get_color (name, &col) != 0) /* Color not found */ 1612 if (ns_get_color (name, &col) != 0) /* Color not found */
1597 { 1613 {
1598 UNBLOCK_INPUT; 1614 unblock_input ();
1599 return 0; 1615 return 0;
1600 } 1616 }
1601 if (makeIndex && alloc) 1617 if (makeIndex && alloc)
1602 color_def->pixel = ns_index_color (col, f); 1618 color_def->pixel = ns_index_color (col, f);
1603 ns_query_color (col, color_def, !makeIndex); 1619 ns_query_color (col, color_def, !makeIndex);
1604 UNBLOCK_INPUT; 1620 unblock_input ();
1605 return 1; 1621 return 1;
1606} 1622}
1607 1623
@@ -1767,7 +1783,7 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
1767 1783
1768 dpyinfo = FRAME_NS_DISPLAY_INFO (*fp); 1784 dpyinfo = FRAME_NS_DISPLAY_INFO (*fp);
1769 1785
1770 BLOCK_INPUT; 1786 block_input ();
1771 1787
1772 if (last_mouse_scroll_bar != nil && insist == 0) 1788 if (last_mouse_scroll_bar != nil && insist == 0)
1773 { 1789 {
@@ -1812,7 +1828,7 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
1812 } 1828 }
1813 } 1829 }
1814 1830
1815 UNBLOCK_INPUT; 1831 unblock_input ();
1816} 1832}
1817 1833
1818 1834
@@ -1832,7 +1848,7 @@ ns_frame_up_to_date (struct frame *f)
1832 if ((hlinfo->mouse_face_deferred_gc || f ==hlinfo->mouse_face_mouse_frame) 1848 if ((hlinfo->mouse_face_deferred_gc || f ==hlinfo->mouse_face_mouse_frame)
1833 /*&& hlinfo->mouse_face_mouse_frame*/) 1849 /*&& hlinfo->mouse_face_mouse_frame*/)
1834 { 1850 {
1835 BLOCK_INPUT; 1851 block_input ();
1836 ns_update_begin(f); 1852 ns_update_begin(f);
1837 if (hlinfo->mouse_face_mouse_frame) 1853 if (hlinfo->mouse_face_mouse_frame)
1838 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, 1854 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
@@ -1840,7 +1856,7 @@ ns_frame_up_to_date (struct frame *f)
1840 hlinfo->mouse_face_mouse_y); 1856 hlinfo->mouse_face_mouse_y);
1841 hlinfo->mouse_face_deferred_gc = 0; 1857 hlinfo->mouse_face_deferred_gc = 0;
1842 ns_update_end(f); 1858 ns_update_end(f);
1843 UNBLOCK_INPUT; 1859 unblock_input ();
1844 } 1860 }
1845 } 1861 }
1846} 1862}
@@ -1955,7 +1971,7 @@ ns_clear_frame (struct frame *f)
1955 1971
1956 r = [view bounds]; 1972 r = [view bounds];
1957 1973
1958 BLOCK_INPUT; 1974 block_input ();
1959 ns_focus (f, &r, 1); 1975 ns_focus (f, &r, 1);
1960 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (FRAME_DEFAULT_FACE (f)), f) set]; 1976 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (FRAME_DEFAULT_FACE (f)), f) set];
1961 NSRectFill (r); 1977 NSRectFill (r);
@@ -1967,7 +1983,7 @@ ns_clear_frame (struct frame *f)
1967 1983
1968 /* as of 2006/11 or so this is now needed */ 1984 /* as of 2006/11 or so this is now needed */
1969 ns_redraw_scroll_bars (f); 1985 ns_redraw_scroll_bars (f);
1970 UNBLOCK_INPUT; 1986 unblock_input ();
1971} 1987}
1972 1988
1973 1989
@@ -2068,7 +2084,7 @@ ns_scroll_run (struct window *w, struct run *run)
2068 if (height == 0) 2084 if (height == 0)
2069 return; 2085 return;
2070 2086
2071 BLOCK_INPUT; 2087 block_input ();
2072 2088
2073 updated_window = w; 2089 updated_window = w;
2074 x_clear_cursor (w); 2090 x_clear_cursor (w);
@@ -2083,7 +2099,7 @@ ns_scroll_run (struct window *w, struct run *run)
2083 ns_unfocus (f); 2099 ns_unfocus (f);
2084 } 2100 }
2085 2101
2086 UNBLOCK_INPUT; 2102 unblock_input ();
2087} 2103}
2088 2104
2089 2105
@@ -2117,12 +2133,12 @@ ns_after_update_window_line (struct glyph_row *desired_row)
2117 { 2133 {
2118 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 2134 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
2119 2135
2120 BLOCK_INPUT; 2136 block_input ();
2121 ns_clear_frame_area (f, 0, y, width, height); 2137 ns_clear_frame_area (f, 0, y, width, height);
2122 ns_clear_frame_area (f, 2138 ns_clear_frame_area (f,
2123 FRAME_PIXEL_WIDTH (f) - width, 2139 FRAME_PIXEL_WIDTH (f) - width,
2124 y, width, height); 2140 y, width, height);
2125 UNBLOCK_INPUT; 2141 unblock_input ();
2126 } 2142 }
2127} 2143}
2128 2144
@@ -2489,12 +2505,12 @@ show_hourglass (struct atimer *timer)
2489 if (hourglass_shown_p) 2505 if (hourglass_shown_p)
2490 return; 2506 return;
2491 2507
2492 BLOCK_INPUT; 2508 block_input ();
2493 2509
2494 /* TODO: add NSProgressIndicator to selected frame (see macfns.c) */ 2510 /* TODO: add NSProgressIndicator to selected frame (see macfns.c) */
2495 2511
2496 hourglass_shown_p = 1; 2512 hourglass_shown_p = 1;
2497 UNBLOCK_INPUT; 2513 unblock_input ();
2498} 2514}
2499 2515
2500 2516
@@ -2504,12 +2520,12 @@ hide_hourglass (void)
2504 if (!hourglass_shown_p) 2520 if (!hourglass_shown_p)
2505 return; 2521 return;
2506 2522
2507 BLOCK_INPUT; 2523 block_input ();
2508 2524
2509 /* TODO: remove NSProgressIndicator from all frames */ 2525 /* TODO: remove NSProgressIndicator from all frames */
2510 2526
2511 hourglass_shown_p = 0; 2527 hourglass_shown_p = 0;
2512 UNBLOCK_INPUT; 2528 unblock_input ();
2513} 2529}
2514 2530
2515 2531
@@ -2979,7 +2995,8 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2979 if (img != nil) 2995 if (img != nil)
2980 { 2996 {
2981#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 2997#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
2982 [img drawInRect: br 2998 NSRect dr = NSMakeRect (x, y, s->slice.width, s->slice.height);
2999 [img drawInRect: dr
2983 fromRect: NSZeroRect 3000 fromRect: NSZeroRect
2984 operation: NSCompositeSourceOver 3001 operation: NSCompositeSourceOver
2985 fraction: 1.0 3002 fraction: 1.0
@@ -3351,17 +3368,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
3351 if ([NSApp modalWindow] != nil) 3368 if ([NSApp modalWindow] != nil)
3352 return -1; 3369 return -1;
3353 3370
3354 if (interrupt_input_blocked) 3371 block_input ();
3355 {
3356 interrupt_input_pending = 1;
3357 pending_signals = 1;
3358 return -1;
3359 }
3360
3361 interrupt_input_pending = 0;
3362 pending_signals = pending_atimers;
3363
3364 BLOCK_INPUT;
3365 n_emacs_events_pending = 0; 3372 n_emacs_events_pending = 0;
3366 EVENT_INIT (ev); 3373 EVENT_INIT (ev);
3367 emacs_event = &ev; 3374 emacs_event = &ev;
@@ -3406,7 +3413,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
3406 nevents = n_emacs_events_pending; 3413 nevents = n_emacs_events_pending;
3407 n_emacs_events_pending = 0; 3414 n_emacs_events_pending = 0;
3408 emacs_event = q_event_ptr = NULL; 3415 emacs_event = q_event_ptr = NULL;
3409 UNBLOCK_INPUT; 3416 unblock_input ();
3410 3417
3411 return nevents; 3418 return nevents;
3412} 3419}
@@ -3486,7 +3493,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3486 } 3493 }
3487 3494
3488 EVENT_INIT (event); 3495 EVENT_INIT (event);
3489 BLOCK_INPUT; 3496 block_input ();
3490 emacs_event = &event; 3497 emacs_event = &event;
3491 if (++apploopnr != 1) 3498 if (++apploopnr != 1)
3492 { 3499 {
@@ -3500,7 +3507,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3500 c = 's'; 3507 c = 's';
3501 write (selfds[1], &c, 1); 3508 write (selfds[1], &c, 1);
3502 } 3509 }
3503 UNBLOCK_INPUT; 3510 unblock_input ();
3504 3511
3505 ev = last_appdefined_event; 3512 ev = last_appdefined_event;
3506 3513
@@ -3612,7 +3619,7 @@ ns_set_vertical_scroll_bar (struct window *window,
3612 || WINDOW_RIGHT_MARGIN_COLS (window) == 0)); 3619 || WINDOW_RIGHT_MARGIN_COLS (window) == 0));
3613 3620
3614 XSETWINDOW (win, window); 3621 XSETWINDOW (win, window);
3615 BLOCK_INPUT; 3622 block_input ();
3616 3623
3617 /* we want at least 5 lines to display a scrollbar */ 3624 /* we want at least 5 lines to display a scrollbar */
3618 if (WINDOW_TOTAL_LINES (window) < 5) 3625 if (WINDOW_TOTAL_LINES (window) < 5)
@@ -3624,7 +3631,7 @@ ns_set_vertical_scroll_bar (struct window *window,
3624 wset_vertical_scroll_bar (window, Qnil); 3631 wset_vertical_scroll_bar (window, Qnil);
3625 } 3632 }
3626 ns_clear_frame_area (f, sb_left, top, width, height); 3633 ns_clear_frame_area (f, sb_left, top, width, height);
3627 UNBLOCK_INPUT; 3634 unblock_input ();
3628 return; 3635 return;
3629 } 3636 }
3630 3637
@@ -3656,7 +3663,7 @@ ns_set_vertical_scroll_bar (struct window *window,
3656 } 3663 }
3657 3664
3658 [bar setPosition: position portion: portion whole: whole]; 3665 [bar setPosition: position portion: portion whole: whole];
3659 UNBLOCK_INPUT; 3666 unblock_input ();
3660} 3667}
3661 3668
3662 3669
@@ -3900,11 +3907,11 @@ ns_delete_terminal (struct terminal *terminal)
3900 if (!terminal->name) 3907 if (!terminal->name)
3901 return; 3908 return;
3902 3909
3903 BLOCK_INPUT; 3910 block_input ();
3904 3911
3905 x_destroy_all_bitmaps (dpyinfo); 3912 x_destroy_all_bitmaps (dpyinfo);
3906 ns_delete_display (dpyinfo); 3913 ns_delete_display (dpyinfo);
3907 UNBLOCK_INPUT; 3914 unblock_input ();
3908} 3915}
3909 3916
3910 3917
@@ -3941,7 +3948,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
3941 terminal->frame_rehighlight_hook = ns_frame_rehighlight; 3948 terminal->frame_rehighlight_hook = ns_frame_rehighlight;
3942 terminal->frame_raise_lower_hook = ns_frame_raise_lower; 3949 terminal->frame_raise_lower_hook = ns_frame_raise_lower;
3943 3950
3944 terminal->fullscreen_hook = 0; /* see XTfullscreen_hook */ 3951 terminal->fullscreen_hook = ns_fullscreen_hook;
3945 3952
3946 terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar; 3953 terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar;
3947 terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars; 3954 terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars;
@@ -3982,7 +3989,7 @@ ns_term_init (Lisp_Object display_name)
3982 3989
3983 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */ 3990 /* count object allocs (About, click icon); on OS X use ObjectAlloc tool */
3984 /*GSDebugAllocationActive (YES); */ 3991 /*GSDebugAllocationActive (YES); */
3985 BLOCK_INPUT; 3992 block_input ();
3986 3993
3987 baud_rate = 38400; 3994 baud_rate = 38400;
3988 Fset_input_interrupt_mode (Qnil); 3995 Fset_input_interrupt_mode (Qnil);
@@ -4051,7 +4058,7 @@ ns_term_init (Lisp_Object display_name)
4051 4058
4052 terminal->name = xstrdup (SSDATA (display_name)); 4059 terminal->name = xstrdup (SSDATA (display_name));
4053 4060
4054 UNBLOCK_INPUT; 4061 unblock_input ();
4055 4062
4056 if (!inhibit_x_resources) 4063 if (!inhibit_x_resources)
4057 { 4064 {
@@ -4696,6 +4703,8 @@ not_in_argv (NSString *arg)
4696{ 4703{
4697 NSTRACE (EmacsView_dealloc); 4704 NSTRACE (EmacsView_dealloc);
4698 [toolbar release]; 4705 [toolbar release];
4706 if (fs_state == FULLSCREEN_BOTH)
4707 [nonfs_window release];
4699 [super dealloc]; 4708 [super dealloc];
4700} 4709}
4701 4710
@@ -5414,6 +5423,7 @@ not_in_argv (NSString *arg)
5414 SET_FRAME_GARBAGED (emacsframe); 5423 SET_FRAME_GARBAGED (emacsframe);
5415 cancel_mouse_face (emacsframe); 5424 cancel_mouse_face (emacsframe);
5416 [view setFrame: NSMakeRect (0, 0, neww, newh)]; 5425 [view setFrame: NSMakeRect (0, 0, neww, newh)];
5426 [self windowDidMove:nil]; // Update top/left.
5417 } 5427 }
5418} 5428}
5419 5429
@@ -5423,6 +5433,19 @@ not_in_argv (NSString *arg)
5423 NSTRACE (windowWillResize); 5433 NSTRACE (windowWillResize);
5424/*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ 5434/*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */
5425 5435
5436 if (fs_state == FULLSCREEN_MAXIMIZED
5437 && (maximized_width != (int)frameSize.width
5438 || maximized_height != (int)frameSize.height))
5439 [self setFSValue: FULLSCREEN_NONE];
5440 else if (fs_state == FULLSCREEN_WIDTH
5441 && maximized_width != (int)frameSize.width)
5442 [self setFSValue: FULLSCREEN_NONE];
5443 else if (fs_state == FULLSCREEN_HEIGHT
5444 && maximized_height != (int)frameSize.height)
5445 [self setFSValue: FULLSCREEN_NONE];
5446 if (fs_state == FULLSCREEN_NONE)
5447 maximized_width = maximized_height = -1;
5448
5426 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, 5449 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe,
5427#ifdef NS_IMPL_GNUSTEP 5450#ifdef NS_IMPL_GNUSTEP
5428 frameSize.width + 3); 5451 frameSize.width + 3);
@@ -5604,6 +5627,10 @@ not_in_argv (NSString *arg)
5604 windowClosing = NO; 5627 windowClosing = NO;
5605 processingCompose = NO; 5628 processingCompose = NO;
5606 scrollbarsNeedingUpdate = 0; 5629 scrollbarsNeedingUpdate = 0;
5630 fs_state = FULLSCREEN_NONE;
5631 fs_before_fs = next_maximized = -1;
5632 maximized_width = maximized_height = -1;
5633 nonfs_window = nil;
5607 5634
5608/*fprintf (stderr,"init with %d, %d\n",f->text_cols, f->text_lines); */ 5635/*fprintf (stderr,"init with %d, %d\n",f->text_cols, f->text_lines); */
5609 5636
@@ -5628,9 +5655,13 @@ not_in_argv (NSString *arg)
5628 backing: NSBackingStoreBuffered 5655 backing: NSBackingStoreBuffered
5629 defer: YES]; 5656 defer: YES];
5630 5657
5658#ifdef NEW_STYLE_FS
5659 [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
5660#endif
5661
5631 wr = [win frame]; 5662 wr = [win frame];
5632 f->border_width = wr.size.width - r.size.width; 5663 bwidth = f->border_width = wr.size.width - r.size.width;
5633 FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height; 5664 tbar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height;
5634 5665
5635 [win setAcceptsMouseMovedEvents: YES]; 5666 [win setAcceptsMouseMovedEvents: YES];
5636 [win setDelegate: self]; 5667 [win setDelegate: self];
@@ -5736,27 +5767,50 @@ not_in_argv (NSString *arg)
5736 5767
5737 NSTRACE (windowWillUseStandardFrame); 5768 NSTRACE (windowWillUseStandardFrame);
5738 5769
5739 if (abs (defaultFrame.size.height - result.size.height) 5770 if (fs_before_fs != -1) /* Entering fullscreen */
5740 > FRAME_LINE_HEIGHT (emacsframe)) 5771 {
5772 result = defaultFrame;
5773 }
5774 else if (next_maximized == FULLSCREEN_HEIGHT
5775 || (next_maximized == -1
5776 && abs (defaultFrame.size.height - result.size.height)
5777 > FRAME_LINE_HEIGHT (emacsframe)))
5741 { 5778 {
5742 /* first click */ 5779 /* first click */
5743 ns_userRect = result; 5780 ns_userRect = result;
5744 result.size.height = defaultFrame.size.height; 5781 maximized_height = result.size.height = defaultFrame.size.height;
5782 maximized_width = -1;
5745 result.origin.y = defaultFrame.origin.y; 5783 result.origin.y = defaultFrame.origin.y;
5784 [self setFSValue: FULLSCREEN_HEIGHT];
5785 }
5786 else if (next_maximized == FULLSCREEN_WIDTH)
5787 {
5788 ns_userRect = result;
5789 maximized_width = result.size.width = defaultFrame.size.width;
5790 maximized_height = -1;
5791 result.origin.x = defaultFrame.origin.x;
5792 [self setFSValue: FULLSCREEN_WIDTH];
5793 }
5794 else if (next_maximized == FULLSCREEN_MAXIMIZED
5795 || (next_maximized == -1
5796 && abs (defaultFrame.size.width - result.size.width)
5797 > FRAME_COLUMN_WIDTH (emacsframe)))
5798 {
5799 result = defaultFrame; /* second click */
5800 maximized_width = result.size.width;
5801 maximized_height = result.size.height;
5802 [self setFSValue: FULLSCREEN_MAXIMIZED];
5746 } 5803 }
5747 else 5804 else
5748 { 5805 {
5749 if (abs (defaultFrame.size.width - result.size.width) 5806 /* restore */
5750 > FRAME_COLUMN_WIDTH (emacsframe)) 5807 result = ns_userRect.size.height ? ns_userRect : result;
5751 result = defaultFrame; /* second click */ 5808 ns_userRect = NSMakeRect (0, 0, 0, 0);
5752 else 5809 [self setFSValue: FULLSCREEN_NONE];
5753 { 5810 maximized_width = maximized_width = -1;
5754 /* restore */
5755 result = ns_userRect.size.height ? ns_userRect : result;
5756 ns_userRect = NSMakeRect (0, 0, 0, 0);
5757 }
5758 } 5811 }
5759 5812
5813 if (fs_before_fs == -1) next_maximized = -1;
5760 [self windowWillResize: sender toSize: result.size]; 5814 [self windowWillResize: sender toSize: result.size];
5761 return result; 5815 return result;
5762} 5816}
@@ -5808,6 +5862,200 @@ not_in_argv (NSString *arg)
5808 } 5862 }
5809} 5863}
5810 5864
5865- (void)windowWillEnterFullScreen:(NSNotification *)notification
5866{
5867 fs_before_fs = fs_state;
5868}
5869
5870- (void)windowDidEnterFullScreen:(NSNotification *)notification
5871{
5872 [self setFSValue: FULLSCREEN_BOTH];
5873#ifndef NEW_STYLE_FS
5874 fprintf(stderr, "%s %d\n", __func__, FRAME_PIXEL_WIDTH (emacsframe));
5875 [self windowDidBecomeKey:notification];
5876#endif
5877}
5878
5879- (void)windowWillExitFullScreen:(NSNotification *)notification
5880{
5881 if (next_maximized != -1)
5882 fs_before_fs = next_maximized;
5883}
5884
5885- (void)windowDidExitFullScreen:(NSNotification *)notification
5886{
5887 [self setFSValue: fs_before_fs];
5888 fs_before_fs = -1;
5889 if (next_maximized != -1)
5890 [[self window] performZoom:self];
5891}
5892
5893- (void)toggleFullScreen: (id)sender
5894{
5895 /* Bugs remain:
5896 1) Having fullscreen in initial/default frame alist.
5897 2) Fullscreen in default frame alist only applied to first frame.
5898 */
5899
5900#ifdef NEW_STYLE_FS
5901 [[self window] toggleFullScreen:sender];
5902#else
5903 NSWindow *w = [self window], *fw;
5904 BOOL onFirstScreen = [[w screen]
5905 isEqual:[[NSScreen screens] objectAtIndex:0]];
5906 struct frame *f = emacsframe;
5907 NSSize sz;
5908 NSRect r;
5909 NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
5910 (FRAME_DEFAULT_FACE (f)),
5911 f);
5912
5913 sz.width = FRAME_COLUMN_WIDTH (f);
5914 sz.height = FRAME_LINE_HEIGHT (f);
5915
5916 if (fs_state != FULLSCREEN_BOTH)
5917 {
5918 /* Hide dock and menubar if we are on the primary screen. */
5919 if (onFirstScreen)
5920 {
5921#if defined (NS_IMPL_COCOA) && \
5922 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
5923 NSApplicationPresentationOptions options
5924 = NSApplicationPresentationAutoHideDock
5925 | NSApplicationPresentationAutoHideMenuBar;
5926
5927 [NSApp setPresentationOptions: options];
5928#else
5929 [NSMenu setMenuBarVisible:NO];
5930#endif
5931 }
5932
5933 fw = [[EmacsFSWindow alloc]
5934 initWithContentRect:[w contentRectForFrameRect:[w frame]]
5935 styleMask:NSBorderlessWindowMask
5936 backing:NSBackingStoreBuffered
5937 defer:YES
5938 screen:[w screen]];
5939
5940 [fw setContentView:[w contentView]];
5941 [fw setTitle:[w title]];
5942 [fw makeKeyAndOrderFront:NSApp];
5943 [fw setDelegate:self];
5944 [fw makeFirstResponder:self];
5945 [fw setAcceptsMouseMovedEvents: YES];
5946 [fw useOptimizedDrawing: YES];
5947 [fw setResizeIncrements: sz];
5948 [fw setBackgroundColor: col];
5949 if ([col alphaComponent] != 1.0)
5950 [fw setOpaque: NO];
5951
5952 f->border_width = 0;
5953 FRAME_NS_TITLEBAR_HEIGHT (f) = 0;
5954
5955 nonfs_window = w;
5956 [self windowWillEnterFullScreen:nil];
5957 [w orderOut:self];
5958 r = [fw frameRectForContentRect:[[fw screen] frame]];
5959 [fw setFrame: r display:YES animate:YES];
5960 [self windowDidEnterFullScreen:nil];
5961 }
5962 else
5963 {
5964 fw = w;
5965 w = nonfs_window;
5966
5967 if (onFirstScreen)
5968 {
5969#if defined (NS_IMPL_COCOA) && \
5970 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
5971 [NSApp setPresentationOptions: NSApplicationPresentationDefault];
5972#else
5973 [NSMenu setMenuBarVisible:YES];
5974#endif
5975 }
5976
5977 [w setContentView:[fw contentView]];
5978 [w setResizeIncrements: sz];
5979 [w setBackgroundColor: col];
5980 if ([col alphaComponent] != 1.0)
5981 [w setOpaque: NO];
5982
5983 f->border_width = bwidth;
5984 FRAME_NS_TITLEBAR_HEIGHT (f) = tbar_height;
5985
5986 [self windowWillExitFullScreen:nil];
5987 [fw setFrame: [w frame] display:YES animate:YES];
5988 [fw close];
5989 [w makeKeyAndOrderFront:NSApp];
5990 [self windowDidExitFullScreen:nil];
5991 }
5992#endif
5993}
5994
5995- (void)handleFS
5996{
5997 if (fs_state != emacsframe->want_fullscreen)
5998 {
5999 if (fs_state == FULLSCREEN_BOTH)
6000 {
6001 [self toggleFullScreen:self];
6002 }
6003
6004 switch (emacsframe->want_fullscreen)
6005 {
6006 case FULLSCREEN_BOTH:
6007 [self toggleFullScreen:self];
6008 break;
6009 case FULLSCREEN_WIDTH:
6010 next_maximized = FULLSCREEN_WIDTH;
6011 if (fs_state != FULLSCREEN_BOTH)
6012 [[self window] performZoom:self];
6013 break;
6014 case FULLSCREEN_HEIGHT:
6015 next_maximized = FULLSCREEN_HEIGHT;
6016 if (fs_state != FULLSCREEN_BOTH)
6017 [[self window] performZoom:self];
6018 break;
6019 case FULLSCREEN_MAXIMIZED:
6020 next_maximized = FULLSCREEN_MAXIMIZED;
6021 if (fs_state != FULLSCREEN_BOTH)
6022 [[self window] performZoom:self];
6023 break;
6024 case FULLSCREEN_NONE:
6025 if (fs_state != FULLSCREEN_BOTH)
6026 {
6027 next_maximized = FULLSCREEN_NONE;
6028 [[self window] performZoom:self];
6029 }
6030 break;
6031 }
6032
6033 emacsframe->want_fullscreen = FULLSCREEN_NONE;
6034 }
6035
6036}
6037
6038- (void) setFSValue: (int)value
6039{
6040 Lisp_Object lval = Qnil;
6041 switch (value)
6042 {
6043 case FULLSCREEN_BOTH:
6044 lval = Qfullboth;
6045 break;
6046 case FULLSCREEN_WIDTH:
6047 lval = Qfullwidth;
6048 break;
6049 case FULLSCREEN_HEIGHT:
6050 lval = Qfullheight;
6051 break;
6052 case FULLSCREEN_MAXIMIZED:
6053 lval = Qmaximized;
6054 break;
6055 }
6056 store_frame_param (emacsframe, Qfullscreen, lval);
6057 fs_state = value;
6058}
5811 6059
5812- (void)mouseEntered: (NSEvent *)theEvent 6060- (void)mouseEntered: (NSEvent *)theEvent
5813{ 6061{
@@ -6299,6 +6547,15 @@ not_in_argv (NSString *arg)
6299@end /* EmacsWindow */ 6547@end /* EmacsWindow */
6300 6548
6301 6549
6550@implementation EmacsFSWindow
6551
6552- (BOOL)canBecomeKeyWindow
6553{
6554 return YES;
6555}
6556
6557@end
6558
6302/* ========================================================================== 6559/* ==========================================================================
6303 6560
6304 EmacsScroller implementation 6561 EmacsScroller implementation
@@ -6369,13 +6626,13 @@ not_in_argv (NSString *arg)
6369- (void)setFrame: (NSRect)newRect 6626- (void)setFrame: (NSRect)newRect
6370{ 6627{
6371 NSTRACE (EmacsScroller_setFrame); 6628 NSTRACE (EmacsScroller_setFrame);
6372/* BLOCK_INPUT; */ 6629/* block_input (); */
6373 pixel_height = NSHeight (newRect); 6630 pixel_height = NSHeight (newRect);
6374 if (pixel_height == 0) pixel_height = 1; 6631 if (pixel_height == 0) pixel_height = 1;
6375 min_portion = 20 / pixel_height; 6632 min_portion = 20 / pixel_height;
6376 [super setFrame: newRect]; 6633 [super setFrame: newRect];
6377 [self display]; 6634 [self display];
6378/* UNBLOCK_INPUT; */ 6635/* unblock_input (); */
6379} 6636}
6380 6637
6381 6638
@@ -6410,14 +6667,14 @@ not_in_argv (NSString *arg)
6410 if (condemned) 6667 if (condemned)
6411 { 6668 {
6412 EmacsView *view; 6669 EmacsView *view;
6413 BLOCK_INPUT; 6670 block_input ();
6414 /* ensure other scrollbar updates after deletion */ 6671 /* ensure other scrollbar updates after deletion */
6415 view = (EmacsView *)FRAME_NS_VIEW (frame); 6672 view = (EmacsView *)FRAME_NS_VIEW (frame);
6416 if (view != nil) 6673 if (view != nil)
6417 view->scrollbarsNeedingUpdate++; 6674 view->scrollbarsNeedingUpdate++;
6418 [self removeFromSuperview]; 6675 [self removeFromSuperview];
6419 [self release]; 6676 [self release];
6420 UNBLOCK_INPUT; 6677 unblock_input ();
6421 } 6678 }
6422 return self; 6679 return self;
6423} 6680}
diff --git a/src/print.c b/src/print.c
index aae13bb6764..49b491faec8 100644
--- a/src/print.c
+++ b/src/print.c
@@ -753,9 +753,9 @@ append to existing target file. */)
753{ 753{
754 if (initial_stderr_stream != NULL) 754 if (initial_stderr_stream != NULL)
755 { 755 {
756 BLOCK_INPUT; 756 block_input ();
757 fclose (stderr); 757 fclose (stderr);
758 UNBLOCK_INPUT; 758 unblock_input ();
759 } 759 }
760 stderr = initial_stderr_stream; 760 stderr = initial_stderr_stream;
761 initial_stderr_stream = NULL; 761 initial_stderr_stream = NULL;
diff --git a/src/process.c b/src/process.c
index c654369627d..ab215766c07 100644
--- a/src/process.c
+++ b/src/process.c
@@ -255,11 +255,12 @@ static int keyboard_bit_set (SELECT_TYPE *);
255static void deactivate_process (Lisp_Object); 255static void deactivate_process (Lisp_Object);
256static void status_notify (struct Lisp_Process *); 256static void status_notify (struct Lisp_Process *);
257static int read_process_output (Lisp_Object, int); 257static int read_process_output (Lisp_Object, int);
258static void handle_child_signal (int);
258static void create_pty (Lisp_Object); 259static void create_pty (Lisp_Object);
259 260
260/* If we support a window system, turn on the code to poll periodically 261/* If we support a window system, turn on the code to poll periodically
261 to detect C-g. It isn't actually used when doing interrupt input. */ 262 to detect C-g. It isn't actually used when doing interrupt input. */
262#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 263#ifdef HAVE_WINDOW_SYSTEM
263#define POLL_FOR_INPUT 264#define POLL_FOR_INPUT
264#endif 265#endif
265 266
@@ -1610,11 +1611,16 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1610 int wait_child_setup[2]; 1611 int wait_child_setup[2];
1611#endif 1612#endif
1612#ifdef SIGCHLD 1613#ifdef SIGCHLD
1613 sigset_t blocked, procmask; 1614 sigset_t blocked;
1614#endif 1615#endif
1615 /* Use volatile to protect variables from being clobbered by vfork. */ 1616 /* Use volatile to protect variables from being clobbered by vfork. */
1616 volatile int forkin, forkout; 1617 volatile int forkin, forkout;
1617 volatile int pty_flag = 0; 1618 volatile int pty_flag = 0;
1619 volatile Lisp_Object lisp_pty_name = Qnil;
1620 volatile Lisp_Object encoded_current_dir;
1621#if HAVE_WORKING_VFORK
1622 char **volatile save_environ;
1623#endif
1618 1624
1619 inchannel = outchannel = -1; 1625 inchannel = outchannel = -1;
1620 1626
@@ -1640,6 +1646,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1640 forkin = forkout = -1; 1646 forkin = forkout = -1;
1641#endif /* not USG, or USG_SUBTTY_WORKS */ 1647#endif /* not USG, or USG_SUBTTY_WORKS */
1642 pty_flag = 1; 1648 pty_flag = 1;
1649 lisp_pty_name = build_string (pty_name);
1643 } 1650 }
1644 else 1651 else
1645#endif /* HAVE_PTYS */ 1652#endif /* HAVE_PTYS */
@@ -1704,14 +1711,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1704 XPROCESS (process)->pty_flag = pty_flag; 1711 XPROCESS (process)->pty_flag = pty_flag;
1705 pset_status (XPROCESS (process), Qrun); 1712 pset_status (XPROCESS (process), Qrun);
1706 1713
1707#ifdef SIGCHLD
1708 /* Delay interrupts until we have a chance to store
1709 the new fork's pid in its process structure */
1710 sigemptyset (&blocked);
1711 sigaddset (&blocked, SIGCHLD);
1712 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
1713#endif
1714
1715 FD_SET (inchannel, &input_wait_mask); 1714 FD_SET (inchannel, &input_wait_mask);
1716 FD_SET (inchannel, &non_keyboard_wait_mask); 1715 FD_SET (inchannel, &non_keyboard_wait_mask);
1717 if (inchannel > max_process_desc) 1716 if (inchannel > max_process_desc)
@@ -1729,89 +1728,99 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1729 error. */ 1728 error. */
1730 setup_process_coding_systems (process); 1729 setup_process_coding_systems (process);
1731 1730
1732 BLOCK_INPUT; 1731 encoded_current_dir = ENCODE_FILE (current_dir);
1733 1732
1734 { 1733 block_input ();
1735 /* child_setup must clobber environ on systems with true vfork. 1734
1736 Protect it from permanent change. */ 1735#ifdef SIGCHLD
1737 char **save_environ = environ; 1736 /* Block SIGCHLD until we have a chance to store the new fork's
1738 volatile Lisp_Object encoded_current_dir = ENCODE_FILE (current_dir); 1737 pid in its process structure. */
1738 sigemptyset (&blocked);
1739 sigaddset (&blocked, SIGCHLD);
1740 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1741#endif
1742
1743#if HAVE_WORKING_VFORK
1744 /* child_setup must clobber environ on systems with true vfork.
1745 Protect it from permanent change. */
1746 save_environ = environ;
1747#endif
1739 1748
1740#ifndef WINDOWSNT 1749#ifndef WINDOWSNT
1741 pid = vfork (); 1750 pid = vfork ();
1742 if (pid == 0) 1751 if (pid == 0)
1743#endif /* not WINDOWSNT */ 1752#endif /* not WINDOWSNT */
1744 { 1753 {
1745 int xforkin = forkin; 1754 int xforkin = forkin;
1746 int xforkout = forkout; 1755 int xforkout = forkout;
1747 1756
1748 /* Make the pty be the controlling terminal of the process. */ 1757 /* Make the pty be the controlling terminal of the process. */
1749#ifdef HAVE_PTYS 1758#ifdef HAVE_PTYS
1750 /* First, disconnect its current controlling terminal. */ 1759 /* First, disconnect its current controlling terminal. */
1751#ifdef HAVE_SETSID 1760#ifdef HAVE_SETSID
1752 /* We tried doing setsid only if pty_flag, but it caused 1761 /* We tried doing setsid only if pty_flag, but it caused
1753 process_set_signal to fail on SGI when using a pipe. */ 1762 process_set_signal to fail on SGI when using a pipe. */
1754 setsid (); 1763 setsid ();
1755 /* Make the pty's terminal the controlling terminal. */ 1764 /* Make the pty's terminal the controlling terminal. */
1756 if (pty_flag && xforkin >= 0) 1765 if (pty_flag && xforkin >= 0)
1757 { 1766 {
1758#ifdef TIOCSCTTY 1767#ifdef TIOCSCTTY
1759 /* We ignore the return value 1768 /* We ignore the return value
1760 because faith@cs.unc.edu says that is necessary on Linux. */ 1769 because faith@cs.unc.edu says that is necessary on Linux. */
1761 ioctl (xforkin, TIOCSCTTY, 0); 1770 ioctl (xforkin, TIOCSCTTY, 0);
1762#endif 1771#endif
1763 } 1772 }
1764#else /* not HAVE_SETSID */ 1773#else /* not HAVE_SETSID */
1765#ifdef USG 1774#ifdef USG
1766 /* It's very important to call setpgrp here and no time 1775 /* It's very important to call setpgrp here and no time
1767 afterwards. Otherwise, we lose our controlling tty which 1776 afterwards. Otherwise, we lose our controlling tty which
1768 is set when we open the pty. */ 1777 is set when we open the pty. */
1769 setpgrp (); 1778 setpgrp ();
1770#endif /* USG */ 1779#endif /* USG */
1771#endif /* not HAVE_SETSID */ 1780#endif /* not HAVE_SETSID */
1772#if defined (LDISC1) 1781#if defined (LDISC1)
1773 if (pty_flag && xforkin >= 0) 1782 if (pty_flag && xforkin >= 0)
1774 { 1783 {
1775 struct termios t; 1784 struct termios t;
1776 tcgetattr (xforkin, &t); 1785 tcgetattr (xforkin, &t);
1777 t.c_lflag = LDISC1; 1786 t.c_lflag = LDISC1;
1778 if (tcsetattr (xforkin, TCSANOW, &t) < 0) 1787 if (tcsetattr (xforkin, TCSANOW, &t) < 0)
1779 emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39); 1788 emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39);
1780 } 1789 }
1781#else 1790#else
1782#if defined (NTTYDISC) && defined (TIOCSETD) 1791#if defined (NTTYDISC) && defined (TIOCSETD)
1783 if (pty_flag && xforkin >= 0) 1792 if (pty_flag && xforkin >= 0)
1784 { 1793 {
1785 /* Use new line discipline. */ 1794 /* Use new line discipline. */
1786 int ldisc = NTTYDISC; 1795 int ldisc = NTTYDISC;
1787 ioctl (xforkin, TIOCSETD, &ldisc); 1796 ioctl (xforkin, TIOCSETD, &ldisc);
1788 } 1797 }
1789#endif 1798#endif
1790#endif 1799#endif
1791#ifdef TIOCNOTTY 1800#ifdef TIOCNOTTY
1792 /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you 1801 /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you
1793 can do TIOCSPGRP only to the process's controlling tty. */ 1802 can do TIOCSPGRP only to the process's controlling tty. */
1794 if (pty_flag) 1803 if (pty_flag)
1795 { 1804 {
1796 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? 1805 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here?
1797 I can't test it since I don't have 4.3. */ 1806 I can't test it since I don't have 4.3. */
1798 int j = emacs_open ("/dev/tty", O_RDWR, 0); 1807 int j = emacs_open ("/dev/tty", O_RDWR, 0);
1799 if (j >= 0) 1808 if (j >= 0)
1800 { 1809 {
1801 ioctl (j, TIOCNOTTY, 0); 1810 ioctl (j, TIOCNOTTY, 0);
1802 emacs_close (j); 1811 emacs_close (j);
1803 } 1812 }
1804#ifndef USG 1813#ifndef USG
1805 /* In order to get a controlling terminal on some versions 1814 /* In order to get a controlling terminal on some versions
1806 of BSD, it is necessary to put the process in pgrp 0 1815 of BSD, it is necessary to put the process in pgrp 0
1807 before it opens the terminal. */ 1816 before it opens the terminal. */
1808#ifdef HAVE_SETPGID 1817#ifdef HAVE_SETPGID
1809 setpgid (0, 0); 1818 setpgid (0, 0);
1810#else 1819#else
1811 setpgrp (0, 0); 1820 setpgrp (0, 0);
1812#endif 1821#endif
1813#endif 1822#endif
1814 } 1823 }
1815#endif /* TIOCNOTTY */ 1824#endif /* TIOCNOTTY */
1816 1825
1817#if !defined (DONT_REOPEN_PTY) 1826#if !defined (DONT_REOPEN_PTY)
@@ -1823,70 +1832,79 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1823 both HAVE_SETSID and TIOCSCTTY are defined. */ 1832 both HAVE_SETSID and TIOCSCTTY are defined. */
1824 /* Now close the pty (if we had it open) and reopen it. 1833 /* Now close the pty (if we had it open) and reopen it.
1825 This makes the pty the controlling terminal of the subprocess. */ 1834 This makes the pty the controlling terminal of the subprocess. */
1826 if (pty_flag) 1835 if (pty_flag)
1827 { 1836 {
1828 1837
1829 /* I wonder if emacs_close (emacs_open (pty_name, ...)) 1838 /* I wonder if emacs_close (emacs_open (pty_name, ...))
1830 would work? */ 1839 would work? */
1831 if (xforkin >= 0) 1840 if (xforkin >= 0)
1832 emacs_close (xforkin); 1841 emacs_close (xforkin);
1833 xforkout = xforkin = emacs_open (pty_name, O_RDWR, 0); 1842 xforkout = xforkin = emacs_open (pty_name, O_RDWR, 0);
1834 1843
1835 if (xforkin < 0) 1844 if (xforkin < 0)
1836 { 1845 {
1837 emacs_write (1, "Couldn't open the pty terminal ", 31); 1846 emacs_write (1, "Couldn't open the pty terminal ", 31);
1838 emacs_write (1, pty_name, strlen (pty_name)); 1847 emacs_write (1, pty_name, strlen (pty_name));
1839 emacs_write (1, "\n", 1); 1848 emacs_write (1, "\n", 1);
1840 _exit (1); 1849 _exit (1);
1841 } 1850 }
1842 1851
1843 } 1852 }
1844#endif /* not DONT_REOPEN_PTY */ 1853#endif /* not DONT_REOPEN_PTY */
1845 1854
1846#ifdef SETUP_SLAVE_PTY 1855#ifdef SETUP_SLAVE_PTY
1847 if (pty_flag) 1856 if (pty_flag)
1848 { 1857 {
1849 SETUP_SLAVE_PTY; 1858 SETUP_SLAVE_PTY;
1850 } 1859 }
1851#endif /* SETUP_SLAVE_PTY */ 1860#endif /* SETUP_SLAVE_PTY */
1852#ifdef AIX 1861#ifdef AIX
1853 /* On AIX, we've disabled SIGHUP above once we start a child on a pty. 1862 /* On AIX, we've disabled SIGHUP above once we start a child on a pty.
1854 Now reenable it in the child, so it will die when we want it to. */ 1863 Now reenable it in the child, so it will die when we want it to. */
1855 if (pty_flag) 1864 if (pty_flag)
1856 signal (SIGHUP, SIG_DFL); 1865 signal (SIGHUP, SIG_DFL);
1857#endif 1866#endif
1858#endif /* HAVE_PTYS */ 1867#endif /* HAVE_PTYS */
1859 1868
1860 signal (SIGINT, SIG_DFL); 1869 signal (SIGINT, SIG_DFL);
1861 signal (SIGQUIT, SIG_DFL); 1870 signal (SIGQUIT, SIG_DFL);
1862 /* GConf causes us to ignore SIGPIPE, make sure it is restored 1871
1863 in the child. */ 1872 /* Emacs ignores SIGPIPE, but the child should not. */
1864 signal (SIGPIPE, SIG_DFL); 1873 signal (SIGPIPE, SIG_DFL);
1865 1874
1866#ifdef SIGCHLD 1875#ifdef SIGCHLD
1867 /* Stop blocking signals in the child. */ 1876 /* Stop blocking signals in the child. */
1868 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1877 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
1869#endif 1878#endif
1870 1879
1871 if (pty_flag) 1880 if (pty_flag)
1872 child_setup_tty (xforkout); 1881 child_setup_tty (xforkout);
1873#ifdef WINDOWSNT 1882#ifdef WINDOWSNT
1874 pid = child_setup (xforkin, xforkout, xforkout, 1883 pid = child_setup (xforkin, xforkout, xforkout,
1875 new_argv, 1, encoded_current_dir); 1884 new_argv, 1, encoded_current_dir);
1876#else /* not WINDOWSNT */ 1885#else /* not WINDOWSNT */
1877#ifdef FD_CLOEXEC 1886#ifdef FD_CLOEXEC
1878 emacs_close (wait_child_setup[0]); 1887 emacs_close (wait_child_setup[0]);
1879#endif 1888#endif
1880 child_setup (xforkin, xforkout, xforkout, 1889 child_setup (xforkin, xforkout, xforkout,
1881 new_argv, 1, encoded_current_dir); 1890 new_argv, 1, encoded_current_dir);
1882#endif /* not WINDOWSNT */ 1891#endif /* not WINDOWSNT */
1883 } 1892 }
1884 environ = save_environ; 1893
1885 } 1894 /* Back in the parent process. */
1895
1896#if HAVE_WORKING_VFORK
1897 environ = save_environ;
1898#endif
1899
1900 XPROCESS (process)->pid = pid;
1886 1901
1887 UNBLOCK_INPUT; 1902 /* Stop blocking signals in the parent. */
1903#ifdef SIGCHLD
1904 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
1905#endif
1906 unblock_input ();
1888 1907
1889 /* This runs in the Emacs process. */
1890 if (pid < 0) 1908 if (pid < 0)
1891 { 1909 {
1892 if (forkin >= 0) 1910 if (forkin >= 0)
@@ -1897,7 +1915,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1897 else 1915 else
1898 { 1916 {
1899 /* vfork succeeded. */ 1917 /* vfork succeeded. */
1900 XPROCESS (process)->pid = pid;
1901 1918
1902#ifdef WINDOWSNT 1919#ifdef WINDOWSNT
1903 register_child (pid, inchannel); 1920 register_child (pid, inchannel);
@@ -1923,12 +1940,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1923 if (forkin != forkout && forkout >= 0) 1940 if (forkin != forkout && forkout >= 0)
1924 emacs_close (forkout); 1941 emacs_close (forkout);
1925 1942
1926#ifdef HAVE_PTYS 1943 pset_tty_name (XPROCESS (process), lisp_pty_name);
1927 if (pty_flag)
1928 pset_tty_name (XPROCESS (process), build_string (pty_name));
1929 else
1930#endif
1931 pset_tty_name (XPROCESS (process), Qnil);
1932 1944
1933#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1945#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1934 /* Wait for child_setup to complete in case that vfork is 1946 /* Wait for child_setup to complete in case that vfork is
@@ -1945,11 +1957,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1945#endif 1957#endif
1946 } 1958 }
1947 1959
1948#ifdef SIGCHLD
1949 /* Stop blocking signals in the parent. */
1950 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1951#endif
1952
1953 /* Now generate the error if vfork failed. */ 1960 /* Now generate the error if vfork failed. */
1954 if (pid < 0) 1961 if (pid < 0)
1955 report_file_error ("Doing vfork", Qnil); 1962 report_file_error ("Doing vfork", Qnil);
@@ -3402,9 +3409,9 @@ usage: (make-network-process &rest ARGS) */)
3402#ifdef HAVE_GETADDRINFO 3409#ifdef HAVE_GETADDRINFO
3403 if (res != &ai) 3410 if (res != &ai)
3404 { 3411 {
3405 BLOCK_INPUT; 3412 block_input ();
3406 freeaddrinfo (res); 3413 freeaddrinfo (res);
3407 UNBLOCK_INPUT; 3414 unblock_input ();
3408 } 3415 }
3409#endif 3416#endif
3410 3417
@@ -4372,7 +4379,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4372 Otherwise, do pending quit if requested. */ 4379 Otherwise, do pending quit if requested. */
4373 if (read_kbd >= 0) 4380 if (read_kbd >= 0)
4374 QUIT; 4381 QUIT;
4375 else 4382 else if (pending_signals)
4376 process_pending_signals (); 4383 process_pending_signals ();
4377 4384
4378 /* Exit now if the cell we're waiting for became non-nil. */ 4385 /* Exit now if the cell we're waiting for became non-nil. */
@@ -4739,21 +4746,6 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4739 check_write = 0; 4746 check_write = 0;
4740 } 4747 }
4741 4748
4742#if 0 /* When polling is used, interrupt_input is 0,
4743 so get_input_pending should read the input.
4744 So this should not be needed. */
4745 /* If we are using polling for input,
4746 and we see input available, make it get read now.
4747 Otherwise it might not actually get read for a second.
4748 And on hpux, since we turn off polling in wait_reading_process_output,
4749 it might never get read at all if we don't spend much time
4750 outside of wait_reading_process_output. */
4751 if (read_kbd && interrupt_input
4752 && keyboard_bit_set (&Available)
4753 && input_polling_used ())
4754 kill (getpid (), SIGALRM);
4755#endif
4756
4757 /* Check for keyboard input */ 4749 /* Check for keyboard input */
4758 /* If there is any, return immediately 4750 /* If there is any, return immediately
4759 to give it higher priority than subprocesses */ 4751 to give it higher priority than subprocesses */
@@ -4817,7 +4809,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4817 4809
4818 if (read_kbd && interrupt_input 4810 if (read_kbd && interrupt_input
4819 && keyboard_bit_set (&Available) && ! noninteractive) 4811 && keyboard_bit_set (&Available) && ! noninteractive)
4820 kill (getpid (), SIGIO); 4812 handle_input_available_signal (SIGIO);
4821#endif 4813#endif
4822 4814
4823 if (! wait_proc) 4815 if (! wait_proc)
@@ -4937,7 +4929,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4937 pset_status (p, Qfailed); 4929 pset_status (p, Qfailed);
4938 } 4930 }
4939 else 4931 else
4940 kill (getpid (), SIGCHLD); 4932 handle_child_signal (SIGCHLD);
4941 } 4933 }
4942#endif /* HAVE_PTYS */ 4934#endif /* HAVE_PTYS */
4943 /* If we can detect process termination, don't consider the 4935 /* If we can detect process termination, don't consider the
@@ -5393,25 +5385,6 @@ read_process_output (Lisp_Object proc, register int channel)
5393 5385
5394/* Sending data to subprocess */ 5386/* Sending data to subprocess */
5395 5387
5396static sys_jmp_buf send_process_frame;
5397static Lisp_Object process_sent_to;
5398
5399static _Noreturn void
5400handle_pipe_signal (int sig)
5401{
5402 sigset_t unblocked;
5403 sigemptyset (&unblocked);
5404 sigaddset (&unblocked, SIGPIPE);
5405 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
5406 sys_longjmp (send_process_frame, 1);
5407}
5408
5409static void
5410deliver_pipe_signal (int sig)
5411{
5412 handle_on_main_thread (sig, handle_pipe_signal);
5413}
5414
5415/* In send_process, when a write fails temporarily, 5388/* In send_process, when a write fails temporarily,
5416 wait_reading_process_output is called. It may execute user code, 5389 wait_reading_process_output is called. It may execute user code,
5417 e.g. timers, that attempts to write new data to the same process. 5390 e.g. timers, that attempts to write new data to the same process.
@@ -5495,14 +5468,12 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj,
5495 This function can evaluate Lisp code and can garbage collect. */ 5468 This function can evaluate Lisp code and can garbage collect. */
5496 5469
5497static void 5470static void
5498send_process (volatile Lisp_Object proc, const char *volatile buf, 5471send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5499 volatile ptrdiff_t len, volatile Lisp_Object object) 5472 Lisp_Object object)
5500{ 5473{
5501 /* Use volatile to protect variables from being clobbered by longjmp. */
5502 struct Lisp_Process *p = XPROCESS (proc); 5474 struct Lisp_Process *p = XPROCESS (proc);
5503 ssize_t rv; 5475 ssize_t rv;
5504 struct coding_system *coding; 5476 struct coding_system *coding;
5505 struct sigaction old_sigpipe_action;
5506 5477
5507 if (p->raw_status_new) 5478 if (p->raw_status_new)
5508 update_status (p); 5479 update_status (p);
@@ -5609,145 +5580,126 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5609 pty_max_bytes--; 5580 pty_max_bytes--;
5610 } 5581 }
5611 5582
5612 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5583 /* If there is already data in the write_queue, put the new data
5613 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5584 in the back of queue. Otherwise, ignore it. */
5614 when returning with longjmp despite being declared volatile. */ 5585 if (!NILP (p->write_queue))
5615 if (!sys_setjmp (send_process_frame)) 5586 write_queue_push (p, object, buf, len, 0);
5616 {
5617 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5618 process_sent_to = proc;
5619 5587
5620 /* If there is already data in the write_queue, put the new data 5588 do /* while !NILP (p->write_queue) */
5621 in the back of queue. Otherwise, ignore it. */ 5589 {
5622 if (!NILP (p->write_queue)) 5590 ptrdiff_t cur_len = -1;
5623 write_queue_push (p, object, buf, len, 0); 5591 const char *cur_buf;
5592 Lisp_Object cur_object;
5624 5593
5625 do /* while !NILP (p->write_queue) */ 5594 /* If write_queue is empty, ignore it. */
5595 if (!write_queue_pop (p, &cur_object, &cur_buf, &cur_len))
5626 { 5596 {
5627 ptrdiff_t cur_len = -1; 5597 cur_len = len;
5628 const char *cur_buf; 5598 cur_buf = buf;
5629 Lisp_Object cur_object; 5599 cur_object = object;
5600 }
5630 5601
5631 /* If write_queue is empty, ignore it. */ 5602 while (cur_len > 0)
5632 if (!write_queue_pop (p, &cur_object, &cur_buf, &cur_len)) 5603 {
5604 /* Send this batch, using one or more write calls. */
5605 ptrdiff_t written = 0;
5606 int outfd = p->outfd;
5607#ifdef DATAGRAM_SOCKETS
5608 if (DATAGRAM_CHAN_P (outfd))
5633 { 5609 {
5634 cur_len = len; 5610 rv = sendto (outfd, cur_buf, cur_len,
5635 cur_buf = buf; 5611 0, datagram_address[outfd].sa,
5636 cur_object = object; 5612 datagram_address[outfd].len);
5613 if (0 <= rv)
5614 written = rv;
5615 else if (errno == EMSGSIZE)
5616 report_file_error ("sending datagram", Fcons (proc, Qnil));
5637 } 5617 }
5638 5618 else
5639 while (cur_len > 0)
5640 {
5641 /* Send this batch, using one or more write calls. */
5642 ptrdiff_t written = 0;
5643 int outfd = p->outfd;
5644 struct sigaction action;
5645 emacs_sigaction_init (&action, deliver_pipe_signal);
5646 sigaction (SIGPIPE, &action, &old_sigpipe_action);
5647#ifdef DATAGRAM_SOCKETS
5648 if (DATAGRAM_CHAN_P (outfd))
5649 {
5650 rv = sendto (outfd, cur_buf, cur_len,
5651 0, datagram_address[outfd].sa,
5652 datagram_address[outfd].len);
5653 if (0 <= rv)
5654 written = rv;
5655 else if (errno == EMSGSIZE)
5656 {
5657 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5658 report_file_error ("sending datagram",
5659 Fcons (proc, Qnil));
5660 }
5661 }
5662 else
5663#endif 5619#endif
5664 { 5620 {
5665#ifdef HAVE_GNUTLS 5621#ifdef HAVE_GNUTLS
5666 if (p->gnutls_p) 5622 if (p->gnutls_p)
5667 written = emacs_gnutls_write (p, cur_buf, cur_len); 5623 written = emacs_gnutls_write (p, cur_buf, cur_len);
5668 else 5624 else
5669#endif 5625#endif
5670 written = emacs_write (outfd, cur_buf, cur_len); 5626 written = emacs_write (outfd, cur_buf, cur_len);
5671 rv = (written ? 0 : -1); 5627 rv = (written ? 0 : -1);
5672#ifdef ADAPTIVE_READ_BUFFERING 5628#ifdef ADAPTIVE_READ_BUFFERING
5673 if (p->read_output_delay > 0 5629 if (p->read_output_delay > 0
5674 && p->adaptive_read_buffering == 1) 5630 && p->adaptive_read_buffering == 1)
5675 { 5631 {
5676 p->read_output_delay = 0; 5632 p->read_output_delay = 0;
5677 process_output_delay_count--; 5633 process_output_delay_count--;
5678 p->read_output_skip = 0; 5634 p->read_output_skip = 0;
5679 }
5680#endif
5681 } 5635 }
5682 sigaction (SIGPIPE, &old_sigpipe_action, 0); 5636#endif
5637 }
5683 5638
5684 if (rv < 0) 5639 if (rv < 0)
5685 { 5640 {
5686 if (0 5641 if (0
5687#ifdef EWOULDBLOCK 5642#ifdef EWOULDBLOCK
5688 || errno == EWOULDBLOCK 5643 || errno == EWOULDBLOCK
5689#endif 5644#endif
5690#ifdef EAGAIN 5645#ifdef EAGAIN
5691 || errno == EAGAIN 5646 || errno == EAGAIN
5692#endif 5647#endif
5693 ) 5648 )
5694 /* Buffer is full. Wait, accepting input; 5649 /* Buffer is full. Wait, accepting input;
5695 that may allow the program 5650 that may allow the program
5696 to finish doing output and read more. */ 5651 to finish doing output and read more. */
5697 { 5652 {
5698#ifdef BROKEN_PTY_READ_AFTER_EAGAIN 5653#ifdef BROKEN_PTY_READ_AFTER_EAGAIN
5699 /* A gross hack to work around a bug in FreeBSD. 5654 /* A gross hack to work around a bug in FreeBSD.
5700 In the following sequence, read(2) returns 5655 In the following sequence, read(2) returns
5701 bogus data: 5656 bogus data:
5702 5657
5703 write(2) 1022 bytes 5658 write(2) 1022 bytes
5704 write(2) 954 bytes, get EAGAIN 5659 write(2) 954 bytes, get EAGAIN
5705 read(2) 1024 bytes in process_read_output 5660 read(2) 1024 bytes in process_read_output
5706 read(2) 11 bytes in process_read_output 5661 read(2) 11 bytes in process_read_output
5707 5662
5708 That is, read(2) returns more bytes than have 5663 That is, read(2) returns more bytes than have
5709 ever been written successfully. The 1033 bytes 5664 ever been written successfully. The 1033 bytes
5710 read are the 1022 bytes written successfully 5665 read are the 1022 bytes written successfully
5711 after processing (for example with CRs added if 5666 after processing (for example with CRs added if
5712 the terminal is set up that way which it is 5667 the terminal is set up that way which it is
5713 here). The same bytes will be seen again in a 5668 here). The same bytes will be seen again in a
5714 later read(2), without the CRs. */ 5669 later read(2), without the CRs. */
5715 5670
5716 if (errno == EAGAIN) 5671 if (errno == EAGAIN)
5717 { 5672 {
5718 int flags = FWRITE; 5673 int flags = FWRITE;
5719 ioctl (p->outfd, TIOCFLUSH, &flags); 5674 ioctl (p->outfd, TIOCFLUSH, &flags);
5720 } 5675 }
5721#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ 5676#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
5722 5677
5723 /* Put what we should have written in wait_queue. */ 5678 /* Put what we should have written in wait_queue. */
5724 write_queue_push (p, cur_object, cur_buf, cur_len, 1); 5679 write_queue_push (p, cur_object, cur_buf, cur_len, 1);
5725 wait_reading_process_output (0, 20 * 1000 * 1000, 5680 wait_reading_process_output (0, 20 * 1000 * 1000,
5726 0, 0, Qnil, NULL, 0); 5681 0, 0, Qnil, NULL, 0);
5727 /* Reread queue, to see what is left. */ 5682 /* Reread queue, to see what is left. */
5728 break; 5683 break;
5729 }
5730 else
5731 /* This is a real error. */
5732 report_file_error ("writing to process", Fcons (proc, Qnil));
5733 } 5684 }
5734 cur_buf += written; 5685 else if (errno == EPIPE)
5735 cur_len -= written; 5686 {
5687 p->raw_status_new = 0;
5688 pset_status (p, list2 (Qexit, make_number (256)));
5689 p->tick = ++process_tick;
5690 deactivate_process (proc);
5691 error ("process %s no longer connected to pipe; closed it",
5692 SDATA (p->name));
5693 }
5694 else
5695 /* This is a real error. */
5696 report_file_error ("writing to process", Fcons (proc, Qnil));
5736 } 5697 }
5698 cur_buf += written;
5699 cur_len -= written;
5737 } 5700 }
5738 while (!NILP (p->write_queue));
5739 }
5740 else
5741 {
5742 sigaction (SIGPIPE, &old_sigpipe_action, 0);
5743 proc = process_sent_to;
5744 p = XPROCESS (proc);
5745 p->raw_status_new = 0;
5746 pset_status (p, Fcons (Qexit, Fcons (make_number (256), Qnil)));
5747 p->tick = ++process_tick;
5748 deactivate_process (proc);
5749 error ("SIGPIPE raised on process %s; closed it", SDATA (p->name));
5750 } 5701 }
5702 while (!NILP (p->write_queue));
5751} 5703}
5752 5704
5753DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, 5705DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region,
@@ -6178,39 +6130,27 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6178#ifdef SIGUSR2 6130#ifdef SIGUSR2
6179 parse_signal ("usr2", SIGUSR2); 6131 parse_signal ("usr2", SIGUSR2);
6180#endif 6132#endif
6181#ifdef SIGTERM
6182 parse_signal ("term", SIGTERM); 6133 parse_signal ("term", SIGTERM);
6183#endif
6184#ifdef SIGHUP 6134#ifdef SIGHUP
6185 parse_signal ("hup", SIGHUP); 6135 parse_signal ("hup", SIGHUP);
6186#endif 6136#endif
6187#ifdef SIGINT
6188 parse_signal ("int", SIGINT); 6137 parse_signal ("int", SIGINT);
6189#endif
6190#ifdef SIGQUIT 6138#ifdef SIGQUIT
6191 parse_signal ("quit", SIGQUIT); 6139 parse_signal ("quit", SIGQUIT);
6192#endif 6140#endif
6193#ifdef SIGILL
6194 parse_signal ("ill", SIGILL); 6141 parse_signal ("ill", SIGILL);
6195#endif
6196#ifdef SIGABRT
6197 parse_signal ("abrt", SIGABRT); 6142 parse_signal ("abrt", SIGABRT);
6198#endif
6199#ifdef SIGEMT 6143#ifdef SIGEMT
6200 parse_signal ("emt", SIGEMT); 6144 parse_signal ("emt", SIGEMT);
6201#endif 6145#endif
6202#ifdef SIGKILL 6146#ifdef SIGKILL
6203 parse_signal ("kill", SIGKILL); 6147 parse_signal ("kill", SIGKILL);
6204#endif 6148#endif
6205#ifdef SIGFPE
6206 parse_signal ("fpe", SIGFPE); 6149 parse_signal ("fpe", SIGFPE);
6207#endif
6208#ifdef SIGBUS 6150#ifdef SIGBUS
6209 parse_signal ("bus", SIGBUS); 6151 parse_signal ("bus", SIGBUS);
6210#endif 6152#endif
6211#ifdef SIGSEGV
6212 parse_signal ("segv", SIGSEGV); 6153 parse_signal ("segv", SIGSEGV);
6213#endif
6214#ifdef SIGSYS 6154#ifdef SIGSYS
6215 parse_signal ("sys", SIGSYS); 6155 parse_signal ("sys", SIGSYS);
6216#endif 6156#endif
@@ -6375,27 +6315,15 @@ process has been transmitted to the serial port. */)
6375 ** Malloc WARNING: This should never call malloc either directly or 6315 ** Malloc WARNING: This should never call malloc either directly or
6376 indirectly; if it does, that is a bug */ 6316 indirectly; if it does, that is a bug */
6377 6317
6378#ifdef SIGCHLD 6318/* Record the changed status of the child process PID with wait status W. */
6379 6319void
6380/* Record one child's changed status. Return true if a child was found. */ 6320record_child_status_change (pid_t pid, int w)
6381static bool
6382record_child_status_change (void)
6383{ 6321{
6322#ifdef SIGCHLD
6384 Lisp_Object proc; 6323 Lisp_Object proc;
6385 struct Lisp_Process *p; 6324 struct Lisp_Process *p;
6386 pid_t pid;
6387 int w;
6388 Lisp_Object tail; 6325 Lisp_Object tail;
6389 6326
6390 do
6391 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6392 while (pid < 0 && errno == EINTR);
6393
6394 /* PID == 0 means no processes found, PID == -1 means a real failure.
6395 Either way, we have done all our job. */
6396 if (pid <= 0)
6397 return false;
6398
6399 /* Find the process that signaled us, and record its status. */ 6327 /* Find the process that signaled us, and record its status. */
6400 6328
6401 /* The process can have been deleted by Fdelete_process. */ 6329 /* The process can have been deleted by Fdelete_process. */
@@ -6406,7 +6334,7 @@ record_child_status_change (void)
6406 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid))) 6334 || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid)))
6407 { 6335 {
6408 XSETCAR (tail, Qnil); 6336 XSETCAR (tail, Qnil);
6409 return true; 6337 return;
6410 } 6338 }
6411 } 6339 }
6412 6340
@@ -6476,10 +6404,11 @@ record_child_status_change (void)
6476 if (input_available_clear_time) 6404 if (input_available_clear_time)
6477 *input_available_clear_time = make_emacs_time (0, 0); 6405 *input_available_clear_time = make_emacs_time (0, 0);
6478 } 6406 }
6479 6407#endif
6480 return true;
6481} 6408}
6482 6409
6410#ifdef SIGCHLD
6411
6483/* On some systems, the SIGCHLD handler must return right away. If 6412/* On some systems, the SIGCHLD handler must return right away. If
6484 any more processes want to signal us, we will get another signal. 6413 any more processes want to signal us, we will get another signal.
6485 Otherwise, loop around to use up all the processes that have 6414 Otherwise, loop around to use up all the processes that have
@@ -6495,14 +6424,29 @@ enum { CAN_HANDLE_MULTIPLE_CHILDREN = 1 };
6495static void 6424static void
6496handle_child_signal (int sig) 6425handle_child_signal (int sig)
6497{ 6426{
6498 while (record_child_status_change () && CAN_HANDLE_MULTIPLE_CHILDREN) 6427 do
6499 continue; 6428 {
6429 pid_t pid;
6430 int status;
6431
6432 do
6433 pid = waitpid (-1, &status, WNOHANG | WUNTRACED);
6434 while (pid < 0 && errno == EINTR);
6435
6436 /* PID == 0 means no processes found, PID == -1 means a real failure.
6437 Either way, we have done all our job. */
6438 if (pid <= 0)
6439 break;
6440
6441 record_child_status_change (pid, status);
6442 }
6443 while (CAN_HANDLE_MULTIPLE_CHILDREN);
6500} 6444}
6501 6445
6502static void 6446static void
6503deliver_child_signal (int sig) 6447deliver_child_signal (int sig)
6504{ 6448{
6505 handle_on_main_thread (sig, handle_child_signal); 6449 deliver_process_signal (sig, handle_child_signal);
6506} 6450}
6507 6451
6508#endif /* SIGCHLD */ 6452#endif /* SIGCHLD */
diff --git a/src/profiler.c b/src/profiler.c
new file mode 100644
index 00000000000..90a85c5230e
--- /dev/null
+++ b/src/profiler.c
@@ -0,0 +1,518 @@
1/* Profiler implementation.
2
3Copyright (C) 2012 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#include <config.h>
21#include "lisp.h"
22#include "syssignal.h"
23#include "systime.h"
24
25/* Return A + B, but return the maximum fixnum if the result would overflow.
26 Assume A and B are nonnegative and in fixnum range. */
27
28static EMACS_INT
29saturated_add (EMACS_INT a, EMACS_INT b)
30{
31 return min (a + b, MOST_POSITIVE_FIXNUM);
32}
33
34/* Logs. */
35
36typedef struct Lisp_Hash_Table log_t;
37
38static Lisp_Object
39make_log (int heap_size, int max_stack_depth)
40{
41 /* We use a standard Elisp hash-table object, but we use it in
42 a special way. This is OK as long as the object is not exposed
43 to Elisp, i.e. until it is returned by *-profiler-log, after which
44 it can't be used any more. */
45 Lisp_Object log = make_hash_table (Qequal, make_number (heap_size),
46 make_float (DEFAULT_REHASH_SIZE),
47 make_float (DEFAULT_REHASH_THRESHOLD),
48 Qnil, Qnil, Qnil);
49 struct Lisp_Hash_Table *h = XHASH_TABLE (log);
50
51 /* What is special about our hash-tables is that the keys are pre-filled
52 with the vectors we'll put in them. */
53 int i = ASIZE (h->key_and_value) / 2;
54 while (0 < i)
55 set_hash_key_slot (h, --i,
56 Fmake_vector (make_number (max_stack_depth), Qnil));
57 return log;
58}
59
60/* Evict the least used half of the hash_table.
61
62 When the table is full, we have to evict someone.
63 The easiest and most efficient is to evict the value we're about to add
64 (i.e. once the table is full, stop sampling).
65
66 We could also pick the element with the lowest count and evict it,
67 but finding it is O(N) and for that amount of work we get very
68 little in return: for the next sample, this latest sample will have
69 count==1 and will hence be a prime candidate for eviction :-(
70
71 So instead, we take O(N) time to eliminate more or less half of the
72 entries (the half with the lowest counts). So we get an amortized
73 cost of O(1) and we get O(N) time for a new entry to grow larger
74 than the other least counts before a new round of eviction. */
75
76static EMACS_INT approximate_median (log_t *log,
77 ptrdiff_t start, ptrdiff_t size)
78{
79 eassert (size > 0);
80 if (size < 2)
81 return XINT (HASH_VALUE (log, start));
82 if (size < 3)
83 /* Not an actual median, but better for our application than
84 choosing either of the two numbers. */
85 return ((XINT (HASH_VALUE (log, start))
86 + XINT (HASH_VALUE (log, start + 1)))
87 / 2);
88 else
89 {
90 ptrdiff_t newsize = size / 3;
91 ptrdiff_t start2 = start + newsize;
92 EMACS_INT i1 = approximate_median (log, start, newsize);
93 EMACS_INT i2 = approximate_median (log, start2, newsize);
94 EMACS_INT i3 = approximate_median (log, start2 + newsize,
95 size - 2 * newsize);
96 return (i1 < i2
97 ? (i2 < i3 ? i2 : (i1 < i3 ? i3 : i1))
98 : (i1 < i3 ? i1 : (i2 < i3 ? i3 : i2)));
99 }
100}
101
102static void evict_lower_half (log_t *log)
103{
104 ptrdiff_t size = ASIZE (log->key_and_value) / 2;
105 EMACS_INT median = approximate_median (log, 0, size);
106 ptrdiff_t i;
107
108 for (i = 0; i < size; i++)
109 /* Evict not only values smaller but also values equal to the median,
110 so as to make sure we evict something no matter what. */
111 if (XINT (HASH_VALUE (log, i)) <= median)
112 {
113 Lisp_Object key = HASH_KEY (log, i);
114 { /* FIXME: we could make this more efficient. */
115 Lisp_Object tmp;
116 XSET_HASH_TABLE (tmp, log); /* FIXME: Use make_lisp_ptr. */
117 Fremhash (key, tmp);
118 }
119 eassert (EQ (log->next_free, make_number (i)));
120 {
121 int j;
122 eassert (VECTORP (key));
123 for (j = 0; j < ASIZE (key); j++)
124 ASET (key, j, Qnil);
125 }
126 set_hash_key_slot (log, i, key);
127 }
128}
129
130/* Record the current backtrace in LOG. COUNT is the weight of this
131 current backtrace: milliseconds for CPU counts, and the allocation
132 size for memory logs. */
133
134static void
135record_backtrace (log_t *log, EMACS_INT count)
136{
137 struct backtrace *backlist = backtrace_list;
138 Lisp_Object backtrace;
139 ptrdiff_t index, i = 0;
140 ptrdiff_t asize;
141
142 if (!INTEGERP (log->next_free))
143 /* FIXME: transfer the evicted counts to a special entry rather
144 than dropping them on the floor. */
145 evict_lower_half (log);
146 index = XINT (log->next_free);
147
148 /* Get a "working memory" vector. */
149 backtrace = HASH_KEY (log, index);
150 asize = ASIZE (backtrace);
151
152 /* Copy the backtrace contents into working memory. */
153 for (; i < asize && backlist; i++, backlist = backlist->next)
154 /* FIXME: For closures we should ignore the environment. */
155 ASET (backtrace, i, backlist->function);
156
157 /* Make sure that unused space of working memory is filled with nil. */
158 for (; i < asize; i++)
159 ASET (backtrace, i, Qnil);
160
161 { /* We basically do a `gethash+puthash' here, except that we have to be
162 careful to avoid memory allocation since we're in a signal
163 handler, and we optimize the code to try and avoid computing the
164 hash+lookup twice. See fns.c:Fputhash for reference. */
165 EMACS_UINT hash;
166 ptrdiff_t j = hash_lookup (log, backtrace, &hash);
167 if (j >= 0)
168 {
169 EMACS_INT old_val = XINT (HASH_VALUE (log, j));
170 EMACS_INT new_val = saturated_add (old_val, count);
171 set_hash_value_slot (log, j, make_number (new_val));
172 }
173 else
174 { /* BEWARE! hash_put in general can allocate memory.
175 But currently it only does that if log->next_free is nil. */
176 int j;
177 eassert (!NILP (log->next_free));
178 j = hash_put (log, backtrace, make_number (count), hash);
179 /* Let's make sure we've put `backtrace' right where it
180 already was to start with. */
181 eassert (index == j);
182
183 /* FIXME: If the hash-table is almost full, we should set
184 some global flag so that some Elisp code can offload its
185 data elsewhere, so as to avoid the eviction code.
186 There are 2 ways to do that, AFAICT:
187 - Set a flag checked in QUIT, such that QUIT can then call
188 Fprofiler_cpu_log and stash the full log for later use.
189 - Set a flag check in post-gc-hook, so that Elisp code can call
190 profiler-cpu-log. That gives us more flexibility since that
191 Elisp code can then do all kinds of fun stuff like write
192 the log to disk. Or turn it right away into a call tree.
193 Of course, using Elisp is generally preferable, but it may
194 take longer until we get a chance to run the Elisp code, so
195 there's more risk that the table will get full before we
196 get there. */
197 }
198 }
199}
200
201/* Sample profiler. */
202
203/* FIXME: Add support for the CPU profiler in W32. */
204
205#ifdef PROFILER_CPU_SUPPORT
206
207/* The profiler timer and whether it was properly initialized, if
208 POSIX timers are available. */
209#ifdef HAVE_TIMER_SETTIME
210static timer_t profiler_timer;
211static bool profiler_timer_ok;
212#endif
213
214/* Status of sampling profiler. */
215static enum profiler_cpu_running
216 { NOT_RUNNING, TIMER_SETTIME_RUNNING, SETITIMER_RUNNING }
217 profiler_cpu_running;
218
219/* Hash-table log of CPU profiler. */
220static Lisp_Object cpu_log;
221
222/* Separate counter for the time spent in the GC. */
223static EMACS_INT cpu_gc_count;
224
225/* The current sample interval in milliseconds. */
226static EMACS_INT current_sample_interval;
227
228/* Signal handler for sample profiler. */
229
230static void
231handle_profiler_signal (int signal)
232{
233 if (backtrace_list && EQ (backtrace_list->function, Qautomatic_gc))
234 /* Special case the time-count inside GC because the hash-table
235 code is not prepared to be used while the GC is running.
236 More specifically it uses ASIZE at many places where it does
237 not expect the ARRAY_MARK_FLAG to be set. We could try and
238 harden the hash-table code, but it doesn't seem worth the
239 effort. */
240 cpu_gc_count = saturated_add (cpu_gc_count, current_sample_interval);
241 else
242 {
243 eassert (HASH_TABLE_P (cpu_log));
244 record_backtrace (XHASH_TABLE (cpu_log), current_sample_interval);
245 }
246}
247
248static void
249deliver_profiler_signal (int signal)
250{
251 deliver_process_signal (signal, handle_profiler_signal);
252}
253
254static enum profiler_cpu_running
255setup_cpu_timer (Lisp_Object sample_interval)
256{
257 struct sigaction action;
258 struct itimerval timer;
259 struct timespec interval;
260
261 if (! RANGED_INTEGERP (1, sample_interval,
262 (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / 1000
263 ? (EMACS_INT) TYPE_MAXIMUM (time_t) * 1000 + 999
264 : EMACS_INT_MAX)))
265 return NOT_RUNNING;
266
267 current_sample_interval = XINT (sample_interval);
268 interval = make_emacs_time (current_sample_interval / 1000,
269 current_sample_interval % 1000 * 1000000);
270 emacs_sigaction_init (&action, deliver_profiler_signal);
271 sigaction (SIGPROF, &action, 0);
272
273#ifdef HAVE_TIMER_SETTIME
274 if (! profiler_timer_ok)
275 {
276 /* System clocks to try, in decreasing order of desirability. */
277 static clockid_t const system_clock[] = {
278#ifdef CLOCK_THREAD_CPUTIME_ID
279 CLOCK_THREAD_CPUTIME_ID,
280#endif
281#ifdef CLOCK_PROCESS_CPUTIME_ID
282 CLOCK_PROCESS_CPUTIME_ID,
283#endif
284#ifdef CLOCK_MONOTONIC
285 CLOCK_MONOTONIC,
286#endif
287 CLOCK_REALTIME
288 };
289 int i;
290 struct sigevent sigev;
291 sigev.sigev_value.sival_ptr = &profiler_timer;
292 sigev.sigev_signo = SIGPROF;
293 sigev.sigev_notify = SIGEV_SIGNAL;
294
295 for (i = 0; i < sizeof system_clock / sizeof *system_clock; i++)
296 if (timer_create (system_clock[i], &sigev, &profiler_timer) == 0)
297 {
298 profiler_timer_ok = 1;
299 break;
300 }
301 }
302
303 if (profiler_timer_ok)
304 {
305 struct itimerspec ispec;
306 ispec.it_value = ispec.it_interval = interval;
307 timer_settime (profiler_timer, 0, &ispec, 0);
308 return TIMER_SETTIME_RUNNING;
309 }
310#endif
311
312 timer.it_value = timer.it_interval = make_timeval (interval);
313 setitimer (ITIMER_PROF, &timer, 0);
314 return SETITIMER_RUNNING;
315}
316
317DEFUN ("profiler-cpu-start", Fprofiler_cpu_start, Sprofiler_cpu_start,
318 1, 1, 0,
319 doc: /* Start or restart the cpu profiler.
320It takes call-stack samples each SAMPLE-INTERVAL milliseconds.
321See also `profiler-log-size' and `profiler-max-stack-depth'. */)
322 (Lisp_Object sample_interval)
323{
324 if (profiler_cpu_running)
325 error ("Sample profiler is already running");
326
327 if (NILP (cpu_log))
328 {
329 cpu_gc_count = 0;
330 cpu_log = make_log (profiler_log_size,
331 profiler_max_stack_depth);
332 }
333
334 profiler_cpu_running = setup_cpu_timer (sample_interval);
335 if (! profiler_cpu_running)
336 error ("Invalid sample interval");
337
338 return Qt;
339}
340
341DEFUN ("profiler-cpu-stop", Fprofiler_cpu_stop, Sprofiler_cpu_stop,
342 0, 0, 0,
343 doc: /* Stop the cpu profiler. The profiler log is not affected.
344Return non-nil if the profiler was running. */)
345 (void)
346{
347 switch (profiler_cpu_running)
348 {
349 case NOT_RUNNING:
350 return Qnil;
351
352#ifdef HAVE_TIMER_SETTIME
353 case TIMER_SETTIME_RUNNING:
354 {
355 struct itimerspec disable;
356 memset (&disable, 0, sizeof disable);
357 timer_settime (profiler_timer, 0, &disable, 0);
358 }
359 break;
360#endif
361
362 case SETITIMER_RUNNING:
363 {
364 struct itimerval disable;
365 memset (&disable, 0, sizeof disable);
366 setitimer (ITIMER_PROF, &disable, 0);
367 }
368 break;
369 }
370
371 signal (SIGPROF, SIG_IGN);
372 profiler_cpu_running = NOT_RUNNING;
373 return Qt;
374}
375
376DEFUN ("profiler-cpu-running-p",
377 Fprofiler_cpu_running_p, Sprofiler_cpu_running_p,
378 0, 0, 0,
379 doc: /* Return non-nil iff cpu profiler is running. */)
380 (void)
381{
382 return profiler_cpu_running ? Qt : Qnil;
383}
384
385DEFUN ("profiler-cpu-log", Fprofiler_cpu_log, Sprofiler_cpu_log,
386 0, 0, 0,
387 doc: /* Return the current cpu profiler log.
388The log is a hash-table mapping backtraces to counters which represent
389the amount of time spent at those points. Every backtrace is a vector
390of functions, where the last few elements may be nil.
391Before returning, a new log is allocated for future samples. */)
392 (void)
393{
394 Lisp_Object result = cpu_log;
395 /* Here we're making the log visible to Elisp, so it's not safe any
396 more for our use afterwards since we can't rely on its special
397 pre-allocated keys anymore. So we have to allocate a new one. */
398 cpu_log = (profiler_cpu_running
399 ? make_log (profiler_log_size, profiler_max_stack_depth)
400 : Qnil);
401 Fputhash (Fmake_vector (make_number (1), Qautomatic_gc),
402 make_number (cpu_gc_count),
403 result);
404 cpu_gc_count = 0;
405 return result;
406}
407#endif /* PROFILER_CPU_SUPPORT */
408
409/* Memory profiler. */
410
411/* True if memory profiler is running. */
412bool profiler_memory_running;
413
414static Lisp_Object memory_log;
415
416DEFUN ("profiler-memory-start", Fprofiler_memory_start, Sprofiler_memory_start,
417 0, 0, 0,
418 doc: /* Start/restart the memory profiler.
419The memory profiler will take samples of the call-stack whenever a new
420allocation takes place. Note that most small allocations only trigger
421the profiler occasionally.
422See also `profiler-log-size' and `profiler-max-stack-depth'. */)
423 (void)
424{
425 if (profiler_memory_running)
426 error ("Memory profiler is already running");
427
428 if (NILP (memory_log))
429 memory_log = make_log (profiler_log_size,
430 profiler_max_stack_depth);
431
432 profiler_memory_running = true;
433
434 return Qt;
435}
436
437DEFUN ("profiler-memory-stop",
438 Fprofiler_memory_stop, Sprofiler_memory_stop,
439 0, 0, 0,
440 doc: /* Stop the memory profiler. The profiler log is not affected.
441Return non-nil if the profiler was running. */)
442 (void)
443{
444 if (!profiler_memory_running)
445 return Qnil;
446 profiler_memory_running = false;
447 return Qt;
448}
449
450DEFUN ("profiler-memory-running-p",
451 Fprofiler_memory_running_p, Sprofiler_memory_running_p,
452 0, 0, 0,
453 doc: /* Return non-nil if memory profiler is running. */)
454 (void)
455{
456 return profiler_memory_running ? Qt : Qnil;
457}
458
459DEFUN ("profiler-memory-log",
460 Fprofiler_memory_log, Sprofiler_memory_log,
461 0, 0, 0,
462 doc: /* Return the current memory profiler log.
463The log is a hash-table mapping backtraces to counters which represent
464the amount of memory allocated at those points. Every backtrace is a vector
465of functions, where the last few elements may be nil.
466Before returning, a new log is allocated for future samples. */)
467 (void)
468{
469 Lisp_Object result = memory_log;
470 /* Here we're making the log visible to Elisp , so it's not safe any
471 more for our use afterwards since we can't rely on its special
472 pre-allocated keys anymore. So we have to allocate a new one. */
473 memory_log = (profiler_memory_running
474 ? make_log (profiler_log_size, profiler_max_stack_depth)
475 : Qnil);
476 return result;
477}
478
479
480/* Signals and probes. */
481
482/* Record that the current backtrace allocated SIZE bytes. */
483void
484malloc_probe (size_t size)
485{
486 eassert (HASH_TABLE_P (memory_log));
487 record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM));
488}
489
490void
491syms_of_profiler (void)
492{
493 DEFVAR_INT ("profiler-max-stack-depth", profiler_max_stack_depth,
494 doc: /* Number of elements from the call-stack recorded in the log. */);
495 profiler_max_stack_depth = 16;
496 DEFVAR_INT ("profiler-log-size", profiler_log_size,
497 doc: /* Number of distinct call-stacks that can be recorded in a profiler log.
498If the log gets full, some of the least-seen call-stacks will be evicted
499to make room for new entries. */);
500 profiler_log_size = 10000;
501
502#ifdef PROFILER_CPU_SUPPORT
503 profiler_cpu_running = NOT_RUNNING;
504 cpu_log = Qnil;
505 staticpro (&cpu_log);
506 defsubr (&Sprofiler_cpu_start);
507 defsubr (&Sprofiler_cpu_stop);
508 defsubr (&Sprofiler_cpu_running_p);
509 defsubr (&Sprofiler_cpu_log);
510#endif
511 profiler_memory_running = false;
512 memory_log = Qnil;
513 staticpro (&memory_log);
514 defsubr (&Sprofiler_memory_start);
515 defsubr (&Sprofiler_memory_stop);
516 defsubr (&Sprofiler_memory_running_p);
517 defsubr (&Sprofiler_memory_log);
518}
diff --git a/src/ralloc.c b/src/ralloc.c
index 9a4b1ada229..ab91baae5b5 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1199,9 +1199,9 @@ r_alloc_init (void)
1199#endif 1199#endif
1200 1200
1201#ifdef DOUG_LEA_MALLOC 1201#ifdef DOUG_LEA_MALLOC
1202 BLOCK_INPUT; 1202 block_input ();
1203 mallopt (M_TOP_PAD, 64 * 4096); 1203 mallopt (M_TOP_PAD, 64 * 4096);
1204 UNBLOCK_INPUT; 1204 unblock_input ();
1205#else 1205#else
1206#ifndef SYSTEM_MALLOC 1206#ifndef SYSTEM_MALLOC
1207 /* Give GNU malloc's morecore some hysteresis so that we move all 1207 /* Give GNU malloc's morecore some hysteresis so that we move all
diff --git a/src/search.c b/src/search.c
index 5224556fa17..7c084c62e28 100644
--- a/src/search.c
+++ b/src/search.c
@@ -156,7 +156,7 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object tra
156 re_set_whitespace_regexp (NULL); 156 re_set_whitespace_regexp (NULL);
157 157
158 re_set_syntax (old); 158 re_set_syntax (old);
159 /* UNBLOCK_INPUT; */ 159 /* unblock_input (); */
160 if (val) 160 if (val)
161 xsignal1 (Qinvalid_regexp, build_string (val)); 161 xsignal1 (Qinvalid_regexp, build_string (val));
162 162
diff --git a/src/sysdep.c b/src/sysdep.c
index dbfd9efc7d4..b7141011d05 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -279,10 +279,6 @@ init_baud_rate (int fd)
279 279
280 280
281 281
282/* Set nonzero to make following function work under dbx
283 (at least for bsd). */
284int wait_debugging EXTERNALLY_VISIBLE;
285
286#ifndef MSDOS 282#ifndef MSDOS
287 283
288static void 284static void
@@ -290,48 +286,24 @@ wait_for_termination_1 (pid_t pid, int interruptible)
290{ 286{
291 while (1) 287 while (1)
292 { 288 {
293#if (defined (BSD_SYSTEM) || defined (HPUX)) && !defined (__GNU__)
294 /* Note that kill returns -1 even if the process is just a zombie now.
295 But inevitably a SIGCHLD interrupt should be generated
296 and child_sig will do waitpid and make the process go away. */
297 /* There is some indication that there is a bug involved with
298 termination of subprocesses, perhaps involving a kernel bug too,
299 but no idea what it is. Just as a hunch we signal SIGCHLD to see
300 if that causes the problem to go away or get worse. */
301 sigset_t sigchild_mask;
302 sigemptyset (&sigchild_mask);
303 sigaddset (&sigchild_mask, SIGCHLD);
304 pthread_sigmask (SIG_SETMASK, &sigchild_mask, 0);
305
306 if (0 > kill (pid, 0))
307 {
308 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
309 kill (getpid (), SIGCHLD);
310 break;
311 }
312 if (wait_debugging)
313 sleep (1);
314 else
315 sigsuspend (&empty_mask);
316#else /* not BSD_SYSTEM, and not HPUX version >= 6 */
317#ifdef WINDOWSNT 289#ifdef WINDOWSNT
318 wait (0); 290 wait (0);
319 break; 291 break;
320#else /* not WINDOWSNT */ 292#else /* not WINDOWSNT */
321 sigset_t blocked; 293 int status;
322 sigemptyset (&blocked); 294 int wait_result = waitpid (pid, &status, 0);
323 sigaddset (&blocked, SIGCHLD); 295 if (wait_result < 0)
324 pthread_sigmask (SIG_BLOCK, &blocked, 0);
325 errno = 0;
326 if (kill (pid, 0) == -1 && errno == ESRCH)
327 { 296 {
328 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 297 if (errno != EINTR)
298 break;
299 }
300 else
301 {
302 record_child_status_change (wait_result, status);
329 break; 303 break;
330 } 304 }
331 305
332 sigsuspend (&empty_mask);
333#endif /* not WINDOWSNT */ 306#endif /* not WINDOWSNT */
334#endif /* not BSD_SYSTEM, and not HPUX version >= 6 */
335 if (interruptible) 307 if (interruptible)
336 QUIT; 308 QUIT;
337 } 309 }
@@ -1438,40 +1410,80 @@ init_system_name (void)
1438 1410
1439sigset_t empty_mask; 1411sigset_t empty_mask;
1440 1412
1441/* Store into *ACTION a signal action suitable for Emacs, with handler 1413static struct sigaction process_fatal_action;
1442 HANDLER. */ 1414
1443void 1415static int
1444emacs_sigaction_init (struct sigaction *action, signal_handler_t handler) 1416emacs_sigaction_flags (void)
1445{ 1417{
1446 sigemptyset (&action->sa_mask); 1418#ifdef SA_RESTART
1447 action->sa_handler = handler;
1448 action->sa_flags = 0;
1449#if defined (SA_RESTART)
1450 /* SA_RESTART causes interruptible functions with timeouts (e.g., 1419 /* SA_RESTART causes interruptible functions with timeouts (e.g.,
1451 'select') to reset their timeout on some platforms (e.g., 1420 'select') to reset their timeout on some platforms (e.g.,
1452 HP-UX 11), which is not what we want. Also, when Emacs is 1421 HP-UX 11), which is not what we want. Also, when Emacs is
1453 interactive, we don't want SA_RESTART because we need to poll 1422 interactive, we don't want SA_RESTART because we need to poll
1454 for pending input so we need long-running syscalls to be interrupted 1423 for pending input so we need long-running syscalls to be interrupted
1455 after a signal that sets the interrupt_input_pending flag. */ 1424 after a signal that sets pending_signals.
1456 /* Non-interactive keyboard input goes through stdio, where we always 1425
1457 want restartable system calls. */ 1426 Non-interactive keyboard input goes through stdio, where we
1427 always want restartable system calls. */
1458 if (noninteractive) 1428 if (noninteractive)
1459 action->sa_flags = SA_RESTART; 1429 return SA_RESTART;
1430#endif
1431 return 0;
1432}
1433
1434/* Store into *ACTION a signal action suitable for Emacs, with handler
1435 HANDLER. */
1436void
1437emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1438{
1439 sigemptyset (&action->sa_mask);
1440
1441 /* When handling a signal, block nonfatal system signals that are caught
1442 by Emacs. This makes race conditions less likely. */
1443 sigaddset (&action->sa_mask, SIGALRM);
1444#ifdef SIGCHLD
1445 sigaddset (&action->sa_mask, SIGCHLD);
1446#endif
1447#ifdef SIGDANGER
1448 sigaddset (&action->sa_mask, SIGDANGER);
1460#endif 1449#endif
1450#ifdef PROFILER_CPU_SUPPORT
1451 sigaddset (&action->sa_mask, SIGPROF);
1452#endif
1453#ifdef SIGWINCH
1454 sigaddset (&action->sa_mask, SIGWINCH);
1455#endif
1456 if (! noninteractive)
1457 {
1458 sigaddset (&action->sa_mask, SIGINT);
1459 sigaddset (&action->sa_mask, SIGQUIT);
1460#ifdef USABLE_SIGIO
1461 sigaddset (&action->sa_mask, SIGIO);
1462#endif
1463 }
1464
1465 if (! IEEE_FLOATING_POINT)
1466 sigaddset (&action->sa_mask, SIGFPE);
1467
1468 action->sa_handler = handler;
1469 action->sa_flags = emacs_sigaction_flags ();
1461} 1470}
1462 1471
1463#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 1472#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1464static pthread_t main_thread; 1473static pthread_t main_thread;
1465#endif 1474#endif
1466 1475
1467/* If we are on the main thread, handle the signal SIG with HANDLER. 1476/* SIG has arrived at the current process. Deliver it to the main
1477 thread, which should handle it with HANDLER.
1478
1479 If we are on the main thread, handle the signal SIG with HANDLER.
1468 Otherwise, redirect the signal to the main thread, blocking it from 1480 Otherwise, redirect the signal to the main thread, blocking it from
1469 this thread. POSIX says any thread can receive a signal that is 1481 this thread. POSIX says any thread can receive a signal that is
1470 associated with a process, process group, or asynchronous event. 1482 associated with a process, process group, or asynchronous event.
1471 On GNU/Linux that is not true, but for other systems (FreeBSD at 1483 On GNU/Linux that is not true, but for other systems (FreeBSD at
1472 least) it is. */ 1484 least) it is. */
1473void 1485void
1474handle_on_main_thread (int sig, signal_handler_t handler) 1486deliver_process_signal (int sig, signal_handler_t handler)
1475{ 1487{
1476 /* Preserve errno, to avoid race conditions with signal handlers that 1488 /* Preserve errno, to avoid race conditions with signal handlers that
1477 might change errno. Races can occur even in single-threaded hosts. */ 1489 might change errno. Races can occur even in single-threaded hosts. */
@@ -1494,6 +1506,39 @@ handle_on_main_thread (int sig, signal_handler_t handler)
1494 1506
1495 errno = old_errno; 1507 errno = old_errno;
1496} 1508}
1509
1510/* Static location to save a fatal backtrace in a thread.
1511 FIXME: If two subsidiary threads fail simultaneously, the resulting
1512 backtrace may be garbage. */
1513enum { BACKTRACE_LIMIT_MAX = 500 };
1514static void *thread_backtrace_buffer[BACKTRACE_LIMIT_MAX + 1];
1515static int thread_backtrace_npointers;
1516
1517/* SIG has arrived at the current thread.
1518 If we are on the main thread, handle the signal SIG with HANDLER.
1519 Otherwise, this is a fatal error in the handling thread. */
1520static void
1521deliver_thread_signal (int sig, signal_handler_t handler)
1522{
1523 int old_errno = errno;
1524
1525#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1526 if (! pthread_equal (pthread_self (), main_thread))
1527 {
1528 thread_backtrace_npointers
1529 = backtrace (thread_backtrace_buffer, BACKTRACE_LIMIT_MAX);
1530 sigaction (sig, &process_fatal_action, 0);
1531 pthread_kill (main_thread, sig);
1532
1533 /* Avoid further damage while the main thread is exiting. */
1534 while (1)
1535 sigsuspend (&empty_mask);
1536 }
1537#endif
1538
1539 handler (sig);
1540 errno = old_errno;
1541}
1497 1542
1498#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1543#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1499static char *my_sys_siglist[NSIG]; 1544static char *my_sys_siglist[NSIG];
@@ -1503,9 +1548,60 @@ static char *my_sys_siglist[NSIG];
1503# define sys_siglist my_sys_siglist 1548# define sys_siglist my_sys_siglist
1504#endif 1549#endif
1505 1550
1551/* Handle bus errors, invalid instruction, etc. */
1552static void
1553handle_fatal_signal (int sig)
1554{
1555 terminate_due_to_signal (sig, 40);
1556}
1557
1558static void
1559deliver_fatal_signal (int sig)
1560{
1561 deliver_process_signal (sig, handle_fatal_signal);
1562}
1563
1564static void
1565deliver_fatal_thread_signal (int sig)
1566{
1567 deliver_thread_signal (sig, handle_fatal_signal);
1568}
1569
1570static _Noreturn void
1571handle_arith_signal (int sig)
1572{
1573 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
1574 xsignal0 (Qarith_error);
1575}
1576
1577static void
1578deliver_arith_signal (int sig)
1579{
1580 deliver_thread_signal (sig, handle_arith_signal);
1581}
1582
1583/* Treat SIG as a terminating signal, unless it is already ignored and
1584 we are in --batch mode. Among other things, this makes nohup work. */
1585static void
1586maybe_fatal_sig (int sig)
1587{
1588 bool catch_sig = !noninteractive;
1589 if (!catch_sig)
1590 {
1591 struct sigaction old_action;
1592 sigaction (sig, 0, &old_action);
1593 catch_sig = old_action.sa_handler != SIG_IGN;
1594 }
1595 if (catch_sig)
1596 sigaction (sig, &process_fatal_action, 0);
1597}
1598
1506void 1599void
1507init_signals (void) 1600init_signals (bool dumping)
1508{ 1601{
1602 struct sigaction thread_fatal_action;
1603 struct sigaction action;
1604
1509 sigemptyset (&empty_mask); 1605 sigemptyset (&empty_mask);
1510 1606
1511#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 1607#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
@@ -1515,9 +1611,7 @@ init_signals (void)
1515#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1611#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
1516 if (! initialized) 1612 if (! initialized)
1517 { 1613 {
1518# ifdef SIGABRT
1519 sys_siglist[SIGABRT] = "Aborted"; 1614 sys_siglist[SIGABRT] = "Aborted";
1520# endif
1521# ifdef SIGAIO 1615# ifdef SIGAIO
1522 sys_siglist[SIGAIO] = "LAN I/O interrupt"; 1616 sys_siglist[SIGAIO] = "LAN I/O interrupt";
1523# endif 1617# endif
@@ -1545,9 +1639,7 @@ init_signals (void)
1545# ifdef SIGEMT 1639# ifdef SIGEMT
1546 sys_siglist[SIGEMT] = "Emulation trap"; 1640 sys_siglist[SIGEMT] = "Emulation trap";
1547# endif 1641# endif
1548# ifdef SIGFPE
1549 sys_siglist[SIGFPE] = "Arithmetic exception"; 1642 sys_siglist[SIGFPE] = "Arithmetic exception";
1550# endif
1551# ifdef SIGFREEZE 1643# ifdef SIGFREEZE
1552 sys_siglist[SIGFREEZE] = "SIGFREEZE"; 1644 sys_siglist[SIGFREEZE] = "SIGFREEZE";
1553# endif 1645# endif
@@ -1557,12 +1649,8 @@ init_signals (void)
1557# ifdef SIGHUP 1649# ifdef SIGHUP
1558 sys_siglist[SIGHUP] = "Hangup"; 1650 sys_siglist[SIGHUP] = "Hangup";
1559# endif 1651# endif
1560# ifdef SIGILL
1561 sys_siglist[SIGILL] = "Illegal instruction"; 1652 sys_siglist[SIGILL] = "Illegal instruction";
1562# endif
1563# ifdef SIGINT
1564 sys_siglist[SIGINT] = "Interrupt"; 1653 sys_siglist[SIGINT] = "Interrupt";
1565# endif
1566# ifdef SIGIO 1654# ifdef SIGIO
1567 sys_siglist[SIGIO] = "I/O possible"; 1655 sys_siglist[SIGIO] = "I/O possible";
1568# endif 1656# endif
@@ -1611,9 +1699,7 @@ init_signals (void)
1611# ifdef SIGSAK 1699# ifdef SIGSAK
1612 sys_siglist[SIGSAK] = "Secure attention"; 1700 sys_siglist[SIGSAK] = "Secure attention";
1613# endif 1701# endif
1614# ifdef SIGSEGV
1615 sys_siglist[SIGSEGV] = "Segmentation violation"; 1702 sys_siglist[SIGSEGV] = "Segmentation violation";
1616# endif
1617# ifdef SIGSOUND 1703# ifdef SIGSOUND
1618 sys_siglist[SIGSOUND] = "Sound completed"; 1704 sys_siglist[SIGSOUND] = "Sound completed";
1619# endif 1705# endif
@@ -1626,9 +1712,7 @@ init_signals (void)
1626# ifdef SIGSYS 1712# ifdef SIGSYS
1627 sys_siglist[SIGSYS] = "Bad argument to system call"; 1713 sys_siglist[SIGSYS] = "Bad argument to system call";
1628# endif 1714# endif
1629# ifdef SIGTERM
1630 sys_siglist[SIGTERM] = "Terminated"; 1715 sys_siglist[SIGTERM] = "Terminated";
1631# endif
1632# ifdef SIGTHAW 1716# ifdef SIGTHAW
1633 sys_siglist[SIGTHAW] = "SIGTHAW"; 1717 sys_siglist[SIGTHAW] = "SIGTHAW";
1634# endif 1718# endif
@@ -1673,6 +1757,129 @@ init_signals (void)
1673# endif 1757# endif
1674 } 1758 }
1675#endif /* !defined HAVE_STRSIGNAL && !defined HAVE_DECL_SYS_SIGLIST */ 1759#endif /* !defined HAVE_STRSIGNAL && !defined HAVE_DECL_SYS_SIGLIST */
1760
1761 /* Don't alter signal handlers if dumping. On some machines,
1762 changing signal handlers sets static data that would make signals
1763 fail to work right when the dumped Emacs is run. */
1764 if (dumping)
1765 return;
1766
1767 sigfillset (&process_fatal_action.sa_mask);
1768 process_fatal_action.sa_handler = deliver_fatal_signal;
1769 process_fatal_action.sa_flags = emacs_sigaction_flags ();
1770
1771 sigfillset (&thread_fatal_action.sa_mask);
1772 thread_fatal_action.sa_handler = deliver_fatal_thread_signal;
1773 thread_fatal_action.sa_flags = process_fatal_action.sa_flags;
1774
1775 /* SIGINT may need special treatment on MS-Windows. See
1776 http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
1777 Please update the doc of kill-emacs, kill-emacs-hook, and
1778 NEWS if you change this. */
1779
1780 maybe_fatal_sig (SIGHUP);
1781 maybe_fatal_sig (SIGINT);
1782 maybe_fatal_sig (SIGTERM);
1783
1784 /* Emacs checks for write errors, so it can safely ignore SIGPIPE.
1785 However, in batch mode leave SIGPIPE alone, as that causes Emacs
1786 to behave more like typical batch applications do. */
1787 if (! noninteractive)
1788 signal (SIGPIPE, SIG_IGN);
1789
1790 sigaction (SIGQUIT, &process_fatal_action, 0);
1791 sigaction (SIGILL, &thread_fatal_action, 0);
1792 sigaction (SIGTRAP, &thread_fatal_action, 0);
1793
1794 /* Typically SIGFPE is thread-specific and is fatal, like SIGILL.
1795 But on a non-IEEE host SIGFPE can come from a trap in the Lisp
1796 interpreter's floating point operations, so treat SIGFPE as an
1797 arith-error if it arises in the main thread. */
1798 if (IEEE_FLOATING_POINT)
1799 sigaction (SIGFPE, &thread_fatal_action, 0);
1800 else
1801 {
1802 emacs_sigaction_init (&action, deliver_arith_signal);
1803 sigaction (SIGFPE, &action, 0);
1804 }
1805
1806#ifdef SIGUSR1
1807 add_user_signal (SIGUSR1, "sigusr1");
1808#endif
1809#ifdef SIGUSR2
1810 add_user_signal (SIGUSR2, "sigusr2");
1811#endif
1812 sigaction (SIGABRT, &thread_fatal_action, 0);
1813#ifdef SIGPRE
1814 sigaction (SIGPRE, &thread_fatal_action, 0);
1815#endif
1816#ifdef SIGORE
1817 sigaction (SIGORE, &thread_fatal_action, 0);
1818#endif
1819#ifdef SIGUME
1820 sigaction (SIGUME, &thread_fatal_action, 0);
1821#endif
1822#ifdef SIGDLK
1823 sigaction (SIGDLK, &process_fatal_action, 0);
1824#endif
1825#ifdef SIGCPULIM
1826 sigaction (SIGCPULIM, &process_fatal_action, 0);
1827#endif
1828#ifdef SIGIOT
1829 sigaction (SIGIOT, &thread_fatal_action, 0);
1830#endif
1831#ifdef SIGEMT
1832 sigaction (SIGEMT, &thread_fatal_action, 0);
1833#endif
1834#ifdef SIGBUS
1835 sigaction (SIGBUS, &thread_fatal_action, 0);
1836#endif
1837 sigaction (SIGSEGV, &thread_fatal_action, 0);
1838#ifdef SIGSYS
1839 sigaction (SIGSYS, &thread_fatal_action, 0);
1840#endif
1841 sigaction (SIGTERM, &process_fatal_action, 0);
1842#ifdef SIGPROF
1843 signal (SIGPROF, SIG_IGN);
1844#endif
1845#ifdef SIGVTALRM
1846 sigaction (SIGVTALRM, &process_fatal_action, 0);
1847#endif
1848#ifdef SIGXCPU
1849 sigaction (SIGXCPU, &process_fatal_action, 0);
1850#endif
1851#ifdef SIGXFSZ
1852 sigaction (SIGXFSZ, &process_fatal_action, 0);
1853#endif
1854
1855#ifdef SIGDANGER
1856 /* This just means available memory is getting low. */
1857 emacs_sigaction_init (&action, deliver_danger_signal);
1858 sigaction (SIGDANGER, &action, 0);
1859#endif
1860
1861 /* AIX-specific signals. */
1862#ifdef SIGGRANT
1863 sigaction (SIGGRANT, &process_fatal_action, 0);
1864#endif
1865#ifdef SIGMIGRATE
1866 sigaction (SIGMIGRATE, &process_fatal_action, 0);
1867#endif
1868#ifdef SIGMSG
1869 sigaction (SIGMSG, &process_fatal_action, 0);
1870#endif
1871#ifdef SIGRETRACT
1872 sigaction (SIGRETRACT, &process_fatal_action, 0);
1873#endif
1874#ifdef SIGSAK
1875 sigaction (SIGSAK, &process_fatal_action, 0);
1876#endif
1877#ifdef SIGSOUND
1878 sigaction (SIGSOUND, &process_fatal_action, 0);
1879#endif
1880#ifdef SIGTALRM
1881 sigaction (SIGTALRM, &thread_fatal_action, 0);
1882#endif
1676} 1883}
1677 1884
1678#ifndef HAVE_RANDOM 1885#ifndef HAVE_RANDOM
@@ -1811,23 +2018,36 @@ snprintf (char *buf, size_t bufsize, char const *format, ...)
1811void 2018void
1812emacs_backtrace (int backtrace_limit) 2019emacs_backtrace (int backtrace_limit)
1813{ 2020{
1814 enum { BACKTRACE_LIMIT_MAX = 500 }; 2021 void *main_backtrace_buffer[BACKTRACE_LIMIT_MAX + 1];
1815 void *buffer[BACKTRACE_LIMIT_MAX + 1];
1816 int bounded_limit = min (backtrace_limit, BACKTRACE_LIMIT_MAX); 2022 int bounded_limit = min (backtrace_limit, BACKTRACE_LIMIT_MAX);
1817 int npointers = backtrace (buffer, bounded_limit + 1); 2023 void *buffer;
2024 int npointers;
2025
2026 if (thread_backtrace_npointers)
2027 {
2028 buffer = thread_backtrace_buffer;
2029 npointers = thread_backtrace_npointers;
2030 }
2031 else
2032 {
2033 buffer = main_backtrace_buffer;
2034 npointers = backtrace (buffer, bounded_limit + 1);
2035 }
2036
1818 if (npointers) 2037 if (npointers)
1819 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12)); 2038 {
1820 backtrace_symbols_fd (buffer, bounded_limit, STDERR_FILENO); 2039 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12));
1821 if (bounded_limit < npointers) 2040 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
1822 ignore_value (write (STDERR_FILENO, "...\n", 4)); 2041 if (bounded_limit < npointers)
2042 ignore_value (write (STDERR_FILENO, "...\n", 4));
2043 }
1823} 2044}
1824 2045
1825#ifndef HAVE_NTGUI 2046#ifndef HAVE_NTGUI
1826/* Using emacs_abort lets GDB return from a breakpoint here. */
1827void 2047void
1828emacs_abort (void) 2048emacs_abort (void)
1829{ 2049{
1830 fatal_error_backtrace (SIGABRT, 10); 2050 terminate_due_to_signal (SIGABRT, 10);
1831} 2051}
1832#endif 2052#endif
1833 2053
@@ -1910,7 +2130,8 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte)
1910 { 2130 {
1911 /* I originally used `QUIT' but that might causes files to 2131 /* I originally used `QUIT' but that might causes files to
1912 be truncated if you hit C-g in the middle of it. --Stef */ 2132 be truncated if you hit C-g in the middle of it. --Stef */
1913 process_pending_signals (); 2133 if (pending_signals)
2134 process_pending_signals ();
1914 continue; 2135 continue;
1915 } 2136 }
1916 else 2137 else
@@ -1975,11 +2196,11 @@ getwd (char *pathname)
1975 char *npath, *spath; 2196 char *npath, *spath;
1976 extern char *getcwd (char *, size_t); 2197 extern char *getcwd (char *, size_t);
1977 2198
1978 BLOCK_INPUT; /* getcwd uses malloc */ 2199 block_input (); /* getcwd uses malloc */
1979 spath = npath = getcwd ((char *) 0, MAXPATHLEN); 2200 spath = npath = getcwd ((char *) 0, MAXPATHLEN);
1980 if (spath == 0) 2201 if (spath == 0)
1981 { 2202 {
1982 UNBLOCK_INPUT; 2203 unblock_input ();
1983 return spath; 2204 return spath;
1984 } 2205 }
1985 /* On Altos 3068, getcwd can return @hostname/dir, so discard 2206 /* On Altos 3068, getcwd can return @hostname/dir, so discard
@@ -1988,7 +2209,7 @@ getwd (char *pathname)
1988 npath++; 2209 npath++;
1989 strcpy (pathname, npath); 2210 strcpy (pathname, npath);
1990 free (spath); /* getcwd uses malloc */ 2211 free (spath); /* getcwd uses malloc */
1991 UNBLOCK_INPUT; 2212 unblock_input ();
1992 return pathname; 2213 return pathname;
1993} 2214}
1994 2215
@@ -2422,7 +2643,7 @@ get_up_time (void)
2422 FILE *fup; 2643 FILE *fup;
2423 EMACS_TIME up = make_emacs_time (0, 0); 2644 EMACS_TIME up = make_emacs_time (0, 0);
2424 2645
2425 BLOCK_INPUT; 2646 block_input ();
2426 fup = fopen ("/proc/uptime", "r"); 2647 fup = fopen ("/proc/uptime", "r");
2427 2648
2428 if (fup) 2649 if (fup)
@@ -2453,7 +2674,7 @@ get_up_time (void)
2453 } 2674 }
2454 fclose (fup); 2675 fclose (fup);
2455 } 2676 }
2456 UNBLOCK_INPUT; 2677 unblock_input ();
2457 2678
2458 return up; 2679 return up;
2459} 2680}
@@ -2467,7 +2688,7 @@ procfs_ttyname (int rdev)
2467 FILE *fdev = NULL; 2688 FILE *fdev = NULL;
2468 char name[PATH_MAX]; 2689 char name[PATH_MAX];
2469 2690
2470 BLOCK_INPUT; 2691 block_input ();
2471 fdev = fopen ("/proc/tty/drivers", "r"); 2692 fdev = fopen ("/proc/tty/drivers", "r");
2472 2693
2473 if (fdev) 2694 if (fdev)
@@ -2499,7 +2720,7 @@ procfs_ttyname (int rdev)
2499 } 2720 }
2500 fclose (fdev); 2721 fclose (fdev);
2501 } 2722 }
2502 UNBLOCK_INPUT; 2723 unblock_input ();
2503 return build_string (name); 2724 return build_string (name);
2504} 2725}
2505 2726
@@ -2509,7 +2730,7 @@ procfs_get_total_memory (void)
2509 FILE *fmem = NULL; 2730 FILE *fmem = NULL;
2510 unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */ 2731 unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */
2511 2732
2512 BLOCK_INPUT; 2733 block_input ();
2513 fmem = fopen ("/proc/meminfo", "r"); 2734 fmem = fopen ("/proc/meminfo", "r");
2514 2735
2515 if (fmem) 2736 if (fmem)
@@ -2528,7 +2749,7 @@ procfs_get_total_memory (void)
2528 } 2749 }
2529 fclose (fmem); 2750 fclose (fmem);
2530 } 2751 }
2531 UNBLOCK_INPUT; 2752 unblock_input ();
2532 return retval; 2753 return retval;
2533} 2754}
2534 2755
@@ -2574,17 +2795,17 @@ system_process_attributes (Lisp_Object pid)
2574 /* euid egid */ 2795 /* euid egid */
2575 uid = st.st_uid; 2796 uid = st.st_uid;
2576 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs); 2797 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs);
2577 BLOCK_INPUT; 2798 block_input ();
2578 pw = getpwuid (uid); 2799 pw = getpwuid (uid);
2579 UNBLOCK_INPUT; 2800 unblock_input ();
2580 if (pw) 2801 if (pw)
2581 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); 2802 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
2582 2803
2583 gid = st.st_gid; 2804 gid = st.st_gid;
2584 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs); 2805 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs);
2585 BLOCK_INPUT; 2806 block_input ();
2586 gr = getgrgid (gid); 2807 gr = getgrgid (gid);
2587 UNBLOCK_INPUT; 2808 unblock_input ();
2588 if (gr) 2809 if (gr)
2589 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 2810 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
2590 2811
@@ -2812,17 +3033,17 @@ system_process_attributes (Lisp_Object pid)
2812 /* euid egid */ 3033 /* euid egid */
2813 uid = st.st_uid; 3034 uid = st.st_uid;
2814 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs); 3035 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs);
2815 BLOCK_INPUT; 3036 block_input ();
2816 pw = getpwuid (uid); 3037 pw = getpwuid (uid);
2817 UNBLOCK_INPUT; 3038 unblock_input ();
2818 if (pw) 3039 if (pw)
2819 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); 3040 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
2820 3041
2821 gid = st.st_gid; 3042 gid = st.st_gid;
2822 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs); 3043 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs);
2823 BLOCK_INPUT; 3044 block_input ();
2824 gr = getgrgid (gid); 3045 gr = getgrgid (gid);
2825 UNBLOCK_INPUT; 3046 unblock_input ();
2826 if (gr) 3047 if (gr)
2827 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 3048 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
2828 3049
@@ -2943,17 +3164,17 @@ system_process_attributes (Lisp_Object pid)
2943 3164
2944 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (proc.ki_uid)), attrs); 3165 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (proc.ki_uid)), attrs);
2945 3166
2946 BLOCK_INPUT; 3167 block_input ();
2947 pw = getpwuid (proc.ki_uid); 3168 pw = getpwuid (proc.ki_uid);
2948 UNBLOCK_INPUT; 3169 unblock_input ();
2949 if (pw) 3170 if (pw)
2950 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); 3171 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
2951 3172
2952 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (proc.ki_svgid)), attrs); 3173 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (proc.ki_svgid)), attrs);
2953 3174
2954 BLOCK_INPUT; 3175 block_input ();
2955 gr = getgrgid (proc.ki_svgid); 3176 gr = getgrgid (proc.ki_svgid);
2956 UNBLOCK_INPUT; 3177 unblock_input ();
2957 if (gr) 3178 if (gr)
2958 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 3179 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
2959 3180
@@ -2993,9 +3214,9 @@ system_process_attributes (Lisp_Object pid)
2993 attrs = Fcons (Fcons (Qpgrp, make_fixnum_or_float (proc.ki_pgid)), attrs); 3214 attrs = Fcons (Fcons (Qpgrp, make_fixnum_or_float (proc.ki_pgid)), attrs);
2994 attrs = Fcons (Fcons (Qsess, make_fixnum_or_float (proc.ki_sid)), attrs); 3215 attrs = Fcons (Fcons (Qsess, make_fixnum_or_float (proc.ki_sid)), attrs);
2995 3216
2996 BLOCK_INPUT; 3217 block_input ();
2997 ttyname = proc.ki_tdev == NODEV ? NULL : devname (proc.ki_tdev, S_IFCHR); 3218 ttyname = proc.ki_tdev == NODEV ? NULL : devname (proc.ki_tdev, S_IFCHR);
2998 UNBLOCK_INPUT; 3219 unblock_input ();
2999 if (ttyname) 3220 if (ttyname)
3000 attrs = Fcons (Fcons (Qtty, build_string (ttyname)), attrs); 3221 attrs = Fcons (Fcons (Qtty, build_string (ttyname)), attrs);
3001 3222
diff --git a/src/syssignal.h b/src/syssignal.h
index e309e6725b7..ece2515dec9 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -18,8 +18,9 @@ You 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> 20#include <signal.h>
21#include <stdbool.h>
21 22
22extern void init_signals (void); 23extern void init_signals (bool);
23 24
24#ifdef HAVE_PTHREAD 25#ifdef HAVE_PTHREAD
25#include <pthread.h> 26#include <pthread.h>
@@ -28,6 +29,11 @@ extern void init_signals (void);
28#define FORWARD_SIGNAL_TO_MAIN_THREAD 29#define FORWARD_SIGNAL_TO_MAIN_THREAD
29#endif 30#endif
30 31
32#if (defined SIGPROF && (defined HAVE_TIMER_SETTIME || defined HAVE_SETITIMER) \
33 && !defined PROFILING)
34# define PROFILER_CPU_SUPPORT
35#endif
36
31extern sigset_t empty_mask; 37extern sigset_t empty_mask;
32 38
33typedef void (*signal_handler_t) (int); 39typedef void (*signal_handler_t) (int);
@@ -39,6 +45,10 @@ extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
39# define NSIG NSIG_MINIMUM 45# define NSIG NSIG_MINIMUM
40#endif 46#endif
41 47
48#ifndef emacs_raise
49# define emacs_raise(sig) raise (sig)
50#endif
51
42/* On bsd, [man says] kill does not accept a negative number to kill a pgrp. 52/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
43 Must do that using the killpg call. */ 53 Must do that using the killpg call. */
44#ifdef BSD_SYSTEM 54#ifdef BSD_SYSTEM
@@ -64,4 +74,4 @@ extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
64char *strsignal (int); 74char *strsignal (int);
65#endif 75#endif
66 76
67void handle_on_main_thread (int, signal_handler_t); 77void deliver_process_signal (int, signal_handler_t);
diff --git a/src/syswait.h b/src/syswait.h
index 9d84876d4be..aa4c4bcf527 100644
--- a/src/syswait.h
+++ b/src/syswait.h
@@ -51,4 +51,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51#define WTERMSIG(status) ((status) & 0x7f) 51#define WTERMSIG(status) ((status) & 0x7f)
52#endif 52#endif
53 53
54/* Defined in process.c. */
55extern void record_child_status_change (pid_t, int);
56
57/* Defined in sysdep.c. */
58extern void wait_for_termination (pid_t);
59extern void interruptible_wait_for_termination (pid_t);
60
54#endif /* EMACS_SYSWAIT_H */ 61#endif /* EMACS_SYSWAIT_H */
diff --git a/src/term.c b/src/term.c
index f4117d67dec..189fb783cbc 100644
--- a/src/term.c
+++ b/src/term.c
@@ -753,13 +753,13 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
753 conversion_buffer = encode_terminal_code (string, n, coding); 753 conversion_buffer = encode_terminal_code (string, n, coding);
754 if (coding->produced > 0) 754 if (coding->produced > 0)
755 { 755 {
756 BLOCK_INPUT; 756 block_input ();
757 fwrite (conversion_buffer, 1, coding->produced, tty->output); 757 fwrite (conversion_buffer, 1, coding->produced, tty->output);
758 if (ferror (tty->output)) 758 if (ferror (tty->output))
759 clearerr (tty->output); 759 clearerr (tty->output);
760 if (tty->termscript) 760 if (tty->termscript)
761 fwrite (conversion_buffer, 1, coding->produced, tty->termscript); 761 fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
762 UNBLOCK_INPUT; 762 unblock_input ();
763 } 763 }
764 string += n; 764 string += n;
765 765
@@ -814,13 +814,13 @@ tty_write_glyphs_with_face (register struct frame *f, register struct glyph *str
814 conversion_buffer = encode_terminal_code (string, len, coding); 814 conversion_buffer = encode_terminal_code (string, len, coding);
815 if (coding->produced > 0) 815 if (coding->produced > 0)
816 { 816 {
817 BLOCK_INPUT; 817 block_input ();
818 fwrite (conversion_buffer, 1, coding->produced, tty->output); 818 fwrite (conversion_buffer, 1, coding->produced, tty->output);
819 if (ferror (tty->output)) 819 if (ferror (tty->output))
820 clearerr (tty->output); 820 clearerr (tty->output);
821 if (tty->termscript) 821 if (tty->termscript)
822 fwrite (conversion_buffer, 1, coding->produced, tty->termscript); 822 fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
823 UNBLOCK_INPUT; 823 unblock_input ();
824 } 824 }
825 825
826 /* Turn appearance modes off. */ 826 /* Turn appearance modes off. */
@@ -900,13 +900,13 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len)
900 900
901 if (coding->produced > 0) 901 if (coding->produced > 0)
902 { 902 {
903 BLOCK_INPUT; 903 block_input ();
904 fwrite (conversion_buffer, 1, coding->produced, tty->output); 904 fwrite (conversion_buffer, 1, coding->produced, tty->output);
905 if (ferror (tty->output)) 905 if (ferror (tty->output))
906 clearerr (tty->output); 906 clearerr (tty->output);
907 if (tty->termscript) 907 if (tty->termscript)
908 fwrite (conversion_buffer, 1, coding->produced, tty->termscript); 908 fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
909 UNBLOCK_INPUT; 909 unblock_input ();
910 } 910 }
911 911
912 OUTPUT1_IF (tty, tty->TS_pad_inserted_char); 912 OUTPUT1_IF (tty, tty->TS_pad_inserted_char);
diff --git a/src/termhooks.h b/src/termhooks.h
index 53e401de409..f35bd929af1 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -591,8 +591,7 @@ struct terminal
591 /* Called to read input events. 591 /* Called to read input events.
592 592
593 TERMINAL indicates which terminal device to read from. Input 593 TERMINAL indicates which terminal device to read from. Input
594 events should be read into BUF, the size of which is given in 594 events should be read into HOLD_QUIT.
595 SIZE.
596 595
597 A positive return value indicates that that many input events 596 A positive return value indicates that that many input events
598 were read into BUF. 597 were read into BUF.
diff --git a/src/w16select.c b/src/w16select.c
index a3f6f1fb9ae..b8aaa3619ba 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -459,7 +459,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
459 if ( !FRAME_MSDOS_P (XFRAME (frame))) 459 if ( !FRAME_MSDOS_P (XFRAME (frame)))
460 goto done; 460 goto done;
461 461
462 BLOCK_INPUT; 462 block_input ();
463 463
464 if (!open_clipboard ()) 464 if (!open_clipboard ())
465 goto error; 465 goto error;
@@ -520,7 +520,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
520 520
521 unblock: 521 unblock:
522 xfree (dst); 522 xfree (dst);
523 UNBLOCK_INPUT; 523 unblock_input ();
524 524
525 /* Notify user if the text is too large to fit into DOS memory. 525 /* Notify user if the text is too large to fit into DOS memory.
526 (This will happen somewhere after 600K bytes (470K in DJGPP v1.x), 526 (This will happen somewhere after 600K bytes (470K in DJGPP v1.x),
@@ -565,7 +565,7 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
565 if ( !FRAME_MSDOS_P (XFRAME (frame))) 565 if ( !FRAME_MSDOS_P (XFRAME (frame)))
566 goto done; 566 goto done;
567 567
568 BLOCK_INPUT; 568 block_input ();
569 569
570 if (!open_clipboard ()) 570 if (!open_clipboard ())
571 goto unblock; 571 goto unblock;
@@ -626,7 +626,7 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
626 close_clipboard (); 626 close_clipboard ();
627 627
628 unblock: 628 unblock:
629 UNBLOCK_INPUT; 629 unblock_input ();
630 630
631 done: 631 done:
632 632
diff --git a/src/w32.c b/src/w32.c
index bcb0511e2fa..3154c725abf 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -6521,33 +6521,27 @@ sys_localtime (const time_t *t)
6521 6521
6522 6522
6523 6523
6524/* Delayed loading of libraries. */ 6524/* Try loading LIBRARY_ID from the file(s) specified in
6525 6525 Vdynamic_library_alist. If the library is loaded successfully,
6526Lisp_Object Vlibrary_cache; 6526 return the handle of the DLL, and record the filename in the
6527 6527 property :loaded-from of LIBRARY_ID. If the library could not be
6528/* The argument LIBRARIES is an alist that associates a symbol 6528 found, or when it was already loaded (because the handle is not
6529 LIBRARY_ID, identifying an external DLL library known to Emacs, to 6529 recorded anywhere, and so is lost after use), return NULL.
6530 a list of filenames under which the library is usually found. In 6530
6531 most cases, the argument passed as LIBRARIES is the variable 6531 We could also save the handle in :loaded-from, but currently
6532 `dynamic-library-alist', which is initialized to a list of common 6532 there's no use case for it. */
6533 library names. If the function loads the library successfully, it
6534 returns the handle of the DLL, and records the filename in the
6535 property :loaded-from of LIBRARY_ID; it returns NULL if the library
6536 could not be found, or when it was already loaded (because the
6537 handle is not recorded anywhere, and so is lost after use). It
6538 would be trivial to save the handle too in :loaded-from, but
6539 currently there's no use case for it. */
6540HMODULE 6533HMODULE
6541w32_delayed_load (Lisp_Object libraries, Lisp_Object library_id) 6534w32_delayed_load (Lisp_Object library_id)
6542{ 6535{
6543 HMODULE library_dll = NULL; 6536 HMODULE library_dll = NULL;
6544 6537
6545 CHECK_SYMBOL (library_id); 6538 CHECK_SYMBOL (library_id);
6546 6539
6547 if (CONSP (libraries) && NILP (Fassq (library_id, Vlibrary_cache))) 6540 if (CONSP (Vdynamic_library_alist)
6541 && NILP (Fassq (library_id, Vlibrary_cache)))
6548 { 6542 {
6549 Lisp_Object found = Qnil; 6543 Lisp_Object found = Qnil;
6550 Lisp_Object dlls = Fassq (library_id, libraries); 6544 Lisp_Object dlls = Fassq (library_id, Vdynamic_library_alist);
6551 6545
6552 if (CONSP (dlls)) 6546 if (CONSP (dlls))
6553 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls)) 6547 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
@@ -6626,8 +6620,9 @@ check_windows_init_file (void)
6626} 6620}
6627 6621
6628void 6622void
6629term_ntproc (void) 6623term_ntproc (int ignored)
6630{ 6624{
6625 (void)ignored;
6631 /* shutdown the socket interface if necessary */ 6626 /* shutdown the socket interface if necessary */
6632 term_winsock (); 6627 term_winsock ();
6633 6628
@@ -6635,7 +6630,7 @@ term_ntproc (void)
6635} 6630}
6636 6631
6637void 6632void
6638init_ntproc (void) 6633init_ntproc (int dumping)
6639{ 6634{
6640 /* Initialize the socket interface now if available and requested by 6635 /* Initialize the socket interface now if available and requested by
6641 the user by defining PRELOAD_WINSOCK; otherwise loading will be 6636 the user by defining PRELOAD_WINSOCK; otherwise loading will be
@@ -6712,7 +6707,8 @@ init_ntproc (void)
6712 6707
6713 /* unfortunately, atexit depends on implementation of malloc */ 6708 /* unfortunately, atexit depends on implementation of malloc */
6714 /* atexit (term_ntproc); */ 6709 /* atexit (term_ntproc); */
6715 signal (SIGABRT, term_ntproc); 6710 if (!dumping)
6711 signal (SIGABRT, term_ntproc);
6716 6712
6717 /* determine which drives are fixed, for GetCachedVolumeInformation */ 6713 /* determine which drives are fixed, for GetCachedVolumeInformation */
6718 { 6714 {
@@ -6769,9 +6765,6 @@ globals_of_w32 (void)
6769 6765
6770 DEFSYM (QCloaded_from, ":loaded-from"); 6766 DEFSYM (QCloaded_from, ":loaded-from");
6771 6767
6772 Vlibrary_cache = Qnil;
6773 staticpro (&Vlibrary_cache);
6774
6775 g_b_init_is_windows_9x = 0; 6768 g_b_init_is_windows_9x = 0;
6776 g_b_init_open_process_token = 0; 6769 g_b_init_open_process_token = 0;
6777 g_b_init_get_token_information = 0; 6770 g_b_init_get_token_information = 0;
diff --git a/src/w32.h b/src/w32.h
index 73d57a65a4a..a833c8f4315 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -127,8 +127,8 @@ extern void reset_standard_handles (int in, int out,
127/* Return the string resource associated with KEY of type TYPE. */ 127/* Return the string resource associated with KEY of type TYPE. */
128extern LPBYTE w32_get_resource (char * key, LPDWORD type); 128extern LPBYTE w32_get_resource (char * key, LPDWORD type);
129 129
130extern void init_ntproc (void); 130extern void init_ntproc (int);
131extern void term_ntproc (void); 131extern void term_ntproc (int);
132extern void globals_of_w32 (void); 132extern void globals_of_w32 (void);
133extern void syms_of_w32term (void); 133extern void syms_of_w32term (void);
134extern void syms_of_w32fns (void); 134extern void syms_of_w32fns (void);
@@ -145,8 +145,8 @@ extern void check_windows_init_file (void);
145extern int _sys_read_ahead (int fd); 145extern int _sys_read_ahead (int fd);
146extern int _sys_wait_accept (int fd); 146extern int _sys_wait_accept (int fd);
147 147
148extern Lisp_Object Vlibrary_cache, QCloaded_from; 148extern Lisp_Object QCloaded_from;
149extern HMODULE w32_delayed_load (Lisp_Object, Lisp_Object); 149extern HMODULE w32_delayed_load (Lisp_Object);
150 150
151#ifdef HAVE_GNUTLS 151#ifdef HAVE_GNUTLS
152#include <gnutls/gnutls.h> 152#include <gnutls/gnutls.h>
diff --git a/src/w32fns.c b/src/w32fns.c
index be008bb18c8..808e19d0b66 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -364,7 +364,7 @@ if the entry is new. */)
364 364
365 XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue))); 365 XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue)));
366 366
367 BLOCK_INPUT; 367 block_input ();
368 368
369 /* replace existing entry in w32-color-map or add new entry. */ 369 /* replace existing entry in w32-color-map or add new entry. */
370 entry = Fassoc (name, Vw32_color_map); 370 entry = Fassoc (name, Vw32_color_map);
@@ -379,7 +379,7 @@ if the entry is new. */)
379 Fsetcdr (entry, rgb); 379 Fsetcdr (entry, rgb);
380 } 380 }
381 381
382 UNBLOCK_INPUT; 382 unblock_input ();
383 383
384 return (oldrgb); 384 return (oldrgb);
385} 385}
@@ -642,7 +642,7 @@ w32_default_color_map (void)
642 colormap_t *pc = w32_color_map; 642 colormap_t *pc = w32_color_map;
643 Lisp_Object cmap; 643 Lisp_Object cmap;
644 644
645 BLOCK_INPUT; 645 block_input ();
646 646
647 cmap = Qnil; 647 cmap = Qnil;
648 648
@@ -652,7 +652,7 @@ w32_default_color_map (void)
652 make_number (pc->colorref)), 652 make_number (pc->colorref)),
653 cmap); 653 cmap);
654 654
655 UNBLOCK_INPUT; 655 unblock_input ();
656 656
657 return (cmap); 657 return (cmap);
658} 658}
@@ -669,7 +669,7 @@ w32_color_map_lookup (char *colorname)
669{ 669{
670 Lisp_Object tail, ret = Qnil; 670 Lisp_Object tail, ret = Qnil;
671 671
672 BLOCK_INPUT; 672 block_input ();
673 673
674 for (tail = Vw32_color_map; CONSP (tail); tail = XCDR (tail)) 674 for (tail = Vw32_color_map; CONSP (tail); tail = XCDR (tail))
675 { 675 {
@@ -689,7 +689,7 @@ w32_color_map_lookup (char *colorname)
689 QUIT; 689 QUIT;
690 } 690 }
691 691
692 UNBLOCK_INPUT; 692 unblock_input ();
693 693
694 return ret; 694 return ret;
695} 695}
@@ -701,7 +701,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
701 HKEY colors_key; 701 HKEY colors_key;
702 702
703 /* Other registry operations are done with input blocked. */ 703 /* Other registry operations are done with input blocked. */
704 BLOCK_INPUT; 704 block_input ();
705 705
706 /* Look for "Control Panel/Colors" under User and Machine registry 706 /* Look for "Control Panel/Colors" under User and Machine registry
707 settings. */ 707 settings. */
@@ -739,7 +739,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
739 RegCloseKey (colors_key); 739 RegCloseKey (colors_key);
740 } 740 }
741 741
742 UNBLOCK_INPUT; 742 unblock_input ();
743} 743}
744 744
745 745
@@ -748,7 +748,7 @@ x_to_w32_color (char * colorname)
748{ 748{
749 register Lisp_Object ret = Qnil; 749 register Lisp_Object ret = Qnil;
750 750
751 BLOCK_INPUT; 751 block_input ();
752 752
753 if (colorname[0] == '#') 753 if (colorname[0] == '#')
754 { 754 {
@@ -801,7 +801,7 @@ x_to_w32_color (char * colorname)
801 pos += 0x8; 801 pos += 0x8;
802 if (i == 2) 802 if (i == 2)
803 { 803 {
804 UNBLOCK_INPUT; 804 unblock_input ();
805 XSETINT (ret, colorval); 805 XSETINT (ret, colorval);
806 return ret; 806 return ret;
807 } 807 }
@@ -855,7 +855,7 @@ x_to_w32_color (char * colorname)
855 { 855 {
856 if (*end != '\0') 856 if (*end != '\0')
857 break; 857 break;
858 UNBLOCK_INPUT; 858 unblock_input ();
859 XSETINT (ret, colorval); 859 XSETINT (ret, colorval);
860 return ret; 860 return ret;
861 } 861 }
@@ -897,7 +897,7 @@ x_to_w32_color (char * colorname)
897 { 897 {
898 if (*end != '\0') 898 if (*end != '\0')
899 break; 899 break;
900 UNBLOCK_INPUT; 900 unblock_input ();
901 XSETINT (ret, colorval); 901 XSETINT (ret, colorval);
902 return ret; 902 return ret;
903 } 903 }
@@ -932,7 +932,7 @@ x_to_w32_color (char * colorname)
932 } 932 }
933 } 933 }
934 934
935 UNBLOCK_INPUT; 935 unblock_input ();
936 return ret; 936 return ret;
937} 937}
938 938
@@ -1235,7 +1235,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1235 f->output_data.w32->mouse_pixel = FRAME_FOREGROUND_PIXEL (f); 1235 f->output_data.w32->mouse_pixel = FRAME_FOREGROUND_PIXEL (f);
1236 1236
1237#if 0 /* TODO : Mouse cursor customization. */ 1237#if 0 /* TODO : Mouse cursor customization. */
1238 BLOCK_INPUT; 1238 block_input ();
1239 1239
1240 /* It's not okay to crash if the user selects a screwy cursor. */ 1240 /* It's not okay to crash if the user selects a screwy cursor. */
1241 count = x_catch_errors (FRAME_W32_DISPLAY (f)); 1241 count = x_catch_errors (FRAME_W32_DISPLAY (f));
@@ -1358,7 +1358,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1358 f->output_data.w32->hand_cursor = hand_cursor; 1358 f->output_data.w32->hand_cursor = hand_cursor;
1359 1359
1360 XFlush (FRAME_W32_DISPLAY (f)); 1360 XFlush (FRAME_W32_DISPLAY (f));
1361 UNBLOCK_INPUT; 1361 unblock_input ();
1362 1362
1363 update_face_from_frame_parameter (f, Qmouse_color, arg); 1363 update_face_from_frame_parameter (f, Qmouse_color, arg);
1364#endif /* TODO */ 1364#endif /* TODO */
@@ -1390,12 +1390,12 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1390 1390
1391 if (FRAME_W32_WINDOW (f) != 0) 1391 if (FRAME_W32_WINDOW (f) != 0)
1392 { 1392 {
1393 BLOCK_INPUT; 1393 block_input ();
1394 /* Update frame's cursor_gc. */ 1394 /* Update frame's cursor_gc. */
1395 f->output_data.w32->cursor_gc->foreground = fore_pixel; 1395 f->output_data.w32->cursor_gc->foreground = fore_pixel;
1396 f->output_data.w32->cursor_gc->background = pixel; 1396 f->output_data.w32->cursor_gc->background = pixel;
1397 1397
1398 UNBLOCK_INPUT; 1398 unblock_input ();
1399 1399
1400 if (FRAME_VISIBLE_P (f)) 1400 if (FRAME_VISIBLE_P (f))
1401 { 1401 {
@@ -1466,16 +1466,16 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1466 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval)) 1466 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval))
1467 return; 1467 return;
1468 1468
1469 BLOCK_INPUT; 1469 block_input ();
1470 1470
1471 result = x_bitmap_icon (f, arg); 1471 result = x_bitmap_icon (f, arg);
1472 if (result) 1472 if (result)
1473 { 1473 {
1474 UNBLOCK_INPUT; 1474 unblock_input ();
1475 error ("No icon window available"); 1475 error ("No icon window available");
1476 } 1476 }
1477 1477
1478 UNBLOCK_INPUT; 1478 unblock_input ();
1479} 1479}
1480 1480
1481void 1481void
@@ -1495,7 +1495,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1495 if (f->output_data.w32->icon_bitmap != 0) 1495 if (f->output_data.w32->icon_bitmap != 0)
1496 return; 1496 return;
1497 1497
1498 BLOCK_INPUT; 1498 block_input ();
1499 1499
1500 result = x_text_icon (f, 1500 result = x_text_icon (f,
1501 SSDATA ((!NILP (f->icon_name) 1501 SSDATA ((!NILP (f->icon_name)
@@ -1506,7 +1506,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1506 1506
1507 if (result) 1507 if (result)
1508 { 1508 {
1509 UNBLOCK_INPUT; 1509 unblock_input ();
1510 error ("No icon window available"); 1510 error ("No icon window available");
1511 } 1511 }
1512 1512
@@ -1521,7 +1521,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1521 } 1521 }
1522 1522
1523 XFlush (FRAME_W32_DISPLAY (f)); 1523 XFlush (FRAME_W32_DISPLAY (f));
1524 UNBLOCK_INPUT; 1524 unblock_input ();
1525#endif 1525#endif
1526} 1526}
1527 1527
@@ -1623,13 +1623,13 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1623 int width = FRAME_PIXEL_WIDTH (f); 1623 int width = FRAME_PIXEL_WIDTH (f);
1624 int y = nlines * FRAME_LINE_HEIGHT (f); 1624 int y = nlines * FRAME_LINE_HEIGHT (f);
1625 1625
1626 BLOCK_INPUT; 1626 block_input ();
1627 { 1627 {
1628 HDC hdc = get_frame_dc (f); 1628 HDC hdc = get_frame_dc (f);
1629 w32_clear_area (f, hdc, 0, y, width, height); 1629 w32_clear_area (f, hdc, 0, y, width, height);
1630 release_frame_dc (f, hdc); 1630 release_frame_dc (f, hdc);
1631 } 1631 }
1632 UNBLOCK_INPUT; 1632 unblock_input ();
1633 1633
1634 if (WINDOWP (f->tool_bar_window)) 1634 if (WINDOWP (f->tool_bar_window))
1635 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); 1635 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
@@ -1697,9 +1697,9 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
1697 if (STRING_MULTIBYTE (name)) 1697 if (STRING_MULTIBYTE (name))
1698 name = ENCODE_SYSTEM (name); 1698 name = ENCODE_SYSTEM (name);
1699 1699
1700 BLOCK_INPUT; 1700 block_input ();
1701 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); 1701 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
1702 UNBLOCK_INPUT; 1702 unblock_input ();
1703 } 1703 }
1704} 1704}
1705 1705
@@ -1743,9 +1743,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
1743 if (STRING_MULTIBYTE (name)) 1743 if (STRING_MULTIBYTE (name))
1744 name = ENCODE_SYSTEM (name); 1744 name = ENCODE_SYSTEM (name);
1745 1745
1746 BLOCK_INPUT; 1746 block_input ();
1747 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); 1747 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
1748 UNBLOCK_INPUT; 1748 unblock_input ();
1749 } 1749 }
1750} 1750}
1751 1751
@@ -3896,7 +3896,7 @@ my_create_tip_window (struct frame *f)
3896static void 3896static void
3897w32_window (struct frame *f, long window_prompting, int minibuffer_only) 3897w32_window (struct frame *f, long window_prompting, int minibuffer_only)
3898{ 3898{
3899 BLOCK_INPUT; 3899 block_input ();
3900 3900
3901 /* Use the resource name as the top-level window name 3901 /* Use the resource name as the top-level window name
3902 for looking up resources. Make a non-Lisp copy 3902 for looking up resources. Make a non-Lisp copy
@@ -3928,7 +3928,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only)
3928 x_set_name (f, name, explicit); 3928 x_set_name (f, name, explicit);
3929 } 3929 }
3930 3930
3931 UNBLOCK_INPUT; 3931 unblock_input ();
3932 3932
3933 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f)) 3933 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
3934 initialize_frame_menubar (f); 3934 initialize_frame_menubar (f);
@@ -3959,7 +3959,7 @@ x_icon (struct frame *f, Lisp_Object parms)
3959 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound)) 3959 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
3960 error ("Both left and top icon corners of icon must be specified"); 3960 error ("Both left and top icon corners of icon must be specified");
3961 3961
3962 BLOCK_INPUT; 3962 block_input ();
3963 3963
3964 if (! EQ (icon_x, Qunbound)) 3964 if (! EQ (icon_x, Qunbound))
3965 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y)); 3965 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
@@ -3976,7 +3976,7 @@ x_icon (struct frame *f, Lisp_Object parms)
3976 : f->name))); 3976 : f->name)));
3977#endif 3977#endif
3978 3978
3979 UNBLOCK_INPUT; 3979 unblock_input ();
3980} 3980}
3981 3981
3982 3982
@@ -3985,7 +3985,7 @@ x_make_gc (struct frame *f)
3985{ 3985{
3986 XGCValues gc_values; 3986 XGCValues gc_values;
3987 3987
3988 BLOCK_INPUT; 3988 block_input ();
3989 3989
3990 /* Create the GC's of this frame. 3990 /* Create the GC's of this frame.
3991 Note that many default values are used. */ 3991 Note that many default values are used. */
@@ -4005,7 +4005,7 @@ x_make_gc (struct frame *f)
4005 f->output_data.w32->white_relief.gc = 0; 4005 f->output_data.w32->white_relief.gc = 0;
4006 f->output_data.w32->black_relief.gc = 0; 4006 f->output_data.w32->black_relief.gc = 0;
4007 4007
4008 UNBLOCK_INPUT; 4008 unblock_input ();
4009} 4009}
4010 4010
4011 4011
@@ -4351,9 +4351,9 @@ This function is an internal primitive--use `make-frame' instead. */)
4351 /* Tell the server what size and position, etc, we want, and how 4351 /* Tell the server what size and position, etc, we want, and how
4352 badly we want them. This should be done after we have the menu 4352 badly we want them. This should be done after we have the menu
4353 bar so that its size can be taken into account. */ 4353 bar so that its size can be taken into account. */
4354 BLOCK_INPUT; 4354 block_input ();
4355 x_wm_set_size_hint (f, window_prompting, 0); 4355 x_wm_set_size_hint (f, window_prompting, 0);
4356 UNBLOCK_INPUT; 4356 unblock_input ();
4357 4357
4358 /* Make the window appear on the frame and enable display, unless 4358 /* Make the window appear on the frame and enable display, unless
4359 the caller says not to. However, with explicit parent, Emacs 4359 the caller says not to. However, with explicit parent, Emacs
@@ -4862,11 +4862,11 @@ If DISPLAY is nil, that stands for the selected frame's display. */)
4862 if (dpyinfo->reference_count > 0) 4862 if (dpyinfo->reference_count > 0)
4863 error ("Display still has frames on it"); 4863 error ("Display still has frames on it");
4864 4864
4865 BLOCK_INPUT; 4865 block_input ();
4866 x_destroy_all_bitmaps (dpyinfo); 4866 x_destroy_all_bitmaps (dpyinfo);
4867 4867
4868 x_delete_display (dpyinfo); 4868 x_delete_display (dpyinfo);
4869 UNBLOCK_INPUT; 4869 unblock_input ();
4870 4870
4871 return Qnil; 4871 return Qnil;
4872} 4872}
@@ -4935,7 +4935,7 @@ FRAME. Default is to change on the edit X window. */)
4935 CHECK_STRING (prop); 4935 CHECK_STRING (prop);
4936 CHECK_STRING (value); 4936 CHECK_STRING (value);
4937 4937
4938 BLOCK_INPUT; 4938 block_input ();
4939 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False); 4939 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
4940 XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), 4940 XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
4941 prop_atom, XA_STRING, 8, PropModeReplace, 4941 prop_atom, XA_STRING, 8, PropModeReplace,
@@ -4943,7 +4943,7 @@ FRAME. Default is to change on the edit X window. */)
4943 4943
4944 /* Make sure the property is set when we return. */ 4944 /* Make sure the property is set when we return. */
4945 XFlush (FRAME_W32_DISPLAY (f)); 4945 XFlush (FRAME_W32_DISPLAY (f));
4946 UNBLOCK_INPUT; 4946 unblock_input ();
4947 4947
4948 return value; 4948 return value;
4949} 4949}
@@ -4959,13 +4959,13 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */)
4959 Atom prop_atom; 4959 Atom prop_atom;
4960 4960
4961 CHECK_STRING (prop); 4961 CHECK_STRING (prop);
4962 BLOCK_INPUT; 4962 block_input ();
4963 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False); 4963 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
4964 XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom); 4964 XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
4965 4965
4966 /* Make sure the property is removed when we return. */ 4966 /* Make sure the property is removed when we return. */
4967 XFlush (FRAME_W32_DISPLAY (f)); 4967 XFlush (FRAME_W32_DISPLAY (f));
4968 UNBLOCK_INPUT; 4968 unblock_input ();
4969 4969
4970 return prop; 4970 return prop;
4971} 4971}
@@ -5001,7 +5001,7 @@ no value of TYPE (always string in the MS Windows case). */)
5001 unsigned long actual_size, bytes_remaining; 5001 unsigned long actual_size, bytes_remaining;
5002 5002
5003 CHECK_STRING (prop); 5003 CHECK_STRING (prop);
5004 BLOCK_INPUT; 5004 block_input ();
5005 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False); 5005 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
5006 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), 5006 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
5007 prop_atom, 0, 0, False, XA_STRING, 5007 prop_atom, 0, 0, False, XA_STRING,
@@ -5026,7 +5026,7 @@ no value of TYPE (always string in the MS Windows case). */)
5026 XFree (tmp_data); 5026 XFree (tmp_data);
5027 } 5027 }
5028 5028
5029 UNBLOCK_INPUT; 5029 unblock_input ();
5030 5030
5031 return prop_value; 5031 return prop_value;
5032 5032
@@ -5349,9 +5349,9 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5349 f->left_fringe_width = 0; 5349 f->left_fringe_width = 0;
5350 f->right_fringe_width = 0; 5350 f->right_fringe_width = 0;
5351 5351
5352 BLOCK_INPUT; 5352 block_input ();
5353 my_create_tip_window (f); 5353 my_create_tip_window (f);
5354 UNBLOCK_INPUT; 5354 unblock_input ();
5355 5355
5356 x_make_gc (f); 5356 x_make_gc (f);
5357 5357
@@ -5457,11 +5457,11 @@ compute_tip_xy (struct frame *f,
5457 max_x = x_display_pixel_width (FRAME_W32_DISPLAY_INFO (f)); 5457 max_x = x_display_pixel_width (FRAME_W32_DISPLAY_INFO (f));
5458 max_y = x_display_pixel_height (FRAME_W32_DISPLAY_INFO (f)); 5458 max_y = x_display_pixel_height (FRAME_W32_DISPLAY_INFO (f));
5459 5459
5460 BLOCK_INPUT; 5460 block_input ();
5461 GetCursorPos (&pt); 5461 GetCursorPos (&pt);
5462 *root_x = pt.x; 5462 *root_x = pt.x;
5463 *root_y = pt.y; 5463 *root_y = pt.y;
5464 UNBLOCK_INPUT; 5464 unblock_input ();
5465 5465
5466 /* If multiple monitor support is available, constrain the tip onto 5466 /* If multiple monitor support is available, constrain the tip onto
5467 the current monitor. This improves the above by allowing negative 5467 the current monitor. This improves the above by allowing negative
@@ -5596,7 +5596,7 @@ Text larger than the specified size is clipped. */)
5596 call1 (Qcancel_timer, timer); 5596 call1 (Qcancel_timer, timer);
5597 } 5597 }
5598 5598
5599 BLOCK_INPUT; 5599 block_input ();
5600 compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f), 5600 compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
5601 FRAME_PIXEL_HEIGHT (f), &root_x, &root_y); 5601 FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
5602 5602
@@ -5610,7 +5610,7 @@ Text larger than the specified size is clipped. */)
5610 0, 0, 0, 0, 5610 0, 0, 0, 0,
5611 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 5611 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
5612 5612
5613 UNBLOCK_INPUT; 5613 unblock_input ();
5614 goto start_timer; 5614 goto start_timer;
5615 } 5615 }
5616 } 5616 }
@@ -5637,7 +5637,7 @@ Text larger than the specified size is clipped. */)
5637 5637
5638 /* Block input until the tip has been fully drawn, to avoid crashes 5638 /* Block input until the tip has been fully drawn, to avoid crashes
5639 when drawing tips in menus. */ 5639 when drawing tips in menus. */
5640 BLOCK_INPUT; 5640 block_input ();
5641 5641
5642 /* Create a frame for the tooltip, and record it in the global 5642 /* Create a frame for the tooltip, and record it in the global
5643 variable tip_frame. */ 5643 variable tip_frame. */
@@ -5809,7 +5809,7 @@ Text larger than the specified size is clipped. */)
5809 w->must_be_updated_p = 1; 5809 w->must_be_updated_p = 1;
5810 update_single_window (w, 1); 5810 update_single_window (w, 1);
5811 5811
5812 UNBLOCK_INPUT; 5812 unblock_input ();
5813 5813
5814 /* Restore original current buffer. */ 5814 /* Restore original current buffer. */
5815 set_buffer_internal_1 (old_buffer); 5815 set_buffer_internal_1 (old_buffer);
@@ -6002,7 +6002,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6002 6002
6003 /* Prevent redisplay. */ 6003 /* Prevent redisplay. */
6004 specbind (Qinhibit_redisplay, Qt); 6004 specbind (Qinhibit_redisplay, Qt);
6005 BLOCK_INPUT; 6005 block_input ();
6006 6006
6007 memset (&new_file_details, 0, sizeof (new_file_details)); 6007 memset (&new_file_details, 0, sizeof (new_file_details));
6008 /* Apparently NT4 crashes if you give it an unexpected size. 6008 /* Apparently NT4 crashes if you give it an unexpected size.
@@ -6041,7 +6041,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6041 6041
6042 file_opened = GetOpenFileName (file_details); 6042 file_opened = GetOpenFileName (file_details);
6043 6043
6044 UNBLOCK_INPUT; 6044 unblock_input ();
6045 6045
6046 if (file_opened) 6046 if (file_opened)
6047 { 6047 {
diff --git a/src/w32inevt.c b/src/w32inevt.c
index a96d8d70483..ebb95dcace5 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -567,7 +567,7 @@ w32_console_mouse_position (FRAME_PTR *f,
567 Lisp_Object *y, 567 Lisp_Object *y,
568 Time *time) 568 Time *time)
569{ 569{
570 BLOCK_INPUT; 570 block_input ();
571 571
572 insist = insist; 572 insist = insist;
573 573
@@ -580,7 +580,7 @@ w32_console_mouse_position (FRAME_PTR *f,
580 XSETINT (*y, movement_pos.Y); 580 XSETINT (*y, movement_pos.Y);
581 *time = movement_time; 581 *time = movement_time;
582 582
583 UNBLOCK_INPUT; 583 unblock_input ();
584} 584}
585 585
586/* Remember mouse motion and notify emacs. */ 586/* Remember mouse motion and notify emacs. */
@@ -749,14 +749,7 @@ w32_console_read_socket (struct terminal *terminal,
749 int nev, add; 749 int nev, add;
750 int isdead; 750 int isdead;
751 751
752 if (interrupt_input_blocked) 752 block_input ();
753 {
754 interrupt_input_pending = 1;
755 return -1;
756 }
757
758 interrupt_input_pending = 0;
759 BLOCK_INPUT;
760 753
761 for (;;) 754 for (;;)
762 { 755 {
@@ -818,6 +811,6 @@ w32_console_read_socket (struct terminal *terminal,
818 if (!w32_use_full_screen_buffer) 811 if (!w32_use_full_screen_buffer)
819 maybe_generate_resize_event (); 812 maybe_generate_resize_event ();
820 813
821 UNBLOCK_INPUT; 814 unblock_input ();
822 return nev; 815 return nev;
823} 816}
diff --git a/src/w32menu.c b/src/w32menu.c
index fa7db64f147..fb1cb606940 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -85,7 +85,7 @@ MessageBoxW_Proc unicode_message_box = NULL;
85 85
86Lisp_Object Qdebug_on_next_call; 86Lisp_Object Qdebug_on_next_call;
87 87
88void set_frame_menubar (FRAME_PTR, int, int); 88void set_frame_menubar (FRAME_PTR, bool, bool);
89 89
90#ifdef HAVE_DIALOGS 90#ifdef HAVE_DIALOGS
91static Lisp_Object w32_dialog_show (FRAME_PTR, int, Lisp_Object, char**); 91static Lisp_Object w32_dialog_show (FRAME_PTR, int, Lisp_Object, char**);
@@ -221,9 +221,9 @@ otherwise it is "Question". */)
221 list_of_panes (Fcons (contents, Qnil)); 221 list_of_panes (Fcons (contents, Qnil));
222 222
223 /* Display them in a dialog box. */ 223 /* Display them in a dialog box. */
224 BLOCK_INPUT; 224 block_input ();
225 selection = w32_dialog_show (f, 0, title, header, &error_name); 225 selection = w32_dialog_show (f, 0, title, header, &error_name);
226 UNBLOCK_INPUT; 226 unblock_input ();
227 227
228 discard_menu_items (); 228 discard_menu_items ();
229 FRAME_X_DISPLAY_INFO (f)->grabbed = 0; 229 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
@@ -356,7 +356,7 @@ menubar_selection_callback (FRAME_PTR f, void * client_data)
356 it is set the first time this is called, from initialize_frame_menubar. */ 356 it is set the first time this is called, from initialize_frame_menubar. */
357 357
358void 358void
359set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) 359set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
360{ 360{
361 HMENU menubar_widget = f->output_data.w32->menubar_widget; 361 HMENU menubar_widget = f->output_data.w32->menubar_widget;
362 Lisp_Object items; 362 Lisp_Object items;
@@ -571,7 +571,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
571 571
572 /* Create or update the menu bar widget. */ 572 /* Create or update the menu bar widget. */
573 573
574 BLOCK_INPUT; 574 block_input ();
575 575
576 if (menubar_widget) 576 if (menubar_widget)
577 { 577 {
@@ -601,7 +601,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
601 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); 601 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
602 } 602 }
603 603
604 UNBLOCK_INPUT; 604 unblock_input ();
605} 605}
606 606
607/* Called from Fx_create_frame to create the initial menubar of a frame 607/* Called from Fx_create_frame to create the initial menubar of a frame
@@ -624,7 +624,7 @@ initialize_frame_menubar (FRAME_PTR f)
624void 624void
625free_frame_menubar (FRAME_PTR f) 625free_frame_menubar (FRAME_PTR f)
626{ 626{
627 BLOCK_INPUT; 627 block_input ();
628 628
629 { 629 {
630 HMENU old = GetMenu (FRAME_W32_WINDOW (f)); 630 HMENU old = GetMenu (FRAME_W32_WINDOW (f));
@@ -633,7 +633,7 @@ free_frame_menubar (FRAME_PTR f)
633 DestroyMenu (old); 633 DestroyMenu (old);
634 } 634 }
635 635
636 UNBLOCK_INPUT; 636 unblock_input ();
637} 637}
638 638
639 639
diff --git a/src/w32proc.c b/src/w32proc.c
index 26a0925ad87..b367b42d8c6 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -86,19 +86,34 @@ typedef void (_CALLBACK_ *signal_handler) (int);
86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ 86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */
87static signal_handler sig_handlers[NSIG]; 87static signal_handler sig_handlers[NSIG];
88 88
89/* Fake signal implementation to record the SIGCHLD handler. */ 89/* Improve on the CRT 'signal' implementation so that we could record
90 the SIGCHLD handler. */
90signal_handler 91signal_handler
91sys_signal (int sig, signal_handler handler) 92sys_signal (int sig, signal_handler handler)
92{ 93{
93 signal_handler old; 94 signal_handler old;
94 95
95 if (sig != SIGCHLD) 96 /* SIGCHLD is needed for supporting subprocesses, see sys_kill
97 below. All the others are the only ones supported by the MS
98 runtime. */
99 if (!(sig == SIGCHLD || sig == SIGSEGV || sig == SIGILL
100 || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM))
96 { 101 {
97 errno = EINVAL; 102 errno = EINVAL;
98 return SIG_ERR; 103 return SIG_ERR;
99 } 104 }
100 old = sig_handlers[sig]; 105 old = sig_handlers[sig];
101 sig_handlers[sig] = handler; 106 /* SIGABRT is treated specially because w32.c installs term_ntproc
107 as its handler, so we don't want to override that afterwards.
108 Aborting Emacs works specially anyway: either by calling
109 emacs_abort directly or through terminate_due_to_signal, which
110 calls emacs_abort through emacs_raise. */
111 if (!(sig == SIGABRT && old == term_ntproc))
112 {
113 sig_handlers[sig] = handler;
114 if (sig != SIGCHLD)
115 signal (sig, handler);
116 }
102 return old; 117 return old;
103} 118}
104 119
@@ -106,23 +121,26 @@ sys_signal (int sig, signal_handler handler)
106int 121int
107sigaction (int sig, const struct sigaction *act, struct sigaction *oact) 122sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
108{ 123{
109 signal_handler old; 124 signal_handler old = SIG_DFL;
125 int retval = 0;
110 126
111 if (sig != SIGCHLD) 127 if (act)
128 old = sys_signal (sig, act->sa_handler);
129 else if (oact)
130 old = sig_handlers[sig];
131
132 if (old == SIG_ERR)
112 { 133 {
113 errno = EINVAL; 134 errno = EINVAL;
114 return -1; 135 retval = -1;
115 } 136 }
116 old = sig_handlers[sig];
117 if (act)
118 sig_handlers[sig] = act->sa_handler;
119 if (oact) 137 if (oact)
120 { 138 {
121 oact->sa_handler = old; 139 oact->sa_handler = old;
122 oact->sa_flags = 0; 140 oact->sa_flags = 0;
123 oact->sa_mask = empty_mask; 141 oact->sa_mask = empty_mask;
124 } 142 }
125 return 0; 143 return retval;
126} 144}
127 145
128/* Defined in <process.h> which conflicts with the local copy */ 146/* Defined in <process.h> which conflicts with the local copy */
@@ -1420,6 +1438,7 @@ find_child_console (HWND hwnd, LPARAM arg)
1420 return TRUE; 1438 return TRUE;
1421} 1439}
1422 1440
1441/* Emulate 'kill', but only for other processes. */
1423int 1442int
1424sys_kill (int pid, int sig) 1443sys_kill (int pid, int sig)
1425{ 1444{
@@ -1428,9 +1447,6 @@ sys_kill (int pid, int sig)
1428 int need_to_free = 0; 1447 int need_to_free = 0;
1429 int rc = 0; 1448 int rc = 0;
1430 1449
1431 if (pid == getpid () && sig == SIGABRT)
1432 emacs_abort ();
1433
1434 /* Only handle signals that will result in the process dying */ 1450 /* Only handle signals that will result in the process dying */
1435 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) 1451 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
1436 { 1452 {
@@ -1441,6 +1457,11 @@ sys_kill (int pid, int sig)
1441 cp = find_child_pid (pid); 1457 cp = find_child_pid (pid);
1442 if (cp == NULL) 1458 if (cp == NULL)
1443 { 1459 {
1460 /* We were passed a PID of something other than our subprocess.
1461 If that is our own PID, we will send to ourself a message to
1462 close the selected frame, which does not necessarily
1463 terminates Emacs. But then we are not supposed to call
1464 sys_kill with our own PID. */
1444 proc_hand = OpenProcess (PROCESS_TERMINATE, 0, pid); 1465 proc_hand = OpenProcess (PROCESS_TERMINATE, 0, pid);
1445 if (proc_hand == NULL) 1466 if (proc_hand == NULL)
1446 { 1467 {
diff --git a/src/w32reg.c b/src/w32reg.c
index 8a6a3c853b1..8b6c76503a6 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -84,7 +84,7 @@ w32_get_string_resource (char *name, char *class, DWORD dwexptype)
84 84
85 trykey: 85 trykey:
86 86
87 BLOCK_INPUT; 87 block_input ();
88 88
89 /* Check both the current user and the local machine to see if we have 89 /* Check both the current user and the local machine to see if we have
90 any resources */ 90 any resources */
@@ -115,7 +115,7 @@ w32_get_string_resource (char *name, char *class, DWORD dwexptype)
115 RegCloseKey (hrootkey); 115 RegCloseKey (hrootkey);
116 } 116 }
117 117
118 UNBLOCK_INPUT; 118 unblock_input ();
119 119
120 if (!ok) 120 if (!ok)
121 { 121 {
diff --git a/src/w32select.c b/src/w32select.c
index 11c68c9c617..66f9f7ab041 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -391,7 +391,7 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
391 extern int waiting_for_input; /* from keyboard.c */ 391 extern int waiting_for_input; /* from keyboard.c */
392 int owfi; 392 int owfi;
393 393
394 BLOCK_INPUT; 394 block_input ();
395 395
396 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is 396 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
397 set. */ 397 set. */
@@ -402,7 +402,7 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
402 402
403 waiting_for_input = owfi; 403 waiting_for_input = owfi;
404 404
405 UNBLOCK_INPUT; 405 unblock_input ();
406} 406}
407 407
408static Lisp_Object 408static Lisp_Object
@@ -474,7 +474,10 @@ term_w32select (void)
474{ 474{
475 /* This is needed to trigger WM_RENDERALLFORMATS. */ 475 /* This is needed to trigger WM_RENDERALLFORMATS. */
476 if (clipboard_owner != NULL) 476 if (clipboard_owner != NULL)
477 DestroyWindow (clipboard_owner); 477 {
478 DestroyWindow (clipboard_owner);
479 clipboard_owner = NULL;
480 }
478} 481}
479 482
480static void 483static void
@@ -694,7 +697,7 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
694 current_num_nls = 0; 697 current_num_nls = 0;
695 current_requires_encoding = 0; 698 current_requires_encoding = 0;
696 699
697 BLOCK_INPUT; 700 block_input ();
698 701
699 /* Check for non-ASCII characters. While we are at it, count the 702 /* Check for non-ASCII characters. While we are at it, count the
700 number of LFs, so we know how many CRs we will have to add later 703 number of LFs, so we know how many CRs we will have to add later
@@ -782,7 +785,7 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
782 current_coding_system = Qnil; 785 current_coding_system = Qnil;
783 786
784 done: 787 done:
785 UNBLOCK_INPUT; 788 unblock_input ();
786 789
787 return (ok ? string : Qnil); 790 return (ok ? string : Qnil);
788} 791}
@@ -810,7 +813,7 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
810 setup_config (); 813 setup_config ();
811 actual_clipboard_type = cfg_clipboard_type; 814 actual_clipboard_type = cfg_clipboard_type;
812 815
813 BLOCK_INPUT; 816 block_input ();
814 817
815 if (!OpenClipboard (clipboard_owner)) 818 if (!OpenClipboard (clipboard_owner))
816 goto done; 819 goto done;
@@ -1000,7 +1003,7 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
1000 CloseClipboard (); 1003 CloseClipboard ();
1001 1004
1002 done: 1005 done:
1003 UNBLOCK_INPUT; 1006 unblock_input ();
1004 1007
1005 return (ret); 1008 return (ret);
1006} 1009}
diff --git a/src/w32term.c b/src/w32term.c
index b8227c52fed..5d5e572c475 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -197,7 +197,7 @@ static void w32_define_cursor (Window, Cursor);
197 197
198void x_lower_frame (struct frame *); 198void x_lower_frame (struct frame *);
199void x_scroll_bar_clear (struct frame *); 199void x_scroll_bar_clear (struct frame *);
200void x_wm_set_size_hint (struct frame *, long, int); 200void x_wm_set_size_hint (struct frame *, long, bool);
201void x_raise_frame (struct frame *); 201void x_raise_frame (struct frame *);
202void x_set_window_size (struct frame *, int, int, int); 202void x_set_window_size (struct frame *, int, int, int);
203void x_wm_set_window_state (struct frame *, int); 203void x_wm_set_window_state (struct frame *, int);
@@ -563,7 +563,7 @@ x_update_window_begin (struct window *w)
563 updated_window = w; 563 updated_window = w;
564 set_output_cursor (&w->cursor); 564 set_output_cursor (&w->cursor);
565 565
566 BLOCK_INPUT; 566 block_input ();
567 567
568 if (f == hlinfo->mouse_face_mouse_frame) 568 if (f == hlinfo->mouse_face_mouse_frame)
569 { 569 {
@@ -602,7 +602,7 @@ x_update_window_begin (struct window *w)
602#endif /* 0 */ 602#endif /* 0 */
603 } 603 }
604 604
605 UNBLOCK_INPUT; 605 unblock_input ();
606} 606}
607 607
608/* Draw a vertical window border from (x,y0) to (x,y1) */ 608/* Draw a vertical window border from (x,y0) to (x,y1) */
@@ -652,7 +652,7 @@ x_update_window_end (struct window *w, int cursor_on_p,
652 652
653 if (!w->pseudo_window_p) 653 if (!w->pseudo_window_p)
654 { 654 {
655 BLOCK_INPUT; 655 block_input ();
656 656
657 if (cursor_on_p) 657 if (cursor_on_p)
658 display_and_set_cursor (w, 1, output_cursor.hpos, 658 display_and_set_cursor (w, 1, output_cursor.hpos,
@@ -662,7 +662,7 @@ x_update_window_end (struct window *w, int cursor_on_p,
662 if (draw_window_fringes (w, 1)) 662 if (draw_window_fringes (w, 1))
663 x_draw_vertical_border (w); 663 x_draw_vertical_border (w);
664 664
665 UNBLOCK_INPUT; 665 unblock_input ();
666 } 666 }
667 667
668 /* If a row with mouse-face was overwritten, arrange for 668 /* If a row with mouse-face was overwritten, arrange for
@@ -714,13 +714,13 @@ w32_frame_up_to_date (struct frame *f)
714 if (hlinfo->mouse_face_deferred_gc 714 if (hlinfo->mouse_face_deferred_gc
715 || f == hlinfo->mouse_face_mouse_frame) 715 || f == hlinfo->mouse_face_mouse_frame)
716 { 716 {
717 BLOCK_INPUT; 717 block_input ();
718 if (hlinfo->mouse_face_mouse_frame) 718 if (hlinfo->mouse_face_mouse_frame)
719 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, 719 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
720 hlinfo->mouse_face_mouse_x, 720 hlinfo->mouse_face_mouse_x,
721 hlinfo->mouse_face_mouse_y); 721 hlinfo->mouse_face_mouse_y);
722 hlinfo->mouse_face_deferred_gc = 0; 722 hlinfo->mouse_face_deferred_gc = 0;
723 UNBLOCK_INPUT; 723 unblock_input ();
724 } 724 }
725 } 725 }
726} 726}
@@ -761,7 +761,7 @@ x_after_update_window_line (struct glyph_row *desired_row)
761 { 761 {
762 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 762 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
763 763
764 BLOCK_INPUT; 764 block_input ();
765 { 765 {
766 HDC hdc = get_frame_dc (f); 766 HDC hdc = get_frame_dc (f);
767 w32_clear_area (f, hdc, 0, y, width, height); 767 w32_clear_area (f, hdc, 0, y, width, height);
@@ -769,7 +769,7 @@ x_after_update_window_line (struct glyph_row *desired_row)
769 y, width, height); 769 y, width, height);
770 release_frame_dc (f, hdc); 770 release_frame_dc (f, hdc);
771 } 771 }
772 UNBLOCK_INPUT; 772 unblock_input ();
773 } 773 }
774} 774}
775 775
@@ -2646,7 +2646,7 @@ x_clear_frame (struct frame *f)
2646 2646
2647 /* We don't set the output cursor here because there will always 2647 /* We don't set the output cursor here because there will always
2648 follow an explicit cursor_to. */ 2648 follow an explicit cursor_to. */
2649 BLOCK_INPUT; 2649 block_input ();
2650 2650
2651 w32_clear_window (f); 2651 w32_clear_window (f);
2652 2652
@@ -2654,7 +2654,7 @@ x_clear_frame (struct frame *f)
2654 colors or something like that, then they should be notified. */ 2654 colors or something like that, then they should be notified. */
2655 x_scroll_bar_clear (f); 2655 x_scroll_bar_clear (f);
2656 2656
2657 UNBLOCK_INPUT; 2657 unblock_input ();
2658} 2658}
2659 2659
2660 2660
@@ -2663,7 +2663,7 @@ x_clear_frame (struct frame *f)
2663static void 2663static void
2664w32_ring_bell (struct frame *f) 2664w32_ring_bell (struct frame *f)
2665{ 2665{
2666 BLOCK_INPUT; 2666 block_input ();
2667 2667
2668 if (FRAME_W32_P (f) && visible_bell) 2668 if (FRAME_W32_P (f) && visible_bell)
2669 { 2669 {
@@ -2680,7 +2680,7 @@ w32_ring_bell (struct frame *f)
2680 else 2680 else
2681 w32_sys_ring_bell (f); 2681 w32_sys_ring_bell (f);
2682 2682
2683 UNBLOCK_INPUT; 2683 unblock_input ();
2684} 2684}
2685 2685
2686 2686
@@ -2779,7 +2779,7 @@ x_scroll_run (struct window *w, struct run *run)
2779 expect_dirty = CreateRectRgn (x, y, x + width, to_y); 2779 expect_dirty = CreateRectRgn (x, y, x + width, to_y);
2780 } 2780 }
2781 2781
2782 BLOCK_INPUT; 2782 block_input ();
2783 2783
2784 /* Cursor off. Will be switched on again in x_update_window_end. */ 2784 /* Cursor off. Will be switched on again in x_update_window_end. */
2785 updated_window = w; 2785 updated_window = w;
@@ -2813,7 +2813,7 @@ x_scroll_run (struct window *w, struct run *run)
2813 DeleteObject (combined); 2813 DeleteObject (combined);
2814 } 2814 }
2815 2815
2816 UNBLOCK_INPUT; 2816 unblock_input ();
2817 DeleteObject (expect_dirty); 2817 DeleteObject (expect_dirty);
2818} 2818}
2819 2819
@@ -2998,9 +2998,9 @@ x_get_keysym_name (int keysym)
2998 /* Make static so we can always return it */ 2998 /* Make static so we can always return it */
2999 static char value[100]; 2999 static char value[100];
3000 3000
3001 BLOCK_INPUT; 3001 block_input ();
3002 GetKeyNameText (keysym, value, 100); 3002 GetKeyNameText (keysym, value, 100);
3003 UNBLOCK_INPUT; 3003 unblock_input ();
3004 3004
3005 return value; 3005 return value;
3006} 3006}
@@ -3308,7 +3308,7 @@ w32_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
3308{ 3308{
3309 FRAME_PTR f1; 3309 FRAME_PTR f1;
3310 3310
3311 BLOCK_INPUT; 3311 block_input ();
3312 3312
3313 if (! NILP (last_mouse_scroll_bar) && insist == 0) 3313 if (! NILP (last_mouse_scroll_bar) && insist == 0)
3314 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); 3314 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
@@ -3382,7 +3382,7 @@ w32_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
3382 } 3382 }
3383 } 3383 }
3384 3384
3385 UNBLOCK_INPUT; 3385 unblock_input ();
3386} 3386}
3387 3387
3388 3388
@@ -3480,12 +3480,12 @@ w32_set_scroll_bar_thumb (struct scroll_bar *bar,
3480 if (draggingp) 3480 if (draggingp)
3481 { 3481 {
3482 int near_bottom_p; 3482 int near_bottom_p;
3483 BLOCK_INPUT; 3483 block_input ();
3484 si.cbSize = sizeof (si); 3484 si.cbSize = sizeof (si);
3485 si.fMask = SIF_POS | SIF_PAGE; 3485 si.fMask = SIF_POS | SIF_PAGE;
3486 GetScrollInfo (w, SB_CTL, &si); 3486 GetScrollInfo (w, SB_CTL, &si);
3487 near_bottom_p = si.nPos + si.nPage >= range; 3487 near_bottom_p = si.nPos + si.nPage >= range;
3488 UNBLOCK_INPUT; 3488 unblock_input ();
3489 if (!near_bottom_p) 3489 if (!near_bottom_p)
3490 return; 3490 return;
3491 } 3491 }
@@ -3514,7 +3514,7 @@ w32_set_scroll_bar_thumb (struct scroll_bar *bar,
3514 3514
3515 sb_page = max (sb_page, VERTICAL_SCROLL_BAR_MIN_HANDLE); 3515 sb_page = max (sb_page, VERTICAL_SCROLL_BAR_MIN_HANDLE);
3516 3516
3517 BLOCK_INPUT; 3517 block_input ();
3518 3518
3519 si.cbSize = sizeof (si); 3519 si.cbSize = sizeof (si);
3520 si.fMask = SIF_PAGE | SIF_POS; 3520 si.fMask = SIF_PAGE | SIF_POS;
@@ -3523,7 +3523,7 @@ w32_set_scroll_bar_thumb (struct scroll_bar *bar,
3523 3523
3524 SetScrollInfo (w, SB_CTL, &si, TRUE); 3524 SetScrollInfo (w, SB_CTL, &si, TRUE);
3525 3525
3526 UNBLOCK_INPUT; 3526 unblock_input ();
3527} 3527}
3528 3528
3529 3529
@@ -3614,7 +3614,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
3614 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 3614 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
3615 Lisp_Object barobj; 3615 Lisp_Object barobj;
3616 3616
3617 BLOCK_INPUT; 3617 block_input ();
3618 3618
3619 XSETWINDOW (bar->window, w); 3619 XSETWINDOW (bar->window, w);
3620 XSETINT (bar->top, top); 3620 XSETINT (bar->top, top);
@@ -3650,7 +3650,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
3650 if (! NILP (bar->next)) 3650 if (! NILP (bar->next))
3651 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); 3651 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
3652 3652
3653 UNBLOCK_INPUT; 3653 unblock_input ();
3654 3654
3655 return bar; 3655 return bar;
3656} 3656}
@@ -3664,7 +3664,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
3664{ 3664{
3665 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 3665 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
3666 3666
3667 BLOCK_INPUT; 3667 block_input ();
3668 3668
3669 /* Destroy the window. */ 3669 /* Destroy the window. */
3670 my_destroy_window (f, SCROLL_BAR_W32_WINDOW (bar)); 3670 my_destroy_window (f, SCROLL_BAR_W32_WINDOW (bar));
@@ -3672,7 +3672,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
3672 /* Dissociate this scroll bar from its window. */ 3672 /* Dissociate this scroll bar from its window. */
3673 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil); 3673 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil);
3674 3674
3675 UNBLOCK_INPUT; 3675 unblock_input ();
3676} 3676}
3677 3677
3678/* Set the handle of the vertical scroll bar for WINDOW to indicate 3678/* Set the handle of the vertical scroll bar for WINDOW to indicate
@@ -3727,7 +3727,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3727 if (NILP (w->vertical_scroll_bar)) 3727 if (NILP (w->vertical_scroll_bar))
3728 { 3728 {
3729 HDC hdc; 3729 HDC hdc;
3730 BLOCK_INPUT; 3730 block_input ();
3731 if (width > 0 && height > 0) 3731 if (width > 0 && height > 0)
3732 { 3732 {
3733 hdc = get_frame_dc (f); 3733 hdc = get_frame_dc (f);
@@ -3737,7 +3737,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3737 w32_clear_area (f, hdc, left, top, width, height); 3737 w32_clear_area (f, hdc, left, top, width, height);
3738 release_frame_dc (f, hdc); 3738 release_frame_dc (f, hdc);
3739 } 3739 }
3740 UNBLOCK_INPUT; 3740 unblock_input ();
3741 3741
3742 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height); 3742 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
3743 } 3743 }
@@ -3765,7 +3765,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3765 HDC hdc; 3765 HDC hdc;
3766 SCROLLINFO si; 3766 SCROLLINFO si;
3767 3767
3768 BLOCK_INPUT; 3768 block_input ();
3769 if (width && height) 3769 if (width && height)
3770 { 3770 {
3771 hdc = get_frame_dc (f); 3771 hdc = get_frame_dc (f);
@@ -3801,7 +3801,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3801 XSETINT (bar->width, sb_width); 3801 XSETINT (bar->width, sb_width);
3802 XSETINT (bar->height, height); 3802 XSETINT (bar->height, height);
3803 3803
3804 UNBLOCK_INPUT; 3804 unblock_input ();
3805 } 3805 }
3806 } 3806 }
3807 bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil; 3807 bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil;
@@ -4043,7 +4043,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
4043 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 4043 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
4044 SCROLLINFO si; 4044 SCROLLINFO si;
4045 4045
4046 BLOCK_INPUT; 4046 block_input ();
4047 4047
4048 *fp = f; 4048 *fp = f;
4049 *bar_window = bar->window; 4049 *bar_window = bar->window;
@@ -4080,7 +4080,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
4080 4080
4081 *time = last_mouse_movement_time; 4081 *time = last_mouse_movement_time;
4082 4082
4083 UNBLOCK_INPUT; 4083 unblock_input ();
4084} 4084}
4085 4085
4086 4086
@@ -4157,15 +4157,7 @@ w32_read_socket (struct terminal *terminal,
4157 struct w32_display_info *dpyinfo = &one_w32_display_info; 4157 struct w32_display_info *dpyinfo = &one_w32_display_info;
4158 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 4158 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
4159 4159
4160 if (interrupt_input_blocked) 4160 block_input ();
4161 {
4162 interrupt_input_pending = 1;
4163 pending_signals = 1;
4164 return -1;
4165 }
4166
4167 interrupt_input_pending = 0;
4168 BLOCK_INPUT;
4169 4161
4170 /* So people can tell when we have read the available input. */ 4162 /* So people can tell when we have read the available input. */
4171 input_signal_count++; 4163 input_signal_count++;
@@ -4961,7 +4953,7 @@ w32_read_socket (struct terminal *terminal,
4961 } 4953 }
4962 } 4954 }
4963 4955
4964 UNBLOCK_INPUT; 4956 unblock_input ();
4965 return count; 4957 return count;
4966} 4958}
4967 4959
@@ -5476,7 +5468,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff,
5476 } 5468 }
5477 x_calc_absolute_position (f); 5469 x_calc_absolute_position (f);
5478 5470
5479 BLOCK_INPUT; 5471 block_input ();
5480 x_wm_set_size_hint (f, (long) 0, 0); 5472 x_wm_set_size_hint (f, (long) 0, 0);
5481 5473
5482 modified_left = f->left_pos; 5474 modified_left = f->left_pos;
@@ -5487,7 +5479,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff,
5487 modified_left, modified_top, 5479 modified_left, modified_top,
5488 0, 0, 5480 0, 0,
5489 SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); 5481 SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
5490 UNBLOCK_INPUT; 5482 unblock_input ();
5491} 5483}
5492 5484
5493 5485
@@ -5528,7 +5520,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
5528{ 5520{
5529 int pixelwidth, pixelheight; 5521 int pixelwidth, pixelheight;
5530 5522
5531 BLOCK_INPUT; 5523 block_input ();
5532 5524
5533 check_frame_size (f, &rows, &cols); 5525 check_frame_size (f, &rows, &cols);
5534 f->scroll_bar_actual_width 5526 f->scroll_bar_actual_width
@@ -5608,7 +5600,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
5608 cancel_mouse_face (f); 5600 cancel_mouse_face (f);
5609#endif 5601#endif
5610 5602
5611 UNBLOCK_INPUT; 5603 unblock_input ();
5612} 5604}
5613 5605
5614/* Mouse warping. */ 5606/* Mouse warping. */
@@ -5638,7 +5630,7 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
5638 RECT rect; 5630 RECT rect;
5639 POINT pt; 5631 POINT pt;
5640 5632
5641 BLOCK_INPUT; 5633 block_input ();
5642 5634
5643 GetClientRect (FRAME_W32_WINDOW (f), &rect); 5635 GetClientRect (FRAME_W32_WINDOW (f), &rect);
5644 pt.x = rect.left + pix_x; 5636 pt.x = rect.left + pix_x;
@@ -5647,7 +5639,7 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
5647 5639
5648 SetCursorPos (pt.x, pt.y); 5640 SetCursorPos (pt.x, pt.y);
5649 5641
5650 UNBLOCK_INPUT; 5642 unblock_input ();
5651} 5643}
5652 5644
5653 5645
@@ -5659,7 +5651,7 @@ x_focus_on_frame (struct frame *f)
5659 struct w32_display_info *dpyinfo = &one_w32_display_info; 5651 struct w32_display_info *dpyinfo = &one_w32_display_info;
5660 5652
5661 /* Give input focus to frame. */ 5653 /* Give input focus to frame. */
5662 BLOCK_INPUT; 5654 block_input ();
5663#if 0 5655#if 0
5664 /* Try not to change its Z-order if possible. */ 5656 /* Try not to change its Z-order if possible. */
5665 if (x_window_to_frame (dpyinfo, GetForegroundWindow ())) 5657 if (x_window_to_frame (dpyinfo, GetForegroundWindow ()))
@@ -5667,7 +5659,7 @@ x_focus_on_frame (struct frame *f)
5667 else 5659 else
5668#endif 5660#endif
5669 my_set_foreground_window (FRAME_W32_WINDOW (f)); 5661 my_set_foreground_window (FRAME_W32_WINDOW (f));
5670 UNBLOCK_INPUT; 5662 unblock_input ();
5671} 5663}
5672 5664
5673void 5665void
@@ -5679,7 +5671,7 @@ x_unfocus_frame (struct frame *f)
5679void 5671void
5680x_raise_frame (struct frame *f) 5672x_raise_frame (struct frame *f)
5681{ 5673{
5682 BLOCK_INPUT; 5674 block_input ();
5683 5675
5684 /* Strictly speaking, raise-frame should only change the frame's Z 5676 /* Strictly speaking, raise-frame should only change the frame's Z
5685 order, leaving input focus unchanged. This is reasonable behavior 5677 order, leaving input focus unchanged. This is reasonable behavior
@@ -5734,19 +5726,19 @@ x_raise_frame (struct frame *f)
5734 my_bring_window_to_top (FRAME_W32_WINDOW (f)); 5726 my_bring_window_to_top (FRAME_W32_WINDOW (f));
5735 } 5727 }
5736 5728
5737 UNBLOCK_INPUT; 5729 unblock_input ();
5738} 5730}
5739 5731
5740/* Lower frame F. */ 5732/* Lower frame F. */
5741void 5733void
5742x_lower_frame (struct frame *f) 5734x_lower_frame (struct frame *f)
5743{ 5735{
5744 BLOCK_INPUT; 5736 block_input ();
5745 my_set_window_pos (FRAME_W32_WINDOW (f), 5737 my_set_window_pos (FRAME_W32_WINDOW (f),
5746 HWND_BOTTOM, 5738 HWND_BOTTOM,
5747 0, 0, 0, 0, 5739 0, 0, 0, 0,
5748 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); 5740 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
5749 UNBLOCK_INPUT; 5741 unblock_input ();
5750} 5742}
5751 5743
5752static void 5744static void
@@ -5775,7 +5767,7 @@ x_make_frame_visible (struct frame *f)
5775{ 5767{
5776 Lisp_Object type; 5768 Lisp_Object type;
5777 5769
5778 BLOCK_INPUT; 5770 block_input ();
5779 5771
5780 type = x_icon_type (f); 5772 type = x_icon_type (f);
5781 if (!NILP (type)) 5773 if (!NILP (type))
@@ -5827,7 +5819,7 @@ x_make_frame_visible (struct frame *f)
5827 int count; 5819 int count;
5828 5820
5829 /* This must come after we set COUNT. */ 5821 /* This must come after we set COUNT. */
5830 UNBLOCK_INPUT; 5822 unblock_input ();
5831 5823
5832 XSETFRAME (frame, f); 5824 XSETFRAME (frame, f);
5833 5825
@@ -5870,7 +5862,7 @@ x_make_frame_invisible (struct frame *f)
5870 if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f) 5862 if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f)
5871 FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0; 5863 FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0;
5872 5864
5873 BLOCK_INPUT; 5865 block_input ();
5874 5866
5875 my_show_window (f, FRAME_W32_WINDOW (f), SW_HIDE); 5867 my_show_window (f, FRAME_W32_WINDOW (f), SW_HIDE);
5876 5868
@@ -5884,7 +5876,7 @@ x_make_frame_invisible (struct frame *f)
5884 f->async_visible = 0; 5876 f->async_visible = 0;
5885 f->async_iconified = 0; 5877 f->async_iconified = 0;
5886 5878
5887 UNBLOCK_INPUT; 5879 unblock_input ();
5888} 5880}
5889 5881
5890/* Change window state from mapped to iconified. */ 5882/* Change window state from mapped to iconified. */
@@ -5901,7 +5893,7 @@ x_iconify_frame (struct frame *f)
5901 if (f->async_iconified) 5893 if (f->async_iconified)
5902 return; 5894 return;
5903 5895
5904 BLOCK_INPUT; 5896 block_input ();
5905 5897
5906 type = x_icon_type (f); 5898 type = x_icon_type (f);
5907 if (!NILP (type)) 5899 if (!NILP (type))
@@ -5910,7 +5902,7 @@ x_iconify_frame (struct frame *f)
5910 /* Simulate the user minimizing the frame. */ 5902 /* Simulate the user minimizing the frame. */
5911 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MINIMIZE, 0); 5903 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MINIMIZE, 0);
5912 5904
5913 UNBLOCK_INPUT; 5905 unblock_input ();
5914} 5906}
5915 5907
5916 5908
@@ -5922,7 +5914,7 @@ x_free_frame_resources (struct frame *f)
5922 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 5914 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
5923 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 5915 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
5924 5916
5925 BLOCK_INPUT; 5917 block_input ();
5926 5918
5927 /* We must free faces before destroying windows because some 5919 /* We must free faces before destroying windows because some
5928 font-driver (e.g. xft) access a window while finishing a 5920 font-driver (e.g. xft) access a window while finishing a
@@ -5970,7 +5962,7 @@ x_free_frame_resources (struct frame *f)
5970 hlinfo->mouse_face_mouse_frame = 0; 5962 hlinfo->mouse_face_mouse_frame = 0;
5971 } 5963 }
5972 5964
5973 UNBLOCK_INPUT; 5965 unblock_input ();
5974} 5966}
5975 5967
5976 5968
@@ -5990,10 +5982,10 @@ x_destroy_window (struct frame *f)
5990/* Set the normal size hints for the window manager, for frame F. 5982/* Set the normal size hints for the window manager, for frame F.
5991 FLAGS is the flags word to use--or 0 meaning preserve the flags 5983 FLAGS is the flags word to use--or 0 meaning preserve the flags
5992 that the window now has. 5984 that the window now has.
5993 If USER_POSITION is nonzero, we set the USPosition 5985 If USER_POSITION, set the USPosition
5994 flag (this is useful when FLAGS is 0). */ 5986 flag (this is useful when FLAGS is 0). */
5995void 5987void
5996x_wm_set_size_hint (struct frame *f, long flags, int user_position) 5988x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
5997{ 5989{
5998 Window window = FRAME_W32_WINDOW (f); 5990 Window window = FRAME_W32_WINDOW (f);
5999 5991
@@ -6254,10 +6246,10 @@ x_delete_terminal (struct terminal *terminal)
6254 if (!terminal->name) 6246 if (!terminal->name)
6255 return; 6247 return;
6256 6248
6257 BLOCK_INPUT; 6249 block_input ();
6258 6250
6259 x_delete_display (dpyinfo); 6251 x_delete_display (dpyinfo);
6260 UNBLOCK_INPUT; 6252 unblock_input ();
6261} 6253}
6262 6254
6263struct w32_display_info * 6255struct w32_display_info *
@@ -6267,7 +6259,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6267 struct terminal *terminal; 6259 struct terminal *terminal;
6268 HDC hdc; 6260 HDC hdc;
6269 6261
6270 BLOCK_INPUT; 6262 block_input ();
6271 6263
6272 if (!w32_initialized) 6264 if (!w32_initialized)
6273 { 6265 {
@@ -6329,7 +6321,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6329 init_sigio (connection); 6321 init_sigio (connection);
6330#endif /* ! defined (SIGIO) */ 6322#endif /* ! defined (SIGIO) */
6331 6323
6332 UNBLOCK_INPUT; 6324 unblock_input ();
6333 6325
6334 return dpyinfo; 6326 return dpyinfo;
6335} 6327}
diff --git a/src/widget.c b/src/widget.c
index fd5ad167125..1f472c6231c 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -677,13 +677,13 @@ EmacsFrameDestroy (Widget widget)
677 if (! s) emacs_abort (); 677 if (! s) emacs_abort ();
678 if (! s->output_data.x) emacs_abort (); 678 if (! s->output_data.x) emacs_abort ();
679 679
680 BLOCK_INPUT; 680 block_input ();
681 x_free_gcs (s); 681 x_free_gcs (s);
682 if (s->output_data.x->white_relief.gc) 682 if (s->output_data.x->white_relief.gc)
683 XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc); 683 XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc);
684 if (s->output_data.x->black_relief.gc) 684 if (s->output_data.x->black_relief.gc)
685 XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc); 685 XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc);
686 UNBLOCK_INPUT; 686 unblock_input ();
687} 687}
688 688
689static void 689static void
diff --git a/src/window.c b/src/window.c
index 6798be8231c..bb3b73f9acd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -60,7 +60,7 @@ static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
60static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 60static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
61static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; 61static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
62static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 62static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
63static Lisp_Object Qsafe, Qabove, Qbelow, Qtemp_buffer_resize, Qclone_of; 63static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
64 64
65static int displayed_window_lines (struct window *); 65static int displayed_window_lines (struct window *);
66static int count_windows (struct window *); 66static int count_windows (struct window *);
@@ -2819,7 +2819,7 @@ window-start value is reasonable when this function is called. */)
2819 } 2819 }
2820 } 2820 }
2821 2821
2822 BLOCK_INPUT; 2822 block_input ();
2823 if (!FRAME_INITIAL_P (f)) 2823 if (!FRAME_INITIAL_P (f))
2824 { 2824 {
2825 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 2825 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
@@ -2961,7 +2961,7 @@ window-start value is reasonable when this function is called. */)
2961 } 2961 }
2962 2962
2963 adjust_glyphs (f); 2963 adjust_glyphs (f);
2964 UNBLOCK_INPUT; 2964 unblock_input ();
2965 2965
2966 run_window_configuration_change_hook (f); 2966 run_window_configuration_change_hook (f);
2967 2967
@@ -3696,14 +3696,14 @@ be applied on the Elisp level. */)
3696 (horflag ? r->total_cols : r->total_lines))) 3696 (horflag ? r->total_cols : r->total_lines)))
3697 return Qnil; 3697 return Qnil;
3698 3698
3699 BLOCK_INPUT; 3699 block_input ();
3700 window_resize_apply (r, horflag); 3700 window_resize_apply (r, horflag);
3701 3701
3702 windows_or_buffers_changed++; 3702 windows_or_buffers_changed++;
3703 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 3703 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
3704 3704
3705 adjust_glyphs (f); 3705 adjust_glyphs (f);
3706 UNBLOCK_INPUT; 3706 unblock_input ();
3707 3707
3708 run_window_configuration_change_hook (f); 3708 run_window_configuration_change_hook (f);
3709 3709
@@ -3973,13 +3973,13 @@ set correctly. See the code of `split-window' for how this is done. */)
3973 wset_new_total (n, total_size); 3973 wset_new_total (n, total_size);
3974 wset_new_normal (n, normal_size); 3974 wset_new_normal (n, normal_size);
3975 3975
3976 BLOCK_INPUT; 3976 block_input ();
3977 window_resize_apply (p, horflag); 3977 window_resize_apply (p, horflag);
3978 adjust_glyphs (f); 3978 adjust_glyphs (f);
3979 /* Set buffer of NEW to buffer of reference window. Don't run 3979 /* Set buffer of NEW to buffer of reference window. Don't run
3980 any hooks. */ 3980 any hooks. */
3981 set_window_buffer (new, r->buffer, 0, 1); 3981 set_window_buffer (new, r->buffer, 0, 1);
3982 UNBLOCK_INPUT; 3982 unblock_input ();
3983 3983
3984 /* Maybe we should run the scroll functions in Elisp (which already 3984 /* Maybe we should run the scroll functions in Elisp (which already
3985 runs the configuration change hook). */ 3985 runs the configuration change hook). */
@@ -4060,7 +4060,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4060 { 4060 {
4061 4061
4062 /* Block input. */ 4062 /* Block input. */
4063 BLOCK_INPUT; 4063 block_input ();
4064 window_resize_apply (p, horflag); 4064 window_resize_apply (p, horflag);
4065 4065
4066 /* If this window is referred to by the dpyinfo's mouse 4066 /* If this window is referred to by the dpyinfo's mouse
@@ -4132,7 +4132,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4132 else 4132 else
4133 fset_selected_window (f, new_selected_window); 4133 fset_selected_window (f, new_selected_window);
4134 4134
4135 UNBLOCK_INPUT; 4135 unblock_input ();
4136 4136
4137 /* Now look whether `get-mru-window' gets us something. */ 4137 /* Now look whether `get-mru-window' gets us something. */
4138 mru_window = call1 (Qget_mru_window, frame); 4138 mru_window = call1 (Qget_mru_window, frame);
@@ -4147,7 +4147,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4147 fset_selected_window (f, new_selected_window); 4147 fset_selected_window (f, new_selected_window);
4148 } 4148 }
4149 else 4149 else
4150 UNBLOCK_INPUT; 4150 unblock_input ();
4151 4151
4152 /* Must be run by the caller: 4152 /* Must be run by the caller:
4153 run_window_configuration_change_hook (f); */ 4153 run_window_configuration_change_hook (f); */
@@ -4197,7 +4197,7 @@ grow_mini_window (struct window *w, int delta)
4197 root, make_number (- delta)); 4197 root, make_number (- delta));
4198 if (INTEGERP (value) && window_resize_check (r, 0)) 4198 if (INTEGERP (value) && window_resize_check (r, 0))
4199 { 4199 {
4200 BLOCK_INPUT; 4200 block_input ();
4201 window_resize_apply (r, 0); 4201 window_resize_apply (r, 0);
4202 4202
4203 /* Grow the mini-window. */ 4203 /* Grow the mini-window. */
@@ -4209,7 +4209,7 @@ grow_mini_window (struct window *w, int delta)
4209 w->last_overlay_modified = 0; 4209 w->last_overlay_modified = 0;
4210 4210
4211 adjust_glyphs (f); 4211 adjust_glyphs (f);
4212 UNBLOCK_INPUT; 4212 unblock_input ();
4213 } 4213 }
4214} 4214}
4215 4215
@@ -4234,7 +4234,7 @@ shrink_mini_window (struct window *w)
4234 root, make_number (size - 1)); 4234 root, make_number (size - 1));
4235 if (INTEGERP (value) && window_resize_check (r, 0)) 4235 if (INTEGERP (value) && window_resize_check (r, 0))
4236 { 4236 {
4237 BLOCK_INPUT; 4237 block_input ();
4238 window_resize_apply (r, 0); 4238 window_resize_apply (r, 0);
4239 4239
4240 /* Shrink the mini-window. */ 4240 /* Shrink the mini-window. */
@@ -4246,7 +4246,7 @@ shrink_mini_window (struct window *w)
4246 w->last_overlay_modified = 0; 4246 w->last_overlay_modified = 0;
4247 4247
4248 adjust_glyphs (f); 4248 adjust_glyphs (f);
4249 UNBLOCK_INPUT; 4249 unblock_input ();
4250 } 4250 }
4251 /* If the above failed for whatever strange reason we must make a 4251 /* If the above failed for whatever strange reason we must make a
4252 one window frame here. The same routine will be needed when 4252 one window frame here. The same routine will be needed when
@@ -4278,7 +4278,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4278 && XINT (w->new_total) > 0 4278 && XINT (w->new_total) > 0
4279 && height == XINT (r->new_total) + XINT (w->new_total)) 4279 && height == XINT (r->new_total) + XINT (w->new_total))
4280 { 4280 {
4281 BLOCK_INPUT; 4281 block_input ();
4282 window_resize_apply (r, 0); 4282 window_resize_apply (r, 0);
4283 4283
4284 wset_total_lines (w, w->new_total); 4284 wset_total_lines (w, w->new_total);
@@ -4288,7 +4288,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4288 windows_or_buffers_changed++; 4288 windows_or_buffers_changed++;
4289 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4289 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
4290 adjust_glyphs (f); 4290 adjust_glyphs (f);
4291 UNBLOCK_INPUT; 4291 unblock_input ();
4292 4292
4293 run_window_configuration_change_hook (f); 4293 run_window_configuration_change_hook (f);
4294 return Qt; 4294 return Qt;
@@ -5624,7 +5624,7 @@ the return value is nil. Otherwise the value is t. */)
5624 5624
5625 /* The mouse highlighting code could get screwed up 5625 /* The mouse highlighting code could get screwed up
5626 if it runs during this. */ 5626 if it runs during this. */
5627 BLOCK_INPUT; 5627 block_input ();
5628 5628
5629 if (data->frame_lines != previous_frame_lines 5629 if (data->frame_lines != previous_frame_lines
5630 || data->frame_cols != previous_frame_cols) 5630 || data->frame_cols != previous_frame_cols)
@@ -5875,7 +5875,7 @@ the return value is nil. Otherwise the value is t. */)
5875 } 5875 }
5876 5876
5877 adjust_glyphs (f); 5877 adjust_glyphs (f);
5878 UNBLOCK_INPUT; 5878 unblock_input ();
5879 5879
5880 /* Scan dead buffer windows. */ 5880 /* Scan dead buffer windows. */
5881 for (; CONSP (dead_windows); dead_windows = XCDR (dead_windows)) 5881 for (; CONSP (dead_windows); dead_windows = XCDR (dead_windows))
@@ -6704,7 +6704,7 @@ syms_of_window (void)
6704 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); 6704 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows");
6705 DEFSYM (Qrecord_window_buffer, "record-window-buffer"); 6705 DEFSYM (Qrecord_window_buffer, "record-window-buffer");
6706 DEFSYM (Qget_mru_window, "get-mru-window"); 6706 DEFSYM (Qget_mru_window, "get-mru-window");
6707 DEFSYM (Qtemp_buffer_resize, "temp-buffer-resize"); 6707 DEFSYM (Qwindow_size, "window-size");
6708 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); 6708 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook");
6709 DEFSYM (Qabove, "above"); 6709 DEFSYM (Qabove, "above");
6710 DEFSYM (Qbelow, "below"); 6710 DEFSYM (Qbelow, "below");
@@ -6804,19 +6804,19 @@ This variable takes no effect if `window-combination-limit' is non-nil. */);
6804The following values are recognized: 6804The following values are recognized:
6805 6805
6806nil means splitting a window will create a new parent window only if the 6806nil means splitting a window will create a new parent window only if the
6807 window has no parent window or the window shall become a combination 6807 window has no parent window or the window shall become part of a
6808 orthogonal to the one it is part of. 6808 combination orthogonal to the one it is part of.
6809 6809
6810`temp-buffer-resize' means that splitting a window for displaying a 6810`window-size' means that splitting a window for displaying a buffer
6811 temporary buffer makes a new parent window provided 6811 makes a new parent window provided `display-buffer' is supposed to
6812 `temp-buffer-resize-mode' is enabled. Otherwise, this value is 6812 explicitly set the window's size due to the presence of a
6813 handled like nil. 6813 `window-height' or `window-width' entry in the alist used by
6814 `display-buffer'. Otherwise, this value is handled like nil.
6814 6815
6815`temp-buffer' means that splitting a window for displaying a temporary 6816`temp-buffer' means that splitting a window for displaying a temporary
6816 buffer always makes a new parent window. Otherwise, this value is 6817 buffer always makes a new parent window. Otherwise, this value is
6817 handled like nil. 6818 handled like nil.
6818 6819
6819
6820`display-buffer' means that splitting a window for displaying a buffer 6820`display-buffer' means that splitting a window for displaying a buffer
6821 always makes a new parent window. Since temporary buffers are 6821 always makes a new parent window. Since temporary buffers are
6822 displayed by the function `display-buffer', this value is stronger 6822 displayed by the function `display-buffer', this value is stronger
@@ -6829,7 +6829,7 @@ t means that splitting a window always creates a new parent window. If
6829 sibling. 6829 sibling.
6830 6830
6831Other values are reserved for future use. */); 6831Other values are reserved for future use. */);
6832 Vwindow_combination_limit = Qtemp_buffer_resize; 6832 Vwindow_combination_limit = Qwindow_size;
6833 6833
6834 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, 6834 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters,
6835 doc: /* Alist of persistent window parameters. 6835 doc: /* Alist of persistent window parameters.
diff --git a/src/xdisp.c b/src/xdisp.c
index c2032696a1c..b23a06ff3d1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -275,6 +275,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
275#include <limits.h> 275#include <limits.h>
276 276
277#include "lisp.h" 277#include "lisp.h"
278#include "atimer.h"
278#include "keyboard.h" 279#include "keyboard.h"
279#include "frame.h" 280#include "frame.h"
280#include "window.h" 281#include "window.h"
@@ -332,10 +333,10 @@ static Lisp_Object Qinhibit_eval_during_redisplay;
332static Lisp_Object Qbuffer_position, Qposition, Qobject; 333static Lisp_Object Qbuffer_position, Qposition, Qobject;
333static Lisp_Object Qright_to_left, Qleft_to_right; 334static Lisp_Object Qright_to_left, Qleft_to_right;
334 335
335/* Cursor shapes */ 336/* Cursor shapes. */
336Lisp_Object Qbar, Qhbar, Qbox, Qhollow; 337Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
337 338
338/* Pointer shapes */ 339/* Pointer shapes. */
339static Lisp_Object Qarrow, Qhand; 340static Lisp_Object Qarrow, Qhand;
340Lisp_Object Qtext; 341Lisp_Object Qtext;
341 342
@@ -346,6 +347,7 @@ static Lisp_Object Qfontification_functions;
346 347
347static Lisp_Object Qwrap_prefix; 348static Lisp_Object Qwrap_prefix;
348static Lisp_Object Qline_prefix; 349static Lisp_Object Qline_prefix;
350static Lisp_Object Qredisplay_internal;
349 351
350/* Non-nil means don't actually do any redisplay. */ 352/* Non-nil means don't actually do any redisplay. */
351 353
@@ -11402,11 +11404,11 @@ x_cursor_to (int vpos, int hpos, int y, int x)
11402 This will also set the cursor position of W. */ 11404 This will also set the cursor position of W. */
11403 if (updated_window == NULL) 11405 if (updated_window == NULL)
11404 { 11406 {
11405 BLOCK_INPUT; 11407 block_input ();
11406 display_and_set_cursor (w, 1, hpos, vpos, x, y); 11408 display_and_set_cursor (w, 1, hpos, vpos, x, y);
11407 if (FRAME_RIF (SELECTED_FRAME ())->flush_display_optional) 11409 if (FRAME_RIF (SELECTED_FRAME ())->flush_display_optional)
11408 FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (SELECTED_FRAME ()); 11410 FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (SELECTED_FRAME ());
11409 UNBLOCK_INPUT; 11411 unblock_input ();
11410 } 11412 }
11411} 11413}
11412 11414
@@ -11520,11 +11522,11 @@ update_tool_bar (struct frame *f, int save_match_data)
11520 /* Redisplay that happens asynchronously due to an expose event 11522 /* Redisplay that happens asynchronously due to an expose event
11521 may access f->tool_bar_items. Make sure we update both 11523 may access f->tool_bar_items. Make sure we update both
11522 variables within BLOCK_INPUT so no such event interrupts. */ 11524 variables within BLOCK_INPUT so no such event interrupts. */
11523 BLOCK_INPUT; 11525 block_input ();
11524 fset_tool_bar_items (f, new_tool_bar); 11526 fset_tool_bar_items (f, new_tool_bar);
11525 f->n_tool_bar_items = new_n_tool_bar; 11527 f->n_tool_bar_items = new_n_tool_bar;
11526 w->update_mode_line = 1; 11528 w->update_mode_line = 1;
11527 UNBLOCK_INPUT; 11529 unblock_input ();
11528 } 11530 }
11529 11531
11530 UNGCPRO; 11532 UNGCPRO;
@@ -12928,12 +12930,13 @@ redisplay_internal (void)
12928 struct frame *sf; 12930 struct frame *sf;
12929 int polling_stopped_here = 0; 12931 int polling_stopped_here = 0;
12930 Lisp_Object old_frame = selected_frame; 12932 Lisp_Object old_frame = selected_frame;
12933 struct backtrace backtrace;
12931 12934
12932 /* Non-zero means redisplay has to consider all windows on all 12935 /* Non-zero means redisplay has to consider all windows on all
12933 frames. Zero means, only selected_window is considered. */ 12936 frames. Zero means, only selected_window is considered. */
12934 int consider_all_windows_p; 12937 int consider_all_windows_p;
12935 12938
12936 /* Non-zero means redisplay has to redisplay the miniwindow */ 12939 /* Non-zero means redisplay has to redisplay the miniwindow. */
12937 int update_miniwindow_p = 0; 12940 int update_miniwindow_p = 0;
12938 12941
12939 TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); 12942 TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p));
@@ -12970,6 +12973,14 @@ redisplay_internal (void)
12970 redisplaying_p = 1; 12973 redisplaying_p = 1;
12971 specbind (Qinhibit_free_realized_faces, Qnil); 12974 specbind (Qinhibit_free_realized_faces, Qnil);
12972 12975
12976 /* Record this function, so it appears on the profiler's backtraces. */
12977 backtrace.next = backtrace_list;
12978 backtrace.function = Qredisplay_internal;
12979 backtrace.args = &Qnil;
12980 backtrace.nargs = 0;
12981 backtrace.debug_on_exit = 0;
12982 backtrace_list = &backtrace;
12983
12973 { 12984 {
12974 Lisp_Object tail, frame; 12985 Lisp_Object tail, frame;
12975 12986
@@ -13667,6 +13678,7 @@ redisplay_internal (void)
13667#endif /* HAVE_WINDOW_SYSTEM */ 13678#endif /* HAVE_WINDOW_SYSTEM */
13668 13679
13669 end_of_redisplay: 13680 end_of_redisplay:
13681 backtrace_list = backtrace.next;
13670 unbind_to (count, Qnil); 13682 unbind_to (count, Qnil);
13671 RESUME_POLLING; 13683 RESUME_POLLING;
13672} 13684}
@@ -16205,10 +16217,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16205 || w->pseudo_window_p))) 16217 || w->pseudo_window_p)))
16206 { 16218 {
16207 update_begin (f); 16219 update_begin (f);
16208 BLOCK_INPUT; 16220 block_input ();
16209 if (draw_window_fringes (w, 1)) 16221 if (draw_window_fringes (w, 1))
16210 x_draw_vertical_border (w); 16222 x_draw_vertical_border (w);
16211 UNBLOCK_INPUT; 16223 unblock_input ();
16212 update_end (f); 16224 update_end (f);
16213 } 16225 }
16214#endif /* HAVE_WINDOW_SYSTEM */ 16226#endif /* HAVE_WINDOW_SYSTEM */
@@ -20161,10 +20173,6 @@ display_menu_bar (struct window *w)
20161 this. */ 20173 this. */
20162 it.paragraph_embedding = L2R; 20174 it.paragraph_embedding = L2R;
20163 20175
20164 if (! mode_line_inverse_video)
20165 /* Force the menu-bar to be displayed in the default face. */
20166 it.base_face_id = it.face_id = DEFAULT_FACE_ID;
20167
20168 /* Clear all rows of the menu bar. */ 20176 /* Clear all rows of the menu bar. */
20169 for (i = 0; i < FRAME_MENU_BAR_LINES (f); ++i) 20177 for (i = 0; i < FRAME_MENU_BAR_LINES (f); ++i)
20170 { 20178 {
@@ -20334,10 +20342,6 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
20334 20342
20335 it.glyph_row->mode_line_p = 1; 20343 it.glyph_row->mode_line_p = 1;
20336 20344
20337 if (! mode_line_inverse_video)
20338 /* Force the mode-line to be displayed in the default face. */
20339 it.base_face_id = it.face_id = DEFAULT_FACE_ID;
20340
20341 /* FIXME: This should be controlled by a user option. But 20345 /* FIXME: This should be controlled by a user option. But
20342 supporting such an option is not trivial, since the mode line is 20346 supporting such an option is not trivial, since the mode line is
20343 made up of many separate strings. */ 20347 made up of many separate strings. */
@@ -25327,7 +25331,7 @@ x_write_glyphs (struct glyph *start, int len)
25327 if (updated_row->reversed_p && chpos >= updated_row->used[TEXT_AREA]) 25331 if (updated_row->reversed_p && chpos >= updated_row->used[TEXT_AREA])
25328 chpos = updated_row->used[TEXT_AREA] - 1; 25332 chpos = updated_row->used[TEXT_AREA] - 1;
25329 25333
25330 BLOCK_INPUT; 25334 block_input ();
25331 25335
25332 /* Write glyphs. */ 25336 /* Write glyphs. */
25333 25337
@@ -25345,7 +25349,7 @@ x_write_glyphs (struct glyph *start, int len)
25345 && chpos < hpos + len) 25349 && chpos < hpos + len)
25346 updated_window->phys_cursor_on_p = 0; 25350 updated_window->phys_cursor_on_p = 0;
25347 25351
25348 UNBLOCK_INPUT; 25352 unblock_input ();
25349 25353
25350 /* Advance the output cursor. */ 25354 /* Advance the output cursor. */
25351 output_cursor.hpos += len; 25355 output_cursor.hpos += len;
@@ -25368,7 +25372,7 @@ x_insert_glyphs (struct glyph *start, int len)
25368 ptrdiff_t hpos; 25372 ptrdiff_t hpos;
25369 25373
25370 eassert (updated_window && updated_row); 25374 eassert (updated_window && updated_row);
25371 BLOCK_INPUT; 25375 block_input ();
25372 w = updated_window; 25376 w = updated_window;
25373 f = XFRAME (WINDOW_FRAME (w)); 25377 f = XFRAME (WINDOW_FRAME (w));
25374 25378
@@ -25402,7 +25406,7 @@ x_insert_glyphs (struct glyph *start, int len)
25402 /* Advance the output cursor. */ 25406 /* Advance the output cursor. */
25403 output_cursor.hpos += len; 25407 output_cursor.hpos += len;
25404 output_cursor.x += shift_by_width; 25408 output_cursor.x += shift_by_width;
25405 UNBLOCK_INPUT; 25409 unblock_input ();
25406} 25410}
25407 25411
25408 25412
@@ -25471,10 +25475,10 @@ x_clear_end_of_line (int to_x)
25471 /* Prevent inadvertently clearing to end of the X window. */ 25475 /* Prevent inadvertently clearing to end of the X window. */
25472 if (to_x > from_x && to_y > from_y) 25476 if (to_x > from_x && to_y > from_y)
25473 { 25477 {
25474 BLOCK_INPUT; 25478 block_input ();
25475 FRAME_RIF (f)->clear_frame_area (f, from_x, from_y, 25479 FRAME_RIF (f)->clear_frame_area (f, from_x, from_y,
25476 to_x - from_x, to_y - from_y); 25480 to_x - from_x, to_y - from_y);
25477 UNBLOCK_INPUT; 25481 unblock_input ();
25478 } 25482 }
25479} 25483}
25480 25484
@@ -25801,7 +25805,7 @@ x_fix_overlapping_area (struct window *w, struct glyph_row *row,
25801{ 25805{
25802 int i, x; 25806 int i, x;
25803 25807
25804 BLOCK_INPUT; 25808 block_input ();
25805 25809
25806 x = 0; 25810 x = 0;
25807 for (i = 0; i < row->used[area];) 25811 for (i = 0; i < row->used[area];)
@@ -25829,7 +25833,7 @@ x_fix_overlapping_area (struct window *w, struct glyph_row *row,
25829 } 25833 }
25830 } 25834 }
25831 25835
25832 UNBLOCK_INPUT; 25836 unblock_input ();
25833} 25837}
25834 25838
25835 25839
@@ -26047,7 +26051,7 @@ display_and_set_cursor (struct window *w, int on,
26047 || (0 <= hpos && hpos < glyph_row->used[TEXT_AREA])) 26051 || (0 <= hpos && hpos < glyph_row->used[TEXT_AREA]))
26048 glyph = glyph_row->glyphs[TEXT_AREA] + hpos; 26052 glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
26049 26053
26050 eassert (interrupt_input_blocked); 26054 eassert (input_blocked_p ());
26051 26055
26052 /* Set new_cursor_type to the cursor we want to be displayed. */ 26056 /* Set new_cursor_type to the cursor we want to be displayed. */
26053 new_cursor_type = get_window_cursor_type (w, glyph, 26057 new_cursor_type = get_window_cursor_type (w, glyph,
@@ -26117,10 +26121,10 @@ update_window_cursor (struct window *w, int on)
26117 if (row->reversed_p && hpos >= row->used[TEXT_AREA]) 26121 if (row->reversed_p && hpos >= row->used[TEXT_AREA])
26118 hpos = row->used[TEXT_AREA] - 1; 26122 hpos = row->used[TEXT_AREA] - 1;
26119 26123
26120 BLOCK_INPUT; 26124 block_input ();
26121 display_and_set_cursor (w, on, hpos, vpos, 26125 display_and_set_cursor (w, on, hpos, vpos,
26122 w->phys_cursor.x, w->phys_cursor.y); 26126 w->phys_cursor.x, w->phys_cursor.y);
26123 UNBLOCK_INPUT; 26127 unblock_input ();
26124 } 26128 }
26125} 26129}
26126 26130
@@ -26298,10 +26302,10 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
26298 if (row->reversed_p && hpos >= row->used[TEXT_AREA]) 26302 if (row->reversed_p && hpos >= row->used[TEXT_AREA])
26299 hpos = row->used[TEXT_AREA] - 1; 26303 hpos = row->used[TEXT_AREA] - 1;
26300 26304
26301 BLOCK_INPUT; 26305 block_input ();
26302 display_and_set_cursor (w, 1, hpos, w->phys_cursor.vpos, 26306 display_and_set_cursor (w, 1, hpos, w->phys_cursor.vpos,
26303 w->phys_cursor.x, w->phys_cursor.y); 26307 w->phys_cursor.x, w->phys_cursor.y);
26304 UNBLOCK_INPUT; 26308 unblock_input ();
26305 } 26309 }
26306#endif /* HAVE_WINDOW_SYSTEM */ 26310#endif /* HAVE_WINDOW_SYSTEM */
26307 } 26311 }
@@ -28116,11 +28120,11 @@ x_clear_window_mouse_face (struct window *w)
28116 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); 28120 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
28117 Lisp_Object window; 28121 Lisp_Object window;
28118 28122
28119 BLOCK_INPUT; 28123 block_input ();
28120 XSETWINDOW (window, w); 28124 XSETWINDOW (window, w);
28121 if (EQ (window, hlinfo->mouse_face_window)) 28125 if (EQ (window, hlinfo->mouse_face_window))
28122 clear_mouse_face (hlinfo); 28126 clear_mouse_face (hlinfo);
28123 UNBLOCK_INPUT; 28127 unblock_input ();
28124} 28128}
28125 28129
28126 28130
@@ -28690,6 +28694,7 @@ syms_of_xdisp (void)
28690 staticpro (&Vmessage_stack); 28694 staticpro (&Vmessage_stack);
28691 28695
28692 DEFSYM (Qinhibit_redisplay, "inhibit-redisplay"); 28696 DEFSYM (Qinhibit_redisplay, "inhibit-redisplay");
28697 DEFSYM (Qredisplay_internal, "redisplay_internal (C function)");
28693 28698
28694 message_dolog_marker1 = Fmake_marker (); 28699 message_dolog_marker1 = Fmake_marker ();
28695 staticpro (&message_dolog_marker1); 28700 staticpro (&message_dolog_marker1);
@@ -28929,12 +28934,6 @@ A value of nil means to respect the value of `truncate-lines'.
28929If `word-wrap' is enabled, you might want to reduce this. */); 28934If `word-wrap' is enabled, you might want to reduce this. */);
28930 Vtruncate_partial_width_windows = make_number (50); 28935 Vtruncate_partial_width_windows = make_number (50);
28931 28936
28932 DEFVAR_BOOL ("mode-line-inverse-video", mode_line_inverse_video,
28933 doc: /* When nil, display the mode-line/header-line/menu-bar in the default face.
28934Any other value means to use the appropriate face, `mode-line',
28935`header-line', or `menu' respectively. */);
28936 mode_line_inverse_video = 1;
28937
28938 DEFVAR_LISP ("line-number-display-limit", Vline_number_display_limit, 28937 DEFVAR_LISP ("line-number-display-limit", Vline_number_display_limit,
28939 doc: /* Maximum buffer size for which line number should be displayed. 28938 doc: /* Maximum buffer size for which line number should be displayed.
28940If the buffer is bigger than this, the line number does not appear 28939If the buffer is bigger than this, the line number does not appear
@@ -29362,7 +29361,7 @@ init_xdisp (void)
29362 the following three functions in w32fns.c. */ 29361 the following three functions in w32fns.c. */
29363#ifndef WINDOWSNT 29362#ifndef WINDOWSNT
29364 29363
29365/* Platform-independent portion of hourglass implementation. */ 29364/* Platform-independent portion of hourglass implementation. */
29366 29365
29367/* Cancel a currently active hourglass timer, and start a new one. */ 29366/* Cancel a currently active hourglass timer, and start a new one. */
29368void 29367void
diff --git a/src/xfaces.c b/src/xfaces.c
index c240a05c6c0..28be6aaf082 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -605,9 +605,9 @@ static inline GC
605x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv) 605x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv)
606{ 606{
607 GC gc; 607 GC gc;
608 BLOCK_INPUT; 608 block_input ();
609 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), mask, xgcv); 609 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), mask, xgcv);
610 UNBLOCK_INPUT; 610 unblock_input ();
611 IF_DEBUG (++ngcs); 611 IF_DEBUG (++ngcs);
612 return gc; 612 return gc;
613} 613}
@@ -618,7 +618,7 @@ x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv)
618static inline void 618static inline void
619x_free_gc (struct frame *f, GC gc) 619x_free_gc (struct frame *f, GC gc)
620{ 620{
621 eassert (interrupt_input_blocked); 621 eassert (input_blocked_p ());
622 IF_DEBUG (eassert (--ngcs >= 0)); 622 IF_DEBUG (eassert (--ngcs >= 0));
623 XFreeGC (FRAME_X_DISPLAY (f), gc); 623 XFreeGC (FRAME_X_DISPLAY (f), gc);
624} 624}
@@ -632,9 +632,9 @@ static inline GC
632x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv) 632x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
633{ 633{
634 GC gc; 634 GC gc;
635 BLOCK_INPUT; 635 block_input ();
636 gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, xgcv); 636 gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, xgcv);
637 UNBLOCK_INPUT; 637 unblock_input ();
638 IF_DEBUG (++ngcs); 638 IF_DEBUG (++ngcs);
639 return gc; 639 return gc;
640} 640}
@@ -907,7 +907,7 @@ load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr,
907 907
908 CHECK_TYPE (!NILP (Fbitmap_spec_p (name)), Qbitmap_spec_p, name); 908 CHECK_TYPE (!NILP (Fbitmap_spec_p (name)), Qbitmap_spec_p, name);
909 909
910 BLOCK_INPUT; 910 block_input ();
911 if (CONSP (name)) 911 if (CONSP (name))
912 { 912 {
913 /* Decode a bitmap spec into a bitmap. */ 913 /* Decode a bitmap spec into a bitmap. */
@@ -927,7 +927,7 @@ load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr,
927 /* It must be a string -- a file name. */ 927 /* It must be a string -- a file name. */
928 bitmap_id = x_create_bitmap_from_file (f, name); 928 bitmap_id = x_create_bitmap_from_file (f, name);
929 } 929 }
930 UNBLOCK_INPUT; 930 unblock_input ();
931 931
932 if (bitmap_id < 0) 932 if (bitmap_id < 0)
933 { 933 {
@@ -991,7 +991,7 @@ parse_rgb_list (Lisp_Object rgb_list, XColor *color)
991 non-zero, then the `standard' definition of the same color is 991 non-zero, then the `standard' definition of the same color is
992 returned in it. */ 992 returned in it. */
993 993
994static int 994static bool
995tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, 995tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
996 XColor *std_color) 996 XColor *std_color)
997{ 997{
@@ -1052,11 +1052,11 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
1052 1052
1053/* A version of defined_color for non-X frames. */ 1053/* A version of defined_color for non-X frames. */
1054 1054
1055static int 1055static bool
1056tty_defined_color (struct frame *f, const char *color_name, 1056tty_defined_color (struct frame *f, const char *color_name,
1057 XColor *color_def, int alloc) 1057 XColor *color_def, bool alloc)
1058{ 1058{
1059 int status = 1; 1059 bool status = 1;
1060 1060
1061 /* Defaults. */ 1061 /* Defaults. */
1062 color_def->pixel = FACE_TTY_DEFAULT_COLOR; 1062 color_def->pixel = FACE_TTY_DEFAULT_COLOR;
@@ -1084,13 +1084,13 @@ tty_defined_color (struct frame *f, const char *color_name,
1084 1084
1085/* Decide if color named COLOR_NAME is valid for the display 1085/* Decide if color named COLOR_NAME is valid for the display
1086 associated with the frame F; if so, return the rgb values in 1086 associated with the frame F; if so, return the rgb values in
1087 COLOR_DEF. If ALLOC is nonzero, allocate a new colormap cell. 1087 COLOR_DEF. If ALLOC, allocate a new colormap cell.
1088 1088
1089 This does the right thing for any type of frame. */ 1089 This does the right thing for any type of frame. */
1090 1090
1091static int 1091static bool
1092defined_color (struct frame *f, const char *color_name, XColor *color_def, 1092defined_color (struct frame *f, const char *color_name, XColor *color_def,
1093 int alloc) 1093 bool alloc)
1094{ 1094{
1095 if (!FRAME_WINDOW_P (f)) 1095 if (!FRAME_WINDOW_P (f))
1096 return tty_defined_color (f, color_name, color_def, alloc); 1096 return tty_defined_color (f, color_name, color_def, alloc);
@@ -1364,9 +1364,9 @@ unload_color (struct frame *f, long unsigned int pixel)
1364#ifdef HAVE_X_WINDOWS 1364#ifdef HAVE_X_WINDOWS
1365 if (pixel != -1) 1365 if (pixel != -1)
1366 { 1366 {
1367 BLOCK_INPUT; 1367 block_input ();
1368 x_free_colors (f, &pixel, 1); 1368 x_free_colors (f, &pixel, 1);
1369 UNBLOCK_INPUT; 1369 unblock_input ();
1370 } 1370 }
1371#endif 1371#endif
1372} 1372}
@@ -1382,7 +1382,7 @@ free_face_colors (struct frame *f, struct face *face)
1382 if (face->colors_copied_bitwise_p) 1382 if (face->colors_copied_bitwise_p)
1383 return; 1383 return;
1384 1384
1385 BLOCK_INPUT; 1385 block_input ();
1386 1386
1387 if (!face->foreground_defaulted_p) 1387 if (!face->foreground_defaulted_p)
1388 { 1388 {
@@ -1424,7 +1424,7 @@ free_face_colors (struct frame *f, struct face *face)
1424 IF_DEBUG (--ncolors_allocated); 1424 IF_DEBUG (--ncolors_allocated);
1425 } 1425 }
1426 1426
1427 UNBLOCK_INPUT; 1427 unblock_input ();
1428#endif /* HAVE_X_WINDOWS */ 1428#endif /* HAVE_X_WINDOWS */
1429} 1429}
1430 1430
@@ -3438,10 +3438,10 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource,
3438 CHECK_STRING (resource); 3438 CHECK_STRING (resource);
3439 CHECK_STRING (class); 3439 CHECK_STRING (class);
3440 CHECK_LIVE_FRAME (frame); 3440 CHECK_LIVE_FRAME (frame);
3441 BLOCK_INPUT; 3441 block_input ();
3442 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), 3442 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)),
3443 resource, class, Qnil, Qnil); 3443 resource, class, Qnil, Qnil);
3444 UNBLOCK_INPUT; 3444 unblock_input ();
3445 return value; 3445 return value;
3446} 3446}
3447 3447
@@ -4114,12 +4114,12 @@ free_realized_face (struct frame *f, struct face *face)
4114 free_face_fontset (f, face); 4114 free_face_fontset (f, face);
4115 if (face->gc) 4115 if (face->gc)
4116 { 4116 {
4117 BLOCK_INPUT; 4117 block_input ();
4118 if (face->font) 4118 if (face->font)
4119 font_done_for_face (f, face); 4119 font_done_for_face (f, face);
4120 x_free_gc (f, face->gc); 4120 x_free_gc (f, face->gc);
4121 face->gc = 0; 4121 face->gc = 0;
4122 UNBLOCK_INPUT; 4122 unblock_input ();
4123 } 4123 }
4124 4124
4125 free_face_colors (f, face); 4125 free_face_colors (f, face);
@@ -4153,7 +4153,7 @@ prepare_face_for_display (struct frame *f, struct face *face)
4153 xgcv.graphics_exposures = False; 4153 xgcv.graphics_exposures = False;
4154#endif 4154#endif
4155 4155
4156 BLOCK_INPUT; 4156 block_input ();
4157#ifdef HAVE_X_WINDOWS 4157#ifdef HAVE_X_WINDOWS
4158 if (face->stipple) 4158 if (face->stipple)
4159 { 4159 {
@@ -4165,7 +4165,7 @@ prepare_face_for_display (struct frame *f, struct face *face)
4165 face->gc = x_create_gc (f, mask, &xgcv); 4165 face->gc = x_create_gc (f, mask, &xgcv);
4166 if (face->font) 4166 if (face->font)
4167 font_prepare_for_face (f, face); 4167 font_prepare_for_face (f, face);
4168 UNBLOCK_INPUT; 4168 unblock_input ();
4169 } 4169 }
4170#endif /* HAVE_WINDOW_SYSTEM */ 4170#endif /* HAVE_WINDOW_SYSTEM */
4171} 4171}
@@ -4263,12 +4263,12 @@ clear_face_gcs (struct face_cache *c)
4263 struct face *face = c->faces_by_id[i]; 4263 struct face *face = c->faces_by_id[i];
4264 if (face && face->gc) 4264 if (face && face->gc)
4265 { 4265 {
4266 BLOCK_INPUT; 4266 block_input ();
4267 if (face->font) 4267 if (face->font)
4268 font_done_for_face (c->f, face); 4268 font_done_for_face (c->f, face);
4269 x_free_gc (c->f, face->gc); 4269 x_free_gc (c->f, face->gc);
4270 face->gc = 0; 4270 face->gc = 0;
4271 UNBLOCK_INPUT; 4271 unblock_input ();
4272 } 4272 }
4273 } 4273 }
4274#endif /* HAVE_WINDOW_SYSTEM */ 4274#endif /* HAVE_WINDOW_SYSTEM */
@@ -4292,7 +4292,7 @@ free_realized_faces (struct face_cache *c)
4292 /* We must block input here because we can't process X events 4292 /* We must block input here because we can't process X events
4293 safely while only some faces are freed, or when the frame's 4293 safely while only some faces are freed, or when the frame's
4294 current matrix still references freed faces. */ 4294 current matrix still references freed faces. */
4295 BLOCK_INPUT; 4295 block_input ();
4296 4296
4297 for (i = 0; i < c->used; ++i) 4297 for (i = 0; i < c->used; ++i)
4298 { 4298 {
@@ -4314,7 +4314,7 @@ free_realized_faces (struct face_cache *c)
4314 ++windows_or_buffers_changed; 4314 ++windows_or_buffers_changed;
4315 } 4315 }
4316 4316
4317 UNBLOCK_INPUT; 4317 unblock_input ();
4318 } 4318 }
4319} 4319}
4320 4320
@@ -5275,7 +5275,7 @@ realize_basic_faces (struct frame *f)
5275 5275
5276 /* Block input here so that we won't be surprised by an X expose 5276 /* Block input here so that we won't be surprised by an X expose
5277 event, for instance, without having the faces set up. */ 5277 event, for instance, without having the faces set up. */
5278 BLOCK_INPUT; 5278 block_input ();
5279 specbind (Qscalable_fonts_allowed, Qt); 5279 specbind (Qscalable_fonts_allowed, Qt);
5280 5280
5281 if (realize_default_face (f)) 5281 if (realize_default_face (f))
@@ -5306,7 +5306,7 @@ realize_basic_faces (struct frame *f)
5306 } 5306 }
5307 5307
5308 unbind_to (count, Qnil); 5308 unbind_to (count, Qnil);
5309 UNBLOCK_INPUT; 5309 unblock_input ();
5310 return success_p; 5310 return success_p;
5311} 5311}
5312 5312
@@ -6352,7 +6352,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6352 int red, green, blue; 6352 int red, green, blue;
6353 int num; 6353 int num;
6354 6354
6355 BLOCK_INPUT; 6355 block_input ();
6356 6356
6357 while (fgets (buf, sizeof (buf), fp) != NULL) { 6357 while (fgets (buf, sizeof (buf), fp) != NULL) {
6358 if (sscanf (buf, "%u %u %u %n", &red, &green, &blue, &num) == 3) 6358 if (sscanf (buf, "%u %u %u %n", &red, &green, &blue, &num) == 3)
@@ -6372,7 +6372,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6372 } 6372 }
6373 fclose (fp); 6373 fclose (fp);
6374 6374
6375 UNBLOCK_INPUT; 6375 unblock_input ();
6376 } 6376 }
6377 6377
6378 return cmap; 6378 return cmap;
diff --git a/src/xfns.c b/src/xfns.c
index 8304a3df04f..928e6367743 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -425,7 +425,7 @@ x_real_positions (FRAME_PTR f, int *xptr, int *yptr)
425 unsigned char *tmp_data = NULL; 425 unsigned char *tmp_data = NULL;
426 Atom target_type = XA_CARDINAL; 426 Atom target_type = XA_CARDINAL;
427 427
428 BLOCK_INPUT; 428 block_input ();
429 429
430 x_catch_errors (dpy); 430 x_catch_errors (dpy);
431 431
@@ -543,7 +543,7 @@ x_real_positions (FRAME_PTR f, int *xptr, int *yptr)
543 543
544 x_uncatch_errors (); 544 x_uncatch_errors ();
545 545
546 UNBLOCK_INPUT; 546 unblock_input ();
547 547
548 if (had_errors) return; 548 if (had_errors) return;
549 549
@@ -575,27 +575,27 @@ gamma_correct (struct frame *f, XColor *color)
575 575
576 576
577/* Decide if color named COLOR_NAME is valid for use on frame F. If 577/* Decide if color named COLOR_NAME is valid for use on frame F. If
578 so, return the RGB values in COLOR. If ALLOC_P is non-zero, 578 so, return the RGB values in COLOR. If ALLOC_P,
579 allocate the color. Value is zero if COLOR_NAME is invalid, or 579 allocate the color. Value is false if COLOR_NAME is invalid, or
580 no color could be allocated. */ 580 no color could be allocated. */
581 581
582int 582bool
583x_defined_color (struct frame *f, const char *color_name, 583x_defined_color (struct frame *f, const char *color_name,
584 XColor *color, int alloc_p) 584 XColor *color, bool alloc_p)
585{ 585{
586 int success_p = 0; 586 bool success_p = 0;
587 Display *dpy = FRAME_X_DISPLAY (f); 587 Display *dpy = FRAME_X_DISPLAY (f);
588 Colormap cmap = FRAME_X_COLORMAP (f); 588 Colormap cmap = FRAME_X_COLORMAP (f);
589 589
590 BLOCK_INPUT; 590 block_input ();
591#ifdef USE_GTK 591#ifdef USE_GTK
592 success_p = xg_check_special_colors (f, color_name, color); 592 success_p = xg_check_special_colors (f, color_name, color);
593#endif 593#endif
594 if (!success_p) 594 if (!success_p)
595 success_p = XParseColor (dpy, cmap, color_name, color); 595 success_p = XParseColor (dpy, cmap, color_name, color) != 0;
596 if (success_p && alloc_p) 596 if (success_p && alloc_p)
597 success_p = x_alloc_nearest_color (f, cmap, color); 597 success_p = x_alloc_nearest_color (f, cmap, color);
598 UNBLOCK_INPUT; 598 unblock_input ();
599 599
600 return success_p; 600 return success_p;
601} 601}
@@ -656,8 +656,8 @@ x_set_tool_bar_position (struct frame *f,
656 if (EQ (new_value, old_value)) return; 656 if (EQ (new_value, old_value)) return;
657 657
658#ifdef USE_GTK 658#ifdef USE_GTK
659 if (xg_change_toolbar_position (f, new_value)) 659 xg_change_toolbar_position (f, new_value);
660 fset_tool_bar_position (f, new_value); 660 fset_tool_bar_position (f, new_value);
661#endif 661#endif
662} 662}
663 663
@@ -679,7 +679,7 @@ xg_set_icon (FRAME_PTR f, Lisp_Object file)
679 GdkPixbuf *pixbuf; 679 GdkPixbuf *pixbuf;
680 GError *err = NULL; 680 GError *err = NULL;
681 char *filename = SSDATA (found); 681 char *filename = SSDATA (found);
682 BLOCK_INPUT; 682 block_input ();
683 683
684 pixbuf = gdk_pixbuf_new_from_file (filename, &err); 684 pixbuf = gdk_pixbuf_new_from_file (filename, &err);
685 685
@@ -694,7 +694,7 @@ xg_set_icon (FRAME_PTR f, Lisp_Object file)
694 else 694 else
695 g_error_free (err); 695 g_error_free (err);
696 696
697 UNBLOCK_INPUT; 697 unblock_input ();
698 } 698 }
699 699
700 return result; 700 return result;
@@ -737,7 +737,7 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
737 { 737 {
738 Display *dpy = FRAME_X_DISPLAY (f); 738 Display *dpy = FRAME_X_DISPLAY (f);
739 739
740 BLOCK_INPUT; 740 block_input ();
741 XSetForeground (dpy, x->normal_gc, fg); 741 XSetForeground (dpy, x->normal_gc, fg);
742 XSetBackground (dpy, x->reverse_gc, fg); 742 XSetBackground (dpy, x->reverse_gc, fg);
743 743
@@ -748,7 +748,7 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
748 XSetBackground (dpy, x->cursor_gc, x->cursor_pixel); 748 XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);
749 } 749 }
750 750
751 UNBLOCK_INPUT; 751 unblock_input ();
752 752
753 update_face_from_frame_parameter (f, Qforeground_color, arg); 753 update_face_from_frame_parameter (f, Qforeground_color, arg);
754 754
@@ -773,7 +773,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
773 { 773 {
774 Display *dpy = FRAME_X_DISPLAY (f); 774 Display *dpy = FRAME_X_DISPLAY (f);
775 775
776 BLOCK_INPUT; 776 block_input ();
777 XSetBackground (dpy, x->normal_gc, bg); 777 XSetBackground (dpy, x->normal_gc, bg);
778 XSetForeground (dpy, x->reverse_gc, bg); 778 XSetForeground (dpy, x->reverse_gc, bg);
779 XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg); 779 XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);
@@ -797,7 +797,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
797 } 797 }
798#endif /* USE_TOOLKIT_SCROLL_BARS */ 798#endif /* USE_TOOLKIT_SCROLL_BARS */
799 799
800 UNBLOCK_INPUT; 800 unblock_input ();
801 update_face_from_frame_parameter (f, Qbackground_color, arg); 801 update_face_from_frame_parameter (f, Qbackground_color, arg);
802 802
803 if (FRAME_VISIBLE_P (f)) 803 if (FRAME_VISIBLE_P (f))
@@ -854,7 +854,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
854 unload_color (f, x->mouse_pixel); 854 unload_color (f, x->mouse_pixel);
855 x->mouse_pixel = pixel; 855 x->mouse_pixel = pixel;
856 856
857 BLOCK_INPUT; 857 block_input ();
858 858
859 /* It's not okay to crash if the user selects a screwy cursor. */ 859 /* It's not okay to crash if the user selects a screwy cursor. */
860 x_catch_errors (dpy); 860 x_catch_errors (dpy);
@@ -974,7 +974,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
974 x->horizontal_drag_cursor = horizontal_drag_cursor; 974 x->horizontal_drag_cursor = horizontal_drag_cursor;
975 975
976 XFlush (dpy); 976 XFlush (dpy);
977 UNBLOCK_INPUT; 977 unblock_input ();
978 978
979 update_face_from_frame_parameter (f, Qmouse_color, arg); 979 update_face_from_frame_parameter (f, Qmouse_color, arg);
980} 980}
@@ -1031,10 +1031,10 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1031 1031
1032 if (FRAME_X_WINDOW (f) != 0) 1032 if (FRAME_X_WINDOW (f) != 0)
1033 { 1033 {
1034 BLOCK_INPUT; 1034 block_input ();
1035 XSetBackground (FRAME_X_DISPLAY (f), x->cursor_gc, x->cursor_pixel); 1035 XSetBackground (FRAME_X_DISPLAY (f), x->cursor_gc, x->cursor_pixel);
1036 XSetForeground (FRAME_X_DISPLAY (f), x->cursor_gc, fore_pixel); 1036 XSetForeground (FRAME_X_DISPLAY (f), x->cursor_gc, fore_pixel);
1037 UNBLOCK_INPUT; 1037 unblock_input ();
1038 1038
1039 if (FRAME_VISIBLE_P (f)) 1039 if (FRAME_VISIBLE_P (f))
1040 { 1040 {
@@ -1058,9 +1058,9 @@ x_set_border_pixel (struct frame *f, int pix)
1058 1058
1059 if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0) 1059 if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0)
1060 { 1060 {
1061 BLOCK_INPUT; 1061 block_input ();
1062 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), pix); 1062 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), pix);
1063 UNBLOCK_INPUT; 1063 unblock_input ();
1064 1064
1065 if (FRAME_VISIBLE_P (f)) 1065 if (FRAME_VISIBLE_P (f))
1066 redraw_frame (f); 1066 redraw_frame (f);
@@ -1112,7 +1112,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1112 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) 1112 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
1113 return; 1113 return;
1114 1114
1115 BLOCK_INPUT; 1115 block_input ();
1116 if (NILP (arg)) 1116 if (NILP (arg))
1117 result = x_text_icon (f, 1117 result = x_text_icon (f,
1118 SSDATA ((!NILP (f->icon_name) 1118 SSDATA ((!NILP (f->icon_name)
@@ -1123,12 +1123,12 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1123 1123
1124 if (result) 1124 if (result)
1125 { 1125 {
1126 UNBLOCK_INPUT; 1126 unblock_input ();
1127 error ("No icon window available"); 1127 error ("No icon window available");
1128 } 1128 }
1129 1129
1130 XFlush (FRAME_X_DISPLAY (f)); 1130 XFlush (FRAME_X_DISPLAY (f));
1131 UNBLOCK_INPUT; 1131 unblock_input ();
1132} 1132}
1133 1133
1134static void 1134static void
@@ -1149,7 +1149,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1149 if (f->output_data.x->icon_bitmap != 0) 1149 if (f->output_data.x->icon_bitmap != 0)
1150 return; 1150 return;
1151 1151
1152 BLOCK_INPUT; 1152 block_input ();
1153 1153
1154 result = x_text_icon (f, 1154 result = x_text_icon (f,
1155 SSDATA ((!NILP (f->icon_name) 1155 SSDATA ((!NILP (f->icon_name)
@@ -1160,12 +1160,12 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1160 1160
1161 if (result) 1161 if (result)
1162 { 1162 {
1163 UNBLOCK_INPUT; 1163 unblock_input ();
1164 error ("No icon window available"); 1164 error ("No icon window available");
1165 } 1165 }
1166 1166
1167 XFlush (FRAME_X_DISPLAY (f)); 1167 XFlush (FRAME_X_DISPLAY (f));
1168 UNBLOCK_INPUT; 1168 unblock_input ();
1169} 1169}
1170 1170
1171 1171
@@ -1228,10 +1228,10 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1228 { 1228 {
1229 y = FRAME_TOP_MARGIN_HEIGHT (f); 1229 y = FRAME_TOP_MARGIN_HEIGHT (f);
1230 1230
1231 BLOCK_INPUT; 1231 block_input ();
1232 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1232 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1233 0, y, width, height, False); 1233 0, y, width, height, False);
1234 UNBLOCK_INPUT; 1234 unblock_input ();
1235 } 1235 }
1236 1236
1237 if (nlines > 1 && nlines > olines) 1237 if (nlines > 1 && nlines > olines)
@@ -1239,10 +1239,10 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1239 y = (olines == 0 ? 1 : olines) * FRAME_LINE_HEIGHT (f); 1239 y = (olines == 0 ? 1 : olines) * FRAME_LINE_HEIGHT (f);
1240 height = nlines * FRAME_LINE_HEIGHT (f) - y; 1240 height = nlines * FRAME_LINE_HEIGHT (f) - y;
1241 1241
1242 BLOCK_INPUT; 1242 block_input ();
1243 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1243 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1244 0, y, width, height, False); 1244 0, y, width, height, False);
1245 UNBLOCK_INPUT; 1245 unblock_input ();
1246 } 1246 }
1247 1247
1248 if (nlines == 0 && WINDOWP (f->menu_bar_window)) 1248 if (nlines == 0 && WINDOWP (f->menu_bar_window))
@@ -1338,10 +1338,10 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1338 /* height can be zero here. */ 1338 /* height can be zero here. */
1339 if (height > 0 && width > 0) 1339 if (height > 0 && width > 0)
1340 { 1340 {
1341 BLOCK_INPUT; 1341 block_input ();
1342 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1342 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1343 0, y, width, height, False); 1343 0, y, width, height, False);
1344 UNBLOCK_INPUT; 1344 unblock_input ();
1345 } 1345 }
1346 1346
1347 if (WINDOWP (f->tool_bar_window)) 1347 if (WINDOWP (f->tool_bar_window))
@@ -1494,7 +1494,7 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name)
1494{ 1494{
1495 if (FRAME_X_WINDOW (f)) 1495 if (FRAME_X_WINDOW (f))
1496 { 1496 {
1497 BLOCK_INPUT; 1497 block_input ();
1498 { 1498 {
1499 XTextProperty text, icon; 1499 XTextProperty text, icon;
1500 ptrdiff_t bytes; 1500 ptrdiff_t bytes;
@@ -1586,7 +1586,7 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name)
1586 if (do_free_text_value) 1586 if (do_free_text_value)
1587 xfree (text.value); 1587 xfree (text.value);
1588 } 1588 }
1589 UNBLOCK_INPUT; 1589 unblock_input ();
1590 } 1590 }
1591} 1591}
1592 1592
@@ -1779,7 +1779,7 @@ hack_wm_protocols (FRAME_PTR f, Widget widget)
1779 int need_focus = 1; 1779 int need_focus = 1;
1780 int need_save = 1; 1780 int need_save = 1;
1781 1781
1782 BLOCK_INPUT; 1782 block_input ();
1783 { 1783 {
1784 Atom type; 1784 Atom type;
1785 unsigned char *catoms; 1785 unsigned char *catoms;
@@ -1827,7 +1827,7 @@ hack_wm_protocols (FRAME_PTR f, Widget widget)
1827 XA_ATOM, 32, PropModeAppend, 1827 XA_ATOM, 32, PropModeAppend,
1828 (unsigned char *) props, count); 1828 (unsigned char *) props, count);
1829 } 1829 }
1830 UNBLOCK_INPUT; 1830 unblock_input ();
1831} 1831}
1832#endif 1832#endif
1833 1833
@@ -2350,7 +2350,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2350 Arg al [25]; 2350 Arg al [25];
2351 int ac; 2351 int ac;
2352 2352
2353 BLOCK_INPUT; 2353 block_input ();
2354 2354
2355 /* Use the resource name as the top-level widget name 2355 /* Use the resource name as the top-level widget name
2356 for looking up resources. Make a non-Lisp copy 2356 for looking up resources. Make a non-Lisp copy
@@ -2572,7 +2572,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2572 f->output_data.x->current_cursor 2572 f->output_data.x->current_cursor
2573 = f->output_data.x->text_cursor); 2573 = f->output_data.x->text_cursor);
2574 2574
2575 UNBLOCK_INPUT; 2575 unblock_input ();
2576 2576
2577 /* This is a no-op, except under Motif. Make sure main areas are 2577 /* This is a no-op, except under Motif. Make sure main areas are
2578 set to something reasonable, in case we get an error later. */ 2578 set to something reasonable, in case we get an error later. */
@@ -2591,7 +2591,7 @@ x_window (FRAME_PTR f)
2591 FRAME_XIC (f) = NULL; 2591 FRAME_XIC (f) = NULL;
2592 if (use_xim) 2592 if (use_xim)
2593 { 2593 {
2594 BLOCK_INPUT; 2594 block_input ();
2595 create_frame_xic (f); 2595 create_frame_xic (f);
2596 if (FRAME_XIC (f)) 2596 if (FRAME_XIC (f))
2597 { 2597 {
@@ -2613,7 +2613,7 @@ x_window (FRAME_PTR f)
2613 attribute_mask, &attributes); 2613 attribute_mask, &attributes);
2614 } 2614 }
2615 } 2615 }
2616 UNBLOCK_INPUT; 2616 unblock_input ();
2617 } 2617 }
2618#endif 2618#endif
2619} 2619}
@@ -2638,7 +2638,7 @@ x_window (struct frame *f)
2638 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask 2638 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
2639 | CWColormap); 2639 | CWColormap);
2640 2640
2641 BLOCK_INPUT; 2641 block_input ();
2642 FRAME_X_WINDOW (f) 2642 FRAME_X_WINDOW (f)
2643 = XCreateWindow (FRAME_X_DISPLAY (f), 2643 = XCreateWindow (FRAME_X_DISPLAY (f),
2644 f->output_data.x->parent_desc, 2644 f->output_data.x->parent_desc,
@@ -2715,7 +2715,7 @@ x_window (struct frame *f)
2715 f->output_data.x->current_cursor 2715 f->output_data.x->current_cursor
2716 = f->output_data.x->text_cursor); 2716 = f->output_data.x->text_cursor);
2717 2717
2718 UNBLOCK_INPUT; 2718 unblock_input ();
2719 2719
2720 if (FRAME_X_WINDOW (f) == 0) 2720 if (FRAME_X_WINDOW (f) == 0)
2721 error ("Unable to create window"); 2721 error ("Unable to create window");
@@ -2768,7 +2768,7 @@ x_icon (struct frame *f, Lisp_Object parms)
2768 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound)) 2768 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
2769 error ("Both left and top icon corners of icon must be specified"); 2769 error ("Both left and top icon corners of icon must be specified");
2770 2770
2771 BLOCK_INPUT; 2771 block_input ();
2772 2772
2773 if (! EQ (icon_x, Qunbound)) 2773 if (! EQ (icon_x, Qunbound))
2774 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y)); 2774 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
@@ -2787,7 +2787,7 @@ x_icon (struct frame *f, Lisp_Object parms)
2787 ? f->icon_name 2787 ? f->icon_name
2788 : f->name))); 2788 : f->name)));
2789 2789
2790 UNBLOCK_INPUT; 2790 unblock_input ();
2791} 2791}
2792 2792
2793/* Make the GCs needed for this window, setting the 2793/* Make the GCs needed for this window, setting the
@@ -2799,7 +2799,7 @@ x_make_gc (struct frame *f)
2799{ 2799{
2800 XGCValues gc_values; 2800 XGCValues gc_values;
2801 2801
2802 BLOCK_INPUT; 2802 block_input ();
2803 2803
2804 /* Create the GCs of this frame. 2804 /* Create the GCs of this frame.
2805 Note that many default values are used. */ 2805 Note that many default values are used. */
@@ -2847,7 +2847,7 @@ x_make_gc (struct frame *f)
2847 FRAME_BACKGROUND_PIXEL (f), 2847 FRAME_BACKGROUND_PIXEL (f),
2848 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)))); 2848 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))));
2849 2849
2850 UNBLOCK_INPUT; 2850 unblock_input ();
2851} 2851}
2852 2852
2853 2853
@@ -2858,7 +2858,7 @@ x_free_gcs (struct frame *f)
2858{ 2858{
2859 Display *dpy = FRAME_X_DISPLAY (f); 2859 Display *dpy = FRAME_X_DISPLAY (f);
2860 2860
2861 BLOCK_INPUT; 2861 block_input ();
2862 2862
2863 if (f->output_data.x->normal_gc) 2863 if (f->output_data.x->normal_gc)
2864 { 2864 {
@@ -2884,7 +2884,7 @@ x_free_gcs (struct frame *f)
2884 f->output_data.x->border_tile = 0; 2884 f->output_data.x->border_tile = 0;
2885 } 2885 }
2886 2886
2887 UNBLOCK_INPUT; 2887 unblock_input ();
2888} 2888}
2889 2889
2890 2890
@@ -3007,10 +3007,10 @@ If FRAME is nil, use the selected frame. */)
3007 if (NILP (frame)) 3007 if (NILP (frame))
3008 frame = selected_frame; 3008 frame = selected_frame;
3009 f = XFRAME (frame); 3009 f = XFRAME (frame);
3010 BLOCK_INPUT; 3010 block_input ();
3011 if (FRAME_X_P (f)) 3011 if (FRAME_X_P (f))
3012 x_wm_set_size_hint (f, 0, 0); 3012 x_wm_set_size_hint (f, 0, 0);
3013 UNBLOCK_INPUT; 3013 unblock_input ();
3014 return Qnil; 3014 return Qnil;
3015} 3015}
3016 3016
@@ -3405,9 +3405,9 @@ This function is an internal primitive--use `make-frame' instead. */)
3405 /* Tell the server what size and position, etc, we want, and how 3405 /* Tell the server what size and position, etc, we want, and how
3406 badly we want them. This should be done after we have the menu 3406 badly we want them. This should be done after we have the menu
3407 bar so that its size can be taken into account. */ 3407 bar so that its size can be taken into account. */
3408 BLOCK_INPUT; 3408 block_input ();
3409 x_wm_set_size_hint (f, window_prompting, 0); 3409 x_wm_set_size_hint (f, window_prompting, 0);
3410 UNBLOCK_INPUT; 3410 unblock_input ();
3411 3411
3412 /* Make the window appear on the frame and enable display, unless 3412 /* Make the window appear on the frame and enable display, unless
3413 the caller says not to. However, with explicit parent, Emacs 3413 the caller says not to. However, with explicit parent, Emacs
@@ -3431,7 +3431,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3431 } 3431 }
3432 } 3432 }
3433 3433
3434 BLOCK_INPUT; 3434 block_input ();
3435 3435
3436 /* Set machine name and pid for the purpose of window managers. */ 3436 /* Set machine name and pid for the purpose of window managers. */
3437 set_machine_and_pid_properties (f); 3437 set_machine_and_pid_properties (f);
@@ -3447,7 +3447,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3447 (unsigned char *) &dpyinfo->client_leader_window, 1); 3447 (unsigned char *) &dpyinfo->client_leader_window, 1);
3448 } 3448 }
3449 3449
3450 UNBLOCK_INPUT; 3450 unblock_input ();
3451 3451
3452 /* Initialize `default-minibuffer-frame' in case this is the first 3452 /* Initialize `default-minibuffer-frame' in case this is the first
3453 frame on this terminal. */ 3453 frame on this terminal. */
@@ -3506,7 +3506,7 @@ FRAME nil means use the selected frame. */)
3506 struct frame *f = check_x_frame (frame); 3506 struct frame *f = check_x_frame (frame);
3507 Display *dpy = FRAME_X_DISPLAY (f); 3507 Display *dpy = FRAME_X_DISPLAY (f);
3508 3508
3509 BLOCK_INPUT; 3509 block_input ();
3510 x_catch_errors (dpy); 3510 x_catch_errors (dpy);
3511 3511
3512 if (FRAME_X_EMBEDDED_P (f)) 3512 if (FRAME_X_EMBEDDED_P (f))
@@ -3524,7 +3524,7 @@ FRAME nil means use the selected frame. */)
3524 } 3524 }
3525 3525
3526 x_uncatch_errors (); 3526 x_uncatch_errors ();
3527 UNBLOCK_INPUT; 3527 unblock_input ();
3528 3528
3529 return Qnil; 3529 return Qnil;
3530} 3530}
@@ -4152,9 +4152,9 @@ If TERMINAL is omitted or nil, that stands for the selected frame's display. */
4152void 4152void
4153x_sync (FRAME_PTR f) 4153x_sync (FRAME_PTR f)
4154{ 4154{
4155 BLOCK_INPUT; 4155 block_input ();
4156 XSync (FRAME_X_DISPLAY (f), False); 4156 XSync (FRAME_X_DISPLAY (f), False);
4157 UNBLOCK_INPUT; 4157 unblock_input ();
4158} 4158}
4159 4159
4160 4160
@@ -4229,7 +4229,7 @@ FRAME. Default is to change on the edit X window. */)
4229 nelements = SBYTES (value); 4229 nelements = SBYTES (value);
4230 } 4230 }
4231 4231
4232 BLOCK_INPUT; 4232 block_input ();
4233 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); 4233 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
4234 if (! NILP (type)) 4234 if (! NILP (type))
4235 { 4235 {
@@ -4248,7 +4248,7 @@ FRAME. Default is to change on the edit X window. */)
4248 4248
4249 /* Make sure the property is set when we return. */ 4249 /* Make sure the property is set when we return. */
4250 XFlush (FRAME_X_DISPLAY (f)); 4250 XFlush (FRAME_X_DISPLAY (f));
4251 UNBLOCK_INPUT; 4251 unblock_input ();
4252 4252
4253 return value; 4253 return value;
4254} 4254}
@@ -4264,13 +4264,13 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */)
4264 Atom prop_atom; 4264 Atom prop_atom;
4265 4265
4266 CHECK_STRING (prop); 4266 CHECK_STRING (prop);
4267 BLOCK_INPUT; 4267 block_input ();
4268 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); 4268 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
4269 XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom); 4269 XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom);
4270 4270
4271 /* Make sure the property is removed when we return. */ 4271 /* Make sure the property is removed when we return. */
4272 XFlush (FRAME_X_DISPLAY (f)); 4272 XFlush (FRAME_X_DISPLAY (f));
4273 UNBLOCK_INPUT; 4273 unblock_input ();
4274 4274
4275 return prop; 4275 return prop;
4276} 4276}
@@ -4318,7 +4318,7 @@ no value of TYPE (always string in the MS Windows case). */)
4318 target_window = FRAME_X_DISPLAY_INFO (f)->root_window; 4318 target_window = FRAME_X_DISPLAY_INFO (f)->root_window;
4319 } 4319 }
4320 4320
4321 BLOCK_INPUT; 4321 block_input ();
4322 if (STRINGP (type)) 4322 if (STRINGP (type))
4323 { 4323 {
4324 if (strcmp ("AnyPropertyType", SSDATA (type)) == 0) 4324 if (strcmp ("AnyPropertyType", SSDATA (type)) == 0)
@@ -4384,7 +4384,7 @@ no value of TYPE (always string in the MS Windows case). */)
4384 if (tmp_data) XFree (tmp_data); 4384 if (tmp_data) XFree (tmp_data);
4385 } 4385 }
4386 4386
4387 UNBLOCK_INPUT; 4387 unblock_input ();
4388 UNGCPRO; 4388 UNGCPRO;
4389 return prop_value; 4389 return prop_value;
4390} 4390}
@@ -4415,7 +4415,7 @@ show_hourglass (struct atimer *timer)
4415 { 4415 {
4416 Lisp_Object rest, frame; 4416 Lisp_Object rest, frame;
4417 4417
4418 BLOCK_INPUT; 4418 block_input ();
4419 4419
4420 FOR_EACH_FRAME (rest, frame) 4420 FOR_EACH_FRAME (rest, frame)
4421 { 4421 {
@@ -4459,7 +4459,7 @@ show_hourglass (struct atimer *timer)
4459 } 4459 }
4460 4460
4461 hourglass_shown_p = 1; 4461 hourglass_shown_p = 1;
4462 UNBLOCK_INPUT; 4462 unblock_input ();
4463 } 4463 }
4464} 4464}
4465 4465
@@ -4474,7 +4474,7 @@ hide_hourglass (void)
4474 { 4474 {
4475 Lisp_Object rest, frame; 4475 Lisp_Object rest, frame;
4476 4476
4477 BLOCK_INPUT; 4477 block_input ();
4478 FOR_EACH_FRAME (rest, frame) 4478 FOR_EACH_FRAME (rest, frame)
4479 { 4479 {
4480 struct frame *f = XFRAME (frame); 4480 struct frame *f = XFRAME (frame);
@@ -4493,7 +4493,7 @@ hide_hourglass (void)
4493 } 4493 }
4494 4494
4495 hourglass_shown_p = 0; 4495 hourglass_shown_p = 0;
4496 UNBLOCK_INPUT; 4496 unblock_input ();
4497 } 4497 }
4498} 4498}
4499 4499
@@ -4743,7 +4743,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4743 unsigned long mask; 4743 unsigned long mask;
4744 Atom type = FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type_tooltip; 4744 Atom type = FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type_tooltip;
4745 4745
4746 BLOCK_INPUT; 4746 block_input ();
4747 mask = CWBackPixel | CWOverrideRedirect | CWEventMask; 4747 mask = CWBackPixel | CWOverrideRedirect | CWEventMask;
4748 if (DoesSaveUnders (dpyinfo->screen)) 4748 if (DoesSaveUnders (dpyinfo->screen))
4749 mask |= CWSaveUnder; 4749 mask |= CWSaveUnder;
@@ -4770,7 +4770,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4770 FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type, 4770 FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type,
4771 XA_ATOM, 32, PropModeReplace, 4771 XA_ATOM, 32, PropModeReplace,
4772 (unsigned char *)&type, 1); 4772 (unsigned char *)&type, 1);
4773 UNBLOCK_INPUT; 4773 unblock_input ();
4774 } 4774 }
4775 4775
4776 x_make_gc (f); 4776 x_make_gc (f);
@@ -4884,10 +4884,10 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object
4884 show it. */ 4884 show it. */
4885 if (!INTEGERP (left) || !INTEGERP (top)) 4885 if (!INTEGERP (left) || !INTEGERP (top))
4886 { 4886 {
4887 BLOCK_INPUT; 4887 block_input ();
4888 XQueryPointer (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window, 4888 XQueryPointer (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
4889 &root, &child, root_x, root_y, &win_x, &win_y, &pmask); 4889 &root, &child, root_x, root_y, &win_x, &win_y, &pmask);
4890 UNBLOCK_INPUT; 4890 unblock_input ();
4891 } 4891 }
4892 4892
4893 if (INTEGERP (top)) 4893 if (INTEGERP (top))
@@ -4985,20 +4985,21 @@ Text larger than the specified size is clipped. */)
4985#ifdef USE_GTK 4985#ifdef USE_GTK
4986 if (x_gtk_use_system_tooltips) 4986 if (x_gtk_use_system_tooltips)
4987 { 4987 {
4988 int ok; 4988 bool ok;
4989 4989
4990 /* Hide a previous tip, if any. */ 4990 /* Hide a previous tip, if any. */
4991 Fx_hide_tip (); 4991 Fx_hide_tip ();
4992 4992
4993 BLOCK_INPUT; 4993 block_input ();
4994 if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0) 4994 ok = xg_prepare_tooltip (f, string, &width, &height);
4995 if (ok)
4995 { 4996 {
4996 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); 4997 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
4997 xg_show_tooltip (f, root_x, root_y); 4998 xg_show_tooltip (f, root_x, root_y);
4998 /* This is used in Fx_hide_tip. */ 4999 /* This is used in Fx_hide_tip. */
4999 XSETFRAME (tip_frame, f); 5000 XSETFRAME (tip_frame, f);
5000 } 5001 }
5001 UNBLOCK_INPUT; 5002 unblock_input ();
5002 if (ok) goto start_timer; 5003 if (ok) goto start_timer;
5003 } 5004 }
5004#endif /* USE_GTK */ 5005#endif /* USE_GTK */
@@ -5026,12 +5027,12 @@ Text larger than the specified size is clipped. */)
5026 call1 (Qcancel_timer, timer); 5027 call1 (Qcancel_timer, timer);
5027 } 5028 }
5028 5029
5029 BLOCK_INPUT; 5030 block_input ();
5030 compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f), 5031 compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f),
5031 FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y); 5032 FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y);
5032 XMoveWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), 5033 XMoveWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f),
5033 root_x, root_y); 5034 root_x, root_y);
5034 UNBLOCK_INPUT; 5035 unblock_input ();
5035 goto start_timer; 5036 goto start_timer;
5036 } 5037 }
5037 } 5038 }
@@ -5185,11 +5186,11 @@ Text larger than the specified size is clipped. */)
5185 show it. */ 5186 show it. */
5186 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); 5187 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
5187 5188
5188 BLOCK_INPUT; 5189 block_input ();
5189 XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5190 XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5190 root_x, root_y, width, height); 5191 root_x, root_y, width, height);
5191 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 5192 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
5192 UNBLOCK_INPUT; 5193 unblock_input ();
5193 5194
5194 /* Draw into the window. */ 5195 /* Draw into the window. */
5195 w->must_be_updated_p = 1; 5196 w->must_be_updated_p = 1;
@@ -5261,9 +5262,9 @@ Value is t if tooltip was open, nil otherwise. */)
5261 if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) 5262 if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen)
5262 && w != NULL) 5263 && w != NULL)
5263 { 5264 {
5264 BLOCK_INPUT; 5265 block_input ();
5265 xlwmenu_redisplay (w); 5266 xlwmenu_redisplay (w);
5266 UNBLOCK_INPUT; 5267 unblock_input ();
5267 } 5268 }
5268 } 5269 }
5269#endif /* USE_LUCID */ 5270#endif /* USE_LUCID */
@@ -5327,11 +5328,11 @@ clean_up_file_dialog (Lisp_Object arg)
5327 Widget dialog = (Widget) p->pointer; 5328 Widget dialog = (Widget) p->pointer;
5328 5329
5329 /* Clean up. */ 5330 /* Clean up. */
5330 BLOCK_INPUT; 5331 block_input ();
5331 XtUnmanageChild (dialog); 5332 XtUnmanageChild (dialog);
5332 XtDestroyWidget (dialog); 5333 XtDestroyWidget (dialog);
5333 x_menu_set_in_use (0); 5334 x_menu_set_in_use (0);
5334 UNBLOCK_INPUT; 5335 unblock_input ();
5335 5336
5336 return Qnil; 5337 return Qnil;
5337} 5338}
@@ -5372,7 +5373,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5372 /* Prevent redisplay. */ 5373 /* Prevent redisplay. */
5373 specbind (Qinhibit_redisplay, Qt); 5374 specbind (Qinhibit_redisplay, Qt);
5374 5375
5375 BLOCK_INPUT; 5376 block_input ();
5376 5377
5377 /* Create the dialog with PROMPT as title, using DIR as initial 5378 /* Create the dialog with PROMPT as title, using DIR as initial
5378 directory and using "*" as pattern. */ 5379 directory and using "*" as pattern. */
@@ -5486,7 +5487,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5486 else 5487 else
5487 file = Qnil; 5488 file = Qnil;
5488 5489
5489 UNBLOCK_INPUT; 5490 unblock_input ();
5490 UNGCPRO; 5491 UNGCPRO;
5491 5492
5492 /* Make "Cancel" equivalent to C-g. */ 5493 /* Make "Cancel" equivalent to C-g. */
@@ -5543,7 +5544,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5543 specbind (Qinhibit_redisplay, Qt); 5544 specbind (Qinhibit_redisplay, Qt);
5544 record_unwind_protect (clean_up_dialog, Qnil); 5545 record_unwind_protect (clean_up_dialog, Qnil);
5545 5546
5546 BLOCK_INPUT; 5547 block_input ();
5547 5548
5548 if (STRINGP (default_filename)) 5549 if (STRINGP (default_filename))
5549 cdef_file = SSDATA (default_filename); 5550 cdef_file = SSDATA (default_filename);
@@ -5560,7 +5561,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5560 xfree (fn); 5561 xfree (fn);
5561 } 5562 }
5562 5563
5563 UNBLOCK_INPUT; 5564 unblock_input ();
5564 UNGCPRO; 5565 UNGCPRO;
5565 5566
5566 /* Make "Cancel" equivalent to C-g. */ 5567 /* Make "Cancel" equivalent to C-g. */
@@ -5600,7 +5601,7 @@ nil, it defaults to the selected frame. */)
5600 specbind (Qinhibit_redisplay, Qt); 5601 specbind (Qinhibit_redisplay, Qt);
5601 record_unwind_protect (clean_up_dialog, Qnil); 5602 record_unwind_protect (clean_up_dialog, Qnil);
5602 5603
5603 BLOCK_INPUT; 5604 block_input ();
5604 5605
5605 GCPRO2 (font_param, font); 5606 GCPRO2 (font_param, font);
5606 5607
@@ -5618,7 +5619,7 @@ nil, it defaults to the selected frame. */)
5618 font = xg_get_font (f, default_name); 5619 font = xg_get_font (f, default_name);
5619 xfree (default_name); 5620 xfree (default_name);
5620 5621
5621 UNBLOCK_INPUT; 5622 unblock_input ();
5622 5623
5623 if (NILP (font)) 5624 if (NILP (font))
5624 Fsignal (Qquit, Qnil); 5625 Fsignal (Qquit, Qnil);
@@ -5655,14 +5656,14 @@ present and mapped to the usual X keysyms. */)
5655 Lisp_Object have_keys; 5656 Lisp_Object have_keys;
5656 int major, minor, op, event, error_code; 5657 int major, minor, op, event, error_code;
5657 5658
5658 BLOCK_INPUT; 5659 block_input ();
5659 5660
5660 /* Check library version in case we're dynamically linked. */ 5661 /* Check library version in case we're dynamically linked. */
5661 major = XkbMajorVersion; 5662 major = XkbMajorVersion;
5662 minor = XkbMinorVersion; 5663 minor = XkbMinorVersion;
5663 if (!XkbLibraryVersion (&major, &minor)) 5664 if (!XkbLibraryVersion (&major, &minor))
5664 { 5665 {
5665 UNBLOCK_INPUT; 5666 unblock_input ();
5666 return Qlambda; 5667 return Qlambda;
5667 } 5668 }
5668 5669
@@ -5671,7 +5672,7 @@ present and mapped to the usual X keysyms. */)
5671 minor = XkbMinorVersion; 5672 minor = XkbMinorVersion;
5672 if (!XkbQueryExtension (dpy, &op, &event, &error_code, &major, &minor)) 5673 if (!XkbQueryExtension (dpy, &op, &event, &error_code, &major, &minor))
5673 { 5674 {
5674 UNBLOCK_INPUT; 5675 unblock_input ();
5675 return Qlambda; 5676 return Qlambda;
5676 } 5677 }
5677 5678
@@ -5724,7 +5725,7 @@ present and mapped to the usual X keysyms. */)
5724 && XKeysymToKeycode (dpy, XK_BackSpace) == backspace_keycode) 5725 && XKeysymToKeycode (dpy, XK_BackSpace) == backspace_keycode)
5725 have_keys = Qt; 5726 have_keys = Qt;
5726 } 5727 }
5727 UNBLOCK_INPUT; 5728 unblock_input ();
5728 return have_keys; 5729 return have_keys;
5729#else /* not HAVE_XKBGETKEYBOARD */ 5730#else /* not HAVE_XKBGETKEYBOARD */
5730 return Qlambda; 5731 return Qlambda;
diff --git a/src/xfont.c b/src/xfont.c
index 1f2fd13f1b7..2d493088b0b 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -362,7 +362,7 @@ xfont_list_pattern (Display *display, const char *pattern,
362 } 362 }
363 } 363 }
364 364
365 BLOCK_INPUT; 365 block_input ();
366 x_catch_errors (display); 366 x_catch_errors (display);
367 367
368 for (limit = 512; ; limit *= 2) 368 for (limit = 512; ; limit *= 2)
@@ -479,7 +479,7 @@ xfont_list_pattern (Display *display, const char *pattern,
479 } 479 }
480 480
481 x_uncatch_errors (); 481 x_uncatch_errors ();
482 UNBLOCK_INPUT; 482 unblock_input ();
483 483
484 FONT_ADD_LOG ("xfont-list", build_string (pattern), list); 484 FONT_ADD_LOG ("xfont-list", build_string (pattern), list);
485 return list; 485 return list;
@@ -588,7 +588,7 @@ xfont_match (Lisp_Object frame, Lisp_Object spec)
588 if (xfont_encode_coding_xlfd (name) < 0) 588 if (xfont_encode_coding_xlfd (name) < 0)
589 return Qnil; 589 return Qnil;
590 590
591 BLOCK_INPUT; 591 block_input ();
592 entity = Qnil; 592 entity = Qnil;
593 xfont = XLoadQueryFont (display, name); 593 xfont = XLoadQueryFont (display, name);
594 if (xfont) 594 if (xfont)
@@ -615,7 +615,7 @@ xfont_match (Lisp_Object frame, Lisp_Object spec)
615 } 615 }
616 XFreeFont (display, xfont); 616 XFreeFont (display, xfont);
617 } 617 }
618 UNBLOCK_INPUT; 618 unblock_input ();
619 619
620 FONT_ADD_LOG ("xfont-match", spec, entity); 620 FONT_ADD_LOG ("xfont-match", spec, entity);
621 return entity; 621 return entity;
@@ -632,7 +632,7 @@ xfont_list_family (Lisp_Object frame)
632 char *last_family IF_LINT (= 0); 632 char *last_family IF_LINT (= 0);
633 int last_len; 633 int last_len;
634 634
635 BLOCK_INPUT; 635 block_input ();
636 x_catch_errors (dpyinfo->display); 636 x_catch_errors (dpyinfo->display);
637 names = XListFonts (dpyinfo->display, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*", 637 names = XListFonts (dpyinfo->display, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
638 0x8000, &num_fonts); 638 0x8000, &num_fonts);
@@ -673,7 +673,7 @@ xfont_list_family (Lisp_Object frame)
673 673
674 XFreeFontNames (names); 674 XFreeFontNames (names);
675 x_uncatch_errors (); 675 x_uncatch_errors ();
676 UNBLOCK_INPUT; 676 unblock_input ();
677 677
678 return list; 678 return list;
679} 679}
@@ -717,7 +717,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
717 return Qnil; 717 return Qnil;
718 } 718 }
719 719
720 BLOCK_INPUT; 720 block_input ();
721 x_catch_errors (display); 721 x_catch_errors (display);
722 xfont = XLoadQueryFont (display, name); 722 xfont = XLoadQueryFont (display, name);
723 if (x_had_errors_p (display)) 723 if (x_had_errors_p (display))
@@ -784,7 +784,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
784 XFree (p0); 784 XFree (p0);
785 } 785 }
786 x_uncatch_errors (); 786 x_uncatch_errors ();
787 UNBLOCK_INPUT; 787 unblock_input ();
788 788
789 if (! xfont) 789 if (! xfont)
790 { 790 {
@@ -866,7 +866,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
866 } 866 }
867 } 867 }
868 868
869 BLOCK_INPUT; 869 block_input ();
870 font->underline_thickness 870 font->underline_thickness
871 = (XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &value) 871 = (XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &value)
872 ? (long) value : 0); 872 ? (long) value : 0);
@@ -882,7 +882,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
882 font->default_ascent 882 font->default_ascent
883 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_DEFAULT_ASCENT, &value) 883 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_DEFAULT_ASCENT, &value)
884 ? (long) value : 0); 884 ? (long) value : 0);
885 UNBLOCK_INPUT; 885 unblock_input ();
886 886
887 if (NILP (fullname)) 887 if (NILP (fullname))
888 fullname = AREF (font_object, FONT_NAME_INDEX); 888 fullname = AREF (font_object, FONT_NAME_INDEX);
@@ -897,18 +897,18 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
897static void 897static void
898xfont_close (FRAME_PTR f, struct font *font) 898xfont_close (FRAME_PTR f, struct font *font)
899{ 899{
900 BLOCK_INPUT; 900 block_input ();
901 XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont); 901 XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont);
902 UNBLOCK_INPUT; 902 unblock_input ();
903} 903}
904 904
905static int 905static int
906xfont_prepare_face (FRAME_PTR f, struct face *face) 906xfont_prepare_face (FRAME_PTR f, struct face *face)
907{ 907{
908 BLOCK_INPUT; 908 block_input ();
909 XSetFont (FRAME_X_DISPLAY (f), face->gc, 909 XSetFont (FRAME_X_DISPLAY (f), face->gc,
910 ((struct xfont_info *) face->font)->xfont->fid); 910 ((struct xfont_info *) face->font)->xfont->fid);
911 UNBLOCK_INPUT; 911 unblock_input ();
912 912
913 return 0; 913 return 0;
914} 914}
@@ -1028,9 +1028,9 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1028 1028
1029 if (s->gc != s->face->gc) 1029 if (s->gc != s->face->gc)
1030 { 1030 {
1031 BLOCK_INPUT; 1031 block_input ();
1032 XSetFont (s->display, gc, xfont->fid); 1032 XSetFont (s->display, gc, xfont->fid);
1033 UNBLOCK_INPUT; 1033 unblock_input ();
1034 } 1034 }
1035 1035
1036 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) 1036 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0)
@@ -1039,7 +1039,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1039 char *str = SAFE_ALLOCA (len); 1039 char *str = SAFE_ALLOCA (len);
1040 for (i = 0; i < len ; i++) 1040 for (i = 0; i < len ; i++)
1041 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); 1041 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
1042 BLOCK_INPUT; 1042 block_input ();
1043 if (with_background) 1043 if (with_background)
1044 { 1044 {
1045 if (s->padding_p) 1045 if (s->padding_p)
@@ -1060,12 +1060,12 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1060 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), 1060 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f),
1061 gc, x, y, str, len); 1061 gc, x, y, str, len);
1062 } 1062 }
1063 UNBLOCK_INPUT; 1063 unblock_input ();
1064 SAFE_FREE (); 1064 SAFE_FREE ();
1065 return s->nchars; 1065 return s->nchars;
1066 } 1066 }
1067 1067
1068 BLOCK_INPUT; 1068 block_input ();
1069 if (with_background) 1069 if (with_background)
1070 { 1070 {
1071 if (s->padding_p) 1071 if (s->padding_p)
@@ -1086,7 +1086,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1086 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), 1086 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f),
1087 gc, x, y, s->char2b + from, len); 1087 gc, x, y, s->char2b + from, len);
1088 } 1088 }
1089 UNBLOCK_INPUT; 1089 unblock_input ();
1090 1090
1091 return len; 1091 return len;
1092} 1092}
diff --git a/src/xftfont.c b/src/xftfont.c
index 9f52eb8b233..372ed87705f 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -93,7 +93,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
93 XGCValues xgcv; 93 XGCValues xgcv;
94 bool fg_done = 0, bg_done = 0; 94 bool fg_done = 0, bg_done = 0;
95 95
96 BLOCK_INPUT; 96 block_input ();
97 XGetGCValues (FRAME_X_DISPLAY (f), gc, 97 XGetGCValues (FRAME_X_DISPLAY (f), gc,
98 GCForeground | GCBackground, &xgcv); 98 GCForeground | GCBackground, &xgcv);
99 if (xftface_info) 99 if (xftface_info)
@@ -131,7 +131,7 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
131 bg->color.blue = colors[1].blue; 131 bg->color.blue = colors[1].blue;
132 } 132 }
133 } 133 }
134 UNBLOCK_INPUT; 134 unblock_input ();
135 } 135 }
136} 136}
137 137
@@ -324,7 +324,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
324 FcPatternAddInteger (pat, FC_INDEX, XINT (idx)); 324 FcPatternAddInteger (pat, FC_INDEX, XINT (idx));
325 325
326 326
327 BLOCK_INPUT; 327 block_input ();
328 /* Make sure that the Xrender extension is added before the Xft one. 328 /* Make sure that the Xrender extension is added before the Xft one.
329 Otherwise, the close-display hook set by Xft is called after the 329 Otherwise, the close-display hook set by Xft is called after the
330 one for Xrender, and the former tries to re-add the latter. This 330 one for Xrender, and the former tries to re-add the latter. This
@@ -345,12 +345,12 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
345 xftfont = XftFontOpenPattern (display, match); 345 xftfont = XftFontOpenPattern (display, match);
346 if (!xftfont) 346 if (!xftfont)
347 { 347 {
348 UNBLOCK_INPUT; 348 unblock_input ();
349 XftPatternDestroy (match); 349 XftPatternDestroy (match);
350 return Qnil; 350 return Qnil;
351 } 351 }
352 ft_face = XftLockFace (xftfont); 352 ft_face = XftLockFace (xftfont);
353 UNBLOCK_INPUT; 353 unblock_input ();
354 354
355 /* We should not destroy PAT here because it is kept in XFTFONT and 355 /* We should not destroy PAT here because it is kept in XFTFONT and
356 destroyed automatically when XFTFONT is closed. */ 356 destroyed automatically when XFTFONT is closed. */
@@ -399,7 +399,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
399 for (ch = 0; ch < 95; ch++) 399 for (ch = 0; ch < 95; ch++)
400 ascii_printable[ch] = ' ' + ch; 400 ascii_printable[ch] = ' ' + ch;
401 } 401 }
402 BLOCK_INPUT; 402 block_input ();
403 403
404 /* Unfortunately Xft doesn't provide a way to get minimum char 404 /* Unfortunately Xft doesn't provide a way to get minimum char
405 width. So, we set min_width to space_width. */ 405 width. So, we set min_width to space_width. */
@@ -425,7 +425,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
425 XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); 425 XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents);
426 font->average_width = (font->space_width + extents.xOff) / 95; 426 font->average_width = (font->space_width + extents.xOff) / 95;
427 } 427 }
428 UNBLOCK_INPUT; 428 unblock_input ();
429 429
430 font->ascent = xftfont->ascent; 430 font->ascent = xftfont->ascent;
431 font->descent = xftfont->descent; 431 font->descent = xftfont->descent;
@@ -494,10 +494,10 @@ xftfont_close (FRAME_PTR f, struct font *font)
494 if (xftfont_info->otf) 494 if (xftfont_info->otf)
495 OTF_close (xftfont_info->otf); 495 OTF_close (xftfont_info->otf);
496#endif 496#endif
497 BLOCK_INPUT; 497 block_input ();
498 XftUnlockFace (xftfont_info->xftfont); 498 XftUnlockFace (xftfont_info->xftfont);
499 XftFontClose (xftfont_info->display, xftfont_info->xftfont); 499 XftFontClose (xftfont_info->display, xftfont_info->xftfont);
500 UNBLOCK_INPUT; 500 unblock_input ();
501} 501}
502 502
503static int 503static int
@@ -581,10 +581,10 @@ xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct
581 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 581 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
582 XGlyphInfo extents; 582 XGlyphInfo extents;
583 583
584 BLOCK_INPUT; 584 block_input ();
585 XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs, 585 XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs,
586 &extents); 586 &extents);
587 UNBLOCK_INPUT; 587 unblock_input ();
588 if (metrics) 588 if (metrics)
589 { 589 {
590 metrics->lbearing = - extents.x; 590 metrics->lbearing = - extents.x;
@@ -603,12 +603,12 @@ xftfont_get_xft_draw (FRAME_PTR f)
603 603
604 if (! xft_draw) 604 if (! xft_draw)
605 { 605 {
606 BLOCK_INPUT; 606 block_input ();
607 xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f), 607 xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f),
608 FRAME_X_WINDOW (f), 608 FRAME_X_WINDOW (f),
609 FRAME_X_VISUAL (f), 609 FRAME_X_VISUAL (f),
610 FRAME_X_COLORMAP (f)); 610 FRAME_X_COLORMAP (f));
611 UNBLOCK_INPUT; 611 unblock_input ();
612 eassert (xft_draw != NULL); 612 eassert (xft_draw != NULL);
613 font_put_frame_data (f, &xftfont_driver, xft_draw); 613 font_put_frame_data (f, &xftfont_driver, xft_draw);
614 } 614 }
@@ -633,7 +633,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
633 xftface_info = (struct xftface_info *) face->extra; 633 xftface_info = (struct xftface_info *) face->extra;
634 xftfont_get_colors (f, face, s->gc, xftface_info, 634 xftfont_get_colors (f, face, s->gc, xftface_info,
635 &fg, with_background ? &bg : NULL); 635 &fg, with_background ? &bg : NULL);
636 BLOCK_INPUT; 636 block_input ();
637 if (s->num_clips > 0) 637 if (s->num_clips > 0)
638 XftDrawSetClipRectangles (xft_draw, 0, 0, s->clip, s->num_clips); 638 XftDrawSetClipRectangles (xft_draw, 0, 0, s->clip, s->num_clips);
639 else 639 else
@@ -654,7 +654,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
654 else 654 else
655 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont, 655 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont,
656 x, y, code, len); 656 x, y, code, len);
657 UNBLOCK_INPUT; 657 unblock_input ();
658 658
659 return len; 659 return len;
660} 660}
@@ -690,9 +690,9 @@ xftfont_end_for_frame (FRAME_PTR f)
690 690
691 if (xft_draw) 691 if (xft_draw)
692 { 692 {
693 BLOCK_INPUT; 693 block_input ();
694 XftDrawDestroy (xft_draw); 694 XftDrawDestroy (xft_draw);
695 UNBLOCK_INPUT; 695 unblock_input ();
696 font_put_frame_data (f, &xftfont_driver, NULL); 696 font_put_frame_data (f, &xftfont_driver, NULL);
697 } 697 }
698 return 0; 698 return 0;
diff --git a/src/xmenu.c b/src/xmenu.c
index d03a4bc974b..96a1ae87fdc 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -165,7 +165,7 @@ mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
165 if (! FRAME_X_P (f)) 165 if (! FRAME_X_P (f))
166 emacs_abort (); 166 emacs_abort ();
167 167
168 BLOCK_INPUT; 168 block_input ();
169 169
170 XQueryPointer (FRAME_X_DISPLAY (f), 170 XQueryPointer (FRAME_X_DISPLAY (f),
171 DefaultRootWindow (FRAME_X_DISPLAY (f)), 171 DefaultRootWindow (FRAME_X_DISPLAY (f)),
@@ -186,7 +186,7 @@ mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
186 we don't care. */ 186 we don't care. */
187 (unsigned int *) &dummy); 187 (unsigned int *) &dummy);
188 188
189 UNBLOCK_INPUT; 189 unblock_input ();
190 190
191 /* xmenu_show expects window coordinates, not root window 191 /* xmenu_show expects window coordinates, not root window
192 coordinates. Translate. */ 192 coordinates. Translate. */
@@ -328,9 +328,9 @@ for instance using the window manager, then this produces a quit and
328 list_of_panes (Fcons (contents, Qnil)); 328 list_of_panes (Fcons (contents, Qnil));
329 329
330 /* Display them in a dialog box. */ 330 /* Display them in a dialog box. */
331 BLOCK_INPUT; 331 block_input ();
332 selection = xdialog_show (f, 0, title, header, &error_name); 332 selection = xdialog_show (f, 0, title, header, &error_name);
333 UNBLOCK_INPUT; 333 unblock_input ();
334 334
335 unbind_to (specpdl_count, Qnil); 335 unbind_to (specpdl_count, Qnil);
336 discard_menu_items (); 336 discard_menu_items ();
@@ -490,7 +490,7 @@ If FRAME is nil or not given, use the selected frame. */)
490 XEvent ev; 490 XEvent ev;
491 FRAME_PTR f = check_x_frame (frame); 491 FRAME_PTR f = check_x_frame (frame);
492 Widget menubar; 492 Widget menubar;
493 BLOCK_INPUT; 493 block_input ();
494 494
495 if (FRAME_EXTERNAL_MENU_BAR (f)) 495 if (FRAME_EXTERNAL_MENU_BAR (f))
496 set_frame_menubar (f, 0, 1); 496 set_frame_menubar (f, 0, 1);
@@ -548,7 +548,7 @@ If FRAME is nil or not given, use the selected frame. */)
548 } 548 }
549 } 549 }
550 550
551 UNBLOCK_INPUT; 551 unblock_input ();
552 552
553 return Qnil; 553 return Qnil;
554} 554}
@@ -569,9 +569,9 @@ If FRAME is nil or not given, use the selected frame. */)
569 FRAME_PTR f; 569 FRAME_PTR f;
570 570
571 /* gcc 2.95 doesn't accept the FRAME_PTR declaration after 571 /* gcc 2.95 doesn't accept the FRAME_PTR declaration after
572 BLOCK_INPUT. */ 572 block_input (). */
573 573
574 BLOCK_INPUT; 574 block_input ();
575 f = check_x_frame (frame); 575 f = check_x_frame (frame);
576 576
577 if (FRAME_EXTERNAL_MENU_BAR (f)) 577 if (FRAME_EXTERNAL_MENU_BAR (f))
@@ -590,7 +590,7 @@ If FRAME is nil or not given, use the selected frame. */)
590 g_list_free (children); 590 g_list_free (children);
591 } 591 }
592 } 592 }
593 UNBLOCK_INPUT; 593 unblock_input ();
594 594
595 return Qnil; 595 return Qnil;
596} 596}
@@ -642,7 +642,7 @@ x_activate_menubar (FRAME_PTR f)
642#endif 642#endif
643 643
644 set_frame_menubar (f, 0, 1); 644 set_frame_menubar (f, 0, 1);
645 BLOCK_INPUT; 645 block_input ();
646 popup_activated_flag = 1; 646 popup_activated_flag = 1;
647#ifdef USE_GTK 647#ifdef USE_GTK
648 XPutBackEvent (f->output_data.x->display_info->display, 648 XPutBackEvent (f->output_data.x->display_info->display,
@@ -650,7 +650,7 @@ x_activate_menubar (FRAME_PTR f)
650#else 650#else
651 XtDispatchEvent (f->output_data.x->saved_menu_event); 651 XtDispatchEvent (f->output_data.x->saved_menu_event);
652#endif 652#endif
653 UNBLOCK_INPUT; 653 unblock_input ();
654 654
655 /* Ignore this if we get it a second time. */ 655 /* Ignore this if we get it a second time. */
656 f->output_data.x->saved_menu_event->type = 0; 656 f->output_data.x->saved_menu_event->type = 0;
@@ -803,10 +803,10 @@ menubar_selection_callback (GtkWidget *widget, gpointer client_data)
803 sit-for will exit at once if the focus event follows the menu selection 803 sit-for will exit at once if the focus event follows the menu selection
804 event. */ 804 event. */
805 805
806 BLOCK_INPUT; 806 block_input ();
807 while (gtk_events_pending ()) 807 while (gtk_events_pending ())
808 gtk_main_iteration (); 808 gtk_main_iteration ();
809 UNBLOCK_INPUT; 809 unblock_input ();
810 810
811 find_and_call_menu_selection (cb_data->cl_data->f, 811 find_and_call_menu_selection (cb_data->cl_data->f,
812 cb_data->cl_data->menu_bar_items_used, 812 cb_data->cl_data->menu_bar_items_used,
@@ -834,13 +834,13 @@ menubar_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
834#endif /* not USE_GTK */ 834#endif /* not USE_GTK */
835 835
836/* Recompute all the widgets of frame F, when the menu bar has been 836/* Recompute all the widgets of frame F, when the menu bar has been
837 changed. Value is non-zero if widgets were updated. */ 837 changed. */
838 838
839static int 839static void
840update_frame_menubar (FRAME_PTR f) 840update_frame_menubar (FRAME_PTR f)
841{ 841{
842#ifdef USE_GTK 842#ifdef USE_GTK
843 return xg_update_frame_menubar (f); 843 xg_update_frame_menubar (f);
844#else 844#else
845 struct x_output *x; 845 struct x_output *x;
846 int columns, rows; 846 int columns, rows;
@@ -851,9 +851,9 @@ update_frame_menubar (FRAME_PTR f)
851 x = f->output_data.x; 851 x = f->output_data.x;
852 852
853 if (!x->menubar_widget || XtIsManaged (x->menubar_widget)) 853 if (!x->menubar_widget || XtIsManaged (x->menubar_widget))
854 return 0; 854 return;
855 855
856 BLOCK_INPUT; 856 block_input ();
857 /* Save the size of the frame because the pane widget doesn't accept 857 /* Save the size of the frame because the pane widget doesn't accept
858 to resize itself. So force it. */ 858 to resize itself. So force it. */
859 columns = FRAME_COLS (f); 859 columns = FRAME_COLS (f);
@@ -880,9 +880,8 @@ update_frame_menubar (FRAME_PTR f)
880 880
881 /* Force the pane widget to resize itself with the right values. */ 881 /* Force the pane widget to resize itself with the right values. */
882 EmacsFrameSetCharSize (x->edit_widget, columns, rows); 882 EmacsFrameSetCharSize (x->edit_widget, columns, rows);
883 UNBLOCK_INPUT; 883 unblock_input ();
884#endif 884#endif
885 return 1;
886} 885}
887 886
888#ifdef USE_LUCID 887#ifdef USE_LUCID
@@ -921,7 +920,7 @@ apply_systemfont_to_menu (struct frame *f, Widget w)
921 it is set the first time this is called, from initialize_frame_menubar. */ 920 it is set the first time this is called, from initialize_frame_menubar. */
922 921
923void 922void
924set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) 923set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
925{ 924{
926 xt_or_gtk_widget menubar_widget; 925 xt_or_gtk_widget menubar_widget;
927#ifdef USE_X_TOOLKIT 926#ifdef USE_X_TOOLKIT
@@ -1164,7 +1163,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
1164 1163
1165 /* Create or update the menu bar widget. */ 1164 /* Create or update the menu bar widget. */
1166 1165
1167 BLOCK_INPUT; 1166 block_input ();
1168 1167
1169#ifdef USE_GTK 1168#ifdef USE_GTK
1170 xg_crazy_callback_abort = 1; 1169 xg_crazy_callback_abort = 1;
@@ -1264,7 +1263,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
1264 xg_crazy_callback_abort = 0; 1263 xg_crazy_callback_abort = 0;
1265#endif 1264#endif
1266 1265
1267 UNBLOCK_INPUT; 1266 unblock_input ();
1268} 1267}
1269 1268
1270/* Called from Fx_create_frame to create the initial menubar of a frame 1269/* Called from Fx_create_frame to create the initial menubar of a frame
@@ -1313,7 +1312,7 @@ free_frame_menubar (FRAME_PTR f)
1313 Position x0, y0, x1, y1; 1312 Position x0, y0, x1, y1;
1314#endif 1313#endif
1315 1314
1316 BLOCK_INPUT; 1315 block_input ();
1317 1316
1318#ifdef USE_MOTIF 1317#ifdef USE_MOTIF
1319 if (f->output_data.x->widget) 1318 if (f->output_data.x->widget)
@@ -1332,7 +1331,7 @@ free_frame_menubar (FRAME_PTR f)
1332#endif 1331#endif
1333 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); 1332 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
1334 } 1333 }
1335 UNBLOCK_INPUT; 1334 unblock_input ();
1336 } 1335 }
1337} 1336}
1338#endif /* not USE_GTK */ 1337#endif /* not USE_GTK */
@@ -1417,9 +1416,9 @@ pop_down_menu (Lisp_Object arg)
1417 struct Lisp_Save_Value *p = XSAVE_VALUE (arg); 1416 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1418 1417
1419 popup_activated_flag = 0; 1418 popup_activated_flag = 0;
1420 BLOCK_INPUT; 1419 block_input ();
1421 gtk_widget_destroy (GTK_WIDGET (p->pointer)); 1420 gtk_widget_destroy (GTK_WIDGET (p->pointer));
1422 UNBLOCK_INPUT; 1421 unblock_input ();
1423 return Qnil; 1422 return Qnil;
1424} 1423}
1425 1424
@@ -1527,9 +1526,9 @@ pop_down_menu (Lisp_Object arg)
1527 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) 1526 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
1528 | XINT (XCDR (arg))); 1527 | XINT (XCDR (arg)));
1529 1528
1530 BLOCK_INPUT; 1529 block_input ();
1531 lw_destroy_all_widgets (id); 1530 lw_destroy_all_widgets (id);
1532 UNBLOCK_INPUT; 1531 unblock_input ();
1533 popup_activated_flag = 0; 1532 popup_activated_flag = 0;
1534 1533
1535 return Qnil; 1534 return Qnil;
@@ -1955,9 +1954,9 @@ dialog_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
1955 if ((intptr_t) client_data != -1) 1954 if ((intptr_t) client_data != -1)
1956 menu_item_selection = (Lisp_Object *) client_data; 1955 menu_item_selection = (Lisp_Object *) client_data;
1957 1956
1958 BLOCK_INPUT; 1957 block_input ();
1959 lw_destroy_all_widgets (id); 1958 lw_destroy_all_widgets (id);
1960 UNBLOCK_INPUT; 1959 unblock_input ();
1961 popup_activated_flag = 0; 1960 popup_activated_flag = 0;
1962} 1961}
1963 1962
@@ -2251,7 +2250,7 @@ pop_down_menu (Lisp_Object arg)
2251 FRAME_PTR f = p1->pointer; 2250 FRAME_PTR f = p1->pointer;
2252 XMenu *menu = p2->pointer; 2251 XMenu *menu = p2->pointer;
2253 2252
2254 BLOCK_INPUT; 2253 block_input ();
2255#ifndef MSDOS 2254#ifndef MSDOS
2256 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime); 2255 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
2257 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime); 2256 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
@@ -2271,7 +2270,7 @@ pop_down_menu (Lisp_Object arg)
2271 2270
2272#endif /* HAVE_X_WINDOWS */ 2271#endif /* HAVE_X_WINDOWS */
2273 2272
2274 UNBLOCK_INPUT; 2273 unblock_input ();
2275 2274
2276 return Qnil; 2275 return Qnil;
2277} 2276}
diff --git a/src/xml.c b/src/xml.c
index b668525cf26..a22ca208743 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -82,7 +82,7 @@ libxml2_loaded_p (void)
82#endif /* !WINDOWSNT */ 82#endif /* !WINDOWSNT */
83 83
84static int 84static int
85init_libxml2_functions (Lisp_Object libraries) 85init_libxml2_functions (void)
86{ 86{
87#ifdef WINDOWSNT 87#ifdef WINDOWSNT
88 if (libxml2_loaded_p ()) 88 if (libxml2_loaded_p ())
@@ -91,7 +91,7 @@ init_libxml2_functions (Lisp_Object libraries)
91 { 91 {
92 HMODULE library; 92 HMODULE library;
93 93
94 if (!(library = w32_delayed_load (libraries, Qlibxml2_dll))) 94 if (!(library = w32_delayed_load (Qlibxml2_dll)))
95 { 95 {
96 message ("%s", "libxml2 library not found"); 96 message ("%s", "libxml2 library not found");
97 return 0; 97 return 0;
@@ -257,7 +257,7 @@ DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
257If BASE-URL is non-nil, it is used to expand relative URLs. */) 257If BASE-URL is non-nil, it is used to expand relative URLs. */)
258 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url) 258 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
259{ 259{
260 if (init_libxml2_functions (Vdynamic_library_alist)) 260 if (init_libxml2_functions ())
261 return parse_region (start, end, base_url, 1); 261 return parse_region (start, end, base_url, 1);
262 return Qnil; 262 return Qnil;
263} 263}
@@ -269,7 +269,7 @@ DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
269If BASE-URL is non-nil, it is used to expand relative URLs. */) 269If BASE-URL is non-nil, it is used to expand relative URLs. */)
270 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url) 270 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
271{ 271{
272 if (init_libxml2_functions (Vdynamic_library_alist)) 272 if (init_libxml2_functions ())
273 return parse_region (start, end, base_url, 0); 273 return parse_region (start, end, base_url, 0);
274 return Qnil; 274 return Qnil;
275} 275}
diff --git a/src/xselect.c b/src/xselect.c
index ab199e0b9b9..de9386bd7d9 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -247,9 +247,9 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym)
247 if (!SYMBOLP (sym)) emacs_abort (); 247 if (!SYMBOLP (sym)) emacs_abort ();
248 248
249 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); 249 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
250 BLOCK_INPUT; 250 block_input ();
251 val = XInternAtom (dpyinfo->display, SSDATA (SYMBOL_NAME (sym)), False); 251 val = XInternAtom (dpyinfo->display, SSDATA (SYMBOL_NAME (sym)), False);
252 UNBLOCK_INPUT; 252 unblock_input ();
253 return val; 253 return val;
254} 254}
255 255
@@ -307,16 +307,16 @@ x_atom_to_symbol (Display *dpy, Atom atom)
307 if (atom == dpyinfo->Xatom_NULL) 307 if (atom == dpyinfo->Xatom_NULL)
308 return QNULL; 308 return QNULL;
309 309
310 BLOCK_INPUT; 310 block_input ();
311 str = XGetAtomName (dpy, atom); 311 str = XGetAtomName (dpy, atom);
312 UNBLOCK_INPUT; 312 unblock_input ();
313 TRACE1 ("XGetAtomName --> %s", str); 313 TRACE1 ("XGetAtomName --> %s", str);
314 if (! str) return Qnil; 314 if (! str) return Qnil;
315 val = intern (str); 315 val = intern (str);
316 BLOCK_INPUT; 316 block_input ();
317 /* This was allocated by Xlib, so use XFree. */ 317 /* This was allocated by Xlib, so use XFree. */
318 XFree (str); 318 XFree (str);
319 UNBLOCK_INPUT; 319 unblock_input ();
320 return val; 320 return val;
321} 321}
322 322
@@ -336,12 +336,12 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
336 Time timestamp = last_event_timestamp; 336 Time timestamp = last_event_timestamp;
337 Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_name); 337 Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_name);
338 338
339 BLOCK_INPUT; 339 block_input ();
340 x_catch_errors (display); 340 x_catch_errors (display);
341 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp); 341 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp);
342 x_check_errors (display, "Can't set selection: %s"); 342 x_check_errors (display, "Can't set selection: %s");
343 x_uncatch_errors (); 343 x_uncatch_errors ();
344 UNBLOCK_INPUT; 344 unblock_input ();
345 345
346 /* Now update the local cache */ 346 /* Now update the local cache */
347 { 347 {
@@ -469,12 +469,12 @@ x_decline_selection_request (struct input_event *event)
469 469
470 /* The reason for the error may be that the receiver has 470 /* The reason for the error may be that the receiver has
471 died in the meantime. Handle that case. */ 471 died in the meantime. Handle that case. */
472 BLOCK_INPUT; 472 block_input ();
473 x_catch_errors (reply->display); 473 x_catch_errors (reply->display);
474 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base); 474 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
475 XFlush (reply->display); 475 XFlush (reply->display);
476 x_uncatch_errors (); 476 x_uncatch_errors ();
477 UNBLOCK_INPUT; 477 unblock_input ();
478} 478}
479 479
480/* This is the selection request currently being processed. 480/* This is the selection request currently being processed.
@@ -536,9 +536,9 @@ x_selection_request_lisp_error (Lisp_Object ignore)
536static Lisp_Object 536static Lisp_Object
537x_catch_errors_unwind (Lisp_Object dummy) 537x_catch_errors_unwind (Lisp_Object dummy)
538{ 538{
539 BLOCK_INPUT; 539 block_input ();
540 x_uncatch_errors (); 540 x_uncatch_errors ();
541 UNBLOCK_INPUT; 541 unblock_input ();
542 return Qnil; 542 return Qnil;
543} 543}
544 544
@@ -610,7 +610,7 @@ x_reply_selection_request (struct input_event *event,
610 if (reply->property == None) 610 if (reply->property == None)
611 reply->property = reply->target; 611 reply->property = reply->target;
612 612
613 BLOCK_INPUT; 613 block_input ();
614 /* The protected block contains wait_for_property_change, which can 614 /* The protected block contains wait_for_property_change, which can
615 run random lisp code (process handlers) or signal. Therefore, we 615 run random lisp code (process handlers) or signal. Therefore, we
616 put the x_uncatch_errors call in an unwind. */ 616 put the x_uncatch_errors call in an unwind. */
@@ -682,7 +682,7 @@ x_reply_selection_request (struct input_event *event,
682 { 682 {
683 int format_bytes = cs->format / 8; 683 int format_bytes = cs->format / 8;
684 int had_errors = x_had_errors_p (display); 684 int had_errors = x_had_errors_p (display);
685 UNBLOCK_INPUT; 685 unblock_input ();
686 686
687 bytes_remaining = cs->size; 687 bytes_remaining = cs->size;
688 bytes_remaining *= format_bytes; 688 bytes_remaining *= format_bytes;
@@ -703,7 +703,7 @@ x_reply_selection_request (struct input_event *event,
703 int i = ((bytes_remaining < max_bytes) 703 int i = ((bytes_remaining < max_bytes)
704 ? bytes_remaining 704 ? bytes_remaining
705 : max_bytes) / format_bytes; 705 : max_bytes) / format_bytes;
706 BLOCK_INPUT; 706 block_input ();
707 707
708 cs->wait_object 708 cs->wait_object
709 = expect_property_change (display, window, cs->property, 709 = expect_property_change (display, window, cs->property,
@@ -722,7 +722,7 @@ x_reply_selection_request (struct input_event *event,
722 : format_bytes); 722 : format_bytes);
723 XFlush (display); 723 XFlush (display);
724 had_errors = x_had_errors_p (display); 724 had_errors = x_had_errors_p (display);
725 UNBLOCK_INPUT; 725 unblock_input ();
726 726
727 if (had_errors) break; 727 if (had_errors) break;
728 728
@@ -735,7 +735,7 @@ x_reply_selection_request (struct input_event *event,
735 735
736 /* Now write a zero-length chunk to the property to tell the 736 /* Now write a zero-length chunk to the property to tell the
737 requestor that we're done. */ 737 requestor that we're done. */
738 BLOCK_INPUT; 738 block_input ();
739 if (! waiting_for_other_props_on_window (display, window)) 739 if (! waiting_for_other_props_on_window (display, window))
740 XSelectInput (display, window, 0L); 740 XSelectInput (display, window, 0L);
741 741
@@ -757,15 +757,15 @@ x_reply_selection_request (struct input_event *event,
757 /* 2004-09-10: XSync and UNBLOCK so that possible protocol errors are 757 /* 2004-09-10: XSync and UNBLOCK so that possible protocol errors are
758 delivered before uncatch errors. */ 758 delivered before uncatch errors. */
759 XSync (display, False); 759 XSync (display, False);
760 UNBLOCK_INPUT; 760 unblock_input ();
761 761
762 /* GTK queues events in addition to the queue in Xlib. So we 762 /* GTK queues events in addition to the queue in Xlib. So we
763 UNBLOCK to enter the event loop and get possible errors delivered, 763 UNBLOCK to enter the event loop and get possible errors delivered,
764 and then BLOCK again because x_uncatch_errors requires it. */ 764 and then BLOCK again because x_uncatch_errors requires it. */
765 BLOCK_INPUT; 765 block_input ();
766 /* This calls x_uncatch_errors. */ 766 /* This calls x_uncatch_errors. */
767 unbind_to (count, Qnil); 767 unbind_to (count, Qnil);
768 UNBLOCK_INPUT; 768 unblock_input ();
769} 769}
770 770
771/* Handle a SelectionRequest event EVENT. 771/* Handle a SelectionRequest event EVENT.
@@ -1232,7 +1232,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1232 if (! NILP (time_stamp)) 1232 if (! NILP (time_stamp))
1233 CONS_TO_INTEGER (time_stamp, Time, requestor_time); 1233 CONS_TO_INTEGER (time_stamp, Time, requestor_time);
1234 1234
1235 BLOCK_INPUT; 1235 block_input ();
1236 TRACE2 ("Get selection %s, type %s", 1236 TRACE2 ("Get selection %s, type %s",
1237 XGetAtomName (display, type_atom), 1237 XGetAtomName (display, type_atom),
1238 XGetAtomName (display, target_property)); 1238 XGetAtomName (display, target_property));
@@ -1257,7 +1257,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1257 record_unwind_protect (queue_selection_requests_unwind, Qnil); 1257 record_unwind_protect (queue_selection_requests_unwind, Qnil);
1258#endif 1258#endif
1259 1259
1260 UNBLOCK_INPUT; 1260 unblock_input ();
1261 1261
1262 /* This allows quits. Also, don't wait forever. */ 1262 /* This allows quits. Also, don't wait forever. */
1263 timeout = max (0, x_selection_timeout); 1263 timeout = max (0, x_selection_timeout);
@@ -1309,7 +1309,7 @@ x_get_window_property (Display *display, Window window, Atom property,
1309 ? min (PTRDIFF_MAX, SIZE_MAX) - 1 1309 ? min (PTRDIFF_MAX, SIZE_MAX) - 1
1310 : LONG_MAX * x_long_size); 1310 : LONG_MAX * x_long_size);
1311 1311
1312 BLOCK_INPUT; 1312 block_input ();
1313 1313
1314 /* First probe the thing to find out how big it is. */ 1314 /* First probe the thing to find out how big it is. */
1315 result = XGetWindowProperty (display, window, property, 1315 result = XGetWindowProperty (display, window, property,
@@ -1410,19 +1410,19 @@ x_get_window_property (Display *display, Window window, Atom property,
1410 data[offset] = '\0'; 1410 data[offset] = '\0';
1411 1411
1412 done: 1412 done:
1413 UNBLOCK_INPUT; 1413 unblock_input ();
1414 *data_ret = data; 1414 *data_ret = data;
1415 *bytes_ret = offset; 1415 *bytes_ret = offset;
1416 return; 1416 return;
1417 1417
1418 size_overflow: 1418 size_overflow:
1419 free (data); 1419 free (data);
1420 UNBLOCK_INPUT; 1420 unblock_input ();
1421 memory_full (SIZE_MAX); 1421 memory_full (SIZE_MAX);
1422 1422
1423 memory_exhausted: 1423 memory_exhausted:
1424 free (data); 1424 free (data);
1425 UNBLOCK_INPUT; 1425 unblock_input ();
1426 memory_full (total_size + 1); 1426 memory_full (total_size + 1);
1427} 1427}
1428 1428
@@ -1454,7 +1454,7 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1454 that property, then reading the property, then deleting it to ack. 1454 that property, then reading the property, then deleting it to ack.
1455 We are done when the sender places a property of length 0. 1455 We are done when the sender places a property of length 0.
1456 */ 1456 */
1457 BLOCK_INPUT; 1457 block_input ();
1458 XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask); 1458 XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask);
1459 TRACE1 (" Delete property %s", 1459 TRACE1 (" Delete property %s",
1460 SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property)))); 1460 SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property))));
@@ -1464,7 +1464,7 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1464 wait_object = expect_property_change (display, window, property, 1464 wait_object = expect_property_change (display, window, property,
1465 PropertyNewValue); 1465 PropertyNewValue);
1466 XFlush (display); 1466 XFlush (display);
1467 UNBLOCK_INPUT; 1467 unblock_input ();
1468 1468
1469 while (1) 1469 while (1)
1470 { 1470 {
@@ -1496,14 +1496,14 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1496 break; 1496 break;
1497 } 1497 }
1498 1498
1499 BLOCK_INPUT; 1499 block_input ();
1500 TRACE1 (" ACK by deleting property %s", 1500 TRACE1 (" ACK by deleting property %s",
1501 XGetAtomName (display, property)); 1501 XGetAtomName (display, property));
1502 XDeleteProperty (display, window, property); 1502 XDeleteProperty (display, window, property);
1503 wait_object = expect_property_change (display, window, property, 1503 wait_object = expect_property_change (display, window, property,
1504 PropertyNewValue); 1504 PropertyNewValue);
1505 XFlush (display); 1505 XFlush (display);
1506 UNBLOCK_INPUT; 1506 unblock_input ();
1507 1507
1508 if (*size_bytes_ret - offset < tmp_size_bytes) 1508 if (*size_bytes_ret - offset < tmp_size_bytes)
1509 *data_ret = xpalloc (*data_ret, size_bytes_ret, 1509 *data_ret = xpalloc (*data_ret, size_bytes_ret,
@@ -1545,10 +1545,10 @@ x_get_window_property_as_lisp_data (Display *display, Window window,
1545 if (! data) 1545 if (! data)
1546 { 1546 {
1547 int there_is_a_selection_owner; 1547 int there_is_a_selection_owner;
1548 BLOCK_INPUT; 1548 block_input ();
1549 there_is_a_selection_owner 1549 there_is_a_selection_owner
1550 = XGetSelectionOwner (display, selection_atom); 1550 = XGetSelectionOwner (display, selection_atom);
1551 UNBLOCK_INPUT; 1551 unblock_input ();
1552 if (there_is_a_selection_owner) 1552 if (there_is_a_selection_owner)
1553 signal_error ("Selection owner couldn't convert", 1553 signal_error ("Selection owner couldn't convert",
1554 actual_type 1554 actual_type
@@ -1565,22 +1565,22 @@ x_get_window_property_as_lisp_data (Display *display, Window window,
1565 /* That wasn't really the data, just the beginning. */ 1565 /* That wasn't really the data, just the beginning. */
1566 1566
1567 unsigned int min_size_bytes = * ((unsigned int *) data); 1567 unsigned int min_size_bytes = * ((unsigned int *) data);
1568 BLOCK_INPUT; 1568 block_input ();
1569 /* Use xfree, not XFree, because x_get_window_property 1569 /* Use xfree, not XFree, because x_get_window_property
1570 calls xmalloc itself. */ 1570 calls xmalloc itself. */
1571 xfree (data); 1571 xfree (data);
1572 UNBLOCK_INPUT; 1572 unblock_input ();
1573 receive_incremental_selection (display, window, property, target_type, 1573 receive_incremental_selection (display, window, property, target_type,
1574 min_size_bytes, &data, &bytes, 1574 min_size_bytes, &data, &bytes,
1575 &actual_type, &actual_format, 1575 &actual_type, &actual_format,
1576 &actual_size); 1576 &actual_size);
1577 } 1577 }
1578 1578
1579 BLOCK_INPUT; 1579 block_input ();
1580 TRACE1 (" Delete property %s", XGetAtomName (display, property)); 1580 TRACE1 (" Delete property %s", XGetAtomName (display, property));
1581 XDeleteProperty (display, window, property); 1581 XDeleteProperty (display, window, property);
1582 XFlush (display); 1582 XFlush (display);
1583 UNBLOCK_INPUT; 1583 unblock_input ();
1584 1584
1585 /* It's been read. Now convert it to a lisp object in some semi-rational 1585 /* It's been read. Now convert it to a lisp object in some semi-rational
1586 manner. */ 1586 manner. */
@@ -2096,13 +2096,13 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
2096 2096
2097 selection_atom = symbol_to_x_atom (dpyinfo, selection); 2097 selection_atom = symbol_to_x_atom (dpyinfo, selection);
2098 2098
2099 BLOCK_INPUT; 2099 block_input ();
2100 if (NILP (time_object)) 2100 if (NILP (time_object))
2101 timestamp = last_event_timestamp; 2101 timestamp = last_event_timestamp;
2102 else 2102 else
2103 CONS_TO_INTEGER (time_object, Time, timestamp); 2103 CONS_TO_INTEGER (time_object, Time, timestamp);
2104 XSetSelectionOwner (dpyinfo->display, selection_atom, None, timestamp); 2104 XSetSelectionOwner (dpyinfo->display, selection_atom, None, timestamp);
2105 UNBLOCK_INPUT; 2105 unblock_input ();
2106 2106
2107 /* It doesn't seem to be guaranteed that a SelectionClear event will be 2107 /* It doesn't seem to be guaranteed that a SelectionClear event will be
2108 generated for a window which owns the selection when that window sets 2108 generated for a window which owns the selection when that window sets
@@ -2179,9 +2179,9 @@ On Nextstep, TERMINAL is unused. */)
2179 2179
2180 atom = symbol_to_x_atom (dpyinfo, selection); 2180 atom = symbol_to_x_atom (dpyinfo, selection);
2181 if (atom == 0) return Qnil; 2181 if (atom == 0) return Qnil;
2182 BLOCK_INPUT; 2182 block_input ();
2183 owner = XGetSelectionOwner (dpyinfo->display, atom); 2183 owner = XGetSelectionOwner (dpyinfo->display, atom);
2184 UNBLOCK_INPUT; 2184 unblock_input ();
2185 return (owner ? Qt : Qnil); 2185 return (owner ? Qt : Qnil);
2186} 2186}
2187 2187
@@ -2353,9 +2353,9 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2353 val = cons_to_signed (o, LONG_MIN, LONG_MAX); 2353 val = cons_to_signed (o, LONG_MIN, LONG_MAX);
2354 else if (STRINGP (o)) 2354 else if (STRINGP (o))
2355 { 2355 {
2356 BLOCK_INPUT; 2356 block_input ();
2357 val = (long) XInternAtom (dpy, SSDATA (o), False); 2357 val = (long) XInternAtom (dpy, SSDATA (o), False);
2358 UNBLOCK_INPUT; 2358 unblock_input ();
2359 } 2359 }
2360 else 2360 else
2361 error ("Wrong type, must be string, number or cons"); 2361 error ("Wrong type, must be string, number or cons");
@@ -2413,7 +2413,7 @@ mouse_position_for_drop (FRAME_PTR f, int *x, int *y)
2413 Window root, dummy_window; 2413 Window root, dummy_window;
2414 int dummy; 2414 int dummy;
2415 2415
2416 BLOCK_INPUT; 2416 block_input ();
2417 2417
2418 XQueryPointer (FRAME_X_DISPLAY (f), 2418 XQueryPointer (FRAME_X_DISPLAY (f),
2419 DefaultRootWindow (FRAME_X_DISPLAY (f)), 2419 DefaultRootWindow (FRAME_X_DISPLAY (f)),
@@ -2439,7 +2439,7 @@ mouse_position_for_drop (FRAME_PTR f, int *x, int *y)
2439 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); 2439 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
2440 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); 2440 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
2441 2441
2442 UNBLOCK_INPUT; 2442 unblock_input ();
2443} 2443}
2444 2444
2445DEFUN ("x-get-atom-name", Fx_get_atom_name, 2445DEFUN ("x-get-atom-name", Fx_get_atom_name,
@@ -2462,7 +2462,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2462 2462
2463 CONS_TO_INTEGER (value, Atom, atom); 2463 CONS_TO_INTEGER (value, Atom, atom);
2464 2464
2465 BLOCK_INPUT; 2465 block_input ();
2466 x_catch_errors (dpy); 2466 x_catch_errors (dpy);
2467 name = atom ? XGetAtomName (dpy, atom) : empty; 2467 name = atom ? XGetAtomName (dpy, atom) : empty;
2468 had_errors = x_had_errors_p (dpy); 2468 had_errors = x_had_errors_p (dpy);
@@ -2474,7 +2474,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2474 if (atom && name) XFree (name); 2474 if (atom && name) XFree (name);
2475 if (NILP (ret)) ret = empty_unibyte_string; 2475 if (NILP (ret)) ret = empty_unibyte_string;
2476 2476
2477 UNBLOCK_INPUT; 2477 unblock_input ();
2478 2478
2479 return ret; 2479 return ret;
2480} 2480}
@@ -2496,9 +2496,9 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2496 x_atom = symbol_to_x_atom (dpyinfo, atom); 2496 x_atom = symbol_to_x_atom (dpyinfo, atom);
2497 else if (STRINGP (atom)) 2497 else if (STRINGP (atom))
2498 { 2498 {
2499 BLOCK_INPUT; 2499 block_input ();
2500 x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False); 2500 x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False);
2501 UNBLOCK_INPUT; 2501 unblock_input ();
2502 } 2502 }
2503 else 2503 else
2504 error ("ATOM must be a symbol or a string"); 2504 error ("ATOM must be a symbol or a string");
@@ -2657,7 +2657,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2657 if (wdest == 0) wdest = dpyinfo->root_window; 2657 if (wdest == 0) wdest = dpyinfo->root_window;
2658 to_root = wdest == dpyinfo->root_window; 2658 to_root = wdest == dpyinfo->root_window;
2659 2659
2660 BLOCK_INPUT; 2660 block_input ();
2661 2661
2662 event.xclient.message_type = message_type; 2662 event.xclient.message_type = message_type;
2663 event.xclient.display = dpyinfo->display; 2663 event.xclient.display = dpyinfo->display;
@@ -2683,7 +2683,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2683 XFlush (dpyinfo->display); 2683 XFlush (dpyinfo->display);
2684 } 2684 }
2685 x_uncatch_errors (); 2685 x_uncatch_errors ();
2686 UNBLOCK_INPUT; 2686 unblock_input ();
2687} 2687}
2688 2688
2689 2689
diff --git a/src/xsettings.c b/src/xsettings.c
index 58c84495489..7c68ff295cf 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -929,7 +929,7 @@ init_xsettings (struct x_display_info *dpyinfo)
929{ 929{
930 Display *dpy = dpyinfo->display; 930 Display *dpy = dpyinfo->display;
931 931
932 BLOCK_INPUT; 932 block_input ();
933 933
934 /* Select events so we can detect client messages sent when selection 934 /* Select events so we can detect client messages sent when selection
935 owner changes. */ 935 owner changes. */
@@ -939,7 +939,7 @@ init_xsettings (struct x_display_info *dpyinfo)
939 if (dpyinfo->xsettings_window != None) 939 if (dpyinfo->xsettings_window != None)
940 read_and_apply_settings (dpyinfo, False); 940 read_and_apply_settings (dpyinfo, False);
941 941
942 UNBLOCK_INPUT; 942 unblock_input ();
943} 943}
944 944
945void 945void
diff --git a/src/xterm.c b/src/xterm.c
index 8c955d0e576..6cd1d583870 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -287,7 +287,7 @@ enum xembed_message
287 287
288/* Used in x_flush. */ 288/* Used in x_flush. */
289 289
290static int x_alloc_nearest_color_1 (Display *, Colormap, XColor *); 290static bool x_alloc_nearest_color_1 (Display *, Colormap, XColor *);
291static void x_set_window_size_1 (struct frame *, int, int, int); 291static void x_set_window_size_1 (struct frame *, int, int, int);
292static void x_raise_frame (struct frame *); 292static void x_raise_frame (struct frame *);
293static void x_lower_frame (struct frame *); 293static void x_lower_frame (struct frame *);
@@ -353,7 +353,7 @@ x_flush (struct frame *f)
353 if (!NILP (Vinhibit_redisplay)) 353 if (!NILP (Vinhibit_redisplay))
354 return; 354 return;
355 355
356 BLOCK_INPUT; 356 block_input ();
357 if (f == NULL) 357 if (f == NULL)
358 { 358 {
359 Lisp_Object rest, frame; 359 Lisp_Object rest, frame;
@@ -363,7 +363,7 @@ x_flush (struct frame *f)
363 } 363 }
364 else if (FRAME_X_P (f)) 364 else if (FRAME_X_P (f))
365 XFlush (FRAME_X_DISPLAY (f)); 365 XFlush (FRAME_X_DISPLAY (f));
366 UNBLOCK_INPUT; 366 unblock_input ();
367} 367}
368 368
369 369
@@ -564,7 +564,7 @@ x_update_window_begin (struct window *w)
564 updated_window = w; 564 updated_window = w;
565 set_output_cursor (&w->cursor); 565 set_output_cursor (&w->cursor);
566 566
567 BLOCK_INPUT; 567 block_input ();
568 568
569 if (f == hlinfo->mouse_face_mouse_frame) 569 if (f == hlinfo->mouse_face_mouse_frame)
570 { 570 {
@@ -577,7 +577,7 @@ x_update_window_begin (struct window *w)
577 hlinfo->mouse_face_window = Qnil; 577 hlinfo->mouse_face_window = Qnil;
578 } 578 }
579 579
580 UNBLOCK_INPUT; 580 unblock_input ();
581} 581}
582 582
583 583
@@ -618,7 +618,7 @@ x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritt
618 618
619 if (!w->pseudo_window_p) 619 if (!w->pseudo_window_p)
620 { 620 {
621 BLOCK_INPUT; 621 block_input ();
622 622
623 if (cursor_on_p) 623 if (cursor_on_p)
624 display_and_set_cursor (w, 1, output_cursor.hpos, 624 display_and_set_cursor (w, 1, output_cursor.hpos,
@@ -628,7 +628,7 @@ x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritt
628 if (draw_window_fringes (w, 1)) 628 if (draw_window_fringes (w, 1))
629 x_draw_vertical_border (w); 629 x_draw_vertical_border (w);
630 630
631 UNBLOCK_INPUT; 631 unblock_input ();
632 } 632 }
633 633
634 /* If a row with mouse-face was overwritten, arrange for 634 /* If a row with mouse-face was overwritten, arrange for
@@ -654,9 +654,9 @@ x_update_end (struct frame *f)
654 MOUSE_HL_INFO (f)->mouse_face_defer = 0; 654 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
655 655
656#ifndef XFlush 656#ifndef XFlush
657 BLOCK_INPUT; 657 block_input ();
658 XFlush (FRAME_X_DISPLAY (f)); 658 XFlush (FRAME_X_DISPLAY (f));
659 UNBLOCK_INPUT; 659 unblock_input ();
660#endif 660#endif
661} 661}
662 662
@@ -675,13 +675,13 @@ XTframe_up_to_date (struct frame *f)
675 if (hlinfo->mouse_face_deferred_gc 675 if (hlinfo->mouse_face_deferred_gc
676 || f == hlinfo->mouse_face_mouse_frame) 676 || f == hlinfo->mouse_face_mouse_frame)
677 { 677 {
678 BLOCK_INPUT; 678 block_input ();
679 if (hlinfo->mouse_face_mouse_frame) 679 if (hlinfo->mouse_face_mouse_frame)
680 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, 680 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
681 hlinfo->mouse_face_mouse_x, 681 hlinfo->mouse_face_mouse_x,
682 hlinfo->mouse_face_mouse_y); 682 hlinfo->mouse_face_mouse_y);
683 hlinfo->mouse_face_deferred_gc = 0; 683 hlinfo->mouse_face_deferred_gc = 0;
684 UNBLOCK_INPUT; 684 unblock_input ();
685 } 685 }
686 } 686 }
687} 687}
@@ -722,13 +722,13 @@ x_after_update_window_line (struct glyph_row *desired_row)
722 { 722 {
723 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 723 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
724 724
725 BLOCK_INPUT; 725 block_input ();
726 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 726 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
727 0, y, width, height, False); 727 0, y, width, height, False);
728 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 728 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
729 FRAME_PIXEL_WIDTH (f) - width, 729 FRAME_PIXEL_WIDTH (f) - width,
730 y, width, height, False); 730 y, width, height, False);
731 UNBLOCK_INPUT; 731 unblock_input ();
732 } 732 }
733} 733}
734 734
@@ -899,8 +899,8 @@ static void x_compute_glyph_string_overhangs (struct glyph_string *);
899static void x_set_cursor_gc (struct glyph_string *); 899static void x_set_cursor_gc (struct glyph_string *);
900static void x_set_mode_line_face_gc (struct glyph_string *); 900static void x_set_mode_line_face_gc (struct glyph_string *);
901static void x_set_mouse_face_gc (struct glyph_string *); 901static void x_set_mouse_face_gc (struct glyph_string *);
902static int x_alloc_lighter_color (struct frame *, Display *, Colormap, 902static bool x_alloc_lighter_color (struct frame *, Display *, Colormap,
903 unsigned long *, double, int); 903 unsigned long *, double, int);
904static void x_setup_relief_color (struct frame *, struct relief *, 904static void x_setup_relief_color (struct frame *, struct relief *,
905 double, int, unsigned long); 905 double, int, unsigned long);
906static void x_setup_relief_colors (struct glyph_string *); 906static void x_setup_relief_colors (struct glyph_string *);
@@ -1469,9 +1469,9 @@ x_frame_of_widget (Widget widget)
1469 If this produces the same color as PIXEL, try a color where all RGB 1469 If this produces the same color as PIXEL, try a color where all RGB
1470 values have DELTA added. Return the allocated color in *PIXEL. 1470 values have DELTA added. Return the allocated color in *PIXEL.
1471 DISPLAY is the X display, CMAP is the colormap to operate on. 1471 DISPLAY is the X display, CMAP is the colormap to operate on.
1472 Value is non-zero if successful. */ 1472 Value is true if successful. */
1473 1473
1474int 1474bool
1475x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap, 1475x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap,
1476 unsigned long *pixel, double factor, int delta) 1476 unsigned long *pixel, double factor, int delta)
1477{ 1477{
@@ -1696,15 +1696,15 @@ x_query_color (struct frame *f, XColor *color)
1696 1696
1697/* Allocate the color COLOR->pixel on DISPLAY, colormap CMAP. If an 1697/* Allocate the color COLOR->pixel on DISPLAY, colormap CMAP. If an
1698 exact match can't be allocated, try the nearest color available. 1698 exact match can't be allocated, try the nearest color available.
1699 Value is non-zero if successful. Set *COLOR to the color 1699 Value is true if successful. Set *COLOR to the color
1700 allocated. */ 1700 allocated. */
1701 1701
1702static int 1702static bool
1703x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color) 1703x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
1704{ 1704{
1705 int rc; 1705 bool rc;
1706 1706
1707 rc = XAllocColor (dpy, cmap, color); 1707 rc = XAllocColor (dpy, cmap, color) != 0;
1708 if (rc == 0) 1708 if (rc == 0)
1709 { 1709 {
1710 /* If we got to this point, the colormap is full, so we're going 1710 /* If we got to this point, the colormap is full, so we're going
@@ -1735,7 +1735,7 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
1735 color->red = cells[nearest].red; 1735 color->red = cells[nearest].red;
1736 color->green = cells[nearest].green; 1736 color->green = cells[nearest].green;
1737 color->blue = cells[nearest].blue; 1737 color->blue = cells[nearest].blue;
1738 rc = XAllocColor (dpy, cmap, color); 1738 rc = XAllocColor (dpy, cmap, color) != 0;
1739 } 1739 }
1740 else 1740 else
1741 { 1741 {
@@ -1768,10 +1768,10 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
1768 1768
1769/* Allocate the color COLOR->pixel on frame F, colormap CMAP. If an 1769/* Allocate the color COLOR->pixel on frame F, colormap CMAP. If an
1770 exact match can't be allocated, try the nearest color available. 1770 exact match can't be allocated, try the nearest color available.
1771 Value is non-zero if successful. Set *COLOR to the color 1771 Value is true if successful. Set *COLOR to the color
1772 allocated. */ 1772 allocated. */
1773 1773
1774int 1774bool
1775x_alloc_nearest_color (struct frame *f, Colormap cmap, XColor *color) 1775x_alloc_nearest_color (struct frame *f, Colormap cmap, XColor *color)
1776{ 1776{
1777 gamma_correct (f, color); 1777 gamma_correct (f, color);
@@ -1789,10 +1789,10 @@ x_copy_color (struct frame *f, long unsigned int pixel)
1789 XColor color; 1789 XColor color;
1790 1790
1791 color.pixel = pixel; 1791 color.pixel = pixel;
1792 BLOCK_INPUT; 1792 block_input ();
1793 x_query_color (f, &color); 1793 x_query_color (f, &color);
1794 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color); 1794 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color);
1795 UNBLOCK_INPUT; 1795 unblock_input ();
1796#ifdef DEBUG_X_COLORS 1796#ifdef DEBUG_X_COLORS
1797 register_color (pixel); 1797 register_color (pixel);
1798#endif 1798#endif
@@ -1821,12 +1821,12 @@ x_copy_color (struct frame *f, long unsigned int pixel)
1821 DISPLAY is the X display, CMAP is the colormap to operate on. 1821 DISPLAY is the X display, CMAP is the colormap to operate on.
1822 Value is non-zero if successful. */ 1822 Value is non-zero if successful. */
1823 1823
1824static int 1824static bool
1825x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long unsigned int *pixel, double factor, int delta) 1825x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long unsigned int *pixel, double factor, int delta)
1826{ 1826{
1827 XColor color, new; 1827 XColor color, new;
1828 long bright; 1828 long bright;
1829 int success_p; 1829 bool success_p;
1830 1830
1831 /* Get RGB color values. */ 1831 /* Get RGB color values. */
1832 color.pixel = *pixel; 1832 color.pixel = *pixel;
@@ -3028,7 +3028,7 @@ x_clear_frame (struct frame *f)
3028 3028
3029 /* We don't set the output cursor here because there will always 3029 /* We don't set the output cursor here because there will always
3030 follow an explicit cursor_to. */ 3030 follow an explicit cursor_to. */
3031 BLOCK_INPUT; 3031 block_input ();
3032 3032
3033 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 3033 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
3034 3034
@@ -3045,7 +3045,7 @@ x_clear_frame (struct frame *f)
3045 3045
3046 XFlush (FRAME_X_DISPLAY (f)); 3046 XFlush (FRAME_X_DISPLAY (f));
3047 3047
3048 UNBLOCK_INPUT; 3048 unblock_input ();
3049} 3049}
3050 3050
3051 3051
@@ -3055,7 +3055,7 @@ x_clear_frame (struct frame *f)
3055static void 3055static void
3056XTflash (struct frame *f) 3056XTflash (struct frame *f)
3057{ 3057{
3058 BLOCK_INPUT; 3058 block_input ();
3059 3059
3060 { 3060 {
3061#ifdef USE_GTK 3061#ifdef USE_GTK
@@ -3208,14 +3208,14 @@ XTflash (struct frame *f)
3208 } 3208 }
3209 } 3209 }
3210 3210
3211 UNBLOCK_INPUT; 3211 unblock_input ();
3212} 3212}
3213 3213
3214 3214
3215static void 3215static void
3216XTtoggle_invisible_pointer (FRAME_PTR f, int invisible) 3216XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3217{ 3217{
3218 BLOCK_INPUT; 3218 block_input ();
3219 if (invisible) 3219 if (invisible)
3220 { 3220 {
3221 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0) 3221 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0)
@@ -3226,7 +3226,7 @@ XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3226 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3226 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3227 f->output_data.x->current_cursor); 3227 f->output_data.x->current_cursor);
3228 f->pointer_invisible = invisible; 3228 f->pointer_invisible = invisible;
3229 UNBLOCK_INPUT; 3229 unblock_input ();
3230} 3230}
3231 3231
3232 3232
@@ -3241,10 +3241,10 @@ XTring_bell (struct frame *f)
3241 XTflash (f); 3241 XTflash (f);
3242 else 3242 else
3243 { 3243 {
3244 BLOCK_INPUT; 3244 block_input ();
3245 XBell (FRAME_X_DISPLAY (f), 0); 3245 XBell (FRAME_X_DISPLAY (f), 0);
3246 XFlush (FRAME_X_DISPLAY (f)); 3246 XFlush (FRAME_X_DISPLAY (f));
3247 UNBLOCK_INPUT; 3247 unblock_input ();
3248 } 3248 }
3249 } 3249 }
3250} 3250}
@@ -3341,7 +3341,7 @@ x_scroll_run (struct window *w, struct run *run)
3341 height = run->height; 3341 height = run->height;
3342 } 3342 }
3343 3343
3344 BLOCK_INPUT; 3344 block_input ();
3345 3345
3346 /* Cursor off. Will be switched on again in x_update_window_end. */ 3346 /* Cursor off. Will be switched on again in x_update_window_end. */
3347 updated_window = w; 3347 updated_window = w;
@@ -3354,7 +3354,7 @@ x_scroll_run (struct window *w, struct run *run)
3354 width, height, 3354 width, height,
3355 x, to_y); 3355 x, to_y);
3356 3356
3357 UNBLOCK_INPUT; 3357 unblock_input ();
3358} 3358}
3359 3359
3360 3360
@@ -3371,7 +3371,7 @@ frame_highlight (struct frame *f)
3371 the ICCCM (section 4.1.6) says that the window's border pixmap 3371 the ICCCM (section 4.1.6) says that the window's border pixmap
3372 and border pixel are window attributes which are "private to the 3372 and border pixel are window attributes which are "private to the
3373 client", so we can always change it to whatever we want. */ 3373 client", so we can always change it to whatever we want. */
3374 BLOCK_INPUT; 3374 block_input ();
3375 /* I recently started to get errors in this XSetWindowBorder, depending on 3375 /* I recently started to get errors in this XSetWindowBorder, depending on
3376 the window-manager in use, tho something more is at play since I've been 3376 the window-manager in use, tho something more is at play since I've been
3377 using that same window-manager binary for ever. Let's not crash just 3377 using that same window-manager binary for ever. Let's not crash just
@@ -3380,7 +3380,7 @@ frame_highlight (struct frame *f)
3380 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3380 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3381 f->output_data.x->border_pixel); 3381 f->output_data.x->border_pixel);
3382 x_uncatch_errors (); 3382 x_uncatch_errors ();
3383 UNBLOCK_INPUT; 3383 unblock_input ();
3384 x_update_cursor (f, 1); 3384 x_update_cursor (f, 1);
3385 x_set_frame_alpha (f); 3385 x_set_frame_alpha (f);
3386} 3386}
@@ -3392,13 +3392,13 @@ frame_unhighlight (struct frame *f)
3392 the ICCCM (section 4.1.6) says that the window's border pixmap 3392 the ICCCM (section 4.1.6) says that the window's border pixmap
3393 and border pixel are window attributes which are "private to the 3393 and border pixel are window attributes which are "private to the
3394 client", so we can always change it to whatever we want. */ 3394 client", so we can always change it to whatever we want. */
3395 BLOCK_INPUT; 3395 block_input ();
3396 /* Same as above for XSetWindowBorder (bug#9310). */ 3396 /* Same as above for XSetWindowBorder (bug#9310). */
3397 x_catch_errors (FRAME_X_DISPLAY (f)); 3397 x_catch_errors (FRAME_X_DISPLAY (f));
3398 XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3398 XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3399 f->output_data.x->border_tile); 3399 f->output_data.x->border_tile);
3400 x_uncatch_errors (); 3400 x_uncatch_errors ();
3401 UNBLOCK_INPUT; 3401 unblock_input ();
3402 x_update_cursor (f, 1); 3402 x_update_cursor (f, 1);
3403 x_set_frame_alpha (f); 3403 x_set_frame_alpha (f);
3404} 3404}
@@ -3765,9 +3765,9 @@ x_get_keysym_name (int keysym)
3765{ 3765{
3766 char *value; 3766 char *value;
3767 3767
3768 BLOCK_INPUT; 3768 block_input ();
3769 value = XKeysymToString (keysym); 3769 value = XKeysymToString (keysym);
3770 UNBLOCK_INPUT; 3770 unblock_input ();
3771 3771
3772 return value; 3772 return value;
3773} 3773}
@@ -3897,7 +3897,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
3897{ 3897{
3898 FRAME_PTR f1; 3898 FRAME_PTR f1;
3899 3899
3900 BLOCK_INPUT; 3900 block_input ();
3901 3901
3902 if (! NILP (last_mouse_scroll_bar) && insist == 0) 3902 if (! NILP (last_mouse_scroll_bar) && insist == 0)
3903 x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp); 3903 x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp);
@@ -4078,7 +4078,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
4078 } 4078 }
4079 } 4079 }
4080 4080
4081 UNBLOCK_INPUT; 4081 unblock_input ();
4082} 4082}
4083 4083
4084 4084
@@ -4267,7 +4267,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4267 struct frame *f = XFRAME (w->frame); 4267 struct frame *f = XFRAME (w->frame);
4268 ptrdiff_t i; 4268 ptrdiff_t i;
4269 4269
4270 BLOCK_INPUT; 4270 block_input ();
4271 4271
4272 /* Construct a ClientMessage event to send to the frame. */ 4272 /* Construct a ClientMessage event to send to the frame. */
4273 ev->type = ClientMessage; 4273 ev->type = ClientMessage;
@@ -4314,7 +4314,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4314 be sent to the client that created the window, and if that 4314 be sent to the client that created the window, and if that
4315 window no longer exists, no event will be sent. */ 4315 window no longer exists, no event will be sent. */
4316 XSendEvent (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), False, 0, &event); 4316 XSendEvent (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), False, 0, &event);
4317 UNBLOCK_INPUT; 4317 unblock_input ();
4318} 4318}
4319 4319
4320 4320
@@ -4405,9 +4405,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4405 int slider_size; 4405 int slider_size;
4406 4406
4407 /* Get the slider size. */ 4407 /* Get the slider size. */
4408 BLOCK_INPUT; 4408 block_input ();
4409 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL); 4409 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL);
4410 UNBLOCK_INPUT; 4410 unblock_input ();
4411 4411
4412 whole = XM_SB_MAX - slider_size; 4412 whole = XM_SB_MAX - slider_size;
4413 portion = min (cs->value, whole); 4413 portion = min (cs->value, whole);
@@ -4528,9 +4528,9 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4528 int part; 4528 int part;
4529 4529
4530 /* Get the size of the thumb, a value between 0 and 1. */ 4530 /* Get the size of the thumb, a value between 0 and 1. */
4531 BLOCK_INPUT; 4531 block_input ();
4532 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL); 4532 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
4533 UNBLOCK_INPUT; 4533 unblock_input ();
4534 4534
4535 whole = 10000000; 4535 whole = 10000000;
4536 portion = shown < 1 ? top * whole : 0; 4536 portion = shown < 1 ? top * whole : 0;
@@ -4570,9 +4570,9 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4570 int part; 4570 int part;
4571 4571
4572 /* Get the height of the scroll bar. */ 4572 /* Get the height of the scroll bar. */
4573 BLOCK_INPUT; 4573 block_input ();
4574 XtVaGetValues (widget, XtNheight, &height, NULL); 4574 XtVaGetValues (widget, XtNheight, &height, NULL);
4575 UNBLOCK_INPUT; 4575 unblock_input ();
4576 4576
4577 if (eabs (position) >= height) 4577 if (eabs (position) >= height)
4578 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle; 4578 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle;
@@ -4603,11 +4603,11 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4603{ 4603{
4604 const char *scroll_bar_name = SCROLL_BAR_NAME; 4604 const char *scroll_bar_name = SCROLL_BAR_NAME;
4605 4605
4606 BLOCK_INPUT; 4606 block_input ();
4607 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), 4607 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
4608 G_CALLBACK (xg_end_scroll_callback), 4608 G_CALLBACK (xg_end_scroll_callback),
4609 scroll_bar_name); 4609 scroll_bar_name);
4610 UNBLOCK_INPUT; 4610 unblock_input ();
4611} 4611}
4612 4612
4613#else /* not USE_GTK */ 4613#else /* not USE_GTK */
@@ -4622,7 +4622,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4622 const char *scroll_bar_name = SCROLL_BAR_NAME; 4622 const char *scroll_bar_name = SCROLL_BAR_NAME;
4623 unsigned long pixel; 4623 unsigned long pixel;
4624 4624
4625 BLOCK_INPUT; 4625 block_input ();
4626 4626
4627#ifdef USE_MOTIF 4627#ifdef USE_MOTIF
4628 /* Set resources. Create the widget. */ 4628 /* Set resources. Create the widget. */
@@ -4806,7 +4806,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4806 xwindow = XtWindow (widget); 4806 xwindow = XtWindow (widget);
4807 bar->x_window = xwindow; 4807 bar->x_window = xwindow;
4808 4808
4809 UNBLOCK_INPUT; 4809 unblock_input ();
4810} 4810}
4811#endif /* not USE_GTK */ 4811#endif /* not USE_GTK */
4812 4812
@@ -4830,7 +4830,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4830 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 4830 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
4831 float top, shown; 4831 float top, shown;
4832 4832
4833 BLOCK_INPUT; 4833 block_input ();
4834 4834
4835#ifdef USE_MOTIF 4835#ifdef USE_MOTIF
4836 4836
@@ -4921,7 +4921,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4921 } 4921 }
4922#endif /* !USE_MOTIF */ 4922#endif /* !USE_MOTIF */
4923 4923
4924 UNBLOCK_INPUT; 4924 unblock_input ();
4925} 4925}
4926#endif /* not USE_GTK */ 4926#endif /* not USE_GTK */
4927 4927
@@ -4946,7 +4946,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4946 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER); 4946 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
4947 Lisp_Object barobj; 4947 Lisp_Object barobj;
4948 4948
4949 BLOCK_INPUT; 4949 block_input ();
4950 4950
4951#ifdef USE_TOOLKIT_SCROLL_BARS 4951#ifdef USE_TOOLKIT_SCROLL_BARS
4952 x_create_toolkit_scroll_bar (f, bar); 4952 x_create_toolkit_scroll_bar (f, bar);
@@ -5034,7 +5034,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
5034 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window); 5034 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window);
5035#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5035#endif /* not USE_TOOLKIT_SCROLL_BARS */
5036 5036
5037 UNBLOCK_INPUT; 5037 unblock_input ();
5038 return bar; 5038 return bar;
5039} 5039}
5040 5040
@@ -5068,7 +5068,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5068 && end == bar->end) 5068 && end == bar->end)
5069 return; 5069 return;
5070 5070
5071 BLOCK_INPUT; 5071 block_input ();
5072 5072
5073 { 5073 {
5074 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width); 5074 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width);
@@ -5144,7 +5144,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5144 5144
5145 } 5145 }
5146 5146
5147 UNBLOCK_INPUT; 5147 unblock_input ();
5148} 5148}
5149 5149
5150#endif /* !USE_TOOLKIT_SCROLL_BARS */ 5150#endif /* !USE_TOOLKIT_SCROLL_BARS */
@@ -5156,7 +5156,7 @@ static void
5156x_scroll_bar_remove (struct scroll_bar *bar) 5156x_scroll_bar_remove (struct scroll_bar *bar)
5157{ 5157{
5158 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5158 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5159 BLOCK_INPUT; 5159 block_input ();
5160 5160
5161#ifdef USE_TOOLKIT_SCROLL_BARS 5161#ifdef USE_TOOLKIT_SCROLL_BARS
5162#ifdef USE_GTK 5162#ifdef USE_GTK
@@ -5171,7 +5171,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
5171 /* Dissociate this scroll bar from its window. */ 5171 /* Dissociate this scroll bar from its window. */
5172 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil); 5172 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil);
5173 5173
5174 UNBLOCK_INPUT; 5174 unblock_input ();
5175} 5175}
5176 5176
5177 5177
@@ -5239,7 +5239,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5239 { 5239 {
5240 if (width > 0 && height > 0) 5240 if (width > 0 && height > 0)
5241 { 5241 {
5242 BLOCK_INPUT; 5242 block_input ();
5243#ifdef USE_TOOLKIT_SCROLL_BARS 5243#ifdef USE_TOOLKIT_SCROLL_BARS
5244 if (fringe_extended_p) 5244 if (fringe_extended_p)
5245 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5245 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -5248,7 +5248,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5248#endif 5248#endif
5249 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5249 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5250 left, top, width, height, False); 5250 left, top, width, height, False);
5251 UNBLOCK_INPUT; 5251 unblock_input ();
5252 } 5252 }
5253 5253
5254 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height); 5254 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
@@ -5260,7 +5260,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5260 5260
5261 bar = XSCROLL_BAR (w->vertical_scroll_bar); 5261 bar = XSCROLL_BAR (w->vertical_scroll_bar);
5262 5262
5263 BLOCK_INPUT; 5263 block_input ();
5264 5264
5265 if (sb_left != bar->left) 5265 if (sb_left != bar->left)
5266 mask |= CWX; 5266 mask |= CWX;
@@ -5357,7 +5357,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5357 bar->width = sb_width; 5357 bar->width = sb_width;
5358 bar->height = height; 5358 bar->height = height;
5359 5359
5360 UNBLOCK_INPUT; 5360 unblock_input ();
5361 } 5361 }
5362 5362
5363#ifdef USE_TOOLKIT_SCROLL_BARS 5363#ifdef USE_TOOLKIT_SCROLL_BARS
@@ -5508,7 +5508,7 @@ x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event)
5508 GC gc = f->output_data.x->normal_gc; 5508 GC gc = f->output_data.x->normal_gc;
5509 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; 5509 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM;
5510 5510
5511 BLOCK_INPUT; 5511 block_input ();
5512 5512
5513 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1); 5513 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1);
5514 5514
@@ -5530,7 +5530,7 @@ x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event)
5530 XSetForeground (FRAME_X_DISPLAY (f), gc, 5530 XSetForeground (FRAME_X_DISPLAY (f), gc,
5531 FRAME_FOREGROUND_PIXEL (f)); 5531 FRAME_FOREGROUND_PIXEL (f));
5532 5532
5533 UNBLOCK_INPUT; 5533 unblock_input ();
5534 5534
5535} 5535}
5536#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5536#endif /* not USE_TOOLKIT_SCROLL_BARS */
@@ -5643,7 +5643,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
5643 int dummy_coord; 5643 int dummy_coord;
5644 unsigned int dummy_mask; 5644 unsigned int dummy_mask;
5645 5645
5646 BLOCK_INPUT; 5646 block_input ();
5647 5647
5648 /* Get the mouse's position relative to the scroll bar window, and 5648 /* Get the mouse's position relative to the scroll bar window, and
5649 report that. */ 5649 report that. */
@@ -5695,7 +5695,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
5695 5695
5696 *timestamp = last_mouse_movement_time; 5696 *timestamp = last_mouse_movement_time;
5697 5697
5698 UNBLOCK_INPUT; 5698 unblock_input ();
5699} 5699}
5700 5700
5701 5701
@@ -5816,7 +5816,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5816{ 5816{
5817 XEvent *xev = (XEvent *) gxev; 5817 XEvent *xev = (XEvent *) gxev;
5818 5818
5819 BLOCK_INPUT; 5819 block_input ();
5820 if (current_count >= 0) 5820 if (current_count >= 0)
5821 { 5821 {
5822 struct x_display_info *dpyinfo; 5822 struct x_display_info *dpyinfo;
@@ -5831,7 +5831,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5831 && dpyinfo 5831 && dpyinfo
5832 && x_filter_event (dpyinfo, xev)) 5832 && x_filter_event (dpyinfo, xev))
5833 { 5833 {
5834 UNBLOCK_INPUT; 5834 unblock_input ();
5835 return GDK_FILTER_REMOVE; 5835 return GDK_FILTER_REMOVE;
5836 } 5836 }
5837#endif 5837#endif
@@ -5846,7 +5846,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5846 else 5846 else
5847 current_finish = x_dispatch_event (xev, xev->xany.display); 5847 current_finish = x_dispatch_event (xev, xev->xany.display);
5848 5848
5849 UNBLOCK_INPUT; 5849 unblock_input ();
5850 5850
5851 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP) 5851 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP)
5852 return GDK_FILTER_REMOVE; 5852 return GDK_FILTER_REMOVE;
@@ -7041,10 +7041,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
7041 default: 7041 default:
7042 OTHER: 7042 OTHER:
7043#ifdef USE_X_TOOLKIT 7043#ifdef USE_X_TOOLKIT
7044 BLOCK_INPUT; 7044 block_input ();
7045 if (*finish != X_EVENT_DROP) 7045 if (*finish != X_EVENT_DROP)
7046 XtDispatchEvent (&event); 7046 XtDispatchEvent (&event);
7047 UNBLOCK_INPUT; 7047 unblock_input ();
7048#endif /* USE_X_TOOLKIT */ 7048#endif /* USE_X_TOOLKIT */
7049 break; 7049 break;
7050 } 7050 }
@@ -7122,16 +7122,7 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7122 int count = 0; 7122 int count = 0;
7123 int event_found = 0; 7123 int event_found = 0;
7124 7124
7125 if (interrupt_input_blocked) 7125 block_input ();
7126 {
7127 interrupt_input_pending = 1;
7128 pending_signals = 1;
7129 return -1;
7130 }
7131
7132 interrupt_input_pending = 0;
7133 pending_signals = pending_atimers;
7134 BLOCK_INPUT;
7135 7126
7136 /* So people can tell when we have read the available input. */ 7127 /* So people can tell when we have read the available input. */
7137 input_signal_count++; 7128 input_signal_count++;
@@ -7224,7 +7215,7 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7224 pending_autoraise_frame = 0; 7215 pending_autoraise_frame = 0;
7225 } 7216 }
7226 7217
7227 UNBLOCK_INPUT; 7218 unblock_input ();
7228 7219
7229 return count; 7220 return count;
7230} 7221}
@@ -7660,7 +7651,7 @@ x_uncatch_errors (void)
7660{ 7651{
7661 struct x_error_message_stack *tmp; 7652 struct x_error_message_stack *tmp;
7662 7653
7663 BLOCK_INPUT; 7654 block_input ();
7664 7655
7665 /* The display may have been closed before this function is called. 7656 /* The display may have been closed before this function is called.
7666 Check if it is still open before calling XSync. */ 7657 Check if it is still open before calling XSync. */
@@ -7670,7 +7661,7 @@ x_uncatch_errors (void)
7670 tmp = x_error_message; 7661 tmp = x_error_message;
7671 x_error_message = x_error_message->prev; 7662 x_error_message = x_error_message->prev;
7672 xfree (tmp); 7663 xfree (tmp);
7673 UNBLOCK_INPUT; 7664 unblock_input ();
7674} 7665}
7675 7666
7676/* If any X protocol errors have arrived since the last call to 7667/* If any X protocol errors have arrived since the last call to
@@ -7733,26 +7724,6 @@ x_trace_wire (void)
7733#endif /* ! 0 */ 7724#endif /* ! 0 */
7734 7725
7735 7726
7736/* Handle SIGPIPE, which can happen when the connection to a server
7737 simply goes away. SIGPIPE is handled by x_connection_signal.
7738 Don't need to do anything, because the write which caused the
7739 SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
7740 which will do the appropriate cleanup for us. */
7741
7742static void
7743x_connection_signal (int signalnum) /* If we don't have an argument, */
7744 /* some compilers complain in signal calls. */
7745{
7746#ifdef USG
7747 /* USG systems forget handlers when they are used;
7748 must reestablish each time */
7749 struct sigaction action;
7750 emacs_sigaction_init (&action, x_connection_signal);
7751 sigaction (signalnum, &action, 0);
7752#endif /* USG */
7753}
7754
7755
7756/************************************************************************ 7727/************************************************************************
7757 Handling X errors 7728 Handling X errors
7758 ************************************************************************/ 7729 ************************************************************************/
@@ -7856,17 +7827,7 @@ For details, see etc/PROBLEMS.\n",
7856 /* NOTREACHED */ 7827 /* NOTREACHED */
7857 } 7828 }
7858 7829
7859 /* Ordinary stack unwind doesn't deal with these. */ 7830 totally_unblock_input ();
7860 {
7861 sigset_t unblocked;
7862 sigemptyset (&unblocked);
7863#ifdef USABLE_SIGIO
7864 sigaddset (&unblocked, SIGIO);
7865#endif
7866 sigaddset (&unblocked, SIGALRM);
7867 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
7868 }
7869 TOTALLY_UNBLOCK_INPUT;
7870 7831
7871 unbind_to (idx, Qnil); 7832 unbind_to (idx, Qnil);
7872 clear_waiting_for_input (); 7833 clear_waiting_for_input ();
@@ -8005,9 +7966,9 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
8005 if (FRAME_XIC (f) 7966 if (FRAME_XIC (f)
8006 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea))) 7967 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
8007 { 7968 {
8008 BLOCK_INPUT; 7969 block_input ();
8009 xic_set_xfontset (f, SSDATA (fontset_ascii (fontset))); 7970 xic_set_xfontset (f, SSDATA (fontset_ascii (fontset)));
8010 UNBLOCK_INPUT; 7971 unblock_input ();
8011 } 7972 }
8012#endif 7973#endif
8013 7974
@@ -8033,7 +7994,7 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
8033 struct x_display_info *dpyinfo = (struct x_display_info *) client_data; 7994 struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
8034 Lisp_Object frame, tail; 7995 Lisp_Object frame, tail;
8035 7996
8036 BLOCK_INPUT; 7997 block_input ();
8037 7998
8038 /* No need to call XDestroyIC.. */ 7999 /* No need to call XDestroyIC.. */
8039 FOR_EACH_FRAME (tail, frame) 8000 FOR_EACH_FRAME (tail, frame)
@@ -8049,7 +8010,7 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
8049 /* No need to call XCloseIM. */ 8010 /* No need to call XCloseIM. */
8050 dpyinfo->xim = NULL; 8011 dpyinfo->xim = NULL;
8051 XFree (dpyinfo->xim_styles); 8012 XFree (dpyinfo->xim_styles);
8052 UNBLOCK_INPUT; 8013 unblock_input ();
8053} 8014}
8054 8015
8055#endif /* HAVE_X11R6 */ 8016#endif /* HAVE_X11R6 */
@@ -8124,7 +8085,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_
8124 { 8085 {
8125 Lisp_Object tail, frame; 8086 Lisp_Object tail, frame;
8126 8087
8127 BLOCK_INPUT; 8088 block_input ();
8128 FOR_EACH_FRAME (tail, frame) 8089 FOR_EACH_FRAME (tail, frame)
8129 { 8090 {
8130 struct frame *f = XFRAME (frame); 8091 struct frame *f = XFRAME (frame);
@@ -8144,7 +8105,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_
8144 } 8105 }
8145 } 8106 }
8146 8107
8147 UNBLOCK_INPUT; 8108 unblock_input ();
8148 } 8109 }
8149} 8110}
8150 8111
@@ -8291,7 +8252,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8291 } 8252 }
8292 x_calc_absolute_position (f); 8253 x_calc_absolute_position (f);
8293 8254
8294 BLOCK_INPUT; 8255 block_input ();
8295 x_wm_set_size_hint (f, (long) 0, 0); 8256 x_wm_set_size_hint (f, (long) 0, 0);
8296 8257
8297 modified_left = f->left_pos; 8258 modified_left = f->left_pos;
@@ -8330,7 +8291,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8330 && FRAME_X_OUTPUT (f)->move_offset_top == 0)))) 8291 && FRAME_X_OUTPUT (f)->move_offset_top == 0))))
8331 x_check_expected_move (f, modified_left, modified_top); 8292 x_check_expected_move (f, modified_left, modified_top);
8332 8293
8333 UNBLOCK_INPUT; 8294 unblock_input ();
8334} 8295}
8335 8296
8336/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED 8297/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
@@ -8353,7 +8314,7 @@ wm_supports (struct frame *f, Atom want_atom)
8353 unsigned char *tmp_data = NULL; 8314 unsigned char *tmp_data = NULL;
8354 Atom target_type = XA_WINDOW; 8315 Atom target_type = XA_WINDOW;
8355 8316
8356 BLOCK_INPUT; 8317 block_input ();
8357 8318
8358 x_catch_errors (dpy); 8319 x_catch_errors (dpy);
8359 rc = XGetWindowProperty (dpy, target_window, 8320 rc = XGetWindowProperty (dpy, target_window,
@@ -8366,7 +8327,7 @@ wm_supports (struct frame *f, Atom want_atom)
8366 { 8327 {
8367 if (tmp_data) XFree (tmp_data); 8328 if (tmp_data) XFree (tmp_data);
8368 x_uncatch_errors (); 8329 x_uncatch_errors ();
8369 UNBLOCK_INPUT; 8330 unblock_input ();
8370 return 0; 8331 return 0;
8371 } 8332 }
8372 8333
@@ -8379,7 +8340,7 @@ wm_supports (struct frame *f, Atom want_atom)
8379 if (x_had_errors_p (dpy)) 8340 if (x_had_errors_p (dpy))
8380 { 8341 {
8381 x_uncatch_errors (); 8342 x_uncatch_errors ();
8382 UNBLOCK_INPUT; 8343 unblock_input ();
8383 return 0; 8344 return 0;
8384 } 8345 }
8385 8346
@@ -8404,7 +8365,7 @@ wm_supports (struct frame *f, Atom want_atom)
8404 { 8365 {
8405 if (tmp_data) XFree (tmp_data); 8366 if (tmp_data) XFree (tmp_data);
8406 x_uncatch_errors (); 8367 x_uncatch_errors ();
8407 UNBLOCK_INPUT; 8368 unblock_input ();
8408 return 0; 8369 return 0;
8409 } 8370 }
8410 8371
@@ -8419,7 +8380,7 @@ wm_supports (struct frame *f, Atom want_atom)
8419 rc = dpyinfo->net_supported_atoms[i] == want_atom; 8380 rc = dpyinfo->net_supported_atoms[i] == want_atom;
8420 8381
8421 x_uncatch_errors (); 8382 x_uncatch_errors ();
8422 UNBLOCK_INPUT; 8383 unblock_input ();
8423 8384
8424 return rc; 8385 return rc;
8425} 8386}
@@ -8478,7 +8439,7 @@ get_current_wm_state (struct frame *f,
8478 *sticky = 0; 8439 *sticky = 0;
8479 *size_state = FULLSCREEN_NONE; 8440 *size_state = FULLSCREEN_NONE;
8480 8441
8481 BLOCK_INPUT; 8442 block_input ();
8482 x_catch_errors (dpy); 8443 x_catch_errors (dpy);
8483 rc = XGetWindowProperty (dpy, window, dpyinfo->Xatom_net_wm_state, 8444 rc = XGetWindowProperty (dpy, window, dpyinfo->Xatom_net_wm_state,
8484 0, max_len, False, target_type, 8445 0, max_len, False, target_type,
@@ -8489,7 +8450,7 @@ get_current_wm_state (struct frame *f,
8489 { 8450 {
8490 if (tmp_data) XFree (tmp_data); 8451 if (tmp_data) XFree (tmp_data);
8491 x_uncatch_errors (); 8452 x_uncatch_errors ();
8492 UNBLOCK_INPUT; 8453 unblock_input ();
8493 return ! f->iconified; 8454 return ! f->iconified;
8494 } 8455 }
8495 8456
@@ -8524,7 +8485,7 @@ get_current_wm_state (struct frame *f,
8524 } 8485 }
8525 8486
8526 if (tmp_data) XFree (tmp_data); 8487 if (tmp_data) XFree (tmp_data);
8527 UNBLOCK_INPUT; 8488 unblock_input ();
8528 return ! is_hidden; 8489 return ! is_hidden;
8529} 8490}
8530 8491
@@ -8604,10 +8565,10 @@ XTfullscreen_hook (FRAME_PTR f)
8604{ 8565{
8605 if (f->async_visible) 8566 if (f->async_visible)
8606 { 8567 {
8607 BLOCK_INPUT; 8568 block_input ();
8608 x_check_fullscreen (f); 8569 x_check_fullscreen (f);
8609 x_sync (f); 8570 x_sync (f);
8610 UNBLOCK_INPUT; 8571 unblock_input ();
8611 } 8572 }
8612} 8573}
8613 8574
@@ -8792,10 +8753,10 @@ x_wait_for_event (struct frame *f, int eventtype)
8792 8753
8793 while (pending_event_wait.eventtype) 8754 while (pending_event_wait.eventtype)
8794 { 8755 {
8795 interrupt_input_pending = 1; 8756 pending_signals = 1;
8796 TOTALLY_UNBLOCK_INPUT; 8757 totally_unblock_input ();
8797 /* XTread_socket is called after unblock. */ 8758 /* XTread_socket is called after unblock. */
8798 BLOCK_INPUT; 8759 block_input ();
8799 interrupt_input_blocked = level; 8760 interrupt_input_blocked = level;
8800 8761
8801 FD_ZERO (&fds); 8762 FD_ZERO (&fds);
@@ -8886,7 +8847,7 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows)
8886void 8847void
8887x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) 8848x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
8888{ 8849{
8889 BLOCK_INPUT; 8850 block_input ();
8890 8851
8891 if (NILP (tip_frame) || XFRAME (tip_frame) != f) 8852 if (NILP (tip_frame) || XFRAME (tip_frame) != f)
8892 { 8853 {
@@ -8934,7 +8895,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
8934 so don't try--just let the highlighting be done afresh with new size. */ 8895 so don't try--just let the highlighting be done afresh with new size. */
8935 cancel_mouse_face (f); 8896 cancel_mouse_face (f);
8936 8897
8937 UNBLOCK_INPUT; 8898 unblock_input ();
8938} 8899}
8939 8900
8940/* Mouse warping. */ 8901/* Mouse warping. */
@@ -8953,11 +8914,11 @@ x_set_mouse_position (struct frame *f, int x, int y)
8953 if (pix_y < 0) pix_y = 0; 8914 if (pix_y < 0) pix_y = 0;
8954 if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f); 8915 if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
8955 8916
8956 BLOCK_INPUT; 8917 block_input ();
8957 8918
8958 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 8919 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
8959 0, 0, 0, 0, pix_x, pix_y); 8920 0, 0, 0, 0, pix_x, pix_y);
8960 UNBLOCK_INPUT; 8921 unblock_input ();
8961} 8922}
8962 8923
8963/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ 8924/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */
@@ -8965,11 +8926,11 @@ x_set_mouse_position (struct frame *f, int x, int y)
8965void 8926void
8966x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) 8927x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
8967{ 8928{
8968 BLOCK_INPUT; 8929 block_input ();
8969 8930
8970 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 8931 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
8971 0, 0, 0, 0, pix_x, pix_y); 8932 0, 0, 0, 0, pix_x, pix_y);
8972 UNBLOCK_INPUT; 8933 unblock_input ();
8973} 8934}
8974 8935
8975/* Raise frame F. */ 8936/* Raise frame F. */
@@ -8977,12 +8938,12 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
8977void 8938void
8978x_raise_frame (struct frame *f) 8939x_raise_frame (struct frame *f)
8979{ 8940{
8980 BLOCK_INPUT; 8941 block_input ();
8981 if (f->async_visible) 8942 if (f->async_visible)
8982 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8943 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8983 8944
8984 XFlush (FRAME_X_DISPLAY (f)); 8945 XFlush (FRAME_X_DISPLAY (f));
8985 UNBLOCK_INPUT; 8946 unblock_input ();
8986} 8947}
8987 8948
8988/* Lower frame F. */ 8949/* Lower frame F. */
@@ -8992,10 +8953,10 @@ x_lower_frame (struct frame *f)
8992{ 8953{
8993 if (f->async_visible) 8954 if (f->async_visible)
8994 { 8955 {
8995 BLOCK_INPUT; 8956 block_input ();
8996 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8957 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8997 XFlush (FRAME_X_DISPLAY (f)); 8958 XFlush (FRAME_X_DISPLAY (f));
8998 UNBLOCK_INPUT; 8959 unblock_input ();
8999 } 8960 }
9000} 8961}
9001 8962
@@ -9104,7 +9065,7 @@ x_make_frame_visible (struct frame *f)
9104 9065
9105 retry: 9066 retry:
9106 9067
9107 BLOCK_INPUT; 9068 block_input ();
9108 9069
9109 type = x_icon_type (f); 9070 type = x_icon_type (f);
9110 if (!NILP (type)) 9071 if (!NILP (type))
@@ -9163,7 +9124,7 @@ x_make_frame_visible (struct frame *f)
9163 original_top = f->top_pos; 9124 original_top = f->top_pos;
9164 9125
9165 /* This must come after we set COUNT. */ 9126 /* This must come after we set COUNT. */
9166 UNBLOCK_INPUT; 9127 unblock_input ();
9167 9128
9168 /* We unblock here so that arriving X events are processed. */ 9129 /* We unblock here so that arriving X events are processed. */
9169 9130
@@ -9186,7 +9147,7 @@ x_make_frame_visible (struct frame *f)
9186 int x, y; 9147 int x, y;
9187 unsigned int width, height, border, depth; 9148 unsigned int width, height, border, depth;
9188 9149
9189 BLOCK_INPUT; 9150 block_input ();
9190 9151
9191 /* On some window managers (such as FVWM) moving an existing 9152 /* On some window managers (such as FVWM) moving an existing
9192 window, even to the same place, causes the window manager 9153 window, even to the same place, causes the window manager
@@ -9202,7 +9163,7 @@ x_make_frame_visible (struct frame *f)
9202 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 9163 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
9203 original_left, original_top); 9164 original_left, original_top);
9204 9165
9205 UNBLOCK_INPUT; 9166 unblock_input ();
9206 } 9167 }
9207 9168
9208 XSETFRAME (frame, f); 9169 XSETFRAME (frame, f);
@@ -9269,7 +9230,7 @@ x_make_frame_invisible (struct frame *f)
9269 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) 9230 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
9270 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; 9231 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
9271 9232
9272 BLOCK_INPUT; 9233 block_input ();
9273 9234
9274 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim 9235 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
9275 that the current position of the window is user-specified, rather than 9236 that the current position of the window is user-specified, rather than
@@ -9292,7 +9253,7 @@ x_make_frame_invisible (struct frame *f)
9292 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, 9253 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window,
9293 DefaultScreen (FRAME_X_DISPLAY (f)))) 9254 DefaultScreen (FRAME_X_DISPLAY (f))))
9294 { 9255 {
9295 UNBLOCK_INPUT_RESIGNAL; 9256 unblock_input ();
9296 error ("Can't notify window manager of window withdrawal"); 9257 error ("Can't notify window manager of window withdrawal");
9297 } 9258 }
9298 } 9259 }
@@ -9309,7 +9270,7 @@ x_make_frame_invisible (struct frame *f)
9309 9270
9310 x_sync (f); 9271 x_sync (f);
9311 9272
9312 UNBLOCK_INPUT; 9273 unblock_input ();
9313} 9274}
9314 9275
9315/* Change window state from mapped to iconified. */ 9276/* Change window state from mapped to iconified. */
@@ -9329,7 +9290,7 @@ x_iconify_frame (struct frame *f)
9329 if (f->async_iconified) 9290 if (f->async_iconified)
9330 return; 9291 return;
9331 9292
9332 BLOCK_INPUT; 9293 block_input ();
9333 9294
9334 FRAME_SAMPLE_VISIBILITY (f); 9295 FRAME_SAMPLE_VISIBILITY (f);
9335 9296
@@ -9348,7 +9309,7 @@ x_iconify_frame (struct frame *f)
9348 f->visible = 1; 9309 f->visible = 1;
9349 f->async_iconified = 1; 9310 f->async_iconified = 1;
9350 f->async_visible = 0; 9311 f->async_visible = 0;
9351 UNBLOCK_INPUT; 9312 unblock_input ();
9352 return; 9313 return;
9353 } 9314 }
9354#endif 9315#endif
@@ -9368,14 +9329,14 @@ x_iconify_frame (struct frame *f)
9368 f->visible = 1; 9329 f->visible = 1;
9369 f->async_iconified = 1; 9330 f->async_iconified = 1;
9370 f->async_visible = 0; 9331 f->async_visible = 0;
9371 UNBLOCK_INPUT; 9332 unblock_input ();
9372 return; 9333 return;
9373 } 9334 }
9374 9335
9375 result = XIconifyWindow (FRAME_X_DISPLAY (f), 9336 result = XIconifyWindow (FRAME_X_DISPLAY (f),
9376 XtWindow (f->output_data.x->widget), 9337 XtWindow (f->output_data.x->widget),
9377 DefaultScreen (FRAME_X_DISPLAY (f))); 9338 DefaultScreen (FRAME_X_DISPLAY (f)));
9378 UNBLOCK_INPUT; 9339 unblock_input ();
9379 9340
9380 if (!result) 9341 if (!result)
9381 error ("Can't notify window manager of iconification"); 9342 error ("Can't notify window manager of iconification");
@@ -9384,9 +9345,9 @@ x_iconify_frame (struct frame *f)
9384 f->async_visible = 0; 9345 f->async_visible = 0;
9385 9346
9386 9347
9387 BLOCK_INPUT; 9348 block_input ();
9388 XFlush (FRAME_X_DISPLAY (f)); 9349 XFlush (FRAME_X_DISPLAY (f));
9389 UNBLOCK_INPUT; 9350 unblock_input ();
9390#else /* not USE_X_TOOLKIT */ 9351#else /* not USE_X_TOOLKIT */
9391 9352
9392 /* Make sure the X server knows where the window should be positioned, 9353 /* Make sure the X server knows where the window should be positioned,
@@ -9416,7 +9377,7 @@ x_iconify_frame (struct frame *f)
9416 SubstructureRedirectMask | SubstructureNotifyMask, 9377 SubstructureRedirectMask | SubstructureNotifyMask,
9417 &msg)) 9378 &msg))
9418 { 9379 {
9419 UNBLOCK_INPUT_RESIGNAL; 9380 unblock_input ();
9420 error ("Can't notify window manager of iconification"); 9381 error ("Can't notify window manager of iconification");
9421 } 9382 }
9422 } 9383 }
@@ -9435,7 +9396,7 @@ x_iconify_frame (struct frame *f)
9435 f->async_visible = 0; 9396 f->async_visible = 0;
9436 9397
9437 XFlush (FRAME_X_DISPLAY (f)); 9398 XFlush (FRAME_X_DISPLAY (f));
9438 UNBLOCK_INPUT; 9399 unblock_input ();
9439#endif /* not USE_X_TOOLKIT */ 9400#endif /* not USE_X_TOOLKIT */
9440} 9401}
9441 9402
@@ -9452,7 +9413,7 @@ x_free_frame_resources (struct frame *f)
9452 struct scroll_bar *b; 9413 struct scroll_bar *b;
9453#endif 9414#endif
9454 9415
9455 BLOCK_INPUT; 9416 block_input ();
9456 9417
9457 /* If a display connection is dead, don't try sending more 9418 /* If a display connection is dead, don't try sending more
9458 commands to the X server. */ 9419 commands to the X server. */
@@ -9555,7 +9516,7 @@ x_free_frame_resources (struct frame *f)
9555 hlinfo->mouse_face_mouse_frame = 0; 9516 hlinfo->mouse_face_mouse_frame = 0;
9556 } 9517 }
9557 9518
9558 UNBLOCK_INPUT; 9519 unblock_input ();
9559} 9520}
9560 9521
9561 9522
@@ -9580,13 +9541,13 @@ x_destroy_window (struct frame *f)
9580/* Set the normal size hints for the window manager, for frame F. 9541/* Set the normal size hints for the window manager, for frame F.
9581 FLAGS is the flags word to use--or 0 meaning preserve the flags 9542 FLAGS is the flags word to use--or 0 meaning preserve the flags
9582 that the window now has. 9543 that the window now has.
9583 If USER_POSITION is nonzero, we set the USPosition 9544 If USER_POSITION, set the USPosition
9584 flag (this is useful when FLAGS is 0). 9545 flag (this is useful when FLAGS is 0).
9585 The GTK version is in gtkutils.c */ 9546 The GTK version is in gtkutils.c. */
9586 9547
9587#ifndef USE_GTK 9548#ifndef USE_GTK
9588void 9549void
9589x_wm_set_size_hint (struct frame *f, long flags, int user_position) 9550x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
9590{ 9551{
9591 XSizeHints size_hints; 9552 XSizeHints size_hints;
9592 Window window = FRAME_OUTER_WINDOW (f); 9553 Window window = FRAME_OUTER_WINDOW (f);
@@ -9935,7 +9896,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9935 Mouse_HLInfo *hlinfo; 9896 Mouse_HLInfo *hlinfo;
9936 ptrdiff_t lim; 9897 ptrdiff_t lim;
9937 9898
9938 BLOCK_INPUT; 9899 block_input ();
9939 9900
9940 if (!x_initialized) 9901 if (!x_initialized)
9941 { 9902 {
@@ -9996,11 +9957,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9996 Call before gtk_init so Gtk+ event filters comes after our. */ 9957 Call before gtk_init so Gtk+ event filters comes after our. */
9997 gdk_window_add_filter (NULL, event_handler_gdk, NULL); 9958 gdk_window_add_filter (NULL, event_handler_gdk, NULL);
9998 9959
9960 /* gtk_init does set_locale. Fix locale before and after. */
9961 fixup_locale ();
9999 gtk_init (&argc, &argv2); 9962 gtk_init (&argc, &argv2);
9963 fixup_locale ();
9964
10000 g_log_remove_handler ("GLib", id); 9965 g_log_remove_handler ("GLib", id);
10001 9966
10002 /* gtk_init does set_locale. We must fix locale after calling it. */
10003 fixup_locale ();
10004 xg_initialize (); 9967 xg_initialize ();
10005 9968
10006 dpy = DEFAULT_GDK_DISPLAY (); 9969 dpy = DEFAULT_GDK_DISPLAY ();
@@ -10067,7 +10030,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10067 /* Detect failure. */ 10030 /* Detect failure. */
10068 if (dpy == 0) 10031 if (dpy == 0)
10069 { 10032 {
10070 UNBLOCK_INPUT; 10033 unblock_input ();
10071 return 0; 10034 return 0;
10072 } 10035 }
10073 10036
@@ -10114,12 +10077,12 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10114 10077
10115 /* Temporarily hide the partially initialized terminal. */ 10078 /* Temporarily hide the partially initialized terminal. */
10116 terminal_list = terminal->next_terminal; 10079 terminal_list = terminal->next_terminal;
10117 UNBLOCK_INPUT; 10080 unblock_input ();
10118 kset_system_key_alist 10081 kset_system_key_alist
10119 (terminal->kboard, 10082 (terminal->kboard,
10120 call1 (Qvendor_specific_keysyms, 10083 call1 (Qvendor_specific_keysyms,
10121 vendor ? build_string (vendor) : empty_unibyte_string)); 10084 vendor ? build_string (vendor) : empty_unibyte_string));
10122 BLOCK_INPUT; 10085 block_input ();
10123 terminal->next_terminal = terminal_list; 10086 terminal->next_terminal = terminal_list;
10124 terminal_list = terminal; 10087 terminal_list = terminal;
10125 UNGCPRO; 10088 UNGCPRO;
@@ -10468,7 +10431,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10468 x_session_initialize (dpyinfo); 10431 x_session_initialize (dpyinfo);
10469#endif 10432#endif
10470 10433
10471 UNBLOCK_INPUT; 10434 unblock_input ();
10472 10435
10473 return dpyinfo; 10436 return dpyinfo;
10474} 10437}
@@ -10548,7 +10511,7 @@ x_delete_display (struct x_display_info *dpyinfo)
10548static void 10511static void
10549x_process_timeouts (struct atimer *timer) 10512x_process_timeouts (struct atimer *timer)
10550{ 10513{
10551 BLOCK_INPUT; 10514 block_input ();
10552 x_timeout_atimer_activated_flag = 0; 10515 x_timeout_atimer_activated_flag = 0;
10553 if (toolkit_scroll_bar_interaction || popup_activated ()) 10516 if (toolkit_scroll_bar_interaction || popup_activated ())
10554 { 10517 {
@@ -10557,7 +10520,7 @@ x_process_timeouts (struct atimer *timer)
10557 /* Reactivate the atimer for next time. */ 10520 /* Reactivate the atimer for next time. */
10558 x_activate_timeout_atimer (); 10521 x_activate_timeout_atimer ();
10559 } 10522 }
10560 UNBLOCK_INPUT; 10523 unblock_input ();
10561} 10524}
10562 10525
10563/* Install an asynchronous timer that processes Xt timeout events 10526/* Install an asynchronous timer that processes Xt timeout events
@@ -10571,14 +10534,14 @@ x_process_timeouts (struct atimer *timer)
10571void 10534void
10572x_activate_timeout_atimer (void) 10535x_activate_timeout_atimer (void)
10573{ 10536{
10574 BLOCK_INPUT; 10537 block_input ();
10575 if (!x_timeout_atimer_activated_flag) 10538 if (!x_timeout_atimer_activated_flag)
10576 { 10539 {
10577 EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000); 10540 EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000);
10578 start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0); 10541 start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0);
10579 x_timeout_atimer_activated_flag = 1; 10542 x_timeout_atimer_activated_flag = 1;
10580 } 10543 }
10581 UNBLOCK_INPUT; 10544 unblock_input ();
10582} 10545}
10583 10546
10584#endif /* USE_X_TOOLKIT */ 10547#endif /* USE_X_TOOLKIT */
@@ -10631,7 +10594,7 @@ x_delete_terminal (struct terminal *terminal)
10631 if (!terminal->name) 10594 if (!terminal->name)
10632 return; 10595 return;
10633 10596
10634 BLOCK_INPUT; 10597 block_input ();
10635#ifdef HAVE_X_I18N 10598#ifdef HAVE_X_I18N
10636 /* We must close our connection to the XIM server before closing the 10599 /* We must close our connection to the XIM server before closing the
10637 X display. */ 10600 X display. */
@@ -10686,7 +10649,7 @@ x_delete_terminal (struct terminal *terminal)
10686 /* Mark as dead. */ 10649 /* Mark as dead. */
10687 dpyinfo->display = NULL; 10650 dpyinfo->display = NULL;
10688 x_delete_display (dpyinfo); 10651 x_delete_display (dpyinfo);
10689 UNBLOCK_INPUT; 10652 unblock_input ();
10690} 10653}
10691 10654
10692/* Create a struct terminal, initialize it with the X11 specific 10655/* Create a struct terminal, initialize it with the X11 specific
@@ -10743,8 +10706,6 @@ x_create_terminal (struct x_display_info *dpyinfo)
10743void 10706void
10744x_initialize (void) 10707x_initialize (void)
10745{ 10708{
10746 struct sigaction action;
10747
10748 baud_rate = 19200; 10709 baud_rate = 19200;
10749 10710
10750 x_noop_count = 0; 10711 x_noop_count = 0;
@@ -10790,9 +10751,6 @@ x_initialize (void)
10790 original error handler. */ 10751 original error handler. */
10791 XSetErrorHandler (x_error_handler); 10752 XSetErrorHandler (x_error_handler);
10792 XSetIOErrorHandler (x_io_error_quitter); 10753 XSetIOErrorHandler (x_io_error_quitter);
10793
10794 emacs_sigaction_init (&action, x_connection_signal);
10795 sigaction (SIGPIPE, &action, 0);
10796} 10754}
10797 10755
10798 10756
diff --git a/src/xterm.h b/src/xterm.h
index 2d718f49118..4bc8f9813ed 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -962,11 +962,11 @@ extern XtAppContext Xt_app_con;
962extern void x_activate_timeout_atimer (void); 962extern void x_activate_timeout_atimer (void);
963#endif 963#endif
964#ifdef USE_LUCID 964#ifdef USE_LUCID
965extern int x_alloc_lighter_color_for_widget (Widget, Display *, Colormap, 965extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
966 unsigned long *, 966 unsigned long *,
967 double, int); 967 double, int);
968#endif 968#endif
969extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *); 969extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
970extern void x_query_color (struct frame *f, XColor *); 970extern void x_query_color (struct frame *f, XColor *);
971extern void x_clear_area (Display *, Window, int, int, int, int, int); 971extern void x_clear_area (Display *, Window, int, int, int, int, int);
972#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK 972#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK
@@ -1034,7 +1034,7 @@ extern void xic_set_statusarea (struct frame *);
1034extern void xic_set_xfontset (struct frame *, const char *); 1034extern void xic_set_xfontset (struct frame *, const char *);
1035extern int x_pixel_width (struct frame *); 1035extern int x_pixel_width (struct frame *);
1036extern int x_pixel_height (struct frame *); 1036extern int x_pixel_height (struct frame *);
1037extern int x_defined_color (struct frame *, const char *, XColor *, int); 1037extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
1038#ifdef HAVE_X_I18N 1038#ifdef HAVE_X_I18N
1039extern void free_frame_xic (struct frame *); 1039extern void free_frame_xic (struct frame *);
1040# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT 1040# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT