Merged in changes from CVS trunk.
[bpt/emacs.git] / src / syssignal.h
1 /* syssignal.h - System-dependent definitions for signals.
2 Copyright (C) 1993, 1999 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 2, or (at your option)
9 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; 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. */
20
21 extern void init_signals P_ ((void));
22
23 #ifdef POSIX_SIGNALS
24
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. */
30 /* XXX This is not correct anymore, there is a BROKEN_SIGIO macro. */
31
32 #define SIGMASKTYPE sigset_t
33
34 #define SIGEMPTYMASK (empty_mask)
35 #define SIGFULLMASK (full_mask)
36 extern sigset_t empty_mask, full_mask;
37
38 /* POSIX pretty much destroys any possibility of writing sigmask as a
39 macro in standard C. We always define our own version because the
40 predefined macro in Glibc 2.1 is only provided for compatility for old
41 programs that use int as signal mask type. */
42 #undef sigmask
43 #ifdef __GNUC__
44 #define sigmask(SIG) \
45 ({ \
46 sigset_t _mask; \
47 sigemptyset (&_mask); \
48 sigaddset (&_mask, SIG); \
49 _mask; \
50 })
51 #else /* ! defined (__GNUC__) */
52 extern sigset_t sys_sigmask ();
53 #define sigmask(SIG) (sys_sigmask (SIG))
54 #endif /* ! defined (__GNUC__) */
55
56 #undef sigpause
57 #define sigpause(MASK) sigsuspend (&(MASK))
58
59 #define sigblock(SIG) sys_sigblock (SIG)
60 #define sigunblock(SIG) sys_sigunblock (SIG)
61 #ifndef sigsetmask
62 #define sigsetmask(SIG) sys_sigsetmask (SIG)
63 #endif
64 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
65 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
66 #undef signal
67 #define signal(SIG,ACT) sys_signal(SIG,ACT)
68
69 /* Whether this is what all systems want or not, this is what
70 appears to be assumed in the source, for example data.c:arith_error. */
71 typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
72
73 signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action));
74 sigset_t sys_sigblock P_ ((sigset_t new_mask));
75 sigset_t sys_sigunblock P_ ((sigset_t new_mask));
76 sigset_t sys_sigsetmask P_ ((sigset_t new_mask));
77
78 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
79
80 #else /* ! defined (POSIX_SIGNALS) */
81 #ifdef USG5_4
82
83 extern SIGMASKTYPE sigprocmask_set;
84
85 #ifndef sigblock
86 #define sigblock(sig) \
87 (sigprocmask_set = SIGEMPTYMASK | (sig), \
88 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
89 #endif
90
91 #ifndef sigunblock
92 #define sigunblock(sig) \
93 (sigprocmask_set = SIGFULLMASK & ~(sig), \
94 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
95 #endif
96
97 #else
98 #ifdef USG
99
100 #ifndef sigunblock
101 #define sigunblock(sig)
102 #endif
103
104 #else
105
106 #ifndef sigunblock
107 #define sigunblock(SIG) \
108 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
109 #endif
110
111 #endif /* ! defined (USG) */
112 #endif /* ! defined (USG5_4) */
113 #endif /* ! defined (POSIX_SIGNALS) */
114
115 #ifndef SIGMASKTYPE
116 #define SIGMASKTYPE int
117 #endif
118
119 #ifndef SIGEMPTYMASK
120 #define SIGEMPTYMASK (0)
121 #endif
122
123 #ifndef SIGFULLMASK
124 #define SIGFULLMASK (0xffffffff)
125 #endif
126
127 #ifndef sigmask
128 #define sigmask(no) (1L << ((no) - 1))
129 #endif
130
131 #ifndef sigunblock
132 #define sigunblock(SIG) \
133 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
134 #endif
135
136 #ifndef BSD4_1
137 #define sigfree() sigsetmask (SIGEMPTYMASK)
138 #endif /* not BSD4_1 */
139
140 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
141 #undef SIGINFO
142 #endif
143 #if defined (SIGIO) && defined (BROKEN_SIGIO)
144 #undef SIGIO
145 #endif
146 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
147 #undef SIGPOLL
148 #endif
149 #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP)
150 #undef SIGTSTP
151 #endif
152 #if defined (SIGURG) && defined (BROKEN_SIGURG)
153 #undef SIGURG
154 #endif
155 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
156 #undef SIGAIO
157 #endif
158 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
159 #undef SIGPTY
160 #endif
161
162
163 #if NSIG < NSIG_MINIMUM
164 # ifdef NSIG
165 # undef NSIG
166 # endif
167 # define NSIG NSIG_MINIMUM
168 #endif
169
170 #ifdef BSD4_1
171 #define SIGIO SIGTINT
172 /* sigfree is in sysdep.c */
173 #endif /* BSD4_1 */
174
175 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
176 Must do that using the killpg call. */
177 #ifdef BSD_SYSTEM
178 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
179 #else
180 #ifdef WINDOWSNT
181 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
182 #else
183 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
184 #endif
185 #endif
186
187 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
188 testing SIGCHLD. */
189 #ifndef VMS
190 #ifdef SIGCLD
191 #ifndef SIGCHLD
192 #define SIGCHLD SIGCLD
193 #endif /* SIGCHLD */
194 #endif /* ! defined (SIGCLD) */
195 #endif /* VMS */
196
197 #ifndef HAVE_STRSIGNAL
198 /* strsignal is in sysdep.c */
199 char *strsignal ();
200 #endif
201
202 /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152
203 (do not change this comment) */