H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_SIGNAL_H |
| 2 | #define _ASM_X86_SIGNAL_H |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 3 | |
| 4 | #ifndef __ASSEMBLY__ |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 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 |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 14 | #else |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 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 | |
Suresh Siddha | 050902c | 2012-07-24 16:05:27 -0700 | [diff] [blame] | 26 | #ifndef CONFIG_COMPAT |
| 27 | typedef sigset_t compat_sigset_t; |
| 28 | #endif |
| 29 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 30 | #endif /* __ASSEMBLY__ */ |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame] | 31 | #include <uapi/asm/signal.h> |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 32 | #ifndef __ASSEMBLY__ |
Jaswinder Singh | 7b5b50f | 2008-12-15 22:24:48 +0530 | [diff] [blame] | 33 | extern void do_notify_resume(struct pt_regs *, void *, __u32); |
Al Viro | 574c486 | 2012-11-25 22:24:19 -0500 | [diff] [blame] | 34 | |
| 35 | #define __ARCH_HAS_SA_RESTORER |
| 36 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 37 | #include <asm/sigcontext.h> |
| 38 | |
Herton Ronaldo Krzesinski | 723edb5 | 2008-07-14 17:40:23 -0300 | [diff] [blame] | 39 | #ifdef __i386__ |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 40 | |
| 41 | #define __HAVE_ARCH_SIG_BITOPS |
| 42 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 43 | #define sigaddset(set,sig) \ |
Herton Ronaldo Krzesinski | 723edb5 | 2008-07-14 17:40:23 -0300 | [diff] [blame] | 44 | (__builtin_constant_p(sig) \ |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 45 | ? __const_sigaddset((set), (sig)) \ |
| 46 | : __gen_sigaddset((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 47 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 48 | static inline void __gen_sigaddset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 49 | { |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 50 | asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 51 | } |
| 52 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 53 | static inline void __const_sigaddset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 54 | { |
| 55 | unsigned long sig = _sig - 1; |
| 56 | set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); |
| 57 | } |
| 58 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 59 | #define sigdelset(set, sig) \ |
| 60 | (__builtin_constant_p(sig) \ |
| 61 | ? __const_sigdelset((set), (sig)) \ |
| 62 | : __gen_sigdelset((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 63 | |
| 64 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 65 | static inline void __gen_sigdelset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 66 | { |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 67 | asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 68 | } |
| 69 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 70 | static inline void __const_sigdelset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 71 | { |
| 72 | unsigned long sig = _sig - 1; |
| 73 | set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); |
| 74 | } |
| 75 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 76 | static inline int __const_sigismember(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 77 | { |
| 78 | unsigned long sig = _sig - 1; |
| 79 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
| 80 | } |
| 81 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 82 | static inline int __gen_sigismember(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 83 | { |
| 84 | int ret; |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 85 | asm("btl %2,%1\n\tsbbl %0,%0" |
| 86 | : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 87 | return ret; |
| 88 | } |
| 89 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 90 | #define sigismember(set, sig) \ |
| 91 | (__builtin_constant_p(sig) \ |
| 92 | ? __const_sigismember((set), (sig)) \ |
| 93 | : __gen_sigismember((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 94 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 95 | struct pt_regs; |
| 96 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 97 | #else /* __i386__ */ |
| 98 | |
| 99 | #undef __HAVE_ARCH_SIG_BITOPS |
| 100 | |
Roland McGrath | e1f2877 | 2008-01-30 13:30:50 +0100 | [diff] [blame] | 101 | #endif /* !__i386__ */ |
| 102 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 103 | #endif /* __ASSEMBLY__ */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 104 | #endif /* _ASM_X86_SIGNAL_H */ |