OSDN Git Service

gcc/testsuite/
[pf3gnuchains/gcc-fork.git] / gcc / gthr-posix.h
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    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
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 2, or (at your option) any later
11 version.
12
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
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.  */
22
23 /* As a special exception, if you link this library with other files,
24    some of which are compiled with GCC, to produce an executable,
25    this library does not by itself cause the resulting executable
26    to be covered by the GNU General Public License.
27    This exception does not however invalidate any other reasons why
28    the executable file might be covered by the GNU General Public License.  */
29
30 #ifndef GCC_GTHR_POSIX_H
31 #define GCC_GTHR_POSIX_H
32
33 /* POSIX threads specific definitions.
34    Easy, since the interface is just one-to-one mapping.  */
35
36 #define __GTHREADS 1
37
38 /* Some implementations of <pthread.h> require this to be defined.  */
39 #if !defined(_REENTRANT) && defined(__osf__)
40 #define _REENTRANT 1
41 #endif
42
43 #include <pthread.h>
44 #include <unistd.h>
45
46 typedef pthread_key_t __gthread_key_t;
47 typedef pthread_once_t __gthread_once_t;
48 typedef pthread_mutex_t __gthread_mutex_t;
49 typedef pthread_mutex_t __gthread_recursive_mutex_t;
50
51 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
52 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
53 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
54 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
55 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
56 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
57 #else
58 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
59 #endif
60
61 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
62 # ifndef __gthrw_pragma
63 #  define __gthrw_pragma(pragma)
64 # endif
65 # define __gthrw2(name,name2,type) \
66   static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
67   __gthrw_pragma(weak type)
68 # define __gthrw_(name) __gthrw_ ## name
69 #else
70 # define __gthrw2(name,name2,type)
71 # define __gthrw_(name) name
72 #endif
73
74 /* Typically, __gthrw_foo is a weak reference to symbol foo.  */
75 #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
76
77 /* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to
78    map a subset of the POSIX pthread API to mangled versions of their
79    names.  */
80 #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
81 #define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name)
82 __gthrw3(pthread_once)
83 __gthrw3(pthread_getspecific)
84 __gthrw3(pthread_setspecific)
85 __gthrw3(pthread_create)
86 __gthrw3(pthread_cancel)
87 __gthrw3(pthread_mutex_lock)
88 __gthrw3(pthread_mutex_trylock)
89 __gthrw3(pthread_mutex_unlock)
90 __gthrw3(pthread_mutex_init)
91 #else
92 __gthrw(pthread_once)
93 __gthrw(pthread_getspecific)
94 __gthrw(pthread_setspecific)
95 __gthrw(pthread_create)
96 __gthrw(pthread_cancel)
97 __gthrw(pthread_mutex_lock)
98 __gthrw(pthread_mutex_trylock)
99 __gthrw(pthread_mutex_unlock)
100 __gthrw(pthread_mutex_init)
101 #endif
102
103 __gthrw(pthread_key_create)
104 __gthrw(pthread_key_delete)
105 __gthrw(pthread_mutexattr_init)
106 __gthrw(pthread_mutexattr_settype)
107 __gthrw(pthread_mutexattr_destroy)
108
109
110 #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
111 /* Objective-C.  */
112 #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
113 __gthrw3(pthread_cond_broadcast)
114 __gthrw3(pthread_cond_destroy)
115 __gthrw3(pthread_cond_init)
116 __gthrw3(pthread_cond_signal)
117 __gthrw3(pthread_cond_wait)
118 __gthrw3(pthread_exit)
119 __gthrw3(pthread_mutex_destroy)
120 __gthrw3(pthread_self)
121 #else
122 __gthrw(pthread_cond_broadcast)
123 __gthrw(pthread_cond_destroy)
124 __gthrw(pthread_cond_init)
125 __gthrw(pthread_cond_signal)
126 __gthrw(pthread_cond_wait)
127 __gthrw(pthread_exit)
128 __gthrw(pthread_mutex_destroy)
129 __gthrw(pthread_self)
130 #endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */
131 #ifdef _POSIX_PRIORITY_SCHEDULING
132 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
133 __gthrw(sched_get_priority_max)
134 __gthrw(sched_get_priority_min)
135 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
136 #endif /* _POSIX_PRIORITY_SCHEDULING */
137 __gthrw(sched_yield)
138 __gthrw(pthread_attr_destroy)
139 __gthrw(pthread_attr_init)
140 __gthrw(pthread_attr_setdetachstate)
141 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
142 __gthrw(pthread_getschedparam)
143 __gthrw(pthread_setschedparam)
144 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
145 #endif /* _LIBOBJC || _LIBOBJC_WEAK */
146
147 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
148
149 /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
150    -pthreads is not specified.  The functions are dummies and most return an
151    error value.  However pthread_once returns 0 without invoking the routine
152    it is passed so we cannot pretend that the interface is active if -pthreads
153    is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
154    we need to play the usual game with weak symbols.  On Solaris 10 and up, a
155    working interface is always exposed.  */
156
157 #if defined(__sun) && defined(__svr4__)
158
159 static volatile int __gthread_active = -1;
160
161 static void
162 __gthread_trigger (void)
163 {
164   __gthread_active = 1;
165 }
166
167 static inline int
168 __gthread_active_p (void)
169 {
170   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
171   static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
172
173   /* Avoid reading __gthread_active twice on the main code path.  */
174   int __gthread_active_latest_value = __gthread_active;
175
176   /* This test is not protected to avoid taking a lock on the main code
177      path so every update of __gthread_active in a threaded program must
178      be atomic with regard to the result of the test.  */
179   if (__builtin_expect (__gthread_active_latest_value < 0, 0))
180     {
181       if (__gthrw_(pthread_once))
182         {
183           /* If this really is a threaded program, then we must ensure that
184              __gthread_active has been set to 1 before exiting this block.  */
185           __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
186           __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
187           __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
188         }
189
190       /* Make sure we'll never enter this block again.  */
191       if (__gthread_active < 0)
192         __gthread_active = 0;
193
194       __gthread_active_latest_value = __gthread_active;
195     }
196
197   return __gthread_active_latest_value != 0;
198 }
199
200 #else /* not Solaris */
201
202 static inline int
203 __gthread_active_p (void)
204 {
205   static void *const __gthread_active_ptr 
206     = __extension__ (void *) &__gthrw_(pthread_cancel);
207   return __gthread_active_ptr != 0;
208 }
209
210 #endif /* Solaris */
211
212 #else /* not SUPPORTS_WEAK */
213
214 /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
215    calls in shared flavors of the HP-UX C library.  Most of the stubs
216    have no functionality.  The details are described in the "libc cumulative
217    patch" for each subversion of HP-UX 11.  There are two special interfaces
218    provided for checking whether an application is linked to a pthread
219    library or not.  However, these interfaces aren't available in early
220    libc versions.  We also can't use pthread_once as some libc versions
221    call the init function.  So, we use pthread_create to check whether it
222    is possible to create a thread or not.  The stub implementation returns
223    the error number ENOSYS.  */
224
225 #if defined(__hppa__) && defined(__hpux__)
226
227 #include <errno.h>
228
229 static volatile int __gthread_active = -1;
230
231 static void *
232 __gthread_start (void *arg __attribute__((unused)))
233 {
234   return NULL;
235 }
236
237 static void __gthread_active_init (void) __attribute__((noinline));
238 static void
239 __gthread_active_init (void)
240 {
241   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
242   pthread_t t;
243   int result;
244
245   __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
246   if (__gthread_active < 0)
247     {
248       result = __gthrw_(pthread_create) (&t, NULL, __gthread_start, NULL);
249       if (result != ENOSYS)
250         {
251           __gthread_active = 1;
252           if (!result)
253             __gthrw_(pthread_join) (t, NULL);
254         }
255       else
256         __gthread_active = 0;
257     }
258   __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
259 }
260
261 static inline int
262 __gthread_active_p (void)
263 {
264   /* Avoid reading __gthread_active twice on the main code path.  */
265   int __gthread_active_latest_value = __gthread_active;
266
267   /* This test is not protected to avoid taking a lock on the main code
268      path so every update of __gthread_active in a threaded program must
269      be atomic with regard to the result of the test.  */
270   if (__builtin_expect (__gthread_active_latest_value < 0, 0))
271     {
272       __gthread_active_init ();
273       __gthread_active_latest_value = __gthread_active;
274     }
275
276   return __gthread_active_latest_value != 0;
277 }
278
279 #else /* not hppa-hpux */
280
281 static inline int
282 __gthread_active_p (void)
283 {
284   return 1;
285 }
286
287 #endif /* hppa-hpux */
288
289 #endif /* SUPPORTS_WEAK */
290
291 #ifdef _LIBOBJC
292
293 /* This is the config.h file in libobjc/ */
294 #include <config.h>
295
296 #ifdef HAVE_SCHED_H
297 # include <sched.h>
298 #endif
299
300 /* Key structure for maintaining thread specific storage */
301 static pthread_key_t _objc_thread_storage;
302 static pthread_attr_t _objc_thread_attribs;
303
304 /* Thread local storage for a single thread */
305 static void *thread_local_storage = NULL;
306
307 /* Backend initialization functions */
308
309 /* Initialize the threads subsystem.  */
310 static inline int
311 __gthread_objc_init_thread_system (void)
312 {
313   if (__gthread_active_p ())
314     {
315       /* Initialize the thread storage key.  */
316       if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
317         {
318           /* The normal default detach state for threads is
319            * PTHREAD_CREATE_JOINABLE which causes threads to not die
320            * when you think they should.  */
321           if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
322               && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
323                                               PTHREAD_CREATE_DETACHED) == 0)
324             return 0;
325         }
326     }
327
328   return -1;
329 }
330
331 /* Close the threads subsystem.  */
332 static inline int
333 __gthread_objc_close_thread_system (void)
334 {
335   if (__gthread_active_p ()
336       && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
337       && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
338     return 0;
339
340   return -1;
341 }
342
343 /* Backend thread functions */
344
345 /* Create a new thread of execution.  */
346 static inline objc_thread_t
347 __gthread_objc_thread_detach (void (*func)(void *), void *arg)
348 {
349   objc_thread_t thread_id;
350   pthread_t new_thread_handle;
351
352   if (!__gthread_active_p ())
353     return NULL;
354
355   if (!(__gthrw_(pthread_create) (&new_thread_handle, NULL, (void *) func, arg)))
356     thread_id = (objc_thread_t) new_thread_handle;
357   else
358     thread_id = NULL;
359
360   return thread_id;
361 }
362
363 /* Set the current thread's priority.  */
364 static inline int
365 __gthread_objc_thread_set_priority (int priority)
366 {
367   if (!__gthread_active_p ())
368     return -1;
369   else
370     {
371 #ifdef _POSIX_PRIORITY_SCHEDULING
372 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
373       pthread_t thread_id = __gthrw_(pthread_self) ();
374       int policy;
375       struct sched_param params;
376       int priority_min, priority_max;
377
378       if (__gthrw_(pthread_getschedparam) (thread_id, &policy, &params) == 0)
379         {
380           if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
381             return -1;
382
383           if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
384             return -1;
385
386           if (priority > priority_max)
387             priority = priority_max;
388           else if (priority < priority_min)
389             priority = priority_min;
390           params.sched_priority = priority;
391
392           /*
393            * The solaris 7 and several other man pages incorrectly state that
394            * this should be a pointer to policy but pthread.h is universally
395            * at odds with this.
396            */
397           if (__gthrw_(pthread_setschedparam) (thread_id, policy, &params) == 0)
398             return 0;
399         }
400 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
401 #endif /* _POSIX_PRIORITY_SCHEDULING */
402       return -1;
403     }
404 }
405
406 /* Return the current thread's priority.  */
407 static inline int
408 __gthread_objc_thread_get_priority (void)
409 {
410 #ifdef _POSIX_PRIORITY_SCHEDULING
411 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
412   if (__gthread_active_p ())
413     {
414       int policy;
415       struct sched_param params;
416
417       if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, &params) == 0)
418         return params.sched_priority;
419       else
420         return -1;
421     }
422   else
423 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
424 #endif /* _POSIX_PRIORITY_SCHEDULING */
425     return OBJC_THREAD_INTERACTIVE_PRIORITY;
426 }
427
428 /* Yield our process time to another thread.  */
429 static inline void
430 __gthread_objc_thread_yield (void)
431 {
432   if (__gthread_active_p ())
433     __gthrw_(sched_yield) ();
434 }
435
436 /* Terminate the current thread.  */
437 static inline int
438 __gthread_objc_thread_exit (void)
439 {
440   if (__gthread_active_p ())
441     /* exit the thread */
442     __gthrw_(pthread_exit) (&__objc_thread_exit_status);
443
444   /* Failed if we reached here */
445   return -1;
446 }
447
448 /* Returns an integer value which uniquely describes a thread.  */
449 static inline objc_thread_t
450 __gthread_objc_thread_id (void)
451 {
452   if (__gthread_active_p ())
453     return (objc_thread_t) __gthrw_(pthread_self) ();
454   else
455     return (objc_thread_t) 1;
456 }
457
458 /* Sets the thread's local storage pointer.  */
459 static inline int
460 __gthread_objc_thread_set_data (void *value)
461 {
462   if (__gthread_active_p ())
463     return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
464   else
465     {
466       thread_local_storage = value;
467       return 0;
468     }
469 }
470
471 /* Returns the thread's local storage pointer.  */
472 static inline void *
473 __gthread_objc_thread_get_data (void)
474 {
475   if (__gthread_active_p ())
476     return __gthrw_(pthread_getspecific) (_objc_thread_storage);
477   else
478     return thread_local_storage;
479 }
480
481 /* Backend mutex functions */
482
483 /* Allocate a mutex.  */
484 static inline int
485 __gthread_objc_mutex_allocate (objc_mutex_t mutex)
486 {
487   if (__gthread_active_p ())
488     {
489       mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
490
491       if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
492         {
493           objc_free (mutex->backend);
494           mutex->backend = NULL;
495           return -1;
496         }
497     }
498
499   return 0;
500 }
501
502 /* Deallocate a mutex.  */
503 static inline int
504 __gthread_objc_mutex_deallocate (objc_mutex_t mutex)
505 {
506   if (__gthread_active_p ())
507     {
508       int count;
509
510       /*
511        * Posix Threads specifically require that the thread be unlocked
512        * for __gthrw_(pthread_mutex_destroy) to work.
513        */
514
515       do
516         {
517           count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
518           if (count < 0)
519             return -1;
520         }
521       while (count);
522
523       if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
524         return -1;
525
526       objc_free (mutex->backend);
527       mutex->backend = NULL;
528     }
529   return 0;
530 }
531
532 /* Grab a lock on a mutex.  */
533 static inline int
534 __gthread_objc_mutex_lock (objc_mutex_t mutex)
535 {
536   if (__gthread_active_p ()
537       && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
538     {
539       return -1;
540     }
541
542   return 0;
543 }
544
545 /* Try to grab a lock on a mutex.  */
546 static inline int
547 __gthread_objc_mutex_trylock (objc_mutex_t mutex)
548 {
549   if (__gthread_active_p ()
550       && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
551     {
552       return -1;
553     }
554
555   return 0;
556 }
557
558 /* Unlock the mutex */
559 static inline int
560 __gthread_objc_mutex_unlock (objc_mutex_t mutex)
561 {
562   if (__gthread_active_p ()
563       && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
564     {
565       return -1;
566     }
567
568   return 0;
569 }
570
571 /* Backend condition mutex functions */
572
573 /* Allocate a condition.  */
574 static inline int
575 __gthread_objc_condition_allocate (objc_condition_t condition)
576 {
577   if (__gthread_active_p ())
578     {
579       condition->backend = objc_malloc (sizeof (pthread_cond_t));
580
581       if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
582         {
583           objc_free (condition->backend);
584           condition->backend = NULL;
585           return -1;
586         }
587     }
588
589   return 0;
590 }
591
592 /* Deallocate a condition.  */
593 static inline int
594 __gthread_objc_condition_deallocate (objc_condition_t condition)
595 {
596   if (__gthread_active_p ())
597     {
598       if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
599         return -1;
600
601       objc_free (condition->backend);
602       condition->backend = NULL;
603     }
604   return 0;
605 }
606
607 /* Wait on the condition */
608 static inline int
609 __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
610 {
611   if (__gthread_active_p ())
612     return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
613                               (pthread_mutex_t *) mutex->backend);
614   else
615     return 0;
616 }
617
618 /* Wake up all threads waiting on this condition.  */
619 static inline int
620 __gthread_objc_condition_broadcast (objc_condition_t condition)
621 {
622   if (__gthread_active_p ())
623     return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
624   else
625     return 0;
626 }
627
628 /* Wake up one thread waiting on this condition.  */
629 static inline int
630 __gthread_objc_condition_signal (objc_condition_t condition)
631 {
632   if (__gthread_active_p ())
633     return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
634   else
635     return 0;
636 }
637
638 #else /* _LIBOBJC */
639
640 static inline int
641 __gthread_once (__gthread_once_t *once, void (*func) (void))
642 {
643   if (__gthread_active_p ())
644     return __gthrw_(pthread_once) (once, func);
645   else
646     return -1;
647 }
648
649 static inline int
650 __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
651 {
652   return __gthrw_(pthread_key_create) (key, dtor);
653 }
654
655 static inline int
656 __gthread_key_delete (__gthread_key_t key)
657 {
658   return __gthrw_(pthread_key_delete) (key);
659 }
660
661 static inline void *
662 __gthread_getspecific (__gthread_key_t key)
663 {
664   return __gthrw_(pthread_getspecific) (key);
665 }
666
667 static inline int
668 __gthread_setspecific (__gthread_key_t key, const void *ptr)
669 {
670   return __gthrw_(pthread_setspecific) (key, ptr);
671 }
672
673 static inline int
674 __gthread_mutex_lock (__gthread_mutex_t *mutex)
675 {
676   if (__gthread_active_p ())
677     return __gthrw_(pthread_mutex_lock) (mutex);
678   else
679     return 0;
680 }
681
682 static inline int
683 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
684 {
685   if (__gthread_active_p ())
686     return __gthrw_(pthread_mutex_trylock) (mutex);
687   else
688     return 0;
689 }
690
691 static inline int
692 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
693 {
694   if (__gthread_active_p ())
695     return __gthrw_(pthread_mutex_unlock) (mutex);
696   else
697     return 0;
698 }
699
700 #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
701 static inline int
702 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
703 {
704   if (__gthread_active_p ())
705     {
706       pthread_mutexattr_t attr;
707       int r;
708
709       r = __gthrw_(pthread_mutexattr_init) (&attr);
710       if (!r)
711         r = __gthrw_(pthread_mutexattr_settype) (&attr, PTHREAD_MUTEX_RECURSIVE);
712       if (!r)
713         r = __gthrw_(pthread_mutex_init) (mutex, &attr);
714       if (!r)
715         r = __gthrw_(pthread_mutexattr_destroy) (&attr);
716       return r;
717     }
718   return 0;
719 }
720 #endif
721
722 static inline int
723 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
724 {
725   return __gthread_mutex_lock (mutex);
726 }
727
728 static inline int
729 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
730 {
731   return __gthread_mutex_trylock (mutex);
732 }
733
734 static inline int
735 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
736 {
737   return __gthread_mutex_unlock (mutex);
738 }
739
740 #endif /* _LIBOBJC */
741
742 #endif /* ! GCC_GTHR_POSIX_H */