root/src/blockinput.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. block_input
  2. input_blocked_p

     1 /* blockinput.h - interface to blocking complicated interrupt-driven input.
     2    Copyright (C) 1989, 1993, 2001-2023 Free Software Foundation, Inc.
     3 
     4 This file is part of GNU Emacs.
     5 
     6 GNU Emacs is free software: you can redistribute it and/or modify
     7 it under the terms of the GNU General Public License as published by
     8 the Free Software Foundation, either version 3 of the License, or (at
     9 your option) any later version.
    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
    17 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    18 
    19 #ifndef EMACS_BLOCKINPUT_H
    20 #define EMACS_BLOCKINPUT_H
    21 
    22 INLINE_HEADER_BEGIN
    23 
    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.
    28 
    29    To avoid this, we make the following requirements:
    30 
    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.
    35 
    36    * Any complicated interrupt handling code should test
    37    INPUT_BLOCKED_P, and put off its work until later.
    38 
    39    * If the interrupt handling code wishes, it may set
    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.
    43 
    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.  */
    47 
    48 extern volatile int interrupt_input_blocked;
    49 
    50 /* Begin critical section. */
    51 
    52 INLINE void
    53 block_input (void)
    54 {
    55   interrupt_input_blocked++;
    56 }
    57 
    58 extern void unblock_input (void);
    59 extern void totally_unblock_input (void);
    60 extern void unblock_input_to (int);
    61 
    62 /* In critical section?  */
    63 
    64 INLINE bool
    65 input_blocked_p (void)
    66 {
    67   return interrupt_input_blocked > 0;
    68 }
    69 
    70 INLINE_HEADER_END
    71 
    72 #endif /* EMACS_BLOCKINPUT_H */

/* [<][>][^][v][top][bottom][index][help] */