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 #ifndef GCC_GTHR_VXWORKS_H
00031 #define GCC_GTHR_VXWORKS_H
00032
00033 #ifdef _LIBOBJC
00034
00035
00036 static void *thread_local_storage = NULL;
00037
00038
00039
00040
00041 int
00042 __gthread_objc_init_thread_system (void)
00043 {
00044
00045 return -1;
00046 }
00047
00048
00049 int
00050 __gthread_objc_close_thread_system (void)
00051 {
00052
00053 return -1;
00054 }
00055
00056
00057
00058
00059 objc_thread_t
00060 __gthread_objc_thread_detach (void (*func)(void *arg), void *arg)
00061 {
00062
00063 return NULL;
00064 }
00065
00066
00067 int
00068 __gthread_objc_thread_set_priority (int priority)
00069 {
00070
00071 return -1;
00072 }
00073
00074
00075 int
00076 __gthread_objc_thread_get_priority (void)
00077 {
00078 return OBJC_THREAD_INTERACTIVE_PRIORITY;
00079 }
00080
00081
00082 void
00083 __gthread_objc_thread_yield (void)
00084 {
00085 return;
00086 }
00087
00088
00089 int
00090 __gthread_objc_thread_exit (void)
00091 {
00092
00093
00094
00095 return -1;
00096 }
00097
00098
00099 objc_thread_t
00100 __gthread_objc_thread_id (void)
00101 {
00102
00103 return (objc_thread_t) 1;
00104 }
00105
00106
00107 int
00108 __gthread_objc_thread_set_data (void *value)
00109 {
00110 thread_local_storage = value;
00111 return 0;
00112 }
00113
00114
00115 void *
00116 __gthread_objc_thread_get_data (void)
00117 {
00118 return thread_local_storage;
00119 }
00120
00121
00122
00123
00124 int
00125 __gthread_objc_mutex_allocate (objc_mutex_t mutex)
00126 {
00127 return 0;
00128 }
00129
00130
00131 int
00132 __gthread_objc_mutex_deallocate (objc_mutex_t mutex)
00133 {
00134 return 0;
00135 }
00136
00137
00138 int
00139 __gthread_objc_mutex_lock (objc_mutex_t mutex)
00140 {
00141
00142 return 0;
00143 }
00144
00145
00146 int
00147 __gthread_objc_mutex_trylock (objc_mutex_t mutex)
00148 {
00149
00150 return 0;
00151 }
00152
00153
00154 int
00155 __gthread_objc_mutex_unlock (objc_mutex_t mutex)
00156 {
00157 return 0;
00158 }
00159
00160
00161
00162
00163 int
00164 __gthread_objc_condition_allocate (objc_condition_t condition)
00165 {
00166 return 0;
00167 }
00168
00169
00170 int
00171 __gthread_objc_condition_deallocate (objc_condition_t condition)
00172 {
00173 return 0;
00174 }
00175
00176
00177 int
00178 __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
00179 {
00180 return 0;
00181 }
00182
00183
00184 int
00185 __gthread_objc_condition_broadcast (objc_condition_t condition)
00186 {
00187 return 0;
00188 }
00189
00190
00191 int
00192 __gthread_objc_condition_signal (objc_condition_t condition)
00193 {
00194 return 0;
00195 }
00196
00197 #else
00198
00199
00200
00201
00202 #define __GTHREADS 1
00203
00204 #include <vxWorks.h>
00205 #include <semLib.h>
00206
00207
00208 typedef int __gthread_key_t;
00209 typedef char __gthread_once_t;
00210 typedef SEM_ID __gthread_mutex_t;
00211
00212 #define __GTHREAD_MUTEX_INIT 0
00213 #define __GTHREAD_ONCE_INIT 0
00214
00215 #ifndef REG_SAVED_REG
00216 static inline int
00217 __gthread_once (__gthread_once_t *once, void (*func) (void))
00218 {
00219 (*func)();
00220 return 0;
00221 }
00222
00223 extern __gthread_key_t eh_context_key;
00224
00225
00226
00227
00228 static void
00229 __ehdtor (void *pTcb)
00230 {
00231 int tid = (int) pTcb;
00232 void *p = (void *) taskVarGet (tid, &eh_context_key);
00233 if (p != (void *) -1)
00234 {
00235 if (p)
00236 free (p);
00237 taskVarSet (tid, &eh_context_key, 0);
00238 }
00239 }
00240
00241
00242
00243 static inline int
00244 __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
00245 {
00246 *key = 0;
00247
00248
00249
00250
00251 taskVarInit ();
00252
00253
00254
00255
00256 taskDeleteHookAdd (__ehdtor);
00257
00258 return 0;
00259 }
00260
00261 #define __gthread_setspecific(key, ptr) \
00262 (key = (int) ptr, 0)
00263
00264 static inline int
00265 __gthread_key_dtor (__gthread_key_t key, void *ptr)
00266 {
00267
00268 if (ptr)
00269 return __gthread_setspecific (key, 0);
00270 else
00271 return 0;
00272 }
00273
00274 #define __gthread_key_delete(key) \
00275 taskVarDelete (taskIdSelf (), &key)
00276
00277 #define __gthread_getspecific(key) \
00278 ((key == 0) \
00279 ? ((taskVarAdd (taskIdSelf (), &key) != OK) \
00280 ? (__terminate (), (void *) 0) \
00281 : (void *) 0) \
00282 : (void *) key)
00283 #endif
00284
00285 static inline int
00286 __gthread_mutex_lock (__gthread_mutex_t *mutex)
00287 {
00288 if (*mutex == 0)
00289 *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
00290 return semTake (*mutex, WAIT_FOREVER);
00291 }
00292
00293 static inline int
00294 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
00295 {
00296 if (*mutex == 0)
00297 *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
00298 return semTake (*mutex, NO_WAIT);
00299 }
00300
00301 static inline int
00302 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
00303 {
00304
00305 return semGive (*mutex);
00306 }
00307
00308 #endif
00309
00310 #endif