(root)/
texinfo-7.1/
info/
signals.h
       1  /* signals.h -- header to include system dependent signal definitions.
       2  
       3     Copyright 1993-2023 Free Software Foundation, Inc.
       4  
       5     This program is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU General Public License as published by
       7     the Free Software Foundation, either version 3 of the License, or
       8     (at your option) any later version.
       9  
      10     This program is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13     GNU General Public License for more details.
      14  
      15     You should have received a copy of the GNU General Public License
      16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17  
      18     Originally written by Brian Fox. */
      19  
      20  #ifndef INFO_SIGNALS_H
      21  #define INFO_SIGNALS_H
      22  
      23  #include <sys/types.h>
      24  #include <signal.h>
      25  
      26  void signal_block_winch (void);
      27  void signal_unblock_winch (void);
      28  
      29  /* For sysV68 --phdm@info.ucl.ac.be.  */
      30  #if !defined (SIGCHLD) && defined (SIGCLD)
      31  #define SIGCHLD SIGCLD
      32  #endif
      33  
      34  #if !defined (HAVE_SIGPROCMASK) && !defined (sigmask)
      35  #  define sigmask(x) (1 << ((x)-1))
      36  #endif /* !HAVE_SIGPROCMASK && !sigmask */
      37  
      38  /* Without SA_NOCLDSTOP, sigset_t might end up being undefined even
      39     though we have sigprocmask, on older systems, according to Nelson
      40     Beebe.  The test is from coreutils/sort.c, via Paul Eggert.  */
      41  #if !defined (HAVE_SIGPROCMASK) || !defined (SA_NOCLDSTOP)
      42  #  if !defined (SIG_BLOCK)
      43  #    define SIG_UNBLOCK 1
      44  #    define SIG_BLOCK   2
      45  #    define SIG_SETMASK 3
      46  #  endif /* SIG_BLOCK */
      47  
      48  /* Type of a signal set. */
      49  #  define sigset_t int
      50  
      51  /* Make SET have no signals in it. */
      52  #  define sigemptyset(set) (*(set) = (sigset_t)0x0)
      53  
      54  /* Make SET have the full range of signal specifications possible. */
      55  #  define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)
      56  
      57  /* Add SIG to the contents of SET. */
      58  #  define sigaddset(set, sig) *(set) |= sigmask (sig)
      59  
      60  /* Delete SIG from the contents of SET. */
      61  #  define sigdelset(set, sig) *(set) &= ~(sigmask (sig))
      62  
      63  /* Tell if SET contains SIG. */
      64  #  define sigismember(set, sig) (*(set) & (sigmask (sig)))
      65  
      66  /* Suspend the process until the reception of one of the signals
      67     not present in SET. */
      68  #  define sigsuspend(set) sigpause (*(set))
      69  #endif /* !HAVE_SIGPROCMASK */
      70  
      71  #if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
      72  /* These definitions are used both in POSIX and non-POSIX implementations. */
      73  
      74  #define BLOCK_SIGNAL(sig) \
      75    do { \
      76      sigset_t nvar, ovar; \
      77      sigemptyset (&nvar); \
      78      sigemptyset (&ovar); \
      79      sigaddset (&nvar, sig); \
      80      sigprocmask (SIG_BLOCK, &nvar, &ovar); \
      81    } while (0)
      82  
      83  #define UNBLOCK_SIGNAL(sig) \
      84    do { \
      85      sigset_t nvar, ovar; \
      86      sigemptyset (&ovar); \
      87      sigemptyset (&nvar); \
      88      sigaddset (&nvar, sig); \
      89      sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
      90    } while (0)
      91  
      92  #else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
      93  #  define BLOCK_SIGNAL(sig)
      94  #  define UNBLOCK_SIGNAL(sig)
      95  #endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
      96  
      97  #endif /* not INFO_SIGNALS_H */