* 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 -
This commit is contained in:
tom_at_work 2005-11-10 17:06:25 +00:00
parent 54dee95053
commit 367df58016
20 changed files with 31 additions and 42 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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