]> code.delx.au - gnu-emacs/blob - src/syssignal.h
*** empty log message ***
[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
21 #ifdef POSIX_SIGNALS
22 #define SIGMASKTYPE sigset_t
23
24 #define SIGEMPTYMASK (empty_mask)
25 #define SIGFULLMASK (full_mask)
26 extern sigset_t empty_mask, full_mask, temp_mask;
27
28 #define sigmask(SIG) \
29 (sigemptyset (&temp_mask), sigaddset (&temp_mask, SIG), temp_mask)
30
31 /* The below routines may need a local mask. There could be problems
32 if code using any of the 3 macros below could be reentered due to a
33 signal occurring. This can't happen in Emacs 18.57, so we don't
34 worry. - DJB */
35
36 #define EMACS_SIGPAUSE(sigset) \
37 do { sigset_t _mask; sys_sigpause (sigset); } while (0)
38 #define EMACS_SIGBLOCK(new_sig, old_sig) \
39 do { sigset_t _mask; (old_sig) = sys_sigblock (new_sig); } while (0)
40 #define EMACS_SIGUNBLOCK(new_sig, old_sig) \
41 do { sigset_t _mask; (old_sig) = sys_sigunblock (new_sig); } while (0)
42 #define EMACS_SIGSETMASK(new_sig, old_sig) \
43 do { sigset_t _mask; (old_sig) = sys_sigsetmask (new_sig); } while (0)
44 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
45 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
46
47 int (*sys_signal (int signal_number, int (*action)())) ();
48 int sys_sigpause (int signal_number);
49 sigset_t sys_sigblock (sigset_t new_mask);
50 sigset_t sys_sigunblock (sigset_t new_mask);
51 sigset_t sys_sigsetmask (sigset_t new_mask);
52
53 #define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG)
54
55 #else /* ! defined (POSIX_SIGNALS) */
56
57 #define sigunblock(SIG) \
58 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
59
60 #endif /* ! defined (POSIX_SIGNALS) */
61
62 #ifndef SIGMASKTYPE
63 #define SIGMASKTYPE int
64 #endif
65
66 #ifndef SIGEMPTYMASK
67 #define SIGEMPTYMASK 0
68 #endif
69
70 #ifndef sigmask
71 #define sigmask(no) (1L << ((no) - 1))
72 #endif
73
74 #ifdef BSD4_1
75 #define SIGIO SIGTINT
76 /* sigfree and sigholdx are in sysdep.c */
77 #define EMACS_SIGFREE () sigfree ()
78
79 /* We define the following macros to expand into statements rather
80 than expressions, because the POSIX macros above do the same, and
81 we don't want people on BSD4_1 systems accidentally using the
82 macros in a way that will break the other systems. */
83 #define EMACS_SIGHOLDX(new_sig, old_sig) \
84 do { (old_sig) = sigholdx (new_sig); } while (0)
85 #define EMACS_SIGBLOCKX(new_sig, old_sig) \
86 do { (old_sig) = sighold (new_sig); } while (0)
87 #define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
88 do { (old_sig) = sigrelse (new_sig); } while (0)
89 #define EMACS_SIGPAUSEX(sig) \
90 EMACS_SIGPAUSE (new_sig);
91
92 #else /* ! defined (BSD4_1) */
93
94 #define EMACS_SIGFREE() \
95 do { SIGMASKTYPE _dummy; EMACS_SIGSETMASK (SIGEMPTYMASK, _dummy); } while (0)
96 #define EMACS_SIGHOLDX(new_sig, old_sig) \
97 EMACS_SIGSETMASK (sigmask (new_sig), old_sig)
98 #define EMACS_SIGBLOCKX(new_sig, old_sig) \
99 EMACS_SIGBLOCK (sigmask (new_sig), old_sig)
100 #define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
101 EMACS_SIGUNBLOCK (sigmask (new_sig), old_sig)
102 #define EMACS_SIGPAUSEX(sig) \
103 EMACS_SIGPAUSE (0)
104
105 #endif /* ! defined (BSD4_1) */
106
107 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
108 Must do that using the killpg call. */
109 #ifdef BSD
110 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
111 #else
112 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
113 #endif
114
115 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
116 testing SIGCHLD. */
117
118 #ifndef VMS
119 #ifdef SIGCLD
120 #ifndef SIGCHLD
121 #define SIGCHLD SIGCLD
122 #endif /* SIGCHLD */
123 #endif /* ! defined (SIGCLD) */
124 #endif /* VMS */