Selaa lähdekoodia

* fixed pthread type definitions for darwin and made them generic

Jonas Maebe 21 vuotta sitten
vanhempi
commit
341d25bfb2

+ 15 - 40
packages/base/pthreads/pthrbsd.inc

@@ -117,35 +117,6 @@ const
     }
 
   type
-     pthread = record
-       end;
-    
-     pthread_attr = record
-       end;
-
-     pthread_cond = record
-       end;
-
-     pthread_cond_attr = record
-       end;
-
-     pthread_mutex = record
-       end;
-
-  
-     pthread_mutex_attr = record
-       end;
-
-{
-     pthread_once = record
-       end;
-}
-     pthread_rwlock = record
-       end;
-
-     pthread_rwlockattr = record
-       end;
-
 { from semaphore.h }
 
      sem 		= record end;
@@ -162,22 +133,23 @@ const
      pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
     }
 
-     pthread_t 			= ^pthread;
-     pthread_attr_t 		= ^pthread_attr;
-     pthread_mutex_t 		= ^pthread_mutex;
-     pthread_mutexattr_t 	= ^pthread_mutex_attr;
-     pthread_cond_t 		= ^pthread_cond;
-     pthread_condattr_t 	= ^pthread_cond_attr;
-     pthread_key_t 		= cint;
-     pthread_rwlock_t 		= ^pthread_rwlock;
-     pthread_rwlockattr_t 	= ^pthread_rwlockattr;
+     pthread_t 			= record a: array[0..DWORDS_IN_PTHREAD_T-1] of dword; end;
+     pthread_attr_t 		= record a: array[0..DWORDS_IN_PTHREAD_ATTR_T-1] of dword; end;
+     pthread_mutex_t 		= record a: array[0..DWORDS_IN_PTHREAD_MUTEX_T-1] of dword; end;
+     pthread_mutexattr_t 	= record a: array[0..DWORDS_IN_PTHREAD_MUTEXATTR_T-1] of dword; end;
+     pthread_cond_t 		= record a: array[0..DWORDS_IN_PTHREAD_COND_T-1] of dword; end;
+     pthread_condattr_t 	= record a: array[0..DWORDS_IN_PTHREAD_COND_ATTR_T-1] of dword; end;
+{    moved to ptypes.inc because not the same on all systems }
+{     pthread_key_t 		= cint; }
+     pthread_rwlock_t 		= record a: array[0..DWORDS_IN_PTHREAD_RWLOCK_T-1] of dword; end;
+     pthread_rwlockattr_t 	= record a: array[0..DWORDS_IN_PTHREAD_RWLOCK_ATTR_T-1] of dword; end;
 
      TThreadID = pthread_t;
      PThreadID = ^TThreadID;
      TThreadAttr = pthread_attr_t;
      PThreadAttr = ^TThreadAttr;
      TPthreadMutex = pthread_mutex_t;
-     PTpthreadmutex= ^pthread_mutex;
+     PTpthreadmutex= ^TPthreadMutex;
      TMutexAttribute = pthread_mutexattr_t;
      PMutexAttribute = ^TMutexAttribute;
      TPthreadCondattr = pthread_condattr_t;
