1 #include "stdio_impl.h"
3 int __fseeko_unlocked(FILE *f, off_t off, int whence)
5 /* Adjust relative offset for unread data in buffer, if any. */
6 if (whence == SEEK_CUR) off -= f->rend - f->rpos;
8 /* If writing, flush output. */
9 if (f->wpos > f->buf && __oflow(f)) return -1;
11 /* Perform the underlying seek operation. */
12 if (f->seek(f, off, whence) < 0) return -1;
14 /* If seek succeeded, file is seekable and we discard read buffer. */
15 f->rpos = f->rend = f->rstop = 0;
22 int __fseeko(FILE *f, off_t off, int whence)
26 result = __fseeko_unlocked(f, off, whence);
31 int fseek(FILE *f, long off, int whence)
33 return __fseeko(f, off, whence);
36 weak_alias(__fseeko, fseeko);