OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [include/] [pthread.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Linuxthreads - a simple clone()-based implementation of Posix        */
2
/* threads for Linux.                                                   */
3
/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr)              */
4
/*                                                                      */
5
/* This program is free software; you can redistribute it and/or        */
6
/* modify it under the terms of the GNU Library General Public License  */
7
/* as published by the Free Software Foundation; either version 2       */
8
/* of the License, or (at your option) any later version.               */
9
/*                                                                      */
10
/* This program is distributed in the hope that it will be useful,      */
11
/* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
12
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
13
/* GNU Library General Public License for more details.                 */
14
 
15
#ifndef _PTHREAD_H
16
#define _PTHREAD_H      1
17
 
18
#include <features.h>
19
 
20
#include <sched.h>
21
#include <time.h>
22
 
23
#define __need_sigset_t
24
#include <signal.h>
25
#include <bits/pthreadtypes.h>
26
#include <bits/initspin.h>
27
#ifdef _LIBC
28
#include <bits/uClibc_pthread.h>
29
#endif
30
 
31
 
32
__BEGIN_DECLS
33
 
34
/* Initializers.  */
35
 
36
#define PTHREAD_MUTEX_INITIALIZER \
37
  {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
38
#ifdef __USE_GNU
39
# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
40
  {0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __LOCK_INITIALIZER}
41
# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
42
  {0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __LOCK_INITIALIZER}
43
# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
44
  {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
45
#endif
46
 
47
#define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0}
48
 
49
#ifdef __USE_UNIX98
50
# define PTHREAD_RWLOCK_INITIALIZER \
51
  { __LOCK_INITIALIZER, 0, NULL, NULL, NULL,                                   \
52
    PTHREAD_RWLOCK_DEFAULT_NP, PTHREAD_PROCESS_PRIVATE }
53
#endif
54
#ifdef __USE_GNU
55
# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
56
  { __LOCK_INITIALIZER, 0, NULL, NULL, NULL,                                   \
57
    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_PROCESS_PRIVATE }
58
#endif
59
 
60
/* Values for attributes.  */
61
 
62
enum
63
{
64
  PTHREAD_CREATE_JOINABLE,
65
#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
66
  PTHREAD_CREATE_DETACHED
67
#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
68
};
69
 
70
enum
71
{
72
  PTHREAD_INHERIT_SCHED,
73
#define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED
74
  PTHREAD_EXPLICIT_SCHED
75
#define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED
76
};
77
 
78
enum
79
{
80
  PTHREAD_SCOPE_SYSTEM,
81
#define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM
82
  PTHREAD_SCOPE_PROCESS
83
#define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS
84
};
85
 
86
enum
87
{
88
  PTHREAD_MUTEX_ADAPTIVE_NP,
89
  PTHREAD_MUTEX_RECURSIVE_NP,
90
  PTHREAD_MUTEX_ERRORCHECK_NP,
91
  PTHREAD_MUTEX_TIMED_NP
92
#ifdef __USE_UNIX98
93
  ,
94
  PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_ADAPTIVE_NP,
95
  PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
96
  PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
97
  PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
98
#endif
99
#ifdef __USE_GNU
100
  /* For compatibility.  */
101
  , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_ADAPTIVE_NP
102
#endif
103
};
104
 
105
enum
106
{
107
  PTHREAD_PROCESS_PRIVATE,
108
#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
109
  PTHREAD_PROCESS_SHARED
110
#define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED
111
};
112
 
113
#ifdef __USE_UNIX98
114
enum
115
{
116
  PTHREAD_RWLOCK_PREFER_READER_NP,
117
  PTHREAD_RWLOCK_PREFER_WRITER_NP,
118
  PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
119
  PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP
120
};
121
#endif  /* Unix98 */
122
 
123
#define PTHREAD_ONCE_INIT 0
124
 
125
/* Special constants */
126
 
127
#ifdef __USE_XOPEN2K
128
/* -1 is distinct from 0 and all errno constants */
129
# define PTHREAD_BARRIER_SERIAL_THREAD -1
130
#endif
131
 
132
/* Cleanup buffers */
133
 
134
struct _pthread_cleanup_buffer
135
{
136
  void (*__routine) (void *);             /* Function to call.  */
137
  void *__arg;                            /* Its argument.  */
138
  int __canceltype;                       /* Saved cancellation type. */
139
  struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions.  */
140
};
141
 
142
/* Cancellation */
143
 
144
enum
145
{
146
  PTHREAD_CANCEL_ENABLE,
147
#define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE
148
  PTHREAD_CANCEL_DISABLE
149
#define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE
150
};
151
enum
152
{
153
  PTHREAD_CANCEL_DEFERRED,
154
#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
155
  PTHREAD_CANCEL_ASYNCHRONOUS
156
#define PTHREAD_CANCEL_ASYNCHRONOUS     PTHREAD_CANCEL_ASYNCHRONOUS
157
};
158
#define PTHREAD_CANCELED ((void *) -1)
159
 
160
 
161
/* Function for handling threads.  */
162
 
163
/* Create a thread with given attributes ATTR (or default attributes
164
   if ATTR is NULL), and call function START_ROUTINE with given
165
   arguments ARG.  */
166
extern int pthread_create (pthread_t *__restrict __thread_id,
167
                           __const pthread_attr_t *__restrict __attr,
168
                           void *(*__start_routine) (void *),
169
                           void *__restrict __arg) __THROW;
170
 
171
/* Obtain the identifier of the current thread.  */
172
extern pthread_t pthread_self (void) __THROW;
173
 
174
/* Compare two thread identifiers.  */
175
extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW;
176
 
177
/* Terminate calling thread.  */
178
extern void pthread_exit (void *__retval)
179
     __THROW __attribute__ ((__noreturn__));
180
 
181
/* Make calling thread wait for termination of the thread TH.  The
182
   exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
183
   is not NULL.  */
184
extern int pthread_join (pthread_t __th, void **__thread_return) __THROW;
185
 
186
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
187
   The resources of TH will therefore be freed immediately when it
188
   terminates, instead of waiting for another thread to perform PTHREAD_JOIN
189
   on it.  */
190
extern int pthread_detach (pthread_t __th) __THROW;
191
 
192
 
193
/* Functions for handling attributes.  */
194
 
195
/* Initialize thread attribute *ATTR with default attributes
196
   (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
197
    no user-provided stack).  */
198
extern int pthread_attr_init (pthread_attr_t *__attr) __THROW;
199
 
200
/* Destroy thread attribute *ATTR.  */
201
extern int pthread_attr_destroy (pthread_attr_t *__attr) __THROW;
202
 
203
/* Set the `detachstate' attribute in *ATTR according to DETACHSTATE.  */
204
extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
205
                                        int __detachstate) __THROW;
206
 
207
/* Return in *DETACHSTATE the `detachstate' attribute in *ATTR.  */
208
extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
209
                                        int *__detachstate) __THROW;
