1/* 2 * BK Id: SCCS/s.siginfo.h 1.5 05/17/01 18:14:25 cort 3 */ 4#ifndef _PPC_SIGINFO_H 5#define _PPC_SIGINFO_H 6 7/* Copied from i386 from alpha. */ 8 9typedef union sigval { 10 int sival_int; 11 void *sival_ptr; 12} sigval_t; 13 14#define SI_MAX_SIZE 128 15#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) 16 17typedef struct siginfo { 18 int si_signo; 19 int si_errno; 20 int si_code; 21 22 union { 23 int _pad[SI_PAD_SIZE]; 24 25 /* kill() */ 26 struct { 27 pid_t _pid; /* sender's pid */ 28 uid_t _uid; /* sender's uid */ 29 } _kill; 30 31 /* POSIX.1b timers */ 32 struct { 33 unsigned int _timer1; 34 unsigned int _timer2; 35 } _timer; 36 37 /* POSIX.1b signals */ 38 struct { 39 pid_t _pid; /* sender's pid */ 40 uid_t _uid; /* sender's uid */ 41 sigval_t _sigval; 42 } _rt; 43 44 /* SIGCHLD */ 45 struct { 46 pid_t _pid; /* which child */ 47 uid_t _uid; /* sender's uid */ 48 int _status; /* exit code */ 49 clock_t _utime; 50 clock_t _stime; 51 } _sigchld; 52 53 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 54 struct { 55 void *_addr; /* faulting insn/memory ref. */ 56 } _sigfault; 57 58 /* SIGPOLL */ 59 struct { 60 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 61 int _fd; 62 } _sigpoll; 63 } _sifields; 64} siginfo_t; 65 66/* 67 * How these fields are to be accessed. 68 */ 69#define si_pid _sifields._kill._pid 70#define si_uid _sifields._kill._uid 71#define si_status _sifields._sigchld._status 72#define si_utime _sifields._sigchld._utime 73#define si_stime _sifields._sigchld._stime 74#define si_value _sifields._rt._sigval 75#define si_int _sifields._rt._sigval.sival_int 76#define si_ptr _sifields._rt._sigval.sival_ptr 77#define si_addr _sifields._sigfault._addr 78#define si_band _sifields._sigpoll._band 79#define si_fd _sifields._sigpoll._fd 80 81#ifdef __KERNEL__ 82#define __SI_MASK 0xffff0000 83#define __SI_KILL (0 << 16) 84#define __SI_TIMER (1 << 16) 85#define __SI_POLL (2 << 16) 86#define __SI_FAULT (3 << 16) 87#define __SI_CHLD (4 << 16) 88#define __SI_RT (5 << 16) 89#define __SI_CODE(T,N) ((T) << 16 | ((N) & 0xffff)) 90#else 91#define __SI_KILL 0 92#define __SI_TIMER 0 93#define __SI_POLL 0 94#define __SI_FAULT 0 95#define __SI_CHLD 0 96#define __SI_RT 0 97#define __SI_CODE(T,N) (N) 98#endif 99 100/* 101 * si_code values 102 * Digital reserves positive values for kernel-generated signals. 103 */ 104#define SI_USER 0 /* sent by kill, sigsend, raise */ 105#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ 106#define SI_QUEUE -1 /* sent by sigqueue */ 107#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ 108#define SI_MESGQ -3 /* sent by real time mesq state change */ 109#define SI_ASYNCIO -4 /* sent by AIO completion */ 110#define SI_SIGIO -5 /* sent by queued SIGIO */ 111#define SI_TKILL -6 /* sent by tkill system call */ 112 113#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) 114#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) 115 116/* 117 * SIGILL si_codes 118 */ 119#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ 120#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ 121#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ 122#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ 123#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ 124#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ 125#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ 126#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ 127#define NSIGILL 8 128 129/* 130 * SIGFPE si_codes 131 */ 132#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ 133#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ 134#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ 135#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ 136#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ 137#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ 138#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ 139#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ 140#define NSIGFPE 8 141 142/* 143 * SIGSEGV si_codes 144 */ 145#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ 146#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ 147#define NSIGSEGV 2 148 149/* 150 * SIGBUS si_codes 151 */ 152#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ 153#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ 154#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ 155#define NSIGBUS 3 156 157/* 158 * SIGTRAP si_codes 159 */ 160#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ 161#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ 162#define NSIGTRAP 2 163 164/* 165 * SIGCHLD si_codes 166 */ 167#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ 168#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ 169#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ 170#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ 171#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ 172#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ 173#define NSIGCHLD 6 174 175/* 176 * SIGPOLL si_codes 177 */ 178#define POLL_IN (__SI_POLL|1) /* data input available */ 179#define POLL_OUT (__SI_POLL|2) /* output buffers available */ 180#define POLL_MSG (__SI_POLL|3) /* input message available */ 181#define POLL_ERR (__SI_POLL|4) /* i/o error */ 182#define POLL_PRI (__SI_POLL|5) /* high priority input available */ 183#define POLL_HUP (__SI_POLL|6) /* device disconnected */ 184#define NSIGPOLL 6 185 186/* 187 * sigevent definitions 188 * 189 * It seems likely that SIGEV_THREAD will have to be handled from 190 * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the 191 * thread manager then catches and does the appropriate nonsense. 192 * However, everything is written out here so as to not get lost. 193 */ 194#define SIGEV_SIGNAL 0 /* notify via signal */ 195#define SIGEV_NONE 1 /* other notification: meaningless */ 196#define SIGEV_THREAD 2 /* deliver via thread creation */ 197 198#define SIGEV_MAX_SIZE 64 199#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) 200 201typedef struct sigevent { 202 sigval_t sigev_value; 203 int sigev_signo; 204 int sigev_notify; 205 union { 206 int _pad[SIGEV_PAD_SIZE]; 207 208 struct { 209 void (*_function)(sigval_t); 210 void *_attribute; /* really pthread_attr_t */ 211 } _sigev_thread; 212 } _sigev_un; 213} sigevent_t; 214 215#define sigev_notify_function _sigev_un._sigev_thread._function 216#define sigev_notify_attributes _sigev_un._sigev_thread._attribute 217 218#ifdef __KERNEL__ 219#include <linux/string.h> 220 221extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from) 222{ 223 if (from->si_code < 0) 224 memcpy(to, from, sizeof(siginfo_t)); 225 else 226 /* _sigchld is currently the largest know union member */ 227 memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld)); 228} 229 230extern int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from); 231 232#endif /* __KERNEL__ */ 233 234#endif 235