diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 8f718214c..909dee6ed 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2014-09-05 Bin Cheng + + * libc/stdio/findfp.c (_cleanup_r): Call _fflush_r when configuration + option "--enable-lite-exit" is in effect. Refactor the code. + 2014-09-05 Bin Cheng * libc/stdio/fwalk.c (_fwalk_reent): Remove redundant test. diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 9ee43b53d..27408f548 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -174,17 +174,22 @@ _VOID _DEFUN(_cleanup_r, (ptr), struct _reent *ptr) { + int (*cleanup_func) (struct _reent *, FILE *); #ifdef _STDIO_BSD_SEMANTICS /* BSD and Glibc systems only flush streams which have been written to at exit time. Calling flush rather than close for speed, as on the aforementioned systems. */ - _CAST_VOID _fwalk_reent (ptr, __sflushw_r); + cleanup_func = __sflushw_r; #else /* Otherwise close files and flush read streams, too. - FIXME: Do we really have to call fclose rather than fflush for - RTOS compatibility? */ - _CAST_VOID _fwalk_reent (ptr, _fclose_r); + Note we call flush directly if "--enable-lite-exit" is in effect. */ +#ifdef _LITE_EXIT + cleanup_func = _fflush_r; +#else + cleanup_func = _fclose_r; #endif +#endif + _CAST_VOID _fwalk_reent (ptr, cleanup_func); } #ifndef _REENT_ONLY