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 */
5 /* Threads compatibility routines for libgcc2 and libobjc. */
6 /* Compile this one with gcc. */
7 /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
9 This file is part of GCC.
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
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
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.
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/>. */
30 #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
31 #define _GLIBCXX_GCC_GTHR_SINGLE_H
33 /* Just provide compatibility for mutex handling. */
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
;
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
45 #define _GLIBCXX_UNUSED __attribute__((unused))
49 /* Thread local storage for a single thread */
50 static void *thread_local_storage
= NULL
;
52 /* Backend initialization functions */
54 /* Initialize the threads subsystem. */
56 __gthread_objc_init_thread_system (void)
58 /* No thread support available */
62 /* Close the threads subsystem. */
64 __gthread_objc_close_thread_system (void)
66 /* No thread support available */
70 /* Backend thread functions */
72 /* Create a new thread of execution. */
73 static inline objc_thread_t
74 __gthread_objc_thread_detach (void (* func
)(void *), void * arg _GLIBCXX_UNUSED
)
76 /* No thread support available */
80 /* Set the current thread's priority. */
82 __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED
)
84 /* No thread support available */
88 /* Return the current thread's priority. */
90 __gthread_objc_thread_get_priority (void)
92 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
95 /* Yield our process time to another thread. */
97 __gthread_objc_thread_yield (void)
102 /* Terminate the current thread. */
104 __gthread_objc_thread_exit (void)
106 /* No thread support available */
107 /* Should we really exit the program */
108 /* exit (&__objc_thread_exit_status); */
112 /* Returns an integer value which uniquely describes a thread. */
113 static inline objc_thread_t
114 __gthread_objc_thread_id (void)
116 /* No thread support, use 1. */
117 return (objc_thread_t
) 1;
120 /* Sets the thread's local storage pointer. */
122 __gthread_objc_thread_set_data (void *value
)
124 thread_local_storage
= value
;
128 /* Returns the thread's local storage pointer. */
130 __gthread_objc_thread_get_data (void)
132 return thread_local_storage
;
135 /* Backend mutex functions */
137 /* Allocate a mutex. */
139 __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED
)
144 /* Deallocate a mutex. */
146 __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED
)
151 /* Grab a lock on a mutex. */
153 __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED
)
155 /* There can only be one thread, so we always get the lock */
159 /* Try to grab a lock on a mutex. */
161 __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED
)
163 /* There can only be one thread, so we always get the lock */
167 /* Unlock the mutex */
169 __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED
)
174 /* Backend condition mutex functions */
176 /* Allocate a condition. */
178 __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED
)
183 /* Deallocate a condition. */
185 __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED
)
190 /* Wait on the condition */
192 __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED
,
193 objc_mutex_t mutex _GLIBCXX_UNUSED
)
198 /* Wake up all threads waiting on this condition. */
200 __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED
)
205 /* Wake up one thread waiting on this condition. */
207 __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED
)
215 __gthread_active_p (void)
221 __gthread_once (__gthread_once_t
*__once _GLIBCXX_UNUSED
, void (*__func
) (void) _GLIBCXX_UNUSED
)
226 static inline int _GLIBCXX_UNUSED
227 __gthread_key_create (__gthread_key_t
*__key _GLIBCXX_UNUSED
, void (*__func
) (void *) _GLIBCXX_UNUSED
)
232 static int _GLIBCXX_UNUSED
233 __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED
)
239 __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED
)
245 __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED
, const void *__v _GLIBCXX_UNUSED
)
251 __gthread_mutex_destroy (__gthread_mutex_t
*__mutex _GLIBCXX_UNUSED
)
257 __gthread_mutex_lock (__gthread_mutex_t
*__mutex _GLIBCXX_UNUSED
)
263 __gthread_mutex_trylock (__gthread_mutex_t
*__mutex _GLIBCXX_UNUSED
)
269 __gthread_mutex_unlock (__gthread_mutex_t
*__mutex _GLIBCXX_UNUSED
)
275 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*__mutex
)
277 return __gthread_mutex_lock (__mutex
);
281 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*__mutex
)
283 return __gthread_mutex_trylock (__mutex
);
287 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*__mutex
)
289 return __gthread_mutex_unlock (__mutex
);
293 __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t
*__mutex
)
295 return __gthread_mutex_destroy (__mutex
);
298 #endif /* _LIBOBJC */
300 #undef _GLIBCXX_UNUSED
302 #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */