162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _M68K_SIGNAL_H 362306a36Sopenharmony_ci#define _M68K_SIGNAL_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <uapi/asm/signal.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci/* Most things should be clean enough to redefine this at will, if care 862306a36Sopenharmony_ci is taken to make libc match. */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define _NSIG 64 1162306a36Sopenharmony_ci#define _NSIG_BPW 32 1262306a36Sopenharmony_ci#define _NSIG_WORDS (_NSIG / _NSIG_BPW) 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_citypedef unsigned long old_sigset_t; /* at least 32 bits */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_citypedef struct { 1762306a36Sopenharmony_ci unsigned long sig[_NSIG_WORDS]; 1862306a36Sopenharmony_ci} sigset_t; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define __ARCH_HAS_SA_RESTORER 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#include <asm/sigcontext.h> 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#ifndef CONFIG_CPU_HAS_NO_BITFIELDS 2562306a36Sopenharmony_ci#define __HAVE_ARCH_SIG_BITOPS 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistatic inline void sigaddset(sigset_t *set, int _sig) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci asm ("bfset %0{%1,#1}" 3062306a36Sopenharmony_ci : "+o" (*set) 3162306a36Sopenharmony_ci : "id" ((_sig - 1) ^ 31) 3262306a36Sopenharmony_ci : "cc"); 3362306a36Sopenharmony_ci} 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_cistatic inline void sigdelset(sigset_t *set, int _sig) 3662306a36Sopenharmony_ci{ 3762306a36Sopenharmony_ci asm ("bfclr %0{%1,#1}" 3862306a36Sopenharmony_ci : "+o" (*set) 3962306a36Sopenharmony_ci : "id" ((_sig - 1) ^ 31) 4062306a36Sopenharmony_ci : "cc"); 4162306a36Sopenharmony_ci} 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistatic inline int __const_sigismember(sigset_t *set, int _sig) 4462306a36Sopenharmony_ci{ 4562306a36Sopenharmony_ci unsigned long sig = _sig - 1; 4662306a36Sopenharmony_ci return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); 4762306a36Sopenharmony_ci} 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_cistatic inline int __gen_sigismember(sigset_t *set, int _sig) 5062306a36Sopenharmony_ci{ 5162306a36Sopenharmony_ci int ret; 5262306a36Sopenharmony_ci asm ("bfextu %1{%2,#1},%0" 5362306a36Sopenharmony_ci : "=d" (ret) 5462306a36Sopenharmony_ci : "o" (*set), "id" ((_sig-1) ^ 31) 5562306a36Sopenharmony_ci : "cc"); 5662306a36Sopenharmony_ci return ret; 5762306a36Sopenharmony_ci} 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define sigismember(set,sig) \ 6062306a36Sopenharmony_ci (__builtin_constant_p(sig) ? \ 6162306a36Sopenharmony_ci __const_sigismember(set,sig) : \ 6262306a36Sopenharmony_ci __gen_sigismember(set,sig)) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#endif /* _M68K_SIGNAL_H */ 67