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