(Coding Conventions): Node renamed from Style Tips.
[bpt/emacs.git] / src / syssignal.h
CommitLineData
9ab9afa9 1/* syssignal.h - System-dependent definitions for signals.
c6c5df7f 2 Copyright (C) 1993 Free Software Foundation, Inc.
9ab9afa9
JB
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
7c938215 8the Free Software Foundation; either version 2, or (at your option)
9ab9afa9
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
3b7ad313
EN
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
9ab9afa9
JB
20
21#ifdef POSIX_SIGNALS
00eaaa32 22
c3aa5fec 23/* Don't #include <signal.h>. That header should always be #included
cf026b25
JB
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. */
00eaaa32 28
9ab9afa9
JB
29#define SIGMASKTYPE sigset_t
30
31#define SIGEMPTYMASK (empty_mask)
32#define SIGFULLMASK (full_mask)
33extern sigset_t empty_mask, full_mask, temp_mask;
34
1b1f8f85
JB
35/* POSIX pretty much destroys any possibility of writing sigmask as a
36 macro in standard C. */
00eaaa32 37#ifndef sigmask
1b1f8f85
JB
38#ifdef __GNUC__
39#define sigmask(SIG) \
40 ({ \
41 sigset_t _mask; \
42 sigemptyset (&_mask); \
43 sigaddset (&_mask, SIG); \
44 _mask; \
45 })
985a35a3 46#else /* ! defined (__GNUC__) */
9bd67a37 47extern sigset_t sys_sigmask ();
1b1f8f85 48#define sigmask(SIG) (sys_sigmask (SIG))
985a35a3 49#endif /* ! defined (__GNUC__) */
00eaaa32 50#endif
1b1f8f85 51
69037d5a
RS
52#define sigpause(SIG) sys_sigpause (SIG)
53#define sigblock(SIG) sys_sigblock (SIG)
54#define sigunblock(SIG) sys_sigunblock (SIG)
cc210d67 55#ifndef sigsetmask
69037d5a 56#define sigsetmask(SIG) sys_sigsetmask (SIG)
cc210d67 57#endif
9ab9afa9
JB
58#define sighold(SIG) ONLY_USED_IN_BSD_4_1
59#define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
6c8a1e24 60#undef signal
9c063f29 61#define signal(SIG,ACT) sys_signal(SIG,ACT)
9ab9afa9 62
00eaaa32 63/* Whether this is what all systems want or not, this is what
69037d5a 64 appears to be assumed in the source, for example data.c:arith_error. */
667da7f5 65typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
00eaaa32 66
667da7f5
KH
67signal_handler_t sys_signal (/*int signal_number, signal_handler_t action*/);
68int sys_sigpause (/*sigset_t new_mask*/);
69sigset_t sys_sigblock (/*sigset_t new_mask*/);
70sigset_t sys_sigunblock (/*sigset_t new_mask*/);
71sigset_t sys_sigsetmask (/*sigset_t new_mask*/);
9ab9afa9 72
69037d5a 73#define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
9ab9afa9 74
985a35a3
JB
75#else /* ! defined (POSIX_SIGNALS) */
76#ifdef USG5_4
77
69037d5a 78#ifndef sigblock
d8b3c190 79#define sigblock(sig) (sigprocmask (SIG_BLOCK, SIGEMPTYMASK | sig, NULL))
69037d5a
RS
80#endif
81
82#define sigunblock(sig) (sigprocmask (SIG_SETMASK, SIGFULLMASK & ~(sig), NULL))
985a35a3
JB
83
84#else
85#ifdef USG
86
87#define sigunblock(sig)
88
89#else
9ab9afa9
JB
90
91#define sigunblock(SIG) \
92{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
93
985a35a3
JB
94#endif /* ! defined (USG) */
95#endif /* ! defined (USG5_4) */
96#endif /* ! defined (POSIX_SIGNALS) */
9ab9afa9
JB
97
98#ifndef SIGMASKTYPE
99#define SIGMASKTYPE int
100#endif
101
102#ifndef SIGEMPTYMASK
1b1f8f85
JB
103#define SIGEMPTYMASK (0)
104#endif
105
106#ifndef SIGFULLMASK
107#define SIGFULLMASK (0xffffffff)
9ab9afa9
JB
108#endif
109
110#ifndef sigmask
111#define sigmask(no) (1L << ((no) - 1))
112#endif
113
1b1f8f85
JB
114#ifndef sigunblock
115#define sigunblock(SIG) \
116{ SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
117#endif
118
1b1f8f85
JB
119#ifndef BSD4_1
120#define sigfree() sigsetmask (SIGEMPTYMASK)
ea973b10 121#endif /* not BSD4_1 */
1b1f8f85 122
9ab9afa9
JB
123#ifdef BSD4_1
124#define SIGIO SIGTINT
645280b7 125/* sigfree is in sysdep.c */
ea973b10 126#endif /* BSD4_1 */
9ab9afa9
JB
127
128/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
129 Must do that using the killpg call. */
6df54671 130#ifdef BSD_SYSTEM
9ab9afa9
JB
131#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
132#else
57d65592 133#ifdef WINDOWSNT
f405affb 134#define EMACS_KILLPG(gid, signo) (kill (gid, signo))
57d65592 135#else
9ab9afa9
JB
136#define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
137#endif
57d65592 138#endif
9ab9afa9
JB
139
140/* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
141 testing SIGCHLD. */
9ab9afa9
JB
142#ifndef VMS
143#ifdef SIGCLD
144#ifndef SIGCHLD
145#define SIGCHLD SIGCLD
985a35a3
JB
146#endif /* SIGCHLD */
147#endif /* ! defined (SIGCLD) */
148#endif /* VMS */