1 #include "stdio_impl.h"
3 static int __fflush_unlocked(FILE *f)
5 /* If writing, flush output */
6 if (f->wpos > f->wbase) {
8 if (!f->wpos) return EOF;
11 /* If reading, sync position, per POSIX */
12 if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
14 /* Clear read and write modes */
15 f->wpos = f->wbase = f->wend = 0;
16 f->rpos = f->rend = 0;
18 /* Hook for special behavior on flush */
19 if (f->flush) f->flush(f);
24 /* stdout.c will override this if linked */
25 static FILE *const dummy = 0;
26 weak_alias(dummy, __stdout_used);
35 r = __fflush_unlocked(f);
40 r = __stdout_used ? fflush(__stdout_used) : 0;
43 for (f=libc.ofl_head; f; f=next) {
46 if (f->wpos > f->wbase) r |= __fflush_unlocked(f);
56 weak_alias(__fflush_unlocked, fflush_unlocked);