diff options
| author | rpj <rpj> | 1998-08-04 08:01:05 +0000 | 
|---|---|---|
| committer | rpj <rpj> | 1998-08-04 08:01:05 +0000 | 
| commit | 9ff4d7a4815f0e20f1dc95e9a9e91b55eee7459a (patch) | |
| tree | c498419490efabb58635a95bb6d910a6f21ddc10 | |
| parent | 10f173691b6929033d5714cde8a33f4477aaba28 (diff) | |
Tue Aug  4 16:57:58 1998  Ross Johnson  <rpj@swan.canberra.edu.au>
        * private.c (_pthread_delete_thread): Fix typo. Add missing ';'.
        * global.c (_pthread_virgins): Change types from pointer to
        array pointer.
        (_pthread_reuse): Ditto.
        (_pthread_win32handle_map): Ditto.
        (_pthread_threads_mutex_table): Ditto.
        * implement.h(_pthread_virgins): Change types from pointer to
        array pointer.
        (_pthread_reuse): Ditto.
        (_pthread_win32handle_map): Ditto.
        (_pthread_threads_mutex_table): Ditto.
        * private.c (_pthread_delete_thread): Fix "entry" should be "thread".
        * misc.c (pthread_self): Add extern for _pthread_threadID_TlsIndex.
        * global.c: Add comment.
        * misc.c (pthread_once): Fix member -> dereferences.
        Change _pthread_once_flag to once_control->flag in "if" test.
| -rw-r--r-- | ChangeLog | 25 | ||||
| -rw-r--r-- | global.c | 18 | ||||
| -rw-r--r-- | implement.h | 14 | ||||
| -rw-r--r-- | misc.c | 8 | ||||
| -rw-r--r-- | mutex.c | 2 | ||||
| -rw-r--r-- | private.c | 8 | 
6 files changed, 59 insertions, 16 deletions
| @@ -1,3 +1,28 @@ +Tue Aug  4 16:57:58 1998  Ross Johnson  <rpj@swan.canberra.edu.au> + +	* private.c (_pthread_delete_thread): Fix typo. Add missing ';'. + +	* global.c (_pthread_virgins): Change types from pointer to  +	array pointer. +	(_pthread_reuse): Ditto. +	(_pthread_win32handle_map): Ditto. +	(_pthread_threads_mutex_table): Ditto. + +	* implement.h(_pthread_virgins): Change types from pointer to  +	array pointer. +	(_pthread_reuse): Ditto. +	(_pthread_win32handle_map): Ditto. +	(_pthread_threads_mutex_table): Ditto. + +	* private.c (_pthread_delete_thread): Fix "entry" should be "thread". + +	* misc.c (pthread_self): Add extern for _pthread_threadID_TlsIndex. + +	* global.c: Add comment. + +	* misc.c (pthread_once): Fix member -> dereferences. +	Change _pthread_once_flag to once_control->flag in "if" test. +  Tue Aug  4 00:09:30 1998  Ross Johnson  <rpj@ixobrychus.canberra.edu.au>  	* implement.h(_pthread_virgins): Add extern. @@ -30,6 +30,9 @@ const int _pthread_cancel_disable      = 1;  const int _pthread_cancel_asynchronous = 0;  const int _pthread_cancel_deferred     = 1; + +/* Declare variables which are global to all threads in the process. */ +  /* FIXME: This is temporary. */  #define PTHREAD_MUTEX_INITIALIZER {0} @@ -38,15 +41,22 @@ pthread_mutex_t _pthread_table_mutex = PTHREAD_MUTEX_INITIALIZER;  DWORD _pthread_threads_count = 0;  /* Per thread management storage. See comments in private.c */ -_pthread_t * _pthread_virgins; +/* An array of struct _pthread */ +_pthread_t _pthread_virgins[]; +/* Index to the next available previously unused struct _pthread */  int _pthread_virgin_next = 0; -pthread_t * _pthread_reuse; +/* An array of pointers to struct _pthread */ +pthread_t _pthread_reuse[]; +/* Index to the first available reusable pthread_t. */  int _pthread_reuse_top = -1; -pthread_t * _pthread_win32handle_map; +/* An array of pointers to struct _pthread indexed by hashing +   the Win32 handle. */ +pthread_t _pthread_win32handle_map[];  /* Per thread mutex locks. */ -pthread_mutex_t * _pthread_threads_mutex_table; +pthread_mutex_t _pthread_threads_mutex_table[]; + diff --git a/implement.h b/implement.h index f132674..4a616ec 100644 --- a/implement.h +++ b/implement.h @@ -137,18 +137,24 @@ extern pthread_mutex_t _pthread_table_mutex;  extern DWORD _pthread_threads_count; -extern _pthread_t * _pthread_virgins; +/* An array of struct _pthread */ +extern _pthread_t _pthread_virgins[]; +/* Index to the next available previously unused struct _pthread */  extern int _pthread_virgin_next; -extern pthread_t * _pthread_reuse; +/* An array of pointers to struct _pthread */ +extern pthread_t _pthread_reuse[]; +/* Index to the first available reusable pthread_t. */  extern int _pthread_reuse_top; -extern pthread_t * _pthread_win32handle_map; +/* An array of pointers to struct _pthread indexed by hashing +   the Win32 handle. */ +extern pthread_t _pthread_win32handle_map[];  /* Per thread mutex locks. */ -extern pthread_mutex_t * _pthread_threads_mutex_table; +extern pthread_mutex_t _pthread_threads_mutex_table[];  #endif /* _IMPLEMENT_H */ @@ -25,12 +25,12 @@ pthread_once(pthread_once_t *once_control,       the DLL is unloaded. */    /* An atomic test-and-set of the "once" flag. */ -  EnterCriticalSection(once_control.lock); -  if (_pthread_once_flag == 0) +  EnterCriticalSection(once_control->lock); +  if (once_control->flag == 0)      {        flag = once_control->flag = 1;      } -  LeaveCriticalSection(once_control.lock); +  LeaveCriticalSection(once_control->lock);    if (flag)      { @@ -45,6 +45,8 @@ pthread_t  pthread_self(void)  {    pthread_t ret; +  /* This TLS index is allocated on DLL load by dll.c */ +  extern DWORD _pthread_threadID_TlsIndex;    ret = (pthread_t) TlsGetValue(_pthread_threadID_TlsIndex); @@ -9,7 +9,7 @@  #include "implement.h"  int -pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutex_attr_t *attr) +pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)  {    if (mutex == NULL)      { @@ -126,7 +126,7 @@ _pthread_new_thread(pthread_t * thread)      {        if (_pthread_virgin_next < PTHREAD_THREADS_MAX)  	{ -	  new_thread = _pthread_virgin[_pthread_virgin_next++]; +	  new_thread = (pthread_t) &_pthread_virgins[_pthread_virgin_next++];  	}        else  	{ @@ -163,15 +163,15 @@ _pthread_delete_thread(_pthread_t * thread)    if (thread != NULL        && thread->ptstatus == _PTHREAD_EXITED)      { -      pthread_attr_destroy(&(entry->attr)); +      pthread_attr_destroy(&(thread->attr));        thread->win32handle = NULL; -      thread_ptstatus = _PTHREAD_REUSE; +      thread->ptstatus = _PTHREAD_REUSE;        _pthread_reuse[++_pthread_reuse_top] = thread;      }    else      { -      return EINVAL +      return EINVAL;      }    return 0;  } | 
