2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
32 /* DCE threads interface.
33 DCE threads are based on POSIX threads draft 4, and many things
34 have changed since then. */
40 typedef pthread_key_t __gthread_key_t
;
41 typedef pthread_once_t __gthread_once_t
;
42 typedef pthread_mutex_t __gthread_mutex_t
;
44 #define __GTHREAD_ONCE_INIT pthread_once_init
45 /* Howto define __GTHREAD_MUTEX_INIT? */
47 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
49 #pragma weak pthread_once
50 #pragma weak pthread_once_init
51 #pragma weak pthread_key_create
52 #pragma weak pthread_key_delete
53 #pragma weak pthread_getspecific
54 #pragma weak pthread_setspecific
55 #pragma weak pthread_create
57 #pragma weak pthread_mutex_lock
58 #pragma weak pthread_mutex_trylock
59 #pragma weak pthread_mutex_unlock
61 static void *__gthread_active_ptr
= &pthread_create
;
66 return __gthread_active_ptr
!= 0;
69 #else /* not SUPPORTS_WEAK */
77 #endif /* SUPPORTS_WEAK */
80 __gthread_once (__gthread_once_t
*once
, void (*func
) ())
82 if (__gthread_active_p ())
83 return pthread_once (once
, func
);
89 __gthread_key_create (__gthread_key_t
*key
, void (*dtor
) (void *))
91 return pthread_keycreate (key
, dtor
);
95 __gthread_key_dtor (__gthread_key_t key
, void *ptr
)
102 __gthread_key_delete (__gthread_key_t key
)
104 return pthread_key_delete (key
);
108 __gthread_getspecific (__gthread_key_t key
)
111 if (pthread_getspecific (key
, &ptr
) == 0)
118 __gthread_setspecific (__gthread_key_t key
, const void *ptr
)
120 return pthread_setspecific (key
, (void *) ptr
);
124 __gthread_mutex_lock (__gthread_mutex_t
*mutex
)
126 if (__gthread_active_p ())
127 return pthread_mutex_lock (mutex
);
133 __gthread_mutex_trylock (__gthread_mutex_t
*mutex
)
135 if (__gthread_active_p ())
136 return pthread_mutex_trylock (mutex
);
142 __gthread_mutex_unlock (__gthread_mutex_t
*mutex
)
144 if (__gthread_active_p ())
145 return pthread_mutex_unlock (mutex
);
150 #endif /* not __gthr_dce_h */