]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1965aae3 PA |
2 | #ifndef _ASM_X86_SIGNAL_H |
3 | #define _ASM_X86_SIGNAL_H | |
33185c50 TG |
4 | |
5 | #ifndef __ASSEMBLY__ | |
33185c50 TG |
6 | #include <linux/linkage.h> |
7 | ||
8 | /* Most things should be clean enough to redefine this at will, if care | |
9 | is taken to make libc match. */ | |
10 | ||
11 | #define _NSIG 64 | |
12 | ||
13 | #ifdef __i386__ | |
14 | # define _NSIG_BPW 32 | |
96a388de | 15 | #else |
33185c50 TG |
16 | # define _NSIG_BPW 64 |
17 | #endif | |
18 | ||
19 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) | |
20 | ||
21 | typedef unsigned long old_sigset_t; /* at least 32 bits */ | |
22 | ||
23 | typedef struct { | |
24 | unsigned long sig[_NSIG_WORDS]; | |
25 | } sigset_t; | |
26 | ||
68463510 DS |
27 | /* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */ |
28 | #define SA_IA32_ABI 0x02000000u | |
29 | #define SA_X32_ABI 0x01000000u | |
30 | ||
050902c0 SS |
31 | #ifndef CONFIG_COMPAT |
32 | typedef sigset_t compat_sigset_t; | |
33 | #endif | |
34 | ||
33185c50 | 35 | #endif /* __ASSEMBLY__ */ |
af170c50 | 36 | #include <uapi/asm/signal.h> |
33185c50 | 37 | #ifndef __ASSEMBLY__ |
1f484aa6 | 38 | extern void do_signal(struct pt_regs *regs); |
574c4866 AV |
39 | |
40 | #define __ARCH_HAS_SA_RESTORER | |
41 | ||
decb4c41 | 42 | #include <uapi/asm/sigcontext.h> |
33185c50 | 43 | |
723edb50 | 44 | #ifdef __i386__ |
33185c50 TG |
45 | |
46 | #define __HAVE_ARCH_SIG_BITOPS | |
47 | ||
9551b12a | 48 | #define sigaddset(set,sig) \ |
723edb50 | 49 | (__builtin_constant_p(sig) \ |
9551b12a JP |
50 | ? __const_sigaddset((set), (sig)) \ |
51 | : __gen_sigaddset((set), (sig))) | |
33185c50 | 52 | |
9551b12a | 53 | static inline void __gen_sigaddset(sigset_t *set, int _sig) |
33185c50 | 54 | { |
9551b12a | 55 | asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
33185c50 TG |
56 | } |
57 | ||
9551b12a | 58 | static inline void __const_sigaddset(sigset_t *set, int _sig) |
33185c50 TG |
59 | { |
60 | unsigned long sig = _sig - 1; | |
61 | set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); | |
62 | } | |
63 | ||
9551b12a JP |
64 | #define sigdelset(set, sig) \ |
65 | (__builtin_constant_p(sig) \ | |
66 | ? __const_sigdelset((set), (sig)) \ | |
67 | : __gen_sigdelset((set), (sig))) | |
33185c50 TG |
68 | |
69 | ||
9551b12a | 70 | static inline void __gen_sigdelset(sigset_t *set, int _sig) |
33185c50 | 71 | { |
9551b12a | 72 | asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
33185c50 TG |
73 | } |
74 | ||
9551b12a | 75 | static inline void __const_sigdelset(sigset_t *set, int _sig) |
33185c50 TG |
76 | { |
77 | unsigned long sig = _sig - 1; | |
78 | set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); | |
79 | } | |
80 | ||
9551b12a | 81 | static inline int __const_sigismember(sigset_t *set, int _sig) |
33185c50 TG |
82 | { |
83 | unsigned long sig = _sig - 1; | |
84 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); | |
85 | } | |
86 | ||
9551b12a | 87 | static inline int __gen_sigismember(sigset_t *set, int _sig) |
33185c50 | 88 | { |
2823d4da PA |
89 | unsigned char ret; |
90 | asm("btl %2,%1\n\tsetc %0" | |
91 | : "=qm"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); | |
33185c50 TG |
92 | return ret; |
93 | } | |
94 | ||
9551b12a JP |
95 | #define sigismember(set, sig) \ |
96 | (__builtin_constant_p(sig) \ | |
97 | ? __const_sigismember((set), (sig)) \ | |
98 | : __gen_sigismember((set), (sig))) | |
33185c50 | 99 | |
33185c50 TG |
100 | struct pt_regs; |
101 | ||
33185c50 TG |
102 | #else /* __i386__ */ |
103 | ||
104 | #undef __HAVE_ARCH_SIG_BITOPS | |
105 | ||
e1f28773 RM |
106 | #endif /* !__i386__ */ |
107 | ||
33185c50 | 108 | #endif /* __ASSEMBLY__ */ |
1965aae3 | 109 | #endif /* _ASM_X86_SIGNAL_H */ |