Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: fusl/src/stdio/fflush.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/stdio/ferror.c ('k') | fusl/src/stdio/fgetc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "stdio_impl.h"
2
3 static int __fflush_unlocked(FILE *f)
4 {
5 /* If writing, flush output */
6 if (f->wpos > f->wbase) {
7 f->write(f, 0, 0);
8 if (!f->wpos) return EOF;
9 }
10
11 /* If reading, sync position, per POSIX */
12 if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
13
14 /* Clear read and write modes */
15 f->wpos = f->wbase = f->wend = 0;
16 f->rpos = f->rend = 0;
17
18 return 0;
19 }
20
21 /* stdout.c will override this if linked */
22 static FILE *volatile dummy = 0;
23 weak_alias(dummy, __stdout_used);
24
25 int fflush(FILE *f)
26 {
27 int r;
28
29 if (f) {
30 FLOCK(f);
31 r = __fflush_unlocked(f);
32 FUNLOCK(f);
33 return r;
34 }
35
36 r = __stdout_used ? fflush(__stdout_used) : 0;
37
38 for (f=*__ofl_lock(); f; f=f->next) {
39 FLOCK(f);
40 if (f->wpos > f->wbase) r |= __fflush_unlocked(f);
41 FUNLOCK(f);
42 }
43 __ofl_unlock();
44
45 return r;
46 }
47
48 weak_alias(__fflush_unlocked, fflush_unlocked);
OLDNEW
« no previous file with comments | « fusl/src/stdio/ferror.c ('k') | fusl/src/stdio/fgetc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698