blob: 216bf364a7e7098a82962613faba2b6c6f20adca [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_SIGNAL_H
2#define _ASM_X86_SIGNAL_H
Thomas Gleixner33185c52007-10-23 22:37:24 +02003
4#ifndef __ASSEMBLY__
Thomas Gleixner33185c52007-10-23 22:37:24 +02005#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
Thomas Gleixner96a388d2007-10-11 11:20:03 +020014#else
Thomas Gleixner33185c52007-10-23 22:37:24 +020015# define _NSIG_BPW 64
16#endif
17
18#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
19
20typedef unsigned long old_sigset_t; /* at least 32 bits */
21
22typedef struct {
23 unsigned long sig[_NSIG_WORDS];
24} sigset_t;
25
Suresh Siddha050902c2012-07-24 16:05:27 -070026#ifndef CONFIG_COMPAT
27typedef sigset_t compat_sigset_t;
28#endif
29
Thomas Gleixner33185c52007-10-23 22:37:24 +020030#endif /* __ASSEMBLY__ */
David Howellsaf170c52012-12-14 22:37:13 +000031#include <uapi/asm/signal.h>
Thomas Gleixner33185c52007-10-23 22:37:24 +020032#ifndef __ASSEMBLY__
Jaswinder Singh7b5b50f2008-12-15 22:24:48 +053033extern void do_notify_resume(struct pt_regs *, void *, __u32);
Thomas Gleixner33185c52007-10-23 22:37:24 +020034#ifdef __i386__
Thomas Gleixner33185c52007-10-23 22:37:24 +020035struct 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
42struct 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
49struct k_sigaction {
50 struct sigaction sa;
51};
Jaswinder Singhb994b6c2008-07-21 21:37:52 +053052
Thomas Gleixner33185c52007-10-23 22:37:24 +020053#else /* __i386__ */
Thomas Gleixner33185c52007-10-23 22:37:24 +020054#endif /* !__i386__ */
Thomas Gleixner33185c52007-10-23 22:37:24 +020055#include <asm/sigcontext.h>
56
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -030057#ifdef __i386__
Thomas Gleixner33185c52007-10-23 22:37:24 +020058
59#define __HAVE_ARCH_SIG_BITOPS
60
Joe Perches9551b122008-03-23 01:03:28 -070061#define sigaddset(set,sig) \
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -030062 (__builtin_constant_p(sig) \
Joe Perches9551b122008-03-23 01:03:28 -070063 ? __const_sigaddset((set), (sig)) \
64 : __gen_sigaddset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +020065
Joe Perches9551b122008-03-23 01:03:28 -070066static inline void __gen_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020067{
Joe Perches9551b122008-03-23 01:03:28 -070068 asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +020069}
70
Joe Perches9551b122008-03-23 01:03:28 -070071static inline void __const_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020072{
73 unsigned long sig = _sig - 1;
74 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
75}
76
Joe Perches9551b122008-03-23 01:03:28 -070077#define sigdelset(set, sig) \
78 (__builtin_constant_p(sig) \
79 ? __const_sigdelset((set), (sig)) \
80 : __gen_sigdelset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +020081
82
Joe Perches9551b122008-03-23 01:03:28 -070083static inline void __gen_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020084{
Joe Perches9551b122008-03-23 01:03:28 -070085 asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +020086}
87
Joe Perches9551b122008-03-23 01:03:28 -070088static inline void __const_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020089{
90 unsigned long sig = _sig - 1;
91 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
92}
93
Joe Perches9551b122008-03-23 01:03:28 -070094static inline int __const_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020095{
96 unsigned long sig = _sig - 1;
97 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
98}
99
Joe Perches9551b122008-03-23 01:03:28 -0700100static inline int __gen_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200101{
102 int ret;
Joe Perches9551b122008-03-23 01:03:28 -0700103 asm("btl %2,%1\n\tsbbl %0,%0"
104 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200105 return ret;
106}
107
Joe Perches9551b122008-03-23 01:03:28 -0700108#define sigismember(set, sig) \
109 (__builtin_constant_p(sig) \
110 ? __const_sigismember((set), (sig)) \
111 : __gen_sigismember((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +0200112
Joe Perches9551b122008-03-23 01:03:28 -0700113static inline int sigfindinword(unsigned long word)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200114{
Joe Perches9551b122008-03-23 01:03:28 -0700115 asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200116 return word;
117}
118
119struct pt_regs;
120
Thomas Gleixner33185c52007-10-23 22:37:24 +0200121#else /* __i386__ */
122
123#undef __HAVE_ARCH_SIG_BITOPS
124
Roland McGrathe1f28772008-01-30 13:30:50 +0100125#endif /* !__i386__ */
126
Thomas Gleixner33185c52007-10-23 22:37:24 +0200127#endif /* __ASSEMBLY__ */
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700128#endif /* _ASM_X86_SIGNAL_H */