siginfo.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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