@@ -423,7 +395,10 @@ function pthread_attr_getfloatstate(_para1:Ppthread_attr_t; _para2:Pcint):cint;c
 
 {  
    $Log$
-   Revision 1.4  2004-02-15 19:59:20  marco
+   Revision 1.5  2004-08-25 21:42:11  jonas
+     * fixed pthread type definitions for darwin and made them generic
+
+   Revision 1.4  2004/02/15 19:59:20  marco
     * linklib pthread from now on
 
    Revision 1.3  2003/11/16 21:30:24  marco

+ 1 - 1
packages/base/pthreads/pthreads.pp

@@ -24,7 +24,7 @@ interface
 {$ifdef BSD}
 
 {$ifndef ver1_0}
-Uses BaseUnix;
+Uses BaseUnix, unixtype;
 {$endif}
 
 {$i pthrbsd.inc}

+ 17 - 1
rtl/darwin/ptypes.inc

@@ -108,6 +108,18 @@ CONST
     MFSNAMELEN = 15;
     MNAMELEN   = 90;
 
+
+  DWORDS_IN_PTHREAD_T = sizeof(pointer) div sizeof(dword);
+  DWORDS_IN_PTHREAD_ATTR_T = (36+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_MUTEXATTR_T = (8+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_MUTEX_T = (40+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_COND_ATTR_T = (4+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_COND_T = (24+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_ONCE_T = (4+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_RWLOCK_T = (124+sizeof(clong)) div sizeof(dword);
+  DWORDS_IN_PTHREAD_RWLOCK_ATTR_T = (12+sizeof(clong)) div sizeof(dword);
+
+
   type
      fsid_t = record
           val: array[0..1] of cint32;
@@ -135,11 +147,15 @@ CONST
        end;
     pstatfs = ^tstatfs;
 
+   pthread_key_t = clong;
 
 
 {
   $Log$
-  Revision 1.6  2004-03-04 22:28:08  marco
+  Revision 1.7  2004-08-25 21:42:11  jonas
+    * fixed pthread type definitions for darwin and made them generic
+
+  Revision 1.6  2004/03/04 22:28:08  marco
    * Darwin specific unixtype fixes.
 
   Revision 1.5  2004/03/01 19:50:40  jonas

+ 17 - 1
rtl/freebsd/ptypes.inc

@@ -103,6 +103,8 @@ type
   ptimespec= ^timespec;
   Ttimespec= timespec;
 
+  pthread_key_t = cint;
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
@@ -115,9 +117,23 @@ CONST
 //   wordsinsigset   = 4;		// words in sigset_t
 
 
+    DWORDS_IN_PTHREAD_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEXATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEX_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ONCE_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_ATTR_T = sizeof(pointer) div sizeof(dword);
+
+
 {
   $Log$
-  Revision 1.12  2004-05-18 19:33:45  marco
+  Revision 1.13  2004-08-25 21:42:11  jonas
+    * fixed pthread type definitions for darwin and made them generic
+
+  Revision 1.12  2004/05/18 19:33:45  marco
    * left a comment unmatched
 
   Revision 1.11  2004/05/17 19:18:38  marco

+ 15 - 1
rtl/netbsd/ptypes.inc

@@ -91,6 +91,8 @@ type
   ptimespec= ^timespec;
   Ttimespec= timespec;
 
+  pthread_key_t = cint;
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 256*1024;   {4096}  { Maximum number of argument size     }
@@ -101,10 +103,22 @@ CONST
 
     SIG_MAXSIG      = 128;	// highest signal version
 
+    DWORDS_IN_PTHREAD_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEXATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEX_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ONCE_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_ATTR_T = sizeof(pointer) div sizeof(dword);
 
 {
   $Log$
-  Revision 1.6  2004-05-16 13:03:27  peter
+  Revision 1.7  2004-08-25 21:42:11  jonas
+    * fixed pthread type definitions for darwin and made them generic
+
+  Revision 1.6  2004/05/16 13:03:27  peter
     * remove duplicate wordsinsigset
 
   Revision 1.5  2004/01/04 20:08:45  jonas

+ 15 - 1
rtl/openbsd/ptypes.inc

@@ -91,6 +91,8 @@ type
   ptimespec= ^timespec;
   Ttimespec= timespec;
 
+  pthread_key_t = cint;
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 256*1024;   {4096}  { Maximum number of argument size     }
@@ -102,10 +104,22 @@ CONST
     SIG_MAXSIG      = 128;	// highest signal version
     wordsinsigset   = 4;		// words in sigset_t
 
+    DWORDS_IN_PTHREAD_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEXATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_MUTEX_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_ATTR_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_COND_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_ONCE_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_T = sizeof(pointer) div sizeof(dword);
+    DWORDS_IN_PTHREAD_RWLOCK_ATTR_T = sizeof(pointer) div sizeof(dword);
 
 {
   $Log$
-  Revision 1.4  2004-01-22 13:46:14  marco
+  Revision 1.5  2004-08-25 21:42:11  jonas
+    * fixed pthread type definitions for darwin and made them generic
+
+  Revision 1.4  2004/01/22 13:46:14  marco
   bsd
 
   Revision 1.5  2004/01/04 20:08:45  jonas