1 /* This file is automatically generated. DO NOT EDIT! */
2 /* Generated from: NetBSD: mknative-gcc,v 1.22 2006/06/25 03:06:15 mrg 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, 1999, 2000, 2004 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 2, 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 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING. If not, write to the Free
23 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
26 /* As a special exception, if you link this library with other files,
27 some of which are compiled with GCC, to produce an executable,
28 this library does not by itself cause the resulting executable
29 to be covered by the GNU General Public License.
30 This exception does not however invalidate any other reasons why
31 the executable file might be covered by the GNU General Public License. */
33 #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
34 #define _GLIBCXX_GCC_GTHR_SINGLE_H
36 /* Just provide compatibility for mutex handling. */
38 typedef int __gthread_mutex_t
;
39 typedef int __gthread_recursive_mutex_t
;
41 #define __GTHREAD_MUTEX_INIT 0
44 #define _GLIBCXX_UNUSED(x)
46 #define _GLIBCXX_UNUSED(x) x __attribute__((unused))
51 /* Thread local storage for a single thread */
52 static void *thread_local_storage
= NULL
;
54 /* Backend initialization functions */
56 /* Initialize the threads subsystem. */
58 __gthread_objc_init_thread_system (void)
60 /* No thread support available */
64 /* Close the threads subsystem. */
66 __gthread_objc_close_thread_system (void)
68 /* No thread support available */
72 /* Backend thread functions */
74 /* Create a new thread of execution. */
75 static inline objc_thread_t
76 __gthread_objc_thread_detach (void (* func
)(void *), void * _GLIBCXX_UNUSED(arg
))
78 /* No thread support available */
82 /* Set the current thread's priority. */
84 __gthread_objc_thread_set_priority (int _GLIBCXX_UNUSED(priority
))
86 /* No thread support available */
90 /* Return the current thread's priority. */
92 __gthread_objc_thread_get_priority (void)
94 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
97 /* Yield our process time to another thread. */
99 __gthread_objc_thread_yield (void)
104 /* Terminate the current thread. */
106 __gthread_objc_thread_exit (void)
108 /* No thread support available */
109 /* Should we really exit the program */
110 /* exit (&__objc_thread_exit_status); */
114 /* Returns an integer value which uniquely describes a thread. */
115 static inline objc_thread_t
116 __gthread_objc_thread_id (void)
118 /* No thread support, use 1. */
119 return (objc_thread_t
) 1;
122 /* Sets the thread's local storage pointer. */
124 __gthread_objc_thread_set_data (void *value
)
126 thread_local_storage
= value
;
130 /* Returns the thread's local storage pointer. */
132 __gthread_objc_thread_get_data (void)
134 return thread_local_storage
;
137 /* Backend mutex functions */
139 /* Allocate a mutex. */
141 __gthread_objc_mutex_allocate (objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
146 /* Deallocate a mutex. */
148 __gthread_objc_mutex_deallocate (objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
153 /* Grab a lock on a mutex. */
155 __gthread_objc_mutex_lock (objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
157 /* There can only be one thread, so we always get the lock */
161 /* Try to grab a lock on a mutex. */
163 __gthread_objc_mutex_trylock (objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
165 /* There can only be one thread, so we always get the lock */
169 /* Unlock the mutex */
171 __gthread_objc_mutex_unlock (objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
176 /* Backend condition mutex functions */
178 /* Allocate a condition. */
180 __gthread_objc_condition_allocate (objc_condition_t
_GLIBCXX_UNUSED(condition
))
185 /* Deallocate a condition. */
187 __gthread_objc_condition_deallocate (objc_condition_t
_GLIBCXX_UNUSED(condition
))
192 /* Wait on the condition */
194 __gthread_objc_condition_wait (objc_condition_t
_GLIBCXX_UNUSED(condition
),
195 objc_mutex_t
_GLIBCXX_UNUSED(mutex
))
200 /* Wake up all threads waiting on this condition. */
202 __gthread_objc_condition_broadcast (objc_condition_t
_GLIBCXX_UNUSED(condition
))
207 /* Wake up one thread waiting on this condition. */
209 __gthread_objc_condition_signal (objc_condition_t
_GLIBCXX_UNUSED(condition
))
217 __gthread_active_p (void)
223 __gthread_mutex_lock (__gthread_mutex_t
* _GLIBCXX_UNUSED(mutex
))
229 __gthread_mutex_trylock (__gthread_mutex_t
* _GLIBCXX_UNUSED(mutex
))
235 __gthread_mutex_unlock (__gthread_mutex_t
* _GLIBCXX_UNUSED(mutex
))
241 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*mutex
)
243 return __gthread_mutex_lock (mutex
);
247 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*mutex
)
249 return __gthread_mutex_trylock (mutex
);
253 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*mutex
)
255 return __gthread_mutex_unlock (mutex
);
258 #endif /* _LIBOBJC */
260 #undef _GLIBCXX_UNUSED
262 #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */