(compile-internal): Initialize the process-mark.
[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
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21/* When Emacs is using signal-driven input, the processing of those
22 input signals can get pretty hairy. For example, when Emacs is
23 running under X windows, handling an input signal can entail
24 retrieving events from the X event queue, or making other X calls.
25
26 If an input signal occurs while Emacs is in the midst of some
27 non-reentrant code, and the signal processing invokes that same
28 code, we lose. For example, malloc and the Xlib functions aren't
29 usually re-entrant, and both are used by the X input signal handler
30 - if we try to process an input signal in the midst of executing
31 any of these functions, we'll lose.
32
33 To avoid this, we make the following requirements:
34
35 * Everyone must evaluate BLOCK_INPUT before entering these functions,
36 and then call UNBLOCK_INPUT after performing them. Calls
37 BLOCK_INPUT and UNBLOCK_INPUT may be nested.
38
39 * Any complicated interrupt handling code should test
40 interrupt_input_blocked, and put off its work until later.
41
42 * If the interrupt handling code wishes, it may set
43 interrupt_input_pending to a non-zero value. If that flag is set
44 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */
45
46extern unsigned int interrupt_input_blocked;
47
48/* Nonzero means an input interrupt has arrived
49 during the current critical section. */
50extern int interrupt_input_pending;
51
52/* Begin critical section. */
53#define BLOCK_INPUT (interrupt_input_blocked++)
54
55/* End critical section. */
56#ifdef SIGIO
57/* If doing interrupt input, and an interrupt came in when input was blocked,
58 reinvoke the interrupt handler now to deal with it. */
59#define UNBLOCK_INPUT \
60 (interrupt_input_blocked--, \
61 (interrupt_input_blocked < 0 ? (abort (), 0) : 0), \
af56dc7e 62 ((interrupt_input_blocked == 0 && interrupt_input_pending != 0) \
33f9662a
JB
63 ? (kill (0, SIGIO), 0) \
64 : 0))
65#else
66#define UNBLOCK_INPUT \
67 (interrupt_input_blocked--, \
68 (interrupt_input_blocked < 0 ? (abort (), 0) : 0))
69#endif
70
71#define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0)
72#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT