major stdio overhaul, using readv/writev, plus other changes
[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         errno = ESPIPE;
6         return -1;
7 }
8
9 off_t __stdio_seek(FILE *f, off_t off, int whence)
10 {
11         off_t ret;
12 #ifdef SYS__llseek
13         if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
14                 ret = -1;
15 #else
16         ret = syscall(SYS_lseek, f->fd, off, whence);
17 #endif
18         /* Detect unseekable files and optimize future failures out */
19         if (ret < 0 && errno == ESPIPE) f->seek = retneg1;
20         return ret;
21 }