(pushnew, cl-macroexpand, floatp-safe, plusp, minusp, oddp, evenp, mapcar*,
[emacs.git] / src / syssignal.h
blob04e84df1a3ac68880074ab67506ca2ba28b16df1
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 HAVE_GTK_AND_PTHREAD
24 #include <pthread.h>
25 extern pthread_t main_thread;
26 #endif
28 #ifdef POSIX_SIGNALS
30 /* Don't #include <signal.h>. That header should always be #included
31 before "config.h", because some configuration files (like s/hpux.h)
32 indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file
33 #includes <signal.h>, then that will re-#define SIGIO and confuse
34 things. */
36 #define SIGMASKTYPE sigset_t
38 #define SIGEMPTYMASK (empty_mask)
39 #define SIGFULLMASK (full_mask)
40 extern sigset_t empty_mask, full_mask;
42 /* POSIX pretty much destroys any possibility of writing sigmask as a
43 macro in standard C. We always define our own version because the
44 predefined macro in Glibc 2.1 is only provided for compatility for old
45 programs that use int as signal mask type. */
46 #undef sigmask
47 #ifdef __GNUC__
48 #define sigmask(SIG) \
49 ({ \
50 sigset_t _mask; \
51 sigemptyset (&_mask); \
52 sigaddset (&_mask, SIG); \
53 _mask; \
55 #else /* ! defined (__GNUC__) */
56 extern sigset_t sys_sigmask ();
57 #define sigmask(SIG) (sys_sigmask (SIG))
58 #endif /* ! defined (__GNUC__) */
60 #undef sigpause
61 #define sigpause(MASK) sigsuspend (&(MASK))
63 #define sigblock(SIG) sys_sigblock (SIG)
64 #define sigunblock(SIG) sys_sigunblock (SIG)
65 #ifndef sigsetmask
66 #define sigsetmask(SIG) sys_sigsetmask (SIG)
67 #endif
68 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
69 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
70 #undef signal
71 #define signal(SIG,ACT) sys_signal(SIG,ACT)
73 /* Whether this is what all systems want or not, this is what
74 appears to be assumed in the source, for example data.c:arith_error. */
75 typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
77 signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action));
78 sigset_t sys_sigblock P_ ((sigset_t new_mask));
79 sigset_t sys_sigunblock P_ ((sigset_t new_mask));
80 sigset_t sys_sigsetmask P_ ((sigset_t new_mask));
82 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
84 #else /* ! defined (POSIX_SIGNALS) */
85 #ifdef USG5_4
87 extern SIGMASKTYPE sigprocmask_set;
89 #ifndef sigblock
90 #define sigblock(sig) \
91 (sigprocmask_set = SIGEMPTYMASK | (sig), \
92 sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL))
93 #endif
95 #ifndef sigunblock
96 #define sigunblock(sig) \
97 (sigprocmask_set = SIGFULLMASK & ~(sig), \
98 sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL))
99 #endif
101 #else
102 #ifdef USG
104 #ifndef sigunblock
105 #define sigunblock(sig)
106 #endif
108 #else
110 #ifndef sigunblock
111 #define sigunblock(SIG) \
112 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
113 #endif
115 #endif /* ! defined (USG) */
116 #endif /* ! defined (USG5_4) */
117 #endif /* ! defined (POSIX_SIGNALS) */
119 #ifndef SIGMASKTYPE
120 #define SIGMASKTYPE int
121 #endif
123 #ifndef SIGEMPTYMASK
124 #define SIGEMPTYMASK (0)
125 #endif
127 #ifndef SIGFULLMASK
128 #define SIGFULLMASK (0xffffffff)
129 #endif
131 #ifndef sigmask
132 #define sigmask(no) (1L << ((no) - 1))
133 #endif
135 #ifndef sigunblock
136 #define sigunblock(SIG) \
137 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
138 #endif
140 #ifndef BSD4_1
141 #define sigfree() sigsetmask (SIGEMPTYMASK)
142 #endif /* not BSD4_1 */
144 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
145 #undef SIGINFO
146 #endif
147 #if defined (SIGIO) && defined (BROKEN_SIGIO)
148 #undef SIGIO
149 #endif
150 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
151 #undef SIGPOLL
152 #endif
153 #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP)
154 #undef SIGTSTP
155 #endif
156 #if defined (SIGURG) && defined (BROKEN_SIGURG)
157 #undef SIGURG
158 #endif
159 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
160 #undef SIGAIO
161 #endif
162 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
163 #undef SIGPTY
164 #endif
167 #if NSIG < NSIG_MINIMUM
168 # ifdef NSIG
169 # undef NSIG
170 # endif
171 # define NSIG NSIG_MINIMUM
172 #endif
174 #ifdef BSD4_1
175 #define SIGIO SIGTINT
176 /* sigfree is in sysdep.c */
177 #endif /* BSD4_1 */
179 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
180 Must do that using the killpg call. */
181 #ifdef BSD_SYSTEM
182 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
183 #else
184 #ifdef WINDOWSNT
185 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
186 #else
187 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
188 #endif
189 #endif
191 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
192 testing SIGCHLD. */
193 #ifndef VMS
194 #ifdef SIGCLD
195 #ifndef SIGCHLD
196 #define SIGCHLD SIGCLD
197 #endif /* SIGCHLD */
198 #endif /* ! defined (SIGCLD) */
199 #endif /* VMS */
201 #ifndef HAVE_STRSIGNAL
202 /* strsignal is in sysdep.c */
203 char *strsignal ();
204 #endif
206 #ifdef HAVE_GTK_AND_PTHREAD
207 #define SIGNAL_THREAD_CHECK(signo) \
208 do { \
209 if (pthread_self () != main_thread) \
211 /* POSIX says any thread can receive the signal. On GNU/Linux \
212 that is not true, but for other systems (FreeBSD at least) \
213 it is. So direct the signal to the correct thread and block \
214 it from this thread. */ \
215 sigset_t new_mask; \
217 sigemptyset (&new_mask); \
218 sigaddset (&new_mask, signo); \
219 pthread_sigmask (SIG_BLOCK, &new_mask, 0); \
220 pthread_kill (main_thread, signo); \
221 return; \
223 } while (0)
225 #else /* not HAVE_GTK_AND_PTHREAD */
226 #define SIGNAL_THREAD_CHECK(signo)
227 #endif /* not HAVE_GTK_AND_PTHREAD */
228 /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152
229 (do not change this comment) */