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