瀏覽代碼

* patch from Ales Katona to add a stack size parameter to tthread functions

git-svn-id: trunk@1621 -
florian 20 年之前
父節點
當前提交
7bff61ce29

+ 3 - 2
rtl/darwin/tthread.inc

@@ -180,7 +180,8 @@ begin
 end;
 
 { TThread }
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!
@@ -192,7 +193,7 @@ begin
   FInitialSuspended := CreateSuspended;
   FFatalException := nil;
   WRITE_DEBUG('creating thread, self = ',longint(self));
-  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID);
+  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID, StackSize);
   WRITE_DEBUG('TThread.Create done');
 end;
 

+ 72 - 1
rtl/inc/rtti.inc

@@ -125,7 +125,6 @@ begin
 end;
 
 
-
 Procedure fpc_Initialize (Data,TypeInfo : pointer);[Public,Alias : 'FPC_INITIALIZE'];  compilerproc;
 begin
   case PByte(TypeInfo)^ of
@@ -222,6 +221,78 @@ begin
 end;
 
 
+{
+Procedure fpc_Copy (Src, Dest, TypeInfo : Pointer);[Public,alias : 'FPC_COPY'];  compilerproc;
+var
+  Temp : pbyte;
+  namelen : byte;
+  count,
+  offset,
+  i : longint;
+  info : pointer;
+begin
+  case PByte(TypeInfo)^ of
+    tkAstring:
+      begin
+        fpc_AnsiStr_Incr_Ref(PPointer(Src)^);
+        fpc_AnsiStr_Decr_Ref(PPointer(Dest)^);
+        PPointer(Dest)^:=PPointer(Src)^;
+      end;
+    tkWstring:
+      begin
+        fpc_WideStr_Incr_Ref(PPointer(Src)^);
+        fpc_WideStr_Decr_Ref(PPointer(Dest)^);
+      end;
+    tkArray:
+      begin
+        arrayrtti(data,typeinfo,@fpc_systemDecRef);
+      end;
+    tkobject,
+    tkrecord:
+      begin
+        Temp:=PByte(TypeInfo);
+        inc(Temp);
+        { Skip Name }
+        namelen:=Temp^;
+        inc(temp,namelen+1);
+        temp:=aligntoptr(temp);
+
+        { copy data }
+        move(src^,dest^,plongint(temp)^);
+
+        { Skip size }
+        inc(Temp,4);
+        { Element count }
+        Count:=PLongint(Temp)^;
+        inc(Temp,sizeof(Count));
+        { Process elements }
+        for i:=1 to count Do
+          begin
+            Info:=PPointer(Temp)^;
+            inc(Temp,sizeof(Info));
+            Offset:=PLongint(Temp)^;
+            inc(Temp,sizeof(Offset));
+            fpc_Copy(Src+Offset,Src+Offset,Info);
+	  end;
+    tkDynArray:
+      begin
+        fpc_dynarray_Incr_Ref(PPointer(Src)^);
+        fpc_dynarray_Decr_Ref(PPointer(Dest)^);
+        PPointer(Dest)^:=PPointer(Src)^;
+      end;
+    tkInterface:
+      begin
+        Intf_Incr_Ref(PPointer(Src)^);
+        Intf_Decr_Ref(PPointer(Dest)^);
+        PPointer(Dest)^:=PPointer(Src)^;
+      end;
+    tkVariant:
+      VarCopyProc(pvardata(dest)^,pvardata(src)^);
+  end;
+end;
+}
+
+
 procedure fpc_finalize_array(data,typeinfo : pointer;count,size : longint); [Public,Alias:'FPC_FINALIZEARRAY'];  compilerproc;
   var
      i : longint;

+ 5 - 0
rtl/inc/thread.inc

@@ -62,6 +62,11 @@ Var
         BeginThread:=BeginThread(nil,DefaultStackSize,ThreadFunction,p,0,ThreadId);
       end;
 
+    function BeginThread(ThreadFunction : tthreadfunc;p : pointer;
+                     var ThreadId : TThreadID; const SS: DWord) : TThreadID;
+      begin
+        BeginThread:=BeginThread(nil,SS,ThreadFunction,p,0,ThreadId);
+      end;
 
     procedure EndThread;
       begin

+ 2 - 0
rtl/inc/threadh.inc

@@ -112,6 +112,8 @@ function BeginThread(sa : Pointer;stacksize : dword;
 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;
 
 procedure EndThread(ExitCode : DWord);
 procedure EndThread;

+ 3 - 2
rtl/linux/tthread.inc

@@ -185,7 +185,8 @@ begin
 end;
 
 { TThread }
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!
@@ -197,7 +198,7 @@ begin
   FInitialSuspended := CreateSuspended;
   FFatalException := nil;
   WRITE_DEBUG('creating thread, self = ',longint(self));
-  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID);
+  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID, StackSize);
   WRITE_DEBUG('TThread.Create done');
 end;
 

+ 2 - 1
rtl/morphos/tthread.inc

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

+ 3 - 2
rtl/netbsd/tthread.inc

@@ -176,7 +176,8 @@ begin
 end;
 
 { TThread }
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!
@@ -188,7 +189,7 @@ begin
   FInitialSuspended := CreateSuspended;
   FFatalException := nil;
   WRITE_DEBUG('creating thread, self = ',longint(self));
-  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID);
+  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID, StackSize);
   WRITE_DEBUG('TThread.Create done');
 end;
 

+ 2 - 1
rtl/netware/tthread.inc

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

+ 3 - 2
rtl/netwlibc/tthread.inc

@@ -251,7 +251,8 @@ begin
 end;
 
 { TThread }
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 begin
   // lets just hope that the user doesn't create a thread
   // via BeginThread and creates the first TThread Object in there!
@@ -264,7 +265,7 @@ begin
   FInitialSuspended := CreateSuspended;
   FFatalException := nil;
   WRITE_DEBUG('creating thread, self = %d'#13#10,longint(self));
-  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID);
+  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID, StackSize);
   WRITE_DEBUG('TThread.Create done'#13#10);
 end;
 

+ 2 - 1
rtl/os2/tthread.inc

@@ -173,7 +173,8 @@ begin
   DosExit (deThread, Result);
 end;
 
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 var
   Flags: cardinal;
 begin

+ 4 - 2
rtl/win32/tthread.inc

@@ -114,7 +114,8 @@ begin
   if FreeThread then Thread.Free;
 end;
 
-constructor TThread.Create(CreateSuspended: Boolean);
+constructor TThread.Create(CreateSuspended: Boolean;
+                           const StackSize: DWord = DefaultStackSize);
 var
   Flags: Integer;
 begin
@@ -123,7 +124,8 @@ begin
   FSuspended := CreateSuspended;
   Flags := 0;
   if CreateSuspended then Flags := CREATE_SUSPENDED;
-  FHandle := BeginThread(nil, 0, @ThreadProc, pointer(self), Flags, FThreadID);
+  FHandle := BeginThread(nil, 0, @ThreadProc, pointer(self), Flags,
+                         FThreadID, StackSize);
   FFatalException := nil;
 end;