31 #ifndef _GLIBCXX_GCC_GTHR_TPF_H
32 #define _GLIBCXX_GCC_GTHR_TPF_H
47 typedef pthread_key_t __gthread_key_t;
48 typedef pthread_once_t __gthread_once_t;
49 typedef pthread_mutex_t __gthread_mutex_t;
50 typedef pthread_mutex_t __gthread_recursive_mutex_t;
52 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
53 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
54 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
55 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
58 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
59 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
60 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
63 #define ECBBASEPTR (unsigned long int) *(unsigned int *)0x00000514u
64 #define ECBPG2PTR ECBBASEPTR + 0x1000
65 #define CE2THRCPTR *((unsigned char *)(ECBPG2PTR + 16))
66 #define __tpf_pthread_active() (CE2THRCPTR != NOTATHREAD)
68 #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
69 # define __gthrw(name) \
70 static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name)));
71 # define __gthrw_(name) __gthrw_ ## name
73 # define __gthrw(name)
74 # define __gthrw_(name) name
78 __gthrw(pthread_key_create)
79 __gthrw(pthread_key_delete)
80 __gthrw(pthread_getspecific)
81 __gthrw(pthread_setspecific)
82 __gthrw(pthread_create)
84 __gthrw(pthread_mutex_lock)
85 __gthrw(pthread_mutex_trylock)
86 __gthrw(pthread_mutex_unlock)
87 __gthrw(pthread_mutexattr_init)
88 __gthrw(pthread_mutexattr_settype)
89 __gthrw(pthread_mutexattr_destroy)
90 __gthrw(pthread_mutex_init)
91 __gthrw(pthread_mutex_destroy)
94 __gthread_active_p (
void)
100 __gthread_once (__gthread_once_t *__once,
void (*__func) (
void))
102 if (__tpf_pthread_active ())
103 return __gthrw_(pthread_once) (__once, __func);
109 __gthread_key_create (__gthread_key_t *__key,
void (*__dtor) (
void *))
111 if (__tpf_pthread_active ())
112 return __gthrw_(pthread_key_create) (__key, __dtor);
118 __gthread_key_delete (__gthread_key_t __key)
120 if (__tpf_pthread_active ())
121 return __gthrw_(pthread_key_delete) (__key);
127 __gthread_getspecific (__gthread_key_t __key)
129 if (__tpf_pthread_active ())
130 return __gthrw_(pthread_getspecific) (__key);
136 __gthread_setspecific (__gthread_key_t __key,
const void *__ptr)
138 if (__tpf_pthread_active ())
139 return __gthrw_(pthread_setspecific) (__key, __ptr);
145 __gthread_mutex_destroy (__gthread_mutex_t *__mutex)
147 if (__tpf_pthread_active ())
148 return __gthrw_(pthread_mutex_destroy) (__mutex);
154 __gthread_mutex_lock (__gthread_mutex_t *__mutex)
156 if (__tpf_pthread_active ())
157 return __gthrw_(pthread_mutex_lock) (__mutex);
163 __gthread_mutex_trylock (__gthread_mutex_t *__mutex)
165 if (__tpf_pthread_active ())
166 return __gthrw_(pthread_mutex_trylock) (__mutex);
172 __gthread_mutex_unlock (__gthread_mutex_t *__mutex)
174 if (__tpf_pthread_active ())
175 return __gthrw_(pthread_mutex_unlock) (__mutex);
181 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
183 if (__tpf_pthread_active ())
184 return __gthread_mutex_lock (__mutex);
190 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
192 if (__tpf_pthread_active ())
193 return __gthread_mutex_trylock (__mutex);
199 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
201 if (__tpf_pthread_active ())
202 return __gthread_mutex_unlock (__mutex);
208 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
210 if (__tpf_pthread_active ())
212 pthread_mutexattr_t __attr;
215 __r = __gthrw_(pthread_mutexattr_init) (&__attr);
217 __r = __gthrw_(pthread_mutexattr_settype) (&__attr,
218 PTHREAD_MUTEX_RECURSIVE);
220 __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
222 __r = __gthrw_(pthread_mutexattr_destroy) (&__attr);