signal.h 2.2 KB
Newer Older
H
H. Peter Anvin 已提交
1 2
#ifndef _ASM_X86_SIGNAL_H
#define _ASM_X86_SIGNAL_H
T
Thomas Gleixner 已提交
3 4 5 6 7 8 9 10 11 12 13

#ifndef __ASSEMBLY__
#include <linux/linkage.h>

/* Most things should be clean enough to redefine this at will, if care
   is taken to make libc match.  */

#define _NSIG		64

#ifdef __i386__
# define _NSIG_BPW	32
14
#else
T
Thomas Gleixner 已提交
15 16 17 18 19 20 21 22 23 24 25
# define _NSIG_BPW	64
#endif

#define _NSIG_WORDS	(_NSIG / _NSIG_BPW)

typedef unsigned long old_sigset_t;		/* at least 32 bits */

typedef struct {
	unsigned long sig[_NSIG_WORDS];
} sigset_t;

26 27 28 29
#ifndef CONFIG_COMPAT
typedef sigset_t compat_sigset_t;
#endif

T
Thomas Gleixner 已提交
30
#endif /* __ASSEMBLY__ */
31
#include <uapi/asm/signal.h>
T
Thomas Gleixner 已提交
32
#ifndef __ASSEMBLY__
33
extern void do_signal(struct pt_regs *regs);
34 35 36

#define __ARCH_HAS_SA_RESTORER

37
#include <uapi/asm/sigcontext.h>
T
Thomas Gleixner 已提交
38

39
#ifdef __i386__
T
Thomas Gleixner 已提交
40 41 42

#define __HAVE_ARCH_SIG_BITOPS

43
#define sigaddset(set,sig)		    \
44
	(__builtin_constant_p(sig)	    \
45 46
	 ? __const_sigaddset((set), (sig))  \
	 : __gen_sigaddset((set), (sig)))
T
Thomas Gleixner 已提交
47

48
static inline void __gen_sigaddset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
49
{
50
	asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
T
Thomas Gleixner 已提交
51 52
}

53
static inline void __const_sigaddset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
54 55 56 57 58
{
	unsigned long sig = _sig - 1;
	set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
}

59 60 61 62
#define sigdelset(set, sig)		    \
	(__builtin_constant_p(sig)	    \
	 ? __const_sigdelset((set), (sig))  \
	 : __gen_sigdelset((set), (sig)))
T
Thomas Gleixner 已提交
63 64


65
static inline void __gen_sigdelset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
66
{
67
	asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
T
Thomas Gleixner 已提交
68 69
}

70
static inline void __const_sigdelset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
71 72 73 74 75
{
	unsigned long sig = _sig - 1;
	set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
}

76
static inline int __const_sigismember(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
77 78 79 80 81
{
	unsigned long sig = _sig - 1;
	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
}

82
static inline int __gen_sigismember(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
83
{
84 85 86
	unsigned char ret;
	asm("btl %2,%1\n\tsetc %0"
	    : "=qm"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
T
Thomas Gleixner 已提交
87 88 89
	return ret;
}

90 91 92 93
#define sigismember(set, sig)			\
	(__builtin_constant_p(sig)		\
	 ? __const_sigismember((set), (sig))	\
	 : __gen_sigismember((set), (sig)))
T
Thomas Gleixner 已提交
94 95 96 97 98 99 100

struct pt_regs;

#else /* __i386__ */

#undef __HAVE_ARCH_SIG_BITOPS

R
Roland McGrath 已提交
101 102
#endif /* !__i386__ */

T
Thomas Gleixner 已提交
103
#endif /* __ASSEMBLY__ */
H
H. Peter Anvin 已提交
104
#endif /* _ASM_X86_SIGNAL_H */