signal.h 5.6 KB

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