^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _M68K_SIGNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _M68K_SIGNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <uapi/asm/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /* Most things should be clean enough to redefine this at will, if care
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) is taken to make libc match. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _NSIG 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _NSIG_BPW 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) typedef unsigned long old_sigset_t; /* at least 32 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) unsigned long sig[_NSIG_WORDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) } sigset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define __ARCH_HAS_SA_RESTORER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/sigcontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #ifndef CONFIG_CPU_HAS_NO_BITFIELDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define __HAVE_ARCH_SIG_BITOPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static inline void sigaddset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) asm ("bfset %0{%1,#1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) : "+o" (*set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) : "id" ((_sig - 1) ^ 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) : "cc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static inline void sigdelset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) asm ("bfclr %0{%1,#1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) : "+o" (*set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) : "id" ((_sig - 1) ^ 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) : "cc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static inline int __const_sigismember(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned long sig = _sig - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static inline int __gen_sigismember(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) asm ("bfextu %1{%2,#1},%0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) : "=d" (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) : "o" (*set), "id" ((_sig-1) ^ 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) : "cc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define sigismember(set,sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) (__builtin_constant_p(sig) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __const_sigismember(set,sig) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) __gen_sigismember(set,sig))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #endif /* _M68K_SIGNAL_H */