Commit | Line | Data |
---|---|---|
9ac0d9e0 | 1 | /* blockinput.h - interface to blocking complicated interrupt-driven input. |
ba318903 | 2 | Copyright (C) 1989, 1993, 2001-2014 Free Software Foundation, Inc. |
33f9662a JB |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
b9b1cc14 | 6 | GNU Emacs is free software: you can redistribute it and/or modify |
33f9662a | 7 | it under the terms of the GNU General Public License as published by |
b9b1cc14 GM |
8 | the Free Software Foundation, either version 3 of the License, or |
9 | (at your option) any later version. | |
33f9662a JB |
10 | |
11 | GNU Emacs is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
b9b1cc14 | 17 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
33f9662a | 18 | |
b6df5543 DL |
19 | #ifndef EMACS_BLOCKINPUT_H |
20 | #define EMACS_BLOCKINPUT_H | |
21 | ||
4d7e6e51 | 22 | INLINE_HEADER_BEGIN |
33f9662a | 23 | |
4d7e6e51 PE |
24 | /* Emacs should avoid doing anything hairy in a signal handler, because |
25 | so many system functions are non-reentrant. For example, malloc | |
26 | and the Xlib functions aren't usually re-entrant, so if they were | |
27 | used by the SIGIO handler, we'd lose. | |
33f9662a JB |
28 | |
29 | To avoid this, we make the following requirements: | |
30 | ||
4d7e6e51 PE |
31 | * Everyone must evaluate BLOCK_INPUT before performing actions that |
32 | might conflict with a signal handler, and then call UNBLOCK_INPUT | |
33 | after performing them. Calls BLOCK_INPUT and UNBLOCK_INPUT may be | |
34 | nested. | |
33f9662a JB |
35 | |
36 | * Any complicated interrupt handling code should test | |
4d7e6e51 | 37 | INPUT_BLOCKED_P, and put off its work until later. |
33f9662a JB |
38 | |
39 | * If the interrupt handling code wishes, it may set | |
4d7e6e51 PE |
40 | pending_signals to a non-zero value. If that flag is set |
41 | when input becomes unblocked, UNBLOCK_INPUT will then read | |
42 | input and process timers. | |
33f9662a | 43 | |
4d7e6e51 PE |
44 | Historically, Emacs signal handlers did much more than they do now, |
45 | and this caused many BLOCK_INPUT calls to be sprinkled around the code. | |
46 | FIXME: Remove calls that aren't needed now. */ | |
95d9dd00 | 47 | |
4d7e6e51 | 48 | extern volatile int interrupt_input_blocked; |
95d9dd00 | 49 | |
4d7e6e51 | 50 | /* Begin critical section. */ |
95d9dd00 | 51 | |
00382e8b | 52 | INLINE void |
4d7e6e51 PE |
53 | block_input (void) |
54 | { | |
55 | interrupt_input_blocked++; | |
56 | } | |
edfda783 | 57 | |
4d7e6e51 PE |
58 | extern void unblock_input (void); |
59 | extern void totally_unblock_input (void); | |
60 | extern void unblock_input_to (int); | |
ec5d8db7 | 61 | |
f224e500 | 62 | /* In critical section? */ |
c2de28ef | 63 | |
00382e8b | 64 | INLINE bool |
4d7e6e51 PE |
65 | input_blocked_p (void) |
66 | { | |
908589fd | 67 | return interrupt_input_blocked > 0; |
4d7e6e51 PE |
68 | } |
69 | ||
70 | INLINE_HEADER_END | |
b6df5543 DL |
71 | |
72 | #endif /* EMACS_BLOCKINPUT_H */ |