1 /* $NetBSD: sigtypes.h,v 1.8 2005/12/11 12:25:21 christos 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 _EFI_SIZE_T_ 53 typedef _EFI_SIZE_T_ size_t; 54 #undef _EFI_SIZE_T_ 55 #undef _BSD_SIZE_T_ 56 #endif 57 58 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 59 defined(_NETBSD_SOURCE) 60 61 typedef struct { 62 __uint32_t __bits[4]; 63 } sigset_t; 64 65 /* 66 * Macro for manipulating signal masks. 67 */ 68 #define __sigmask(n) (1 << (((unsigned int)(n) - 1) & 31)) 69 #define __sigword(n) (((unsigned int)(n) - 1) >> 5) 70 #define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n)) 71 #define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n)) 72 #define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0) 73 #define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \ 74 (s)->__bits[1] = 0x00000000, \ 75 (s)->__bits[2] = 0x00000000, \ 76 (s)->__bits[3] = 0x00000000) 77 #define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \ 78 (s1)->__bits[1] == (s2)->__bits[1] && \ 79 (s1)->__bits[2] == (s2)->__bits[2] && \ 80 (s1)->__bits[3] == (s2)->__bits[3]) 81 #define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \ 82 (s)->__bits[1] = 0xffffffff, \ 83 (s)->__bits[2] = 0xffffffff, \ 84 (s)->__bits[3] = 0xffffffff) 85 #define __sigplusset(s, t) \ 86 do { \ 87 (t)->__bits[0] |= (s)->__bits[0]; \ 88 (t)->__bits[1] |= (s)->__bits[1]; \ 89 (t)->__bits[2] |= (s)->__bits[2]; \ 90 (t)->__bits[3] |= (s)->__bits[3]; \ 91 } while (/* CONSTCOND */ 0) 92 #define __sigminusset(s, t) \ 93 do { \ 94 (t)->__bits[0] &= ~(s)->__bits[0]; \ 95 (t)->__bits[1] &= ~(s)->__bits[1]; \ 96 (t)->__bits[2] &= ~(s)->__bits[2]; \ 97 (t)->__bits[3] &= ~(s)->__bits[3]; \ 98 } while (/* CONSTCOND */ 0) 99 #define __sigandset(s, t) \ 100 do { \ 101 (t)->__bits[0] &= (s)->__bits[0]; \ 102 (t)->__bits[1] &= (s)->__bits[1]; \ 103 (t)->__bits[2] &= (s)->__bits[2]; \ 104 (t)->__bits[3] &= (s)->__bits[3]; \ 105 } while (/* CONSTCOND */ 0) 106 107 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ 108 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 109 typedef struct 110 #if defined(_NETBSD_SOURCE) 111 sigaltstack 112 #endif /* _NETBSD_SOURCE */ 113 { 114 void *ss_sp; /* signal stack base */ 115 size_t ss_size; /* signal stack length */ 116 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ 117 } stack_t; 118 119 #endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ 120 121 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */ 122 123 #endif /* !_SYS_SIGTYPES_H_ */ 124