diff options
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc.c | 101 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc_exit.c | 146 | ||||
-rw-r--r-- | cpukit/libcsupport/src/rmdir.c | 2 |
4 files changed, 148 insertions, 103 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index add1f50e63..ff867a1518 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -79,7 +79,7 @@ TERMINAL_IDENTIFICATION_C_FILES = src/ctermid.c src/isatty.c src/ttyname.c LIBC_GLUE_C_FILES = src/__getpid.c src/__gettod.c src/__times.c \ src/truncate.c src/access.c src/stat.c src/lstat.c src/pathconf.c \ - src/newlibc.c src/no_posix.c src/no_libc.c src/utsname.c + src/newlibc.c src/newlibc_exit.c src/no_posix.c src/no_libc.c src/utsname.c BSD_LIBC_C_FILES = src/strlcpy.c src/strlcat.c diff --git a/cpukit/libcsupport/src/newlibc.c b/cpukit/libcsupport/src/newlibc.c index 35fa3ee1b5..80c5cd07ea 100644 --- a/cpukit/libcsupport/src/newlibc.c +++ b/cpukit/libcsupport/src/newlibc.c @@ -54,53 +54,6 @@ int libc_reentrant; /* do we think we are reentrant? */ struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent); /* - * CYGNUS newlib routine that does atexit() processing and flushes - * stdio streams - * undocumented - */ - -extern void _wrapup_reent(struct _reent *); -extern void _reclaim_reent(struct _reent *); - -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; - - /* - * This was already done if the user called exit() directly . - _wrapup_reent(0); - */ - - if (_REENT != &libc_global_reent) { - _wrapup_reent(&libc_global_reent); -#if 0 - /* Don't reclaim this one, just in case we do printfs - * on the way out to ROM. - */ - _reclaim_reent(&libc_global_reent); -#endif - _REENT = &libc_global_reent; - } - - /* - * Try to drain output buffers. - * - * Should this be changed to do *all* file streams? - * _fwalk (_REENT, fclose); - */ - - fclose (stdin); - fclose (stdout); - fclose (stderr); -} - -/* * reent struct allocation moved here from libc_start_hook() to avoid * mutual exclusion problems when memory is allocated from the start hook. * @@ -329,58 +282,4 @@ libc_init(int reentrant) } } -/* - * Function: _exit - * Created: 94/12/10 - * - * Description: - * Called from exit() after it does atexit() processing and stdio fflush's - * - * called from bottom of exit() to really delete the task. - * If we are using reentrant libc, then let the delete extension - * do all the work, otherwise if a shutdown is in progress, - * then just do it. - * - * Parameters: - * exit status - * - * Returns: - * does not return - * - * Side Effects: - * - * Notes: - * - * - * Deficiencies/ToDo: - * - * - */ - -#include <unistd.h> - -#if !defined(RTEMS_UNIX) -void _exit(int status) -{ - /* - * We need to do the exit processing on the global reentrancy structure. - * This has already been done on the per task reentrancy structure - * associated with this task. - */ - - libc_wrapup(); - rtems_shutdown_executive(status); - for (;;) ; /* to avoid warnings */ -} - -#else - -void exit(int status) -{ - libc_wrapup(); - rtems_shutdown_executive(status); - for (;;) ; /* to avoid warnings */ -} -#endif - #endif diff --git a/cpukit/libcsupport/src/newlibc_exit.c b/cpukit/libcsupport/src/newlibc_exit.c new file mode 100644 index 0000000000..cff0146cbb --- /dev/null +++ b/cpukit/libcsupport/src/newlibc_exit.c @@ -0,0 +1,146 @@ +/* + * Implementation of hooks for the CYGNUS newlib libc + * These hooks set things up so that: + * + '_REENT' is switched at task switch time. + * + * COPYRIGHT (c) 1994 by Division Incorporated + * + * 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. + * + * $Id$ + * + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ +#include <rtems.h> + +#if defined(RTEMS_NEWLIB) +#include <rtems/libcsupport.h> + +/* Since we compile with strict ANSI we need to undef it to get + * prototypes for extensions + */ +#undef __STRICT_ANSI__ + +#include <stdlib.h> /* for free() */ +#include <string.h> /* for memset() */ + +#include <sys/reent.h> /* for extern of _REENT (aka _impure_ptr) */ +#include <errno.h> + +#include <stdio.h> + +int _fwalk(struct _reent *ptr, int (*function) (FILE *) ); + +/* do we think we are reentrant? */ +extern int libc_reentrant; +extern struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__; + +/* + * CYGNUS newlib routine that does atexit() processing and flushes + * stdio streams + * undocumented + */ + +extern void _wrapup_reent(struct _reent *); +extern void _reclaim_reent(struct _reent *); + +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; + + /* + * This was already done if the user called exit() directly . + _wrapup_reent(0); + */ + + if (_REENT != &libc_global_reent) { + _wrapup_reent(&libc_global_reent); +#if 0 + /* Don't reclaim this one, just in case we do printfs + * on the way out to ROM. + */ + _reclaim_reent(&libc_global_reent); +#endif + _REENT = &libc_global_reent; + } + + /* + * Try to drain output buffers. + * + * Should this be changed to do *all* file streams? + * _fwalk (_REENT, fclose); + */ + + fclose (stdin); + fclose (stdout); + fclose (stderr); +} + +/* + * Function: _exit + * Created: 94/12/10 + * + * Description: + * Called from exit() after it does atexit() processing and stdio fflush's + * + * called from bottom of exit() to really delete the task. + * If we are using reentrant libc, then let the delete extension + * do all the work, otherwise if a shutdown is in progress, + * then just do it. + * + * Parameters: + * exit status + * + * Returns: + * does not return + * + * Side Effects: + * + * Notes: + * + * + * Deficiencies/ToDo: + * + * + */ + +#include <unistd.h> + +#if !defined(RTEMS_UNIX) +void _exit(int status) +{ + /* + * We need to do the exit processing on the global reentrancy structure. + * This has already been done on the per task reentrancy structure + * associated with this task. + */ + + libc_wrapup(); + rtems_shutdown_executive(status); + for (;;) ; /* to avoid warnings */ +} + +#else + +void exit(int status) +{ + libc_wrapup(); + rtems_shutdown_executive(status); + for (;;) ; /* to avoid warnings */ +} +#endif + +#endif diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c index 59d43ff278..61d6390840 100644 --- a/cpukit/libcsupport/src/rmdir.c +++ b/cpukit/libcsupport/src/rmdir.c @@ -40,7 +40,7 @@ int rmdir( return -1; result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc ); - if (result != 0){ + if (result != 0) { rtems_filesystem_freenode( &loc ); return -1; } |