xref: /openbmc/linux/arch/m68k/include/asm/signal.h (revision 574c4866e33d648520a8bd5bf6f573ea6e554e88)
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 #define __ARCH_HAS_SA_RESTORER
27 
28 #include <asm/sigcontext.h>
29 
30 #ifndef CONFIG_CPU_HAS_NO_BITFIELDS
31 #define __HAVE_ARCH_SIG_BITOPS
32 
33 static inline void sigaddset(sigset_t *set, int _sig)
34 {
35 	asm ("bfset %0{%1,#1}"
36 		: "+o" (*set)
37 		: "id" ((_sig - 1) ^ 31)
38 		: "cc");
39 }
40 
41 static inline void sigdelset(sigset_t *set, int _sig)
42 {
43 	asm ("bfclr %0{%1,#1}"
44 		: "+o" (*set)
45 		: "id" ((_sig - 1) ^ 31)
46 		: "cc");
47 }
48 
49 static inline int __const_sigismember(sigset_t *set, int _sig)
50 {
51 	unsigned long sig = _sig - 1;
52 	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
53 }
54 
55 static inline int __gen_sigismember(sigset_t *set, int _sig)
56 {
57 	int ret;
58 	asm ("bfextu %1{%2,#1},%0"
59 		: "=d" (ret)
60 		: "o" (*set), "id" ((_sig-1) ^ 31)
61 		: "cc");
62 	return ret;
63 }
64 
65 #define sigismember(set,sig)			\
66 	(__builtin_constant_p(sig) ?		\
67 	 __const_sigismember(set,sig) :		\
68 	 __gen_sigismember(set,sig))
69 
70 static inline int sigfindinword(unsigned long word)
71 {
72 	asm ("bfffo %1{#0,#0},%0"
73 		: "=d" (word)
74 		: "d" (word & -word)
75 		: "cc");
76 	return word ^ 31;
77 }
78 
79 #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */
80 
81 #ifndef __uClinux__
82 extern void ptrace_signal_deliver(void);
83 #define ptrace_signal_deliver ptrace_signal_deliver
84 #endif /* __uClinux__ */
85 
86 #endif /* _M68K_SIGNAL_H */
87