* dcrt0.cc (atexit_lock): Delete.

(cygwin_exit): Remove atexit lock.
(cygwin_atexit): Ditto.  Rename parameter to match newlib.  Call __cxa_atexit
when invoked by a registered DLL.
* dll_init.cc (remove_dll_atexit): Delete.
(dll_list::find): New function.
(dll_list::detach): Use dll_list::find to find dll associated with return
address.  Use __cxa_finalize to run atexit functions associated with the dll.
(cygwin_detach_dll): Don't assume that HANDLE == void *.
* dll_init.h (dll_list::find): Declare.
(__cxa_atexit): Ditto.
(__cxa_finalize): Ditto.
* init.cc (dll_entry): Clarify comment.
This commit is contained in:
Christopher Faylor
2010-02-02 02:00:01 +00:00
parent a390615010
commit fc6a0dc849
5 changed files with 58 additions and 60 deletions

View File

@ -1108,24 +1108,18 @@ do_exit (int status)
myself.exit (n);
}
static NO_COPY muto atexit_lock;
extern "C" int
cygwin_atexit (void (*function)(void))
cygwin_atexit (void (*fn) (void))
{
int res;
atexit_lock.init ("atexit_lock");
atexit_lock.acquire ();
res = atexit (function);
atexit_lock.release ();
dll *d = dlls.find ((void *) _my_tls.retaddr ());
res = d ? __cxa_atexit ((void (*) (void *)) fn, NULL, d) : atexit (fn);
return res;
}
extern "C" void
cygwin_exit (int n)
{
if (atexit_lock)
atexit_lock.acquire ();
exit (n);
}