1/* 2 * host-signal.h: signal info dependent on the host architecture 3 * 4 * Copyright (c) 2003-2005 Fabrice Bellard 5 * Copyright (c) 2021 Linaro Limited 6 * 7 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. 8 * See the COPYING file in the top-level directory. 9 */ 10 11#ifndef ALPHA_HOST_SIGNAL_H 12#define ALPHA_HOST_SIGNAL_H 13 14/* The third argument to a SA_SIGINFO handler is ucontext_t. */ 15typedef ucontext_t host_sigcontext; 16 17static inline uintptr_t host_signal_pc(host_sigcontext *uc) 18{ 19 return uc->uc_mcontext.sc_pc; 20} 21 22static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) 23{ 24 uc->uc_mcontext.sc_pc = pc; 25} 26 27static inline void *host_signal_mask(host_sigcontext *uc) 28{ 29 return &uc->uc_sigmask; 30} 31 32static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) 33{ 34 uint32_t *pc = (uint32_t *)host_signal_pc(uc); 35 uint32_t insn = *pc; 36 37 /* XXX: need kernel patch to get write flag faster */ 38 switch (insn >> 26) { 39 case 0x0d: /* stw */ 40 case 0x0e: /* stb */ 41 case 0x0f: /* stq_u */ 42 case 0x24: /* stf */ 43 case 0x25: /* stg */ 44 case 0x26: /* sts */ 45 case 0x27: /* stt */ 46 case 0x2c: /* stl */ 47 case 0x2d: /* stq */ 48 case 0x2e: /* stl_c */ 49 case 0x2f: /* stq_c */ 50 return true; 51 } 52 return false; 53} 54 55#endif 56