Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_SIGNAL_H
0003 #define _ASM_X86_SIGNAL_H
0004 
0005 #ifndef __ASSEMBLY__
0006 #include <linux/linkage.h>
0007 
0008 /* Most things should be clean enough to redefine this at will, if care
0009    is taken to make libc match.  */
0010 
0011 #define _NSIG       64
0012 
0013 #ifdef __i386__
0014 # define _NSIG_BPW  32
0015 #else
0016 # define _NSIG_BPW  64
0017 #endif
0018 
0019 #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
0020 
0021 typedef unsigned long old_sigset_t;     /* at least 32 bits */
0022 
0023 typedef struct {
0024     unsigned long sig[_NSIG_WORDS];
0025 } sigset_t;
0026 
0027 /* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */
0028 #define SA_IA32_ABI 0x02000000u
0029 #define SA_X32_ABI  0x01000000u
0030 
0031 #ifndef CONFIG_COMPAT
0032 #define compat_sigset_t compat_sigset_t
0033 typedef sigset_t compat_sigset_t;
0034 #endif
0035 
0036 #endif /* __ASSEMBLY__ */
0037 #include <uapi/asm/signal.h>
0038 #ifndef __ASSEMBLY__
0039 
0040 #define __ARCH_HAS_SA_RESTORER
0041 
0042 #include <asm/asm.h>
0043 #include <uapi/asm/sigcontext.h>
0044 
0045 #ifdef __i386__
0046 
0047 #define __HAVE_ARCH_SIG_BITOPS
0048 
0049 #define sigaddset(set,sig)          \
0050     (__builtin_constant_p(sig)      \
0051      ? __const_sigaddset((set), (sig))  \
0052      : __gen_sigaddset((set), (sig)))
0053 
0054 static inline void __gen_sigaddset(sigset_t *set, int _sig)
0055 {
0056     asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
0057 }
0058 
0059 static inline void __const_sigaddset(sigset_t *set, int _sig)
0060 {
0061     unsigned long sig = _sig - 1;
0062     set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
0063 }
0064 
0065 #define sigdelset(set, sig)         \
0066     (__builtin_constant_p(sig)      \
0067      ? __const_sigdelset((set), (sig))  \
0068      : __gen_sigdelset((set), (sig)))
0069 
0070 
0071 static inline void __gen_sigdelset(sigset_t *set, int _sig)
0072 {
0073     asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
0074 }
0075 
0076 static inline void __const_sigdelset(sigset_t *set, int _sig)
0077 {
0078     unsigned long sig = _sig - 1;
0079     set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
0080 }
0081 
0082 static inline int __const_sigismember(sigset_t *set, int _sig)
0083 {
0084     unsigned long sig = _sig - 1;
0085     return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
0086 }
0087 
0088 static inline int __gen_sigismember(sigset_t *set, int _sig)
0089 {
0090     bool ret;
0091     asm("btl %2,%1" CC_SET(c)
0092         : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1));
0093     return ret;
0094 }
0095 
0096 #define sigismember(set, sig)           \
0097     (__builtin_constant_p(sig)      \
0098      ? __const_sigismember((set), (sig))    \
0099      : __gen_sigismember((set), (sig)))
0100 
0101 struct pt_regs;
0102 
0103 #else /* __i386__ */
0104 
0105 #undef __HAVE_ARCH_SIG_BITOPS
0106 
0107 #endif /* !__i386__ */
0108 
0109 #endif /* __ASSEMBLY__ */
0110 #endif /* _ASM_X86_SIGNAL_H */