Pārlūkot izejas kodu

+ fixed startup hang in the i8086-msdos rtl on systems without an FPU

git-svn-id: trunk@24455 -
nickysn 12 gadi atpakaļ
vecāks
revīzija
f1861a71d6
2 mainītis faili ar 14 papildinājumiem un 1 dzēšanām
  1. 12 0
      rtl/i8086/i8086.inc
  2. 2 1
      rtl/msdos/system.pp

+ 12 - 0
rtl/i8086/i8086.inc

@@ -136,6 +136,18 @@ const
   fpucw : word = $1300 or FPU_StackUnderflow or FPU_Underflow or FPU_Denormal;
   }
 
+{ returns true if FPU is present }
+function DetectFPU: boolean;
+  var
+    localfpucw: word;
+  begin
+    asm
+      fninit
+      mov byte [localfpucw + 1], 0
+      fnstcw localfpucw
+    end;
+    DetectFPU:=(localfpucw and $FF00)=$0300;
+  end;
 
 {$define FPC_SYSTEM_HAS_SYSINITFPU}
 Procedure SysInitFPU;

+ 2 - 1
rtl/msdos/system.pp

@@ -214,7 +214,8 @@ end;
 begin
   StackLength := CheckInitialStkLen(InitialStkLen);
   StackBottom := __stkbottom;
-  SysInitFPU;
+  if DetectFPU then
+    SysInitFPU;
   { To be set if this is a GUI or console application }
   IsConsole := TRUE;
   { To be set if this is a library and not a program  }