annotate src/blockinput.h @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128

typos.
author Jeff Law <law@redhat.com>
date Wed, 10 Sep 1997 21:16:20 +0000
parents ee40177f6c68
children fb4c986db0e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2437
diff changeset
1 /* blockinput.h - interface to blocking complicated interrupt-driven input.
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 Copyright (C) 1989, 1993 Free Software Foundation, Inc.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 2721
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 2721
diff changeset
19 Boston, MA 02111-1307, USA. */
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 /* When Emacs is using signal-driven input, the processing of those
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 input signals can get pretty hairy. For example, when Emacs is
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 running under X windows, handling an input signal can entail
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 retrieving events from the X event queue, or making other X calls.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 If an input signal occurs while Emacs is in the midst of some
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 non-reentrant code, and the signal processing invokes that same
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 code, we lose. For example, malloc and the Xlib functions aren't
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 usually re-entrant, and both are used by the X input signal handler
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 - if we try to process an input signal in the midst of executing
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 any of these functions, we'll lose.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 To avoid this, we make the following requirements:
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 * Everyone must evaluate BLOCK_INPUT before entering these functions,
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 and then call UNBLOCK_INPUT after performing them. Calls
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 BLOCK_INPUT and UNBLOCK_INPUT may be nested.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 * Any complicated interrupt handling code should test
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 interrupt_input_blocked, and put off its work until later.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 * If the interrupt handling code wishes, it may set
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 interrupt_input_pending to a non-zero value. If that flag is set
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
2479
6d011b24f6fe (interrupt_input_blocked): Make this signed int.
Richard M. Stallman <rms@gnu.org>
parents: 2477
diff changeset
47 extern int interrupt_input_blocked;
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 /* Nonzero means an input interrupt has arrived
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 during the current critical section. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 extern int interrupt_input_pending;
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 /* Begin critical section. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #define BLOCK_INPUT (interrupt_input_blocked++)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
2721
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
56 /* End critical section.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
57
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
58 If doing signal-driven input, and a signal came in when input was
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
59 blocked, reinvoke the signal handler now to deal with it.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
60
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
61 We used to have two possible definitions of this macro - one for
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
62 when SIGIO was #defined, and one for when it wasn't; when SIGIO
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
63 wasn't #defined, we wouldn't bother to check if we should re-invoke
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
64 the signal handler. But that doesn't work very well; some of the
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
65 files which use this macro don't #include the right files to get
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
66 SIGIO.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
67
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
68 So, we always test interrupt_input_pending now; that's not too
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
69 expensive, and it'll never get set if we don't need to resignal. */
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 #define UNBLOCK_INPUT \
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (interrupt_input_blocked--, \
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (interrupt_input_blocked < 0 ? (abort (), 0) : 0), \
2477
4d0d858bc33f (UNBLOCK_INPUT): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 2439
diff changeset
73 ((interrupt_input_blocked == 0 && interrupt_input_pending != 0) \
2721
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
74 ? (reinvoke_input_signal (), 0) \
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 : 0))
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 #define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT