diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-08 09:35:50 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-08 09:35:50 +0000 |
commit | 6ceebb84e2aea999ca8ef55f9e2ef1f5229f20cb (patch) | |
tree | 2af7479e59d3f37ae5035d563a34809a2b4036c7 /libobjc/thr.c | |
parent | f9d4a0a86fcd8c28937b559a06159ec824812830 (diff) | |
download | gcc-6ceebb84e2aea999ca8ef55f9e2ef1f5229f20cb.tar.gz |
Removed obsolete intermediate threading layer.
* thr.c: Use __gthread_objc_xxx functions directly instead of
__objc_thread_xxx ones.
* objc/thr.h: Removed prototypes of no longer existing
__objc_thread_xxx functions.
* Makefile.in: Removed thr-objc.lo.
* thr-dce.c: File removed.
* thr-decosf1.c: File removed.
* thr-irix.c: File removed.
* thr-mach.c: File removed.
* thr-objc.c: File removed.
* thr-os2.c: File removed.
* thr-posix.c: File removed.
* thr-pthreads.c: File removed.
* thr-rtems.c: File removed.
* thr-single.c: File removed.
* thr-solaris.c: File removed.
* thr-vxworks.c: File removed.
* thr-win32.c: File removed.
* README.threads: File removed.
* THREADS.MACH: File removed.
* THREADS: Updated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163996 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/thr.c')
-rw-r--r-- | libobjc/thr.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/libobjc/thr.c b/libobjc/thr.c index a12aa2da010..4bdbb5d1a27 100644 --- a/libobjc/thr.c +++ b/libobjc/thr.c @@ -1,5 +1,5 @@ /* GNU Objective C Runtime Thread Interface - Copyright (C) 1996, 1997, 2009 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2009, 2010 Free Software Foundation, Inc. Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) This file is part of GCC. @@ -22,9 +22,24 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +#define _LIBOBJC +/* The line below is needed for declarations of functions such as + pthread_mutexattr_settype, without which gthr-posix.h may fail to + compile within libobjc. Unfortunately, this breaks compilation on + Tru64 UNIX V4.0F, so disable it there. */ +#ifndef __osf__ +#define _XOPEN_SOURCE 500 +#endif +#include "config.h" +#include "tconfig.h" +#include "coretypes.h" +#include "tm.h" +#include "defaults.h" +#include "objc/thr.h" +#include "objc/runtime.h" +#include <gthr.h> #include <stdlib.h> -#include "objc/runtime.h" /* Global exit status. */ int __objc_thread_exit_status = 0; @@ -61,6 +76,13 @@ objc_thread_callback objc_set_thread_callback (objc_thread_callback func) considered part of the public interface. */ +/* Initialize the threads subsystem. */ +int +__objc_init_thread_system(void) +{ + return __gthread_objc_init_thread_system (); +} + /* First function called in a thread, starts everything else. @@ -152,8 +174,8 @@ objc_thread_detach (SEL selector, id object, id argument) objc_mutex_lock (__objc_runtime_mutex); /* Call the backend to spawn the thread */ - if ((thread_id = __objc_thread_detach ((void *)__objc_thread_detach_function, - istate)) == NULL) + if ((thread_id = __gthread_objc_thread_detach ((void *)__objc_thread_detach_function, + istate)) == NULL) { /* failed! */ objc_mutex_unlock (__objc_runtime_mutex); @@ -173,7 +195,7 @@ int objc_thread_set_priority (int priority) { /* Call the backend */ - return __objc_thread_set_priority (priority); + return __gthread_objc_thread_set_priority (priority); } /* Return the current thread's priority. */ @@ -181,7 +203,7 @@ int objc_thread_get_priority (void) { /* Call the backend */ - return __objc_thread_get_priority (); + return __gthread_objc_thread_get_priority (); } /* @@ -193,7 +215,7 @@ void objc_thread_yield (void) { /* Call the backend */ - __objc_thread_yield (); + __gthread_objc_thread_yield (); } /* @@ -209,7 +231,7 @@ objc_thread_exit (void) objc_mutex_unlock (__objc_runtime_mutex); /* Call the backend to terminate the thread */ - return __objc_thread_exit (); + return __gthread_objc_thread_exit (); } /* @@ -220,7 +242,7 @@ objc_thread_t objc_thread_id (void) { /* Call the backend */ - return __objc_thread_id (); + return __gthread_objc_thread_id (); } /* @@ -231,7 +253,7 @@ int objc_thread_set_data (void *value) { /* Call the backend */ - return __objc_thread_set_data (value); + return __gthread_objc_thread_set_data (value); } /* @@ -241,7 +263,7 @@ void * objc_thread_get_data (void) { /* Call the backend */ - return __objc_thread_get_data (); + return __gthread_objc_thread_get_data (); } /* Frontend mutex functions */ @@ -260,7 +282,7 @@ objc_mutex_allocate (void) return NULL; /* Call backend to create the mutex */ - if (__objc_mutex_allocate (mutex)) + if (__gthread_objc_mutex_allocate (mutex)) { /* failed! */ objc_free (mutex); @@ -293,7 +315,7 @@ objc_mutex_deallocate (objc_mutex_t mutex) depth = objc_mutex_lock (mutex); /* Call backend to destroy mutex */ - if (__objc_mutex_deallocate (mutex)) + if (__gthread_objc_mutex_deallocate (mutex)) return -1; /* Free the mutex structure */ @@ -320,12 +342,12 @@ objc_mutex_lock (objc_mutex_t mutex) return -1; /* If we already own the lock then increment depth */ - thread_id = __objc_thread_id (); + thread_id = __gthread_objc_thread_id (); if (mutex->owner == thread_id) return ++mutex->depth; /* Call the backend to lock the mutex */ - status = __objc_mutex_lock (mutex); + status = __gthread_objc_mutex_lock (mutex); /* Failed? */ if (status) @@ -352,12 +374,12 @@ objc_mutex_trylock (objc_mutex_t mutex) return -1; /* If we already own the lock then increment depth */ - thread_id = __objc_thread_id (); + thread_id = __gthread_objc_thread_id (); if (mutex->owner == thread_id) return ++mutex->depth; /* Call the backend to try to lock the mutex */ - status = __objc_mutex_trylock (mutex); + status = __gthread_objc_mutex_trylock (mutex); /* Failed? */ if (status) @@ -387,7 +409,7 @@ objc_mutex_unlock (objc_mutex_t mutex) return -1; /* If another thread owns the lock then abort */ - thread_id = __objc_thread_id (); + thread_id = __gthread_objc_thread_id (); if (mutex->owner != thread_id) return -1; @@ -400,7 +422,7 @@ objc_mutex_unlock (objc_mutex_t mutex) mutex->owner = NULL; /* Have the backend unlock the mutex */ - status = __objc_mutex_unlock (mutex); + status = __gthread_objc_mutex_unlock (mutex); /* Failed? */ if (status) @@ -426,7 +448,7 @@ objc_condition_allocate (void) return NULL; /* Call the backend to create the condition mutex */ - if (__objc_condition_allocate (condition)) + if (__gthread_objc_condition_allocate (condition)) { /* failed! */ objc_free (condition); @@ -452,7 +474,7 @@ objc_condition_deallocate (objc_condition_t condition) return -1; /* Call the backend to destroy */ - if (__objc_condition_deallocate (condition)) + if (__gthread_objc_condition_deallocate (condition)) return -1; /* Free the condition mutex structure */ @@ -479,7 +501,7 @@ objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) return -1; /* Make sure we are owner of mutex */ - thread_id = __objc_thread_id (); + thread_id = __gthread_objc_thread_id (); if (mutex->owner != thread_id) return -1; @@ -492,7 +514,7 @@ objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) mutex->owner = (objc_thread_t)NULL; /* Call the backend to wait */ - __objc_condition_wait (condition, mutex); + __gthread_objc_condition_wait (condition, mutex); /* Make ourselves owner of the mutex */ mutex->owner = thread_id; @@ -514,7 +536,7 @@ objc_condition_broadcast (objc_condition_t condition) if (! condition) return -1; - return __objc_condition_broadcast (condition); + return __gthread_objc_condition_broadcast (condition); } /* @@ -530,7 +552,7 @@ objc_condition_signal (objc_condition_t condition) if (! condition) return -1; - return __objc_condition_signal (condition); + return __gthread_objc_condition_signal (condition); } /* Make the objc thread system aware that a thread which is managed |