~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to rtl/linux/pthread.inc

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{
2
 
    $Id: pthread.inc,v 1.4 2004/05/23 18:49:18 marco Exp $
 
2
    $Id: pthread.inc,v 1.6 2005/02/14 17:13:30 peter Exp $
3
3
    This file is part of the Free Pascal run time library.
4
4
    Copyright (c) 1999-2000 by Peter Vreman
5
5
    member of the Free Pascal development team.
29
29
     THREAD_PRIORITY_HIGHEST            = 80;
30
30
     THREAD_PRIORITY_TIME_CRITICAL      = 99;
31
31
     PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP : array [0..5]of Integer = (0, 0, 0, 1, 0, 0);
32
 
     PTHREAD_MUTEX_RECURSIVE            = 1;
33
32
 
34
33
Type
35
 
  __sem_lock_t = record
36
 
    status: Longint;
37
 
    spinlock: Integer;
38
 
  end;
39
 
  TSemLock = __sem_lock_t;
40
 
  PSemLock = ^TSemLock;
41
 
 
42
 
   sem_t = record
43
 
     __sem_lock: __sem_lock_t;
44
 
     __sem_value: Integer;
45
 
     __sem_waiting: pointer;
46
 
    end;
47
34
   psem_t = ^sem_t;
48
35
   TSemaphore = sem_t;
49
36
   PSemaphore = ^TSemaphore;
58
45
       THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL
59
46
     );
60
47
 
 
48
{
61
49
  type
62
 
     psched_param = ^sched_param;
63
 
     sched_param = record
64
 
        sched_priority : LongInt;
65
 
     end;
66
 
{
67
 
     ptimespec = ^timespec;
68
 
     timespec = record
69
 
        tv_sec : LongInt;
70
 
        tv_nsec : LongInt;
71
 
     end;
72
 
}
73
50
     psigset_t = ^sigset_t;
74
51
     sigset_t = DWORD; // unsigned long 32 bits
 
52
}
75
53
 
76
54
  const
77
55
     _POSIX_THREAD_THREADS_MAX = 64;
80
58
     PTHREAD_KEYS_MAX = 128;
81
59
 
82
60
  type
83
 
    pthread_t = pointer;
84
61
    ppthread_t = ^pthread_t;
85
 
 
 
62
{
86
63
     p_pthread_queue = ^_pthread_queue;
87
 
     _pthread_queue = record
88
 
          head : pthread_t;
89
 
          tail : pthread_t;
90
 
       end;
91
 
 
92
 
     ppthread_mutex_t = PRtlCriticalSection;
93
 
     pthread_mutex_t = TRtlCriticalSection;
 
64
}
 
65
     ppthread_mutex_t = ^pthread_mutex_t;
94
66
 
95
67
     ppthread_cond_t = ^pthread_cond_t;
96
 
     pthread_cond_t = record
97
 
          c_spinlock : longint;
98
 
          c_waiting : _pthread_queue;
99
 
       end;
100
68
 
101
69
     { Attributes  }
102
70
 
109
77
      PTHREAD_SCOPE_PROCESS   = 1;
110
78
 
111
79
    type
112
 
//       size_t = longint;
 
80
       psched_param = ^sched_param;
113
81
 
114
82
       ppthread_attr_t = ^pthread_attr_t;
115
 
       pthread_attr_t = record
116
 
            detachstate : longint;
117
 
            schedpolicy : longint;
118
 
            schedparam : sched_param;
119
 
            inheritsched : longint;
120
 
            scope : longint;
121
 
            __guardsize : size_t;
122
 
            __stackaddr_set : longint;
123
 
            __stackaddr : pointer;
124
 
            __stacksize : size_t;
125
 
         end;
126
83
 
127
84
       ppthread_mutexattr_t = ^pthread_mutexattr_t;
128
 
       pthread_mutexattr_t = record
129
 
            mutexkind : longint;
130
 
         end;
131
 
       pthread_mutex_attr_t = pthread_mutexattr_t;
132
85
 
133
86
       ppthread_condattr_t = ^pthread_condattr_t;
134
 
       pthread_condattr_t = record
135
 
            dummy : longint;
136
 
         end;
137
87
 
138
88
       ppthread_key_t = ^pthread_key_t;
139
 
       pthread_key_t = cardinal;
140
89
 
141
 
       ppthread_once_t = ^pthread_once_t;
142
 
       pthread_once_t = longint;
 
90
{      pthread_once_t = cint;
 
91
       ppthread_once_t = ^pthread_once_t;}
143
92
 
144
93
    const
145
94
       PTHREAD_ONCE_INIT = 0;
146
95
 
147
96
    type
 
97
(*
148
98
       tpcb_routine = Procedure(P:Pointer); cdecl;
149
99
 
150
100
       p_pthread_cleanup_buffer = ^_pthread_cleanup_buffer;
154
104
          canceltype:LongInt;                 { Saved cancellation type. }
155
105
          prev : p_pthread_cleanup_buffer; { Chaining of cleanup functions.  }
156
106
       end;
 
107
*)
157
108
 
