]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/gthr-single.h
updat_bb_profile_for_threading TLC
[thirdparty/gcc.git] / libgcc / gthr-single.h
CommitLineData
15794a95 1/* Threads compatibility routines for libgcc2 and libobjc. */
f24af81b 2/* Compile this one with gcc. */
83ffe9cd 3/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
f24af81b 4
1322177d 5This file is part of GCC.
f24af81b 6
1322177d
LB
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
748086b7 9Software Foundation; either version 3, or (at your option) any later
1322177d 10version.
f24af81b 11
1322177d
LB
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
f24af81b 16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see 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
31typedef int __gthread_key_t;
32typedef int __gthread_once_t;
f24af81b 33typedef int __gthread_mutex_t;
40aac948 34typedef 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 */
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
b8698a0f 216static 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 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}
b8698a0f 233
23688481 234static inline void *
09e361bb 235__gthread_getspecific (__gthread_key_t __key UNUSED)
23688481
BK
236{
237 return 0;
238}
239
b8698a0f 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
1504e3e1
JW
288static 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 */