global cleanup to use the new syscall interface
[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;
11 #ifdef SYS__llseek
12         if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
13                 ret = -1;
14 #else
15         ret = syscall(SYS_lseek, f->fd, off, whence);
16 #endif
17         /* Detect unseekable files and optimize future failures out */
18         if (ret < 0 && off == 0 && whence == SEEK_CUR)
19                 f->seek = retneg1;
20         return ret;
21 }