summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/findfp.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/findfp.c')
-rw-r--r--newlib/libc/stdio/findfp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index e40500a07..f5a35a162 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -170,8 +170,17 @@ _VOID
_DEFUN(_cleanup_r, (ptr),
struct _reent *ptr)
{
- _CAST_VOID _fwalk(ptr, fclose);
- /* _CAST_VOID _fwalk (ptr, fflush); */ /* `cheating' */
+#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);
+#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);
+#endif
}
#ifndef _REENT_ONLY