1/* Threads compatibility routines for libgcc2 and libobjc. */ 2/* Compile this one with gcc. */ 3/* Copyright (C) 1997, 1999, 2000, 2004 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free 9Software Foundation; either version 2, or (at your option) any later 10version. 11 12GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or 14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to the Free 19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2002110-1301, USA. */ 21 22/* As a special exception, if you link this library with other files, 23 some of which are compiled with GCC, to produce an executable, 24 this library does not by itself cause the resulting executable 25 to be covered by the GNU General Public License. 26 This exception does not however invalidate any other reasons why 27 the executable file might be covered by the GNU General Public License. */ 28 29#ifndef GCC_GTHR_SINGLE_H 30#define GCC_GTHR_SINGLE_H 31 32/* Just provide compatibility for mutex handling. */ 33 34typedef int __gthread_mutex_t; 35typedef int __gthread_recursive_mutex_t; 36 37#define __GTHREAD_MUTEX_INIT 0 38 39#ifdef __cplusplus 40#define UNUSED(x) 41#else 42#define UNUSED(x) x __attribute__((unused)) 43#endif 44 45#ifdef _LIBOBJC 46 47/* Thread local storage for a single thread */ 48static void *thread_local_storage = NULL; 49 50/* Backend initialization functions */ 51 52/* Initialize the threads subsystem. */ 53static inline int 54__gthread_objc_init_thread_system (void) 55{ 56 /* No thread support available */ 57 return -1; 58} 59 60/* Close the threads subsystem. */ 61static inline int 62__gthread_objc_close_thread_system (void) 63{ 64 /* No thread support available */ 65 return -1; 66} 67 68/* Backend thread functions */ 69 70/* Create a new thread of execution. */ 71static inline objc_thread_t 72__gthread_objc_thread_detach (void (* func)(void *), void * UNUSED(arg)) 73{ 74 /* No thread support available */ 75 return NULL; 76} 77 78/* Set the current thread's priority. */ 79static inline int 80__gthread_objc_thread_set_priority (int UNUSED(priority)) 81{ 82 /* No thread support available */ 83 return -1; 84} 85 86/* Return the current thread's priority. */ 87static inline int 88__gthread_objc_thread_get_priority (void) 89{ 90 return OBJC_THREAD_INTERACTIVE_PRIORITY; 91} 92 93/* Yield our process time to another thread. */ 94static inline void 95__gthread_objc_thread_yield (void) 96{ 97 return; 98} 99 100/* Terminate the current thread. */ 101static inline int 102__gthread_objc_thread_exit (void) 103{ 104 /* No thread support available */ 105 /* Should we really exit the program */ 106 /* exit (&__objc_thread_exit_status); */ 107 return -1; 108} 109 110/* Returns an integer value which uniquely describes a thread. */ 111static inline objc_thread_t 112__gthread_objc_thread_id (void) 113{ 114 /* No thread support, use 1. */ 115 return (objc_thread_t) 1; 116} 117 118/* Sets the thread's local storage pointer. */ 119static inline int 120__gthread_objc_thread_set_data (void *value) 121{ 122 thread_local_storage = value; 123 return 0; 124} 125 126/* Returns the thread's local storage pointer. */ 127static inline void * 128__gthread_objc_thread_get_data (void) 129{ 130 return thread_local_storage; 131} 132 133/* Backend mutex functions */ 134 135/* Allocate a mutex. */ 136static inline int 137__gthread_objc_mutex_allocate (objc_mutex_t UNUSED(mutex)) 138{ 139 return 0; 140} 141 142/* Deallocate a mutex. */ 143static inline int 144__gthread_objc_mutex_deallocate (objc_mutex_t UNUSED(mutex)) 145{ 146 return 0; 147} 148 149/* Grab a lock on a mutex. */ 150static inline int 151__gthread_objc_mutex_lock (objc_mutex_t UNUSED(mutex)) 152{ 153 /* There can only be one thread, so we always get the lock */ 154 return 0; 155} 156 157/* Try to grab a lock on a mutex. */ 158static inline int 159__gthread_objc_mutex_trylock (objc_mutex_t UNUSED(mutex)) 160{ 161 /* There can only be one thread, so we always get the lock */ 162 return 0; 163} 164 165/* Unlock the mutex */ 166static inline int 167__gthread_objc_mutex_unlock (objc_mutex_t UNUSED(mutex)) 168{ 169 return 0; 170} 171 172/* Backend condition mutex functions */ 173 174/* Allocate a condition. */ 175static inline int 176__gthread_objc_condition_allocate (objc_condition_t UNUSED(condition)) 177{ 178 return 0; 179} 180 181/* Deallocate a condition. */ 182static inline int 183__gthread_objc_condition_deallocate (objc_condition_t UNUSED(condition)) 184{ 185 return 0; 186} 187 188/* Wait on the condition */ 189static inline int 190__gthread_objc_condition_wait (objc_condition_t UNUSED(condition), 191 objc_mutex_t UNUSED(mutex)) 192{ 193 return 0; 194} 195 196/* Wake up all threads waiting on this condition. */ 197static inline int 198__gthread_objc_condition_broadcast (objc_condition_t UNUSED(condition)) 199{ 200 return 0; 201} 202 203/* Wake up one thread waiting on this condition. */ 204static inline int 205__gthread_objc_condition_signal (objc_condition_t UNUSED(condition)) 206{ 207 return 0; 208} 209 210#else /* _LIBOBJC */ 211 212static inline int 213__gthread_active_p (void) 214{ 215 return 0; 216} 217 218static inline int 219__gthread_mutex_lock (__gthread_mutex_t * UNUSED(mutex)) 220{ 221 return 0; 222} 223 224static inline int 225__gthread_mutex_trylock (__gthread_mutex_t * UNUSED(mutex)) 226{ 227 return 0; 228} 229 230static inline int 231__gthread_mutex_unlock (__gthread_mutex_t * UNUSED(mutex)) 232{ 233 return 0; 234} 235 236static inline int 237__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex) 238{ 239 return __gthread_mutex_lock (mutex); 240} 241 242static inline int 243__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex) 244{ 245 return __gthread_mutex_trylock (mutex); 246} 247 248static inline int 249__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex) 250{ 251 return __gthread_mutex_unlock (mutex); 252} 253 254#endif /* _LIBOBJC */ 255 256#undef UNUSED 257 258#endif /* ! GCC_GTHR_SINGLE_H */ 259