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

Side by Side Diff: bin/fdutils_linux.cc

Issue 9194002: Fix failure (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | bin/fdutils_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/ioctl.h> 8 #include <sys/ioctl.h>
9 9
10 #include "bin/fdutils.h" 10 #include "bin/fdutils.h"
(...skipping 21 matching lines...) Expand all
32 if (status < 0) { 32 if (status < 0) {
33 perror("fcntl F_GETFL failed"); 33 perror("fcntl F_GETFL failed");
34 return false; 34 return false;
35 } 35 }
36 *is_blocking = (status & O_NONBLOCK) == 0; 36 *is_blocking = (status & O_NONBLOCK) == 0;
37 return true; 37 return true;
38 } 38 }
39 39
40 40
41 intptr_t FDUtils::AvailableBytes(intptr_t fd) { 41 intptr_t FDUtils::AvailableBytes(intptr_t fd) {
42 size_t available; 42 int available; // ioctl for FIONREAD expects an 'int*' argument.
43 int result = TEMP_FAILURE_RETRY(ioctl(fd, FIONREAD, &available)); 43 int result = TEMP_FAILURE_RETRY(ioctl(fd, FIONREAD, &available));
44 if (result < 0) { 44 if (result < 0) {
45 return result; 45 return result;
46 } 46 }
47 return available; 47 #ifdef DEBUG
48 ASSERT(available >= 0);
49 #endif
50 return static_cast<intptr_t>(available);
48 } 51 }
49 52
50 53
51 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { 54 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) {
52 #ifdef DEBUG 55 #ifdef DEBUG
53 bool is_blocking = false; 56 bool is_blocking = false;
54 ASSERT(FDUtils::IsBlocking(fd, &is_blocking)); 57 ASSERT(FDUtils::IsBlocking(fd, &is_blocking));
55 ASSERT(is_blocking); 58 ASSERT(is_blocking);
56 #endif 59 #endif
57 size_t remaining = count; 60 size_t remaining = count;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT(errno != EWOULDBLOCK); 99 ASSERT(errno != EWOULDBLOCK);
97 return -1; 100 return -1;
98 } else { 101 } else {
99 ASSERT(bytes_written > 0); 102 ASSERT(bytes_written > 0);
100 remaining -= bytes_written; 103 remaining -= bytes_written;
101 buffer_pos += bytes_written; 104 buffer_pos += bytes_written;
102 } 105 }
103 } 106 }
104 return count; 107 return count;
105 } 108 }
OLDNEW
« no previous file with comments | « no previous file | bin/fdutils_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698