signal.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. #endif /* !__i386__ */
  39. #include <asm/sigcontext.h>
  40. #ifdef __i386__
  41. #define __HAVE_ARCH_SIG_BITOPS
  42. #define sigaddset(set,sig) \
  43. (__builtin_constant_p(sig) \
  44. ? __const_sigaddset((set), (sig)) \
  45. : __gen_sigaddset((set), (sig)))
  46. static inline void __gen_sigaddset(sigset_t *set, int _sig)
  47. {
  48. asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  49. }
  50. static inline void __const_sigaddset(sigset_t *set, int _sig)
  51. {
  52. unsigned long sig = _sig - 1;
  53. set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
  54. }
  55. #define sigdelset(set, sig) \
  56. (__builtin_constant_p(sig) \
  57. ? __const_sigdelset((set), (sig)) \
  58. : __gen_sigdelset((set), (sig)))
  59. static inline void __gen_sigdelset(sigset_t *set, int _sig)
  60. {
  61. asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  62. }
  63. static inline void __const_sigdelset(sigset_t *set, int _sig)
  64. {
  65. unsigned long sig = _sig - 1;
  66. set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
  67. }
  68. static inline int __const_sigismember(sigset_t *set, int _sig)
  69. {
  70. unsigned long sig = _sig - 1;
  71. return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
  72. }
  73. static inline int __gen_sigismember(sigset_t *set, int _sig)
  74. {
  75. int ret;
  76. asm("btl %2,%1\n\tsbbl %0,%0"
  77. : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
  78. return ret;
  79. }
  80. #define sigismember(set, sig) \
  81. (__builtin_constant_p(sig) \
  82. ? __const_sigismember((set), (sig)) \
  83. : __gen_sigismember((set), (sig)))
  84. static inline int sigfindinword(unsigned long word)
  85. {
  86. asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
  87. return word;
  88. }
  89. struct pt_regs;
  90. #else /* __i386__ */
  91. #undef __HAVE_ARCH_SIG_BITOPS
  92. #endif /* !__i386__ */
  93. #endif /* __ASSEMBLY__ */
  94. #endif /* _ASM_X86_SIGNAL_H */