1 /* syssignal.h - System-dependent definitions for signals.
2 Copyright (C) 1993, 1999 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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 2, or (at your option)
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 /* Don't #include <signal.h>. That header should always be #included
24 before "config.h", because some configuration files (like s/hpux.h)
25 indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file
26 #includes <signal.h>, then that will re-#define SIGIO and confuse
29 #define SIGMASKTYPE sigset_t
31 #define SIGEMPTYMASK (empty_mask)
32 #define SIGFULLMASK (full_mask)
33 extern sigset_t empty_mask
, full_mask
;
34 extern void init_signals
P_ ((void));
36 /* POSIX pretty much destroys any possibility of writing sigmask as a
37 macro in standard C. We always define our own version because the
38 predefined macro in Glibc 2.1 is only provided for compatility for old
39 programs that use int as signal mask type. */
42 #define sigmask(SIG) \
45 sigemptyset (&_mask); \
46 sigaddset (&_mask, SIG); \
49 #else /* ! defined (__GNUC__) */
50 extern sigset_t
sys_sigmask ();
51 #define sigmask(SIG) (sys_sigmask (SIG))
52 #endif /* ! defined (__GNUC__) */
55 #define sigpause(MASK) sigsuspend (&(MASK))
57 #define sigblock(SIG) sys_sigblock (SIG)
58 #define sigunblock(SIG) sys_sigunblock (SIG)
60 #define sigsetmask(SIG) sys_sigsetmask (SIG)
62 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
63 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
65 #define signal(SIG,ACT) sys_signal(SIG,ACT)
67 /* Whether this is what all systems want or not, this is what
68 appears to be assumed in the source, for example data.c:arith_error. */
69 typedef RETSIGTYPE (*signal_handler_t
) (/*int*/);
71 signal_handler_t sys_signal
P_ ((int signal_number
, signal_handler_t action
));
72 sigset_t sys_sigblock
P_ ((sigset_t new_mask
));
73 sigset_t sys_sigunblock
P_ ((sigset_t new_mask
));
74 sigset_t sys_sigsetmask
P_ ((sigset_t new_mask
));
76 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
78 #else /* ! defined (POSIX_SIGNALS) */
81 extern SIGMASKTYPE sigprocmask_set
;
84 #define sigblock(sig) \
85 (sigprocmask_set = SIGEMPTYMASK | (sig), \
86 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
90 #define sigunblock(sig) \
91 (sigprocmask_set = SIGFULLMASK & ~(sig), \
92 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
99 #define sigunblock(sig)
105 #define sigunblock(SIG) \
106 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
109 #endif /* ! defined (USG) */
110 #endif /* ! defined (USG5_4) */
111 #endif /* ! defined (POSIX_SIGNALS) */
114 #define SIGMASKTYPE int
118 #define SIGEMPTYMASK (0)
122 #define SIGFULLMASK (0xffffffff)
126 #define sigmask(no) (1L << ((no) - 1))
130 #define sigunblock(SIG) \
131 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
135 #define sigfree() sigsetmask (SIGEMPTYMASK)
136 #endif /* not BSD4_1 */
138 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
141 #if defined (SIGIO) && defined (BROKEN_SIGIO)
144 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
147 #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP)
150 #if defined (SIGURG) && defined (BROKEN_SIGURG)
153 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
156 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
161 #if NSIG < NSIG_MINIMUM
165 # define NSIG NSIG_MINIMUM
169 #define SIGIO SIGTINT
170 /* sigfree is in sysdep.c */
173 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
174 Must do that using the killpg call. */
176 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
179 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
181 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
185 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
190 #define SIGCHLD SIGCLD
192 #endif /* ! defined (SIGCLD) */
195 #ifndef HAVE_STRSIGNAL
196 /* strsignal is in sysdep.c */