signal.h 5.6 KB

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