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