1 /* $OpenBSD: siginfo.h,v 1.14 2024/02/21 15:53:07 deraadt Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Theo de Raadt 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef _SYS_SIGINFO_H 29 #define _SYS_SIGINFO_H 30 31 #include <sys/cdefs.h> 32 33 union sigval { 34 int sival_int; /* integer value */ 35 void *sival_ptr; /* pointer value */ 36 }; 37 38 /* 39 * Negative signal codes are reserved for future use for 40 * user generated signals. 41 */ 42 #define SI_FROMUSER(sip) ((sip)->si_code <= 0) 43 #define SI_FROMKERNEL(sip) ((sip)->si_code > 0) 44 45 #define SI_NOINFO 32767 /* no signal information */ 46 #define SI_USER 0 /* user generated signal via kill() */ 47 #define SI_LWP (-1) /* user generated signal via lwp_kill()*/ 48 #define SI_QUEUE (-2) /* user generated signal via sigqueue()*/ 49 #define SI_TIMER (-3) /* from timer expiration */ 50 51 #if __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE 52 /* 53 * The machine dependent signal codes (SIGILL, SIGFPE, 54 * SIGSEGV, and SIGBUS) 55 */ 56 #define ILL_ILLOPC 1 /* illegal opcode */ 57 #define ILL_ILLOPN 2 /* illegal operand */ 58 #define ILL_ILLADR 3 /* illegal addressing mode */ 59 #define ILL_ILLTRP 4 /* illegal trap */ 60 #define ILL_PRVOPC 5 /* privileged opcode */ 61 #define ILL_PRVREG 6 /* privileged register */ 62 #define ILL_COPROC 7 /* co-processor */ 63 #define ILL_BADSTK 8 /* bad stack */ 64 #define ILL_BTCFI 9 /* IBT missing on indirect call */ 65 #define NSIGILL 9 66 67 #define EMT_TAGOVF 1 /* tag overflow */ 68 #define NSIGEMT 1 69 70 #define FPE_INTDIV 1 /* integer divide by zero */ 71 #define FPE_INTOVF 2 /* integer overflow */ 72 #define FPE_FLTDIV 3 /* floating point divide by zero */ 73 #define FPE_FLTOVF 4 /* floating point overflow */ 74 #define FPE_FLTUND 5 /* floating point underflow */ 75 #define FPE_FLTRES 6 /* floating point inexact result */ 76 #define FPE_FLTINV 7 /* invalid floating point operation */ 77 #define FPE_FLTSUB 8 /* subscript out of range */ 78 #define NSIGFPE 8 79 80 #define SEGV_MAPERR 1 /* address not mapped to object */ 81 #define SEGV_ACCERR 2 /* invalid permissions */ 82 #define NSIGSEGV 2 83 84 #define BUS_ADRALN 1 /* invalid address alignment */ 85 #define BUS_ADRERR 2 /* non-existent physical address */ 86 #define BUS_OBJERR 3 /* object specific hardware error */ 87 #define NSIGBUS 3 88 89 #endif /* __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE */ 90 91 /* 92 * SIGTRAP signal codes 93 */ 94 #define TRAP_BRKPT 1 /* breakpoint trap */ 95 #define TRAP_TRACE 2 /* trace trap */ 96 #define NSIGTRAP 2 97 98 /* 99 * SIGCHLD signal codes 100 */ 101 #define CLD_EXITED 1 /* child has exited */ 102 #define CLD_KILLED 2 /* child was killed */ 103 #define CLD_DUMPED 3 /* child has coredumped */ 104 #define CLD_TRAPPED 4 /* traced child has stopped */ 105 #define CLD_STOPPED 5 /* child has stopped on signal */ 106 #define CLD_CONTINUED 6 /* stopped child has continued */ 107 #define NSIGCLD 6 108 109 #if 0 110 /* 111 * SIGPOLL signal codes - not supported 112 */ 113 #define POLL_IN 1 /* input available */ 114 #define POLL_OUT 2 /* output possible */ 115 #define POLL_MSG 3 /* message available */ 116 #define POLL_ERR 4 /* I/O error */ 117 #define POLL_PRI 5 /* high priority input available */ 118 #define POLL_HUP 6 /* device disconnected */ 119 #define NSIGPOLL 6 120 121 /* 122 * SIGPROF signal codes - not supported 123 */ 124 #define PROF_SIG 1 /* have to set code non-zero */ 125 #define NSIGPROF 1 126 #endif 127 128 #define SI_MAXSZ 128 129 #define SI_PAD ((SI_MAXSZ / sizeof (int)) - 3) 130 131 #include <sys/time.h> 132 133 typedef struct { 134 int si_signo; /* signal from signal.h */ 135 int si_code; /* code from above */ 136 int si_errno; /* error from errno.h */ 137 union { 138 int _pad[SI_PAD]; /* for future growth */ 139 struct { /* kill(), SIGCHLD */ 140 pid_t _pid; /* process ID */ 141 uid_t _uid; 142 union { 143 struct { 144 union sigval _value; 145 } _kill; 146 struct { 147 clock_t _utime; 148 clock_t _stime; 149 int _status; 150 } _cld; 151 } _pdata; 152 } _proc; 153 struct { /* SIGSEGV, SIGBUS, SIGILL and SIGFPE */ 154 void *_addr; /* faulting address */ 155 int _trapno; /* illegal trap number */ 156 } _fault; 157 #if 0 158 struct { /* SIGPOLL, SIGXFSZ */ 159 /* fd not currently available for SIGPOLL */ 160 int _fd; /* file descriptor */ 161 long _band; 162 } _file; 163 struct { /* SIGPROF */ 164 caddr_t _faddr; /* last fault address */ 165 timespec _tstamp; /* real time stamp */ 166 short _syscall; /* current syscall */ 167 char _nsysarg; /* number of arguments */ 168 char _fault; /* last fault type */ 169 long _sysarg[8]; /* syscall arguments */ 170 long _mstate[17]; /* exactly fills struct*/ 171 } _prof; 172 #endif 173 } _data; 174 } siginfo_t; 175 176 #define si_pid _data._proc._pid 177 #define si_uid _data._proc._uid 178 179 #define si_status _data._proc._pdata._cld._status 180 #define si_stime _data._proc._pdata._cld._stime 181 #define si_utime _data._proc._pdata._cld._utime 182 #define si_value _data._proc._pdata._kill._value 183 #define si_addr _data._fault._addr 184 #define si_trapno _data._fault._trapno 185 #define si_fd _data._file._fd 186 #define si_band _data._file._band 187 188 #define si_tstamp _data._prof._tstamp 189 #define si_syscall _data._prof._syscall 190 #define si_nsysarg _data._prof._nsysarg 191 #define si_sysarg _data._prof._sysarg 192 #define si_fault _data._prof._fault 193 #define si_faddr _data._prof._faddr 194 #define si_mstate _data._prof._mstate 195 196 #if defined(_KERNEL) 197 void initsiginfo(siginfo_t *, int, u_long, int, union sigval); 198 #endif 199 200 #endif /* _SYS_SIGINFO_H */ 201