diff options
-rw-r--r-- | cpukit/ChangeLog | 8 | ||||
-rw-r--r-- | cpukit/sapi/src/exshutdown.c | 9 | ||||
-rw-r--r-- | cpukit/score/src/threadhandler.c | 8 |
3 files changed, 16 insertions, 9 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index e912326b87..09c69e26d5 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,11 @@ +2008-01-03 Till Straumann <strauman@slac.stanford.edu> + + * score/src/threadhandler.c, sapi/src/exshutdown.c: + cannot call _fini via atexit() from rtems_shutdown_executive() + because at the point where rtems_shutdown_executive is called + the C-library is already dead. + Instead, register an atexit(_fini) after calling _init(). + 2007-12-28 Joel Sherrill <joel.sherrill@OARcorp.com> * libcsupport/Makefile.am: _rename_r is required by newlib 1.16.0. diff --git a/cpukit/sapi/src/exshutdown.c b/cpukit/sapi/src/exshutdown.c index 5db40afa97..a136391048 100644 --- a/cpukit/sapi/src/exshutdown.c +++ b/cpukit/sapi/src/exshutdown.c @@ -19,10 +19,6 @@ #include <rtems/score/sysstate.h> #include <rtems/score/thread.h> -#if defined(__USE_INIT_FINI__) -#include <stdlib.h> /* for atexit() */ -#endif - /* * rtems_shutdown_executive * @@ -40,11 +36,6 @@ void rtems_shutdown_executive( ) { if ( _System_state_Current != SYSTEM_STATE_SHUTDOWN ) { - - #if defined(__USE_INIT_FINI__) - extern void _fini( void ); - atexit( _fini ); - #endif _System_state_Set( SYSTEM_STATE_SHUTDOWN ); _Thread_Stop_multitasking(); } diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c index 523f623d02..f77a4ab3d0 100644 --- a/cpukit/score/src/threadhandler.c +++ b/cpukit/score/src/threadhandler.c @@ -30,6 +30,10 @@ #include <rtems/score/userext.h> #include <rtems/score/wkspace.h> +#if defined(__USE_INIT_FINI__) +#include <stdlib.h> /* for atexit() */ +#endif + /*PAGE * * _Thread_Handler @@ -125,7 +129,11 @@ void _Thread_Handler( void ) * RTEMS target configuration. --joel (12 May 2007) */ if (!doneCons) /* && (volatile void *)_init) */ + { + extern void _fini( void ); _init (); + atexit( _fini ); + } #endif #if defined(__USE__MAIN__) if (!doneCons && _main) |