Remove `LISP_FLOAT_TYPE' and `standalone'.
[bpt/emacs.git] / src / blockinput.h
CommitLineData
9ac0d9e0 1/* blockinput.h - interface to blocking complicated interrupt-driven input.
33f9662a
JB
2 Copyright (C) 1989, 1993 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
3b7ad313
EN
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
33f9662a
JB
20
21
22/* When Emacs is using signal-driven input, the processing of those
23 input signals can get pretty hairy. For example, when Emacs is
24 running under X windows, handling an input signal can entail
25 retrieving events from the X event queue, or making other X calls.
26
27 If an input signal occurs while Emacs is in the midst of some
28 non-reentrant code, and the signal processing invokes that same
29 code, we lose. For example, malloc and the Xlib functions aren't
30 usually re-entrant, and both are used by the X input signal handler
31 - if we try to process an input signal in the midst of executing
32 any of these functions, we'll lose.
33
34 To avoid this, we make the following requirements:
35
36 * Everyone must evaluate BLOCK_INPUT before entering these functions,
37 and then call UNBLOCK_INPUT after performing them. Calls
38 BLOCK_INPUT and UNBLOCK_INPUT may be nested.
39
40 * Any complicated interrupt handling code should test
41 interrupt_input_blocked, and put off its work until later.
42
43 * If the interrupt handling code wishes, it may set
44 interrupt_input_pending to a non-zero value. If that flag is set
45 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */
46
61836955 47extern int interrupt_input_blocked;
33f9662a
JB
48
49/* Nonzero means an input interrupt has arrived
50 during the current critical section. */
51extern int interrupt_input_pending;
52
95d9dd00
GM
53
54/* Non-zero means asynchronous timers should be run when input is
55 unblocked. */
56
57extern int pending_atimers;
58
33f9662a
JB
59/* Begin critical section. */
60#define BLOCK_INPUT (interrupt_input_blocked++)
61
40a4095a
JB
62/* End critical section.
63
64 If doing signal-driven input, and a signal came in when input was
65 blocked, reinvoke the signal handler now to deal with it.
66
67 We used to have two possible definitions of this macro - one for
68 when SIGIO was #defined, and one for when it wasn't; when SIGIO
69 wasn't #defined, we wouldn't bother to check if we should re-invoke
70 the signal handler. But that doesn't work very well; some of the
71 files which use this macro don't #include the right files to get
72 SIGIO.
73
74 So, we always test interrupt_input_pending now; that's not too
75 expensive, and it'll never get set if we don't need to resignal. */
95d9dd00
GM
76
77#define UNBLOCK_INPUT \
78 do \
79 { \
80 --interrupt_input_blocked; \
81 if (interrupt_input_blocked == 0) \
82 { \
83 if (interrupt_input_pending) \
84 reinvoke_input_signal (); \
85 if (pending_atimers) \
86 do_pending_atimers (); \
87 } \
88 else if (interrupt_input_blocked < 0) \
89 abort (); \
90 } \
91 while (0)
33f9662a
JB
92
93#define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0)
94#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
ec5d8db7
AS
95
96/* Defined in keyboard.c */
de4df76b
RS
97/* Don't use a prototype here; it causes trouble in some files. */
98extern void reinvoke_input_signal ();