diff options
| -rw-r--r-- | ChangeLog | 29 | ||||
| -rw-r--r-- | dll.c | 19 | ||||
| -rw-r--r-- | exit.c | 2 | ||||
| -rw-r--r-- | fork.c | 6 | ||||
| -rw-r--r-- | global.c | 10 | ||||
| -rw-r--r-- | implement.h | 3 | ||||
| -rw-r--r-- | misc.c | 4 | ||||
| -rw-r--r-- | private.c | 4 | 
8 files changed, 46 insertions, 31 deletions
| @@ -1,5 +1,34 @@  Thu Aug  6 15:19:22 1998  Ross Johnson  <rpj@swan.canberra.edu.au> +	* misc.c (pthread_once): Fix arg 1 of EnterCriticalSection() + 	and LeaveCriticalSection() calls to pass address-of lock. + +	* fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr +	in each _pthread_handler_push() call. + +	* exit.c (_pthread_exit): Fix attr arg in  +	pthread_attr_getdetachstate() call. + +	* private.c (_pthread_new_thread): Typecast (HANDLE) NULL. +	(_pthread_delete_thread): Ditto. + +	* implement.h: (_PTHREAD_MAX_THREADS): Add define. This keeps +	changing in an attempt to make thread administration data types +	opaque and cleanup DLL startup. + +	* dll.c (PthreadsEntryPoint):  +	(_pthread_virgins): Remove malloc() and free() calls. +	(_pthread_reuse): Ditto. +	(_pthread_win32handle_map): Ditto. +	(_pthread_threads_mutex_table): Ditto. + +	* global.c (_POSIX_THREAD_THREADS_MAX): Initialise with  +	_PTHREAD_MAX_THREADS. +	(_pthread_virgins): Ditto. +	(_pthread_reuse): Ditto. +	(_pthread_win32handle_map): Ditto. +	(_pthread_threads_mutex_table): Ditto. +  	* create.c (pthread_create): Typecast (HANDLE) NULL.  	Typecast (unsigned (*)(void *)) start_routine. @@ -35,20 +35,7 @@ BOOL WINAPI PthreadsEntryPoint(HINSTANCE dllHandle,        break;      case DLL_PROCESS_ATTACH: -      /* Allocate storage for thread admin arrays. */ -      _pthread_virgins =  -	(_pthread_t *) malloc(sizeof(_pthread_t) * PTHREAD_THREADS_MAX); - -      _pthread_reuse = -	(pthread_t *) malloc(sizeof(pthread_t) * PTHREAD_THREADS_MAX); - -      _pthread_win32handle_map = -	(pthread_t *) malloc(sizeof(pthread_t) * PTHREAD_THREADS_MAX); - -      _pthread_threads_mutex_table = -	(pthread_mutex_t *) malloc(sizeof(pthread_mutex_t) * PTHREAD_THREADS_MAX); - -      /* Per thread thread ID storage. */ +      /* Set up per thread thread ID storage. */        _pthread_threadID_TlsIndex = TlsAlloc();        if (_pthread_threadID_TlsIndex == 0xFFFFFFFF) @@ -58,10 +45,6 @@ BOOL WINAPI PthreadsEntryPoint(HINSTANCE dllHandle,        break;      case DLL_PROCESS_DETACH: -      free(_pthread_threads_mutex_table); -      free(_pthread_win32handle_map); -      free(_pthread_reuse); -      free(_pthread_virgins);        (void) TlsFree(_pthread_threadID_TlsIndex);        break; @@ -57,7 +57,7 @@ _pthread_exit(pthread_t thread, void * value, int return_code)       be deleted by the last waiting pthread_join() after this thread       has terminated. */ -  if (pthread_attr_getdetachstate(thread, &detachstate) == 0  +  if (pthread_attr_getdetachstate(&thread->attr, &detachstate) == 0         && detachstate == PTHREAD_CREATE_DETACHED        && thread->join_count == 0)      { @@ -27,7 +27,7 @@ pthread_atfork(void (*prepare)(void),        /* Push prepare. */        if (_pthread_handler_push(_PTHREAD_FORKPREPARE_STACK,  				_PTHREAD_HANDLER_POP_FIFO, -				prepare, +				(void (*)(void *)) prepare,  				NULL) == ENOMEM)  	{  	  ret = ENOMEM; @@ -40,7 +40,7 @@ pthread_atfork(void (*prepare)(void),        /* Push parent. */        if (_pthread_handler_push(_PTHREAD_FORKPARENT_STACK,  				_PTHREAD_HANDLER_POP_LIFO, -				parent, +				(void (*)(void *)) parent,  				NULL) == ENOMEM)  	{  	  ret = ENOMEM; @@ -53,7 +53,7 @@ pthread_atfork(void (*prepare)(void),        /* Push child. */        if (_pthread_handler_push(_PTHREAD_FORKCHILD_STACK,  				_PTHREAD_HANDLER_POP_LIFO, -				child, +				(void (*)(void *)) child,  				NULL) == ENOMEM)  	{  	  ret = ENOMEM; @@ -15,7 +15,7 @@     compatible between versions of the DLL. */  /* POSIX run-time invariant values. (Currently POSIX minimum values) */ -const int _POSIX_THREAD_THREADS_MAX = 128; +const int _POSIX_THREAD_THREADS_MAX = _PTHREAD_MAX_THREADS;  const int _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4;  const int _POSIX_THREAD_KEYS_MAX = 128; @@ -42,21 +42,21 @@ DWORD _pthread_threads_count = 0;  /* Per thread management storage. See comments in private.c */  /* An array of struct _pthread */ -_pthread_t _pthread_virgins[]; +_pthread_t _pthread_virgins[_PTHREAD_MAX_THREADS];  /* Index to the next available previously unused struct _pthread */  int _pthread_virgin_next = 0;  /* An array of pointers to struct _pthread */ -pthread_t _pthread_reuse[]; +pthread_t _pthread_reuse[_PTHREAD_MAX_THREADS];  /* Index to the first available reusable pthread_t. */  int _pthread_reuse_top = -1;  /* An array of pointers to struct _pthread indexed by hashing     the Win32 handle. */ -pthread_t _pthread_win32handle_map[]; +pthread_t _pthread_win32handle_map[_PTHREAD_MAX_THREADS];  /* Per thread mutex locks. */ -pthread_mutex_t _pthread_threads_mutex_table[]; +pthread_mutex_t _pthread_threads_mutex_table[_PTHREAD_MAX_THREADS]; diff --git a/implement.h b/implement.h index 3e270c6..bf55e91 100644 --- a/implement.h +++ b/implement.h @@ -7,6 +7,9 @@  #ifndef _IMPLEMENT_H  #define _IMPLEMENT_H +/* Use internally to initialise const ints and thread admin array sizes. */ +#define _PTHREAD_MAX_THREADS 128 +  #define _PTHREAD_HASH_INDEX(x) (((ULONG) x) % PTHREAD_THREADS_MAX)  enum { @@ -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); +  EnterCriticalSection(&once_control->lock);    if (once_control->flag == 0)      {        flag = once_control->flag = 1;      } -  LeaveCriticalSection(once_control->lock); +  LeaveCriticalSection(&once_control->lock);    if (flag)      { @@ -134,7 +134,7 @@ _pthread_new_thread(pthread_t * thread)  	}      } -  new_thread->win32handle = NULL; +  new_thread->win32handle = (HANDLE) NULL;    new_thread->ptstatus = _PTHREAD_NEW;    pthread_attr_init(&(new_thread->attr));    new_thread->joinvalueptr = NULL; @@ -164,7 +164,7 @@ _pthread_delete_thread(_pthread_t * thread)        && thread->ptstatus == _PTHREAD_EXITED)      {        pthread_attr_destroy(&(thread->attr)); -      thread->win32handle = NULL; +      thread->win32handle = (HANDLE) NULL;        thread->ptstatus = _PTHREAD_REUSE;        _pthread_reuse[++_pthread_reuse_top] = thread; | 
