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