00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _GLIBCXX_GCC_GTHR_TPF_H
00036 #define _GLIBCXX_GCC_GTHR_TPF_H
00037
00038
00039
00040
00041 #define __GTHREADS 1
00042
00043
00044 #ifndef _REENTRANT
00045 #define _REENTRANT 1
00046 #endif
00047
00048 #include <pthread.h>
00049 #include <unistd.h>
00050
00051 typedef pthread_key_t __gthread_key_t;
00052 typedef pthread_once_t __gthread_once_t;
00053 typedef pthread_mutex_t __gthread_mutex_t;
00054 typedef pthread_mutex_t __gthread_recursive_mutex_t;
00055
00056 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
00057 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
00058 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
00059 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
00060 #endif
00061
00062 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
00063 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
00064
00065 #define NOTATHREAD 00
00066 #define ECBBASEPTR (unsigned long int) *(unsigned int *)0x00000514u
00067 #define ECBPG2PTR ECBBASEPTR + 0x1000
00068 #define CE2THRCPTR *((unsigned char *)(ECBPG2PTR + 208))
00069 #define __tpf_pthread_active() (CE2THRCPTR != NOTATHREAD)
00070
00071 #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
00072
00073 #pragma weak pthread_once
00074 #pragma weak pthread_key_create
00075 #pragma weak pthread_key_delete
00076 #pragma weak pthread_getspecific
00077 #pragma weak pthread_setspecific
00078 #pragma weak pthread_create
00079
00080 #pragma weak pthread_mutex_lock
00081 #pragma weak pthread_mutex_trylock
00082 #pragma weak pthread_mutex_unlock
00083
00084 #endif
00085
00086 static inline int
00087 __gthread_active_p (void)
00088 {
00089 return 1;
00090 }
00091
00092 static inline int
00093 __gthread_once (__gthread_once_t *once, void (*func) (void))
00094 {
00095 if (__tpf_pthread_active ())
00096 return pthread_once (once, func);
00097 else
00098 return -1;
00099 }
00100
00101 static inline int
00102 __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
00103 {
00104 if (__tpf_pthread_active ())
00105 return pthread_key_create (key, dtor);
00106 else
00107 return -1;
00108 }
00109
00110 static inline int
00111 __gthread_key_delete (__gthread_key_t key)
00112 {
00113 if (__tpf_pthread_active ())
00114 return pthread_key_delete (key);
00115 else
00116 return -1;
00117 }
00118
00119 static inline void *
00120 __gthread_getspecific (__gthread_key_t key)
00121 {
00122 if (__tpf_pthread_active ())
00123 return pthread_getspecific (key);
00124 else
00125 return NULL;
00126 }
00127
00128 static inline int
00129 __gthread_setspecific (__gthread_key_t key, const void *ptr)
00130 {
00131 if (__tpf_pthread_active ())
00132 return pthread_setspecific (key, ptr);
00133 else
00134 return -1;
00135 }
00136
00137 static inline int
00138 __gthread_mutex_lock (__gthread_mutex_t *mutex)
00139 {
00140 if (__tpf_pthread_active ())
00141 return pthread_mutex_lock (mutex);
00142 else
00143 return 0;
00144 }
00145
00146 static inline int
00147 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
00148 {
00149 if (__tpf_pthread_active ())
00150 return pthread_mutex_trylock (mutex);
00151 else
00152 return 0;
00153 }
00154
00155 static inline int
00156 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
00157 {
00158 if (__tpf_pthread_active ())
00159 return pthread_mutex_unlock (mutex);
00160 else
00161 return 0;
00162 }
00163
00164 static inline int
00165 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
00166 {
00167 if (__tpf_pthread_active ())
00168 return __gthread_mutex_lock (mutex);
00169 else
00170 return 0;
00171 }
00172
00173 static inline int
00174 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
00175 {
00176 if (__tpf_pthread_active ())
00177 return __gthread_mutex_trylock (mutex);
00178 else
00179 return 0;
00180 }
00181
00182 static inline int
00183 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
00184 {
00185 if (__tpf_pthread_active ())
00186 return __gthread_mutex_unlock (mutex);
00187 else
00188 return 0;
00189 }
00190
00191 #endif