signal.h 5.6 KB

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