aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/fflush.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2006-02-20 23:24:00 +0000
committerJeff Johnston <jjohnstn@redhat.com>2006-02-20 23:24:00 +0000
commit99db626d210c747e8e8da2de09afb523547329bc (patch)
tree98ef3a36cf857e0528f6e3e4666fbc471c729919 /newlib/libc/stdio/fflush.c
parent8aaf07c7a2029da9a87e5a751b75568e129e510c (diff)
downloadnewlib-99db626d210c747e8e8da2de09afb523547329bc.zip
newlib-99db626d210c747e8e8da2de09afb523547329bc.tar.gz
newlib-99db626d210c747e8e8da2de09afb523547329bc.tar.bz2
2006-02-20 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/fflush.c (fflush): For an fflush on a read-only stream, turn off fseek/rewind optimization as per POSIX/SUSv3. * libc/stdio/fseek.c (_fseek_r): After a successful unoptimized seek, turn off the __SNPT no-optimization flag.
Diffstat (limited to 'newlib/libc/stdio/fflush.c')
-rw-r--r--newlib/libc/stdio/fflush.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index b417e54..05084dd 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -72,8 +72,18 @@ _DEFUN(fflush, (fp),
_flockfile (fp);
t = fp->_flags;
- if ((t & __SWR) == 0 || (p = fp->_bf._base) == NULL)
+ if ((t & __SWR) == 0)
{
+ /* For a read stream, an fflush causes the next seek to be
+ unoptimized (i.e. forces a system-level seek). This conforms
+ to the POSIX and SUSv3 standards. */
+ fp->_flags |= __SNPT;
+ _funlockfile (fp);
+ return 0;
+ }
+ if ((p = fp->_bf._base) == NULL)
+ {
+ /* Nothing to flush. */
_funlockfile (fp);
return 0;
}