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