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

Linux/Unix编程

开发平台:

Unix_Linux

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