Merge tag 'devicetree-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/robh...
[linux-2.6-block.git] / arch / x86 / include / asm / signal.h
CommitLineData
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
21typedef unsigned long old_sigset_t; /* at least 32 bits */
22
23typedef 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
32typedef sigset_t compat_sigset_t;
33#endif
34
33185c50 35#endif /* __ASSEMBLY__ */
af170c50 36#include <uapi/asm/signal.h>
33185c50 37#ifndef __ASSEMBLY__
1f484aa6 38extern void do_signal(struct pt_regs *regs);
574c4866
AV
39
40#define __ARCH_HAS_SA_RESTORER
41
26e609ec 42#include <asm/asm.h>
decb4c41 43#include <uapi/asm/sigcontext.h>
33185c50 44
723edb50 45#ifdef __i386__
33185c50
TG
46
47#define __HAVE_ARCH_SIG_BITOPS
48
9551b12a 49#define sigaddset(set,sig) \
723edb50 50 (__builtin_constant_p(sig) \
9551b12a
JP
51 ? __const_sigaddset((set), (sig)) \
52 : __gen_sigaddset((set), (sig)))
33185c50 53
9551b12a 54static inline void __gen_sigaddset(sigset_t *set, int _sig)
33185c50 55{
9551b12a 56 asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
33185c50
TG
57}
58
9551b12a 59static inline void __const_sigaddset(sigset_t *set, int _sig)
33185c50
TG
60{
61 unsigned long sig = _sig - 1;
62 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
63}
64
9551b12a
JP
65#define sigdelset(set, sig) \
66 (__builtin_constant_p(sig) \
67 ? __const_sigdelset((set), (sig)) \
68 : __gen_sigdelset((set), (sig)))
33185c50
TG
69
70
9551b12a 71static inline void __gen_sigdelset(sigset_t *set, int _sig)
33185c50 72{
9551b12a 73 asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
33185c50
TG
74}
75
9551b12a 76static inline void __const_sigdelset(sigset_t *set, int _sig)
33185c50
TG
77{
78 unsigned long sig = _sig - 1;
79 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
80}
81
9551b12a 82static inline int __const_sigismember(sigset_t *set, int _sig)
33185c50
TG
83{
84 unsigned long sig = _sig - 1;
85 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
86}
87
9551b12a 88static inline int __gen_sigismember(sigset_t *set, int _sig)
33185c50 89{
26e609ec
UB
90 bool ret;
91 asm("btl %2,%1" CC_SET(c)
92 : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1));
33185c50
TG
93 return ret;
94}
95
9551b12a
JP
96#define sigismember(set, sig) \
97 (__builtin_constant_p(sig) \
98 ? __const_sigismember((set), (sig)) \
99 : __gen_sigismember((set), (sig)))
33185c50 100
33185c50
TG
101struct pt_regs;
102
33185c50
TG
103#else /* __i386__ */
104
105#undef __HAVE_ARCH_SIG_BITOPS
106
e1f28773
RM
107#endif /* !__i386__ */
108
33185c50 109#endif /* __ASSEMBLY__ */
1965aae3 110#endif /* _ASM_X86_SIGNAL_H */