gthr-single.h

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

Generated on Tue Jan 30 17:31:49 2007 for GNU C++ STL by doxygen 1.3.6