From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- lib/libc/stdio/fseek.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/libc/stdio/fseek.c (limited to 'lib/libc/stdio/fseek.c') diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c new file mode 100644 index 00000000..af12cd2c --- /dev/null +++ b/lib/libc/stdio/fseek.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +int fseek(FILE *stream, long offset, int whence) +{ + if (stream == NULL || stream->fd < 0) + return -1; + + LIBC_LOCK(stream->lock); + + stream->buf_pos = 0; + stream->buf_len = 0; + stream->flags &= ~_IO_EOF; + + off_t result = lseek(stream->fd, offset, whence); + + LIBC_UNLOCK(stream->lock); + + if (result == (off_t)-1) { + stream->flags |= _IO_ERR; + return -1; + } + + stream->offset = result; + return 0; +} -- cgit v1.2.3