* DevNotes: Add entry cgf-000014.
* cygheap.cc (tls_sentry): Move here, rename from 'sentry' in cygtls.cc (tls_sentry::lock): Ditto. (nthreads): Move from cygtls.cc (THREADLIST_CHUNK): Ditto. (cygheap_init): Call init_tls_list(). (init_cygheap::init_tls_list): Define new function. (init_cygheap::add_tls): Ditto. (init_cygheap::remove_tls): Ditto. (init_cygheap::find_tls): Ditto. Semi-resurrect from _cygtls::find_tls. * cygheap.h (init_cygheap::init_tls_list): Declare new function. (init_cygheap::add_tls): Ditto. (init_cygheap::remove_tls): Ditto. (init_cygheap::find_tls): Ditto. * cygtls.cc (sentry): Delete. (sentry::lock): Ditto. (nthreads): Ditto. (THREADLIST_CHUNK): Ditto. (_cygtls::init): Delete definition. (_cygtls::init_thread): Call cygheap->add_tls() to add thread to global list. (_cygtls::remove): cygheap->remove_tls() to remove thread from global list. * cygtls.h (_cygtls::init): Delete declaration. * dcrt0.cc (dll_crt0_0): Delete call to _cygtls::init(). * exceptions.cc (sigpacket::process): When no thread is specified, try to find one via cygheap->find_tls.
This commit is contained in:
@@ -19,39 +19,6 @@ details. */
|
||||
#include "sigproc.h"
|
||||
#include "exception.h"
|
||||
|
||||
class sentry
|
||||
{
|
||||
static muto lock;
|
||||
int destroy;
|
||||
public:
|
||||
void init ();
|
||||
bool acquired () {return lock.acquired ();}
|
||||
sentry () {destroy = 0;}
|
||||
sentry (DWORD wait) {destroy = lock.acquire (wait);}
|
||||
~sentry () {if (destroy) lock.release ();}
|
||||
friend void _cygtls::init ();
|
||||
};
|
||||
|
||||
muto NO_COPY sentry::lock;
|
||||
|
||||
static size_t NO_COPY nthreads;
|
||||
|
||||
#define THREADLIST_CHUNK 256
|
||||
|
||||
void
|
||||
_cygtls::init ()
|
||||
{
|
||||
if (cygheap->threadlist)
|
||||
memset (cygheap->threadlist, 0, cygheap->sthreads * sizeof (cygheap->threadlist[0]));
|
||||
else
|
||||
{
|
||||
cygheap->sthreads = THREADLIST_CHUNK;
|
||||
cygheap->threadlist = (_cygtls **) ccalloc_abort (HEAP_TLS, cygheap->sthreads,
|
||||
sizeof (cygheap->threadlist[0]));
|
||||
}
|
||||
sentry::lock.init ("sentry_lock");
|
||||
}
|
||||
|
||||
/* Two calls to get the stack right... */
|
||||
void
|
||||
_cygtls::call (DWORD (*func) (void *, void *), void *arg)
|
||||
@@ -167,18 +134,7 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
|
||||
|| (void *) func == (void *) cygthread::simplestub)
|
||||
return;
|
||||
|
||||
cygheap->user.reimpersonate ();
|
||||
|
||||
sentry here (INFINITE);
|
||||
if (nthreads >= cygheap->sthreads)
|
||||
{
|
||||
cygheap->threadlist = (_cygtls **)
|
||||
crealloc_abort (cygheap->threadlist, (cygheap->sthreads += THREADLIST_CHUNK)
|
||||
* sizeof (cygheap->threadlist[0]));
|
||||
memset (cygheap->threadlist + nthreads, 0, THREADLIST_CHUNK * sizeof (cygheap->threadlist[0]));
|
||||
}
|
||||
|
||||
cygheap->threadlist[nthreads++] = this;
|
||||
cygheap->add_tls (this);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -237,22 +193,7 @@ _cygtls::remove (DWORD wait)
|
||||
free_local (hostent_buf);
|
||||
/* Free temporary TLS path buffers. */
|
||||
locals.pathbufs.destroy ();
|
||||
|
||||
do
|
||||
{
|
||||
sentry here (wait);
|
||||
if (here.acquired ())
|
||||
{
|
||||
for (size_t i = 0; i < nthreads; i++)
|
||||
if (this == cygheap->threadlist[i])
|
||||
{
|
||||
if (i < --nthreads)
|
||||
cygheap->threadlist[i] = cygheap->threadlist[nthreads];
|
||||
debug_printf ("removed %p element %d", this, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
cygheap->remove_tls (this, wait);
|
||||
remove_wq (wait);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user