Changeset 1391 for branches/GNU/src/gcc/libobjc/thr-mach.c
- Timestamp:
- Apr 27, 2004, 8:39:34 PM (21 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 dir.info 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libobjc/thr-mach.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* GNU Objective C Runtime Thread Implementation 2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.2 Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc. 3 3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) 4 4 Modified for Mach threads by Bill Bumgarner <bbum@friday.com> … … 38 38 privileges. Once lowered, it cannot be raised. 39 39 */ 40 static int __mach_get_max_thread_priority(cthread_t t, int *base) 40 static int 41 __mach_get_max_thread_priority (cthread_t t, int *base) 41 42 { 42 43 thread_t threadP; … … 48 49 return -1; 49 50 50 threadP = cthread_thread (t); /* get thread underlying */51 52 error =thread_info(threadP, THREAD_SCHED_INFO,53 (thread_info_t)&info, &info_count);51 threadP = cthread_thread (t); /* get thread underlying */ 52 53 error = thread_info (threadP, THREAD_SCHED_INFO, 54 (thread_info_t) &info, &info_count); 54 55 55 56 if (error != KERN_SUCCESS) … … 66 67 /* Initialize the threads subsystem. */ 67 68 int 68 __objc_init_thread_system (void)69 __objc_init_thread_system (void) 69 70 { 70 71 return 0; … … 73 74 /* Close the threads subsystem. */ 74 75 int 75 __objc_close_thread_system (void)76 __objc_close_thread_system (void) 76 77 { 77 78 return 0; … … 82 83 /* Create a new thread of execution. */ 83 84 objc_thread_t 84 __objc_thread_detach (void (*func)(void *arg), void *arg)85 __objc_thread_detach (void (*func) (void *arg), void *arg) 85 86 { 86 87 objc_thread_t thread_id; … … 88 89 89 90 /* create thread */ 90 new_thread_handle = cthread_fork ((cthread_fn_t)func, arg);91 92 if (new_thread_handle)91 new_thread_handle = cthread_fork ((cthread_fn_t) func, arg); 92 93 if (new_thread_handle) 93 94 { 94 95 /* this is not terribly portable */ 95 thread_id = *(objc_thread_t *) &new_thread_handle;96 cthread_detach (new_thread_handle);96 thread_id = *(objc_thread_t *) &new_thread_handle; 97 cthread_detach (new_thread_handle); 97 98 } 98 99 else … … 104 105 /* Set the current thread's priority. */ 105 106 int 106 __objc_thread_set_priority (int priority)107 { 108 objc_thread_t *t = objc_thread_id ();107 __objc_thread_set_priority (int priority) 108 { 109 objc_thread_t *t = objc_thread_id (); 109 110 cthread_t cT = (cthread_t) t; 110 int maxPriority = __mach_get_max_thread_priority (cT, NULL);111 int maxPriority = __mach_get_max_thread_priority (cT, NULL); 111 112 int sys_priority = 0; 112 113 … … 133 134 134 135 /* Change the priority */ 135 if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS)136 if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS) 136 137 return 0; 137 138 else … … 141 142 /* Return the current thread's priority. */ 142 143 int 143 __objc_thread_get_priority (void)144 { 145 objc_thread_t *t = objc_thread_id ();146 cthread_t cT = (cthread_t) t; /* see objc_thread_id () */144 __objc_thread_get_priority (void) 145 { 146 objc_thread_t *t = objc_thread_id (); 147 cthread_t cT = (cthread_t) t; /* see objc_thread_id () */ 147 148 int basePriority; 148 149 int maxPriority; … … 151 152 int interactiveT, backgroundT, lowT; /* thresholds */ 152 153 153 maxPriority = __mach_get_max_thread_priority (cT, &basePriority);154 155 if (maxPriority == -1)154 maxPriority = __mach_get_max_thread_priority (cT, &basePriority); 155 156 if (maxPriority == -1) 156 157 return -1; 157 158 … … 167 168 /* Yield our process time to another thread. */ 168 169 void 169 __objc_thread_yield (void)170 { 171 cthread_yield ();170 __objc_thread_yield (void) 171 { 172 cthread_yield (); 172 173 } 173 174 174 175 /* Terminate the current thread. */ 175 176 int 176 __objc_thread_exit (void)177 __objc_thread_exit (void) 177 178 { 178 179 /* exit the thread */ 179 cthread_exit (&__objc_thread_exit_status);180 cthread_exit (&__objc_thread_exit_status); 180 181 181 182 /* Failed if we reached here */ … … 185 186 /* Returns an integer value which uniquely describes a thread. */ 186 187 objc_thread_t 187 __objc_thread_id (void)188 { 189 cthread_t self = cthread_self ();190 191 return *(objc_thread_t *) &self;188 __objc_thread_id (void) 189 { 190 cthread_t self = cthread_self (); 191 192 return *(objc_thread_t *) &self; 192 193 } 193 194 194 195 /* Sets the thread's local storage pointer. */ 195 196 int 196 __objc_thread_set_data (void *value)197 { 198 cthread_set_data (cthread_self(), (any_t) value);197 __objc_thread_set_data (void *value) 198 { 199 cthread_set_data (cthread_self (), (any_t) value); 199 200 return 0; 200 201 } … … 202 203 /* Returns the thread's local storage pointer. */ 203 204 void * 204 __objc_thread_get_data (void)205 { 206 return (void *) cthread_data (cthread_self());205 __objc_thread_get_data (void) 206 { 207 return (void *) cthread_data (cthread_self ()); 207 208 } 208 209 … … 211 212 /* Allocate a mutex. */ 212 213 int 213 __objc_mutex_allocate (objc_mutex_t mutex)214 __objc_mutex_allocate (objc_mutex_t mutex) 214 215 { 215 216 int err = 0; 216 mutex->backend = objc_malloc (sizeof(struct mutex));217 218 err = mutex_init ((mutex_t)(mutex->backend));217 mutex->backend = objc_malloc (sizeof (struct mutex)); 218 219 err = mutex_init ((mutex_t) (mutex->backend)); 219 220 220 221 if (err != 0) 221 222 { 222 objc_free (mutex->backend);223 objc_free (mutex->backend); 223 224 return -1; 224 225 } … … 229 230 /* Deallocate a mutex. */ 230 231 int 231 __objc_mutex_deallocate (objc_mutex_t mutex)232 { 233 mutex_clear ((mutex_t)(mutex->backend));234 235 objc_free (mutex->backend);232 __objc_mutex_deallocate (objc_mutex_t mutex) 233 { 234 mutex_clear ((mutex_t) (mutex->backend)); 235 236 objc_free (mutex->backend); 236 237 mutex->backend = NULL; 237 238 return 0; … … 240 241 /* Grab a lock on a mutex. */ 241 242 int 242 __objc_mutex_lock (objc_mutex_t mutex)243 { 244 mutex_lock ((mutex_t)(mutex->backend));243 __objc_mutex_lock (objc_mutex_t mutex) 244 { 245 mutex_lock ((mutex_t) (mutex->backend)); 245 246 return 0; 246 247 } … … 248 249 /* Try to grab a lock on a mutex. */ 249 250 int 250 __objc_mutex_trylock (objc_mutex_t mutex)251 { 252 if (mutex_try_lock ((mutex_t)(mutex->backend)) == 0)251 __objc_mutex_trylock (objc_mutex_t mutex) 252 { 253 if (mutex_try_lock ((mutex_t) (mutex->backend)) == 0) 253 254 return -1; 254 255 else … … 258 259 /* Unlock the mutex */ 259 260 int 260 __objc_mutex_unlock (objc_mutex_t mutex)261 { 262 mutex_unlock ((mutex_t)(mutex->backend));261 __objc_mutex_unlock (objc_mutex_t mutex) 262 { 263 mutex_unlock ((mutex_t) (mutex->backend)); 263 264 return 0; 264 265 } … … 268 269 /* Allocate a condition. */ 269 270 int 270 __objc_condition_allocate (objc_condition_t condition)271 { 272 condition->backend = objc_malloc (sizeof(struct condition));273 condition_init ((condition_t)(condition->backend));271 __objc_condition_allocate (objc_condition_t condition) 272 { 273 condition->backend = objc_malloc (sizeof (struct condition)); 274 condition_init ((condition_t) (condition->backend)); 274 275 return 0; 275 276 } … … 277 278 /* Deallocate a condition. */ 278 279 int 279 __objc_condition_deallocate (objc_condition_t condition)280 { 281 condition_clear ((condition_t)(condition->backend));282 objc_free (condition->backend);280 __objc_condition_deallocate (objc_condition_t condition) 281 { 282 condition_clear ((condition_t) (condition->backend)); 283 objc_free (condition->backend); 283 284 condition->backend = NULL; 284 285 return 0; … … 287 288 /* Wait on the condition */ 288 289 int 289 __objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)290 { 291 condition_wait ((condition_t)(condition->backend),292 (mutex_t)(mutex->backend));290 __objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) 291 { 292 condition_wait ((condition_t) (condition->backend), 293 (mutex_t) (mutex->backend)); 293 294 return 0; 294 295 } … … 296 297 /* Wake up all threads waiting on this condition. */ 297 298 int 298 __objc_condition_broadcast (objc_condition_t condition)299 { 300 condition_broadcast ((condition_t)(condition->backend));299 __objc_condition_broadcast (objc_condition_t condition) 300 { 301 condition_broadcast ((condition_t) (condition->backend)); 301 302 return 0; 302 303 } … … 304 305 /* Wake up one thread waiting on this condition. */ 305 306 int 306 __objc_condition_signal (objc_condition_t condition)307 { 308 condition_signal ((condition_t)(condition->backend));307 __objc_condition_signal (objc_condition_t condition) 308 { 309 condition_signal ((condition_t) (condition->backend)); 309 310 return 0; 310 311 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.