18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_SIGNAL_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_SIGNAL_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 68c2ecf20Sopenharmony_ci#include <linux/linkage.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* Most things should be clean enough to redefine this at will, if care 98c2ecf20Sopenharmony_ci is taken to make libc match. */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define _NSIG 64 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifdef __i386__ 148c2ecf20Sopenharmony_ci# define _NSIG_BPW 32 158c2ecf20Sopenharmony_ci#else 168c2ecf20Sopenharmony_ci# define _NSIG_BPW 64 178c2ecf20Sopenharmony_ci#endif 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define _NSIG_WORDS (_NSIG / _NSIG_BPW) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_citypedef unsigned long old_sigset_t; /* at least 32 bits */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_citypedef struct { 248c2ecf20Sopenharmony_ci unsigned long sig[_NSIG_WORDS]; 258c2ecf20Sopenharmony_ci} sigset_t; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */ 288c2ecf20Sopenharmony_ci#define SA_IA32_ABI 0x02000000u 298c2ecf20Sopenharmony_ci#define SA_X32_ABI 0x01000000u 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#ifndef CONFIG_COMPAT 328c2ecf20Sopenharmony_citypedef sigset_t compat_sigset_t; 338c2ecf20Sopenharmony_ci#endif 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 368c2ecf20Sopenharmony_ci#include <uapi/asm/signal.h> 378c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define __ARCH_HAS_SA_RESTORER 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#include <asm/asm.h> 428c2ecf20Sopenharmony_ci#include <uapi/asm/sigcontext.h> 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#ifdef __i386__ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define __HAVE_ARCH_SIG_BITOPS 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define sigaddset(set,sig) \ 498c2ecf20Sopenharmony_ci (__builtin_constant_p(sig) \ 508c2ecf20Sopenharmony_ci ? __const_sigaddset((set), (sig)) \ 518c2ecf20Sopenharmony_ci : __gen_sigaddset((set), (sig))) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic inline void __gen_sigaddset(sigset_t *set, int _sig) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic inline void __const_sigaddset(sigset_t *set, int _sig) 598c2ecf20Sopenharmony_ci{ 608c2ecf20Sopenharmony_ci unsigned long sig = _sig - 1; 618c2ecf20Sopenharmony_ci set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define sigdelset(set, sig) \ 658c2ecf20Sopenharmony_ci (__builtin_constant_p(sig) \ 668c2ecf20Sopenharmony_ci ? __const_sigdelset((set), (sig)) \ 678c2ecf20Sopenharmony_ci : __gen_sigdelset((set), (sig))) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline void __gen_sigdelset(sigset_t *set, int _sig) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic inline void __const_sigdelset(sigset_t *set, int _sig) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci unsigned long sig = _sig - 1; 788c2ecf20Sopenharmony_ci set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistatic inline int __const_sigismember(sigset_t *set, int _sig) 828c2ecf20Sopenharmony_ci{ 838c2ecf20Sopenharmony_ci unsigned long sig = _sig - 1; 848c2ecf20Sopenharmony_ci return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistatic inline int __gen_sigismember(sigset_t *set, int _sig) 888c2ecf20Sopenharmony_ci{ 898c2ecf20Sopenharmony_ci bool ret; 908c2ecf20Sopenharmony_ci asm("btl %2,%1" CC_SET(c) 918c2ecf20Sopenharmony_ci : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1)); 928c2ecf20Sopenharmony_ci return ret; 938c2ecf20Sopenharmony_ci} 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define sigismember(set, sig) \ 968c2ecf20Sopenharmony_ci (__builtin_constant_p(sig) \ 978c2ecf20Sopenharmony_ci ? __const_sigismember((set), (sig)) \ 988c2ecf20Sopenharmony_ci : __gen_sigismember((set), (sig))) 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistruct pt_regs; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#else /* __i386__ */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#undef __HAVE_ARCH_SIG_BITOPS 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#endif /* !__i386__ */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 1098c2ecf20Sopenharmony_ci#endif /* _ASM_X86_SIGNAL_H */ 110