Call the registered exit functions if the dll is unloaded.

svn path=/trunk/; revision=17294
This commit is contained in:
Hartmut Birr 2005-08-11 19:32:02 +00:00
parent d85fe524ac
commit 7faccfa7bb
4 changed files with 18 additions and 7 deletions

View file

@ -12,13 +12,7 @@ struct __atexit *__atexit_ptr = 0;
void exit(int status)
{
//int i;
struct __atexit *a = __atexit_ptr;
__atexit_ptr = 0; /* to prevent infinite loops */
while (a)
{
(a->__function)();
a = a->__next;
}
/*
if (__stdio_cleanup_hook)
__stdio_cleanup_hook();

View file

@ -2,6 +2,19 @@
#include <stdlib.h>
#include <internal/atexit.h>
void _atexit_cleanup(void)
{
struct __atexit *next, *a = __atexit_ptr;
__atexit_ptr = 0; /* to prevent infinite loops */
while (a)
{
(a->__function)();
next = a->__next;
free(a);
a = next;
}
}
/*
* @implemented
*

View file

@ -38,6 +38,7 @@ extern BOOL __fileno_init(void);
extern int BlockEnvToEnvironA(void);
extern int BlockEnvToEnvironW(void);
extern void FreeEnvironment(char **environment);
extern void _atexit_cleanup(void);
extern unsigned int _osver;
extern unsigned int _winminor;
@ -174,6 +175,7 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
DPRINT("Detach %d\n", nAttachCount);
/* FIXME: more cleanup... */
_fcloseall();
_atexit_cleanup();
/* destroy tls stuff */
DestroyThreadData();

View file

@ -37,6 +37,7 @@ extern BOOL __fileno_init(void);
extern int BlockEnvToEnvironA(void);
extern int BlockEnvToEnvironW(void);
extern void FreeEnvironment(char **environment);
extern void _atexit_cleanup(void);
extern unsigned int _osver;
extern unsigned int _winminor;
@ -116,6 +117,7 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
//DPRINT("Detach\n");
/* FIXME: more cleanup... */
_fcloseall();
_atexit_cleanup();
/* destroy tls stuff */
DestroyThreadData();