diff options
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | buildlib.bat | 2 | ||||
| -rw-r--r-- | cleanup.c | 1 | ||||
| -rw-r--r-- | global.c | 2 | ||||
| -rw-r--r-- | tsd.c | 18 | 
5 files changed, 28 insertions, 5 deletions
| @@ -1,5 +1,15 @@  Sun Dec  6 21:54:35 1998  Ross Johnson  <rpj@ixobrychus.canberra.edu.au> +	* buildlib.bat: Fix args to CL when building the .DLL + +	* cleanup.c (_pthread_destructor_run_all): Fix TSD key management. +	This is a tidy-up before TSD and Thread management is completely +	replaced by John Bossom's much more elegant code. + +	* tsd.c (pthread_key_create): Fix TSD key management. + +	* global.c (_pthread_key_virgin_next): Initialise. +  	* build.bat: New DOS script to compile and link a pthreads app  	using Microsoft's CL compiler linker.  	* buildlib.bat: New DOS script to compile all the object files diff --git a/buildlib.bat b/buildlib.bat index e1005f0..e8a674e 100644 --- a/buildlib.bat +++ b/buildlib.bat @@ -17,4 +17,4 @@ cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c signal  cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c sync.c  cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c tsd.c -cl /LD /Zi *.obj /Fe$@ /link /nodefaultlib:libcmt /implib:pthread.lib msvcrt.lib /def:pthread.def +cl /LD /Zi *.obj /Fepthread.dll /link /nodefaultlib:libcmt /implib:pthread.lib msvcrt.lib /def:pthread.def @@ -192,6 +192,7 @@ _pthread_destructor_run_all()  		     for re-use.  		   */  		  key->status = _PTHREAD_TSD_KEY_REUSE; +		  _pthread_key_reuse[_pthread_key_reuse_top++] = k;  		}  	      else  		{ @@ -74,7 +74,7 @@ int _pthread_tsd_key_next = 0;  pthread_key_t _pthread_key_virgins[_PTHREAD_MAX_KEYS];  /* Index to the next available previously unused pthread_key_t */ -int _pthread_key_virgin_next; +int _pthread_key_virgin_next = 0;  /* An array of pthread_key_t */  pthread_key_t _pthread_key_reuse[_PTHREAD_MAX_KEYS]; @@ -62,14 +62,26 @@ pthread_key_create(pthread_key_t *key, void (*destructor)(void *))    /* CRITICAL SECTION */    pthread_mutex_lock(&_pthread_tsd_mutex); -  if (_pthread_key_virgin_next >= PTHREAD_KEYS_MAX) -    ret = EAGAIN; +  if (_pthread_key_reuse_top >= 0) +    { +      k = _pthread_key_reuse[_pthread_key_reuse_top--]; +    } +  else +    { +      if (_pthread_key_virgin_next < PTHREAD_KEYS_MAX) +	{ +	  k = _pthread_key_virgins[_pthread_key_virgin_next++]; +	} +      else +	{ +	  return EAGAIN; +	} +    }    /* FIXME: This needs to be implemented as a list plus a re-use stack as for       thread IDs. _pthread_destructor_run_all() then needs to be changed       to push keys onto the re-use stack.     */ -  k = _pthread_key_virgin_next++;    _pthread_tsd_key_table[k].in_use = 0;    _pthread_tsd_key_table[k].status = _PTHREAD_TSD_KEY_INUSE; | 
