xref: /openbmc/linux/arch/x86/include/asm/signal.h (revision 0d456bad)
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 #ifndef CONFIG_COMPAT
27 typedef sigset_t compat_sigset_t;
28 #endif
29 
30 #endif /* __ASSEMBLY__ */
31 #include <uapi/asm/signal.h>
32 #ifndef __ASSEMBLY__
33 extern void do_notify_resume(struct pt_regs *, void *, __u32);
34 #ifdef __i386__
35 struct old_sigaction {
36 	__sighandler_t sa_handler;
37 	old_sigset_t sa_mask;
38 	unsigned long sa_flags;
39 	__sigrestore_t sa_restorer;
40 };
41 
42 struct sigaction {
43 	__sighandler_t sa_handler;
44 	unsigned long sa_flags;
45 	__sigrestore_t sa_restorer;
46 	sigset_t sa_mask;		/* mask last for extensibility */
47 };
48 
49 struct k_sigaction {
50 	struct sigaction sa;
51 };
52 
53 #else /* __i386__ */
54 #endif /* !__i386__ */
55 #include <asm/sigcontext.h>
56 
57 #ifdef __i386__
58 
59 #define __HAVE_ARCH_SIG_BITOPS
60 
61 #define sigaddset(set,sig)		    \
62 	(__builtin_constant_p(sig)	    \
63 	 ? __const_sigaddset((set), (sig))  \
64 	 : __gen_sigaddset((set), (sig)))
65 
66 static inline void __gen_sigaddset(sigset_t *set, int _sig)
67 {
68 	asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
69 }
70 
71 static inline void __const_sigaddset(sigset_t *set, int _sig)
72 {
73 	unsigned long sig = _sig - 1;
74 	set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
75 }
76 
77 #define sigdelset(set, sig)		    \
78 	(__builtin_constant_p(sig)	    \
79 	 ? __const_sigdelset((set), (sig))  \
80 	 : __gen_sigdelset((set), (sig)))
81 
82 
83 static inline void __gen_sigdelset(sigset_t *set, int _sig)
84 {
85 	asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
86 }
87 
88 static inline void __const_sigdelset(sigset_t *set, int _sig)
89 {
90 	unsigned long sig = _sig - 1;
91 	set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
92 }
93 
94 static inline int __const_sigismember(sigset_t *set, int _sig)
95 {
96 	unsigned long sig = _sig - 1;
97 	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
98 }
99 
100 static inline int __gen_sigismember(sigset_t *set, int _sig)
101 {
102 	int ret;
103 	asm("btl %2,%1\n\tsbbl %0,%0"
104 	    : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
105 	return ret;
106 }
107 
108 #define sigismember(set, sig)			\
109 	(__builtin_constant_p(sig)		\
110 	 ? __const_sigismember((set), (sig))	\
111 	 : __gen_sigismember((set), (sig)))
112 
113 static inline int sigfindinword(unsigned long word)
114 {
115 	asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
116 	return word;
117 }
118 
119 struct pt_regs;
120 
121 #else /* __i386__ */
122 
123 #undef __HAVE_ARCH_SIG_BITOPS
124 
125 #endif /* !__i386__ */
126 
127 #endif /* __ASSEMBLY__ */
128 #endif /* _ASM_X86_SIGNAL_H */
129