]> code.delx.au - gnu-emacs/blob - src/syssignal.h
Pay attention to BROKEN_SIGAIO and BROKEN_SIGPTY.
[gnu-emacs] / 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 #ifdef POSIX_SIGNALS
22
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
27 things. */
28
29 #define SIGMASKTYPE sigset_t
30
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));
35
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. */
40 #undef sigmask
41 #ifdef __GNUC__
42 #define sigmask(SIG) \
43 ({ \
44 sigset_t _mask; \
45 sigemptyset (&_mask); \
46 sigaddset (&_mask, SIG); \
47 _mask; \
48 })
49 #else /* ! defined (__GNUC__) */
50 extern sigset_t sys_sigmask ();
51 #define sigmask(SIG) (sys_sigmask (SIG))
52 #endif /* ! defined (__GNUC__) */
53
54 #undef sigpause
55 #define sigpause(MASK) sigsuspend (&(MASK))
56
57 #define sigblock(SIG) sys_sigblock (SIG)
58 #define sigunblock(SIG) sys_sigunblock (SIG)
59 #ifndef sigsetmask
60 #define sigsetmask(SIG) sys_sigsetmask (SIG)
61 #endif
62 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
63 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
64 #undef signal
65 #define signal(SIG,ACT) sys_signal(SIG,ACT)
66
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*/);
70
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));
75
76 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
77
78 #else /* ! defined (POSIX_SIGNALS) */
79 #ifdef USG5_4
80
81 extern SIGMASKTYPE sigprocmask_set;
82
83 #ifndef sigblock
84 #define sigblock(sig) \
85 (sigprocmask_set = SIGEMPTYMASK | (sig), \
86 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
87 #endif
88
89 #define sigunblock(sig) \
90 (sigprocmask_set = SIGFULLMASK & ~(sig), \
91 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
92
93 #else
94 #ifdef USG
95
96 #define sigunblock(sig)
97
98 #else
99
100 #define sigunblock(SIG) \
101 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
102
103 #endif /* ! defined (USG) */
104 #endif /* ! defined (USG5_4) */
105 #endif /* ! defined (POSIX_SIGNALS) */
106
107 #ifndef SIGMASKTYPE
108 #define SIGMASKTYPE int
109 #endif
110
111 #ifndef SIGEMPTYMASK
112 #define SIGEMPTYMASK (0)
113 #endif
114
115 #ifndef SIGFULLMASK
116 #define SIGFULLMASK (0xffffffff)
117 #endif
118
119 #ifndef sigmask
120 #define sigmask(no) (1L << ((no) - 1))
121 #endif
122
123 #ifndef sigunblock
124 #define sigunblock(SIG) \
125 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
126 #endif
127
128 #ifndef BSD4_1
129 #define sigfree() sigsetmask (SIGEMPTYMASK)
130 #endif /* not BSD4_1 */
131
132 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
133 #undef SIGINFO
134 #endif
135 #if defined (SIGIO) && defined (BROKEN_SIGIO)
136 #undef SIGIO
137 #endif
138 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
139 #undef SIGPOLL
140 #endif
141 #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP)
142 #undef SIGTSTP
143 #endif
144 #if defined (SIGURG) && defined (BROKEN_SIGURG)
145 #undef SIGURG
146 #endif
147 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
148 #undef SIGAIO
149 #endif
150 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
151 #undef SIGPTY
152 #endif
153
154
155 #if NSIG < NSIG_MINIMUM
156 # ifdef NSIG
157 # undef NSIG
158 # endif
159 # define NSIG NSIG_MINIMUM
160 #endif
161
162 #ifdef BSD4_1
163 #define SIGIO SIGTINT
164 /* sigfree is in sysdep.c */
165 #endif /* BSD4_1 */
166
167 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
168 Must do that using the killpg call. */
169 #ifdef BSD_SYSTEM
170 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
171 #else
172 #ifdef WINDOWSNT
173 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
174 #else
175 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
176 #endif
177 #endif
178
179 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
180 testing SIGCHLD. */
181 #ifndef VMS
182 #ifdef SIGCLD
183 #ifndef SIGCHLD
184 #define SIGCHLD SIGCLD
185 #endif /* SIGCHLD */
186 #endif /* ! defined (SIGCLD) */
187 #endif /* VMS */
188
189 #ifndef HAVE_STRSIGNAL
190 /* strsignal is in sysdep.c */
191 char *strsignal ();
192 #endif