From d8ecc0b9131a229ff6e8fbe5d3a0b284b1620452 Mon Sep 17 00:00:00 2001 From: bellard Date: Mon, 5 Feb 2007 21:41:46 +0000 Subject: [PATCH] Make cpu_signal_handler work on Mac OS X/Darwin x86 git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2400 c046a42c-6fe2-441c-8c8c-71466251a162 --- cpu-exec.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 0b57f0fdc4..058688fc77 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -1176,6 +1176,18 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address, #if defined(__i386__) +#if defined(__APPLE__) +# include + +# define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.eip)) +# define TRAP_sig(context) ((context)->uc_mcontext->es.trapno) +# define ERROR_sig(context) ((context)->uc_mcontext->es.err) +#else +# define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) +# define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) +# define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) +#endif + #if defined(USE_CODE_COPY) static void cpu_send_trap(unsigned long pc, int trap, struct ucontext *uc) @@ -1210,8 +1222,8 @@ int cpu_signal_handler(int host_signum, void *pinfo, #define REG_ERR ERR #define REG_TRAPNO TRAPNO #endif - pc = uc->uc_mcontext.gregs[REG_EIP]; - trapno = uc->uc_mcontext.gregs[REG_TRAPNO]; + pc = EIP_sig(uc); + trapno = TRAP_sig(uc); #if defined(TARGET_I386) && defined(USE_CODE_COPY) if (trapno == 0x00 || trapno == 0x05) { /* send division by zero or bound exception */ @@ -1221,7 +1233,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, #endif return handle_cpu_signal(pc, (unsigned long)info->si_addr, trapno == 0xe ? - (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0, + (ERROR_sig(uc) >> 1) & 1 : 0, &uc->uc_sigmask, puc); }