* gfortran.h: Edit comments on GFC_STD_*.
[official-gcc.git] / gcc / gthr-single.h
blobc3a903deb65749d11a4be03e1fcec13d399eb368
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.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA. */
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. */
29 #ifndef GCC_GTHR_SINGLE_H
30 #define GCC_GTHR_SINGLE_H
32 /* Just provide compatibility for mutex handling. */
34 typedef int __gthread_mutex_t;
35 typedef int __gthread_recursive_mutex_t;
37 #define __GTHREAD_MUTEX_INIT 0
39 #ifdef __cplusplus
40 #define UNUSED(x)
41 #else
42 #define UNUSED(x) x __attribute__((unused))
43 #endif
45 #ifdef _LIBOBJC
47 /* Thread local storage for a single thread */
48 static void *thread_local_storage = NULL;
50 /* Backend initialization functions */
52 /* Initialize the threads subsystem. */
53 static inline int
54 __gthread_objc_init_thread_system (void)
56 /* No thread support available */
57 return -1;
60 /* Close the threads subsystem. */
61 static inline int
62 __gthread_objc_close_thread_system (void)
64 /* No thread support available */
65 return -1;
68 /* Backend thread functions */
70 /* Create a new thread of execution. */
71 static inline objc_thread_t
72 __gthread_objc_thread_detach (void (* func)(void *), void * UNUSED(arg))
74 /* No thread support available */
75 return NULL;
78 /* Set the current thread's priority. */
79 static inline int
80 __gthread_objc_thread_set_priority (int UNUSED(priority))
82 /* No thread support available */
83 return -1;
86 /* Return the current thread's priority. */
87 static inline int
88 __gthread_objc_thread_get_priority (void)
90 return OBJC_THREAD_INTERACTIVE_PRIORITY;
93 /* Yield our process time to another thread. */
94 static inline void
95 __gthread_objc_thread_yield (void)
97 return;
100 /* Terminate the current thread. */
101 static inline int
102 __gthread_objc_thread_exit (void)
104 /* No thread support available */
105 /* Should we really exit the program */
106 /* exit (&__objc_thread_exit_status); */
107 return -1;
110 /* Returns an integer value which uniquely describes a thread. */
111 static inline objc_thread_t
112 __gthread_objc_thread_id (void)
114 /* No thread support, use 1. */
115 return (objc_thread_t) 1;
118 /* Sets the thread's local storage pointer. */
119 static inline int
120 __gthread_objc_thread_set_data (void *value)
122 thread_local_storage = value;
123 return 0;
126 /* Returns the thread's local storage pointer. */
127 static inline void *
128 __gthread_objc_thread_get_data (void)
130 return thread_local_storage;
133 /* Backend mutex functions */
135 /* Allocate a mutex. */
136 static inline int
137 __gthread_objc_mutex_allocate (objc_mutex_t UNUSED(mutex))
139 return 0;
142 /* Deallocate a mutex. */
143 static inline int
144 __gthread_objc_mutex_deallocate (objc_mutex_t UNUSED(mutex))
146 return 0;
149 /* Grab a lock on a mutex. */
150 static inline int
151 __gthread_objc_mutex_lock (objc_mutex_t UNUSED(mutex))
153 /* There can only be one thread, so we always get the lock */
154 return 0;
157 /* Try to grab a lock on a mutex. */
158 static inline int
159 __gthread_objc_mutex_trylock (objc_mutex_t UNUSED(mutex))
161 /* There can only be one thread, so we always get the lock */
162 return 0;
165 /* Unlock the mutex */
166 static inline int
167 __gthread_objc_mutex_unlock (objc_mutex_t UNUSED(mutex))
169 return 0;
172 /* Backend condition mutex functions */
174 /* Allocate a condition. */
175 static inline int
176 __gthread_objc_condition_allocate (objc_condition_t UNUSED(condition))
178 return 0;
181 /* Deallocate a condition. */
182 static inline int
183 __gthread_objc_condition_deallocate (objc_condition_t UNUSED(condition))
185 return 0;
188 /* Wait on the condition */
189 static inline int
190 __gthread_objc_condition_wait (objc_condition_t UNUSED(condition),
191 objc_mutex_t UNUSED(mutex))
193 return 0;
196 /* Wake up all threads waiting on this condition. */
197 static inline int
198 __gthread_objc_condition_broadcast (objc_condition_t UNUSED(condition))
200 return 0;
203 /* Wake up one thread waiting on this condition. */
204 static inline int
205 __gthread_objc_condition_signal (objc_condition_t UNUSED(condition))
207 return 0;
210 #else /* _LIBOBJC */
212 static inline int
213 __gthread_active_p (void)
215 return 0;
218 static inline int
219 __gthread_mutex_lock (__gthread_mutex_t * UNUSED(mutex))
221 return 0;
224 static inline int
225 __gthread_mutex_trylock (__gthread_mutex_t * UNUSED(mutex))
227 return 0;
230 static inline int
231 __gthread_mutex_unlock (__gthread_mutex_t * UNUSED(mutex))
233 return 0;
236 static inline int
237 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
239 return __gthread_mutex_lock (mutex);
242 static inline int
243 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
245 return __gthread_mutex_trylock (mutex);
248 static inline int
249 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
251 return __gthread_mutex_unlock (mutex);
254 #endif /* _LIBOBJC */
256 #undef UNUSED
258 #endif /* ! GCC_GTHR_SINGLE_H */