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