diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-04-24 15:04:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-04-26 10:57:08 +0200 |
commit | b7cf1ff7174377c65816908be427e1a76a5fa20f (patch) | |
tree | 13fb6a245c53df77b5e4559d809c7984559156ef /cpukit | |
parent | libcsupport: Rename open_dev_console() (diff) | |
download | rtems-b7cf1ff7174377c65816908be427e1a76a5fa20f.tar.bz2 |
libcsupport: Delete libc_wrapup()
Add and use rtems_libio_exit_helper. Add rtems_libio_exit().
The fclose(stdin) etc. makes no sense during exit. This would use the
_REENT structure of the thread calling _exit().
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio.h | 4 | ||||
-rw-r--r-- | cpukit/libcsupport/src/libio_exit.c | 34 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc_exit.c | 27 | ||||
-rw-r--r-- | cpukit/sapi/include/confdefs.h | 7 |
5 files changed, 48 insertions, 25 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 42de63cf1d..25e18c69d0 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -56,6 +56,7 @@ BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \ src/mount-mgr.c src/mount-mktgt.c src/libio_init.c \ src/privateenv.c \ src/libio_helper_null.c \ + src/libio_exit.c \ src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \ diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index ec2ced3e7b..23853f916e 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -1392,12 +1392,16 @@ extern const rtems_libio_helper rtems_libio_init_helper; extern const rtems_libio_helper rtems_libio_post_driver_helper; +extern const rtems_libio_helper rtems_libio_exit_helper; + extern const rtems_libio_helper rtems_fs_init_helper; void rtems_libio_helper_null(void); void rtems_libio_post_driver(void); +void rtems_libio_exit(void); + /** * @brief Creates a directory and all its parent directories according to * @a path. diff --git a/cpukit/libcsupport/src/libio_exit.c b/cpukit/libcsupport/src/libio_exit.c new file mode 100644 index 0000000000..443e57627b --- /dev/null +++ b/cpukit/libcsupport/src/libio_exit.c @@ -0,0 +1,34 @@ +/** + * @file + * + * @ingroup LibIO + */ + +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <unistd.h> + +#include <rtems/libio.h> + +void rtems_libio_exit(void) +{ + (void)close(0); + (void)close(1); + (void)close(2); +} diff --git a/cpukit/libcsupport/src/newlibc_exit.c b/cpukit/libcsupport/src/newlibc_exit.c index 8dbbfce0d2..f0c7b42e0c 100644 --- a/cpukit/libcsupport/src/newlibc_exit.c +++ b/cpukit/libcsupport/src/newlibc_exit.c @@ -11,37 +11,14 @@ #include "config.h" #endif -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ #include <rtems.h> #if defined(RTEMS_NEWLIB) -#include <rtems/libcsupport.h> +#include <rtems/libio.h> #include <stdio.h> #include <unistd.h> -static void libc_wrapup(void) -{ - /* - * In case RTEMS is already down, don't do this. It could be - * dangerous. - */ - - if (!_System_state_Is_up(_System_state_Get())) - return; - - /* - * Try to drain output buffers. - * - * Should this be changed to do *all* file streams? - * _fwalk (_REENT, fclose); - */ - - fclose (stdin); - fclose (stdout); - fclose (stderr); -} - /* FIXME: These defines are a blatant hack */ #if defined(__USE_INIT_FINI__) @@ -66,7 +43,7 @@ void _exit(int status) FINI_SYMBOL(); #endif - libc_wrapup(); + (*rtems_libio_exit_helper)(); rtems_shutdown_executive(status); for (;;) ; /* to avoid warnings */ } diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 0d8c99bf0d..c15c8a385c 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -106,6 +106,13 @@ const rtems_libio_helper rtems_libio_post_driver_helper = rtems_libio_post_driver; #endif +const rtems_libio_helper rtems_libio_exit_helper = + #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + rtems_libio_helper_null; + #else + rtems_libio_exit; + #endif + const rtems_libio_helper rtems_fs_init_helper = #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM rtems_libio_helper_null; |