signal.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_SIGNAL_H
  3. #define _ASM_X86_SIGNAL_H
  4. #ifndef __ASSEMBLY__
  5. #include <linux/linkage.h>
  6. /* Most things should be clean enough to redefine this at will, if care
  7. is taken to make libc match. */
  8. #define _NSIG 64
  9. #ifdef __i386__
  10. # define _NSIG_BPW 32
  11. #else
  12. # define _NSIG_BPW 64
  13. #endif
  14. #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
  15. typedef unsigned long old_sigset_t; /* at least 32 bits */
  16. typedef struct {
  17. unsigned long sig[_NSIG_WORDS];
  18. } sigset_t;
  19. /* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */
  20. #define SA_IA32_ABI 0x02000000u
  21. #define SA_X32_ABI 0x01000000u
  22. #ifndef CONFIG_COMPAT
  23. #define compat_sigset_t compat_sigset_t
  24. typedef sigset_t compat_sigset_t;
  25. #endif
  26. #endif /* __ASSEMBLY__ */
  27. #include <uapi/asm/signal.h>
  28. #ifndef __ASSEMBLY__
  29. #define __ARCH_HAS_SA_RESTORER
  30. #include <asm/asm.h>
  31. #include <uapi/asm/sigcontext.h>
  32. #ifdef __i386__
  33. #define __HAVE_ARCH_SIG_BITOPS
  34. #define sigaddset(set,sig) \
  35. (__builtin_constant_p(sig) \
  36. ? __const_sigaddset((set), (sig)) \
  37. : __gen_sigaddset((set), (sig)))
  38. static inline void __gen_sigaddset(sigset_t *set, int _sig)
  39. {
  40. asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  41. }
  42. static inline void __const_sigaddset(sigset_t *set, int _sig)
  43. {
  44. unsigned long sig = _sig - 1;
  45. set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
  46. }
  47. #define sigdelset(set, sig) \
  48. (__builtin_constant_p(sig) \
  49. ? __const_sigdelset((set), (sig)) \
  50. : __gen_sigdelset((set), (sig)))
  51. static inline void __gen_sigdelset(sigset_t *set, int _sig)
  52. {
  53. asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
  54. }
  55. static inline void __const_sigdelset(sigset_t *set, int _sig)
  56. {
  57. unsigned long sig = _sig - 1;
  58. set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
  59. }
  60. static inline int __const_sigismember(sigset_t *set, int _sig)
  61. {
  62. unsigned long sig = _sig - 1;
  63. return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
  64. }
  65. static inline int __gen_sigismember(sigset_t *set, int _sig)
  66. {
  67. bool ret;
  68. asm("btl %2,%1" CC_SET(c)
  69. : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1));
  70. return ret;
  71. }
  72. #define sigismember(set, sig) \
  73. (__builtin_constant_p(sig) \
  74. ? __const_sigismember((set), (sig)) \
  75. : __gen_sigismember((set), (sig)))
  76. struct pt_regs;
  77. #else /* __i386__ */
  78. #undef __HAVE_ARCH_SIG_BITOPS
  79. #endif /* !__i386__ */
  80. #endif /* __ASSEMBLY__ */
  81. #endif /* _ASM_X86_SIGNAL_H */