1 /* Threads compatibility routines for libgcc2 and libobjc. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
29 #ifndef __gthr_single_h
30 #define __gthr_single_h
32 /* Just provide compatibility for mutex handling. */
34 typedef int __gthread_mutex_t
;
36 #define __GTHREAD_MUTEX_INIT 0
41 #define UNUSED(x) x __attribute__((unused))
46 /* Thread local storage for a single thread */
47 static void *thread_local_storage
= NULL
;
49 /* Backend initialization functions */
51 /* Initialize the threads subsystem. */
53 __gthread_objc_init_thread_system(void)
55 /* No thread support available */
59 /* Close the threads subsystem. */
61 __gthread_objc_close_thread_system(void)
63 /* No thread support available */
67 /* Backend thread functions */
69 /* Create a new thread of execution. */
70 static inline objc_thread_t
71 __gthread_objc_thread_detach(void (* func
)(void *), void * UNUSED(arg
))
73 /* No thread support available */
77 /* Set the current thread's priority. */
79 __gthread_objc_thread_set_priority(int UNUSED(priority
))
81 /* No thread support available */
85 /* Return the current thread's priority. */
87 __gthread_objc_thread_get_priority(void)
89 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
92 /* Yield our process time to another thread. */
94 __gthread_objc_thread_yield(void)
99 /* Terminate the current thread. */
101 __gthread_objc_thread_exit(void)
103 /* No thread support available */
104 /* Should we really exit the program */
105 /* exit(&__objc_thread_exit_status); */
109 /* Returns an integer value which uniquely describes a thread. */
110 static inline objc_thread_t
111 __gthread_objc_thread_id(void)
113 /* No thread support, use 1. */
114 return (objc_thread_t
)1;
117 /* Sets the thread's local storage pointer. */
119 __gthread_objc_thread_set_data(void *value
)
121 thread_local_storage
= value
;
125 /* Returns the thread's local storage pointer. */
127 __gthread_objc_thread_get_data(void)
129 return thread_local_storage
;
132 /* Backend mutex functions */
134 /* Allocate a mutex. */
136 __gthread_objc_mutex_allocate(objc_mutex_t
UNUSED(mutex
))
141 /* Deallocate a mutex. */
143 __gthread_objc_mutex_deallocate(objc_mutex_t
UNUSED(mutex
))
148 /* Grab a lock on a mutex. */
150 __gthread_objc_mutex_lock(objc_mutex_t
UNUSED(mutex
))
152 /* There can only be one thread, so we always get the lock */
156 /* Try to grab a lock on a mutex. */
158 __gthread_objc_mutex_trylock(objc_mutex_t
UNUSED(mutex
))
160 /* There can only be one thread, so we always get the lock */
164 /* Unlock the mutex */
166 __gthread_objc_mutex_unlock(objc_mutex_t
UNUSED(mutex
))
171 /* Backend condition mutex functions */
173 /* Allocate a condition. */
175 __gthread_objc_condition_allocate(objc_condition_t
UNUSED(condition
))
180 /* Deallocate a condition. */
182 __gthread_objc_condition_deallocate(objc_condition_t
UNUSED(condition
))
187 /* Wait on the condition */
189 __gthread_objc_condition_wait(objc_condition_t
UNUSED(condition
),
190 objc_mutex_t
UNUSED(mutex
))
195 /* Wake up all threads waiting on this condition. */
197 __gthread_objc_condition_broadcast(objc_condition_t
UNUSED(condition
))
202 /* Wake up one thread waiting on this condition. */
204 __gthread_objc_condition_signal(objc_condition_t
UNUSED(condition
))
212 __gthread_active_p (void)
218 __gthread_mutex_lock (__gthread_mutex_t
* UNUSED(mutex
))
224 __gthread_mutex_trylock (__gthread_mutex_t
* UNUSED(mutex
))
230 __gthread_mutex_unlock (__gthread_mutex_t
* UNUSED(mutex
))
235 #endif /* _LIBOBJC */
239 #endif /* not __gthr_single_h */