|
libstdc++
|
00001 /* Threads compatibility routines for libgcc2 and libobjc. */ 00002 /* Compile this one with gcc. */ 00003 /* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009 00004 Free Software Foundation, Inc. 00005 00006 This file is part of GCC. 00007 00008 GCC is free software; you can redistribute it and/or modify it under 00009 the terms of the GNU General Public License as published by the Free 00010 Software Foundation; either version 3, or (at your option) any later 00011 version. 00012 00013 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 Under Section 7 of GPL version 3, you are granted additional 00019 permissions described in the GCC Runtime Library Exception, version 00020 3.1, as published by the Free Software Foundation. 00021 00022 You should have received a copy of the GNU General Public License and 00023 a copy of the GCC Runtime Library Exception along with this program; 00024 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00025 <http://www.gnu.org/licenses/>. */ 00026 00027 #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H 00028 #define _GLIBCXX_GCC_GTHR_SINGLE_H 00029 00030 /* Just provide compatibility for mutex handling. */ 00031 00032 typedef int __gthread_key_t; 00033 typedef int __gthread_once_t; 00034 typedef int __gthread_mutex_t; 00035 typedef int __gthread_recursive_mutex_t; 00036 00037 #define __GTHREAD_ONCE_INIT 0 00038 #define __GTHREAD_MUTEX_INIT 0 00039 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) 00040 #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 00041 00042 #define _GLIBCXX_UNUSED __attribute__((unused)) 00043 00044 #ifdef _LIBOBJC 00045 00046 /* Thread local storage for a single thread */ 00047 static void *thread_local_storage = NULL; 00048 00049 /* Backend initialization functions */ 00050 00051 /* Initialize the threads subsystem. */ 00052 static inline int 00053 __gthread_objc_init_thread_system (void) 00054 { 00055 /* No thread support available */ 00056 return -1; 00057 } 00058 00059 /* Close the threads subsystem. */ 00060 static inline int 00061 __gthread_objc_close_thread_system (void) 00062 { 00063 /* No thread support available */ 00064 return -1; 00065 } 00066 00067 /* Backend thread functions */ 00068 00069 /* Create a new thread of execution. */ 00070 static inline objc_thread_t 00071 __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) 00072 { 00073 /* No thread support available */ 00074 return NULL; 00075 } 00076 00077 /* Set the current thread's priority. */ 00078 static inline int 00079 __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) 00080 { 00081 /* No thread support available */ 00082 return -1; 00083 } 00084 00085 /* Return the current thread's priority. */ 00086 static inline int 00087 __gthread_objc_thread_get_priority (void) 00088 { 00089 return OBJC_THREAD_INTERACTIVE_PRIORITY; 00090 } 00091 00092 /* Yield our process time to another thread. */ 00093 static inline void 00094 __gthread_objc_thread_yield (void) 00095 { 00096 return; 00097 } 00098 00099 /* Terminate the current thread. */ 00100 static inline int 00101 __gthread_objc_thread_exit (void) 00102 { 00103 /* No thread support available */ 00104 /* Should we really exit the program */ 00105 /* exit (&__objc_thread_exit_status); */ 00106 return -1; 00107 } 00108 00109 /* Returns an integer value which uniquely describes a thread. */ 00110 static inline objc_thread_t 00111 __gthread_objc_thread_id (void) 00112 { 00113 /* No thread support, use 1. */ 00114 return (objc_thread_t) 1; 00115 } 00116 00117 /* Sets the thread's local storage pointer. */ 00118 static inline int 00119 __gthread_objc_thread_set_data (void *value) 00120 { 00121 thread_local_storage = value; 00122 return 0; 00123 } 00124 00125 /* Returns the thread's local storage pointer. */ 00126 static inline void * 00127 __gthread_objc_thread_get_data (void) 00128 { 00129 return thread_local_storage; 00130 } 00131 00132 /* Backend mutex functions */ 00133 00134 /* Allocate a mutex. */ 00135 static inline int 00136 __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) 00137 { 00138 return 0; 00139 } 00140 00141 /* Deallocate a mutex. */ 00142 static inline int 00143 __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) 00144 { 00145 return 0; 00146 } 00147 00148 /* Grab a lock on a mutex. */ 00149 static inline int 00150 __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) 00151 { 00152 /* There can only be one thread, so we always get the lock */ 00153 return 0; 00154 } 00155 00156 /* Try to grab a lock on a mutex. */ 00157 static inline int 00158 __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) 00159 { 00160 /* There can only be one thread, so we always get the lock */ 00161 return 0; 00162 } 00163 00164 /* Unlock the mutex */ 00165 static inline int 00166 __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) 00167 { 00168 return 0; 00169 } 00170 00171 /* Backend condition mutex functions */ 00172 00173 /* Allocate a condition. */ 00174 static inline int 00175 __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) 00176 { 00177 return 0; 00178 } 00179 00180 /* Deallocate a condition. */ 00181 static inline int 00182 __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) 00183 { 00184 return 0; 00185 } 00186 00187 /* Wait on the condition */ 00188 static inline int 00189 __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, 00190 objc_mutex_t mutex _GLIBCXX_UNUSED) 00191 { 00192 return 0; 00193 } 00194 00195 /* Wake up all threads waiting on this condition. */ 00196 static inline int 00197 __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) 00198 { 00199 return 0; 00200 } 00201 00202 /* Wake up one thread waiting on this condition. */ 00203 static inline int 00204 __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) 00205 { 00206 return 0; 00207 } 00208 00209 #else /* _LIBOBJC */ 00210 00211 static inline int 00212 __gthread_active_p (void) 00213 { 00214 return 0; 00215 } 00216 00217 static inline int 00218 __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) 00219 { 00220 return 0; 00221 } 00222 00223 static inline int _GLIBCXX_UNUSED 00224 __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) 00225 { 00226 return 0; 00227 } 00228 00229 static int _GLIBCXX_UNUSED 00230 __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) 00231 { 00232 return 0; 00233 } 00234 00235 static inline void * 00236 __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) 00237 { 00238 return 0; 00239 } 00240 00241 static inline int 00242 __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) 00243 { 00244 return 0; 00245 } 00246 00247 static inline int 00248 __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) 00249 { 00250 return 0; 00251 } 00252 00253 static inline int 00254 __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) 00255 { 00256 return 0; 00257 } 00258 00259 static inline int 00260 __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) 00261 { 00262 return 0; 00263 } 00264 00265 static inline int 00266 __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) 00267 { 00268 return 0; 00269 } 00270 00271 static inline int 00272 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) 00273 { 00274 return __gthread_mutex_lock (__mutex); 00275 } 00276 00277 static inline int 00278 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) 00279 { 00280 return __gthread_mutex_trylock (__mutex); 00281 } 00282 00283 static inline int 00284 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) 00285 { 00286 return __gthread_mutex_unlock (__mutex); 00287 } 00288 00289 #endif /* _LIBOBJC */ 00290 00291 #undef _GLIBCXX_UNUSED 00292 00293 #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */