Chromium Code Reviews| Index: runtime/bin/fdutils_fuchsia.cc |
| diff --git a/runtime/bin/fdutils_android.cc b/runtime/bin/fdutils_fuchsia.cc |
| similarity index 89% |
| copy from runtime/bin/fdutils_android.cc |
| copy to runtime/bin/fdutils_fuchsia.cc |
| index 5d8a8e004c301b150914899ff580c167d7c7a701..9ebf5a02542c1ef7e9981b2fe3fe777a244a3f26 100644 |
| --- a/runtime/bin/fdutils_android.cc |
| +++ b/runtime/bin/fdutils_fuchsia.cc |
| @@ -3,7 +3,7 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| #include "platform/globals.h" |
| -#if defined(TARGET_OS_ANDROID) |
| +#if defined(TARGET_OS_FUCHSIA) |
| #include "bin/fdutils.h" |
| @@ -71,6 +71,8 @@ bool FDUtils::IsBlocking(intptr_t fd, bool* is_blocking) { |
| intptr_t FDUtils::AvailableBytes(intptr_t fd) { |
| + // TODO(MG-364): Enable this code when it is supported. |
| +#if 0 |
| int available; // ioctl for FIONREAD expects an 'int*' argument. |
| int result = NO_RETRY_EXPECTED(ioctl(fd, FIONREAD, &available)); |
|
zra
2016/11/18 23:42:17
Here is the ioctl call for Fuchsia.
|
| if (result < 0) { |
| @@ -78,6 +80,9 @@ intptr_t FDUtils::AvailableBytes(intptr_t fd) { |
| } |
| ASSERT(available >= 0); |
| return static_cast<intptr_t>(available); |
| +#endif |
|
siva
2016/11/21 02:22:41
Can this be turned on, as the ioctl change has bee
zra
2016/11/21 05:56:24
The change to the syscall needed to support the io
|
| + errno = ENOTSUP; |
| + return -1; |
| } |
| @@ -90,7 +95,7 @@ ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) { |
| size_t remaining = count; |
| char* buffer_pos = reinterpret_cast<char*>(buffer); |
| while (remaining > 0) { |
| - ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer_pos, remaining)); |
| + ssize_t bytes_read = NO_RETRY_EXPECTED(read(fd, buffer_pos, remaining)); |
| if (bytes_read == 0) { |
| return count - remaining; |
| } else if (bytes_read == -1) { |
| @@ -119,7 +124,7 @@ ssize_t FDUtils::WriteToBlocking(int fd, const void* buffer, size_t count) { |
| char* buffer_pos = const_cast<char*>(reinterpret_cast<const char*>(buffer)); |
| while (remaining > 0) { |
| ssize_t bytes_written = |
| - TEMP_FAILURE_RETRY(write(fd, buffer_pos, remaining)); |
| + NO_RETRY_EXPECTED(write(fd, buffer_pos, remaining)); |
| if (bytes_written == 0) { |
| return count - remaining; |
| } else if (bytes_written == -1) { |
| @@ -137,7 +142,14 @@ ssize_t FDUtils::WriteToBlocking(int fd, const void* buffer, size_t count) { |
| return count; |
| } |
| + |
| +void FDUtils::SaveErrorAndClose(intptr_t fd) { |
| + int err = errno; |
| + NO_RETRY_EXPECTED(close(fd)); |
| + errno = err; |
| +} |
| + |
| } // namespace bin |
| } // namespace dart |
| -#endif // defined(TARGET_OS_ANDROID) |
| +#endif // defined(TARGET_OS_FUCHSIA) |