Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 2 | #ifndef _M68K_SIGNAL_H |
| 3 | #define _M68K_SIGNAL_H |
| 4 | |
David Howells | 10b3a97 | 2012-10-09 09:47:06 +0100 | [diff] [blame] | 5 | #include <uapi/asm/signal.h> |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 6 | |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 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 | #define _NSIG_BPW 32 |
| 12 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) |
| 13 | |
| 14 | typedef unsigned long old_sigset_t; /* at least 32 bits */ |
| 15 | |
| 16 | typedef struct { |
| 17 | unsigned long sig[_NSIG_WORDS]; |
| 18 | } sigset_t; |
| 19 | |
Al Viro | 574c486 | 2012-11-25 22:24:19 -0500 | [diff] [blame] | 20 | #define __ARCH_HAS_SA_RESTORER |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 21 | |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 22 | #include <asm/sigcontext.h> |
| 23 | |
Greg Ungerer | f3c23a2 | 2011-07-04 14:23:09 +1000 | [diff] [blame] | 24 | #ifndef CONFIG_CPU_HAS_NO_BITFIELDS |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 25 | #define __HAVE_ARCH_SIG_BITOPS |
| 26 | |
| 27 | static inline void sigaddset(sigset_t *set, int _sig) |
| 28 | { |
| 29 | asm ("bfset %0{%1,#1}" |
Andreas Schwab | 34fa78b | 2012-11-17 22:27:04 +0100 | [diff] [blame] | 30 | : "+o" (*set) |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 31 | : "id" ((_sig - 1) ^ 31) |
| 32 | : "cc"); |
| 33 | } |
| 34 | |
| 35 | static inline void sigdelset(sigset_t *set, int _sig) |
| 36 | { |
| 37 | asm ("bfclr %0{%1,#1}" |
Andreas Schwab | 34fa78b | 2012-11-17 22:27:04 +0100 | [diff] [blame] | 38 | : "+o" (*set) |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 39 | : "id" ((_sig - 1) ^ 31) |
| 40 | : "cc"); |
| 41 | } |
| 42 | |
| 43 | static inline int __const_sigismember(sigset_t *set, int _sig) |
| 44 | { |
| 45 | unsigned long sig = _sig - 1; |
| 46 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
| 47 | } |
| 48 | |
| 49 | static inline int __gen_sigismember(sigset_t *set, int _sig) |
| 50 | { |
| 51 | int ret; |
| 52 | asm ("bfextu %1{%2,#1},%0" |
| 53 | : "=d" (ret) |
Andreas Schwab | 34fa78b | 2012-11-17 22:27:04 +0100 | [diff] [blame] | 54 | : "o" (*set), "id" ((_sig-1) ^ 31) |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 55 | : "cc"); |
| 56 | return ret; |
| 57 | } |
| 58 | |
| 59 | #define sigismember(set,sig) \ |
| 60 | (__builtin_constant_p(sig) ? \ |
| 61 | __const_sigismember(set,sig) : \ |
| 62 | __gen_sigismember(set,sig)) |
| 63 | |
Greg Ungerer | f3c23a2 | 2011-07-04 14:23:09 +1000 | [diff] [blame] | 64 | #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */ |
| 65 | |
Greg Ungerer | 8dba99e | 2009-03-16 22:10:08 +1000 | [diff] [blame] | 66 | #endif /* _M68K_SIGNAL_H */ |