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