Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-483
[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
31 #define SIGMASKTYPE sigset_t
32
33 #define SIGEMPTYMASK (empty_mask)
34 #define SIGFULLMASK (full_mask)
35 extern sigset_t empty_mask, full_mask;
36
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; \
49 })
50 #else /* ! defined (__GNUC__) */
51 extern sigset_t sys_sigmask ();
52 #define sigmask(SIG) (sys_sigmask (SIG))
53 #endif /* ! defined (__GNUC__) */
54
55 #undef sigpause
56 #define sigpause(MASK) sigsuspend (&(MASK))
57
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)
67
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*/);
71
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));
76
77 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
78
79 #else /* ! defined (POSIX_SIGNALS) */
80 #ifdef USG5_4
81
82 extern SIGMASKTYPE sigprocmask_set;
83
84 #ifndef sigblock
85 #define sigblock(sig) \
86 (sigprocmask_set = SIGEMPTYMASK | (sig), \
87 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
88 #endif
89
90 #ifndef sigunblock
91 #define sigunblock(sig) \
92 (sigprocmask_set = SIGFULLMASK & ~(sig), \
93 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
94 #endif
95
96 #else
97 #ifdef USG
98
99 #ifndef sigunblock
100 #define sigunblock(sig)
101 #endif
102
103 #else
104
105 #ifndef sigunblock
106 #define sigunblock(SIG) \
107 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
108 #endif
109
110 #endif /* ! defined (USG) */
111 #endif /* ! defined (USG5_4) */
112 #endif /* ! defined (POSIX_SIGNALS) */
113
114 #ifndef SIGMASKTYPE
115 #define SIGMASKTYPE int
116 #endif
117
118 #ifndef SIGEMPTYMASK
119 #define SIGEMPTYMASK (0)
120 #endif
121
122 #ifndef SIGFULLMASK
123 #define SIGFULLMASK (0xffffffff)
124 #endif
125
126 #ifndef sigmask
127 #define sigmask(no) (1L << ((no) - 1))
128 #endif
129
130 #ifndef sigunblock
131 #define sigunblock(SIG) \
132 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
133 #endif
134
135 #ifndef BSD4_1
136 #define sigfree() sigsetmask (SIGEMPTYMASK)
137 #endif /* not BSD4_1 */
138
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
160
161
162 #if NSIG < NSIG_MINIMUM
163 # ifdef NSIG
164 # undef NSIG
165 # endif
166 # define NSIG NSIG_MINIMUM
167 #endif
168
169 #ifdef BSD4_1
170 #define SIGIO SIGTINT
171 /* sigfree is in sysdep.c */
172 #endif /* BSD4_1 */
173
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
185
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 */
195
196 #ifndef HAVE_STRSIGNAL
197 /* strsignal is in sysdep.c */
198 char *strsignal ();
199 #endif
200
201 /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152
202 (do not change this comment) */