source: rtems/c/src/exec/posix/base/pthread.h @ 05195890

4.104.114.84.9
Last change on this file since 05195890 was 05195890, checked in by Joel Sherrill <joel.sherrill@…>, on May 22, 1996 at 10:31:51 PM

These files have been modified in the initial pass at getting the portion
of the POSIX API necessary to support the GNAT runtime to initially compile.
We now have verified that the specifications for the necessary routines
are correct per the POSIX standards we have.

The removed files were moved to newlib as they were duplicates of files
already included there.

  • Property mode set to 100644
File size: 9.5 KB
Line 
1/*  pthread.h
2 *
3 *  $Id$
4 */
5
6#ifndef __PTHREAD_h
7#define __PTHREAD_h
8
9#include <sys/features.h>
10
11#if defined(_POSIX_THREADS)
12
13#include <sys/types.h>
14#include <time.h>
15#include <sys/sched.h>
16
17/*
18 *  3.1.3 Register Fork Handlers, P1003.1c/Draft 10, P1003.1c/Draft 10, p. 27
19 */
20
21int pthread_atfork(
22  void (*prepare)(void),
23  void (*parent)(void),
24  void (*child)(void)
25);
26
27/*
28 *  11.3.1 Mutex Initialization Attributes, P1003.1c/Draft 10, p. 81
29 */
30
31int pthread_mutexattr_init(
32  pthread_mutexattr_t *attr
33);
34
35int pthread_mutexattr_destroy(
36  pthread_mutexattr_t *attr
37);
38
39int pthread_mutexattr_getpshared(
40  const pthread_mutexattr_t *attr,
41  int                       *pshared
42);
43
44int pthread_mutexattr_setpshared(
45  pthread_mutexattr_t *attr,
46  int                  pshared
47);
48
49/*
50 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
51 */
52
53int pthread_mutex_init(
54  pthread_mutex_t           *mutex,
55  const pthread_mutexattr_t *attr
56);
57
58int pthread_mutex_destroy(
59  pthread_mutex_t           *mutex
60);
61
62/*
63 *  This is used to statically initialize a pthread_mutex_t. Example:
64 *
65 *  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
66 */
67
68#define PTHREAD_MUTEX_INITIALIZER  ((pthread_mutex_t) 0xFFFFFFFF)
69
70/*
71 *  11.3.3 Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
72 *       
73 *  NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29
74 */
75
76int pthread_mutex_lock(
77  pthread_mutex_t           *mutex
78);
79
80int pthread_mutex_trylock(
81  pthread_mutex_t           *mutex
82);
83
84int pthread_mutex_unlock(
85  pthread_mutex_t           *mutex
86);
87
88#if defined(_POSIX_TIMEOUTS)
89
90int pthread_mutex_timedlock(
91  pthread_mutex_t       *mutex,
92  const struct timespec *timeout
93);
94
95#endif /* _POSIX_TIMEOUTS */
96
97/*
98 *  11.4.1 Condition Variable Initialization Attributes,
99 *            P1003.1c/Draft 10, p. 96
100 */
101 
102int pthread_condattr_init(
103  pthread_condattr_t *attr
104);
105 
106int pthread_condattr_destroy(
107  pthread_condattr_t *attr
108);
109 
110int pthread_condattr_getpshared(
111  const pthread_condattr_t *attr,
112  int                      *pshared
113);
114 
115int pthread_condattr_setpshared(
116  pthread_condattr_t  *attr,
117  int                  pshared
118);
119 
120/*
121 *  11.4.2 Initializing and Destroying a Condition Variable,
122 *         P1003.1c/Draft 10, p. 87
123 */
124 
125int pthread_cond_init(
126  pthread_cond_t           *cond,
127  const pthread_condattr_t *attr
128);
129 
130int pthread_cond_destroy(
131  pthread_cond_t           *mutex
132);
133 
134/*
135 *  This is used to statically initialize a pthread_cond_t. Example:
136 *
137 *  pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
138 */
139 
140#define PTHREAD_COND_INITIALIZER  ((pthread_mutex_t) 0xFFFFFFFF)
141 
142/*
143 *  11.4.3 Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101
144 */
145 
146int pthread_cond_signal(
147  pthread_cond_t   *cond
148);
149 
150int pthread_cond_broadcast(
151  pthread_cond_t   *cond
152);
153 
154/*
155 *  11.4.4 Waiting on a Condition, P1003.1c/Draft 10, p. 105
156 */
157 
158int pthread_cond_wait(
159  pthread_cond_t     *cond,
160  pthread_mutex_t    *mutex
161);
162 
163int pthread_cond_timedwait(
164  pthread_cond_t        *cond,
165  pthread_mutex_t       *mutex,
166  const struct timespec *abstime
167);
168 
169#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
170
171/*
172 *  13.5.1 Thread Creation Scheduling Attributes, P1003.1c/Draft 10, p. 120
173 */
174
175int pthread_attr_setscope(
176  pthread_attr_t  *attr,
177  int              contentionscope
178);
179
180int pthread_attr_getscope(
181  const pthread_attr_t  *attr,
182  int                   *contentionscope
183);
184
185#define PTHREAD_INHERIT_SCHED  0      /* scheduling policy and associated */
186                                      /*   attributes are inherited from */
187                                      /*   the calling thread. */
188#define PTHREAD_EXPLICIT_SCHED 0      /* set from provided attribute object */
189
190int pthread_attr_setinheritsched(
191  pthread_attr_t  *attr,
192  int              inheritsched
193);
194
195int pthread_attr_getinheritsched(
196  const pthread_attr_t  *attr,
197  int                   *inheritsched
198);
199
200int pthread_attr_setschedpolicy(
201  pthread_attr_t  *attr,
202  int              policy
203);
204
205int pthread_attr_getschedpolicy(
206  const pthread_attr_t  *attr,
207  int                   *policy
208);
209
210#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
211
212int pthread_attr_setschedparam(
213  pthread_attr_t            *attr,
214  const struct sched_param  *param
215);
216
217int pthread_attr_getschedparam(
218  const pthread_attr_t  *attr,
219  struct sched_param    *param
220);
221
222#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
223
224/*
225 *  13.5.2 Dynamic Thread Scheduling Parameters Access,
226 *         P1003.1c/Draft 10, p. 124
227 */
228
229int pthread_getschedparam(
230  pthread_t           thread,
231  int                *policy,
232  struct sched_param *param
233);
234
235int pthread_setschedparam(
236  pthread_t           thread,
237  int                 policy,
238  struct sched_param *param
239);
240
241#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
242
243#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
244
245/*
246 *  13.6.1 Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128
247 */
248 
249/*
250 *  Values for protocol.
251 */
252
253#define PTHREAD_PRIO_NONE    0
254#define PTHREAD_PRIO_INHERIT 1
255#define PTHREAD_PRIO_PROTECT 2
256
257int pthread_mutexattr_setprotocol(
258  pthread_mutexattr_t   *attr,
259  int                    protocol
260);
261
262int pthread_mutexattr_getprotocol(
263  const pthread_mutexattr_t   *attr,
264  int                         *protocol
265);
266
267int pthread_mutexattr_setprioceiling(
268  pthread_mutexattr_t   *attr,
269  int                    prioceiling
270);
271
272int pthread_mutexattr_getprioceiling(
273  const pthread_mutexattr_t   *attr,
274  int                         *prioceiling
275);
276
277#endif /* _POSIX_THREAD_PRIO_INHERIT || _POSIX_THREAD_PRIO_PROTECT */
278
279#if defined(_POSIX_THREAD_PRIO_PROTECT)
280
281/*
282 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
283 */
284
285int pthread_mutex_setprioceiling(
286  pthread_mutex_t   *mutex,
287  int                prioceiling,
288  int               *old_ceiling
289);
290 
291int pthread_mutex_getprioceiling(
292  pthread_mutex_t   *mutex,
293  int               *prioceiling
294);
295
296#endif /* _POSIX_THREAD_PRIO_PROTECT */
297
298/*
299 *  16.1.1 Thread Creation Attributes, P1003.1c/Draft 10, p, 140
300 */
301
302int pthread_attr_init(
303  pthread_attr_t  *attr
304);
305
306int pthread_attr_destroy(
307  pthread_attr_t  *attr
308);
309 
310int pthread_attr_getstacksize(
311  const pthread_attr_t  *attr,
312  size_t                *stacksize
313);
314 
315int pthread_attr_setstacksize(
316  pthread_attr_t  *attr,
317  size_t           stacksize
318);
319 
320int pthread_attr_getstackaddr(
321  const pthread_attr_t   *attr,
322  void                  **stackaddr
323);
324 
325int pthread_attr_setstackaddr(
326  pthread_attr_t  *attr,
327  void            *stackaddr
328);
329 
330int pthread_attr_getdetachstate(
331  const pthread_attr_t  *attr,
332  int                   *detachstate
333);
334 
335int pthread_attr_setdetachstate(
336  pthread_attr_t  *attr,
337  int              detachstate
338);
339
340/*
341 *  16.1.2 Thread Creation, P1003.1c/Draft 10, p. 144
342 */
343
344int pthread_create(
345  pthread_t              *thread,
346  const pthread_attr_t   *attr,
347  void                 *(*start_routine)( void * ),
348  void                   *arg
349);
350
351/*
352 *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
353 */
354
355int pthread_join(
356  pthread_t   thread,
357  void      **value_ptr
358);
359
360/*
361 *  16.1.4 Detaching a Thread, P1003.1c/Draft 10, p. 149
362 */
363
364int pthread_detach(
365  pthread_t   thread
366);
367
368/*
369 * 16.1.5.1 Thread Termination, p1003.1c/Draft 10, p. 150
370 */
371
372void pthread_exit(
373  void  *value_ptr
374);
375
376/*
377 * 16.1.6 Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX
378 */
379
380pthread_t pthread_self( void );
381
382/*
383 *  16.1.7 Compare Thread IDs, p1003.1c/Draft 10, p. 153
384 */
385
386int pthread_equal( 
387  pthread_t  t1,
388  pthread_t  t2
389);
390
391/*
392 *  16.1.8 Dynamic Package Initialization
393 */
394
395/*
396 *  This is used to statically initialize a pthread_once_t. Example:
397 *
398 *  pthread_once_t once = PTHREAD_ONCE_INITIALIZER;
399 */
400 
401#define PTHREAD_ONCE_INITIALIZER  { TRUE, FALSE }
402 
403int pthread_once(
404  pthread_once_t  *once_control,
405  void           (*init_routine)(void)
406);
407
408/*
409 *  17.1.1 Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163
410 */
411
412int pthread_key_create(
413  pthread_key_t  *key,
414  void          (*destructor)( void * )
415);
416
417/*
418 *  17.1.2 Thread-Specific Data Management, P1003.1c/Draft 10, p. 165
419 */
420
421int pthread_setspecific(
422  pthread_key_t  key,
423  const void    *value
424);
425
426void *pthread_getspecific(
427  pthread_key_t  key
428);
429
430/*
431 *  17.1.3 Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167
432 */
433
434int pthread_key_delete(
435  pthread_key_t  key
436);
437
438/*
439 *  18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
440 */
441
442#define PTHREAD_CANCEL_ENABLE  0
443#define PTHREAD_CANCEL_DISABLE 1
444
445#define PTHREAD_CANCEL_DEFERRED 0
446#define PTHREAD_CANCEL_ASYNCHRONOUS 1
447
448int pthread_cancel(
449  pthread_t  thread
450);
451
452/*
453 *  18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183
454 */
455
456int pthread_setcancelstate( 
457  int  state,
458  int *oldstate
459);
460
461int pthread_setcanceltype(
462  int  type,
463  int *oldtype
464);
465
466void pthread_testcancel( void );
467
468/*
469 *  18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184
470 */
471
472void pthread_cleanup_push(
473  void   (*routine)( void * ),
474  void    *arg
475);
476
477void pthread_cleanup_pop(
478  int    execute
479);
480
481#if defined(_POSIX_THREAD_CPUTIME)
482 
483/*
484 *  20.1.6 Accessing a Thread CPU-time Clock, P1003.4b/D8, p. 58
485 */
486 
487int pthread_getcpuclockid(
488  pthread_t      pid,
489  clockid_t *clock_id
490);
491 
492/*
493 *  20.1.7 CPU-time Clock Thread Creation Attribute, P1003.4b/D8, p. 59
494 */
495
496int pthread_attr_setcputime(
497  pthread_attr_t  *attr,
498  int              clock_allowed
499);
500
501int pthread_attr_getcputime(
502  pthread_attr_t  *attr,
503  int             *clock_allowed
504);
505
506#endif /* defined(_POSIX_THREAD_CPUTIME) */
507
508#endif /* defined(_POSIX_THREADS) */
509#endif
510/* end of include file */
Note: See TracBrowser for help on using the repository browser.