signal.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 __KERNEL__
  103. extern void do_notify_resume(struct pt_regs *, void *, __u32);
  104. # endif /* __KERNEL__ */
  105. #ifdef __i386__
  106. # ifdef __KERNEL__
  107. struct old_sigaction {
  108. __sighandler_t sa_handler;
  109. old_sigset_t sa_mask;
  110. unsigned long sa_flags;
  111. __sigrestore_t sa_restorer;
  112. };
  113. struct sigaction {
  114. __sighandler_t sa_handler;
  115. unsigned long sa_flags;
  116. __sigrestore_t sa_restorer;
  117. sigset_t sa_mask; /* mask last for extensibility */
  118. };
  119. struct k_sigaction {
  120. struct sigaction sa;
  121. };
  122. # else /* __KERNEL__ */
  123. /* Here we must cater to libcs that poke about in kernel headers. */
  124. struct sigaction {
  125. union {
  126. __sighandler_t _sa_handler;
  127. void (*_sa_sigaction)(int, struct siginfo *, void *);
  128. } _u;
  129. sigset_t sa_mask;
  130. unsigned long sa_flags;
  131. void (*sa_restorer)(void);
  132. };
  133. #define sa_handler _u._sa_handler
  134. #define sa_sigaction _u._sa_sigaction
  135. # endif /* ! __KERNEL__ */
  136. #else /* __i386__ */
  137. struct sigaction {
  138. __sighandler_t sa_handler;
  139. unsigned long sa_flags;
  140. __sigrestore_t sa_restorer;
  141. sigset_t sa_mask; /* mask last for extensibility */
  142. };
  143. struct k_sigaction {
  144. struct sigaction sa;
  145. };
  146. #endif /* !__i386__ */
  147. typedef struct sigaltstack {
  148. void __user *ss_sp;
  149. int ss_flags;
  150. size_t ss_size;
  151. } stack_t;
  152. #ifdef __KERNEL__
  153. #include <asm/sigcontext.h>
  154. #ifdef __i386__
  155. #define __HAVE_ARCH_SIG_BITOPS
  156. #define sigaddset(set,sig) \
  157. (__builtin_constant_p(sig) \
  158. ? __const_sigaddset((set), (sig)) \
  159. : __gen_sigaddset((set), (sig)))
  160. static inline void __gen_sigaddset(sigset_t *set, int _sig)
  161. {
  162. asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  163. }
  164. static inline void __const_sigaddset(sigset_t *set, int _sig)
  165. {
  166. unsigned long sig = _sig - 1;
  167. set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
  168. }
  169. #define sigdelset(set, sig) \
  170. (__builtin_constant_p(sig) \
  171. ? __const_sigdelset((set), (sig)) \
  172. : __gen_sigdelset((set), (sig)))
  173. static inline void __gen_sigdelset(sigset_t *set, int _sig)
  174. {
  175. asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  176. }
  177. static inline void __const_sigdelset(sigset_t *set, int _sig)
  178. {
  179. unsigned long sig = _sig - 1;
  180. set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
  181. }
  182. static inline int __const_sigismember(sigset_t *set, int _sig)
  183. {
  184. unsigned long sig = _sig - 1;
  185. return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
  186. }
  187. static inline int __gen_sigismember(sigset_t *set, int _sig)
  188. {
  189. int ret;
  190. asm("btl %2,%1\n\tsbbl %0,%0"
  191. : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
  192. return ret;
  193. }
  194. #define sigismember(set, sig) \
  195. (__builtin_constant_p(sig) \
  196. ? __const_sigismember((set), (sig)) \
  197. : __gen_sigismember((set), (sig)))
  198. static inline int sigfindinword(unsigned long word)
  199. {
  200. asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
  201. return word;
  202. }
  203. struct pt_regs;
  204. #else /* __i386__ */
  205. #undef __HAVE_ARCH_SIG_BITOPS
  206. #endif /* !__i386__ */
  207. #define ptrace_signal_deliver(regs, cookie) do { } while (0)
  208. #endif /* __KERNEL__ */
  209. #endif /* __ASSEMBLY__ */
  210. #endif /* _ASM_X86_SIGNAL_H */