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