diff options
Diffstat (limited to 'lib/libc/stdio/fseek.c')
| -rw-r--r-- | lib/libc/stdio/fseek.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index af12cd2c..0e425e8e 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -1,28 +1,31 @@ -#include <unistd.h> -#include <io.h> -#include <stdio.h> -#include <atomic.h> +#include "__stdio.h" // for _IO_EOF, _IO_ERR +#include "stddef.h" // for NULL + +#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK +#include <libc.h> // for __IMPL +#include <stdio.h> // for FILE, fseek +#include <unistd.h> // for lseek, off_t int fseek(FILE *stream, long offset, int whence) { - if (stream == NULL || stream->fd < 0) + if (stream == NULL || __IMPL(stream)->fd < 0) return -1; - LIBC_LOCK(stream->lock); + LIBC_LOCK(__IMPL(stream)->lock); - stream->buf_pos = 0; - stream->buf_len = 0; - stream->flags &= ~_IO_EOF; + __IMPL(stream)->buf_pos = 0; + __IMPL(stream)->buf_len = 0; + __IMPL(stream)->flags &= ~_IO_EOF; - off_t result = lseek(stream->fd, offset, whence); + off_t result = lseek(__IMPL(stream)->fd, offset, whence); - LIBC_UNLOCK(stream->lock); + LIBC_UNLOCK(__IMPL(stream)->lock); if (result == (off_t)-1) { - stream->flags |= _IO_ERR; + __IMPL(stream)->flags |= _IO_ERR; return -1; } - stream->offset = result; + __IMPL(stream)->offset = result; return 0; } |