158
109
     __start_routine_t = function (_para1:pointer):pointer;cdecl;
159
110
     __destr_function_t = procedure (_para1:pointer);
160
 
     t_pthread_cleanup_push_routine = procedure (_para1:pointer);
161
 
     t_pthread_cleanup_push_defer_routine = procedure (_para1:pointer);
 
111
{     t_pthread_cleanup_push_routine = procedure (_para1:pointer);
 
112
     t_pthread_cleanup_push_defer_routine = procedure (_para1:pointer);}
162
113
 
163
114
{$ifndef dynpthreads}
164
115
    function pthread_create(__thread:ppthread_t; __attr:ppthread_attr_t;__start_routine: __start_routine_t;__arg:pointer):longint;cdecl;external;
202
153
    function pthread_key_delete(__key:pthread_key_t):longint;cdecl;external;
203
154
    function pthread_setspecific(__key:pthread_key_t; __pointer:pointer):longint;cdecl;external;
204
155
    function pthread_getspecific(__key:pthread_key_t):pointer;cdecl;external;
205
 
    function pthread_once(__once_control:ppthread_once_t; __init_routine:tprocedure ):longint;cdecl;external;
 
156
{    function pthread_once(__once_control:ppthread_once_t; __init_routine:tprocedure ):longint;cdecl;external;}
206
157
    function pthread_setcancelstate(__state:longint; __oldstate:plongint):longint;cdecl;external;
207
158
    function pthread_setcanceltype(__type:longint; __oldtype:plongint):longint;cdecl;external;
208
159
    function pthread_cancel(__thread:pthread_t):longint;cdecl;external;
209
160
    procedure pthread_testcancel;cdecl;external;
210
 
    procedure _pthread_cleanup_push(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_routine; __arg:pointer);cdecl;external;
211
 
    procedure _pthread_cleanup_push_defer(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_defer_routine; __arg:pointer);cdecl;external;
212
 
    function pthread_sigmask(__how:longint; __newmask:psigset_t; __oldmask:psigset_t):longint;cdecl;external;
 
161
{    procedure _pthread_cleanup_push(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_routine; __arg:pointer);cdecl;external; }
 
162
{    procedure _pthread_cleanup_push_defer(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_defer_routine; __arg:pointer);cdecl;external;}
 
163
{    function pthread_sigmask(__how:longint; __newmask:psigset_t; __oldmask:psigset_t):longint;cdecl;external;}
213
164
    function pthread_kill(__thread:pthread_t; __signo:longint):longint;cdecl;external;
214
 
    function sigwait(__set:psigset_t; __sig:plongint):longint;cdecl;external;
 
165
{    function sigwait(__set:psigset_t; __sig:plongint):longint;cdecl;external;}
215
166
    function pthread_atfork(__prepare:tprocedure ; __parent:tprocedure ; __child:tprocedure ):longint;cdecl;external;
216
167
    procedure pthread_kill_other_threads_np;cdecl;external;
 
168
 
 
169
    function sem_init (__sem:Psem_t; __pshared:longint; __value:dword):longint;cdecl;external;
 
170
    function sem_destroy  (__sem:Psem_t):longint;cdecl;external;
 
171
    function sem_close (__sem:Psem_t):longint;cdecl;external;
 
172
    function sem_unlink (__name:Pchar):longint;cdecl;external;
 
173
    function sem_wait (__sem:Psem_t):longint;cdecl;external;
 
174
    function sem_trywait  (__sem:Psem_t):longint;cdecl;external;
 
175
    function sem_post     (__sem:Psem_t):longint;cdecl;external;
 
176
    function sem_getvalue (__sem:Psem_t; __sval:Plongint):longint;cdecl;external;
 
177
 
 
178
    function pthread_mutexattr_settype (__attr: Ppthread_mutexattr_t; Kind:Integer): Integer; cdecl;external;
 
179
 
217
180
{$else}
218
181
Var
219
182
    pthread_create : Function(__thread:ppthread_t; __attr:ppthread_attr_t;__start_routine: __start_routine_t;__arg:pointer):longint;cdecl;
257
220
    pthread_key_delete : Function(__key:pthread_key_t):longint;cdecl;
258
221
    pthread_setspecific : Function(__key:pthread_key_t; __pointer:pointer):longint;cdecl;
259
222
    pthread_getspecific : Function(__key:pthread_key_t):pointer;cdecl;
260
 
    pthread_once : Function(__once_control:ppthread_once_t; __init_routine:tprocedure ):longint;cdecl;
 
223
{    pthread_once : Function(__once_control:ppthread_once_t; __init_routine:tprocedure ):longint;cdecl;}
261
224
    pthread_setcancelstate : Function(__state:longint; __oldstate:plongint):longint;cdecl;
262
225
    pthread_setcanceltype : Function(__type:longint; __oldtype:plongint):longint;cdecl;
263
226
    pthread_cancel : Function(__thread:pthread_t):longint;cdecl;
