* libc/stdio/findfp.c (_cleanup_r): Call _fflush_r when configuration

option "--enable-lite-exit" is in effect.  Refactor the code.
This commit is contained in:
Corinna Vinschen 2014-09-05 09:42:15 +00:00
parent 1ec7de7271
commit e7565f1088
2 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2014-09-05 Bin Cheng <bin.cheng@arm.com>
* 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 <bin.cheng@arm.com> 2014-09-05 Bin Cheng <bin.cheng@arm.com>
* libc/stdio/fwalk.c (_fwalk_reent): Remove redundant test. * libc/stdio/fwalk.c (_fwalk_reent): Remove redundant test.

View File

@ -174,17 +174,22 @@ _VOID
_DEFUN(_cleanup_r, (ptr), _DEFUN(_cleanup_r, (ptr),
struct _reent *ptr) struct _reent *ptr)
{ {
int (*cleanup_func) (struct _reent *, FILE *);
#ifdef _STDIO_BSD_SEMANTICS #ifdef _STDIO_BSD_SEMANTICS
/* BSD and Glibc systems only flush streams which have been written to /* BSD and Glibc systems only flush streams which have been written to
at exit time. Calling flush rather than close for speed, as on at exit time. Calling flush rather than close for speed, as on
the aforementioned systems. */ the aforementioned systems. */
_CAST_VOID _fwalk_reent (ptr, __sflushw_r); cleanup_func = __sflushw_r;
#else #else
/* Otherwise close files and flush read streams, too. /* Otherwise close files and flush read streams, too.
FIXME: Do we really have to call fclose rather than fflush for Note we call flush directly if "--enable-lite-exit" is in effect. */
RTOS compatibility? */ #ifdef _LITE_EXIT
_CAST_VOID _fwalk_reent (ptr, _fclose_r); cleanup_func = _fflush_r;
#else
cleanup_func = _fclose_r;
#endif #endif
#endif
_CAST_VOID _fwalk_reent (ptr, cleanup_func);
} }
#ifndef _REENT_ONLY #ifndef _REENT_ONLY