Initial revision
[bpt/emacs.git] / src / syssignal.h
CommitLineData
9ab9afa9
JB
1/* syssignal.h - System-dependent definitions for signals.
2 Copyright (C) 1992 Free Software Foundation, Inc.
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
8the Free Software Foundation; either version 1, or (at your option)
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
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#ifdef POSIX_SIGNALS
21#define SIGMASKTYPE sigset_t
22
23#define SIGEMPTYMASK (empty_mask)
24#define SIGFULLMASK (full_mask)
25extern sigset_t empty_mask, full_mask, temp_mask;
26
27#define sigmask(SIG) \
28(sigemptyset (&temp_mask), sigaddset (&temp_mask, SIG), temp_mask)
29
30/* May need a local mask. There could be problems if code using any
31 of the 3 macros below could be reentered due to a signal occurring.
32 This can't happen in Emacs 18.57, so we don't worry. - DJB
33 These macros also require GCC. */
34#define sigpause(SIG) ({ sigset_t _mask; sys_sigpause(SIG); })
35#define sigblock(SIG) ({ sigset_t _mask; sys_sigblock(SIG); })
36#define sigunblock(SIG) ({ sigset_t _mask; sys_sigunblock(SIG); })
37#define sigsetmask(SIG) ({ sigset_t _mask; sys_sigsetmask(SIG); })
38#define sighold(SIG) ONLY_USED_IN_BSD_4_1
39#define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
40
41int (*sys_signal (int signal_number, int (*action)())) ();
42int sys_sigpause (int signal_number);
43sigset_t sys_sigblock (sigset_t new_mask);
44sigset_t sys_sigunblock (sigset_t new_mask);
45sigset_t sys_sigsetmask (sigset_t new_mask);
46
47#define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG)
48
49#else /* not POSIX_SIGNALS */
50
51#define sigunblock(SIG) \
52{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
53
54#endif /* not POSIX_SIGNALS */
55
56#ifndef SIGMASKTYPE
57#define SIGMASKTYPE int
58#endif
59
60#ifndef SIGEMPTYMASK
61#define SIGEMPTYMASK 0
62#endif
63
64#ifndef sigmask
65#define sigmask(no) (1L << ((no) - 1))
66#endif
67
68#ifndef BSD4_1
69#define sigfree() sigsetmask (SIGEMPTYMASK)
70#define sigholdx(sig) sigsetmask (sigmask (sig))
71#define sigblockx(sig) sigblock (sigmask (sig))
72#define sigunblockx(sig) sigblock (SIGEMPTYMASK)
73#define sigpausex(sig) sigpause (0)
74#endif /* not BSD4_1 */
75
76#ifdef BSD4_1
77#define SIGIO SIGTINT
78/* sigfree and sigholdx are in sysdep.c */
79#define sigblockx(sig) sighold (sig)
80#define sigunblockx(sig) sigrelse (sig)
81#define sigpausex(sig) sigpause (sig)
82#endif /* BSD4_1 */
83
84/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
85 Must do that using the killpg call. */
86#ifdef BSD
87#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
88#else
89#define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
90#endif
91
92/* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
93 testing SIGCHLD. */
94
95#ifndef VMS
96#ifdef SIGCLD
97#ifndef SIGCHLD
98#define SIGCHLD SIGCLD
99#endif /* not SIGCHLD */
100#endif /* SIGCLD */
101#endif /* not VMS */