Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: ports/glibc-compat/src/writev.c

Issue 1260083004: Add needed functions to glibc-compat for pkg (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: fix wrong c++ lib Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ports/glibc-compat/src/timegm.c ('k') | ports/gtk+/build.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ports/glibc-compat/src/writev.c
diff --git a/ports/glibc-compat/src/writev.c b/ports/glibc-compat/src/writev.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc33dd1f8593cb5021eb1f3046d1257df537d459
--- /dev/null
+++ b/ports/glibc-compat/src/writev.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2015 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <unistd.h>
+#include <sys/uio.h>
+#include <errno.h>
+
+int writev(int fd, const struct iovec *iov, int iovcnt) {
+ int i = 0, ret = 0, n = 0, len = 0;
+ char* base;
+ errno = 0;
+ while (i < iovcnt) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ ret = write(fd, base, len);
+ if (ret < 0 && n == 0) return -1;
+ if (ret <= 0) return n;
+ errno = 0;
+ n += ret;
+ len -= ret;
+ base += ret;
+ }
+ iov++;
+ i++;
+ }
+ return n;
+}
+
+ssize_t readv(int fd, const struct iovec *iov, int iovcnt) {
+ int i = 0, ret = 0, n = 0, len = 0;
+ char* base;
+ errno = 0;
+ while (i < iovcnt) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ ret = read(fd, base, len);
+ if (ret < 0 && n == 0) return -1;
+ if (ret <= 0) return n;
+ errno = 0;
+ n += ret;
+ len -= ret;
+ base += ret;
+ }
+ iov++;
+ i++;
+ }
+ return n;
+}
« no previous file with comments | « ports/glibc-compat/src/timegm.c ('k') | ports/gtk+/build.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698