Commit e0d0c8a1 by Richard Kenner

(__objc_runtime_mutex): Eliminate leading underscore from name of objc

mutex and thread structures.

From-SVN: r13598
parent 47a84c97
...@@ -40,7 +40,7 @@ static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */ ...@@ -40,7 +40,7 @@ static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */
static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */
/* Global runtime "write" mutex. */ /* Global runtime "write" mutex. */
_objc_mutex_t __objc_runtime_mutex; objc_mutex_t __objc_runtime_mutex;
/* Number of threads that are alive. */ /* Number of threads that are alive. */
int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ int __objc_runtime_threads_alive = 1; /* !T:MUTEX */
......
...@@ -63,7 +63,7 @@ extern BOOL __objc_class_links_resolved; ...@@ -63,7 +63,7 @@ extern BOOL __objc_class_links_resolved;
extern int __objc_selector_max_index; extern int __objc_selector_max_index;
/* Mutex locking __objc_selector_max_index and its arrays. */ /* Mutex locking __objc_selector_max_index and its arrays. */
extern _objc_mutex_t __objc_runtime_mutex; extern objc_mutex_t __objc_runtime_mutex;
/* Number of threads which are alive. */ /* Number of threads which are alive. */
extern int __objc_runtime_threads_alive; extern int __objc_runtime_threads_alive;
......
/* GNU Objective C Runtime Thread Interface /* GNU Objective C Runtime Thread Interface
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -34,9 +34,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -34,9 +34,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
pthread_mutex_t lock; /* pthread mutex. */ pthread_mutex_t lock; /* pthread mutex. */
}; };
...@@ -72,10 +72,10 @@ __objc_fini_thread_system(void) ...@@ -72,10 +72,10 @@ __objc_fini_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
_objc_thread_t thread_id = NULL; /* Detached thread id. */ objc_thread_t thread_id = NULL; /* Detached thread id. */
pthread_t new_thread_handle; /* DCE thread handle. */ pthread_t new_thread_handle; /* DCE thread handle. */
objc_mutex_lock(__objc_runtime_mutex); objc_mutex_lock(__objc_runtime_mutex);
...@@ -83,7 +83,7 @@ objc_thread_create(void (*func)(void *arg), void *arg) ...@@ -83,7 +83,7 @@ objc_thread_create(void (*func)(void *arg), void *arg)
if (pthread_create(&new_thread_handle, pthread_attr_default, if (pthread_create(&new_thread_handle, pthread_attr_default,
(void *)func, arg) == 0) { (void *)func, arg) == 0) {
/* ??? May not work! (64bit)*/ /* ??? May not work! (64bit)*/
thread_id = *(_objc_thread_t *)&new_thread_handle; thread_id = *(objc_thread_t *)&new_thread_handle;
pthread_detach(&new_thread_handle); /* Fully detach thread. */ pthread_detach(&new_thread_handle); /* Fully detach thread. */
__objc_runtime_threads_alive++; __objc_runtime_threads_alive++;
} }
...@@ -167,12 +167,12 @@ objc_thread_exit(void) ...@@ -167,12 +167,12 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* -1 which is reserved as a marker for "no thread". * -1 which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
pthread_t self = pthread_self(); pthread_t self = pthread_self();
return (_objc_thread_t) pthread_getuniqe_np (&self); return (objc_thread_t) pthread_getuniqe_np (&self);
} }
/******** /********
...@@ -205,13 +205,13 @@ objc_thread_get_data(void) ...@@ -205,13 +205,13 @@ objc_thread_get_data(void)
* Allocate a mutex. Return the mutex pointer if successful or NULL if * Allocate a mutex. Return the mutex pointer if successful or NULL if
* the allocation fails for any reason. * the allocation fails for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
int err = 0; int err = 0;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
err = pthread_mutex_init(&mutex->lock, pthread_mutexattr_default); err = pthread_mutex_init(&mutex->lock, pthread_mutexattr_default);
...@@ -220,7 +220,7 @@ objc_mutex_allocate(void) ...@@ -220,7 +220,7 @@ objc_mutex_allocate(void)
objc_free(mutex); /* Yes, free local memory. */ objc_free(mutex); /* Yes, free local memory. */
return NULL; /* Abort. */ return NULL; /* Abort. */
} }
mutex->owner = (_objc_thread_t) -1; /* No owner. */ mutex->owner = (objc_thread_t) -1; /* No owner. */
mutex->depth = 0; /* No locks. */ mutex->depth = 0; /* No locks. */
return mutex; /* Return mutex handle. */ return mutex; /* Return mutex handle. */
} }
...@@ -233,7 +233,7 @@ objc_mutex_allocate(void) ...@@ -233,7 +233,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -255,9 +255,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -255,9 +255,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -278,9 +278,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -278,9 +278,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -303,9 +303,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -303,9 +303,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
* Will also return -1 if the mutex free fails. * Will also return -1 if the mutex free fails.
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -315,7 +315,7 @@ objc_mutex_unlock(_objc_mutex_t mutex) ...@@ -315,7 +315,7 @@ objc_mutex_unlock(_objc_mutex_t mutex)
if (mutex->depth > 1) /* Released last lock? */ if (mutex->depth > 1) /* Released last lock? */
return --mutex->depth; /* No, Decrement depth, end.*/ return --mutex->depth; /* No, Decrement depth, end.*/
mutex->depth = 0; /* Yes, reset depth to 0. */ mutex->depth = 0; /* Yes, reset depth to 0. */
mutex->owner = (_objc_thread_t) -1; /* Set owner to "no thread".*/ mutex->owner = (objc_thread_t) -1; /* Set owner to "no thread".*/
if (pthread_mutex_unlock(&mutex->lock) != 0) /* Unlock system mutex. */ if (pthread_mutex_unlock(&mutex->lock) != 0) /* Unlock system mutex. */
return -1; /* Failed, abort. */ return -1; /* Failed, abort. */
......
/* GNU Objective C Runtime Thread Interface - SGI IRIX Implementation /* GNU Objective C Runtime Thread Interface - SGI IRIX Implementation
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -38,9 +38,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -38,9 +38,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
ulock_t lock; /* Irix lock. */ ulock_t lock; /* Irix lock. */
}; };
...@@ -79,15 +79,15 @@ __objc_fini_thread_system(void) ...@@ -79,15 +79,15 @@ __objc_fini_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
_objc_thread_t thread_id = NULL; objc_thread_t thread_id = NULL;
int sys_id; int sys_id;
objc_mutex_lock(__objc_runtime_mutex); objc_mutex_lock(__objc_runtime_mutex);
if ((sys_id = sproc((void *)func, PR_SALL, arg)) >= 0) { if ((sys_id = sproc((void *)func, PR_SALL, arg)) >= 0) {
thread_id = (_objc_thread_t)sys_id; thread_id = (objc_thread_t)sys_id;
__objc_runtime_threads_alive++; __objc_runtime_threads_alive++;
} }
objc_mutex_unlock(__objc_runtime_mutex); objc_mutex_unlock(__objc_runtime_mutex);
...@@ -154,10 +154,10 @@ objc_thread_exit(void) ...@@ -154,10 +154,10 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* NULL which is reserved as a marker for "no thread". * NULL which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
return (_objc_thread_t)get_pid(); /* Threads are processes. */ return (objc_thread_t)get_pid(); /* Threads are processes. */
} }
/******** /********
...@@ -185,13 +185,13 @@ objc_thread_get_data(void) ...@@ -185,13 +185,13 @@ objc_thread_get_data(void)
* Return the mutex pointer if successful or NULL if the allocation failed * Return the mutex pointer if successful or NULL if the allocation failed
* for any reason. * for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
int err = 0; int err = 0;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
if (!(mutex->lock = usnewlock(__objc_shared_arena_handle))) if (!(mutex->lock = usnewlock(__objc_shared_arena_handle)))
...@@ -214,7 +214,7 @@ objc_mutex_allocate(void) ...@@ -214,7 +214,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -235,9 +235,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -235,9 +235,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -263,9 +263,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -263,9 +263,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -289,9 +289,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -289,9 +289,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
......
/* GNU Objective C Runtime Thread Interface - OS/2 emx Implementation /* GNU Objective C Runtime Thread Interface - OS/2 emx Implementation
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Thomas Baier (baier@ci.tuwien.ac.at) Contributed by Thomas Baier (baier@ci.tuwien.ac.at)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -50,9 +50,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -50,9 +50,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
HMTX handle; /* OS/2 mutex HANDLE. */ HMTX handle; /* OS/2 mutex HANDLE. */
}; };
...@@ -86,7 +86,7 @@ __objc_fini_thread_system(void) ...@@ -86,7 +86,7 @@ __objc_fini_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
int thread_id = 0; /* id of the newly created thread */ int thread_id = 0; /* id of the newly created thread */
...@@ -101,7 +101,7 @@ objc_thread_create(void (*func)(void *arg), void *arg) ...@@ -101,7 +101,7 @@ objc_thread_create(void (*func)(void *arg), void *arg)
objc_mutex_unlock(__objc_runtime_mutex); objc_mutex_unlock(__objc_runtime_mutex);
return (_objc_thread_t)thread_id; return (objc_thread_t)thread_id;
} }
/******** /********
...@@ -191,10 +191,10 @@ objc_thread_exit(void) ...@@ -191,10 +191,10 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* -1 which is reserved as a marker for "no thread". * -1 which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
return (_objc_thread_t) *_threadid; /* Return thread id. */ return (objc_thread_t) *_threadid; /* Return thread id. */
} }
/******** /********
...@@ -222,17 +222,17 @@ objc_thread_get_data(void) ...@@ -222,17 +222,17 @@ objc_thread_get_data(void)
* Allocate a mutex. Return the mutex pointer if successful or NULL if * Allocate a mutex. Return the mutex pointer if successful or NULL if
* the allocation fails for any reason. * the allocation fails for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
int err = 0; int err = 0;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
if (DosCreateMutexSem (NULL,&(mutex->handle),0L,0) > 0) { if (DosCreateMutexSem (NULL,&(mutex->handle),0L,0) > 0) {
free (mutex); objc_free(mutex);
return NULL; return NULL;
} }
...@@ -249,7 +249,7 @@ objc_mutex_allocate(void) ...@@ -249,7 +249,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -270,9 +270,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -270,9 +270,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -295,9 +295,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -295,9 +295,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -320,9 +320,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -320,9 +320,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
* Will also return -1 if the mutex free fails. * Will also return -1 if the mutex free fails.
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
......
/* GNU Objective C Runtime Thread Interface for POSIX compliant threads /* GNU Objective C Runtime Thread Interface for POSIX compliant threads
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
Modified for Linux/Pthreads by Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de) Modified for Linux/Pthreads by Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
...@@ -35,9 +35,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -35,9 +35,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
pthread_mutex_t lock; /* pthread mutex. */ pthread_mutex_t lock; /* pthread mutex. */
}; };
...@@ -71,17 +71,17 @@ __objc_fini_thread_system(void) ...@@ -71,17 +71,17 @@ __objc_fini_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
_objc_thread_t thread_id = NULL; /* Detached thread id. */ objc_thread_t thread_id = NULL; /* Detached thread id. */
pthread_t new_thread_handle; /* DCE thread handle. */ pthread_t new_thread_handle; /* DCE thread handle. */
objc_mutex_lock(__objc_runtime_mutex); objc_mutex_lock(__objc_runtime_mutex);
if (pthread_create(&new_thread_handle, NULL, if (pthread_create(&new_thread_handle, NULL,
(void *)func, arg) == 0) { (void *)func, arg) == 0) {
thread_id = (_objc_thread_t) new_thread_handle; thread_id = (objc_thread_t) new_thread_handle;
pthread_detach(new_thread_handle); /* Fully detach thread. */ pthread_detach(new_thread_handle); /* Fully detach thread. */
__objc_runtime_threads_alive++; __objc_runtime_threads_alive++;
} }
...@@ -170,12 +170,12 @@ objc_thread_exit(void) ...@@ -170,12 +170,12 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* -1 which is reserved as a marker for "no thread". * -1 which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
pthread_t self = pthread_self(); pthread_t self = pthread_self();
return (_objc_thread_t) self; /* Return thread handle. */ return (objc_thread_t) self; /* Return thread handle. */
} }
/******** /********
...@@ -203,13 +203,13 @@ objc_thread_get_data(void) ...@@ -203,13 +203,13 @@ objc_thread_get_data(void)
* Allocate a mutex. Return the mutex pointer if successful or NULL if * Allocate a mutex. Return the mutex pointer if successful or NULL if
* the allocation fails for any reason. * the allocation fails for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
int err = 0; int err = 0;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
err = pthread_mutex_init(&mutex->lock, NULL); err = pthread_mutex_init(&mutex->lock, NULL);
...@@ -231,7 +231,7 @@ objc_mutex_allocate(void) ...@@ -231,7 +231,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -253,9 +253,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -253,9 +253,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -276,9 +276,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -276,9 +276,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -301,9 +301,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -301,9 +301,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
* Will also return -1 if the mutex free fails. * Will also return -1 if the mutex free fails.
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
......
/* GNU Objective C Runtime Thread Implementation /* GNU Objective C Runtime Thread Implementation
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -33,9 +33,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -33,9 +33,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
}; };
...@@ -54,7 +54,7 @@ __objc_init_thread_system(void) ...@@ -54,7 +54,7 @@ __objc_init_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
return NULL; /* We can't start threads. */ return NULL; /* We can't start threads. */
...@@ -104,10 +104,10 @@ objc_thread_exit(void) ...@@ -104,10 +104,10 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* NULL which is reserved as a marker for "no thread". * NULL which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
return (_objc_thread_t)1; /* No thread support, use 1.*/ return (objc_thread_t)1; /* No thread support, use 1.*/
} }
/******** /********
...@@ -137,12 +137,12 @@ objc_thread_get_data(void) ...@@ -137,12 +137,12 @@ objc_thread_get_data(void)
* Allocate a mutex. Return the mutex pointer if successful or NULL if the * Allocate a mutex. Return the mutex pointer if successful or NULL if the
* allocation failed for any reason. * allocation failed for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
mutex->owner = NULL; /* No owner. */ mutex->owner = NULL; /* No owner. */
...@@ -158,7 +158,7 @@ objc_mutex_allocate(void) ...@@ -158,7 +158,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -177,9 +177,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -177,9 +177,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -198,9 +198,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -198,9 +198,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
...@@ -220,9 +220,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -220,9 +220,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
* Will also return -1 if the mutex free fails. * Will also return -1 if the mutex free fails.
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
......
/* GNU Objective C Runtime Thread Interface - Win32 Implementation /* GNU Objective C Runtime Thread Interface - Win32 Implementation
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -38,9 +38,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -38,9 +38,9 @@ Boston, MA 02111-1307, USA. */
* provided by the system. We augment it with depth and current owner id * provided by the system. We augment it with depth and current owner id
* fields to implement and re-entrant lock. * fields to implement and re-entrant lock.
*/ */
struct _objc_mutex struct objc_mutex
{ {
volatile _objc_thread_t owner; /* Id of thread that owns. */ volatile objc_thread_t owner; /* Id of thread that owns. */
volatile int depth; /* # of acquires. */ volatile int depth; /* # of acquires. */
HANDLE handle; /* Win32 mutex HANDLE. */ HANDLE handle; /* Win32 mutex HANDLE. */
}; };
...@@ -79,7 +79,7 @@ __objc_fini_thread_system(void) ...@@ -79,7 +79,7 @@ __objc_fini_thread_system(void)
* Create a new thread of execution and return its id. Return NULL if fails. * Create a new thread of execution and return its id. Return NULL if fails.
* The new thread starts in "func" with the given argument. * The new thread starts in "func" with the given argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_create(void (*func)(void *arg), void *arg) objc_thread_create(void (*func)(void *arg), void *arg)
{ {
DWORD thread_id = 0; /* Detached thread id. */ DWORD thread_id = 0; /* Detached thread id. */
...@@ -96,7 +96,7 @@ objc_thread_create(void (*func)(void *arg), void *arg) ...@@ -96,7 +96,7 @@ objc_thread_create(void (*func)(void *arg), void *arg)
objc_mutex_unlock(__objc_runtime_mutex); objc_mutex_unlock(__objc_runtime_mutex);
return (_objc_thread_t)thread_id; return (objc_thread_t)thread_id;
} }
/******** /********
...@@ -183,10 +183,10 @@ objc_thread_exit(void) ...@@ -183,10 +183,10 @@ objc_thread_exit(void)
* Returns an integer value which uniquely describes a thread. Must not be * Returns an integer value which uniquely describes a thread. Must not be
* -1 which is reserved as a marker for "no thread". * -1 which is reserved as a marker for "no thread".
*/ */
_objc_thread_t objc_thread_t
objc_thread_id(void) objc_thread_id(void)
{ {
return (_objc_thread_t)GetCurrentThreadId(); /* Return thread id. */ return (objc_thread_t)GetCurrentThreadId(); /* Return thread id. */
} }
/******** /********
...@@ -214,13 +214,13 @@ objc_thread_get_data(void) ...@@ -214,13 +214,13 @@ objc_thread_get_data(void)
* Allocate a mutex. Return the mutex pointer if successful or NULL if * Allocate a mutex. Return the mutex pointer if successful or NULL if
* the allocation fails for any reason. * the allocation fails for any reason.
*/ */
_objc_mutex_t objc_mutex_t
objc_mutex_allocate(void) objc_mutex_allocate(void)
{ {
_objc_mutex_t mutex; objc_mutex_t mutex;
int err = 0; int err = 0;
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex)))) if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
return NULL; /* Abort if malloc failed. */ return NULL; /* Abort if malloc failed. */
if ((mutex->handle = CreateMutex(NULL, 0, NULL)) == NULL) { if ((mutex->handle = CreateMutex(NULL, 0, NULL)) == NULL) {
...@@ -240,7 +240,7 @@ objc_mutex_allocate(void) ...@@ -240,7 +240,7 @@ objc_mutex_allocate(void)
* Returns the number of locks on the thread. (1 for deallocate). * Returns the number of locks on the thread. (1 for deallocate).
*/ */
int int
objc_mutex_deallocate(_objc_mutex_t mutex) objc_mutex_deallocate(objc_mutex_t mutex)
{ {
int depth; /* # of locks on mutex. */ int depth; /* # of locks on mutex. */
...@@ -261,9 +261,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex) ...@@ -261,9 +261,9 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
* Returns the lock count on the mutex held by this thread. * Returns the lock count on the mutex held by this thread.
*/ */
int int
objc_mutex_lock(_objc_mutex_t mutex) objc_mutex_lock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
int status; int status;
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
...@@ -287,9 +287,9 @@ objc_mutex_lock(_objc_mutex_t mutex) ...@@ -287,9 +287,9 @@ objc_mutex_lock(_objc_mutex_t mutex)
* thread has a lock on the mutex returns -1. * thread has a lock on the mutex returns -1.
*/ */
int int
objc_mutex_trylock(_objc_mutex_t mutex) objc_mutex_trylock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
DWORD status; /* Return status from Win32.*/ DWORD status; /* Return status from Win32.*/
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
...@@ -314,9 +314,9 @@ objc_mutex_trylock(_objc_mutex_t mutex) ...@@ -314,9 +314,9 @@ objc_mutex_trylock(_objc_mutex_t mutex)
* Will also return -1 if the mutex free fails. * Will also return -1 if the mutex free fails.
*/ */
int int
objc_mutex_unlock(_objc_mutex_t mutex) objc_mutex_unlock(objc_mutex_t mutex)
{ {
_objc_thread_t thread_id; /* Cache our thread id. */ objc_thread_t thread_id; /* Cache our thread id. */
if (!mutex) /* Is argument bad? */ if (!mutex) /* Is argument bad? */
return -1; /* Yes, abort. */ return -1; /* Yes, abort. */
......
/* GNU Objective C Runtime Thread Interface /* GNU Objective C Runtime Thread Interface
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -110,11 +110,11 @@ __objc_thread_detach_function(struct __objc_thread_start_state *istate) ...@@ -110,11 +110,11 @@ __objc_thread_detach_function(struct __objc_thread_start_state *istate)
* Thread is started by sending message with selector to object. Message * Thread is started by sending message with selector to object. Message
* takes a single argument. * takes a single argument.
*/ */
_objc_thread_t objc_thread_t
objc_thread_detach(SEL selector, id object, id argument) objc_thread_detach(SEL selector, id object, id argument)
{ {
struct __objc_thread_start_state *istate; /* Initialial thread state. */ struct __objc_thread_start_state *istate; /* Initialial thread state. */
_objc_thread_t thread_id = NULL; /* Detached thread id. */ objc_thread_t thread_id = NULL; /* Detached thread id. */
if (!(istate = (struct __objc_thread_start_state *) if (!(istate = (struct __objc_thread_start_state *)
objc_malloc(sizeof(*istate)))) /* Can we allocate state? */ objc_malloc(sizeof(*istate)))) /* Can we allocate state? */
...@@ -137,14 +137,14 @@ objc_thread_detach(SEL selector, id object, id argument) ...@@ -137,14 +137,14 @@ objc_thread_detach(SEL selector, id object, id argument)
#undef objc_mutex_unlock() #undef objc_mutex_unlock()
int int
objc_mutex_unlock_x(_objc_mutex_t mutex, const char *f, int l) objc_mutex_unlock_x(objc_mutex_t mutex, const char *f, int l)
{ {
printf("%16.16s#%4d < unlock", f, l); printf("%16.16s#%4d < unlock", f, l);
return objc_mutex_unlock(mutex); return objc_mutex_unlock(mutex);
} }
int int
objc_mutex_lock_x(_objc_mutex_t mutex, const char *f, int l) objc_mutex_lock_x(objc_mutex_t mutex, const char *f, int l)
{ {
printf("%16.16s#%4d < lock", f, l); printf("%16.16s#%4d < lock", f, l);
return objc_mutex_lock(mutex); return objc_mutex_lock(mutex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment