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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [include/] [pthread.h] - Blame information for rev 207

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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