210
 
211
/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */
212
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
213
                                       __const struct sched_param *__restrict
214
                                       __param) __THROW;
215
 
216
/* Return in *PARAM the scheduling parameters of *ATTR.  */
217
extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
218
                                       __attr,
219
                                       struct sched_param *__restrict __param)
220
     __THROW;
221
 
222
/* Set scheduling policy in *ATTR according to POLICY.  */
223
extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
224
     __THROW;
225
 
226
/* Return in *POLICY the scheduling policy of *ATTR.  */
227
extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
228
                                        __attr, int *__restrict __policy)
229
     __THROW;
230
 
231
/* Set scheduling inheritance mode in *ATTR according to INHERIT.  */
232
extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
233
                                         int __inherit) __THROW;
234
 
235
/* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */
236
extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
237
                                         __attr, int *__restrict __inherit)
238
     __THROW;
239
 
240
/* Set scheduling contention scope in *ATTR according to SCOPE.  */
241
extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
242
     __THROW;
243
 
244
/* Return in *SCOPE the scheduling contention scope of *ATTR.  */
245
extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
246
                                  int *__restrict __scope) __THROW;
247
 
248
#ifdef __USE_UNIX98
249
/* Set the size of the guard area at the bottom of the thread.  */
250
extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
251
                                      size_t __guardsize) __THROW;
