Browse Source

* Fixed Linux FPU exception mapping for x86_64 and MIPS, might be still incomplete, but at least operations yielding NaNs no longer produce EAccessViolation.

git-svn-id: trunk@27194 -
sergei 11 years ago
parent
commit
7ba4e67564
2 changed files with 7 additions and 11 deletions
  1. 2 6
      rtl/linux/mips/sighnd.inc
  2. 5 5
      rtl/linux/x86_64/sighnd.inc

+ 2 - 6
rtl/linux/mips/sighnd.inc

@@ -31,19 +31,15 @@ begin
           
           case  siginfo^.si_code of
             FPE_INTDIV:
-              res:=200;
+              res:=200;  // maps to EDivByZero
             FPE_INTOVF:
               res:=215;
             FPE_FLTDIV:
-              res:=200;
+              res:=208;  // maps to EZeroDivide
             FPE_FLTOVF:
               res:=205;
             FPE_FLTUND:
               res:=206;
-            FPE_FLTRES,
-            FPE_FLTINV,
-            FPE_FLTSUB:
-              res:=216;
             else
               res:=207;
           end;

+ 5 - 5
rtl/linux/x86_64/sighnd.inc

@@ -22,9 +22,11 @@ const
 function GetFPUState(const SigContext : TSigContext) : word;
   begin
     if assigned(SigContext.fpstate) then
-      GetfpuState:=SigContext.fpstate^.swd;
+      GetfpuState:=SigContext.fpstate^.swd
+    else
+      GetFPUState:=0;
   {$ifdef SYSTEM_DEBUG}
-    writeln('xx:',sigcontext.en_tw,' ',sigcontext.en_cw);
+    writeln('xx:',sigcontext.twd,' ',sigcontext.cwd);
   {$endif SYSTEM_DEBUG}
   {$ifdef SYSTEM_DEBUG}
     Writeln(stderr,'FpuState = ',result);
@@ -55,10 +57,8 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigCon
                 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_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
                 res:=207
-              else if (FpuState and FPU_Invalid)<>0 then
-                res:=216
               else
                 res:=207;  {'Coprocessor Error'}
             end;