* reset exception flags, resolves on x86_64

git-svn-id: trunk@45995 -
This commit is contained in:
florian 2020-08-02 21:23:29 +00:00
parent 0863291e07
commit eac6675cba
4 changed files with 43 additions and 9 deletions
.gitattributes
rtl/linux
tests/webtbs

1
.gitattributes vendored
View File

@ -18400,6 +18400,7 @@ tests/webtbs/tw37400.pp svneol=native#text/pascal
tests/webtbs/tw3742.pp svneol=native#text/plain
tests/webtbs/tw37427.pp svneol=native#text/pascal
tests/webtbs/tw37449.pp svneol=native#text/pascal
tests/webtbs/tw37468.pp svneol=native#text/pascal
tests/webtbs/tw3751.pp svneol=native#text/plain
tests/webtbs/tw3758.pp svneol=native#text/plain
tests/webtbs/tw3764.pp svneol=native#text/plain

View File

@ -76,17 +76,16 @@ begin
res:=207; {'Coprocessor Error'}
end;
end;
with ucontext^.uc_mcontext.fpstate^ do
begin
{ Reset Status word }
sw:=sw and not FPU_ExceptionMask;
{ Restoree default control word }
cw:=Default8087CW;
{ Reset Tag word to $ffff for all empty }
tag:=$ffff;
end;
end;
end;
if assigned(ucontext^.uc_mcontext.fpstate) then
with ucontext^.uc_mcontext.fpstate^ do
begin
{ Reset Status word }
sw:=sw and not(FPU_ExceptionMask);
mxcsr:=mxcsr and not(MM_ExceptionMask);
SysResetFPU;
end;
end;
SIGBUS:
res:=214;

View File

@ -81,6 +81,11 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigCon
res:=207
else
res:=207; {'Coprocessor Error'}
{ exceptions are handled, clear all flags
as we return from SignalToRunerrer, we have to clear the exception flags in the context }
if assigned(SigContext^.fpstate) then
SigContext^.fpstate^.swd:=SigContext^.fpstate^.swd and not(FPU_All);
end;
MMState:=getMMState(SigContext^);
if (MMState and MM_ExceptionMask)<>0 then
@ -98,6 +103,11 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigCon
res:=216
else
res:=207; {'Coprocessor Error'}
{ exceptions are handled, clear all flags
as we return from SignalToRunerrer, we have to clear the exception flags in the context }
if assigned(SigContext^.fpstate) then
SigContext^.fpstate^.mxcsr:=SigContext^.fpstate^.mxcsr and not(MM_ExceptionMask);
end;
end;
SysResetFPU;

24
tests/webtbs/tw37468.pp Normal file
View File

@ -0,0 +1,24 @@
program Project1;
{$mode objfpc}{$H+}
uses
math, sysutils;
var
a,b: double;
begin
a := 0;
b := -3;
try
try
writeln(power(a,b));
except
on e: EDivByZero do begin
writeln(Infinity);
end;
end;
except
halt(1);
end;
writeln('ok');
end.