252
 
253
/* Get the size of the guard area at the bottom of the thread.  */
254
extern int pthread_attr_getguardsize (__const pthread_attr_t *__restrict
255
                                      __attr, size_t *__restrict __guardsize)
256
     __THROW;
257
#endif
258
 
259
/* Set the starting address of the stack of the thread to be created.
260
   Depending on whether the stack grows up or down the value must either
261
   be higher or lower than all the address in the memory block.  The
262
   minimal size of the block must be PTHREAD_STACK_SIZE.  */
263
extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
264
                                      void *__stackaddr) __THROW;
265
 
266
/* Return the previously set address for the stack.  */
267
extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
268
                                      __attr, void **__restrict __stackaddr)
269
     __THROW;
270
 
271
#ifdef __USE_XOPEN2K
272
/* The following two interfaces are intended to replace the last two.  They
273
   require setting the address as well as the size since only setting the
274
   address will make the implementation on some architectures impossible.  */
275
extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
276
                                  size_t __stacksize) __THROW;
277
 
278
/* Return the previously set address for the stack.  */
279
extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
280
                                  void **__restrict __stackaddr,
281
                                  size_t *__restrict __stacksize) __THROW;
282
#endif
283
 
284
/* Add information about the minimum stack size needed for the thread
285
   to be started.  This size must never be less than PTHREAD_STACK_SIZE
286
   and must also not exceed the system limits.  */
287
extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
288
                                      size_t __stacksize) __THROW;
289
 
290
/* Return the currently used minimal stack size.  */
291
extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
292
                                      __attr, size_t *__restrict __stacksize)
293
     __THROW;
294
 
295
#ifdef __USE_GNU
296
/* Get thread attributes corresponding to the already running thread TH.  */
297
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
298
#endif
299
 
300
/* Functions for scheduling control.  */
301
 
302
/* Set the scheduling parameters for TARGET_THREAD according to POLICY
303
   and *PARAM.  */
304
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
305
                                  __const struct sched_param *__param)
306
     __THROW;
307
 
308
/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD.  */
309
extern int pthread_getschedparam (pthread_t __target_thread,
310
                                  int *__restrict __policy,
311
                                  struct sched_param *__restrict __param)
312
     __THROW;
313
 
314
#ifdef __USE_UNIX98
315
/* Determine level of concurrency.  */
316
extern int pthread_getconcurrency (void) __THROW;
317
 
318
/* Set new concurrency level to LEVEL.  */
319
extern int pthread_setconcurrency (int __level) __THROW;
320
#endif
321
 
322
#ifdef __USE_GNU
323
/* Yield the processor to another thread or process.
324
   This function is similar to the POSIX `sched_yield' function but
325
   might be differently implemented in the case of a m-on-n thread
326
   implementation.  */
327
extern int pthread_yield (void) __THROW;
328
#endif
329
 
330
/* Functions for mutex handling.  */
331
 
332
/* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the
333
   default values if later is NULL.  */
334
extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
335
                               __const pthread_mutexattr_t *__restrict
336
                               __mutex_attr) __THROW;
337
 
338
/* Destroy MUTEX.  */
339
extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
340
 
341
/* Try to lock MUTEX.  */
342
extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
343
 
344
/* Wait until lock for MUTEX becomes available and lock it.  */
345
extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
346
 
347
#ifdef __USE_XOPEN2K
348
/* Wait until lock becomes available, or specified time passes. */
349
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
350
                                    __const struct timespec *__restrict
351
                                    __abstime) __THROW;
352
#endif
353
 
