re PR other/63387 (Optimize pairs of isnan() calls into a single isunordered())
[official-gcc.git] / libgcc / gthr-single.h
blob00b3fd661bb74d7648c50f6849ad82dca3e77cf1
1 /* Threads compatibility routines for libgcc2 and libobjc. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997-2015 Free Software Foundation, Inc.
5 This file is part of GCC.
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
9 Software Foundation; either version 3, or (at your option) any later
10 version.
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.
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.
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/>. */
26 #ifndef GCC_GTHR_SINGLE_H
27 #define GCC_GTHR_SINGLE_H
29 /* Just provide compatibility for mutex handling. */
31 typedef int __gthread_key_t;
32 typedef int __gthread_once_t;
33 typedef int __gthread_mutex_t;
34 typedef int __gthread_recursive_mutex_t;
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
41 #define UNUSED __attribute__((__unused__))
43 #ifdef _LIBOBJC
45 /* Thread local storage for a single thread */
46 static void *thread_local_storage = NULL;
48 /* Backend initialization functions */
50 /* Initialize the threads subsystem. */
51 static inline int
52 __gthread_objc_init_thread_system (void)
54 /* No thread support available */
55 return -1;
58 /* Close the threads subsystem. */
59 static inline int
60 __gthread_objc_close_thread_system (void)
62 /* No thread support available */
63 return -1;
66 /* Backend thread functions */
68 /* Create a new thread of execution. */
69 static inline objc_thread_t
70 __gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED)
72 /* No thread support available */
73 return NULL;
76 /* Set the current thread's priority. */
77 static inline int
78 __gthread_objc_thread_set_priority (int priority UNUSED)
80 /* No thread support available */
81 return -1;
84 /* Return the current thread's priority. */
85 static inline int
86 __gthread_objc_thread_get_priority (void)
88 return OBJC_THREAD_INTERACTIVE_PRIORITY;
91 /* Yield our process time to another thread. */
92 static inline void
93 __gthread_objc_thread_yield (void)
95 return;
98 /* Terminate the current thread. */
99 static inline int
100 __gthread_objc_thread_exit (void)
102 /* No thread support available */
103 /* Should we really exit the program */
104 /* exit (&__objc_thread_exit_status); */
105 return -1;
108 /* Returns an integer value which uniquely describes a thread. */
109 static inline objc_thread_t
110 __gthread_objc_thread_id (void)
112 /* No thread support, use 1. */
113 return (objc_thread_t) 1;
116 /* Sets the thread's local storage pointer. */
117 static inline int
118 __gthread_objc_thread_set_data (void *value)
120 thread_local_storage = value;
121 return 0;
124 /* Returns the thread's local storage pointer. */
125 static inline void *
126 __gthread_objc_thread_get_data (void)
128 return thread_local_storage;
131 /* Backend mutex functions */
133 /* Allocate a mutex. */
134 static inline int
135 __gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED)
137 return 0;
140 /* Deallocate a mutex. */
141 static inline int
142 __gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED)
144 return 0;
147 /* Grab a lock on a mutex. */
148 static inline int
149 __gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED)
151 /* There can only be one thread, so we always get the lock */
152 return 0;
155 /* Try to grab a lock on a mutex. */
156 static inline int
157 __gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED)
159 /* There can only be one thread, so we always get the lock */
160 return 0;
163 /* Unlock the mutex */
164 static inline int
165 __gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED)
167 return 0;
170 /* Backend condition mutex functions */
172 /* Allocate a condition. */
173 static inline int
174 __gthread_objc_condition_allocate (objc_condition_t condition UNUSED)
176 return 0;
179 /* Deallocate a condition. */
180 static inline int
181 __gthread_objc_condition_deallocate (objc_condition_t condition UNUSED)
183 return 0;
186 /* Wait on the condition */
187 static inline int
188 __gthread_objc_condition_wait (objc_condition_t condition UNUSED,
189 objc_mutex_t mutex UNUSED)
191 return 0;
194 /* Wake up all threads waiting on this condition. */
195 static inline int
196 __gthread_objc_condition_broadcast (objc_condition_t condition UNUSED)
198 return 0;
201 /* Wake up one thread waiting on this condition. */
202 static inline int
203 __gthread_objc_condition_signal (objc_condition_t condition UNUSED)
205 return 0;
208 #else /* _LIBOBJC */
210 static inline int
211 __gthread_active_p (void)
213 return 0;
216 static inline int
217 __gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
219 return 0;
222 static inline int UNUSED
223 __gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
225 return 0;
228 static int UNUSED
229 __gthread_key_delete (__gthread_key_t __key UNUSED)
231 return 0;
234 static inline void *
235 __gthread_getspecific (__gthread_key_t __key UNUSED)
237 return 0;
240 static inline int
241 __gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
243 return 0;
246 static inline int
247 __gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
249 return 0;
252 static inline int
253 __gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
255 return 0;
258 static inline int
259 __gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
261 return 0;
264 static inline int
265 __gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
267 return 0;
270 static inline int
271 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
273 return __gthread_mutex_lock (__mutex);
276 static inline int
277 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
279 return __gthread_mutex_trylock (__mutex);
282 static inline int
283 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
285 return __gthread_mutex_unlock (__mutex);
288 static inline int
289 __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
291 return __gthread_mutex_destroy (__mutex);
294 #endif /* _LIBOBJC */
296 #undef UNUSED
298 #endif /* ! GCC_GTHR_SINGLE_H */