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

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

Issue 1226403004: Added (libevent,tor) and modified glibc-compat (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Resolved critical issues in libevent Created 5 years, 4 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/readv.c ('k') | ports/libevent/README » ('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..9f7924379f56b5a45c5f15e64ee0cc02fe74f2f7
--- /dev/null
+++ b/ports/glibc-compat/src/writev.c
@@ -0,0 +1,29 @@
+/* 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 <sys/uio.h>
+#include <unistd.h> // unix(nacl) standards
+#include <errno.h>
+
+ssize_t writev(int fd,const struct iovec *iov,int iovcnt){
+ if(iovcnt < 0){
+ // #TODO(dt) add check for IOV_MAX
+ errno = EINVAL;
+ return -1;
+ }
+ ssize_t bytes_written = 0 ;
+ ssize_t bytes_supposed_to_be_written = 0 ;
+ int i;
+ for (i = 0; i < (iovcnt); i++) {
+ bytes_written += write(fd, iov[i].iov_base, iov[i].iov_len);
+ bytes_supposed_to_be_written += iov[i].iov_len ;
+ // #TODO(dt) add check for (max) ssize_t allowed
+ if (bytes_written != bytes_supposed_to_be_written){
+ // deliberately not setting errno here as it might override
+ // errno set by write(...)
+ return -1;
+ }
+ }
+ return bytes_written;
+}
« no previous file with comments | « ports/glibc-compat/src/readv.c ('k') | ports/libevent/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698