354
/* Unlock MUTEX.  */
355
extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
356
 
357
 
358
/* Functions for handling mutex attributes.  */
359
 
360
/* Initialize mutex attribute object ATTR with default attributes
361
   (kind is PTHREAD_MUTEX_TIMED_NP).  */
362
extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
363
 
364
/* Destroy mutex attribute object ATTR.  */
365
extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
366
 
367
/* Get the process-shared flag of the mutex attribute ATTR.  */
368
extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
369
                                         __restrict __attr,
370
                                         int *__restrict __pshared) __THROW;
371
 
372
/* Set the process-shared flag of the mutex attribute ATTR.  */
373
extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
374
                                         int __pshared) __THROW;
375
 
376
#ifdef __USE_UNIX98
377
/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
378
   PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
379
   PTHREAD_MUTEX_DEFAULT).  */
380
extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
381
     __THROW;
382
 
383
/* Return in *KIND the mutex kind attribute in *ATTR.  */
384
extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
385
                                      __attr, int *__restrict __kind) __THROW;
386
#endif
387
 
388
 
389
/* Functions for handling conditional variables.  */
390
 
391
/* Initialize condition variable COND using attributes ATTR, or use
392
   the default values if later is NULL.  */
393
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
394
                              __const pthread_condattr_t *__restrict
395
                              __cond_attr) __THROW;
396
 
397
/* Destroy condition variable COND.  */
398
extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
399
 
400
/* Wake up one thread waiting for condition variable COND.  */
401
extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
402
 
403
/* Wake up all threads waiting for condition variables COND.  */
404
extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
405
 
406
/* Wait for condition variable COND to be signaled or broadcast.
407
   MUTEX is assumed to be locked before.  */
408
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
409
                              pthread_mutex_t *__restrict __mutex) __THROW;
410
 
411
/* Wait for condition variable COND to be signaled or broadcast until
412
   ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an
413
   absolute time specification; zero is the beginning of the epoch
414
   (00:00:00 GMT, January 1, 1970).  */
415
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
416
                                   pthread_mutex_t *__restrict __mutex,
417
                                   __const struct timespec *__restrict
418
                                   __abstime) __THROW;
419
 
420
/* Functions for handling condition variable attributes.  */
421
 
422
/* Initialize condition variable attribute ATTR.  */
423
extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
424
 
425
/* Destroy condition variable attribute ATTR.  */
426
extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
427
 
428
/* Get the process-shared flag of the condition variable attribute ATTR.  */
429
extern int pthread_condattr_getpshared (__const pthread_condattr_t *
430
                                        __restrict __attr,
431
                                        int *__restrict __pshared) __THROW;
432
 
433
/* Set the process-shared flag of the condition variable attribute ATTR.  */
434
extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
435
                                        int __pshared) __THROW;
436
 
437
 
438
#ifdef __USE_UNIX98
439
/* Functions for handling read-write locks.  */
440
 
441
/* Initialize read-write lock RWLOCK using attributes ATTR, or use
442
   the default values if later is NULL.  */
443
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
444
                                __const pthread_rwlockattr_t *__restrict
445
                                __attr) __THROW;
446
 
447
/* Destroy read-write lock RWLOCK.  */
448
extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
449
 
450
/* Acquire read lock for RWLOCK.  */
451
extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROW;
452
 
453
/* Try to acquire read lock for RWLOCK.  */
454
extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROW;
455
 
456
#ifdef __USE_XOPEN2K
457
/* Try to acquire read lock for RWLOCK or return after specfied time.  */
458
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
459
                                       __const struct timespec *__restrict
460
                                       __abstime) __THROW;
461
#endif
462
 
463
/* Acquire write lock for RWLOCK.  */
464
extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROW;
465
 
466
/* Try to acquire write lock for RWLOCK.  */
467
extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROW;
468
 
469
#ifdef __USE_XOPEN2K
470
/* Try to acquire write lock for RWLOCK or return after specfied time.  */
471
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
472
                                       __const struct timespec *__restrict
473
                                       __abstime) __THROW;
474
#endif
475
 
476
/* Unlock RWLOCK.  */
477
extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROW;
478
 
479
 
480
/* Functions for handling read-write lock attributes.  */
481
 
482
/* Initialize attribute object ATTR with default values.  */
483
extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
484
 
485
/* Destroy attribute object ATTR.  */
486
extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
487
 
488
/* Return current setting of process-shared attribute of ATTR in PSHARED.  */
489
extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
490
                                          __restrict __attr,
491
                                          int *__restrict __pshared) __THROW;
492
 
493
/* Set process-shared attribute of ATTR to PSHARED.  */
494
extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
495
                                          int __pshared) __THROW;
496
 
497
/* Return current setting of reader/writer preference.  */
498
extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *__attr,
499
                                          int *__pref) __THROW;
500
 
501
/* Set reader/write preference.  */
502
extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
503
                                          int __pref) __THROW;
504
#endif
505
 
506
#ifdef __USE_XOPEN2K
507
/* The IEEE Std. 1003.1j-2000 introduces functions to implement
508
   spinlocks.  */
509
 
510
/* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can
511
   be shared between different processes.  */
512
extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
513
     __THROW;
514
 
515
/* Destroy the spinlock LOCK.  */
516
extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
517
 
518
/* Wait until spinlock LOCK is retrieved.  */
519
extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROW;
520
 
521
/* Try to lock spinlock LOCK.  */
522
extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROW;
523
 
524
/* Release spinlock LOCK.  */
525
extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
526
 
527
 
528
/* Barriers are a also a new feature in 1003.1j-2000. */
529
 
530
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
531
                                 __const pthread_barrierattr_t *__restrict
532
                                 __attr, unsigned int __count) __THROW;
533
 
534
extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
535
 
536
extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
537
 
538
extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
539
 
540
extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
541
                                           __restrict __attr,
542
                                           int *__restrict __pshared) __THROW;
543
 
544
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
545
                                           int __pshared) __THROW;
546
 
547
extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
548
#endif
549
 
550
 
551
/* Functions for handling thread-specific data.  */
552
 
553
/* Create a key value identifying a location in the thread-specific
554
   data area.  Each thread maintains a distinct thread-specific data
555
   area.  DESTR_FUNCTION, if non-NULL, is called with the value
556
   associated to that key when the key is destroyed.
557
   DESTR_FUNCTION is not called if the value associated is NULL when
558
   the key is destroyed.  */
559
extern int pthread_key_create (pthread_key_t *__key,
560
                               void (*__destr_function) (void *)) __THROW;
561
 
562
/* Destroy KEY.  */
563
extern int pthread_key_delete (pthread_key_t __key) __THROW;
564
 
565
/* Store POINTER in the thread-specific data slot identified by KEY. */
566
extern int pthread_setspecific (pthread_key_t __key,
567
                                __const void *__pointer) __THROW;
568
 
569
/* Return current value of the thread-specific data slot identified by KEY.  */
570
extern void *pthread_getspecific (pthread_key_t __key) __THROW;
571
 
572
 
573
/* Functions for handling initialization.  */
574
 
575
/* Guarantee that the initialization function INIT_ROUTINE will be called
576
   only once, even if pthread_once is executed several times with the
577
   same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
578
   extern variable initialized to PTHREAD_ONCE_INIT.  */
579
extern int pthread_once (pthread_once_t *__once_control,
580
                         void (*__init_routine) (void)) __THROW;
581
 
582
 
583
/* Functions for handling cancellation.  */
584
 
585
/* Set cancelability state of current thread to STATE, returning old
586
   state in *OLDSTATE if OLDSTATE is not NULL.  */
587
extern int pthread_setcancelstate (int __state, int *__oldstate) __THROW;
588
 
