/* 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)
This file is part of GNU CC.
* provided by the system. We augment it with depth and current owner id
* 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. */
HANDLE handle; /* Win32 mutex HANDLE. */
};
* Create a new thread of execution and return its id. Return NULL if fails.
* 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)
{
DWORD thread_id = 0; /* Detached thread id. */
objc_mutex_unlock(__objc_runtime_mutex);
- return (_objc_thread_t)thread_id;
+ return (objc_thread_t)thread_id;
}
/********
* Returns an integer value which uniquely describes a thread. Must not be
* -1 which is reserved as a marker for "no thread".
*/
-_objc_thread_t
+objc_thread_t
objc_thread_id(void)
{
- return (_objc_thread_t)GetCurrentThreadId(); /* Return thread id. */
+ return (objc_thread_t)GetCurrentThreadId(); /* Return thread id. */
}
/********
* Allocate a mutex. Return the mutex pointer if successful or NULL if
* the allocation fails for any reason.
*/
-_objc_mutex_t
+objc_mutex_t
objc_mutex_allocate(void)
{
- _objc_mutex_t mutex;
+ objc_mutex_t mutex;
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. */
if ((mutex->handle = CreateMutex(NULL, 0, NULL)) == NULL) {
* Returns the number of locks on the thread. (1 for deallocate).
*/
int
-objc_mutex_deallocate(_objc_mutex_t mutex)
+objc_mutex_deallocate(objc_mutex_t mutex)
{
int depth; /* # of locks on mutex. */
* Returns the lock count on the mutex held by this thread.
*/
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;
if (!mutex) /* Is argument bad? */
* thread has a lock on the mutex returns -1.
*/
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.*/
if (!mutex) /* Is argument bad? */
* Will also return -1 if the mutex free fails.
*/
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? */
return -1; /* Yes, abort. */