source: Daodan/MSYS2/mingw32/include/c++/11.2.0/i686-w64-mingw32/bits/gthr-single.h@ 1182

Last change on this file since 1182 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

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