Browse Source

* SPARC: SetExceptionMask and SetRoundingMode must return the old value of mask/mode respectively, not the new one.

git-svn-id: trunk@27218 -
sergei 11 years ago
parent
commit
295e795a0a
1 changed files with 12 additions and 6 deletions
  1. 12 6
      rtl/sparc/mathu.inc

+ 12 - 6
rtl/sparc/mathu.inc

@@ -22,9 +22,12 @@ function GetRoundMode: TFPURoundingMode;
   end;
   end;
 
 
 function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
 function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
+  var
+    cw: dword;
   begin
   begin
-    set_fsr((get_fsr and $3fffffff) or (dword(RoundMode) shl 30));
-    result:=TFPURoundingMode(get_fsr shr 30);
+    cw:=get_fsr;
+    result:=TFPURoundingMode(cw shr 30);
+    set_fsr((cw and $3fffffff) or (dword(RoundMode) shl 30));
   end;
   end;
 
 
 
 
@@ -40,11 +43,8 @@ function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode
   end;
   end;
 
 
 
 
-function GetExceptionMask: TFPUExceptionMask;
-  var
-    fsr : dword;
+function FSR2ExceptionMask(fsr: dword): TFPUExceptionMask;
   begin
   begin
-    fsr:=get_fsr;
     result:=[];
     result:=[];
     { invalid operation: bit 27 }
     { invalid operation: bit 27 }
     if (fsr and (1 shl 27))=0 then
     if (fsr and (1 shl 27))=0 then
@@ -68,12 +68,18 @@ function GetExceptionMask: TFPUExceptionMask;
   end;
   end;
 
 
 
 
+function GetExceptionMask: TFPUExceptionMask;
+  begin
+    result:=FSR2ExceptionMask(get_fsr);
+  end;
+
 
 
 function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
 function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
   var
   var
     fsr : dword;
     fsr : dword;
   begin
   begin
     fsr:=get_fsr;
     fsr:=get_fsr;
+    result:=FSR2ExceptionMask(fsr);
 
 
     { invalid operation: bit 27 }
     { invalid operation: bit 27 }
     if (exInvalidOp in mask) then
     if (exInvalidOp in mask) then