264
227
    pthread_testcancel : Procedure ;cdecl;
265
 
    _pthread_cleanup_push : procedure (__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_routine; __arg:pointer);cdecl;
266
 
    _pthread_cleanup_push_defer : procedure (__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_defer_routine; __arg:pointer);cdecl;
267
 
    pthread_sigmask : Function(__how:longint; __newmask:psigset_t; __oldmask:psigset_t):longint;cdecl;
 
228
{    _pthread_cleanup_push : procedure (__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_routine; __arg:pointer);cdecl;}
 
229
{    _pthread_cleanup_push_defer : procedure (__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_defer_routine; __arg:pointer);cdecl;}
 
230
{    pthread_sigmask : Function(__how:longint; __newmask:psigset_t; __oldmask:psigset_t):longint;cdecl;}
268
231
    pthread_kill : Function(__thread:pthread_t; __signo:longint):longint;cdecl;
269
 
    sigwait : Function(__set:psigset_t; __sig:plongint):longint;cdecl;
 
232
{    sigwait : Function(__set:psigset_t; __sig:plongint):longint;cdecl;}
270
233
    pthread_atfork : Function(__prepare:tprocedure ; __parent:tprocedure ; __child:tprocedure ):longint;cdecl;
271
234
    pthread_kill_other_threads_np : procedure;cdecl;
272
235
 
290
253
begin
291
254
  PThreadDLL:=DlOpen('libpthread.so.0',RTLD_LAZY);
292
255
  Result:=PThreadDLL<>Nil;
293
 
  If Not Result then 
 
256
  If Not Result then
294
257
    exit;
295
258
  Pointer(pthread_create) := dlsym(PthreadDLL,'pthread_create');
296
259
  Pointer(pthread_self) := dlsym(PthreadDLL,'pthread_self');
333
296
  Pointer(pthread_key_delete) := dlsym(PthreadDLL,'pthread_key_delete');
334
297
  Pointer(pthread_setspecific) := dlsym(PthreadDLL,'pthread_setspecific');
335
298
  Pointer(pthread_getspecific) := dlsym(PthreadDLL,'pthread_getspecific');
336
 
  Pointer(pthread_once) := dlsym(PthreadDLL,'pthread_once');
 
299
{  Pointer(pthread_once) := dlsym(PthreadDLL,'pthread_once');}
337
300
  Pointer(pthread_setcancelstate) := dlsym(PthreadDLL,'pthread_setcancelstate');
338
301
  Pointer(pthread_setcanceltype) := dlsym(PthreadDLL,'pthread_setcanceltype');
339
302
  Pointer(pthread_cancel) := dlsym(PthreadDLL,'pthread_cancel');
340
303
  Pointer(pthread_testcancel) := dlsym(PthreadDLL,'pthread_testcancel');
341
 
  Pointer(_pthread_cleanup_push) := dlsym(PthreadDLL,'_pthread_cleanup_push');
342
 
  Pointer(_pthread_cleanup_push_defer) := dlsym(PthreadDLL,'_pthread_cleanup_push_defer');
343
 
  Pointer(pthread_sigmask) := dlsym(PthreadDLL,'pthread_sigmask');
 
304
{  Pointer(_pthread_cleanup_push) := dlsym(PthreadDLL,'_pthread_cleanup_push');}
 
305
{  Pointer(_pthread_cleanup_push_defer) := dlsym(PthreadDLL,'_pthread_cleanup_push_defer');}
 
306
{  Pointer(pthread_sigmask) := dlsym(PthreadDLL,'pthread_sigmask');}
344
307
  Pointer(pthread_kill)  := dlsym(PthreadDLL,'pthread_kill');
345
308
  Pointer(pthread_atfork):= dlsym(PthreadDLL,'pthread_atfork');
346
309
  Pointer(pthread_kill_other_threads_np) := dlsym(PthreadDLL,'pthread_kill_other_threads_np');
360
323
begin
361
324
  Result:=dlclose(PThreadDLL)=0;
362
325
end;
363
 
  
 
326
 
364
327
{$endif}
365
328
 
366
329
{
367
330
  $Log: pthread.inc,v $
368
 
  Revision 1.4  2004/05/23 18:49:18  marco
369
 
   * syncobj stuff
370
 
 
371
 
  Revision 1.3  2003/11/26 20:10:59  michael
372
 
  + New threadmanager implementation
373
 
 
374
 
  Revision 1.2  2003/09/14 20:15:01  marco
375
 
   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
376
 
 
377
 
  Revision 1.1  2002/10/18 18:03:57  marco
378
 
   * From the original systhrds code.
379
 
     Turned out to be not entirely the same as *BSD's (constants with
380
 
     different names, existing and non existing constants), so I decided to
381
 
     make it platform dependant.
382
 
 
383
 
 
384
 
}
 
 
b'\\ No newline at end of file'
 
331
  Revision 1.6  2005/02/14 17:13:30  peter
 
332
    * truncate log
 
333
 
 
334
}