Selaa lähdekoodia

* stack related things (sizes, calculations, etc.) are now 64 bit on 64 bit platforms
* default stack size is now also 32k for Windows (allows the use of stack checking when using threads)

git-svn-id: trunk@1718 -

tom_at_work 20 vuotta sitten
vanhempi
commit
367df58016

+ 6 - 6
compiler/pmodules.pas

@@ -360,14 +360,14 @@ implementation
       begin
         { stacksize can be specified and is now simulated }
         maybe_new_object_file(asmlist[al_globals]);
-        new_section(asmlist[al_globals],sec_data,'__stklen',4);
-        asmlist[al_globals].concat(Tai_symbol.Createname_global('__stklen',AT_DATA,4));
-        asmlist[al_globals].concat(Tai_const.Create_32bit(stacksize));
+        new_section(asmlist[al_globals],sec_data,'__stklen', sizeof(aint));
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('__stklen',AT_DATA,sizeof(aint)));
+        asmlist[al_globals].concat(Tai_const.Create_aint(stacksize));
         { Initial heapsize }
         maybe_new_object_file(asmlist[al_globals]);
-        new_section(asmlist[al_globals],sec_data,'__heapsize',4);
-        asmlist[al_globals].concat(Tai_symbol.Createname_global('__heapsize',AT_DATA,4));
-        asmlist[al_globals].concat(Tai_const.Create_32bit(heapsize));
+        new_section(asmlist[al_globals],sec_data,'__heapsize',sizeof(aint));
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('__heapsize',AT_DATA,sizeof(aint)));
+        asmlist[al_globals].concat(Tai_const.Create_aint(heapsize));
       end;
 
 

+ 1 - 1
rtl/darwin/tthread.inc

@@ -181,7 +181,7 @@ end;
 
 { TThread }
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/freebsd/tthread.inc

@@ -186,7 +186,7 @@ end;
 
 { TThread }
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/go32v2/tthread.inc

@@ -46,7 +46,7 @@ begin
 end;
 
 
-constructor TThread.Create(CreateSuspended: Boolean; const StackSize: DWord = DefaultStackSize);
+constructor TThread.Create(CreateSuspended: Boolean; const StackSize: SizeUInt = DefaultStackSize);
 
 begin
  {IsMultiThread := TRUE; }

+ 2 - 2
rtl/inc/system.inc

@@ -43,7 +43,7 @@ const
 { Used by the ansistrings and maybe also other things in the future }
 var
   emptychar : char;public name 'FPC_EMPTYCHAR';
-  initialstklen : longint;external name '__stklen';
+  initialstklen : SizeUint;external name '__stklen';
 
 
 
@@ -546,7 +546,7 @@ end;
 {$DEFINE STACKCHECK}
 {$ENDIF}
 {$S-}
-procedure fpc_stackcheck(stack_size:Cardinal);[public,alias:'FPC_STACKCHECK'];
+procedure fpc_stackcheck(stack_size:SizeUInt);[public,alias:'FPC_STACKCHECK'];
 var
   c : Pointer;
 begin

+ 1 - 1
rtl/inc/systemh.inc

@@ -350,7 +350,7 @@ ThreadVar
   InOutRes    : Word;
   { Stack checking }
   StackBottom : Pointer;
-  StackLength : Cardinal;
+  StackLength : SizeUInt;
 
 
 { Numbers for routines that have compiler magic }

+ 4 - 10
rtl/inc/thread.inc

@@ -21,7 +21,7 @@ Var
                            Threadvar initialization
 *****************************************************************************}
 
-    procedure InitThread(stklen:cardinal);
+    procedure InitThread(stklen:SizeUInt);
       begin
         SysResetFPU;
         { ExceptAddrStack and ExceptObjectStack are threadvars       }
@@ -63,9 +63,9 @@ Var
       end;
 
     function BeginThread(ThreadFunction : tthreadfunc;p : pointer;
-                     var ThreadId : TThreadID; const SS: DWord) : TThreadID;
+                     var ThreadId : TThreadID; const stacksize: SizeUInt) : TThreadID;
       begin
-        BeginThread:=BeginThread(nil,SS,ThreadFunction,p,0,ThreadId);
+        BeginThread:=BeginThread(nil,stacksize,ThreadFunction,p,0,ThreadId);
       end;
 
     procedure EndThread;
@@ -73,13 +73,7 @@ Var
         EndThread(0);
       end;
 
-function BeginThread(sa : Pointer;stacksize : dword; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;  var ThreadId : TThreadID) : TThreadID;
-
-begin
-  Result:=CurrentTM.BeginThread(sa,stacksize,threadfunction,P,creationflags,ThreadID);
-end;
-
-function BeginThread(sa : Pointer;stacksize : qword; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;  var ThreadId : TThreadID) : TThreadID;
+function BeginThread(sa : Pointer;stacksize : SizeUInt; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;  var ThreadId : TThreadID) : TThreadID;
 
 begin
   Result:=CurrentTM.BeginThread(sa,stacksize,threadfunction,P,creationflags,ThreadID);