589
/* Set cancellation state of current thread to TYPE, returning the old
590
   type in *OLDTYPE if OLDTYPE is not NULL.  */
591
extern int pthread_setcanceltype (int __type, int *__oldtype) __THROW;
592
 
593
/* Cancel THREAD immediately or at the next possibility.  */
594
extern int pthread_cancel (pthread_t __thread_id) __THROW;
595
 
596
/* Test for pending cancellation for the current thread and terminate
597
   the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
598
   cancelled.  */
599
extern void pthread_testcancel (void) __THROW;
600
 
601
 
602
/* Install a cleanup handler: ROUTINE will be called with arguments ARG
603
   when the thread is cancelled or calls pthread_exit.  ROUTINE will also
604
   be called with arguments ARG when the matching pthread_cleanup_pop
605
   is executed with non-zero EXECUTE argument.
606
   pthread_cleanup_push and pthread_cleanup_pop are macros and must always
607
   be used in matching pairs at the same nesting level of braces. */
608
 
609
#define pthread_cleanup_push(routine,arg) \
610
  { struct _pthread_cleanup_buffer _buffer;                                   \
611
    _pthread_cleanup_push (&_buffer, (routine), (arg));
612
 
613
extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
614
                                   void (*__routine) (void *),
615
                                   void *__arg) __THROW;
616
 
617
/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
618
   If EXECUTE is non-zero, the handler function is called. */
619
 
620
#define pthread_cleanup_pop(execute) \
621
    _pthread_cleanup_pop (&_buffer, (execute)); }
622
 
623
extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
624
                                  int __execute) __THROW;
625
 
626
/* Install a cleanup handler as pthread_cleanup_push does, but also
627
   saves the current cancellation type and set it to deferred cancellation.  */
628
 
629
#ifdef __USE_GNU
630
# define pthread_cleanup_push_defer_np(routine,arg) \
631
  { struct _pthread_cleanup_buffer _buffer;                                   \
632
    _pthread_cleanup_push_defer (&_buffer, (routine), (arg));
633
 
634
extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
635
                                         void (*__routine) (void *),
636
                                         void *__arg) __THROW;
637
 
638
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
639
   restores the cancellation type that was in effect when the matching
640
   pthread_cleanup_push_defer was called.  */
641
 
642
# define pthread_cleanup_pop_restore_np(execute) \
643
  _pthread_cleanup_pop_restore (&_buffer, (execute)); }
644
 
645
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
646
                                          int __execute) __THROW;
647
#endif
648
 
649
 
650
#ifdef __USE_XOPEN2K
651
/* Get ID of CPU-time clock for thread THREAD_ID.  */
652
extern int pthread_getcpuclockid (pthread_t __thread_id,
653
                                  clockid_t *__clock_id) __THROW;
654
#endif
655
 
656
 
657
/* Functions for handling signals.  */
658
#include <bits/sigthread.h>
659
 
660
 
661
/* Functions for handling process creation and process execution.  */
662
 
663
/* Install handlers to be called when a new process is created with FORK.
664
   The PREPARE handler is called in the parent process just before performing
665
   FORK. The PARENT handler is called in the parent process just after FORK.
666
   The CHILD handler is called in the child process.  Each of the three
667
   handlers can be NULL, meaning that no handler needs to be called at that
668
   point.
669
   PTHREAD_ATFORK can be called several times, in which case the PREPARE
670
   handlers are called in LIFO order (last added with PTHREAD_ATFORK,
671
   first called before FORK), and the PARENT and CHILD handlers are called
672
   in FIFO (first added, first called).  */
673
 
674
extern int pthread_atfork (void (*__prepare) (void),
675
                           void (*__parent) (void),
676
                           void (*__child) (void)) __THROW;
677
 
678
/* Terminate all threads in the program except the calling process.
679
   Should be called just before invoking one of the exec*() functions.  */
680
 
681
extern void pthread_kill_other_threads_np (void) __THROW;
682
 
683
__END_DECLS
684
 
685
#endif  /* pthread.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.