2
0
Эх сурвалжийг харах

* fixed solaris compilation

git-svn-id: trunk@2955 -
florian 19 жил өмнө
parent
commit
a2f4e33bda

+ 169 - 46
packages/base/pthreads/pthrsnos.inc

@@ -7,44 +7,143 @@
     -s
 }
 
+type
+  { from sem.h }
+  sem_t       = cint;
+  psem_t          = ^sem_t;
+  TSemaphore  = sem_t;
+  PSemaphore  = ^TSemaphore;
+  
 const
   External_library='c'; {Setup as you need}
 
-
 Type
-P_cleanup_t  = ^_cleanup_t;
-Pclockid_t  = ^clockid_t;
-Plongint  = ^longint;
-Ppthread_attr_t  = ^pthread_attr_t;
-Ppthread_barrier_t  = ^pthread_barrier_t;
-Ppthread_barrierattr_t  = ^pthread_barrierattr_t;
-Ppthread_cond_t  = ^pthread_cond_t;
-Ppthread_condattr_t  = ^pthread_condattr_t;
-Ppthread_key_t  = ^pthread_key_t;
-
-Ppthread_mutex_t  = ^pthread_mutex_t;
-TPthreadMutex = pthread_mutex_t;
-
-Ppthread_mutexattr_t  = ^pthread_mutexattr_t;
-Ppthread_once_t  = ^pthread_once_t;
-Ppthread_rwlock_t  = ^pthread_rwlock_t;
-Ppthread_rwlockattr_t  = ^pthread_rwlockattr_t;
-Ppthread_spinlock_t  = ^pthread_spinlock_t;
-Ppthread_t  = ^pthread_t;
-Psched_param  = ^sched_param;
-Psize_t  = ^size_t;
-Ptimespec  = ^timespec;
+    ppthread_t           = ^pthread_t;
+    ppthread_key_t       = ^pthread_key_t;
+    ppthread_mutex_t     = ^pthread_mutex_t;
+    ppthread_attr_t      = ^pthread_attr_t;
+    __destr_func_t       = procedure (p :pointer);cdecl;
+    __startroutine_t     = function (p :pointer):pointer;cdecl;
+    ppthread_mutexattr_t = ^pthread_mutexattr_t;
+    ppthread_cond_t      = ^pthread_cond_t;
+    ppthread_condattr_t  = ^pthread_condattr_t;
+    
+    pthread_t = culong;
+  
+    sched_param = record
+      __sched_priority: cint;
+    end;
+  
+    pthread_attr_t = record
+      __detachstate: cint;
+      __schedpolicy: cint;
+      __schedparam: sched_param;
+      __inheritsched: cint;
+      __scope: cint;
+      __guardsize: size_t;
+      __stackaddr_set: cint;
+      __stackaddr: pointer;
+      __stacksize: size_t;
+    end;
+  
+    _pthread_fastlock = record
+      __status: clong;
+      __spinlock: cint;
+    end;
+  
+    pthread_mutex_t = record
+      __pthread_mutex_flags : record
+           __pthread_mutex_flag1 : word;
+           __pthread_mutex_flag2 : byte;
+           __pthread_mutex_ceiling : byte;
+           __pthread_mutex_type : word;
+           __pthread_mutex_magic : word;
+        end;
+      __pthread_mutex_lock : record
+          case longint of
+             0 : ( __pthread_mutex_lock64 : record
+                  __pthread_mutex_pad : array[0..7] of byte;
+               end );
+             1 : ( __pthread_mutex_lock32 : record
+                  __pthread_ownerpid : dword;
+                  __pthread_lockword : dword;
+               end );
+             2 : ( __pthread_mutex_owner64 : qword );
+          end;
+      __pthread_mutex_data : qword;
+    end;
+  
+    pthread_spinlock_t = pthread_mutex_t;
+  
+    pthread_mutexattr_t = record
+      __mutexkind: cint;
+    end;
+  
+    pthread_cond_t = record
+      __c_lock: _pthread_fastlock;
+      __c_waiting: pointer;
+      __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
+      __align: clonglong;
+    end;
+  
+    pthread_condattr_t = record
+      __dummy: cint;
+    end;
+  
+    pthread_key_t = cuint;
+  
+    pthread_rwlock_t = record
+      __rw_readers: cint;
+      __rw_writer: pointer;
+      __rw_read_waiting: pointer;
+      __rw_write_waiting: pointer;
+      __rw_kind: cint;
+      __rw_pshared: cint;
+    end;
+  
+    pthread_rwlockattr_t = record
+      __lockkind: cint;
+      __pshared: cint;
+    end;
+  
+    _once = record
+       __pthread_once_pad : array[0..3] of upad64_t;
+    end;
+    pthread_once_t = _once;
+  
+    pthread_barrier_t = record
+       __pthread_barrier_count : uint32_t;
+       __pthread_barrier_current : uint32_t;
+       __pthread_barrier_cycle : upad64_t;
+       __pthread_barrier_reserved : upad64_t;
+       __pthread_barrier_lock : pthread_mutex_t;
+       __pthread_barrier_cond : pthread_cond_t;
+    end;
+  
+    pthread_barrierattr_t = record
+       __pthread_barrierattrp : pointer;
+    end;
+    
+  P_cleanup_t  = ^_cleanup_t;
+  Pclockid_t  = ^clockid_t;
+  Plongint  = ^longint;
+  Ppthread_barrier_t  = ^pthread_barrier_t;
+  Ppthread_barrierattr_t  = ^pthread_barrierattr_t;
+  
+    
+  Ppthread_once_t  = ^pthread_once_t;
+  Ppthread_rwlock_t  = ^pthread_rwlock_t;
+  Ppthread_rwlockattr_t  = ^pthread_rwlockattr_t;
+  Ppthread_spinlock_t  = ^pthread_spinlock_t;
+  Psched_param  = ^sched_param;
+  Psize_t  = ^size_t;
+  Ptimespec  = ^timespec;
 
    _cleanup = record
         pthread_cleanup_pad : array[0..3] of uintptr_t;
      end;
    _cleanup_t = _cleanup;
 
