| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 64   status = NO_RETRY_EXPECTED(fcntl(fd, F_GETFL)); | 64   status = NO_RETRY_EXPECTED(fcntl(fd, F_GETFL)); | 
| 65   if (status < 0) { | 65   if (status < 0) { | 
| 66     return false; | 66     return false; | 
| 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 // TODO(MG-364): Enable this code when it is supported. |  | 
| 75 #if 0 |  | 
| 76   int available;  // ioctl for FIONREAD expects an 'int*' argument. | 74   int available;  // ioctl for FIONREAD expects an 'int*' argument. | 
| 77   int result = NO_RETRY_EXPECTED(ioctl(fd, FIONREAD, &available)); | 75   int result = NO_RETRY_EXPECTED(ioctl(fd, FIONREAD, &available)); | 
| 78   if (result < 0) { | 76   if (result < 0) { | 
| 79     return result; | 77     return result; | 
| 80   } | 78   } | 
| 81   ASSERT(available >= 0); | 79   ASSERT(available >= 0); | 
| 82   return static_cast<intptr_t>(available); | 80   return static_cast<intptr_t>(available); | 
| 83 #endif |  | 
| 84   errno = ENOTSUP; |  | 
| 85   return -1; |  | 
| 86 } | 81 } | 
| 87 | 82 | 
| 88 | 83 | 
| 89 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { | 84 ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { | 
| 90 #ifdef DEBUG | 85 #ifdef DEBUG | 
| 91   bool is_blocking = false; | 86   bool is_blocking = false; | 
| 92   ASSERT(FDUtils::IsBlocking(fd, &is_blocking)); | 87   ASSERT(FDUtils::IsBlocking(fd, &is_blocking)); | 
| 93   ASSERT(is_blocking); | 88   ASSERT(is_blocking); | 
| 94 #endif | 89 #endif | 
| 95   size_t remaining = count; | 90   size_t remaining = count; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 145 void FDUtils::SaveErrorAndClose(intptr_t fd) { | 140 void FDUtils::SaveErrorAndClose(intptr_t fd) { | 
| 146   int err = errno; | 141   int err = errno; | 
| 147   NO_RETRY_EXPECTED(close(fd)); | 142   NO_RETRY_EXPECTED(close(fd)); | 
| 148   errno = err; | 143   errno = err; | 
| 149 } | 144 } | 
| 150 | 145 | 
| 151 }  // namespace bin | 146 }  // namespace bin | 
| 152 }  // namespace dart | 147 }  // namespace dart | 
| 153 | 148 | 
| 154 #endif  // defined(TARGET_OS_FUCHSIA) | 149 #endif  // defined(TARGET_OS_FUCHSIA) | 
| OLD | NEW | 
|---|