blob: 9bda8224f3d5d68c3c4e9a72b6e07b3b49f4f1d1 [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);
Al Viro574c4862012-11-25 22:24:19 -050034
35#define __ARCH_HAS_SA_RESTORER
36
Thomas Gleixner33185c52007-10-23 22:37:24 +020037#ifdef __i386__
Thomas Gleixner33185c52007-10-23 22:37:24 +020038struct old_sigaction {
39 __sighandler_t sa_handler;
40 old_sigset_t sa_mask;
41 unsigned long sa_flags;
42 __sigrestore_t sa_restorer;
43};
44
Thomas Gleixner33185c52007-10-23 22:37:24 +020045#endif /* !__i386__ */
Thomas Gleixner33185c52007-10-23 22:37:24 +020046#include <asm/sigcontext.h>
47
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -030048#ifdef __i386__
Thomas Gleixner33185c52007-10-23 22:37:24 +020049
50#define __HAVE_ARCH_SIG_BITOPS
51
Joe Perches9551b122008-03-23 01:03:28 -070052#define sigaddset(set,sig) \
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -030053 (__builtin_constant_p(sig) \
Joe Perches9551b122008-03-23 01:03:28 -070054 ? __const_sigaddset((set), (sig)) \
55 : __gen_sigaddset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +020056
Joe Perches9551b122008-03-23 01:03:28 -070057static inline void __gen_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020058{
Joe Perches9551b122008-03-23 01:03:28 -070059 asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +020060}
61
Joe Perches9551b122008-03-23 01:03:28 -070062static inline void __const_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020063{
64 unsigned long sig = _sig - 1;
65 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
66}
67
Joe Perches9551b122008-03-23 01:03:28 -070068#define sigdelset(set, sig) \
69 (__builtin_constant_p(sig) \
70 ? __const_sigdelset((set), (sig)) \
71 : __gen_sigdelset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +020072
73
Joe Perches9551b122008-03-23 01:03:28 -070074static inline void __gen_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020075{
Joe Perches9551b122008-03-23 01:03:28 -070076 asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +020077}
78
Joe Perches9551b122008-03-23 01:03:28 -070079static inline void __const_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020080{
81 unsigned long sig = _sig - 1;
82 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
83}
84
Joe Perches9551b122008-03-23 01:03:28 -070085static inline int __const_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020086{
87 unsigned long sig = _sig - 1;
88 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
89}
90
Joe Perches9551b122008-03-23 01:03:28 -070091static inline int __gen_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +020092{
93 int ret;
Joe Perches9551b122008-03-23 01:03:28 -070094 asm("btl %2,%1\n\tsbbl %0,%0"
95 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +020096 return ret;
97}
98
Joe Perches9551b122008-03-23 01:03:28 -070099#define sigismember(set, sig) \
100 (__builtin_constant_p(sig) \
101 ? __const_sigismember((set), (sig)) \
102 : __gen_sigismember((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +0200103
Joe Perches9551b122008-03-23 01:03:28 -0700104static inline int sigfindinword(unsigned long word)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200105{
Joe Perches9551b122008-03-23 01:03:28 -0700106 asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200107 return word;
108}
109
110struct pt_regs;
111
Thomas Gleixner33185c52007-10-23 22:37:24 +0200112#else /* __i386__ */
113
114#undef __HAVE_ARCH_SIG_BITOPS
115
Roland McGrathe1f28772008-01-30 13:30:50 +0100116#endif /* !__i386__ */
117
Thomas Gleixner33185c52007-10-23 22:37:24 +0200118#endif /* __ASSEMBLY__ */
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700119#endif /* _ASM_X86_SIGNAL_H */