-{$IFDEF FPC}
-{$PACKRECORDS C}
-{$ENDIF}
-
-
 const
    PTHREAD_CREATE_DETACHED = $40;   
    PTHREAD_CREATE_JOINABLE = 0;   
@@ -68,24 +167,24 @@ const
 
 
 const
-   PTHREAD_MUTEX_NORMAL = $0;   
-   PTHREAD_MUTEX_ERRORCHECK = $2;   
-   PTHREAD_MUTEX_RECURSIVE = $4;   
-   PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;   
-
-   PTHREAD_PRIO_NONE = $0;   
-   PTHREAD_PRIO_INHERIT = $10;   
-   PTHREAD_PRIO_PROTECT = $20;   
-
-   PTHREAD_MUTEX_STALL_NP = $0;   
-   PTHREAD_MUTEX_ROBUST_NP = $40;   
-
-
-   PTHREAD_CANCEL_ENABLE = $00;   
-   PTHREAD_CANCEL_DISABLE = $01;   
-   PTHREAD_CANCEL_DEFERRED = $00;   
-   PTHREAD_CANCEL_ASYNCHRONOUS = $02;   
-   PTHREAD_CANCELED = pointer(-(19));
+  PTHREAD_MUTEX_NORMAL = $0;   
+  PTHREAD_MUTEX_ERRORCHECK = $2;   
+  PTHREAD_MUTEX_RECURSIVE = $4;   
+  PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;   
+  
+  PTHREAD_PRIO_NONE = $0;   
+  PTHREAD_PRIO_INHERIT = $10;   
+  PTHREAD_PRIO_PROTECT = $20;   
+  
+  PTHREAD_MUTEX_STALL_NP = $0;   
+  PTHREAD_MUTEX_ROBUST_NP = $40;   
+  
+  
+  PTHREAD_CANCEL_ENABLE = $00;   
+  PTHREAD_CANCEL_DISABLE = $01;   
+  PTHREAD_CANCEL_DEFERRED = $00;   
+  PTHREAD_CANCEL_ASYNCHRONOUS = $02;   
+  PTHREAD_CANCELED = pointer(-(19));
 
 
 
