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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6 #include <unistd.h>
7 #include <sys/uio.h>
8 #include <errno.h>
9
10 int writev(int fd, const struct iovec *iov, int iovcnt) {
11 int i = 0, ret = 0, n = 0, len = 0;
12 char* base;
13 errno = 0;
14 while (i < iovcnt) {
15 len = iov->iov_len;
16 base = iov->iov_base;
17 while (len > 0) {
18 ret = write(fd, base, len);
19 if (ret < 0 && n == 0) return -1;
20 if (ret <= 0) return n;
21 errno = 0;
22 n += ret;
23 len -= ret;
24 base += ret;
25 }
26 iov++;
27 i++;
28 }
29 return n;
30 }
31
32 ssize_t readv(int fd, const struct iovec *iov, int iovcnt) {
Sam Clegg 2015/07/28 00:14:13 It looks like it might be possible to remove some
zhitingzhu 2015/07/28 02:05:41 Done.
33 int i = 0, ret = 0, n = 0, len = 0;
34 char* base;
35 errno = 0;
36 while (i < iovcnt) {
37 len = iov->iov_len;
38 base = iov->iov_base;
39 while (len > 0) {
40 ret = read(fd, base, len);
41 if (ret < 0 && n == 0) return -1;
42 if (ret <= 0) return n;
43 errno = 0;
44 n += ret;
45 len -= ret;
46 base += ret;
47 }
48 iov++;
49 i++;
50 }
51 return n;
52 }
OLDNEW
« ports/glibc-compat/src/timegm.c ('K') | « ports/glibc-compat/src/timegm.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698