1 /* $NetBSD: sigtypes.h,v 1.10 2012/02/19 21:07:00 rmind 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 /* 43 * This header file defines various signal-related types. We also keep 44 * the macros to manipulate sigset_t here, to encapsulate knowledge of 45 * its internals. 46 */ 47 48 #include <sys/featuretest.h> 49 #include <machine/int_types.h> 50 #include <machine/ansi.h> 51 52 #ifdef _BSD_SIZE_T_ 53 typedef _BSD_SIZE_T_ size_t; 54 #undef _BSD_SIZE_T_ 55 #endif 56 57 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 58 defined(_NETBSD_SOURCE) 59 60 typedef struct { 61 __uint32_t __bits[4]; 62 } sigset_t; 63 64 /* 65 * Macro for manipulating signal masks. 66 */ 67 #define __sigmask(n) (1 << (((unsigned int)(n) - 1) & 31)) 68 #define __sigword(n) (((unsigned int)(n) - 1) >> 5) 69 #define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n)) 70 #define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n)) 71 #define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0) 72 #define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \ 73 (s)->__bits[1] = 0x00000000, \ 74 (s)->__bits[2] = 0x00000000, \ 75 (s)->__bits[3] = 0x00000000) 76 #define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \ 77 (s1)->__bits[1] == (s2)->__bits[1] && \ 78 (s1)->__bits[2] == (s2)->__bits[2] && \ 79 (s1)->__bits[3] == (s2)->__bits[3]) 80 #define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \ 81 (s)->__bits[1] = 0xffffffff, \ 82 (s)->__bits[2] = 0xffffffff, \ 83 (s)->__bits[3] = 0xffffffff) 84 #define __sigplusset(s, t) \ 85 do { \ 86 (t)->__bits[0] |= (s)->__bits[0]; \ 87 (t)->__bits[1] |= (s)->__bits[1]; \ 88 (t)->__bits[2] |= (s)->__bits[2]; \ 89 (t)->__bits[3] |= (s)->__bits[3]; \ 90 } while (/* CONSTCOND */ 0) 91 #define __sigminusset(s, t) \ 92 do { \ 93 (t)->__bits[0] &= ~(s)->__bits[0]; \ 94 (t)->__bits[1] &= ~(s)->__bits[1]; \ 95 (t)->__bits[2] &= ~(s)->__bits[2]; \ 96 (t)->__bits[3] &= ~(s)->__bits[3]; \ 97 } while (/* CONSTCOND */ 0) 98 #define __sigandset(s, t) \ 99 do { \ 100 (t)->__bits[0] &= (s)->__bits[0]; \ 101 (t)->__bits[1] &= (s)->__bits[1]; \ 102 (t)->__bits[2] &= (s)->__bits[2]; \ 103 (t)->__bits[3] &= (s)->__bits[3]; \ 104 } while (/* CONSTCOND */ 0) 105 106 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ 107 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 108 typedef struct 109 #if defined(_NETBSD_SOURCE) 110 sigaltstack 111 #endif /* _NETBSD_SOURCE */ 112 { 113 void *ss_sp; /* signal stack base */ 114 size_t ss_size; /* signal stack length */ 115 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ 116 } stack_t; 117 118 #endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ 119 120 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */ 121 122 #endif /* !_SYS_SIGTYPES_H_ */ 123