@@ -244,3 +343,27 @@ function pthread_barrierattr_getpshared(_RESTRICT_KYWD1:Ppthread_barrierattr_t;
 function pthread_barrier_init(_RESTRICT_KYWD1:Ppthread_barrier_t; _RESTRICT_KYWD2:Ppthread_barrierattr_t; _para3:uint_t):longint;cdecl;external External_library name 'pthread_barrier_init';
 function pthread_barrier_destroy(_para1:Ppthread_barrier_t):longint;cdecl;external External_library name 'pthread_barrier_destroy';
 function pthread_barrier_wait(_para1:Ppthread_barrier_t):longint;cdecl;external External_library name 'pthread_barrier_wait';
+
+function sem_init(__sem:Psem_t; __pshared:cint;__value:cuint):cint;cdecl; external 'c' name 'sem_init';
+function sem_destroy(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_destroy';
+function sem_close(__sem:Psem_t):cint;cdecl;external 'c'  name 'sem_close';
+function sem_unlink(__name:Pchar):cint;cdecl;external 'c' name 'sem_unlink';
+function sem_wait(__sem:Psem_t):cint;cdecl;external 'c'  name 'sem_wait';
+function sem_trywait(__sem:Psem_t):cint;cdecl;external 'c'  name 'sem_trywait';
+function sem_post(__sem:Psem_t):cint;cdecl;external 'c'  name 'sem_post';
+function sem_getvalue(__sem:Psem_t; __sval:Pcint):cint;cdecl;external 'c'  name 'sem_getvalue';
+
+type
+  { redefinitions }
+  TThreadAttr = pthread_attr_t;
+  PThreadAttr = ^TThreadAttr;
+
+  TPthreadFastlock = _pthread_fastlock;
+  PPthreadFastlock = ^TPthreadFastlock;
+
+  TMutexAttribute = pthread_mutexattr_t;
+  PMutexAttribute = ^TMutexAttribute;
+
+  TPthreadMutex = pthread_mutex_t;
+  PPthreadMutex = ^TPthreadMutex;
+  

+ 175 - 4
rtl/solaris/pthread.inc

@@ -19,11 +19,80 @@
 
  **********************************************************************}
 
-CONST PTHREAD_EXPLICIT_SCHED       = 0;
-      PTHREAD_CREATE_DETACHED      = 1;
-      PTHREAD_SCOPE_PROCESS        = 0;
+  const 
+    PTHREAD_EXPLICIT_SCHED       = 0;
+    PTHREAD_CREATE_DETACHED      = 1;
+    PTHREAD_SCOPE_PROCESS        = 0;
 
- TYPE
+  type
+    pthread_t = culong;
+  
+    sched_param = record
+      __sched_priority: cint;
+    end;
+  
+    pthread_attr_t = record
+      __detachstate: cint;
+      __schedpolicy: cint;
+      __schedparam: sched_param;
+      __inheritsched: cint;
+      __scope: cint;
+      __guardsize: size_t;
+      __stackaddr_set: cint;
+      __stackaddr: pointer;
+      __stacksize: size_t;
+    end;
+  
+    _pthread_fastlock = record
+      __status: clong;
+      __spinlock: cint;
+    end;
+  
+    pthread_mutex_t = record
+      __m_reserved: cint;
+      __m_count: cint;
+      __m_owner: pointer;
+      __m_kind:  cint;
+      __m_lock: _pthread_fastlock;
+    end;
+  
+    pthread_mutexattr_t = record
+      __mutexkind: cint;
+    end;
+  
+    pthread_cond_t = record
+      __c_lock: _pthread_fastlock;
+      __c_waiting: pointer;
+      __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
+      __align: clonglong;
+    end;
+  
+    pthread_condattr_t = record
+      __dummy: cint;
+    end;
+  
+    pthread_key_t = cuint;
+  
+    pthread_rwlock_t = record
+      __rw_readers: cint;
+      __rw_writer: pointer;
+      __rw_read_waiting: pointer;
+      __rw_write_waiting: pointer;
+      __rw_kind: cint;
+      __rw_pshared: cint;
+    end;
+  
+    pthread_rwlockattr_t = record
+      __lockkind: cint;
+      __pshared: cint;
+    end;
+  
+    sem_t = record
+       __sem_lock: _pthread_fastlock;
+       __sem_value: cint;
+       __sem_waiting: pointer;
+    end;
+  
     ppthread_t           = ^pthread_t;
     ppthread_key_t       = ^pthread_key_t;
     ppthread_mutex_t     = ^pthread_mutex_t;
@@ -33,6 +102,108 @@ CONST PTHREAD_EXPLICIT_SCHED       = 0;
     ppthread_mutexattr_t = ^pthread_mutexattr_t;
     ppthread_cond_t      = ^pthread_cond_t;
     ppthread_condattr_t  = ^pthread_condattr_t;
+    
+    pthread_t = culong;
+  
+    sched_param = record
+      __sched_priority: cint;
+    end;
+  
+    pthread_attr_t = record
+      __detachstate: cint;
+      __schedpolicy: cint;
+      __schedparam: sched_param;
+      __inheritsched: cint;
+      __scope: cint;
+      __guardsize: size_t;
+      __stackaddr_set: cint;
+      __stackaddr: pointer;
+      __stacksize: size_t;
+    end;
+  
+    _pthread_fastlock = record
+      __status: clong;
+      __spinlock: cint;
+    end;
+  
+    pthread_mutex_t = record
+      __pthread_mutex_flags : record
+           __pthread_mutex_flag1 : word;
+           __pthread_mutex_flag2 : byte;
+           __pthread_mutex_ceiling : byte;
+           __pthread_mutex_type : word;
+           __pthread_mutex_magic : word;
+        end;
+      __pthread_mutex_lock : record
+          case longint of
+             0 : ( __pthread_mutex_lock64 : record
+                  __pthread_mutex_pad : array[0..7] of byte;
+               end );
+             1 : ( __pthread_mutex_lock32 : record
+                  __pthread_ownerpid : dword;
+                  __pthread_lockword : dword;
+               end );
+             2 : ( __pthread_mutex_owner64 : qword );
+          end;
+      __pthread_mutex_data : qword;
+    end;
+  
+    pthread_spinlock_t = pthread_mutex_t;
+  
+    pthread_mutexattr_t = record
+      __mutexkind: cint;
+    end;
+  
+    pthread_cond_t = record
+      __c_lock: _pthread_fastlock;
+      __c_waiting: pointer;
+      __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
+      __align: clonglong;
+    end;
+  
+    pthread_condattr_t = record
+      __dummy: cint;
+    end;
+  
+    pthread_key_t = cuint;
+  
+    pthread_rwlock_t = record
+      __rw_readers: cint;
+      __rw_writer: pointer;
+      __rw_read_waiting: pointer;
+      __rw_write_waiting: pointer;
+      __rw_kind: cint;
+      __rw_pshared: cint;
+    end;
+  
+    pthread_rwlockattr_t = record
+      __lockkind: cint;
+      __pshared: cint;
+    end;
+  
+    _once = record
+       __pthread_once_pad : array[0..3] of upad64_t;
+    end;
+    pthread_once_t = _once;
+  
+    pthread_barrier_t = record
+       __pthread_barrier_count : uint32_t;
+       __pthread_barrier_current : uint32_t;
+       __pthread_barrier_cycle : upad64_t;
+       __pthread_barrier_reserved : upad64_t;
+       __pthread_barrier_lock : pthread_mutex_t;
+       __pthread_barrier_cond : pthread_cond_t;
+    end;
+  
+    pthread_barrierattr_t = record
+       __pthread_barrierattrp : pointer;
+    end;
+  
+    sem_t = record
+       __sem_lock: _pthread_fastlock;
+       __sem_value: cint;
+       __sem_waiting: pointer;
+    end;
 
     sem_t       = cint;
     psem_t          = ^sem_t;

+ 0 - 102
rtl/solaris/ptypes.inc

@@ -166,108 +166,6 @@ Type
   end;
   PStatFS=^TStatFS;
 
-  pthread_t = culong;
-
-  sched_param = record
-    __sched_priority: cint;
-  end;
-
-  pthread_attr_t = record
-    __detachstate: cint;
-    __schedpolicy: cint;
-    __schedparam: sched_param;
-    __inheritsched: cint;
-    __scope: cint;
-    __guardsize: size_t;
-    __stackaddr_set: cint;
-    __stackaddr: pointer;
-    __stacksize: size_t;
-  end;
-
-  _pthread_fastlock = record
-    __status: clong;
-    __spinlock: cint;
-  end;
-
-  pthread_mutex_t = record
-    __pthread_mutex_flags : record
-         __pthread_mutex_flag1 : word;
-         __pthread_mutex_flag2 : byte;
-         __pthread_mutex_ceiling : byte;
-         __pthread_mutex_type : word;
-         __pthread_mutex_magic : word;
-      end;
-    __pthread_mutex_lock : record
-        case longint of
-           0 : ( __pthread_mutex_lock64 : record
-                __pthread_mutex_pad : array[0..7] of byte;
-             end );
-           1 : ( __pthread_mutex_lock32 : record
-                __pthread_ownerpid : dword;
-                __pthread_lockword : dword;
-             end );
-           2 : ( __pthread_mutex_owner64 : qword );
-        end;
-    __pthread_mutex_data : qword;
-  end;
-
-  pthread_spinlock_t = pthread_mutex_t;
-
-  pthread_mutexattr_t = record
-    __mutexkind: cint;
-  end;
-
-  pthread_cond_t = record
-    __c_lock: _pthread_fastlock;
-    __c_waiting: pointer;
-    __padding: array[0..48-1-sizeof(_pthread_fastlock)-sizeof(pointer)-sizeof(clonglong)] of byte;
-    __align: clonglong;
-  end;
-
-  pthread_condattr_t = record
-    __dummy: cint;
-  end;
-
-  pthread_key_t = cuint;
-
-  pthread_rwlock_t = record
-    __rw_readers: cint;
-    __rw_writer: pointer;
-    __rw_read_waiting: pointer;
-    __rw_write_waiting: pointer;
-    __rw_kind: cint;
-    __rw_pshared: cint;
-  end;
-
-  pthread_rwlockattr_t = record
-    __lockkind: cint;
-    __pshared: cint;
-  end;
-
-  _once = record
-     __pthread_once_pad : array[0..3] of upad64_t;
-  end;
-  pthread_once_t = _once;
-
-  pthread_barrier_t = record
-       __pthread_barrier_count : uint32_t;
-       __pthread_barrier_current : uint32_t;
-       __pthread_barrier_cycle : upad64_t;
-       __pthread_barrier_reserved : upad64_t;
-       __pthread_barrier_lock : pthread_mutex_t;
-       __pthread_barrier_cond : pthread_cond_t;
-    end;
-
-  pthread_barrierattr_t = record
-       __pthread_barrierattrp : pointer;
-    end;
-
-  sem_t = record
-     __sem_lock: _pthread_fastlock;
-     __sem_value: cint;
-     __sem_waiting: pointer;
-  end;
-
 
   clock32_t = int32_t;
   timeval32 = record

+ 3 - 0
rtl/unix/aliasptp.inc

@@ -66,9 +66,12 @@ type
     timespec = UnixType.timespec;
     ptimespec= UnixType.ptimespec;
     Ttimespec= UnixType.Ttimespec;
+    
+{   use pthread package instead 
     pthread_mutex_t   = UnixType.pthread_mutex_t;
     pthread_cond_t    = UnixType.pthread_cond_t;
     pthread_t         = UnixType.pthread_t;
+}
     tstatfs  = UnixType.TStatFs;
 
 CONST