1 /* This file is automatically generated. DO NOT EDIT! */
2 /* Generated from: NetBSD: mknative-gcc,v 1.70 2013/05/05 07:11:34 skrll Exp */
3 /* Generated from: NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp */
5 /* Threads compatibility routines for libgcc2 and libobjc. */
6 /* Compile this one with gcc. */
7 /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation; either version 3, or (at your option) any later
16 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 Under Section 7 of GPL version 3, you are granted additional
22 permissions described in the GCC Runtime Library Exception, version
23 3.1, as published by the Free Software Foundation.
25 You should have received a copy of the GNU General Public License and
26 a copy of the GCC Runtime Library Exception along with this program;
27 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
28 <http://www.gnu.org/licenses/>. */
30 #ifndef _GLIBCXX_GCC_GTHR_POSIX_H
31 #define _GLIBCXX_GCC_GTHR_POSIX_H
33 /* POSIX threads specific definitions.
34 Easy, since the interface is just one-to-one mapping. */
37 #define __GTHREADS_CXX0X 1
41 #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
42 || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
44 # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
45 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
47 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
51 typedef pthread_t __gthread_t
;
52 typedef pthread_key_t __gthread_key_t
;
53 typedef pthread_once_t __gthread_once_t
;
54 typedef pthread_mutex_t __gthread_mutex_t
;
55 typedef pthread_mutex_t __gthread_recursive_mutex_t
;
56 typedef pthread_cond_t __gthread_cond_t
;
57 typedef struct timespec __gthread_time_t
;
59 /* POSIX like conditional variables are supported. Please look at comments
60 in gthr.h for details. */
61 #define __GTHREAD_HAS_COND 1
63 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
64 #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
65 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
66 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
67 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
68 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
69 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
71 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
73 #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
74 #define __GTHREAD_TIME_INIT {0,0}
76 #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
77 # undef __GTHREAD_MUTEX_INIT
79 #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
80 # undef __GTHREAD_RECURSIVE_MUTEX_INIT
81 # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
82 # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
84 #ifdef _GTHREAD_USE_COND_INIT_FUNC
85 # undef __GTHREAD_COND_INIT
86 # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
89 #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
90 # ifndef __gthrw_pragma
91 # define __gthrw_pragma(pragma)
93 # define __gthrw2(name,name2,type) \
94 static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
95 __gthrw_pragma(weak type)
96 # define __gthrw_(name) __gthrw_ ## name
98 # define __gthrw2(name,name2,type)
99 # define __gthrw_(name) name
102 /* Typically, __gthrw_foo is a weak reference to symbol foo. */
103 #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
105 __gthrw(pthread_once
)
106 __gthrw(pthread_getspecific
)
107 __gthrw(pthread_setspecific
)
109 __gthrw(pthread_create
)
110 __gthrw(pthread_join
)
111 __gthrw(pthread_equal
)
112 __gthrw(pthread_self
)
113 __gthrw(pthread_detach
)
115 __gthrw(pthread_cancel
)
119 __gthrw(pthread_mutex_lock
)
120 __gthrw(pthread_mutex_trylock
)
121 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
122 __gthrw(pthread_mutex_timedlock
)
124 __gthrw(pthread_mutex_unlock
)
125 __gthrw(pthread_mutex_init
)
126 __gthrw(pthread_mutex_destroy
)
128 __gthrw(pthread_cond_init
)
129 __gthrw(pthread_cond_broadcast
)
130 __gthrw(pthread_cond_signal
)
131 __gthrw(pthread_cond_wait
)
132 __gthrw(pthread_cond_timedwait
)
133 __gthrw(pthread_cond_destroy
)
135 __gthrw(pthread_key_create
)
136 __gthrw(pthread_key_delete
)
137 __gthrw(pthread_mutexattr_init
)
138 __gthrw(pthread_mutexattr_settype
)
139 __gthrw(pthread_mutexattr_destroy
)
142 #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
144 __gthrw(pthread_exit
)
145 #ifdef _POSIX_PRIORITY_SCHEDULING
146 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
147 __gthrw(sched_get_priority_max
)
148 __gthrw(sched_get_priority_min
)
149 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
150 #endif /* _POSIX_PRIORITY_SCHEDULING */
151 __gthrw(pthread_attr_destroy
)
152 __gthrw(pthread_attr_init
)
153 __gthrw(pthread_attr_setdetachstate
)
154 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
155 __gthrw(pthread_getschedparam
)
156 __gthrw(pthread_setschedparam
)
157 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
158 #endif /* _LIBOBJC || _LIBOBJC_WEAK */
160 #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
162 /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
163 -pthreads is not specified. The functions are dummies and most return an
164 error value. However pthread_once returns 0 without invoking the routine
165 it is passed so we cannot pretend that the interface is active if -pthreads
166 is not specified. On Solaris 2.5.1, the interface is not exposed at all so
167 we need to play the usual game with weak symbols. On Solaris 10 and up, a
168 working interface is always exposed. On FreeBSD 6 and later, libc also
169 exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
170 to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
171 which means the alternate __gthread_active_p below cannot be used there. */
173 #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
175 static volatile int __gthread_active
= -1;
178 __gthread_trigger (void)
180 __gthread_active
= 1;
184 __gthread_active_p (void)
186 static pthread_mutex_t __gthread_active_mutex
= PTHREAD_MUTEX_INITIALIZER
;
187 static pthread_once_t __gthread_active_once
= PTHREAD_ONCE_INIT
;
189 /* Avoid reading __gthread_active twice on the main code path. */
190 int __gthread_active_latest_value
= __gthread_active
;
192 /* This test is not protected to avoid taking a lock on the main code
193 path so every update of __gthread_active in a threaded program must
194 be atomic with regard to the result of the test. */
195 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
197 if (__gthrw_(pthread_once
))
199 /* If this really is a threaded program, then we must ensure that
200 __gthread_active has been set to 1 before exiting this block. */
201 __gthrw_(pthread_mutex_lock
) (&__gthread_active_mutex
);
202 __gthrw_(pthread_once
) (&__gthread_active_once
, __gthread_trigger
);
203 __gthrw_(pthread_mutex_unlock
) (&__gthread_active_mutex
);
206 /* Make sure we'll never enter this block again. */
207 if (__gthread_active
< 0)
208 __gthread_active
= 0;
210 __gthread_active_latest_value
= __gthread_active
;
213 return __gthread_active_latest_value
!= 0;
216 #else /* neither FreeBSD nor Solaris */
218 /* For a program to be multi-threaded the only thing that it certainly must
219 be using is pthread_create. However, there may be other libraries that
220 intercept pthread_create with their own definitions to wrap pthreads
221 functionality for some purpose. In those cases, pthread_create being
222 defined might not necessarily mean that libpthread is actually linked
225 For the GNU C library, we can use a known internal name. This is always
226 available in the ABI, but no other library would define it. That is
227 ideal, since any public pthread function might be intercepted just as
228 pthread_create might be. __pthread_key_create is an "internal"
229 implementation symbol, but it is part of the public exported ABI. Also,
230 it's among the symbols that the static libpthread.a always links in
231 whenever pthread_create is used, so there is no danger of a false
232 negative result in any statically-linked, multi-threaded program.
234 For others, we choose pthread_cancel as a function that seems unlikely
235 to be redefined by an interceptor library. The bionic (Android) C
236 library does not provide pthread_cancel, so we do use pthread_create
237 there (and interceptor libraries lose). */
240 __gthrw2(__gthrw_(__pthread_key_create
),
241 __pthread_key_create
,
243 # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
244 #elif defined (__BIONIC__)
245 # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
247 # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
251 __gthread_active_p (void)
253 static void *const __gthread_active_ptr
254 = __extension__ (void *) >HR_ACTIVE_PROXY
;
255 return __gthread_active_ptr
!= 0;
258 #endif /* FreeBSD or Solaris */
260 #else /* not __GXX_WEAK__ */
262 /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
263 calls in shared flavors of the HP-UX C library. Most of the stubs
264 have no functionality. The details are described in the "libc cumulative
265 patch" for each subversion of HP-UX 11. There are two special interfaces
266 provided for checking whether an application is linked to a shared pthread
267 library or not. However, these interfaces aren't available in early
268 libpthread libraries. We also need a test that works for archive
269 libraries. We can't use pthread_once as some libc versions call the
270 init function. We also can't use pthread_create or pthread_attr_init
271 as these create a thread and thereby prevent changing the default stack
272 size. The function pthread_default_stacksize_np is available in both
273 the archive and shared versions of libpthread. It can be used to
274 determine the default pthread stack size. There is a stub in some
275 shared libc versions which returns a zero size if pthreads are not
276 active. We provide an equivalent stub to handle cases where libc
277 doesn't provide one. */
279 #if defined(__hppa__) && defined(__hpux__)
281 static volatile int __gthread_active
= -1;
284 __gthread_active_p (void)
286 /* Avoid reading __gthread_active twice on the main code path. */
287 int __gthread_active_latest_value
= __gthread_active
;
290 if (__builtin_expect (__gthread_active_latest_value
< 0, 0))
292 pthread_default_stacksize_np (0, &__s
);
293 __gthread_active
= __s
? 1 : 0;
294 __gthread_active_latest_value
= __gthread_active
;
297 return __gthread_active_latest_value
!= 0;
300 #else /* not hppa-hpux */
303 __gthread_active_p (void)
308 #endif /* hppa-hpux */
310 #endif /* __GXX_WEAK__ */
314 /* This is the config.h file in libobjc/ */
321 /* Key structure for maintaining thread specific storage */
322 static pthread_key_t _objc_thread_storage
;
323 static pthread_attr_t _objc_thread_attribs
;
325 /* Thread local storage for a single thread */
326 static void *thread_local_storage
= NULL
;
328 /* Backend initialization functions */
330 /* Initialize the threads subsystem. */
332 __gthread_objc_init_thread_system (void)
334 if (__gthread_active_p ())
336 /* Initialize the thread storage key. */
337 if (__gthrw_(pthread_key_create
) (&_objc_thread_storage
, NULL
) == 0)
339 /* The normal default detach state for threads is
340 * PTHREAD_CREATE_JOINABLE which causes threads to not die
341 * when you think they should. */
342 if (__gthrw_(pthread_attr_init
) (&_objc_thread_attribs
) == 0
343 && __gthrw_(pthread_attr_setdetachstate
) (&_objc_thread_attribs
,
344 PTHREAD_CREATE_DETACHED
) == 0)
352 /* Close the threads subsystem. */
354 __gthread_objc_close_thread_system (void)
356 if (__gthread_active_p ()
357 && __gthrw_(pthread_key_delete
) (_objc_thread_storage
) == 0
358 && __gthrw_(pthread_attr_destroy
) (&_objc_thread_attribs
) == 0)
364 /* Backend thread functions */
366 /* Create a new thread of execution. */
367 static inline objc_thread_t
368 __gthread_objc_thread_detach (void (*func
)(void *), void *arg
)
370 objc_thread_t thread_id
;
371 pthread_t new_thread_handle
;
373 if (!__gthread_active_p ())
376 if (!(__gthrw_(pthread_create
) (&new_thread_handle
, &_objc_thread_attribs
,
377 (void *) func
, arg
)))
378 thread_id
= (objc_thread_t
) new_thread_handle
;
385 /* Set the current thread's priority. */
387 __gthread_objc_thread_set_priority (int priority
)
389 if (!__gthread_active_p ())
393 #ifdef _POSIX_PRIORITY_SCHEDULING
394 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
395 pthread_t thread_id
= __gthrw_(pthread_self
) ();
397 struct sched_param params
;
398 int priority_min
, priority_max
;
400 if (__gthrw_(pthread_getschedparam
) (thread_id
, &policy
, ¶ms
) == 0)
402 if ((priority_max
= __gthrw_(sched_get_priority_max
) (policy
)) == -1)
405 if ((priority_min
= __gthrw_(sched_get_priority_min
) (policy
)) == -1)
408 if (priority
> priority_max
)
409 priority
= priority_max
;
410 else if (priority
< priority_min
)
411 priority
= priority_min
;
412 params
.sched_priority
= priority
;
415 * The solaris 7 and several other man pages incorrectly state that
416 * this should be a pointer to policy but pthread.h is universally
419 if (__gthrw_(pthread_setschedparam
) (thread_id
, policy
, ¶ms
) == 0)
422 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
423 #endif /* _POSIX_PRIORITY_SCHEDULING */
428 /* Return the current thread's priority. */
430 __gthread_objc_thread_get_priority (void)
432 #ifdef _POSIX_PRIORITY_SCHEDULING
433 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
434 if (__gthread_active_p ())
437 struct sched_param params
;
439 if (__gthrw_(pthread_getschedparam
) (__gthrw_(pthread_self
) (), &policy
, ¶ms
) == 0)
440 return params
.sched_priority
;
445 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
446 #endif /* _POSIX_PRIORITY_SCHEDULING */
447 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
450 /* Yield our process time to another thread. */
452 __gthread_objc_thread_yield (void)
454 if (__gthread_active_p ())
455 __gthrw_(sched_yield
) ();
458 /* Terminate the current thread. */
460 __gthread_objc_thread_exit (void)
462 if (__gthread_active_p ())
463 /* exit the thread */
464 __gthrw_(pthread_exit
) (&__objc_thread_exit_status
);
466 /* Failed if we reached here */
470 /* Returns an integer value which uniquely describes a thread. */
471 static inline objc_thread_t
472 __gthread_objc_thread_id (void)
474 if (__gthread_active_p ())
475 return (objc_thread_t
) __gthrw_(pthread_self
) ();
477 return (objc_thread_t
) 1;
480 /* Sets the thread's local storage pointer. */
482 __gthread_objc_thread_set_data (void *value
)
484 if (__gthread_active_p ())
485 return __gthrw_(pthread_setspecific
) (_objc_thread_storage
, value
);
488 thread_local_storage
= value
;
493 /* Returns the thread's local storage pointer. */
495 __gthread_objc_thread_get_data (void)
497 if (__gthread_active_p ())
498 return __gthrw_(pthread_getspecific
) (_objc_thread_storage
);
500 return thread_local_storage
;
503 /* Backend mutex functions */
505 /* Allocate a mutex. */
507 __gthread_objc_mutex_allocate (objc_mutex_t mutex
)
509 if (__gthread_active_p ())
511 mutex
->backend
= objc_malloc (sizeof (pthread_mutex_t
));
513 if (__gthrw_(pthread_mutex_init
) ((pthread_mutex_t
*) mutex
->backend
, NULL
))
515 objc_free (mutex
->backend
);
516 mutex
->backend
= NULL
;
524 /* Deallocate a mutex. */
526 __gthread_objc_mutex_deallocate (objc_mutex_t mutex
)
528 if (__gthread_active_p ())
533 * Posix Threads specifically require that the thread be unlocked
534 * for __gthrw_(pthread_mutex_destroy) to work.
539 count
= __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
);
545 if (__gthrw_(pthread_mutex_destroy
) ((pthread_mutex_t
*) mutex
->backend
))
548 objc_free (mutex
->backend
);
549 mutex
->backend
= NULL
;
554 /* Grab a lock on a mutex. */
556 __gthread_objc_mutex_lock (objc_mutex_t mutex
)
558 if (__gthread_active_p ()
559 && __gthrw_(pthread_mutex_lock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
567 /* Try to grab a lock on a mutex. */
569 __gthread_objc_mutex_trylock (objc_mutex_t mutex
)
571 if (__gthread_active_p ()
572 && __gthrw_(pthread_mutex_trylock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
580 /* Unlock the mutex */
582 __gthread_objc_mutex_unlock (objc_mutex_t mutex
)
584 if (__gthread_active_p ()
585 && __gthrw_(pthread_mutex_unlock
) ((pthread_mutex_t
*) mutex
->backend
) != 0)
593 /* Backend condition mutex functions */
595 /* Allocate a condition. */
597 __gthread_objc_condition_allocate (objc_condition_t condition
)
599 if (__gthread_active_p ())
601 condition
->backend
= objc_malloc (sizeof (pthread_cond_t
));
603 if (__gthrw_(pthread_cond_init
) ((pthread_cond_t
*) condition
->backend
, NULL
))
605 objc_free (condition
->backend
);
606 condition
->backend
= NULL
;
614 /* Deallocate a condition. */
616 __gthread_objc_condition_deallocate (objc_condition_t condition
)
618 if (__gthread_active_p ())
620 if (__gthrw_(pthread_cond_destroy
) ((pthread_cond_t
*) condition
->backend
))
623 objc_free (condition
->backend
);
624 condition
->backend
= NULL
;
629 /* Wait on the condition */
631 __gthread_objc_condition_wait (objc_condition_t condition
, objc_mutex_t mutex
)
633 if (__gthread_active_p ())
634 return __gthrw_(pthread_cond_wait
) ((pthread_cond_t
*) condition
->backend
,
635 (pthread_mutex_t
*) mutex
->backend
);
640 /* Wake up all threads waiting on this condition. */
642 __gthread_objc_condition_broadcast (objc_condition_t condition
)
644 if (__gthread_active_p ())
645 return __gthrw_(pthread_cond_broadcast
) ((pthread_cond_t
*) condition
->backend
);
650 /* Wake up one thread waiting on this condition. */
652 __gthread_objc_condition_signal (objc_condition_t condition
)
654 if (__gthread_active_p ())
655 return __gthrw_(pthread_cond_signal
) ((pthread_cond_t
*) condition
->backend
);
663 __gthread_create (__gthread_t
*__threadid
, void *(*__func
) (void*),
666 return __gthrw_(pthread_create
) (__threadid
, NULL
, __func
, __args
);
670 __gthread_join (__gthread_t __threadid
, void **__value_ptr
)
672 return __gthrw_(pthread_join
) (__threadid
, __value_ptr
);
676 __gthread_detach (__gthread_t __threadid
)
678 return __gthrw_(pthread_detach
) (__threadid
);
682 __gthread_equal (__gthread_t __t1
, __gthread_t __t2
)
684 return __gthrw_(pthread_equal
) (__t1
, __t2
);
687 static inline __gthread_t
688 __gthread_self (void)
690 return __gthrw_(pthread_self
) ();
694 __gthread_yield (void)
696 return __gthrw_(sched_yield
) ();
700 __gthread_once (__gthread_once_t
*__once
, void (*__func
) (void))
702 if (__gthread_active_p ())
703 return __gthrw_(pthread_once
) (__once
, __func
);
709 __gthread_key_create (__gthread_key_t
*__key
, void (*__dtor
) (void *))
711 return __gthrw_(pthread_key_create
) (__key
, __dtor
);
715 __gthread_key_delete (__gthread_key_t __key
)
717 return __gthrw_(pthread_key_delete
) (__key
);
721 __gthread_getspecific (__gthread_key_t __key
)
723 return __gthrw_(pthread_getspecific
) (__key
);
727 __gthread_setspecific (__gthread_key_t __key
, const void *__ptr
)
729 return __gthrw_(pthread_setspecific
) (__key
, __ptr
);
733 __gthread_mutex_init_function (__gthread_mutex_t
*__mutex
)
735 if (__gthread_active_p ())
736 __gthrw_(pthread_mutex_init
) (__mutex
, NULL
);
740 __gthread_mutex_destroy (__gthread_mutex_t
*__mutex
)
742 if (__gthread_active_p ())
743 return __gthrw_(pthread_mutex_destroy
) (__mutex
);
749 __gthread_mutex_lock (__gthread_mutex_t
*__mutex
)
751 if (__gthread_active_p ())
752 return __gthrw_(pthread_mutex_lock
) (__mutex
);
758 __gthread_mutex_trylock (__gthread_mutex_t
*__mutex
)
760 if (__gthread_active_p ())
761 return __gthrw_(pthread_mutex_trylock
) (__mutex
);
766 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
768 __gthread_mutex_timedlock (__gthread_mutex_t
*__mutex
,
769 const __gthread_time_t
*__abs_timeout
)
771 if (__gthread_active_p ())
772 return __gthrw_(pthread_mutex_timedlock
) (__mutex
, __abs_timeout
);
779 __gthread_mutex_unlock (__gthread_mutex_t
*__mutex
)
781 if (__gthread_active_p ())
782 return __gthrw_(pthread_mutex_unlock
) (__mutex
);
787 #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
788 || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
790 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t
*__mutex
)
792 if (__gthread_active_p ())
794 pthread_mutexattr_t __attr
;
797 __r
= __gthrw_(pthread_mutexattr_init
) (&__attr
);
799 __r
= __gthrw_(pthread_mutexattr_settype
) (&__attr
,
800 PTHREAD_MUTEX_RECURSIVE
);
802 __r
= __gthrw_(pthread_mutex_init
) (__mutex
, &__attr
);
804 __r
= __gthrw_(pthread_mutexattr_destroy
) (&__attr
);
812 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*__mutex
)
814 return __gthread_mutex_lock (__mutex
);
818 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*__mutex
)
820 return __gthread_mutex_trylock (__mutex
);
823 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
825 __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t
*__mutex
,
826 const __gthread_time_t
*__abs_timeout
)
828 return __gthread_mutex_timedlock (__mutex
, __abs_timeout
);
833 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*__mutex
)
835 return __gthread_mutex_unlock (__mutex
);
839 __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t
*__mutex
)
841 return __gthread_mutex_destroy (__mutex
);
844 #ifdef _GTHREAD_USE_COND_INIT_FUNC
846 __gthread_cond_init_function (__gthread_cond_t
*__cond
)
848 if (__gthread_active_p ())
849 __gthrw_(pthread_cond_init
) (__cond
, NULL
);
854 __gthread_cond_broadcast (__gthread_cond_t
*__cond
)
856 return __gthrw_(pthread_cond_broadcast
) (__cond
);
860 __gthread_cond_signal (__gthread_cond_t
*__cond
)
862 return __gthrw_(pthread_cond_signal
) (__cond
);
866 __gthread_cond_wait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
)
868 return __gthrw_(pthread_cond_wait
) (__cond
, __mutex
);
872 __gthread_cond_timedwait (__gthread_cond_t
*__cond
, __gthread_mutex_t
*__mutex
,
873 const __gthread_time_t
*__abs_timeout
)
875 return __gthrw_(pthread_cond_timedwait
) (__cond
, __mutex
, __abs_timeout
);
879 __gthread_cond_wait_recursive (__gthread_cond_t
*__cond
,
880 __gthread_recursive_mutex_t
*__mutex
)
882 return __gthread_cond_wait (__cond
, __mutex
);
886 __gthread_cond_destroy (__gthread_cond_t
* __cond
)
888 return __gthrw_(pthread_cond_destroy
) (__cond
);
891 #endif /* _LIBOBJC */
893 #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */