*** empty log message ***
[emacs.git] / src / syssignal.h
blobcef71f7459ab1b23c4def7647b8d745e67bcb69b
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)
9 any later version.
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. */
21 extern void init_signals P_ ((void));
23 #ifdef POSIX_SIGNALS
25 /* Don't #include <signal.h>. That header should always be #included
26 before "config.h", because some configuration files (like s/hpux.h)
27 indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file
28 #includes <signal.h>, then that will re-#define SIGIO and confuse
29 things. */
31 #define SIGMASKTYPE sigset_t
33 #define SIGEMPTYMASK (empty_mask)
34 #define SIGFULLMASK (full_mask)
35 extern sigset_t empty_mask, full_mask;
37 /* POSIX pretty much destroys any possibility of writing sigmask as a
38 macro in standard C. We always define our own version because the
39 predefined macro in Glibc 2.1 is only provided for compatility for old
40 programs that use int as signal mask type. */
41 #undef sigmask
42 #ifdef __GNUC__
43 #define sigmask(SIG) \
44 ({ \
45 sigset_t _mask; \
46 sigemptyset (&_mask); \
47 sigaddset (&_mask, SIG); \
48 _mask; \
50 #else /* ! defined (__GNUC__) */
51 extern sigset_t sys_sigmask ();
52 #define sigmask(SIG) (sys_sigmask (SIG))
53 #endif /* ! defined (__GNUC__) */
55 #undef sigpause
56 #define sigpause(MASK) sigsuspend (&(MASK))
58 #define sigblock(SIG) sys_sigblock (SIG)
59 #define sigunblock(SIG) sys_sigunblock (SIG)
60 #ifndef sigsetmask
61 #define sigsetmask(SIG) sys_sigsetmask (SIG)
62 #endif
63 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
64 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
65 #undef signal
66 #define signal(SIG,ACT) sys_signal(SIG,ACT)
68 /* Whether this is what all systems want or not, this is what
69 appears to be assumed in the source, for example data.c:arith_error. */
70 typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
72 signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action));
73 sigset_t sys_sigblock P_ ((sigset_t new_mask));
74 sigset_t sys_sigunblock P_ ((sigset_t new_mask));
75 sigset_t sys_sigsetmask P_ ((sigset_t new_mask));
77 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
79 #else /* ! defined (POSIX_SIGNALS) */
80 #ifdef USG5_4
82 extern SIGMASKTYPE sigprocmask_set;
84 #ifndef sigblock
85 #define sigblock(sig) \
86 (sigprocmask_set = SIGEMPTYMASK | (sig), \
87 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
88 #endif
90 #ifndef sigunblock
91 #define sigunblock(sig) \
92 (sigprocmask_set = SIGFULLMASK & ~(sig), \
93 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
94 #endif
96 #else
97 #ifdef USG
99 #ifndef sigunblock
100 #define sigunblock(sig)
101 #endif
103 #else
105 #ifndef sigunblock
106 #define sigunblock(SIG) \
107 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
108 #endif
110 #endif /* ! defined (USG) */
111 #endif /* ! defined (USG5_4) */
112 #endif /* ! defined (POSIX_SIGNALS) */
114 #ifndef SIGMASKTYPE
115 #define SIGMASKTYPE int
116 #endif
118 #ifndef SIGEMPTYMASK
119 #define SIGEMPTYMASK (0)
120 #endif
122 #ifndef SIGFULLMASK
123 #define SIGFULLMASK (0xffffffff)
124 #endif
126 #ifndef sigmask
127 #define sigmask(no) (1L << ((no) - 1))
128 #endif
130 #ifndef sigunblock
131 #define sigunblock(SIG) \
132 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
133 #endif
135 #ifndef BSD4_1
136 #define sigfree() sigsetmask (SIGEMPTYMASK)
137 #endif /* not BSD4_1 */
139 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
140 #undef SIGINFO
141 #endif
142 #if defined (SIGIO) && defined (BROKEN_SIGIO)
143 #undef SIGIO
144 #endif
145 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
146 #undef SIGPOLL
147 #endif
148 #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP)
149 #undef SIGTSTP
150 #endif
151 #if defined (SIGURG) && defined (BROKEN_SIGURG)
152 #undef SIGURG
153 #endif
154 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
155 #undef SIGAIO
156 #endif
157 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
158 #undef SIGPTY
159 #endif
162 #if NSIG < NSIG_MINIMUM
163 # ifdef NSIG
164 # undef NSIG
165 # endif
166 # define NSIG NSIG_MINIMUM
167 #endif
169 #ifdef BSD4_1
170 #define SIGIO SIGTINT
171 /* sigfree is in sysdep.c */
172 #endif /* BSD4_1 */
174 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
175 Must do that using the killpg call. */
176 #ifdef BSD_SYSTEM
177 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
178 #else
179 #ifdef WINDOWSNT
180 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
181 #else
182 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
183 #endif
184 #endif
186 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
187 testing SIGCHLD. */
188 #ifndef VMS
189 #ifdef SIGCLD
190 #ifndef SIGCHLD
191 #define SIGCHLD SIGCLD
192 #endif /* SIGCHLD */
193 #endif /* ! defined (SIGCLD) */
194 #endif /* VMS */
196 #ifndef HAVE_STRSIGNAL
197 /* strsignal is in sysdep.c */
198 char *strsignal ();
199 #endif
201 /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152
202 (do not change this comment) */