# gthr-single.h

    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
    00036 #define __GTHREAD_MUTEX_INIT 0
    00037
    00038 #ifdef __cplusplus
    00039 #define _GLIBCXX_UNUSED(x)
    00040 #else
    00041 #define _GLIBCXX_UNUSED(x) x __attribute__((unused))
    00042 #endif
    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 * _GLIBCXX_UNUSED(arg))
    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 _GLIBCXX_UNUSED(priority))
    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 _GLIBCXX_UNUSED(mutex))
    00137 {
    00138   return 0;
    00139 }
    00140
    00141 /* Deallocate a mutex.  */
    00142 static inline int
    00143 __gthread_objc_mutex_deallocate (objc_mutex_t _GLIBCXX_UNUSED(mutex))
    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 _GLIBCXX_UNUSED(mutex))
    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 _GLIBCXX_UNUSED(mutex))
    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 _GLIBCXX_UNUSED(mutex))
    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 _GLIBCXX_UNUSED(condition))
    00176 {
    00177   return 0;
    00178 }
    00179
    00180 /* Deallocate a condition.  */
    00181 static inline int
    00182 __gthread_objc_condition_deallocate (objc_condition_t _GLIBCXX_UNUSED(condition))
    00183 {
    00184   return 0;
    00185 }
    00186
    00187 /* Wait on the condition */
    00188 static inline int
    00189 __gthread_objc_condition_wait (objc_condition_t _GLIBCXX_UNUSED(condition),
    00190                    objc_mutex_t _GLIBCXX_UNUSED(mutex))
    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 _GLIBCXX_UNUSED(condition))
    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 _GLIBCXX_UNUSED(condition))
    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_mutex_lock (__gthread_mutex_t * _GLIBCXX_UNUSED(mutex))
    00219 {
    00220   return 0;
    00221 }
    00222
    00223 static inline int
    00224 __gthread_mutex_trylock (__gthread_mutex_t * _GLIBCXX_UNUSED(mutex))
    00225 {
    00226   return 0;
    00227 }
    00228
    00229 static inline int
    00230 __gthread_mutex_unlock (__gthread_mutex_t * _GLIBCXX_UNUSED(mutex))
    00231 {
    00232   return 0;
    00233 }
    00234
    00235 #endif /* _LIBOBJC */
    00236
    00237 #undef _GLIBCXX_UNUSED
    00238
    00239 #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */