Browse Source

* simplify SysResetFPU

florian 8 months ago
parent
commit
73e96f8f1e
2 changed files with 14 additions and 15 deletions
  1. 1 1
      rtl/riscv32/riscv32.inc
  2. 13 14
      rtl/x86_64/x86_64.inc

+ 1 - 1
rtl/riscv32/riscv32.inc

@@ -90,7 +90,7 @@ begin
   softfloat_exception_mask:=[exPrecision,exUnderflow];
 {$ifdef FPUFD}
   cw:=GetNativeFPUControlWord;
-  { riscv does not support triggering exceptoins when FPU exceptions happen;
+  { riscv does not support triggering exceptions when FPU exceptions happen;
     it merely records which exceptions have happened until now -> clear }
   cw.cw:=0;
   { round to nearest }

+ 13 - 14
rtl/x86_64/x86_64.inc

@@ -1621,20 +1621,19 @@ end;
 
 
 {$define FPC_SYSTEM_HAS_SYSRESETFPU}
-Procedure SysResetFPU;
-  var
-    { these locals are so we don't have to hack pic code in the assembler }
-    localmxcsr: dword;
-    localfpucw: word;
-  begin
-    localfpucw:=Default8087CW;
-    localmxcsr:=DefaultMXCSR;
-    asm
-      fninit
-      fwait
-      fldcw   localfpucw
-      ldmxcsr localmxcsr
-    end;
+Procedure SysResetFPU;assembler;nostackframe;
+  asm
+    fninit
+    fwait
+{$ifdef FPC_PIC}
+    movq  Default8087CW@GOTPCREL(%rip),%rax
+    fldcw (%rax)
+    movq  DefaultMXCSR@GOTPCREL(%rip),%rax
+    ldmxcsr (%rax)
+{$else FPC_PIC}
+    fldcw   Default8087CW(%rip)
+    ldmxcsr DefaultMXCSR(%rip)
+{$endif FPC_PIC}
   end;