From 0f30d227497418c6d3bef7d52244407e30454504 Mon Sep 17 00:00:00 2001 From: Kacper Date: Mon, 22 Dec 2025 23:27:56 +0100 Subject: Added c11 threads, fixed some locks and add *_unlocked functions --- lib/libc/stdio/fseek.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/libc/stdio/fseek.c') diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index 7a6754f7..19459e7f 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -7,24 +7,21 @@ int fseek(FILE *stream, long offset, int whence) { - if (stream == NULL || __FILE(stream)->fd < 0) + if (stream == NULL || stream->fd < 0) return -1; - LIBC_LOCK(__FILE(stream)->lock); + stream->buf_pos = 0; + stream->buf_len = 0; + stream->flags &= ~_IO_EOF; - __FILE(stream)->buf_pos = 0; - __FILE(stream)->buf_len = 0; - __FILE(stream)->flags &= ~_IO_EOF; - - off_t result = lseek(__FILE(stream)->fd, offset, whence); - - LIBC_UNLOCK(__FILE(stream)->lock); + off_t result = lseek(stream->fd, offset, whence); if (result == (off_t)-1) { - __FILE(stream)->flags |= _IO_ERR; + stream->flags |= _IO_ERR; return -1; } - __FILE(stream)->offset = result; + stream->offset = result; + return 0; } -- cgit v1.2.3