mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 23:49:44 +02:00
* ARM: SetExceptionMask and SetRoundingMode must return the old value of mask/mode respectively, not the new one.
git-svn-id: trunk@27217 -
This commit is contained in:
parent
29bf988ca7
commit
67a8c315d8
@ -171,11 +171,9 @@ procedure VFP_SetCW(cw : dword); nostackframe; assembler;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetRoundMode: TFPURoundingMode;
|
function VFPCw2RoundingMode(cw: dword): TFPURoundingMode;
|
||||||
var
|
|
||||||
rm: byte;
|
|
||||||
begin
|
begin
|
||||||
case (VFP_GetCW and _VFP_ROUNDINGMODE_MASK) shr _VFP_ROUNDINGMODE_MASK_SHIFT of
|
case (cw and _VFP_ROUNDINGMODE_MASK) shr _VFP_ROUNDINGMODE_MASK_SHIFT of
|
||||||
0 : result := rmNearest;
|
0 : result := rmNearest;
|
||||||
1 : result := rmUp;
|
1 : result := rmUp;
|
||||||
2 : result := rmDown;
|
2 : result := rmDown;
|
||||||
@ -184,32 +182,28 @@ function GetRoundMode: TFPURoundingMode;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetRoundMode: TFPURoundingMode;
|
||||||
|
begin
|
||||||
|
result:=VFPCw2RoundingMode(VFP_GetCW);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
||||||
var
|
var
|
||||||
mode: dword;
|
mode: dword;
|
||||||
|
oldcw: dword;
|
||||||
begin
|
begin
|
||||||
softfloat_rounding_mode:=RoundMode;
|
softfloat_rounding_mode:=RoundMode;
|
||||||
|
oldcw:=VFP_GetCW;
|
||||||
case (RoundMode) of
|
case (RoundMode) of
|
||||||
rmNearest :
|
rmNearest : mode := 0;
|
||||||
begin
|
rmUp : mode := 1;
|
||||||
mode := 0;
|
rmDown : mode := 2;
|
||||||
end;
|
rmTruncate : mode := 3;
|
||||||
rmUp :
|
|
||||||
begin
|
|
||||||
mode := 1;
|
|
||||||
end;
|
|
||||||
rmDown :
|
|
||||||
begin
|
|
||||||
mode := 2;
|
|
||||||
end;
|
|
||||||
rmTruncate :
|
|
||||||
begin
|
|
||||||
mode := 3;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
mode:=mode shl _VFP_ROUNDINGMODE_MASK_SHIFT;
|
mode:=mode shl _VFP_ROUNDINGMODE_MASK_SHIFT;
|
||||||
VFP_SetCW((VFP_GetCW and (not _VFP_ROUNDINGMODE_MASK)) or mode);
|
VFP_SetCW((oldcw and (not _VFP_ROUNDINGMODE_MASK)) or mode);
|
||||||
result := RoundMode;
|
result := VFPCw2RoundingMode(oldcw);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -226,13 +220,9 @@ function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetExceptionMask: TFPUExceptionMask;
|
function VFPCw2ExceptionMask(cw: dword): TFPUExceptionMask;
|
||||||
var
|
|
||||||
cw : dword;
|
|
||||||
begin
|
begin
|
||||||
Result:=[];
|
Result:=[];
|
||||||
cw:=VFP_GetCW;
|
|
||||||
|
|
||||||
if (cw and _VFP_ENABLE_IM)=0 then
|
if (cw and _VFP_ENABLE_IM)=0 then
|
||||||
include(Result,exInvalidOp);
|
include(Result,exInvalidOp);
|
||||||
|
|
||||||
@ -253,11 +243,19 @@ function GetExceptionMask: TFPUExceptionMask;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetExceptionMask: TFPUExceptionMask;
|
||||||
|
begin
|
||||||
|
Result:=VFPCw2ExceptionMask(VFP_GetCW);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
|
function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
|
||||||
var
|
var
|
||||||
cw : dword;
|
cw : dword;
|
||||||
begin
|
begin
|
||||||
cw:=VFP_GetCW and not(_VFP_ENABLE_ALL);
|
cw:=VFP_GetCW;
|
||||||
|
Result:=VFPCw2ExceptionMask(cw);
|
||||||
|
cw:=cw and not(_VFP_ENABLE_ALL);
|
||||||
|
|
||||||
{$ifndef darwin}
|
{$ifndef darwin}
|
||||||
if not(exInvalidOp in Mask) then
|
if not(exInvalidOp in Mask) then
|
||||||
@ -279,8 +277,6 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
|
|||||||
cw:=cw or _VFP_ENABLE_PM;
|
cw:=cw or _VFP_ENABLE_PM;
|
||||||
{$endif}
|
{$endif}
|
||||||
VFP_SetCW(cw);
|
VFP_SetCW(cw);
|
||||||
result:=Mask;
|
|
||||||
|
|
||||||
softfloat_exception_mask:=Mask;
|
softfloat_exception_mask:=Mask;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -390,42 +386,11 @@ procedure FPU_SetCW(cw : dword); nostackframe; assembler;
|
|||||||
asm
|
asm
|
||||||
wfs r0
|
wfs r0
|
||||||
end;
|
end;
|
||||||
{$endif}
|
|
||||||
|
|
||||||
|
|
||||||
function GetRoundMode: TFPURoundingMode;
|
function FPUCw2ExceptionMask(cw: dword): TFPUExceptionMask;
|
||||||
begin
|
begin
|
||||||
GetRoundMode:=softfloat_rounding_mode;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
|
||||||
begin
|
|
||||||
softfloat_rounding_mode:=RoundMode;
|
|
||||||
SetRoundMode:=RoundMode;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function GetPrecisionMode: TFPUPrecisionMode;
|
|
||||||
begin
|
|
||||||
result := pmDouble;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode;
|
|
||||||
begin
|
|
||||||
{ does not apply }
|
|
||||||
result := pmDouble;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function GetExceptionMask: TFPUExceptionMask;
|
|
||||||
var
|
|
||||||
cw : dword;
|
|
||||||
begin
|
|
||||||
{$if not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
|
|
||||||
Result:=[];
|
Result:=[];
|
||||||
cw:=FPU_GetCW;
|
|
||||||
|
|
||||||
if (cw and _FPU_MASK_IM)=0 then
|
if (cw and _FPU_MASK_IM)=0 then
|
||||||
include(Result,exInvalidOp);
|
include(Result,exInvalidOp);
|
||||||
@ -444,6 +409,40 @@ function GetExceptionMask: TFPUExceptionMask;
|
|||||||
|
|
||||||
if (cw and _FPU_MASK_PM)=0 then
|
if (cw and _FPU_MASK_PM)=0 then
|
||||||
include(Result,exPrecision);
|
include(Result,exPrecision);
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
|
function GetRoundMode: TFPURoundingMode;
|
||||||
|
begin
|
||||||
|
GetRoundMode:=softfloat_rounding_mode;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
||||||
|
begin
|
||||||
|
result:=softfloat_rounding_mode;
|
||||||
|
softfloat_rounding_mode:=RoundMode;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetPrecisionMode: TFPUPrecisionMode;
|
||||||
|
begin
|
||||||
|
result := pmDouble;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode;
|
||||||
|
begin
|
||||||
|
{ does not apply }
|
||||||
|
result := pmDouble;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetExceptionMask: TFPUExceptionMask;
|
||||||
|
begin
|
||||||
|
{$if not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
|
||||||
|
Result:=FPUCw2ExceptionMask(FPU_GetCW);
|
||||||
{$else}
|
{$else}
|
||||||
Result:=softfloat_exception_mask;
|
Result:=softfloat_exception_mask;
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -455,7 +454,9 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
|
|||||||
cw : dword;
|
cw : dword;
|
||||||
begin
|
begin
|
||||||
{$if not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
|
{$if not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
|
||||||
cw:=FPU_GetCW or _FPU_MASK_ALL;
|
cw:=FPU_GetCW;
|
||||||
|
Result:=FPUCw2ExceptionMask(cw);
|
||||||
|
cw:=cw or _FPU_MASK_ALL;
|
||||||
|
|
||||||
if exInvalidOp in Mask then
|
if exInvalidOp in Mask then
|
||||||
cw:=cw and not(_FPU_MASK_IM);
|
cw:=cw and not(_FPU_MASK_IM);
|
||||||
@ -476,14 +477,16 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
|
|||||||
cw:=cw and not(_FPU_MASK_PM);
|
cw:=cw and not(_FPU_MASK_PM);
|
||||||
|
|
||||||
FPU_SetCW(cw);
|
FPU_SetCW(cw);
|
||||||
|
{$else}
|
||||||
|
Result:=softfloat_exception_mask;
|
||||||
{$endif}
|
{$endif}
|
||||||
softfloat_exception_mask:=Mask;
|
softfloat_exception_mask:=Mask;
|
||||||
Result:=Mask;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure ClearExceptions(RaisePending: Boolean =true);
|
procedure ClearExceptions(RaisePending: Boolean =true);
|
||||||
begin
|
begin
|
||||||
|
softfloat_exception_flags:=[];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$endif wince}
|
{$endif wince}
|
||||||
|
Loading…
Reference in New Issue
Block a user