From 2d6ca8a363b445df506b96b78560d2e21cd3b9bd Mon Sep 17 00:00:00 2001 From: pierre Date: Sun, 12 Feb 2012 22:55:23 +0000 Subject: [PATCH] * Fix code for SIGFPE and adapt to SignalHandler procedure type change git-svn-id: trunk@20332 - --- rtl/netbsd/i386/sighnd.inc | 50 +++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/rtl/netbsd/i386/sighnd.inc b/rtl/netbsd/i386/sighnd.inc index a83655ec28..46bb3f927f 100644 --- a/rtl/netbsd/i386/sighnd.inc +++ b/rtl/netbsd/i386/sighnd.inc @@ -13,13 +13,29 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } -CONST FPU_ALL=$7F; +{ +/* SIGFPE */ +#define FPE_INTDIV 1 /* Integer divide by zero */ +#define FPE_INTOVF 2 /* Integer overflow */ +#define FPE_FLTDIV 3 /* Floating point divide by zero */ +#define FPE_FLTOVF 4 /* Floating point overflow */ +#define FPE_FLTUND 5 /* Floating point underflow */ +#define FPE_FLTRES 6 /* Floating point inexact result */ +#define FPE_FLTINV 7 /* Invalid Floating point operation */ +#define FPE_FLTSUB 8 /* Subscript out of range */ +} -function getfpustate(const Sigcontext:sigcontextRec):longint; {inline;} -begin - getfpustate:=0; -end; -procedure SignalToRunerror(Sig: longint;code:longint; var SigContext: SigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; +const + FPE_IntDiv = 1; + FPE_IntOvf = 2; + FPE_FltDiv = 3; + FPE_FltOvf = 4; + FPE_FltUnd = 5; + FPE_FltRes = 6; + FPE_FltInv = 7; + FPE_FltSub = 8; + +procedure SignalToRunerror(Sig: longint;info : PSigInfo;SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; var res,fpustate : word; @@ -39,22 +55,22 @@ begin { this is not allways necessary but I don't know yet how to tell if it is or not PM } res:=200; - fpustate:=GetFPUState(SigContext); + fpustate:=info^._info.si_code; - if (FpuState and FPU_All) <> 0 then - begin + { if (FpuState and FPU_All) <> 0 then } + begin { first check the more precise options } - if (FpuState and FPU_DivisionByZero)<>0 then + if FpuState = FPE_IntDiv then res:=200 - else if (FpuState and FPU_Overflow)<>0 then + else if (FpuState = FPE_IntOvf) or (FpuState = FPE_FltOvf) then res:=205 - else if (FpuState and FPU_Underflow)<>0 then + else if FpuState = FPE_FltUnd then res:=206 - else if (FpuState and FPU_Denormal)<>0 then - res:=216 - else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow))<>0 then + { else if FpuState and FPU_Denormal)<>0 then + res:=216 } + else if FpuState = FPE_FltSub then res:=207 - else if (FpuState and FPU_Invalid)<>0 then + else if FpuState = FPE_FltInv then res:=216 else res:=207; {'Coprocessor Error'} @@ -75,7 +91,7 @@ begin if res<>0 then begin {$ifdef cpui386} - HandleErrorAddrFrame(res,pointer(SigContext.sc_eip),pointer(SigContext.sc_ebp)); + HandleErrorAddrFrame(res,pointer(SigContext^.sc_eip),pointer(SigContext^.sc_ebp)); {$endif} end; end;