./trunk/gcc220/vcs_diff_rtl.patch 2026-11-09-15:00
> uname -a OpenBSD cfarm220.cfarm.net 8.0 GENERIC.MP#2 amd64
diff --git a/rtl/openbsd/x86_64/sighnd.inc b/rtl/openbsd/x86_64/sighnd.inc
index f3abb5d04d..81a78cb1ee 100644
--- a/rtl/openbsd/x86_64/sighnd.inc
+++ b/rtl/openbsd/x86_64/sighnd.inc
@@ -15,53 +15,39 @@
CONST FPU_ALL=$7F;
-{$ifdef cpux86_64}
-function getfpustate(sininfo:psiginfo):longint; {inline;}
+function getaltfpustate(sigcontext:psigcontextrec):word; {inline;}
begin
- if ptruint(sininfo)> high(word) then
- getfpustate:=sininfo^.si_code
+ if assigned(sigcontext) then
+ getaltfpustate:=word(sigcontext^.sc_fpstate^.fx_fsw)
else
- getfpustate:=word(ptruint(sininfo));
+ getaltfpustate:=0;
end;
-function getaltfpustate(sigcontext:psigcontextrec):longint; {inline;}
+function getmmxstate(sigcontext:psigcontextrec):word; {inline;}
begin
if assigned(sigcontext) then
- begin
- getaltfpustate:=sigcontext^.sc_fpstate^.fx_fsw;
- if getaltfpustate=0 then
- getaltfpustate:=sigcontext^.sc_fpstate^.fx_mxcsr;
- end
+ getmmxstate:=word(sigcontext^.sc_fpstate^.fx_mxcsr)
else
- getaltfpustate:=0;
+ getmmxstate:=0;
end;
-{$endif}
procedure SignalToRunerror(Sig: longint;sininfo:psiginfo; SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
var
- res,fpustate : word;
+ res,fpustate,mmxstate : word;
begin
res:=0;
-{$ifdef BSD}
-{$ifdef cpux86_64}
fpustate:=0;
asm
fnstsw fpustate
end;
-{$endif cpux86_64}
-{$endif BSD}
case sig of
SIGFPE :
begin
{ this is not always necessary but I don't know yet
how to tell if it is or not PM }
res:=200;
-{$ifdef cpux86_64}
fpustate:=GetaltFPUState(sigcontext);
-{$else}
- fpustate:=0;
-{$endif}
if (FpuState and FPU_All) <> 0 then
begin
{ first check the more precise options }
@@ -79,6 +65,26 @@ procedure SignalToRunerror(Sig: longint;sininfo:psiginfo; SigContext: PSigContex
res:=207
else
res:=207; {'Coprocessor Error'}
+ end
+ else
+ begin
+ fpustate:=getmmxstate(sigcontext);
+ if (FpuState and MM_ExceptionMask)<>0 then
+ begin
+ { first check the more precise options }
+ if (FpuState and MM_DivisionByZero)<>0 then
+ res:=208
+ else if (FpuState and MM_Overflow)<>0 then
+ res:=205
+ else if (FpuState and MM_Underflow)<>0 then
+ res:=206
+ else if (FpuState and MM_Denormal)<>0 then
+ res:=207
+ else if (FpuState and MM_Precicion)<>0 then
+ res:=207
+ else
+ res:=207; {'Coprocessor Error'}
+ end;
end;
SysResetFPU;
end;
@@ -94,11 +100,7 @@ procedure SignalToRunerror(Sig: longint;sininfo:psiginfo; SigContext: PSigContex
reenable_signal(sig);
{ give runtime error at the position where the signal was raised }
if res<>0 then
- begin
-{$ifdef cpux86_64}
- HandleErrorAddrFrame(res,pointer(SigContext^.sc_rip),pointer(SigContext^.sc_rbp));
-{$endif}
- end;
+ HandleErrorAddrFrame(res,pointer(SigContext^.sc_rip),pointer(SigContext^.sc_rbp));
end;