signal.h 5.5 KB

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