| 1 | /* GNU Objective C Runtime Thread Implementation | 
|---|
| 2 | Copyright (C) 1996, 1997 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) | 
|---|
| 6 |  | 
|---|
| 7 | This file is part of GNU CC. | 
|---|
| 8 |  | 
|---|
| 9 | GNU CC 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 2, or (at your option) any later version. | 
|---|
| 12 |  | 
|---|
| 13 | GNU CC 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 | 
|---|
| 16 | details. | 
|---|
| 17 |  | 
|---|
| 18 | You should have received a copy of the GNU General Public License along with | 
|---|
| 19 | GNU CC; see the file COPYING.  If not, write to the Free Software | 
|---|
| 20 | Foundation, 59 Temple Place - Suite 330, | 
|---|
| 21 | Boston, MA 02111-1307, USA.  */ | 
|---|
| 22 |  | 
|---|
| 23 | /* As a special exception, if you link this library with files compiled with | 
|---|
| 24 | GCC to produce an executable, this does not cause the resulting executable | 
|---|
| 25 | to be covered by the GNU General Public License. This exception does not | 
|---|
| 26 | however invalidate any other reasons why the executable file might be | 
|---|
| 27 | covered by the GNU General Public License.  */ | 
|---|
| 28 |  | 
|---|
| 29 | #include <objc/thr.h> | 
|---|
| 30 | #include "runtime.h" | 
|---|
| 31 |  | 
|---|
| 32 | /* Thread local storage for a single thread */ | 
|---|
| 33 | static void *thread_local_storage = NULL; | 
|---|
| 34 |  | 
|---|
| 35 | /* Backend initialization functions */ | 
|---|
| 36 |  | 
|---|
| 37 | /* Initialize the threads subsystem. */ | 
|---|
| 38 | int | 
|---|
| 39 | __objc_init_thread_system(void) | 
|---|
| 40 | { | 
|---|
| 41 | /* No thread support available */ | 
|---|
| 42 | return -1; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | /* Close the threads subsystem. */ | 
|---|
| 46 | int | 
|---|
| 47 | __objc_close_thread_system(void) | 
|---|
| 48 | { | 
|---|
| 49 | /* No thread support available */ | 
|---|
| 50 | return -1; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /* Backend thread functions */ | 
|---|
| 54 |  | 
|---|
| 55 | /* Create a new thread of execution. */ | 
|---|
| 56 | objc_thread_t | 
|---|
| 57 | __objc_thread_detach(void (*func)(void *arg), void *arg) | 
|---|
| 58 | { | 
|---|
| 59 | /* No thread support available */ | 
|---|
| 60 | return NULL; | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | /* Set the current thread's priority. */ | 
|---|
| 64 | int | 
|---|
| 65 | __objc_thread_set_priority(int priority) | 
|---|
| 66 | { | 
|---|
| 67 | /* No thread support available */ | 
|---|
| 68 | return -1; | 
|---|
| 69 | } | 
|---|
| 70 |  | 
|---|
| 71 | /* Return the current thread's priority. */ | 
|---|
| 72 | int | 
|---|
| 73 | __objc_thread_get_priority(void) | 
|---|
| 74 | { | 
|---|
| 75 | return OBJC_THREAD_INTERACTIVE_PRIORITY; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | /* Yield our process time to another thread. */ | 
|---|
| 79 | void | 
|---|
| 80 | __objc_thread_yield(void) | 
|---|
| 81 | { | 
|---|
| 82 | return; | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 | /* Terminate the current thread. */ | 
|---|
| 86 | int | 
|---|
| 87 | __objc_thread_exit(void) | 
|---|
| 88 | { | 
|---|
| 89 | /* No thread support available */ | 
|---|
| 90 | /* Should we really exit the program */ | 
|---|
| 91 | /* exit(&__objc_thread_exit_status); */ | 
|---|
| 92 | return -1; | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 | /* Returns an integer value which uniquely describes a thread. */ | 
|---|
| 96 | objc_thread_t | 
|---|
| 97 | __objc_thread_id(void) | 
|---|
| 98 | { | 
|---|
| 99 | /* No thread support, use 1. */ | 
|---|
| 100 | return (objc_thread_t)1; | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | /* Sets the thread's local storage pointer. */ | 
|---|
| 104 | int | 
|---|
| 105 | __objc_thread_set_data(void *value) | 
|---|
| 106 | { | 
|---|
| 107 | thread_local_storage = value; | 
|---|
| 108 | return 0; | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 | /* Returns the thread's local storage pointer. */ | 
|---|
| 112 | void * | 
|---|
| 113 | __objc_thread_get_data(void) | 
|---|
| 114 | { | 
|---|
| 115 | return thread_local_storage; | 
|---|
| 116 | } | 
|---|
| 117 |  | 
|---|
| 118 | /* Backend mutex functions */ | 
|---|
| 119 |  | 
|---|
| 120 | /* Allocate a mutex. */ | 
|---|
| 121 | int | 
|---|
| 122 | __objc_mutex_allocate(objc_mutex_t mutex) | 
|---|
| 123 | { | 
|---|
| 124 | return 0; | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | /* Deallocate a mutex. */ | 
|---|
| 128 | int | 
|---|
| 129 | __objc_mutex_deallocate(objc_mutex_t mutex) | 
|---|
| 130 | { | 
|---|
| 131 | return 0; | 
|---|
| 132 | } | 
|---|
| 133 |  | 
|---|
| 134 | /* Grab a lock on a mutex. */ | 
|---|
| 135 | int | 
|---|
| 136 | __objc_mutex_lock(objc_mutex_t mutex) | 
|---|
| 137 | { | 
|---|
| 138 | /* There can only be one thread, so we always get the lock */ | 
|---|
| 139 | return 0; | 
|---|
| 140 | } | 
|---|
| 141 |  | 
|---|
| 142 | /* Try to grab a lock on a mutex. */ | 
|---|
| 143 | int | 
|---|
| 144 | __objc_mutex_trylock(objc_mutex_t mutex) | 
|---|
| 145 | { | 
|---|
| 146 | /* There can only be one thread, so we always get the lock */ | 
|---|
| 147 | return 0; | 
|---|
| 148 | } | 
|---|
| 149 |  | 
|---|
| 150 | /* Unlock the mutex */ | 
|---|
| 151 | int | 
|---|
| 152 | __objc_mutex_unlock(objc_mutex_t mutex) | 
|---|
| 153 | { | 
|---|
| 154 | return 0; | 
|---|
| 155 | } | 
|---|
| 156 |  | 
|---|
| 157 | /* Backend condition mutex functions */ | 
|---|
| 158 |  | 
|---|
| 159 | /* Allocate a condition. */ | 
|---|
| 160 | int | 
|---|
| 161 | __objc_condition_allocate(objc_condition_t condition) | 
|---|
| 162 | { | 
|---|
| 163 | return 0; | 
|---|
| 164 | } | 
|---|
| 165 |  | 
|---|
| 166 | /* Deallocate a condition. */ | 
|---|
| 167 | int | 
|---|
| 168 | __objc_condition_deallocate(objc_condition_t condition) | 
|---|
| 169 | { | 
|---|
| 170 | return 0; | 
|---|
| 171 | } | 
|---|
| 172 |  | 
|---|
| 173 | /* Wait on the condition */ | 
|---|
| 174 | int | 
|---|
| 175 | __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex) | 
|---|
| 176 | { | 
|---|
| 177 | return 0; | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | /* Wake up all threads waiting on this condition. */ | 
|---|
| 181 | int | 
|---|
| 182 | __objc_condition_broadcast(objc_condition_t condition) | 
|---|
| 183 | { | 
|---|
| 184 | return 0; | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | /* Wake up one thread waiting on this condition. */ | 
|---|
| 188 | int | 
|---|
| 189 | __objc_condition_signal(objc_condition_t condition) | 
|---|
| 190 | { | 
|---|
| 191 | return 0; | 
|---|
| 192 | } | 
|---|
| 193 |  | 
|---|
| 194 | /* End of File */ | 
|---|