1 /* GNU Objective C Runtime Thread Implementation
2 Copyright (C) 1996, 1997, 2009 Free Software Foundation, Inc.
3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
4 Renamed from thr-vxworks.c to thr-rtems.c by
5 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under the
10 terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 3, or (at your option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
29 #include "objc/runtime.h"
31 /* Thread local storage for a single thread */
32 static void *thread_local_storage
= NULL
;
34 /* Backend initialization functions */
36 /* Initialize the threads subsystem. */
38 __objc_init_thread_system(void)
40 /* No thread support available */
44 /* Close the threads subsystem. */
46 __objc_close_thread_system(void)
48 /* No thread support available */
52 /* Backend thread functions */
54 /* Create a new thread of execution. */
56 __objc_thread_detach(void (*func
)(void *arg
), void *arg
)
58 /* No thread support available */
62 /* Set the current thread's priority. */
64 __objc_thread_set_priority(int priority
)
66 /* No thread support available */
70 /* Return the current thread's priority. */
72 __objc_thread_get_priority(void)
74 return OBJC_THREAD_INTERACTIVE_PRIORITY
;
77 /* Yield our process time to another thread. */
79 __objc_thread_yield(void)
84 /* Terminate the current thread. */
86 __objc_thread_exit(void)
88 /* No thread support available */
89 /* Should we really exit the program */
90 /* exit(&__objc_thread_exit_status); */
94 /* Returns an integer value which uniquely describes a thread. */
96 __objc_thread_id(void)
98 /* No thread support, use 1. */
99 return (objc_thread_t
)1;
102 /* Sets the thread's local storage pointer. */
104 __objc_thread_set_data(void *value
)
106 thread_local_storage
= value
;
110 /* Returns the thread's local storage pointer. */
112 __objc_thread_get_data(void)
114 return thread_local_storage
;
117 /* Backend mutex functions */
119 /* Allocate a mutex. */
121 __objc_mutex_allocate(objc_mutex_t mutex
)
126 /* Deallocate a mutex. */
128 __objc_mutex_deallocate(objc_mutex_t mutex
)
133 /* Grab a lock on a mutex. */
135 __objc_mutex_lock(objc_mutex_t mutex
)
137 /* There can only be one thread, so we always get the lock */
141 /* Try to grab a lock on a mutex. */
143 __objc_mutex_trylock(objc_mutex_t mutex
)
145 /* There can only be one thread, so we always get the lock */
149 /* Unlock the mutex */
151 __objc_mutex_unlock(objc_mutex_t mutex
)
156 /* Backend condition mutex functions */
158 /* Allocate a condition. */
160 __objc_condition_allocate(objc_condition_t condition
)
165 /* Deallocate a condition. */
167 __objc_condition_deallocate(objc_condition_t condition
)
172 /* Wait on the condition */
174 __objc_condition_wait(objc_condition_t condition
, objc_mutex_t mutex
)
179 /* Wake up all threads waiting on this condition. */
181 __objc_condition_broadcast(objc_condition_t condition
)
186 /* Wake up one thread waiting on this condition. */
188 __objc_condition_signal(objc_condition_t condition
)