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

Side by Side Diff: fusl/src/stdio/ftell.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/fsetpos.c ('k') | fusl/src/stdio/ftrylockfile.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 #include <limits.h>
3 #include <errno.h>
4
5 off_t __ftello_unlocked(FILE *f)
6 {
7 off_t pos = f->seek(f, 0,
8 (f->flags & F_APP) && f->wpos > f->wbase
9 ? SEEK_END : SEEK_CUR);
10 if (pos < 0) return pos;
11
12 /* Adjust for data in buffer. */
13 return pos - (f->rend - f->rpos) + (f->wpos - f->wbase);
14 }
15
16 off_t __ftello(FILE *f)
17 {
18 off_t pos;
19 FLOCK(f);
20 pos = __ftello_unlocked(f);
21 FUNLOCK(f);
22 return pos;
23 }
24
25 long ftell(FILE *f)
26 {
27 off_t pos = __ftello(f);
28 if (pos > LONG_MAX) {
29 errno = EOVERFLOW;
30 return -1;
31 }
32 return pos;
33 }
34
35 weak_alias(__ftello, ftello);
36
37 LFS64(ftello);
OLDNEW
« no previous file with comments | « fusl/src/stdio/fsetpos.c ('k') | fusl/src/stdio/ftrylockfile.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698