signal.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. #ifndef _ASMi386_SIGNAL_H
  2. #define _ASMi386_SIGNAL_H
  3. #include <linux/types.h>
  4. #include <linux/linkage.h>
  5. #include <linux/time.h>
  6. #include <linux/compiler.h>
  7. /* Avoid too many header ordering problems. */
  8. struct siginfo;
  9. #ifdef __KERNEL__
  10. /* Most things should be clean enough to redefine this at will, if care
  11. is taken to make libc match. */
  12. #define _NSIG 64
  13. #define _NSIG_BPW 32
  14. #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
  15. typedef unsigned long old_sigset_t; /* at least 32 bits */
  16. typedef struct {
  17. unsigned long sig[_NSIG_WORDS];
  18. } sigset_t;
  19. #else
  20. /* Here we must cater to libcs that poke about in kernel headers. */
  21. #define NSIG 32
  22. typedef unsigned long sigset_t;
  23. #endif /* __KERNEL__ */
  24. #define SIGHUP 1
  25. #define SIGINT 2
  26. #define SIGQUIT 3
  27. #define SIGILL 4
  28. #define SIGTRAP 5
  29. #define SIGABRT 6
  30. #define SIGIOT 6
  31. #define SIGBUS 7
  32. #define SIGFPE 8
  33. #define SIGKILL 9
  34. #define SIGUSR1 10
  35. #define SIGSEGV 11
  36. #define SIGUSR2 12
  37. #define SIGPIPE 13
  38. #define SIGALRM 14
  39. #define SIGTERM 15
  40. #define SIGSTKFLT 16
  41. #define SIGCHLD 17
  42. #define SIGCONT 18
  43. #define SIGSTOP 19
  44. #define SIGTSTP 20
  45. #define SIGTTIN 21
  46. #define SIGTTOU 22
  47. #define SIGURG 23
  48. #define SIGXCPU 24
  49. #define SIGXFSZ 25
  50. #define SIGVTALRM 26
  51. #define SIGPROF 27
  52. #define SIGWINCH 28
  53. #define SIGIO 29
  54. #define SIGPOLL SIGIO
  55. /*
  56. #define SIGLOST 29
  57. */
  58. #define SIGPWR 30
  59. #define SIGSYS 31
  60. #define SIGUNUSED 31
  61. /* These should not be considered constants from userland. */
  62. #define SIGRTMIN 32
  63. #define SIGRTMAX _NSIG
  64. /*
  65. * SA_FLAGS values:
  66. *
  67. * SA_ONSTACK indicates that a registered stack_t will be used.
  68. * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
  69. * SA_RESTART flag to get restarting signals (which were the default long ago)
  70. * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
  71. * SA_RESETHAND clears the handler when the signal is delivered.
  72. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
  73. * SA_NODEFER prevents the current signal from being masked in the handler.
  74. *
  75. * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
  76. * Unix names RESETHAND and NODEFER respectively.
  77. */
  78. #define SA_NOCLDSTOP 0x00000001u
  79. #define SA_NOCLDWAIT 0x00000002u
  80. #define SA_SIGINFO 0x00000004u
  81. #define SA_ONSTACK 0x08000000u
  82. #define SA_RESTART 0x10000000u
  83. #define SA_NODEFER 0x40000000u
  84. #define SA_RESETHAND 0x80000000u
  85. #define SA_NOMASK SA_NODEFER
  86. #define SA_ONESHOT SA_RESETHAND
  87. #define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
  88. #define SA_RESTORER 0x04000000
  89. /*
  90. * sigaltstack controls
  91. */
  92. #define SS_ONSTACK 1
  93. #define SS_DISABLE 2
  94. #define MINSIGSTKSZ 2048
  95. #define SIGSTKSZ 8192
  96. #include <asm-generic/signal.h>
  97. #ifdef __KERNEL__
  98. struct old_sigaction {
  99. __sighandler_t sa_handler;
  100. old_sigset_t sa_mask;
  101. unsigned long sa_flags;
  102. __sigrestore_t sa_restorer;
  103. };
  104. struct sigaction {
  105. __sighandler_t sa_handler;
  106. unsigned long sa_flags;
  107. __sigrestore_t sa_restorer;
  108. sigset_t sa_mask; /* mask last for extensibility */
  109. };
  110. struct k_sigaction {
  111. struct sigaction sa;
  112. };
  113. #else
  114. /* Here we must cater to libcs that poke about in kernel headers. */
  115. struct sigaction {
  116. union {
  117. __sighandler_t _sa_handler;
  118. void (*_sa_sigaction)(int, struct siginfo *, void *);
  119. } _u;
  120. sigset_t sa_mask;
  121. unsigned long sa_flags;
  122. void (*sa_restorer)(void);
  123. };
  124. #define sa_handler _u._sa_handler
  125. #define sa_sigaction _u._sa_sigaction
  126. #endif /* __KERNEL__ */
  127. typedef struct sigaltstack {
  128. void __user *ss_sp;
  129. int ss_flags;
  130. size_t ss_size;
  131. } stack_t;
  132. #ifdef __KERNEL__
  133. #include <asm/sigcontext.h>
  134. #define __HAVE_ARCH_SIG_BITOPS
  135. #define sigaddset(set,sig) \
  136. (__builtin_constant_p(sig) ? \
  137. __const_sigaddset((set),(sig)) : \
  138. __gen_sigaddset((set),(sig)))
  139. static __inline__ void __gen_sigaddset(sigset_t *set, int _sig)
  140. {
  141. __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  142. }
  143. static __inline__ void __const_sigaddset(sigset_t *set, int _sig)
  144. {
  145. unsigned long sig = _sig - 1;
  146. set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
  147. }
  148. #define sigdelset(set,sig) \
  149. (__builtin_constant_p(sig) ? \
  150. __const_sigdelset((set),(sig)) : \
  151. __gen_sigdelset((set),(sig)))
  152. static __inline__ void __gen_sigdelset(sigset_t *set, int _sig)
  153. {
  154. __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  155. }
  156. static __inline__ void __const_sigdelset(sigset_t *set, int _sig)
  157. {
  158. unsigned long sig = _sig - 1;
  159. set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
  160. }
  161. static __inline__ int __const_sigismember(sigset_t *set, int _sig)
  162. {
  163. unsigned long sig = _sig - 1;
  164. return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
  165. }
  166. static __inline__ int __gen_sigismember(sigset_t *set, int _sig)
  167. {
  168. int ret;
  169. __asm__("btl %2,%1\n\tsbbl %0,%0"
  170. : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
  171. return ret;
  172. }
  173. #define sigismember(set,sig) \
  174. (__builtin_constant_p(sig) ? \
  175. __const_sigismember((set),(sig)) : \
  176. __gen_sigismember((set),(sig)))
  177. static __inline__ int sigfindinword(unsigned long word)
  178. {
  179. __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
  180. return word;
  181. }
  182. struct pt_regs;
  183. extern int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset));
  184. #define ptrace_signal_deliver(regs, cookie) \
  185. do { \
  186. if (current->ptrace & PT_DTRACE) { \
  187. current->ptrace &= ~PT_DTRACE; \
  188. (regs)->eflags &= ~TF_MASK; \
  189. } \
  190. } while (0)
  191. #endif /* __KERNEL__ */
  192. #endif