]>
Commit | Line | Data |
---|---|---|
15794a95 | 1 | /* Threads compatibility routines for libgcc2 and libobjc. */ |
f24af81b | 2 | /* Compile this one with gcc. */ |
7adcbafe | 3 | /* Copyright (C) 1997-2022 Free Software Foundation, Inc. |
f24af81b | 4 | |
1322177d | 5 | This file is part of GCC. |
f24af81b | 6 | |
1322177d LB |
7 | GCC is free software; you can redistribute it and/or modify it under |
8 | the terms of the GNU General Public License as published by the Free | |
748086b7 | 9 | Software Foundation; either version 3, or (at your option) any later |
1322177d | 10 | version. |
f24af81b | 11 | |
1322177d LB |
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
f24af81b | 16 | |
748086b7 JJ |
17 | Under Section 7 of GPL version 3, you are granted additional |
18 | permissions described in the GCC Runtime Library Exception, version | |
19 | 3.1, as published by the Free Software Foundation. | |
20 | ||
21 | You should have received a copy of the GNU General Public License and | |
22 | a copy of the GCC Runtime Library Exception along with this program; | |
23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | <http://www.gnu.org/licenses/>. */ | |
f24af81b | 25 | |
88657302 RH |
26 | #ifndef GCC_GTHR_SINGLE_H |
27 | #define GCC_GTHR_SINGLE_H | |
f24af81b | 28 | |
71287280 | 29 | /* Just provide compatibility for mutex handling. */ |
f24af81b | 30 | |
23688481 BK |
31 | typedef int __gthread_key_t; |
32 | typedef int __gthread_once_t; | |
f24af81b | 33 | typedef int __gthread_mutex_t; |
40aac948 | 34 | typedef int __gthread_recursive_mutex_t; |
f24af81b | 35 | |
23688481 | 36 | #define __GTHREAD_ONCE_INIT 0 |
f24af81b | 37 | #define __GTHREAD_MUTEX_INIT 0 |
d26b2237 | 38 | #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0) |
23688481 | 39 | #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 |
f24af81b | 40 | |
7727f8f2 | 41 | #define UNUSED __attribute__((__unused__)) |
e64a6541 | 42 | |
15794a95 L |
43 | #ifdef _LIBOBJC |
44 | ||
45 | /* Thread local storage for a single thread */ | |
46 | static void *thread_local_storage = NULL; | |
47 | ||
48 | /* Backend initialization functions */ | |
49 | ||
71287280 | 50 | /* Initialize the threads subsystem. */ |
15794a95 | 51 | static 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 | 59 | static 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 | 69 | static 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 | 77 | static 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 | 85 | static 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 | 92 | static inline void |
24985beb | 93 | __gthread_objc_thread_yield (void) |
15794a95 L |
94 | { |
95 | return; | |
96 | } | |
97 | ||
71287280 | 98 | /* Terminate the current thread. */ |
15794a95 | 99 | static 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 | 109 | static 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 | 117 | static 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 | 125 | static 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 | 134 | static 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 | 141 | static 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 | 148 | static 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 | 156 | static 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 */ | |
164 | static 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 | 173 | static 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 | 180 | static 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 */ | |
187 | static 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 | 195 | static 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 | 202 | static 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 | 210 | static inline int |
3e7d8ef1 | 211 | __gthread_active_p (void) |
f24af81b TT |
212 | { |
213 | return 0; | |
214 | } | |
215 | ||
b8698a0f | 216 | static inline int |
09e361bb | 217 | __gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED) |
23688481 BK |
218 | { |
219 | return 0; | |
220 | } | |
b8698a0f | 221 | |
23688481 | 222 | static 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 | ||
228 | static int UNUSED | |
09e361bb | 229 | __gthread_key_delete (__gthread_key_t __key UNUSED) |
23688481 BK |
230 | { |
231 | return 0; | |
232 | } | |
b8698a0f | 233 | |
23688481 | 234 | static inline void * |
09e361bb | 235 | __gthread_getspecific (__gthread_key_t __key UNUSED) |
23688481 BK |
236 | { |
237 | return 0; | |
238 | } | |
239 | ||
b8698a0f | 240 | static inline int |
09e361bb | 241 | __gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED) |
23688481 BK |
242 | { |
243 | return 0; | |
244 | } | |
245 | ||
4dabf736 | 246 | static inline int |
09e361bb | 247 | __gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED) |
4dabf736 JB |
248 | { |
249 | return 0; | |
250 | } | |
251 | ||
f24af81b | 252 | static inline int |
09e361bb | 253 | __gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED) |
f24af81b TT |
254 | { |
255 | return 0; | |
256 | } | |
257 | ||
258 | static inline int | |
09e361bb | 259 | __gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED) |
f24af81b TT |
260 | { |
261 | return 0; | |
262 | } | |
263 | ||
264 | static inline int | |
09e361bb | 265 | __gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED) |
f24af81b TT |
266 | { |
267 | return 0; | |
268 | } | |
269 | ||
40aac948 | 270 | static 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 | ||
276 | static 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 | ||
282 | static 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 | ||
1504e3e1 JW |
288 | static inline int |
289 | __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) | |
290 | { | |
291 | return __gthread_mutex_destroy (__mutex); | |
292 | } | |
293 | ||
15794a95 L |
294 | #endif /* _LIBOBJC */ |
295 | ||
e64a6541 RH |
296 | #undef UNUSED |
297 | ||
88657302 | 298 | #endif /* ! GCC_GTHR_SINGLE_H */ |