diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-01-17 10:55:32 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-01-17 10:55:32 +0000 |
commit | 7a7e4d4d95e878c62ea5b642da864018b50aae21 (patch) | |
tree | 7256f4412958add20549f7c053e54b6df1f152cb /newlib/libc/stdio/findfp.c | |
parent | ae5b40a65bfc48f599a94dbfedb87f88ba6e831e (diff) | |
download | cygnal-7a7e4d4d95e878c62ea5b642da864018b50aae21.tar.gz cygnal-7a7e4d4d95e878c62ea5b642da864018b50aae21.tar.bz2 cygnal-7a7e4d4d95e878c62ea5b642da864018b50aae21.zip |
Introduce _STDIO_BSD_SEMANTICS flag to switch fclose/exit file flushing
semantics from POSIX to BSD.
* libc/stdio/fclose.c (_fclose_r): Conditionalize file flushing on
_STDIO_BSD_SEMANTICS. Call __sflush_r rather than _fflush_r. Add
comment.
* libc/stdio/fflush.c (__sflushw_r): New function, only available
if _STDIO_BSD_SEMANTICS is defined.
* libc/stdio/findfp.c (_cleanup_r): Call _fwalk_reent rather than
_fwalk. Conditionalize cleanup function call on _STDIO_BSD_SEMANTICS.
Add comments. Add FIXME.
* libc/stdio/local.h (__sflushw_r): Declare if _STDIO_BSD_SEMANTICS is
defined.
Diffstat (limited to 'newlib/libc/stdio/findfp.c')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 13 |
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 |