summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c')
-rw-r--r--libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c b/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c
new file mode 100644
index 0000000..d6f8851
--- /dev/null
+++ b/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.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 pwritev(int fildes, const struct iovec *iov, int iovcnt, off_t offset) {
+ if (iovcnt < 0 || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ size_t bytes_written;
+ __wasi_errno_t error = __wasi_fd_pwrite(
+ fildes, (const __wasi_ciovec_t *)iov, iovcnt, offset, &bytes_written);
+ if (error != 0) {
+ errno = error;
+ return -1;
+ }
+ return bytes_written;
+}