mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 22:47:54 +02:00
Fix conversion between TFPURoundMode and bits of get_fsr according to SPARC-V8 specifications
git-svn-id: trunk@45781 -
This commit is contained in:
parent
7020490f81
commit
8cf26b7a0f
@ -16,21 +16,26 @@
|
||||
function get_fsr : dword;external name 'FPC_GETFSR';
|
||||
procedure set_fsr(fsr : dword);external name 'FPC_SETFSR';
|
||||
|
||||
|
||||
function GetRoundMode: TFPURoundingMode;
|
||||
const
|
||||
bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmTruncate,rmUp,rmDown);
|
||||
begin
|
||||
result:=TFPURoundingMode(get_fsr shr 30);
|
||||
result:=TFPURoundingMode(bits2rm[(get_fsr shr 30) and 3])
|
||||
end;
|
||||
|
||||
|
||||
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
||||
const
|
||||
rm2bits: array[TFPURoundingMode] of byte = (0,3,2,1);
|
||||
var
|
||||
cw: dword;
|
||||
begin
|
||||
cw:=get_fsr;
|
||||
result:=TFPURoundingMode(cw shr 30);
|
||||
set_fsr((cw and $3fffffff) or (dword(RoundMode) shl 30));
|
||||
set_fsr((cw and $3fffffff) or (rm2bits[RoundMode] shl 30));
|
||||
end;
|
||||
|
||||
|
||||
function GetPrecisionMode: TFPUPrecisionMode;
|
||||
begin
|
||||
result:=pmDouble;
|
||||
|
@ -17,17 +17,22 @@ function get_fsr : dword;external name 'FPC_GETFSR';
|
||||
procedure set_fsr(fsr : dword);external name 'FPC_SETFSR';
|
||||
|
||||
function GetRoundMode: TFPURoundingMode;
|
||||
const
|
||||
bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmTruncate,rmUp,rmDown);
|
||||
begin
|
||||
result:=TFPURoundingMode(get_fsr shr 30);
|
||||
result:=TFPURoundingMode(bits2rm[(get_fsr shr 30) and 3])
|
||||
end;
|
||||
|
||||
|
||||
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
|
||||
const
|
||||
rm2bits: array[TFPURoundingMode] of byte = (0,3,2,1);
|
||||
var
|
||||
cw: dword;
|
||||
begin
|
||||
cw:=get_fsr;
|
||||
result:=TFPURoundingMode(cw shr 30);
|
||||
set_fsr((cw and $3fffffff) or (dword(RoundMode) shl 30));
|
||||
set_fsr((cw and $3fffffff) or (rm2bits[RoundMode] shl 30));
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user