From 72c3d34323756a765ba4c635abf997c2c2584489 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 23 Jan 2003 14:03:02 +0000 Subject: Making atexit weak does nothing for dynamicly linked apps. And for staticly linked apps it entirely prevents destructors from running unless atexit is called for some other reason. So if they enabled ctor/dtor support we need to have a call to the real atexit for dtors to work properly. If people don't want the extra 4k or so of junk in their static apps, they should leave ctor/dtor support disabled. -Erik --- libc/misc/internals/__uClibc_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libc') diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index aa4655cec..9561ac492 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -12,6 +12,7 @@ */ #define _ERRNO_H +#include #include #include @@ -23,7 +24,6 @@ extern int main(int argc, char **argv, char **envp); extern void weak_function _stdio_init(void); extern int *weak_const_function __errno_location(void); extern int *weak_const_function __h_errno_location(void); -extern int weak_function atexit(void (*function)(void)); #ifdef __UCLIBC_HAS_LOCALE__ extern void weak_function _locale_init(void); #endif @@ -123,15 +123,17 @@ __uClibc_start_main(int argc, char **argv, char **envp, * __uClibc_init() regardless, to be sure the right thing happens. */ __uClibc_init(); +#ifdef __UCLIBC_CTOR_DTOR__ /* Arrange for the application's dtors to run before we exit. */ - if (app_fini!=NULL && atexit) { - atexit (app_fini); + if (app_fini!=NULL) { + atexit(app_fini); } /* Run all the application's ctors now. */ if (app_init!=NULL) { app_init(); } +#endif /* Note: It is possible that any initialization done above could * have resulted in errno being set nonzero, so set it to 0 before -- cgit v1.2.3