fortran-modules.exp (list-module-names-1): Remove warning.
[official-gcc.git] / libgcc / gthr-single.h
blob4e3967977852e1aa6ab486e4a469924c4cc6244e
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.
6 This file is part of GCC.
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 3, or (at your option) any later
11 version.
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.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef GCC_GTHR_SINGLE_H
28 #define GCC_GTHR_SINGLE_H
30 /* Just provide compatibility for mutex handling. */
32 typedef int __gthread_key_t;
33 typedef int __gthread_once_t;
34 typedef int __gthread_mutex_t;
35 typedef int __gthread_recursive_mutex_t;
37 #define __GTHREAD_ONCE_INIT 0
38 #define __GTHREAD_MUTEX_INIT 0
39 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
40 #define __GTHREAD_RECURSIVE_MUTEX_INIT 0
42 #define UNUSED __attribute__((unused))
44 #ifdef _LIBOBJC
46 /* Thread local storage for a single thread */
47 static void *thread_local_storage = NULL;
49 /* Backend initialization functions */
51 /* Initialize the threads subsystem. */
52 static inline int
53 __gthread_objc_init_thread_system (void)
55 /* No thread support available */
56 return -1;
59 /* Close the threads subsystem. */
60 static inline int
61 __gthread_objc_close_thread_system (void)
63 /* No thread support available */
64 return -1;
67 /* Backend thread functions */
69 /* Create a new thread of execution. */
70 static inline objc_thread_t
71 __gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED)
73 /* No thread support available */
74 return NULL;
77 /* Set the current thread's priority. */
78 static inline int
79 __gthread_objc_thread_set_priority (int priority UNUSED)
81 /* No thread support available */
82 return -1;
85 /* Return the current thread's priority. */
86 static inline int
87 __gthread_objc_thread_get_priority (void)
89 return OBJC_THREAD_INTERACTIVE_PRIORITY;
92 /* Yield our process time to another thread. */
93 static inline void
94 __gthread_objc_thread_yield (void)
96 return;
99 /* Terminate the current thread. */
100 static inline int
101 __gthread_objc_thread_exit (void)
103 /* No thread support available */
104 /* Should we really exit the program */
105 /* exit (&__objc_thread_exit_status); */
106 return -1;
109 /* Returns an integer value which uniquely describes a thread. */
110 static inline objc_thread_t
111 __gthread_objc_thread_id (void)
113 /* No thread support, use 1. */
114 return (objc_thread_t) 1;
117 /* Sets the thread's local storage pointer. */
118 static inline int
119 __gthread_objc_thread_set_data (void *value)
121 thread_local_storage = value;
122 return 0;
125 /* Returns the thread's local storage pointer. */
126 static inline void *
127 __gthread_objc_thread_get_data (void)
129 return thread_local_storage;
132 /* Backend mutex functions */
134 /* Allocate a mutex. */
135 static inline int
136 __gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED)
138 return 0;
141 /* Deallocate a mutex. */
142 static inline int
143 __gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED)
145 return 0;
148 /* Grab a lock on a mutex. */
149 static inline int
150 __gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED)
152 /* There can only be one thread, so we always get the lock */
153 return 0;
156 /* Try to grab a lock on a mutex. */
157 static inline int
158 __gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED)
160 /* There can only be one thread, so we always get the lock */
161 return 0;
164 /* Unlock the mutex */
165 static inline int
166 __gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED)
168 return 0;
171 /* Backend condition mutex functions */
173 /* Allocate a condition. */
174 static inline int
175 __gthread_objc_condition_allocate (objc_condition_t condition UNUSED)
177 return 0;
180 /* Deallocate a condition. */
181 static inline int
182 __gthread_objc_condition_deallocate (objc_condition_t condition UNUSED)
184 return 0;
187 /* Wait on the condition */
188 static inline int
189 __gthread_objc_condition_wait (objc_condition_t condition UNUSED,
190 objc_mutex_t mutex UNUSED)
192 return 0;
195 /* Wake up all threads waiting on this condition. */
196 static inline int
197 __gthread_objc_condition_broadcast (objc_condition_t condition UNUSED)
199 return 0;
202 /* Wake up one thread waiting on this condition. */
203 static inline int
204 __gthread_objc_condition_signal (objc_condition_t condition UNUSED)
206 return 0;
209 #else /* _LIBOBJC */
211 static inline int
212 __gthread_active_p (void)
214 return 0;
217 static inline int
218 __gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
220 return 0;
223 static inline int UNUSED
224 __gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
226 return 0;
229 static int UNUSED
230 __gthread_key_delete (__gthread_key_t __key UNUSED)
232 return 0;
235 static inline void *
236 __gthread_getspecific (__gthread_key_t __key UNUSED)
238 return 0;
241 static inline int
242 __gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
244 return 0;
247 static inline int
248 __gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
250 return 0;
253 static inline int
254 __gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
256 return 0;
259 static inline int
260 __gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
262 return 0;
265 static inline int
266 __gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
268 return 0;
271 static inline int
272 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
274 return __gthread_mutex_lock (__mutex);
277 static inline int
278 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
280 return __gthread_mutex_trylock (__mutex);
283 static inline int
284 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
286 return __gthread_mutex_unlock (__mutex);
289 #endif /* _LIBOBJC */
291 #undef UNUSED
293 #endif /* ! GCC_GTHR_SINGLE_H */