xref: /linux/arch/m68k/include/asm/signal.h (revision 0d456bad36d42d16022be045c8a53ddbb59ee478)
1 #ifndef _M68K_SIGNAL_H
2 #define _M68K_SIGNAL_H
3 
4 #include <uapi/asm/signal.h>
5 
6 /* Most things should be clean enough to redefine this at will, if care
7    is taken to make libc match.  */
8 
9 #define _NSIG		64
10 #define _NSIG_BPW	32
11 #define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
12 
13 typedef unsigned long old_sigset_t;		/* at least 32 bits */
14 
15 typedef struct {
16 	unsigned long sig[_NSIG_WORDS];
17 } sigset_t;
18 
19 struct old_sigaction {
20 	__sighandler_t sa_handler;
21 	old_sigset_t sa_mask;
22 	unsigned long sa_flags;
23 	__sigrestore_t sa_restorer;
24 };
25 
26 struct sigaction {
27 	__sighandler_t sa_handler;
28 	unsigned long sa_flags;
29 	__sigrestore_t sa_restorer;
30 	sigset_t sa_mask;		/* mask last for extensibility */
31 };
32 
33 struct k_sigaction {
34 	struct sigaction sa;
35 };
36 #include <asm/sigcontext.h>
37 
38 #ifndef CONFIG_CPU_HAS_NO_BITFIELDS
39 #define __HAVE_ARCH_SIG_BITOPS
40 
41 static inline void sigaddset(sigset_t *set, int _sig)
42 {
43 	asm ("bfset %0{%1,#1}"
44 		: "+o" (*set)
45 		: "id" ((_sig - 1) ^ 31)
46 		: "cc");
47 }
48 
49 static inline void sigdelset(sigset_t *set, int _sig)
50 {
51 	asm ("bfclr %0{%1,#1}"
52 		: "+o" (*set)
53 		: "id" ((_sig - 1) ^ 31)
54 		: "cc");
55 }
56 
57 static inline int __const_sigismember(sigset_t *set, int _sig)
58 {
59 	unsigned long sig = _sig - 1;
60 	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
61 }
62 
63 static inline int __gen_sigismember(sigset_t *set, int _sig)
64 {
65 	int ret;
66 	asm ("bfextu %1{%2,#1},%0"
67 		: "=d" (ret)
68 		: "o" (*set), "id" ((_sig-1) ^ 31)
69 		: "cc");
70 	return ret;
71 }
72 
73 #define sigismember(set,sig)			\
74 	(__builtin_constant_p(sig) ?		\
75 	 __const_sigismember(set,sig) :		\
76 	 __gen_sigismember(set,sig))
77 
78 static inline int sigfindinword(unsigned long word)
79 {
80 	asm ("bfffo %1{#0,#0},%0"
81 		: "=d" (word)
82 		: "d" (word & -word)
83 		: "cc");
84 	return word ^ 31;
85 }
86 
87 #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */
88 
89 #ifndef __uClinux__
90 extern void ptrace_signal_deliver(void);
91 #define ptrace_signal_deliver ptrace_signal_deliver
92 #endif /* __uClinux__ */
93 
94 #endif /* _M68K_SIGNAL_H */
95