浏览代码

* proper error message if the cthreads unit is included too late
uses clause

florian 20 年之前
父节点
当前提交
d18746bd15
共有 3 个文件被更改,包括 33 次插入6 次删除
  1. 8 1
      rtl/inc/systemh.inc
  2. 14 4
      rtl/inc/thread.inc
  3. 11 1
      rtl/unix/cthreads.pp

+ 8 - 1
rtl/inc/systemh.inc

@@ -361,6 +361,9 @@ const
   { assume that this program will not spawn other threads, when the
     first thread is started the following constants need to be filled }
   IsMultiThread : boolean = FALSE;
+  { set to true, if a threading helper is used before a thread
+    manager has been installed }
+  ThreadingAlreadyUsed : boolean = FALSE;
   { Indicates if there was an error }
   StackError : boolean = FALSE;
   InitProc : Pointer = nil;
@@ -769,7 +772,11 @@ const
 
 {
   $Log$
-  Revision 1.121  2005-02-25 12:34:46  peter
+  Revision 1.122  2005-04-03 19:29:28  florian
+    * proper error message if the cthreads unit is included too late
+      uses clause
+
+  Revision 1.121  2005/02/25 12:34:46  peter
     * added HexStr(Pointer)
 
   Revision 1.120  2005/02/14 17:13:29  peter

+ 14 - 4
rtl/inc/thread.inc

@@ -326,7 +326,9 @@ procedure NoCriticalSection(var CS);
 
 begin
   if IsMultiThread then
-    NoThreadError;
+    NoThreadError
+  else
+    ThreadingAlreadyUsed:=true;
 end;
 
 procedure NoInitThreadvar(var offset : dword;size : dword);
@@ -388,14 +390,18 @@ function  NORTLEventCreate :PRTLEvent;
 
 begin
   if IsMultiThread then
-    NoThreadError;
+    NoThreadError
+  else
+    ThreadingAlreadyUsed:=true
 end;
 
 procedure NORTLeventdestroy(state:pRTLEvent);
 
 begin
   if IsMultiThread then
-    NoThreadError;
+    NoThreadError
+  else
+    ThreadingAlreadyUsed:=true
 end;
 
 procedure NORTLeventSetEvent(state:pRTLEvent);
@@ -469,7 +475,11 @@ end;
 
 {
   $Log$
-  Revision 1.24  2005-02-26 11:40:38  florian
+  Revision 1.25  2005-04-03 19:29:28  florian
+    * proper error message if the cthreads unit is included too late
+      uses clause
+
+  Revision 1.24  2005/02/26 11:40:38  florian
     * rtl event init/destroy throws only an error if it's used in a mult threaded program
 
   Revision 1.23  2005/02/25 22:02:46  florian

+ 11 - 1
rtl/unix/cthreads.pp

@@ -623,12 +623,22 @@ end;
 
 
 initialization
+  if ThreadingAlreadyUsed then
+    begin
+      writeln('Threading has been used before cthreads was initialized.');
+      writeln('Make cthreads one of the first units in your uses clause.');
+      runerror(211);
+    end;
   SetCThreadManager;
 finalization
 end.
 {
   $Log$
-  Revision 1.24  2005-02-25 22:10:27  florian
+  Revision 1.25  2005-04-03 19:29:28  florian
+    * proper error message if the cthreads unit is included too late
+      uses clause
+
+  Revision 1.24  2005/02/25 22:10:27  florian
     * final fix for linux (hopefully)
 
   Revision 1.23  2005/02/25 22:02:48  florian