initial check-in, version 0.5.0
[musl] / src / stdio / __stdio_seek.c
1 #include "stdio_impl.h"
2
3 static off_t retneg1(FILE *f, off_t off, int whence)
4 {
5         return -1;
6 }
7
8 off_t __stdio_seek(FILE *f, off_t off, int whence)
9 {
10         off_t ret = __syscall_lseek(f->fd, off, whence);
11         /* Detect unseekable files and optimize future failures out */
12         if (ret < 0 && off == 0 && whence == SEEK_CUR)
13                 f->seek = retneg1;
14         return ret;
15 }