Browse Source

* win64 has always SetThreadStackGuarantee

florian 1 year ago
parent
commit
acb6c7f36b
3 changed files with 9 additions and 3 deletions
  1. 6 0
      rtl/win/sysos.inc
  2. 2 0
      rtl/win/systhrd.inc
  3. 1 3
      rtl/win64/system.pp

+ 6 - 0
rtl/win/sysos.inc

@@ -273,8 +273,14 @@ type
   function GetModuleHandle(p : PAnsiChar) : THandle;
     stdcall;external KernelDLL name 'GetModuleHandleA';
 
+{$ifdef win64}
+  { all win64 versions have this function, including 64 bit XP }
+  function SetThreadStackGuarantee(StackSizeInBytes : PPtrUint) : BOOL;
+    stdcall;external KernelDLL name 'SetThreadStackGuarantee';
+{$else win64}
 var
   SetThreadStackGuarantee: function(StackSizeInBytes : PPtrUint) : BOOL; stdcall;
+{$endif win64}
 {$else WINCE}
 
    { module functions }

+ 2 - 0
rtl/win/systhrd.inc

@@ -230,7 +230,9 @@ var
           begin
             InitThread(ti.stklen);
 {$ifndef wince}
+{$ifdef win32}
             if Assigned(SetThreadStackGuarantee) then
+{$endif win32}
               SetThreadStackGuarantee(@StackMargin);
 {$endif wince}            
           end;

+ 1 - 3
rtl/win64/system.pp

@@ -478,9 +478,7 @@ initialization
   { pass dummy value }
   StackLength := CheckInitialStkLen($1000000);
   StackBottom := StackTop - StackLength;
-  CodePointer(SetThreadStackGuarantee) := WinGetProcAddress(WinGetModuleHandleW(KernelDLL), 'SetThreadStackGuarantee');
-  if Assigned(SetThreadStackGuarantee) then
-    SetThreadStackGuarantee(@StackMargin);
+  SetThreadStackGuarantee(@StackMargin);
   
   { get some helpful informations }
   GetStartupInfo(@startupinfo);