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 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
36 /* Some implementations of <pthread.h> require this to be defined. */
37 #if !defined(_REENTRANT) && defined(__osf__)
44 typedef pthread_t __gthread_t
;
45 typedef pthread_key_t __gthread_key_t
;
46 typedef pthread_once_t __gthread_once_t
;
47 typedef pthread_mutex_t __gthread_mutex_t
;
48 typedef pthread_mutex_t __gthread_recursive_mutex_t
;
49 typedef pthread_cond_t __gthread_cond_t
;
50 typedef struct timespec __gthread_time_t
;
52 /* POSIX like conditional variables are supported. Please look at comments
53 in gthr.h for details. */
54 #define __GTHREAD_HAS_COND 1
56 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
57 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
58 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
59 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
60 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
61 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
63 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
65 #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
66 #define __GTHREAD_TIME_INIT {0,0}
68 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
69 # ifndef __gthrw_pragma
70 # define __gthrw_pragma(pragma)
72 # define __gthrw2(name,name2,type) \
73 static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
74 __gthrw_pragma(weak type)
75 # define __gthrw_(name) __gthrw_ ## name
77 # define __gthrw2(name,name2,type)
78 # define __gthrw_(name) name
81 /* Typically, __gthrw_foo is a weak reference to symbol foo. */
82 #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
84 /* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to
85 map a subset of the POSIX pthread API to mangled versions of their
87 #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
88 #define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name)
89 __gthrw3(pthread_once
)
90 __gthrw3(pthread_getspecific
)
91 __gthrw3(pthread_setspecific
)
93 __gthrw3(pthread_create
)
94 __gthrw3(pthread_join
)
95 __gthrw3(pthread_detach
)
96 __gthrw3(pthread_equal
)
97 __gthrw3(pthread_self
)
98 __gthrw3(pthread_cancel
)
101 __gthrw3(pthread_mutex_lock
)
102 __gthrw3(pthread_mutex_trylock
)
103 #ifdef _POSIX_TIMEOUTS
104 #if _POSIX_TIMEOUTS >= 0
105 __gthrw3(pthread_mutex_timedlock
)
107 #endif /* _POSIX_TIMEOUTS */
108 __gthrw3(pthread_mutex_unlock
)
109 __gthrw3(pthread_mutex_init
)
110 __gthrw3(pthread_mutex_destroy
)
112 __gthrw3(pthread_cond_broadcast
)
113 __gthrw3(pthread_cond_signal
)
114 __gthrw3(pthread_cond_wait
)
115 __gthrw3(pthread_cond_timedwait
)
116 __gthrw3(pthread_cond_destroy
)
118 __gthrw(pthread_once
)
119 __gthrw(pthread_getspecific
)
120 __gthrw(pthread_setspecific
)
122 __gthrw(pthread_create
)
123 __gthrw(pthread_join
)
124 __gthrw(pthread_equal
)
125 __gthrw(pthread_self
)
126 __gthrw(pthread_detach
)
128 __gthrw(pthread_cancel
)
132 __gthrw(pthread_mutex_lock
)
133 __gthrw(pthread_mutex_trylock
)
134 #ifdef _POSIX_TIMEOUTS
135 #if _POSIX_TIMEOUTS >= 0
136 __gthrw(pthread_mutex_timedlock
)
138 #endif /* _POSIX_TIMEOUTS */
139 __gthrw(pthread_mutex_unlock
)
140 __gthrw(pthread_mutex_init
)
141 __gthrw(pthread_mutex_destroy
)
143 __gthrw(pthread_cond_broadcast
)
144 __gthrw(pthread_cond_signal
)
145 __gthrw(pthread_cond_wait
)
146 __gthrw(pthread_cond_timedwait
)
147 __gthrw(pthread_cond_destroy
)
150 __gthrw(pthread_key_create
)
151 __gthrw(pthread_key_delete
)
152 __gthrw(pthread_mutexattr_init
)
153 __gthrw(pthread_mutexattr_settype
)
154 __gthrw(pthread_mutexattr_destroy
)
157 #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
159 #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
160 __gthrw3(pthread_cond_init
)
161 __gthrw3(pthread_exit
)
163 __gthrw(pthread_cond_init
)
164 __gthrw(pthread_exit
)
165 #endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */
166 #ifdef _POSIX_PRIORITY_SCHEDULING
167 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
168 __gthrw(sched_get_priority_max
)
169 __gthrw(sched_get_priority_min
)
170 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
171 #endif /* _POSIX_PRIORITY_SCHEDULING */
172 __gthrw(pthread_attr_destroy
)
173 __gthrw(pthread_attr_init
)
174 __gthrw(pthread_attr_setdetachstate
)
175 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
176 __gthrw(pthread_getschedparam
)
177 __gthrw(pthread_setschedparam
)
178 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
179 #endif /* _LIBOBJC || _LIBOBJC_WEAK */
181 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
183 /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
184 -pthreads is not specified. The functions are dummies and most return an
185 error value. However pthread_once returns 0 without invoking the routine
186 it is passed so we cannot pretend that the interface is active if -pthreads
187 is not specified. On Solaris 2.5.1, the interface is not exposed at all so
188 we need to play the usual game with weak symbols. On Solaris 10 and up, a
189 working interface is always exposed. On FreeBSD 6 and later, libc also
190 exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
191 to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
192 which means the alternate __gthread_active_p below cannot be used there. */
194 #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
196 static volatile int __gthread_active
= -1;
199 __gthread_trigger (void)
201 __gthread_active
= 1;
205 __gthread_active_p (void)
207 static pthread_mutex_t __gthread_active_mutex
= PTHREAD_MUTEX_INITIALIZER
;
208 static pthread_once_t __gthread_active_once
= PTHREAD_ONCE_INIT
;
210 /* Avoid reading __gthread_active twice on the main code path. */
211 int __gthread_active_latest_value
= __gthread_active
;
213 /* This test is not protected to avoid taking a lock on the main code
214 path so every update of __gthread_active in a threaded program must
215 be atomic with regard to the result of the test. */
216 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
218 if (__gthrw_(pthread_once
))
220 /* If this really is a threaded program, then we must ensure that
221 __gthread_active has been set to 1 before exiting this block. */
222 __gthrw_(pthread_mutex_lock
) (&__gthread_active_mutex
);
223 __gthrw_(pthread_once
) (&__gthread_active_once
, __gthread_trigger
);
224 __gthrw_(pthread_mutex_unlock
) (&__gthread_active_mutex
);
227 /* Make sure we'll never enter this block again. */
228 if (__gthread_active
< 0)
229 __gthread_active
= 0;
231 __gthread_active_latest_value
= __gthread_active
;
234 return __gthread_active_latest_value
!= 0;
237 #else /* neither FreeBSD nor Solaris */
240 __gthread_active_p (void)
242 static void *const __gthread_active_ptr
243 = __extension__ (void *) &__gthrw_(
244 /* Android's C library does not provide pthread_cancel, check for
245 `pthread_create' instead. */
252 return __gthread_active_ptr
!= 0;
255 #endif /* FreeBSD or Solaris */
257 #else /* not SUPPORTS_WEAK */
259 /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
260 calls in shared flavors of the HP-UX C library. Most of the stubs
261 have no functionality. The details are described in the "libc cumulative
262 patch" for each subversion of HP-UX 11. There are two special interfaces
263 provided for checking whether an application is linked to a pthread
264 library or not. However, these interfaces aren't available in early
265 libc versions. We also can't use pthread_once as some libc versions
266 call the init function. So, we use pthread_create to check whether it
267 is possible to create a thread or not. The stub implementation returns
268 the error number ENOSYS. */
270 #if defined(__hppa__) && defined(__hpux__)
274 static volatile int __gthread_active
= -1;
277 __gthread_start (void *__arg
__attribute__((unused
)))
282 static void __gthread_active_init (void) __attribute__((noinline
));
284 __gthread_active_init (void)
286 static pthread_mutex_t __gthread_active_mutex
= PTHREAD_MUTEX_INITIALIZER
;
291 __gthrw_(pthread_mutex_lock
) (&__gthread_active_mutex
);
292 if (__gthread_active
< 0)
294 __gthrw_(pthread_attr_init
) (&__a
);
295 __gthrw_(pthread_attr_setdetachstate
) (&__a
, PTHREAD_CREATE_DETACHED
);
296 __result
= __gthrw_(pthread_create
) (&__t
, &__a
, __gthread_start
, NULL
);
297 if (__result
!= ENOSYS
)
298 __gthread_active
= 1;
300 __gthread_active
= 0;
301 __gthrw_(pthread_attr_destroy
) (&__a
);
303 __gthrw_(pthread_mutex_unlock
) (&__gthread_active_mutex
);
307 __gthread_active_p (void)
309 /* Avoid reading __gthread_active twice on the main code path. */
310 int __gthread_active_latest_value
= __gthread_active
;
312 /* This test is not protected to avoid taking a lock on the main code
313 path so every update of __gthread_active in a threaded program must
314 be atomic with regard to the result of the test. */
315 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
317 __gthread_active_init ();
318 __gthread_active_latest_value
= __gthread_active
;
321 return __gthread_active_latest_value
!= 0;
324 #else /* not hppa-hpux */
327 __gthread_active_p (void)
332 #endif /* hppa-hpux */
334 #endif /* SUPPORTS_WEAK */
338 /* This is the config.h file in libobjc/ */
345 /* Key structure for maintaining thread specific storage */
346 static pthread_key_t _objc_thread_storage
;
347 static pthread_attr_t _objc_thread_attribs
;
349 /* Thread local storage for a single thread */
350 static void *thread_local_storage
= NULL
;
352 /* Backend initialization functions */
354 /* Initialize the threads subsystem. */
356 __gthread_objc_init_thread_system (void)
358 if (__gthread_active_p ())
360 /* Initialize the thread storage key. */
361 if (__gthrw_(pthread_key_create
) (&_objc_thread_storage
, NULL
) == 0)
363 /* The normal default detach state for threads is
364 * PTHREAD_CREATE_JOINABLE which causes threads to not die
365 * when you think they should. */
366 if (__gthrw_(pthread_attr_init
) (&_objc_thread_attribs
) == 0
367 && __gthrw_(pthread_attr_setdetachstate
) (&_objc_thread_attribs
,
368 PTHREAD_CREATE_DETACHED
) == 0)
376 /* Close the threads subsystem. */
378 __gthread_objc_close_thread_system (void)
380 if (__gthread_active_p ()
381 && __gthrw_(pthread_key_delete
) (_objc_thread_storage
) == 0
382 && __gthrw_(pthread_attr_destroy
) (&_objc_thread_attribs
) == 0)
388 /* Backend thread functions */
390 /* Create a new thread of execution. */
391 static inline objc_thread_t
392 __gthread_objc_thread_detach (void (*func
)(void *), void *arg
)
394 objc_thread_t thread_id
;
395 pthread_t new_thread_handle
;
397 if (!__gthread_active_p ())
400 if (!(__gthrw_(pthread_create
) (&new_thread_handle
, NULL
, (void *) func
, arg
)))
401 thread_id
= (objc_thread_t
) new_thread_handle
;
408 /* Set the current thread's priority. */
410 __gthread_objc_thread_set_priority (int priority
)
412 if (!__gthread_active_p ())
416 #ifdef _POSIX_PRIORITY_SCHEDULING
417 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
418 pthread_t thread_id
= __gthrw_(pthread_self
) ();
420 struct sched_param params
;
421 int priority_min
, priority_max
;
423 if (__gthrw_(pthread_getschedparam
) (thread_id
, &policy
, ¶ms
) == 0)
425 if ((priority_max
= __gthrw_(sched_get_priority_max
) (policy
)) == -1)
428 if ((priority_min
= __gthrw_(sched_get_priority_min
) (policy
)) == -1)
431 if (priority
> priority_max
)
432 priority
= priority_max
;
433 else if (priority
< priority_min
)
434 priority
= priority_min
;
435 params
.sched_priority
= priority
;
438 * The solaris 7 and several other man pages incorrectly state that
439 * this should be a pointer to policy but pthread.h is universally
442 if (__gthrw_(pthread_setschedparam
) (thread_id
, policy
, ¶ms
) == 0)
445 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
446 #endif /* _POSIX_PRIORITY_SCHEDULING */
451 /* Return the current thread's priority. */
453 __gthread_objc_thread_get_priority (void)
455 #ifdef _POSIX_PRIORITY_SCHEDULING
456 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
457 if (__gthread_active_p ())
460 struct sched_param params
;
462 if (__gthrw_(pthread_getschedparam
) (__gthrw_(pthread_self
) (), &policy
, ¶ms
) == 0)
463 return params
.sched_priority
;
468 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
469 #endif /* _POSIX_PRIORITY_SCHEDULING */
470 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
473 /* Yield our process time to another thread. */
475 __gthread_objc_thread_yield (void)
477 if (__gthread_active_p ())
478 __gthrw_(sched_yield
) ();
481 /* Terminate the current thread. */
483 __gthread_objc_thread_exit (void)
485 if (__gthread_active_p ())
486 /* exit the thread */
487 __gthrw_(pthread_exit
) (&__objc_thread_exit_status
);
489 /* Failed if we reached here */
493 /* Returns an integer value which uniquely describes a thread. */
494 static inline objc_thread_t
495 __gthread_objc_thread_id (void)
497 if (__gthread_active_p ())
498 return (objc_thread_t
) __gthrw_(pthread_self
) ();
500 return (objc_thread_t
) 1;
503 /* Sets the thread's local storage pointer. */
505 __gthread_objc_thread_set_data (void *value
)
507 if (__gthread_active_p ())
508 return __gthrw_(pthread_setspecific
) (_objc_thread_storage
, value
);
511 thread_local_storage
= value
;
516 /* Returns the thread's local storage pointer. */
518 __gthread_objc_thread_get_data (void)
520 if (__gthread_active_p ())
521 return __gthrw_(pthread_getspecific
) (_objc_thread_storage
);
523 return thread_local_storage
;
526 /* Backend mutex functions */
528 /* Allocate a mutex. */
530 __gthread_objc_mutex_allocate (objc_mutex_t mutex
)
532 if (__gthread_active_p ())
534 mutex
->backend
= objc_malloc (sizeof (pthread_mutex_t
));
536 if (__gthrw_(pthread_mutex_init
) ((pthread_mutex_t
*) mutex
->backend
, NULL
))
538 objc_free (mutex
->backend
);
539 mutex
->backend
= NULL
;
547 /* Deallocate a mutex. */
549 __gthread_objc_mutex_deallocate (objc_mutex_t mutex
)
551 if (__gthread_active_p ())
556 * Posix Threads specifically require that the thread be unlocked
557 * for __gthrw_(pthread_mutex_destroy) to work.
562 count
= __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
);
568 if (__gthrw_(pthread_mutex_destroy
) ((pthread_mutex_t
*) mutex
->backend
))
571 objc_free (mutex
->backend
);
572 mutex
->backend
= NULL
;
577 /* Grab a lock on a mutex. */
579 __gthread_objc_mutex_lock (objc_mutex_t mutex
)
581 if (__gthread_active_p ()
582 && __gthrw_(pthread_mutex_lock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
590 /* Try to grab a lock on a mutex. */
592 __gthread_objc_mutex_trylock (objc_mutex_t mutex
)
594 if (__gthread_active_p ()
595 && __gthrw_(pthread_mutex_trylock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
603 /* Unlock the mutex */
605 __gthread_objc_mutex_unlock (objc_mutex_t mutex
)
607 if (__gthread_active_p ()
608 && __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
616 /* Backend condition mutex functions */
618 /* Allocate a condition. */
620 __gthread_objc_condition_allocate (objc_condition_t condition
)
622 if (__gthread_active_p ())
624 condition
->backend
= objc_malloc (sizeof (pthread_cond_t
));
626 if (__gthrw_(pthread_cond_init
) ((pthread_cond_t
*) condition
->backend
, NULL
))
628 objc_free (condition
->backend
);
629 condition
->backend
= NULL
;
637 /* Deallocate a condition. */
639 __gthread_objc_condition_deallocate (objc_condition_t condition
)
641 if (__gthread_active_p ())
643 if (__gthrw_(pthread_cond_destroy
) ((pthread_cond_t
*) condition
->backend
))
646 objc_free (condition
->backend
);
647 condition
->backend
= NULL
;
652 /* Wait on the condition */
654 __gthread_objc_condition_wait (objc_condition_t condition
, objc_mutex_t mutex
)
656 if (__gthread_active_p ())
657 return __gthrw_(pthread_cond_wait
) ((pthread_cond_t
*) condition
->backend
,
658 (pthread_mutex_t
*) mutex
->backend
);
663 /* Wake up all threads waiting on this condition. */
665 __gthread_objc_condition_broadcast (objc_condition_t condition
)
667 if (__gthread_active_p ())
668 return __gthrw_(pthread_cond_broadcast
) ((pthread_cond_t
*) condition
->backend
);
673 /* Wake up one thread waiting on this condition. */
675 __gthread_objc_condition_signal (objc_condition_t condition
)
677 if (__gthread_active_p ())
678 return __gthrw_(pthread_cond_signal
) ((pthread_cond_t
*) condition
->backend
);
686 __gthread_create (__gthread_t
*__threadid
, void *(*__func
) (void*),
689 return __gthrw_(pthread_create
) (__threadid
, NULL
, __func
, __args
);
693 __gthread_join (__gthread_t __threadid
, void **__value_ptr
)
695 return __gthrw_(pthread_join
) (__threadid
, __value_ptr
);
699 __gthread_detach (__gthread_t __threadid
)
701 return __gthrw_(pthread_detach
) (__threadid
);
705 __gthread_equal (__gthread_t __t1
, __gthread_t __t2
)
707 return __gthrw_(pthread_equal
) (__t1
, __t2
);
710 static inline __gthread_t
711 __gthread_self (void)
713 return __gthrw_(pthread_self
) ();
717 __gthread_yield (void)
719 return __gthrw_(sched_yield
) ();
723 __gthread_once (__gthread_once_t
*__once
, void (*__func
) (void))
725 if (__gthread_active_p ())
726 return __gthrw_(pthread_once
) (__once
, __func
);
732 __gthread_key_create (__gthread_key_t
*__key
, void (*__dtor
) (void *))
734 return __gthrw_(pthread_key_create
) (__key
, __dtor
);
738 __gthread_key_delete (__gthread_key_t __key
)
740 return __gthrw_(pthread_key_delete
) (__key
);
744 __gthread_getspecific (__gthread_key_t __key
)
746 return __gthrw_(pthread_getspecific
) (__key
);
750 __gthread_setspecific (__gthread_key_t __key
, const void *__ptr
)
752 return __gthrw_(pthread_setspecific
) (__key
, __ptr
);
756 __gthread_mutex_destroy (__gthread_mutex_t
*__mutex
)
758 if (__gthread_active_p ())
759 return __gthrw_(pthread_mutex_destroy
) (__mutex
);
765 __gthread_mutex_lock (__gthread_mutex_t
*__mutex
)
767 if (__gthread_active_p ())
768 return __gthrw_(pthread_mutex_lock
) (__mutex
);
774 __gthread_mutex_trylock (__gthread_mutex_t
*__mutex
)
776 if (__gthread_active_p ())
777 return __gthrw_(pthread_mutex_trylock
) (__mutex
);
782 #ifdef _POSIX_TIMEOUTS
783 #if _POSIX_TIMEOUTS >= 0
785 __gthread_mutex_timedlock (__gthread_mutex_t
*__mutex
,
786 const __gthread_time_t
*__abs_timeout
)
788 if (__gthread_active_p ())
789 return __gthrw_(pthread_mutex_timedlock
) (__mutex
, __abs_timeout
);
797 __gthread_mutex_unlock (__gthread_mutex_t
*__mutex
)
799 if (__gthread_active_p ())
800 return __gthrw_(pthread_mutex_unlock
) (__mutex
);
805 #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
807 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t
*__mutex
)
809 if (__gthread_active_p ())
811 pthread_mutexattr_t __attr
;
814 __r
= __gthrw_(pthread_mutexattr_init
) (&__attr
);
816 __r
= __gthrw_(pthread_mutexattr_settype
) (&__attr
,
817 PTHREAD_MUTEX_RECURSIVE
);
819 __r
= __gthrw_(pthread_mutex_init
) (__mutex
, &__attr
);
821 __r
= __gthrw_(pthread_mutexattr_destroy
) (&__attr
);
829 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*__mutex
)
831 return __gthread_mutex_lock (__mutex
);
835 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*__mutex
)
837 return __gthread_mutex_trylock (__mutex
);
840 #ifdef _POSIX_TIMEOUTS
841 #if _POSIX_TIMEOUTS >= 0
843 __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t
*__mutex
,
844 const __gthread_time_t
*__abs_timeout
)
846 return __gthread_mutex_timedlock (__mutex
, __abs_timeout
);
852 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*__mutex
)
854 return __gthread_mutex_unlock (__mutex
);
858 __gthread_cond_broadcast (__gthread_cond_t
*__cond
)
860 return __gthrw_(pthread_cond_broadcast
) (__cond
);
864 __gthread_cond_signal (__gthread_cond_t
*__cond
)
866 return __gthrw_(pthread_cond_signal
) (__cond
);
870 __gthread_cond_wait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
)
872 return __gthrw_(pthread_cond_wait
) (__cond
, __mutex
);
876 __gthread_cond_timedwait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
,
877 const __gthread_time_t
*__abs_timeout
)
879 return __gthrw_(pthread_cond_timedwait
) (__cond
, __mutex
, __abs_timeout
);
883 __gthread_cond_wait_recursive (__gthread_cond_t
*__cond
,
884 __gthread_recursive_mutex_t
*__mutex
)
886 return __gthread_cond_wait (__cond
, __mutex
);
890 __gthread_cond_timedwait_recursive (__gthread_cond_t
*__cond
,
891 __gthread_recursive_mutex_t
*__mutex
,
892 const __gthread_time_t
*__abs_timeout
)
894 return __gthread_cond_timedwait (__cond
, __mutex
, __abs_timeout
);
898 __gthread_cond_destroy (__gthread_cond_t
* __cond
)
900 return __gthrw_(pthread_cond_destroy
) (__cond
);
903 #endif /* _LIBOBJC */
905 #endif /* ! GCC_GTHR_POSIX_H */