From bfd7862ee65a39ac97cfe39987f538e7c0004d85 Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Wed, 13 Jan 2010 17:04:52 +0800 Subject: [PATCH] Bug 538339 In fpehandler() mask cw and back to the faulting x87 instruction on Solaris r=gal,bsmedberg --- toolkit/xre/nsSigHandlers.cpp | 27 +++++++++++++++++++++++++++ toolkit/xre/nsSigHandlers.h | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/toolkit/xre/nsSigHandlers.cpp b/toolkit/xre/nsSigHandlers.cpp index 215b6e25b5e..ce2450ecf7a 100644 --- a/toolkit/xre/nsSigHandlers.cpp +++ b/toolkit/xre/nsSigHandlers.cpp @@ -64,6 +64,7 @@ #if defined(SOLARIS) #include +#include #endif #ifdef XP_BEOS @@ -259,6 +260,32 @@ static void fpehandler(int signum, siginfo_t *si, void *context) *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */ #endif #endif +#ifdef SOLARIS + ucontext_t *uc = (ucontext_t *)context; + +#if defined(__i386) + uint32_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[0]; + *cw |= FPU_EXCEPTION_MASK; + + uint32_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[1]; + *sw &= ~FPU_STATUS_FLAGS; + + /* address of the instruction that caused the exception */ + uint32_t *ip = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[3]; + uc->uc_mcontext.gregs[REG_PC] = *ip; +#endif +#if defined(__amd64__) + uint16_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw; + *cw |= FPU_EXCEPTION_MASK; + + uint16_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.sw; + *sw &= ~FPU_STATUS_FLAGS; + + uint32_t *mxcsr = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr; + *mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */ + *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */ +#endif +#endif } void InstallSignalHandlers(const char *ProgramName) diff --git a/toolkit/xre/nsSigHandlers.h b/toolkit/xre/nsSigHandlers.h index 6f7640e0574..af7520033c2 100644 --- a/toolkit/xre/nsSigHandlers.h +++ b/toolkit/xre/nsSigHandlers.h @@ -36,7 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ -#if defined(_M_IX86) || defined(__i386__) || defined(__amd64__) +#if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(__amd64__) /* * x87 FPU Control Word: