1 /* Linuxthreads - a simple clone()-based implementation of Posix */
2 /* threads for Linux. */
3 /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
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. */
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. */
23 #define __need_sigset_t
25 #include <bits/pthreadtypes.h>
26 #include <bits/initspin.h>
28 #include <bits/uClibc_pthread.h>
36 #define PTHREAD_MUTEX_INITIALIZER \
37 {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
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}
47 #define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0}
50 # define PTHREAD_RWLOCK_INITIALIZER \
51 { __LOCK_INITIALIZER, 0, NULL, NULL, NULL, \
52 PTHREAD_RWLOCK_DEFAULT_NP, PTHREAD_PROCESS_PRIVATE }
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 }
60 /* Values for attributes. */
64 PTHREAD_CREATE_JOINABLE,
65 #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
66 PTHREAD_CREATE_DETACHED
67 #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
72 PTHREAD_INHERIT_SCHED,
73 #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
74 PTHREAD_EXPLICIT_SCHED
75 #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
81 #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
83 #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
88 PTHREAD_MUTEX_ADAPTIVE_NP,
89 PTHREAD_MUTEX_RECURSIVE_NP,
90 PTHREAD_MUTEX_ERRORCHECK_NP,
91 PTHREAD_MUTEX_TIMED_NP
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
100 /* For compatibility. */
101 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_ADAPTIVE_NP
107 PTHREAD_PROCESS_PRIVATE,
108 #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
109 PTHREAD_PROCESS_SHARED
110 #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
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
123 #define PTHREAD_ONCE_INIT 0
125 /* Special constants */
128 /* -1 is distinct from 0 and all errno constants */
129 # define PTHREAD_BARRIER_SERIAL_THREAD -1
132 /* Cleanup buffers */
134 struct _pthread_cleanup_buffer
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. */
146 PTHREAD_CANCEL_ENABLE,
147 #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
148 PTHREAD_CANCEL_DISABLE
149 #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
153 PTHREAD_CANCEL_DEFERRED,
154 #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
155 PTHREAD_CANCEL_ASYNCHRONOUS
156 #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
158 #define PTHREAD_CANCELED ((void *) -1)
161 /* Function for handling threads. */
163 /* Create a thread with given attributes ATTR (or default attributes
164 if ATTR is NULL), and call function START_ROUTINE with given
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;
171 /* Obtain the identifier of the current thread. */
172 extern pthread_t pthread_self (void) __THROW;
174 /* Compare two thread identifiers. */
175 extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW;
177 /* Terminate calling thread. */
178 extern void pthread_exit (void *__retval)
179 __THROW __attribute__ ((__noreturn__));
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
184 extern int pthread_join (pthread_t __th, void **__thread_return) __THROW;
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
190 extern int pthread_detach (pthread_t __th) __THROW;
193 /* Functions for handling attributes. */
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;
200 /* Destroy thread attribute *ATTR. */
201 extern int pthread_attr_destroy (pthread_attr_t *__attr) __THROW;
203 /* Set the `detachstate' attribute in *ATTR according to DETACHSTATE. */
204 extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
205 int __detachstate) __THROW;
207 /* Return in *DETACHSTATE the `detachstate' attribute in *ATTR. */
208 extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
209 int *__detachstate) __THROW;
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
216 /* Return in *PARAM the scheduling parameters of *ATTR. */
217 extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
219 struct sched_param *__restrict __param)
222 /* Set scheduling policy in *ATTR according to POLICY. */
223 extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
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)
231 /* Set scheduling inheritance mode in *ATTR according to INHERIT. */
232 extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
233 int __inherit) __THROW;
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)
240 /* Set scheduling contention scope in *ATTR according to SCOPE. */
241 extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
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;
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;
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)
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;
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)
272 /* Not yet implemented in uClibc! */
275 /* The following two interfaces are intended to replace the last two. They
276 require setting the address as well as the size since only setting the
277 address will make the implementation on some architectures impossible. */
278 extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
279 size_t __stacksize) __THROW;
281 /* Return the previously set address for the stack. */
282 extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
283 void **__restrict __stackaddr,
284 size_t *__restrict __stacksize) __THROW;
288 /* Add information about the minimum stack size needed for the thread
289 to be started. This size must never be less than PTHREAD_STACK_SIZE
290 and must also not exceed the system limits. */
291 extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
292 size_t __stacksize) __THROW;
294 /* Return the currently used minimal stack size. */
295 extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
296 __attr, size_t *__restrict __stacksize)
300 /* Not yet implemented in uClibc! */
303 /* Get thread attributes corresponding to the already running thread TH. */
304 extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
308 /* Functions for scheduling control. */
310 /* Set the scheduling parameters for TARGET_THREAD according to POLICY
312 extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
313 __const struct sched_param *__param)
316 /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
317 extern int pthread_getschedparam (pthread_t __target_thread,
318 int *__restrict __policy,
319 struct sched_param *__restrict __param)
323 /* Determine level of concurrency. */
324 extern int pthread_getconcurrency (void) __THROW;
326 /* Set new concurrency level to LEVEL. */
327 extern int pthread_setconcurrency (int __level) __THROW;
331 /* Not yet implemented in uClibc! */
334 /* Yield the processor to another thread or process.
335 This function is similar to the POSIX `sched_yield' function but
336 might be differently implemented in the case of a m-on-n thread
338 extern int pthread_yield (void) __THROW;
342 /* Functions for mutex handling. */
344 /* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the
345 default values if later is NULL. */
346 extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
347 __const pthread_mutexattr_t *__restrict
348 __mutex_attr) __THROW;
351 extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
353 /* Try to lock MUTEX. */
354 extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
356 /* Wait until lock for MUTEX becomes available and lock it. */
357 extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
360 /* Wait until lock becomes available, or specified time passes. */
361 extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
362 __const struct timespec *__restrict
367 extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
370 /* Functions for handling mutex attributes. */
372 /* Initialize mutex attribute object ATTR with default attributes
373 (kind is PTHREAD_MUTEX_TIMED_NP). */
374 extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
376 /* Destroy mutex attribute object ATTR. */
377 extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
379 /* Get the process-shared flag of the mutex attribute ATTR. */
380 extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
382 int *__restrict __pshared) __THROW;
384 /* Set the process-shared flag of the mutex attribute ATTR. */
385 extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
386 int __pshared) __THROW;
389 /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
390 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
391 PTHREAD_MUTEX_DEFAULT). */
392 extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
395 /* Return in *KIND the mutex kind attribute in *ATTR. */
396 extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
397 __attr, int *__restrict __kind) __THROW;
401 /* Functions for handling conditional variables. */
403 /* Initialize condition variable COND using attributes ATTR, or use
404 the default values if later is NULL. */
405 extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
406 __const pthread_condattr_t *__restrict
407 __cond_attr) __THROW;
409 /* Destroy condition variable COND. */
410 extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
412 /* Wake up one thread waiting for condition variable COND. */
413 extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
415 /* Wake up all threads waiting for condition variables COND. */
416 extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
418 /* Wait for condition variable COND to be signaled or broadcast.
419 MUTEX is assumed to be locked before. */
420 extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
421 pthread_mutex_t *__restrict __mutex) __THROW;
423 /* Wait for condition variable COND to be signaled or broadcast until
424 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
425 absolute time specification; zero is the beginning of the epoch
426 (00:00:00 GMT, January 1, 1970). */
427 extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
428 pthread_mutex_t *__restrict __mutex,
429 __const struct timespec *__restrict
432 /* Functions for handling condition variable attributes. */
434 /* Initialize condition variable attribute ATTR. */
435 extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
437 /* Destroy condition variable attribute ATTR. */
438 extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
440 /* Get the process-shared flag of the condition variable attribute ATTR. */
441 extern int pthread_condattr_getpshared (__const pthread_condattr_t *
443 int *__restrict __pshared) __THROW;
445 /* Set the process-shared flag of the condition variable attribute ATTR. */
446 extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
447 int __pshared) __THROW;
451 /* Functions for handling read-write locks. */
453 /* Initialize read-write lock RWLOCK using attributes ATTR, or use
454 the default values if later is NULL. */
455 extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
456 __const pthread_rwlockattr_t *__restrict
459 /* Destroy read-write lock RWLOCK. */
460 extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
462 /* Acquire read lock for RWLOCK. */
463 extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROW;
465 /* Try to acquire read lock for RWLOCK. */
466 extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROW;
468 /* Acquire write lock for RWLOCK. */
469 extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROW;
471 /* Try to acquire write lock for RWLOCK. */
472 extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROW;
475 /* Not yet implemented in uClibc! */
478 /* Try to acquire read lock for RWLOCK or return after specfied time. */
479 extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
480 __const struct timespec *__restrict
482 /* Try to acquire write lock for RWLOCK or return after specfied time. */
483 extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
484 __const struct timespec *__restrict
491 extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROW;
494 /* Functions for handling read-write lock attributes. */
496 /* Initialize attribute object ATTR with default values. */
497 extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
499 /* Destroy attribute object ATTR. */
500 extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
502 /* Return current setting of process-shared attribute of ATTR in PSHARED. */
503 extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
505 int *__restrict __pshared) __THROW;
507 /* Set process-shared attribute of ATTR to PSHARED. */
508 extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
509 int __pshared) __THROW;
511 /* Return current setting of reader/writer preference. */
512 extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *__attr,
513 int *__pref) __THROW;
515 /* Set reader/write preference. */
516 extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
521 /* Not yet implemented in uClibc! */
524 /* The IEEE Std. 1003.1j-2000 introduces functions to implement
527 /* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
528 be shared between different processes. */
529 extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
532 /* Destroy the spinlock LOCK. */
533 extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
535 /* Wait until spinlock LOCK is retrieved. */
536 extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROW;
538 /* Try to lock spinlock LOCK. */
539 extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROW;
541 /* Release spinlock LOCK. */
542 extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
545 /* Barriers are a also a new feature in 1003.1j-2000. */
547 extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
548 __const pthread_barrierattr_t *__restrict
549 __attr, unsigned int __count) __THROW;
551 extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
553 extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
555 extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
557 extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
559 int *__restrict __pshared) __THROW;
561 extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
562 int __pshared) __THROW;
564 extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
569 /* Functions for handling thread-specific data. */
571 /* Create a key value identifying a location in the thread-specific
572 data area. Each thread maintains a distinct thread-specific data
573 area. DESTR_FUNCTION, if non-NULL, is called with the value
574 associated to that key when the key is destroyed.
575 DESTR_FUNCTION is not called if the value associated is NULL when
576 the key is destroyed. */
577 extern int pthread_key_create (pthread_key_t *__key,
578 void (*__destr_function) (void *)) __THROW;
581 extern int pthread_key_delete (pthread_key_t __key) __THROW;
583 /* Store POINTER in the thread-specific data slot identified by KEY. */
584 extern int pthread_setspecific (pthread_key_t __key,
585 __const void *__pointer) __THROW;
587 /* Return current value of the thread-specific data slot identified by KEY. */
588 extern void *pthread_getspecific (pthread_key_t __key) __THROW;
591 /* Functions for handling initialization. */
593 /* Guarantee that the initialization function INIT_ROUTINE will be called
594 only once, even if pthread_once is executed several times with the
595 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
596 extern variable initialized to PTHREAD_ONCE_INIT. */
597 extern int pthread_once (pthread_once_t *__once_control,
598 void (*__init_routine) (void)) __THROW;
601 /* Functions for handling cancellation. */
603 /* Set cancelability state of current thread to STATE, returning old
604 state in *OLDSTATE if OLDSTATE is not NULL. */
605 extern int pthread_setcancelstate (int __state, int *__oldstate) __THROW;
607 /* Set cancellation state of current thread to TYPE, returning the old
608 type in *OLDTYPE if OLDTYPE is not NULL. */
609 extern int pthread_setcanceltype (int __type, int *__oldtype) __THROW;
611 /* Cancel THREAD immediately or at the next possibility. */
612 extern int pthread_cancel (pthread_t __thread_id) __THROW;
614 /* Test for pending cancellation for the current thread and terminate
615 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
617 extern void pthread_testcancel (void) __THROW;
620 /* Install a cleanup handler: ROUTINE will be called with arguments ARG
621 when the thread is cancelled or calls pthread_exit. ROUTINE will also
622 be called with arguments ARG when the matching pthread_cleanup_pop
623 is executed with non-zero EXECUTE argument.
624 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
625 be used in matching pairs at the same nesting level of braces. */
627 #define pthread_cleanup_push(routine,arg) \
628 { struct _pthread_cleanup_buffer _buffer; \
629 _pthread_cleanup_push (&_buffer, (routine), (arg));
631 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
632 void (*__routine) (void *),
633 void *__arg) __THROW;
635 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
636 If EXECUTE is non-zero, the handler function is called. */
638 #define pthread_cleanup_pop(execute) \
639 _pthread_cleanup_pop (&_buffer, (execute)); }
641 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
642 int __execute) __THROW;
644 /* Install a cleanup handler as pthread_cleanup_push does, but also
645 saves the current cancellation type and set it to deferred cancellation. */
648 # define pthread_cleanup_push_defer_np(routine,arg) \
649 { struct _pthread_cleanup_buffer _buffer; \
650 _pthread_cleanup_push_defer (&_buffer, (routine), (arg));
652 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
653 void (*__routine) (void *),
654 void *__arg) __THROW;
656 /* Remove a cleanup handler as pthread_cleanup_pop does, but also
657 restores the cancellation type that was in effect when the matching
658 pthread_cleanup_push_defer was called. */
660 # define pthread_cleanup_pop_restore_np(execute) \
661 _pthread_cleanup_pop_restore (&_buffer, (execute)); }
663 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
664 int __execute) __THROW;
669 /* Not yet implemented in uClibc! */
672 /* Get ID of CPU-time clock for thread THREAD_ID. */
673 extern int pthread_getcpuclockid (pthread_t __thread_id,
674 clockid_t *__clock_id) __THROW;
679 /* Functions for handling signals. */
680 #include <bits/sigthread.h>
683 /* Functions for handling process creation and process execution. */
685 /* Install handlers to be called when a new process is created with FORK.
686 The PREPARE handler is called in the parent process just before performing
687 FORK. The PARENT handler is called in the parent process just after FORK.
688 The CHILD handler is called in the child process. Each of the three
689 handlers can be NULL, meaning that no handler needs to be called at that
691 PTHREAD_ATFORK can be called several times, in which case the PREPARE
692 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
693 first called before FORK), and the PARENT and CHILD handlers are called
694 in FIFO (first added, first called). */
696 extern int pthread_atfork (void (*__prepare) (void),
697 void (*__parent) (void),
698 void (*__child) (void)) __THROW;
700 /* Terminate all threads in the program except the calling process.
701 Should be called just before invoking one of the exec*() functions. */
703 extern void pthread_kill_other_threads_np (void) __THROW;
707 #endif /* pthread.h */