signal.h 2.5 KB

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