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

Side by Side Diff: fusl/src/stdio/fseek.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/fscanf.c ('k') | fusl/src/stdio/fsetpos.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 int __fseeko_unlocked(FILE *f, off_t off, int whence)
4 {
5 /* Adjust relative offset for unread data in buffer, if any. */
6 if (whence == SEEK_CUR) off -= f->rend - f->rpos;
7
8 /* Flush write buffer, and report error on failure. */
9 if (f->wpos > f->wbase) {
10 f->write(f, 0, 0);
11 if (!f->wpos) return -1;
12 }
13
14 /* Leave writing mode */
15 f->wpos = f->wbase = f->wend = 0;
16
17 /* Perform the underlying seek. */
18 if (f->seek(f, off, whence) < 0) return -1;
19
20 /* If seek succeeded, file is seekable and we discard read buffer. */
21 f->rpos = f->rend = 0;
22 f->flags &= ~F_EOF;
23
24 return 0;
25 }
26
27 int __fseeko(FILE *f, off_t off, int whence)
28 {
29 int result;
30 FLOCK(f);
31 result = __fseeko_unlocked(f, off, whence);
32 FUNLOCK(f);
33 return result;
34 }
35
36 int fseek(FILE *f, long off, int whence)
37 {
38 return __fseeko(f, off, whence);
39 }
40
41 weak_alias(__fseeko, fseeko);
42
43 LFS64(fseeko);
OLDNEW
« no previous file with comments | « fusl/src/stdio/fscanf.c ('k') | fusl/src/stdio/fsetpos.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698