FreeBSD/Linux Kernel Cross Reference
sys/sys/sigtypes.h
1 /* $NetBSD: sigtypes.h,v 1.6 2005/02/26 22:25:34 perry Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1986, 1989, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)signal.h 8.4 (Berkeley) 5/4/95
37 */
38
39 #ifndef _SYS_SIGTYPES_H_
40 #define _SYS_SIGTYPES_H_
41
42 #if defined(_KERNEL_OPT)
43 #include "opt_compat_netbsd32.h"
44 #endif
45
46 /*
47 * This header file defines various signal-related types. We also keep
48 * the macros to manipulate sigset_t here, to encapsulate knowledge of
49 * its internals.
50 */
51
52 #include <sys/featuretest.h>
53 #include <machine/int_types.h>
54 #include <machine/ansi.h>
55
56 #ifdef _BSD_SIZE_T_
57 typedef _BSD_SIZE_T_ size_t;
58 #undef _BSD_SIZE_T_
59 #endif
60
61 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
62 defined(_NETBSD_SOURCE)
63 #if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
64 typedef unsigned int sigset13_t;
65
66 /*
67 * Macro for manipulating signal masks.
68 */
69 #define __sigmask13(n) (1 << ((n) - 1))
70 #define __sigaddset13(s, n) (*(s) |= __sigmask13(n))
71 #define __sigdelset13(s, n) (*(s) &= ~__sigmask13(n))
72 #define __sigismember13(s, n) (*(s) & __sigmask13(n))
73 #define __sigemptyset13(s) (*(s) = 0)
74 #define __sigfillset13(s) (*(s) = ~(sigset13_t)0)
75 #endif /* __LIBC12_SOURCE__ || _KERNEL */
76
77 typedef struct {
78 __uint32_t __bits[4];
79 } sigset_t;
80
81 /*
82 * Macro for manipulating signal masks.
83 */
84 #define __sigmask(n) (1 << (((unsigned int)(n) - 1) & 31))
85 #define __sigword(n) (((unsigned int)(n) - 1) >> 5)
86 #define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n))
87 #define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n))
88 #define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0)
89 #define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \
90 (s)->__bits[1] = 0x00000000, \
91 (s)->__bits[2] = 0x00000000, \
92 (s)->__bits[3] = 0x00000000)
93 #define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \
94 (s1)->__bits[1] == (s2)->__bits[1] && \
95 (s1)->__bits[2] == (s2)->__bits[2] && \
96 (s1)->__bits[3] == (s2)->__bits[3])
97 #define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \
98 (s)->__bits[1] = 0xffffffff, \
99 (s)->__bits[2] = 0xffffffff, \
100 (s)->__bits[3] = 0xffffffff)
101 #define __sigplusset(s, t) \
102 do { \
103 (t)->__bits[0] |= (s)->__bits[0]; \
104 (t)->__bits[1] |= (s)->__bits[1]; \
105 (t)->__bits[2] |= (s)->__bits[2]; \
106 (t)->__bits[3] |= (s)->__bits[3]; \
107 } while (/* CONSTCOND */ 0)
108 #define __sigminusset(s, t) \
109 do { \
110 (t)->__bits[0] &= ~(s)->__bits[0]; \
111 (t)->__bits[1] &= ~(s)->__bits[1]; \
112 (t)->__bits[2] &= ~(s)->__bits[2]; \
113 (t)->__bits[3] &= ~(s)->__bits[3]; \
114 } while (/* CONSTCOND */ 0)
115 #define __sigandset(s, t) \
116 do { \
117 (t)->__bits[0] &= (s)->__bits[0]; \
118 (t)->__bits[1] &= (s)->__bits[1]; \
119 (t)->__bits[2] &= (s)->__bits[2]; \
120 (t)->__bits[3] &= (s)->__bits[3]; \
121 } while (/* CONSTCOND */ 0)
122
123 #if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
124 /* Not strictly a defined type, but is logically associated with stack_t. */
125 struct sigaltstack13 {
126 char *ss_sp; /* signal stack base */
127 int ss_size; /* signal stack length */
128 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
129 };
130 #endif /* defined(__LIBC12_SOURCE__) || defined(_KERNEL) */
131
132 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
133 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
134 typedef struct
135 #if defined(_NETBSD_SOURCE)
136 sigaltstack
137 #endif /* _NETBSD_SOURCE */
138 {
139 void *ss_sp; /* signal stack base */
140 size_t ss_size; /* signal stack length */
141 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
142 } stack_t;
143
144 #endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
145
146 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */
147
148 #if defined(COMPAT_NETBSD32) && defined(_KERNEL)
149
150 struct __sigaltstack32 {
151 uint32_t ss_sp;
152 uint32_t ss_size;
153 int32_t ss_flags;
154 };
155
156 typedef struct __sigaltstack32 stack32_t;
157
158 #endif /* COMPAT_NETBSD32 && _KERNEL */
159
160
161 #endif /* !_SYS_SIGTYPES_H_ */
Cache object: 87efaf799e054bc20f3a6fdf47198b7a
|