1 /* Threads compatibility routines for libgcc2 and libobjc. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef GCC_GTHR_POSIX_H
28 #define GCC_GTHR_POSIX_H
30 /* POSIX threads specific definitions.
31 Easy, since the interface is just one-to-one mapping. */
34 #define __GTHREADS_CXX0X 1
38 #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
39 || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
41 # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
42 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
44 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
48 typedef pthread_t __gthread_t
;
49 typedef pthread_key_t __gthread_key_t
;
50 typedef pthread_once_t __gthread_once_t
;
51 typedef pthread_mutex_t __gthread_mutex_t
;
52 typedef pthread_mutex_t __gthread_recursive_mutex_t
;
53 typedef pthread_cond_t __gthread_cond_t
;
54 typedef struct timespec __gthread_time_t
;
56 /* POSIX like conditional variables are supported. Please look at comments
57 in gthr.h for details. */
58 #define __GTHREAD_HAS_COND 1
60 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
61 #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
62 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
63 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
64 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
65 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
66 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
68 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
70 #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
71 #define __GTHREAD_TIME_INIT {0,0}
73 #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
74 # undef __GTHREAD_MUTEX_INIT
75 # define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
77 #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
78 # undef __GTHREAD_RECURSIVE_MUTEX_INIT
79 # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
80 # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
82 #ifdef _GTHREAD_USE_COND_INIT_FUNC
83 # undef __GTHREAD_COND_INIT
84 # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
87 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
88 # ifndef __gthrw_pragma
89 # define __gthrw_pragma(pragma)
91 # define __gthrw2(name,name2,type) \
92 static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
93 __gthrw_pragma(weak type)
94 # define __gthrw_(name) __gthrw_ ## name
96 # define __gthrw2(name,name2,type)
97 # define __gthrw_(name) name
100 /* Typically, __gthrw_foo is a weak reference to symbol foo. */
101 #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
103 __gthrw(pthread_once
)
104 __gthrw(pthread_getspecific
)
105 __gthrw(pthread_setspecific
)
107 __gthrw(pthread_create
)
108 __gthrw(pthread_join
)
109 __gthrw(pthread_equal
)
110 __gthrw(pthread_self
)
111 __gthrw(pthread_detach
)
113 __gthrw(pthread_cancel
)
117 __gthrw(pthread_mutex_lock
)
118 __gthrw(pthread_mutex_trylock
)
119 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
120 __gthrw(pthread_mutex_timedlock
)
122 __gthrw(pthread_mutex_unlock
)
123 __gthrw(pthread_mutex_init
)
124 __gthrw(pthread_mutex_destroy
)
126 __gthrw(pthread_cond_init
)
127 __gthrw(pthread_cond_broadcast
)
128 __gthrw(pthread_cond_signal
)
129 __gthrw(pthread_cond_wait
)
130 __gthrw(pthread_cond_timedwait
)
131 __gthrw(pthread_cond_destroy
)
133 __gthrw(pthread_key_create
)
134 __gthrw(pthread_key_delete
)
135 __gthrw(pthread_mutexattr_init
)
136 __gthrw(pthread_mutexattr_settype
)
137 __gthrw(pthread_mutexattr_destroy
)
140 #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
142 __gthrw(pthread_exit
)
143 #ifdef _POSIX_PRIORITY_SCHEDULING
144 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
145 __gthrw(sched_get_priority_max
)
146 __gthrw(sched_get_priority_min
)
147 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
148 #endif /* _POSIX_PRIORITY_SCHEDULING */
149 __gthrw(pthread_attr_destroy
)
150 __gthrw(pthread_attr_init
)
151 __gthrw(pthread_attr_setdetachstate
)
152 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
153 __gthrw(pthread_getschedparam
)
154 __gthrw(pthread_setschedparam
)
155 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
156 #endif /* _LIBOBJC || _LIBOBJC_WEAK */
158 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
160 /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
161 -pthreads is not specified. The functions are dummies and most return an
162 error value. However pthread_once returns 0 without invoking the routine
163 it is passed so we cannot pretend that the interface is active if -pthreads
164 is not specified. On Solaris 2.5.1, the interface is not exposed at all so
165 we need to play the usual game with weak symbols. On Solaris 10 and up, a
166 working interface is always exposed. On FreeBSD 6 and later, libc also
167 exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
168 to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
169 which means the alternate __gthread_active_p below cannot be used there. */
171 #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
173 static volatile int __gthread_active
= -1;
176 __gthread_trigger (void)
178 __gthread_active
= 1;
182 __gthread_active_p (void)
184 static pthread_mutex_t __gthread_active_mutex
= PTHREAD_MUTEX_INITIALIZER
;
185 static pthread_once_t __gthread_active_once
= PTHREAD_ONCE_INIT
;
187 /* Avoid reading __gthread_active twice on the main code path. */
188 int __gthread_active_latest_value
= __gthread_active
;
190 /* This test is not protected to avoid taking a lock on the main code
191 path so every update of __gthread_active in a threaded program must
192 be atomic with regard to the result of the test. */
193 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
195 if (__gthrw_(pthread_once
))
197 /* If this really is a threaded program, then we must ensure that
198 __gthread_active has been set to 1 before exiting this block. */
199 __gthrw_(pthread_mutex_lock
) (&__gthread_active_mutex
);
200 __gthrw_(pthread_once
) (&__gthread_active_once
, __gthread_trigger
);
201 __gthrw_(pthread_mutex_unlock
) (&__gthread_active_mutex
);
204 /* Make sure we'll never enter this block again. */
205 if (__gthread_active
< 0)
206 __gthread_active
= 0;
208 __gthread_active_latest_value
= __gthread_active
;
211 return __gthread_active_latest_value
!= 0;
214 #else /* neither FreeBSD nor Solaris */
217 __gthread_active_p (void)
219 /* Android's C library does not provide pthread_cancel, check for
220 `pthread_create' instead. */
222 static void *const __gthread_active_ptr
223 = __extension__ (void *) &__gthrw_(pthread_cancel
);
225 static void *const __gthread_active_ptr
226 = __extension__ (void *) &__gthrw_(pthread_create
);
228 return __gthread_active_ptr
!= 0;
231 #endif /* FreeBSD or Solaris */
233 #else /* not SUPPORTS_WEAK */
235 /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
236 calls in shared flavors of the HP-UX C library. Most of the stubs
237 have no functionality. The details are described in the "libc cumulative
238 patch" for each subversion of HP-UX 11. There are two special interfaces
239 provided for checking whether an application is linked to a shared pthread
240 library or not. However, these interfaces aren't available in early
241 libpthread libraries. We also need a test that works for archive
242 libraries. We can't use pthread_once as some libc versions call the
243 init function. We also can't use pthread_create or pthread_attr_init
244 as these create a thread and thereby prevent changing the default stack
245 size. The function pthread_default_stacksize_np is available in both
246 the archive and shared versions of libpthread. It can be used to
247 determine the default pthread stack size. There is a stub in some
248 shared libc versions which returns a zero size if pthreads are not
249 active. We provide an equivalent stub to handle cases where libc
250 doesn't provide one. */
252 #if defined(__hppa__) && defined(__hpux__)
254 static volatile int __gthread_active
= -1;
257 __gthread_active_p (void)
259 /* Avoid reading __gthread_active twice on the main code path. */
260 int __gthread_active_latest_value
= __gthread_active
;
263 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
265 pthread_default_stacksize_np (0, &__s
);
266 __gthread_active
= __s
? 1 : 0;
267 __gthread_active_latest_value
= __gthread_active
;
270 return __gthread_active_latest_value
!= 0;
273 #else /* not hppa-hpux */
276 __gthread_active_p (void)
281 #endif /* hppa-hpux */
283 #endif /* SUPPORTS_WEAK */
287 /* This is the config.h file in libobjc/ */
294 /* Key structure for maintaining thread specific storage */
295 static pthread_key_t _objc_thread_storage
;
296 static pthread_attr_t _objc_thread_attribs
;
298 /* Thread local storage for a single thread */
299 static void *thread_local_storage
= NULL
;
301 /* Backend initialization functions */
303 /* Initialize the threads subsystem. */
305 __gthread_objc_init_thread_system (void)
307 if (__gthread_active_p ())
309 /* Initialize the thread storage key. */
310 if (__gthrw_(pthread_key_create
) (&_objc_thread_storage
, NULL
) == 0)
312 /* The normal default detach state for threads is
313 * PTHREAD_CREATE_JOINABLE which causes threads to not die
314 * when you think they should. */
315 if (__gthrw_(pthread_attr_init
) (&_objc_thread_attribs
) == 0
316 && __gthrw_(pthread_attr_setdetachstate
) (&_objc_thread_attribs
,
317 PTHREAD_CREATE_DETACHED
) == 0)
325 /* Close the threads subsystem. */
327 __gthread_objc_close_thread_system (void)
329 if (__gthread_active_p ()
330 && __gthrw_(pthread_key_delete
) (_objc_thread_storage
) == 0
331 && __gthrw_(pthread_attr_destroy
) (&_objc_thread_attribs
) == 0)
337 /* Backend thread functions */
339 /* Create a new thread of execution. */
340 static inline objc_thread_t
341 __gthread_objc_thread_detach (void (*func
)(void *), void *arg
)
343 objc_thread_t thread_id
;
344 pthread_t new_thread_handle
;
346 if (!__gthread_active_p ())
349 if (!(__gthrw_(pthread_create
) (&new_thread_handle
, &_objc_thread_attribs
,
350 (void *) func
, arg
)))
351 thread_id
= (objc_thread_t
) new_thread_handle
;
358 /* Set the current thread's priority. */
360 __gthread_objc_thread_set_priority (int priority
)
362 if (!__gthread_active_p ())
366 #ifdef _POSIX_PRIORITY_SCHEDULING
367 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
368 pthread_t thread_id
= __gthrw_(pthread_self
) ();
370 struct sched_param params
;
371 int priority_min
, priority_max
;
373 if (__gthrw_(pthread_getschedparam
) (thread_id
, &policy
, ¶ms
) == 0)
375 if ((priority_max
= __gthrw_(sched_get_priority_max
) (policy
)) == -1)
378 if ((priority_min
= __gthrw_(sched_get_priority_min
) (policy
)) == -1)
381 if (priority
> priority_max
)
382 priority
= priority_max
;
383 else if (priority
< priority_min
)
384 priority
= priority_min
;
385 params
.sched_priority
= priority
;
388 * The solaris 7 and several other man pages incorrectly state that
389 * this should be a pointer to policy but pthread.h is universally
392 if (__gthrw_(pthread_setschedparam
) (thread_id
, policy
, ¶ms
) == 0)
395 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
396 #endif /* _POSIX_PRIORITY_SCHEDULING */
401 /* Return the current thread's priority. */
403 __gthread_objc_thread_get_priority (void)
405 #ifdef _POSIX_PRIORITY_SCHEDULING
406 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
407 if (__gthread_active_p ())
410 struct sched_param params
;
412 if (__gthrw_(pthread_getschedparam
) (__gthrw_(pthread_self
) (), &policy
, ¶ms
) == 0)
413 return params
.sched_priority
;
418 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
419 #endif /* _POSIX_PRIORITY_SCHEDULING */
420 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
423 /* Yield our process time to another thread. */
425 __gthread_objc_thread_yield (void)
427 if (__gthread_active_p ())
428 __gthrw_(sched_yield
) ();
431 /* Terminate the current thread. */
433 __gthread_objc_thread_exit (void)
435 if (__gthread_active_p ())
436 /* exit the thread */
437 __gthrw_(pthread_exit
) (&__objc_thread_exit_status
);
439 /* Failed if we reached here */
443 /* Returns an integer value which uniquely describes a thread. */
444 static inline objc_thread_t
445 __gthread_objc_thread_id (void)
447 if (__gthread_active_p ())
448 return (objc_thread_t
) __gthrw_(pthread_self
) ();
450 return (objc_thread_t
) 1;
453 /* Sets the thread's local storage pointer. */
455 __gthread_objc_thread_set_data (void *value
)
457 if (__gthread_active_p ())
458 return __gthrw_(pthread_setspecific
) (_objc_thread_storage
, value
);
461 thread_local_storage
= value
;
466 /* Returns the thread's local storage pointer. */
468 __gthread_objc_thread_get_data (void)
470 if (__gthread_active_p ())
471 return __gthrw_(pthread_getspecific
) (_objc_thread_storage
);
473 return thread_local_storage
;
476 /* Backend mutex functions */
478 /* Allocate a mutex. */
480 __gthread_objc_mutex_allocate (objc_mutex_t mutex
)
482 if (__gthread_active_p ())
484 mutex
->backend
= objc_malloc (sizeof (pthread_mutex_t
));
486 if (__gthrw_(pthread_mutex_init
) ((pthread_mutex_t
*) mutex
->backend
, NULL
))
488 objc_free (mutex
->backend
);
489 mutex
->backend
= NULL
;
497 /* Deallocate a mutex. */
499 __gthread_objc_mutex_deallocate (objc_mutex_t mutex
)
501 if (__gthread_active_p ())
506 * Posix Threads specifically require that the thread be unlocked
507 * for __gthrw_(pthread_mutex_destroy) to work.
512 count
= __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
);
518 if (__gthrw_(pthread_mutex_destroy
) ((pthread_mutex_t
*) mutex
->backend
))
521 objc_free (mutex
->backend
);
522 mutex
->backend
= NULL
;
527 /* Grab a lock on a mutex. */
529 __gthread_objc_mutex_lock (objc_mutex_t mutex
)
531 if (__gthread_active_p ()
532 && __gthrw_(pthread_mutex_lock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
540 /* Try to grab a lock on a mutex. */
542 __gthread_objc_mutex_trylock (objc_mutex_t mutex
)
544 if (__gthread_active_p ()
545 && __gthrw_(pthread_mutex_trylock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
553 /* Unlock the mutex */
555 __gthread_objc_mutex_unlock (objc_mutex_t mutex
)
557 if (__gthread_active_p ()
558 && __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
566 /* Backend condition mutex functions */
568 /* Allocate a condition. */
570 __gthread_objc_condition_allocate (objc_condition_t condition
)
572 if (__gthread_active_p ())
574 condition
->backend
= objc_malloc (sizeof (pthread_cond_t
));
576 if (__gthrw_(pthread_cond_init
) ((pthread_cond_t
*) condition
->backend
, NULL
))
578 objc_free (condition
->backend
);
579 condition
->backend
= NULL
;
587 /* Deallocate a condition. */
589 __gthread_objc_condition_deallocate (objc_condition_t condition
)
591 if (__gthread_active_p ())
593 if (__gthrw_(pthread_cond_destroy
) ((pthread_cond_t
*) condition
->backend
))
596 objc_free (condition
->backend
);
597 condition
->backend
= NULL
;
602 /* Wait on the condition */
604 __gthread_objc_condition_wait (objc_condition_t condition
, objc_mutex_t mutex
)
606 if (__gthread_active_p ())
607 return __gthrw_(pthread_cond_wait
) ((pthread_cond_t
*) condition
->backend
,
608 (pthread_mutex_t
*) mutex
->backend
);
613 /* Wake up all threads waiting on this condition. */
615 __gthread_objc_condition_broadcast (objc_condition_t condition
)
617 if (__gthread_active_p ())
618 return __gthrw_(pthread_cond_broadcast
) ((pthread_cond_t
*) condition
->backend
);
623 /* Wake up one thread waiting on this condition. */
625 __gthread_objc_condition_signal (objc_condition_t condition
)
627 if (__gthread_active_p ())
628 return __gthrw_(pthread_cond_signal
) ((pthread_cond_t
*) condition
->backend
);
636 __gthread_create (__gthread_t
*__threadid
, void *(*__func
) (void*),
639 return __gthrw_(pthread_create
) (__threadid
, NULL
, __func
, __args
);
643 __gthread_join (__gthread_t __threadid
, void **__value_ptr
)
645 return __gthrw_(pthread_join
) (__threadid
, __value_ptr
);
649 __gthread_detach (__gthread_t __threadid
)
651 return __gthrw_(pthread_detach
) (__threadid
);
655 __gthread_equal (__gthread_t __t1
, __gthread_t __t2
)
657 return __gthrw_(pthread_equal
) (__t1
, __t2
);
660 static inline __gthread_t
661 __gthread_self (void)
663 return __gthrw_(pthread_self
) ();
667 __gthread_yield (void)
669 return __gthrw_(sched_yield
) ();
673 __gthread_once (__gthread_once_t
*__once
, void (*__func
) (void))
675 if (__gthread_active_p ())
676 return __gthrw_(pthread_once
) (__once
, __func
);
682 __gthread_key_create (__gthread_key_t
*__key
, void (*__dtor
) (void *))
684 return __gthrw_(pthread_key_create
) (__key
, __dtor
);
688 __gthread_key_delete (__gthread_key_t __key
)
690 return __gthrw_(pthread_key_delete
) (__key
);
694 __gthread_getspecific (__gthread_key_t __key
)
696 return __gthrw_(pthread_getspecific
) (__key
);
700 __gthread_setspecific (__gthread_key_t __key
, const void *__ptr
)
702 return __gthrw_(pthread_setspecific
) (__key
, __ptr
);
705 #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
707 __gthread_mutex_init_function (__gthread_mutex_t
*__mutex
)
709 if (__gthread_active_p ())
710 __gthrw_(pthread_mutex_init
) (__mutex
, NULL
);
715 __gthread_mutex_init_function (__gthread_mutex_t
*__mutex
)
717 if (__gthread_active_p ())
718 return __gthrw_(pthread_mutex_init
) (__mutex
, NULL
);
723 __gthread_mutex_destroy (__gthread_mutex_t
*__mutex
)
725 if (__gthread_active_p ())
726 return __gthrw_(pthread_mutex_destroy
) (__mutex
);
732 __gthread_mutex_lock (__gthread_mutex_t
*__mutex
)
734 if (__gthread_active_p ())
735 return __gthrw_(pthread_mutex_lock
) (__mutex
);
741 __gthread_mutex_trylock (__gthread_mutex_t
*__mutex
)
743 if (__gthread_active_p ())
744 return __gthrw_(pthread_mutex_trylock
) (__mutex
);
749 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
751 __gthread_mutex_timedlock (__gthread_mutex_t
*__mutex
,
752 const __gthread_time_t
*__abs_timeout
)
754 if (__gthread_active_p ())
755 return __gthrw_(pthread_mutex_timedlock
) (__mutex
, __abs_timeout
);
762 __gthread_mutex_unlock (__gthread_mutex_t
*__mutex
)
764 if (__gthread_active_p ())
765 return __gthrw_(pthread_mutex_unlock
) (__mutex
);
770 #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
771 || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
773 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t
*__mutex
)
775 if (__gthread_active_p ())
777 pthread_mutexattr_t __attr
;
780 __r
= __gthrw_(pthread_mutexattr_init
) (&__attr
);
782 __r
= __gthrw_(pthread_mutexattr_settype
) (&__attr
,
783 PTHREAD_MUTEX_RECURSIVE
);
785 __r
= __gthrw_(pthread_mutex_init
) (__mutex
, &__attr
);
787 __r
= __gthrw_(pthread_mutexattr_destroy
) (&__attr
);
795 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*__mutex
)
797 return __gthread_mutex_lock (__mutex
);
801 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*__mutex
)
803 return __gthread_mutex_trylock (__mutex
);
806 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
808 __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t
*__mutex
,
809 const __gthread_time_t
*__abs_timeout
)
811 return __gthread_mutex_timedlock (__mutex
, __abs_timeout
);
816 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*__mutex
)
818 return __gthread_mutex_unlock (__mutex
);
821 #ifdef _GTHREAD_USE_COND_INIT_FUNC
823 __gthread_cond_init_function (__gthread_cond_t
*__cond
)
825 if (__gthread_active_p ())
826 __gthrw_(pthread_cond_init
) (__cond
, NULL
);
831 __gthread_cond_broadcast (__gthread_cond_t
*__cond
)
833 return __gthrw_(pthread_cond_broadcast
) (__cond
);
837 __gthread_cond_signal (__gthread_cond_t
*__cond
)
839 return __gthrw_(pthread_cond_signal
) (__cond
);
843 __gthread_cond_wait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
)
845 return __gthrw_(pthread_cond_wait
) (__cond
, __mutex
);
849 __gthread_cond_timedwait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
,
850 const __gthread_time_t
*__abs_timeout
)
852 return __gthrw_(pthread_cond_timedwait
) (__cond
, __mutex
, __abs_timeout
);
856 __gthread_cond_wait_recursive (__gthread_cond_t
*__cond
,
857 __gthread_recursive_mutex_t
*__mutex
)
859 return __gthread_cond_wait (__cond
, __mutex
);
863 __gthread_cond_timedwait_recursive (__gthread_cond_t
*__cond
,
864 __gthread_recursive_mutex_t
*__mutex
,
865 const __gthread_time_t
*__abs_timeout
)
867 return __gthread_cond_timedwait (__cond
, __mutex
, __abs_timeout
);
871 __gthread_cond_destroy (__gthread_cond_t
* __cond
)
873 return __gthrw_(pthread_cond_destroy
) (__cond
);
876 #endif /* _LIBOBJC */
878 #endif /* ! GCC_GTHR_POSIX_H */