signal.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef _ASM_X86_SIGNAL_H
  2. #define _ASM_X86_SIGNAL_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/linkage.h>
  5. /* Most things should be clean enough to redefine this at will, if care
  6. is taken to make libc match. */
  7. #define _NSIG 64
  8. #ifdef __i386__
  9. # define _NSIG_BPW 32
  10. #else
  11. # define _NSIG_BPW 64
  12. #endif
  13. #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
  14. typedef unsigned long old_sigset_t; /* at least 32 bits */
  15. typedef struct {
  16. unsigned long sig[_NSIG_WORDS];
  17. } sigset_t;
  18. #ifndef CONFIG_COMPAT
  19. typedef sigset_t compat_sigset_t;
  20. #endif
  21. #endif /* __ASSEMBLY__ */
  22. #include <uapi/asm/signal.h>
  23. #ifndef __ASSEMBLY__
  24. extern void do_notify_resume(struct pt_regs *, void *, __u32);
  25. #ifdef __i386__
  26. struct old_sigaction {
  27. __sighandler_t sa_handler;
  28. old_sigset_t sa_mask;
  29. unsigned long sa_flags;
  30. __sigrestore_t sa_restorer;
  31. };
  32. struct sigaction {
  33. __sighandler_t sa_handler;
  34. unsigned long sa_flags;
  35. __sigrestore_t sa_restorer;
  36. sigset_t sa_mask; /* mask last for extensibility */
  37. };
  38. struct k_sigaction {
  39. struct sigaction sa;
  40. };
  41. #else /* __i386__ */
  42. #endif /* !__i386__ */
  43. #include <asm/sigcontext.h>
  44. #ifdef __i386__
  45. #define __HAVE_ARCH_SIG_BITOPS
  46. #define sigaddset(set,sig) \
  47. (__builtin_constant_p(sig) \
  48. ? __const_sigaddset((set), (sig)) \
  49. : __gen_sigaddset((set), (sig)))
  50. static inline void __gen_sigaddset(sigset_t *set, int _sig)
  51. {
  52. asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  53. }
  54. static inline void __const_sigaddset(sigset_t *set, int _sig)
  55. {
  56. unsigned long sig = _sig - 1;
  57. set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
  58. }
  59. #define sigdelset(set, sig) \
  60. (__builtin_constant_p(sig) \
  61. ? __const_sigdelset((set), (sig)) \
  62. : __gen_sigdelset((set), (sig)))
  63. static inline void __gen_sigdelset(sigset_t *set, int _sig)
  64. {
  65. asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  66. }
  67. static inline void __const_sigdelset(sigset_t *set, int _sig)
  68. {
  69. unsigned long sig = _sig - 1;
  70. set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
  71. }
  72. static inline int __const_sigismember(sigset_t *set, int _sig)
  73. {
  74. unsigned long sig = _sig - 1;
  75. return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
  76. }
  77. static inline int __gen_sigismember(sigset_t *set, int _sig)
  78. {
  79. int ret;
  80. asm("btl %2,%1\n\tsbbl %0,%0"
  81. : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
  82. return ret;
  83. }
  84. #define sigismember(set, sig) \
  85. (__builtin_constant_p(sig) \
  86. ? __const_sigismember((set), (sig)) \
  87. : __gen_sigismember((set), (sig)))
  88. static inline int sigfindinword(unsigned long word)
  89. {
  90. asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
  91. return word;
  92. }
  93. struct pt_regs;
  94. #else /* __i386__ */
  95. #undef __HAVE_ARCH_SIG_BITOPS
  96. #endif /* !__i386__ */
  97. #endif /* __ASSEMBLY__ */
  98. #endif /* _ASM_X86_SIGNAL_H */