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().
This commit is contained in:
Sebastian Huber
2013-04-24 15:04:30 +02:00
parent 5fa0e5c5ec
commit b7cf1ff717
5 changed files with 48 additions and 25 deletions

View File

@@ -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 \

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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 */
}

View File

@@ -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;