]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gthr-single.h
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / gcc / gthr-single.h
CommitLineData
15794a95 1/* Threads compatibility routines for libgcc2 and libobjc. */
f24af81b 2/* Compile this one with gcc. */
09e361bb
JJ
3/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009
4 Free Software Foundation, Inc.
f24af81b 5
1322177d 6This file is part of GCC.
f24af81b 7
1322177d
LB
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
748086b7 10Software Foundation; either version 3, or (at your option) any later
1322177d 11version.
f24af81b 12
1322177d
LB
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.
f24af81b 17
748086b7
JJ
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/>. */
f24af81b 26
88657302
RH
27#ifndef GCC_GTHR_SINGLE_H
28#define GCC_GTHR_SINGLE_H
f24af81b 29
71287280 30/* Just provide compatibility for mutex handling. */
f24af81b 31
23688481
BK
32typedef int __gthread_key_t;
33typedef int __gthread_once_t;
f24af81b 34typedef int __gthread_mutex_t;
40aac948 35typedef int __gthread_recursive_mutex_t;
f24af81b 36
23688481 37#define __GTHREAD_ONCE_INIT 0
f24af81b 38#define __GTHREAD_MUTEX_INIT 0
23688481 39#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
f24af81b 40
23688481 41#define UNUSED __attribute__((unused))
e64a6541 42
15794a95
L
43#ifdef _LIBOBJC
44
45/* Thread local storage for a single thread */
46static void *thread_local_storage = NULL;
47
48/* Backend initialization functions */
49
71287280 50/* Initialize the threads subsystem. */
15794a95 51static inline int
24985beb 52__gthread_objc_init_thread_system (void)
15794a95
L
53{
54 /* No thread support available */
55 return -1;
56}
57
71287280 58/* Close the threads subsystem. */
15794a95 59static inline int
24985beb 60__gthread_objc_close_thread_system (void)
15794a95
L
61{
62 /* No thread support available */
63 return -1;
64}
65
66/* Backend thread functions */
67
71287280 68/* Create a new thread of execution. */
15794a95 69static inline objc_thread_t
23688481 70__gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED)
15794a95
L
71{
72 /* No thread support available */
73 return NULL;
74}
75
71287280 76/* Set the current thread's priority. */
15794a95 77static inline int
23688481 78__gthread_objc_thread_set_priority (int priority UNUSED)
15794a95
L
79{
80 /* No thread support available */
81 return -1;
82}
83
71287280 84/* Return the current thread's priority. */
15794a95 85static inline int
24985beb 86__gthread_objc_thread_get_priority (void)
15794a95
L
87{
88 return OBJC_THREAD_INTERACTIVE_PRIORITY;
89}
90
71287280 91/* Yield our process time to another thread. */
15794a95 92static inline void
24985beb 93__gthread_objc_thread_yield (void)
15794a95
L
94{
95 return;
96}
97
71287280 98/* Terminate the current thread. */
15794a95 99static inline int
24985beb 100__gthread_objc_thread_exit (void)
15794a95
L
101{
102 /* No thread support available */
103 /* Should we really exit the program */
24985beb 104 /* exit (&__objc_thread_exit_status); */
15794a95
L
105 return -1;
106}
107
71287280 108/* Returns an integer value which uniquely describes a thread. */
15794a95 109static inline objc_thread_t
24985beb 110__gthread_objc_thread_id (void)
15794a95 111{
71287280 112 /* No thread support, use 1. */
24985beb 113 return (objc_thread_t) 1;
15794a95
L
114}
115
71287280 116/* Sets the thread's local storage pointer. */
15794a95 117static inline int
24985beb 118__gthread_objc_thread_set_data (void *value)
15794a95
L
119{
120 thread_local_storage = value;
121 return 0;
122}
123
71287280 124/* Returns the thread's local storage pointer. */
15794a95 125static inline void *
24985beb 126__gthread_objc_thread_get_data (void)
15794a95
L
127{
128 return thread_local_storage;
129}
130
131/* Backend mutex functions */
132
71287280 133/* Allocate a mutex. */
15794a95 134static inline int
23688481 135__gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED)
15794a95
L
136{
137 return 0;
138}
139
71287280 140/* Deallocate a mutex. */
15794a95 141static inline int
23688481 142__gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED)
15794a95
L
143{
144 return 0;
145}
146
71287280 147/* Grab a lock on a mutex. */
15794a95 148static inline int
23688481 149__gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED)
15794a95
L
150{
151 /* There can only be one thread, so we always get the lock */
152 return 0;
153}
154
71287280 155/* Try to grab a lock on a mutex. */
15794a95 156static inline int
23688481 157__gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED)
15794a95
L
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
23688481 165__gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED)
15794a95
L
166{
167 return 0;
168}
169
170/* Backend condition mutex functions */
171
71287280 172/* Allocate a condition. */
15794a95 173static inline int
23688481 174__gthread_objc_condition_allocate (objc_condition_t condition UNUSED)
15794a95
L
175{
176 return 0;
177}
178
71287280 179/* Deallocate a condition. */
15794a95 180static inline int
23688481 181__gthread_objc_condition_deallocate (objc_condition_t condition UNUSED)
15794a95
L
182{
183 return 0;
184}
185
186/* Wait on the condition */
187static inline int
23688481
BK
188__gthread_objc_condition_wait (objc_condition_t condition UNUSED,
189 objc_mutex_t mutex UNUSED)
15794a95
L
190{
191 return 0;
192}
193
71287280 194/* Wake up all threads waiting on this condition. */
15794a95 195static inline int
23688481 196__gthread_objc_condition_broadcast (objc_condition_t condition UNUSED)
15794a95
L
197{
198 return 0;
199}
200
71287280 201/* Wake up one thread waiting on this condition. */
15794a95 202static inline int
23688481 203__gthread_objc_condition_signal (objc_condition_t condition UNUSED)
15794a95
L
204{
205 return 0;
206}
207
208#else /* _LIBOBJC */
209
f24af81b 210static inline int
3e7d8ef1 211__gthread_active_p (void)
f24af81b
TT
212{
213 return 0;
214}
215
23688481 216static inline int
09e361bb 217__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
23688481
BK
218{
219 return 0;
220}
221
222static inline int UNUSED
09e361bb 223__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
23688481
BK
224{
225 return 0;
226}
227
228static int UNUSED
09e361bb 229__gthread_key_delete (__gthread_key_t __key UNUSED)
23688481
BK
230{
231 return 0;
232}
233
234static inline void *
09e361bb 235__gthread_getspecific (__gthread_key_t __key UNUSED)
23688481
BK
236{
237 return 0;
238}
239
240static inline int
09e361bb 241__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
23688481
BK
242{
243 return 0;
244}
245
4dabf736 246static inline int
09e361bb 247__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
4dabf736
JB
248{
249 return 0;
250}
251
f24af81b 252static inline int
09e361bb 253__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
f24af81b
TT
254{
255 return 0;
256}
257
258static inline int
09e361bb 259__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
f24af81b
TT
260{
261 return 0;
262}
263
264static inline int
09e361bb 265__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
f24af81b
TT
266{
267 return 0;
268}
269
40aac948 270static inline int
09e361bb 271__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
40aac948 272{
09e361bb 273 return __gthread_mutex_lock (__mutex);
40aac948
JM
274}
275
276static inline int
09e361bb 277__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
40aac948 278{
09e361bb 279 return __gthread_mutex_trylock (__mutex);
40aac948
JM
280}
281
282static inline int
09e361bb 283__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
40aac948 284{
09e361bb 285 return __gthread_mutex_unlock (__mutex);
40aac948
JM
286}
287
15794a95
L
288#endif /* _LIBOBJC */
289
e64a6541
RH
290#undef UNUSED
291
88657302 292#endif /* ! GCC_GTHR_SINGLE_H */