signal.h 2.6 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_notify_resume(struct pt_regs *, void *, __u32);
T
Thomas Gleixner 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#ifdef __i386__
struct old_sigaction {
	__sighandler_t sa_handler;
	old_sigset_t sa_mask;
	unsigned long sa_flags;
	__sigrestore_t sa_restorer;
};

struct sigaction {
	__sighandler_t sa_handler;
	unsigned long sa_flags;
	__sigrestore_t sa_restorer;
	sigset_t sa_mask;		/* mask last for extensibility */
};

#endif /* !__i386__ */
#include <asm/sigcontext.h>

52
#ifdef __i386__
T
Thomas Gleixner 已提交
53 54 55

#define __HAVE_ARCH_SIG_BITOPS

56
#define sigaddset(set,sig)		    \
57
	(__builtin_constant_p(sig)	    \
58 59
	 ? __const_sigaddset((set), (sig))  \
	 : __gen_sigaddset((set), (sig)))
T
Thomas Gleixner 已提交
60

61
static inline void __gen_sigaddset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
62
{
63
	asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
T
Thomas Gleixner 已提交
64 65
}

66
static inline void __const_sigaddset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
67 68 69 70 71
{
	unsigned long sig = _sig - 1;
	set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
}

72 73 74 75
#define sigdelset(set, sig)		    \
	(__builtin_constant_p(sig)	    \
	 ? __const_sigdelset((set), (sig))  \
	 : __gen_sigdelset((set), (sig)))
T
Thomas Gleixner 已提交
76 77


78
static inline void __gen_sigdelset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
79
{
80
	asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
T
Thomas Gleixner 已提交
81 82
}

83
static inline void __const_sigdelset(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
84 85 86 87 88
{
	unsigned long sig = _sig - 1;
	set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
}

89
static inline int __const_sigismember(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
90 91 92 93 94
{
	unsigned long sig = _sig - 1;
	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
}

95
static inline int __gen_sigismember(sigset_t *set, int _sig)
T
Thomas Gleixner 已提交
96 97
{
	int ret;
98 99
	asm("btl %2,%1\n\tsbbl %0,%0"
	    : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
T
Thomas Gleixner 已提交
100 101 102
	return ret;
}

103 104 105 106
#define sigismember(set, sig)			\
	(__builtin_constant_p(sig)		\
	 ? __const_sigismember((set), (sig))	\
	 : __gen_sigismember((set), (sig)))
T
Thomas Gleixner 已提交
107

108
static inline int sigfindinword(unsigned long word)
T
Thomas Gleixner 已提交
109
{
110
	asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
T
Thomas Gleixner 已提交
111 112 113 114 115 116 117 118 119
	return word;
}

struct pt_regs;

#else /* __i386__ */

#undef __HAVE_ARCH_SIG_BITOPS

R
Roland McGrath 已提交
120 121
#endif /* !__i386__ */

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