Updated copyright years.
[bpt/emacs.git] / src / syssignal.h
1 /* syssignal.h - System-dependent definitions for signals.
2 Copyright (C) 1993 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #ifdef POSIX_SIGNALS
21
22 #include <signal.h>
23
24 #define SIGMASKTYPE sigset_t
25
26 #define SIGEMPTYMASK (empty_mask)
27 #define SIGFULLMASK (full_mask)
28 extern sigset_t empty_mask, full_mask, temp_mask;
29
30 /* POSIX pretty much destroys any possibility of writing sigmask as a
31 macro in standard C. */
32 #ifndef sigmask
33 #ifdef __GNUC__
34 #define sigmask(SIG) \
35 ({ \
36 sigset_t _mask; \
37 sigemptyset (&_mask); \
38 sigaddset (&_mask, SIG); \
39 _mask; \
40 })
41 #else /* ! defined (__GNUC__) */
42 #define sigmask(SIG) (sys_sigmask (SIG))
43 #endif /* ! defined (__GNUC__) */
44 #endif
45
46 #define sigpause(SIG) sys_sigpause(SIG)
47 #define sigblock(SIG) sys_sigblock(SIG)
48 #define sigunblock(SIG) sys_sigunblock(SIG)
49 #define sigsetmask(SIG) sys_sigsetmask(SIG)
50 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
51 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
52
53 /* Whether this is what all systems want or not, this is what
54 appears to be assumed in the source, for example data.c:arith_error() */
55 typedef RETSIGTYPE (*signal_handler_t) (int);
56
57 signal_handler_t sys_signal (int signal_number, int (*action)());
58 int sys_sigpause (sigset_t new_mask);
59 sigset_t sys_sigblock (sigset_t new_mask);
60 sigset_t sys_sigunblock (sigset_t new_mask);
61 sigset_t sys_sigsetmask (sigset_t new_mask);
62
63 #define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG)
64
65 #else /* ! defined (POSIX_SIGNALS) */
66 #ifdef USG5_4
67
68 #define sigunblock(sig) (sigprocmask(SIG_SETMASK, SIGFULLMASK & ~(sig), NULL))
69
70 #else
71 #ifdef USG
72
73 #define sigunblock(sig)
74
75 #else
76
77 #define sigunblock(SIG) \
78 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
79
80 #endif /* ! defined (USG) */
81 #endif /* ! defined (USG5_4) */
82 #endif /* ! defined (POSIX_SIGNALS) */
83
84 #ifndef SIGMASKTYPE
85 #define SIGMASKTYPE int
86 #endif
87
88 #ifndef SIGEMPTYMASK
89 #define SIGEMPTYMASK (0)
90 #endif
91
92 #ifndef SIGFULLMASK
93 #define SIGFULLMASK (0xffffffff)
94 #endif
95
96 #ifndef sigmask
97 #define sigmask(no) (1L << ((no) - 1))
98 #endif
99
100 #ifndef sigunblock
101 #define sigunblock(SIG) \
102 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
103 #endif
104
105 /* It would be very nice if we could somehow clean up all this trash. */
106
107 #ifndef BSD4_1
108 #define sigfree() sigsetmask (SIGEMPTYMASK)
109 #define sigholdx(sig) sigsetmask (sigmask (sig))
110 #define sigblockx(sig) sigblock (sigmask (sig))
111 #define sigunblockx(sig) sigblock (SIGEMPTYMASK)
112 #define sigpausex(sig) sigpause (0)
113 #endif /* BSD4_1 */
114
115 #ifdef BSD4_1
116 #define SIGIO SIGTINT
117 /* sigfree and sigholdx are in sysdep.c */
118 #define sigblockx(sig) sighold (sig)
119 #define sigunblockx(sig) sigrelse (sig)
120 #define sigpausex(sig) sigpause (sig)
121 #endif /* ! defined (BSD4_1) */
122
123 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
124 Must do that using the killpg call. */
125 #ifdef BSD
126 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
127 #else
128 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
129 #endif
130
131 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
132 testing SIGCHLD. */
133 #ifndef VMS
134 #ifdef SIGCLD
135 #ifndef SIGCHLD
136 #define SIGCHLD SIGCLD
137 #endif /* SIGCHLD */
138 #endif /* ! defined (SIGCLD) */
139 #endif /* VMS */