OLD | NEW |
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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
7 | 7 |
8 #include "bin/fdutils.h" | 8 #include "bin/fdutils.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 *is_blocking = (status & O_NONBLOCK) == 0; | 68 *is_blocking = (status & O_NONBLOCK) == 0; |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 intptr_t FDUtils::AvailableBytes(intptr_t fd) { | 73 intptr_t FDUtils::AvailableBytes(intptr_t fd) { |
74 int available; // ioctl for FIONREAD expects an 'int*' argument. | 74 int available; // ioctl for FIONREAD expects an 'int*' argument. |
75 int result = NO_RETRY_EXPECTED(ioctl(fd, FIONREAD, &available)); | 75 int result = NO_RETRY_EXPECTED(ioctl(fd, FIONREAD, &available)); |
76 if (result < 0) { | 76 if (result < 0) { |
| 77 perror("ioctl(fd, FIONREAD, &available) failed"); |
77 return result; | 78 return result; |
78 } | 79 } |
79 ASSERT(available >= 0); | 80 ASSERT(available >= 0); |
80 return static_cast<intptr_t>(available); | 81 return static_cast<intptr_t>(available); |
81 } | 82 } |
82 | 83 |
83 | 84 |
84 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { | 85 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { |
85 #ifdef DEBUG | 86 #ifdef DEBUG |
86 bool is_blocking = false; | 87 bool is_blocking = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void FDUtils::SaveErrorAndClose(intptr_t fd) { | 141 void FDUtils::SaveErrorAndClose(intptr_t fd) { |
141 int err = errno; | 142 int err = errno; |
142 NO_RETRY_EXPECTED(close(fd)); | 143 NO_RETRY_EXPECTED(close(fd)); |
143 errno = err; | 144 errno = err; |
144 } | 145 } |
145 | 146 |
146 } // namespace bin | 147 } // namespace bin |
147 } // namespace dart | 148 } // namespace dart |
148 | 149 |
149 #endif // defined(TARGET_OS_FUCHSIA) | 150 #endif // defined(TARGET_OS_FUCHSIA) |
OLD | NEW |