/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include #include #include #include #include struct __atexit *__atexit_ptr = 0; void (*__stdio_cleanup_hook)(void); /* A hook to close down the file system extensions if any where opened. This does not force them to be linked in. */ void (*__FSEXT_exit_hook)(void) = NULL; typedef void (*FUNC)(void); extern FUNC djgpp_first_dtor[] __asm__("djgpp_first_dtor"); extern FUNC djgpp_last_dtor[] __asm__("djgpp_last_dtor"); void exit(int status) { int i; struct __atexit *a,*o; a = __atexit_ptr; __atexit_ptr = 0; /* to prevent infinite loops */ while (a) { (a->__function)(); o = a; a = a->__next; free(o); } /* Destructors should probably be called after functions registered with atexit(), this is the way it happens in Linux anyway. */ for (i=0; i