diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c | |
parent | Initial commit. (diff) | |
download | wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c')
-rw-r--r-- | libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c b/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c new file mode 100644 index 0000000..36f882d --- /dev/null +++ b/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c @@ -0,0 +1,24 @@ +// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ +// +// SPDX-License-Identifier: BSD-2-Clause + +#include <sys/types.h> +#include <sys/uio.h> + +#include <wasi/api.h> +#include <errno.h> + +ssize_t preadv(int fildes, const struct iovec *iov, int iovcnt, off_t offset) { + if (iovcnt < 0 || offset < 0) { + errno = EINVAL; + return -1; + } + size_t bytes_read; + __wasi_errno_t error = __wasi_fd_pread( + fildes, (const __wasi_iovec_t *)iov, iovcnt, offset, &bytes_read); + if (error != 0) { + errno = error; + return -1; + } + return bytes_read; +} |