OSDN Git Service

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