* dll_init.h (has_dtors): New flag.
(run_dtors): New wrapper function which avoids calling dtors more than once. * dll_init.cc (dll_global_dtors): Use dll.run_dtors wrapper. (dll_list::detach): Ditto. (dll_list::alloc): Set has_dtors flag.
This commit is contained in:
parent
e41f43a1a6
commit
6282fe16dd
@ -1,3 +1,12 @@
|
|||||||
|
2009-08-21 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* dll_init.h (has_dtors): New flag.
|
||||||
|
(run_dtors): New wrapper function which avoids calling dtors more than
|
||||||
|
once.
|
||||||
|
* dll_init.cc (dll_global_dtors): Use dll.run_dtors wrapper.
|
||||||
|
(dll_list::detach): Ditto.
|
||||||
|
(dll_list::alloc): Set has_dtors flag.
|
||||||
|
|
||||||
2009-08-21 Christopher Faylor <me+cygwin@cgf.cx>
|
2009-08-21 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
* fcntl.cc (fcntl64): Detect negative fd as error.
|
* fcntl.cc (fcntl64): Detect negative fd as error.
|
||||||
|
@ -35,7 +35,7 @@ dll_global_dtors ()
|
|||||||
dll_global_dtors_recorded = false;
|
dll_global_dtors_recorded = false;
|
||||||
if (recorded && dlls.start.next)
|
if (recorded && dlls.start.next)
|
||||||
for (dll *d = dlls.end; d != &dlls.start; d = d->prev)
|
for (dll *d = dlls.end; d != &dlls.start; d = d->prev)
|
||||||
d->p.run_dtors ();
|
d->run_dtors ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run all constructors associated with a dll */
|
/* Run all constructors associated with a dll */
|
||||||
@ -119,6 +119,7 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
|
|||||||
return d; /* Return previously allocated pointer. */
|
return d; /* Return previously allocated pointer. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Change this to new at some point. */
|
||||||
d = (dll *) cmalloc (HEAP_2_DLL, sizeof (*d) + (namelen * sizeof (*name)));
|
d = (dll *) cmalloc (HEAP_2_DLL, sizeof (*d) + (namelen * sizeof (*name)));
|
||||||
|
|
||||||
/* Now we've allocated a block of information. Fill it in with the supplied
|
/* Now we've allocated a block of information. Fill it in with the supplied
|
||||||
@ -126,6 +127,7 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
|
|||||||
d->count = 1;
|
d->count = 1;
|
||||||
wcscpy (d->name, name);
|
wcscpy (d->name, name);
|
||||||
d->handle = h;
|
d->handle = h;
|
||||||
|
d->has_dtors = true;
|
||||||
d->p = p;
|
d->p = p;
|
||||||
d->type = type;
|
d->type = type;
|
||||||
if (end == NULL)
|
if (end == NULL)
|
||||||
@ -159,7 +161,7 @@ dll_list::detach (void *retaddr)
|
|||||||
system_printf ("WARNING: trying to detach an already detached dll ...");
|
system_printf ("WARNING: trying to detach an already detached dll ...");
|
||||||
else if (--d->count == 0)
|
else if (--d->count == 0)
|
||||||
{
|
{
|
||||||
d->p.run_dtors ();
|
d->run_dtors ();
|
||||||
d->prev->next = d->next;
|
d->prev->next = d->next;
|
||||||
if (d->next)
|
if (d->next)
|
||||||
d->next->prev = d->prev;
|
d->next->prev = d->prev;
|
||||||
|
@ -50,10 +50,19 @@ struct dll
|
|||||||
per_module p;
|
per_module p;
|
||||||
HMODULE handle;
|
HMODULE handle;
|
||||||
int count;
|
int count;
|
||||||
|
bool has_dtors;
|
||||||
dll_type type;
|
dll_type type;
|
||||||
WCHAR name[1];
|
WCHAR name[1];
|
||||||
void detach ();
|
void detach ();
|
||||||
int init ();
|
int init ();
|
||||||
|
void run_dtors ()
|
||||||
|
{
|
||||||
|
if (has_dtors)
|
||||||
|
{
|
||||||
|
has_dtors = 0;
|
||||||
|
p.run_dtors ();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_DLL_BEFORE_INIT 100
|
#define MAX_DLL_BEFORE_INIT 100
|
||||||
|
Loading…
x
Reference in New Issue
Block a user