+ 3 - 8
rtl/inc/threadh.inc

@@ -15,13 +15,8 @@
  **********************************************************************}
 
 const
-{$ifdef mswindows}
-  { on windows, use stack size of starting process }
-  DefaultStackSize = 0;
-{$else mswindows}
   { including 16384 margin for stackchecking }
   DefaultStackSize = 32768;
-{$endif mswindows}
 
 type
   PEventState = pointer;
@@ -102,13 +97,13 @@ Procedure SetNoThreadManager;
 {$endif DISABLE_NO_THREAD_MANAGER}
 // Needs to be exported, so the manager can call it.
 procedure InitThreadVars(RelocProc : Pointer);
-procedure InitThread(stklen:cardinal);
+procedure InitThread(stklen:SizeUInt);
 
 {*****************************************************************************
                          Multithread Handling
 *****************************************************************************}
 
-function BeginThread(sa : Pointer;stacksize : dword;
+function BeginThread(sa : Pointer;stacksize : SizeUInt;
   ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;
   var ThreadId : TThreadID) : TThreadID;
 
@@ -118,7 +113,7 @@ function BeginThread(ThreadFunction : tthreadfunc) : TThreadID;
 function BeginThread(ThreadFunction : tthreadfunc;p : pointer) : TThreadID;
 function BeginThread(ThreadFunction : tthreadfunc;p : pointer; var ThreadId : TThreadID) : TThreadID;
 function BeginThread(ThreadFunction : tthreadfunc;p : pointer;
-                     var ThreadId : TThreadID; const SS: DWord) : TThreadID;
+                     var ThreadId : TThreadID; const stacksize: SizeUInt) : TThreadID;
 
 procedure EndThread(ExitCode : DWord);
 procedure EndThread;

+ 1 - 1
rtl/linux/tthread.inc

@@ -186,7 +186,7 @@ end;
 
 { TThread }
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/morphos/tthread.inc

@@ -112,7 +112,7 @@ begin
 end;
 
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 var
   Flags: cardinal;
 begin

+ 1 - 1
rtl/netbsd/tthread.inc

@@ -177,7 +177,7 @@ end;
 
 { TThread }
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/netware/systhrd.inc

@@ -151,7 +151,7 @@ function ThreadMain(param : pointer) : dword; cdecl;
      DoneThread;
   end;
 
-function SysBeginThread(sa : Pointer;stacksize : dword;
+function SysBeginThread(sa : Pointer;stacksize : SizeUInt;
                          ThreadFunction : tthreadfunc;p : pointer;
                          creationFlags : dword; var ThreadId : DWord) : DWord;
 

+ 1 - 1
rtl/netware/tthread.inc

@@ -150,7 +150,7 @@ end;
 
 
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 var
   Flags: Integer;
 begin

+ 1 - 1
rtl/netwlibc/systhrd.inc

@@ -126,7 +126,7 @@
       end;
 
 
-    function SysBeginThread(sa : Pointer;stacksize : dword;
+    function SysBeginThread(sa : Pointer;stacksize : SizeUInt;
                          ThreadFunction : tthreadfunc;p : pointer;
                          creationFlags : dword; var ThreadId : THandle) : DWord;
       var

+ 1 - 1
rtl/netwlibc/tthread.inc

@@ -252,7 +252,7 @@ end;
 
 { TThread }
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/openbsd/tthread.inc

@@ -186,7 +186,7 @@ begin
 end;
 
 { TThread }
-constructor TThread.Create(CreateSuspended: Boolean; const StackSize: DWord = DefaultStackSize);
+constructor TThread.Create(CreateSuspended: Boolean; const StackSize: SizeUInt = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!

+ 1 - 1
rtl/os2/systhrd.inc

@@ -184,7 +184,7 @@ end;
       end;
 
 
-    function SysBeginThread(sa : Pointer;stacksize : dword;
+    function SysBeginThread(sa : Pointer;stacksize : SizeUInt;
                          ThreadFunction : tthreadfunc;p : pointer;
                          creationFlags : dword; var ThreadId : TThreadID) : DWord;
       var

+ 1 - 1
rtl/os2/tthread.inc

@@ -174,7 +174,7 @@ begin
 end;
 
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 var
   Flags: cardinal;
 begin

+ 1 - 1
rtl/win32/tthread.inc

@@ -115,7 +115,7 @@ begin
 end;
 
 constructor TThread.Create(CreateSuspended: Boolean;
-                           const StackSize: DWord = DefaultStackSize);
+                           const StackSize: SizeUInt = DefaultStackSize);
 var
   Flags: Integer;
 begin

+ 1 - 1
rtl/wince/tthread.inc

@@ -114,7 +114,7 @@ begin
   if FreeThread then Thread.Free;
 end;
 
-constructor TThread.Create(CreateSuspended: Boolean; const StackSize: DWord = DefaultStackSize);
+constructor TThread.Create(CreateSuspended: Boolean; const StackSize: SizeUInt = DefaultStackSize);
 var
   Flags: Integer;
 begin