1 #include "stdio_impl.h"
3 static int __fflush_unlocked(FILE *f)
5 /* If writing, flush output. */
6 if (f->wpos > f->buf && __oflow(f)) return -1;
8 /* If reading, sync position, per POSIX */
9 if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
12 /* Hook for special behavior on flush */
13 if (f->flush) f->flush(f);
15 return (f->flags & F_ERR) ? EOF : 0;
18 /* stdout.c will override this if linked */
19 static FILE *const __dummy = 0;
20 weak_alias(__dummy, __stdout_to_flush);
29 r = __fflush_unlocked(f);
34 r = __stdout_to_flush ? fflush(__stdout_to_flush) : 0;
37 for (f=ofl_head; f; f=next) {
40 r |= __fflush_unlocked(f);
50 weak_alias(__fflush_unlocked, fflush_unlocked);