| Index: runtime/bin/fdutils_fuchsia.cc
|
| diff --git a/runtime/bin/fdutils_android.cc b/runtime/bin/fdutils_fuchsia.cc
|
| similarity index 88%
|
| copy from runtime/bin/fdutils_android.cc
|
| copy to runtime/bin/fdutils_fuchsia.cc
|
| index 5d8a8e004c301b150914899ff580c167d7c7a701..dd9e881c8d58ce1a91564b04585d0dbf263b3cfc 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));
|
| if (result < 0) {
|
| @@ -78,6 +80,9 @@ intptr_t FDUtils::AvailableBytes(intptr_t fd) {
|
| }
|
| ASSERT(available >= 0);
|
| return static_cast<intptr_t>(available);
|
| +#endif
|
| + 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) {
|
| @@ -118,8 +123,7 @@ ssize_t FDUtils::WriteToBlocking(int fd, const void* buffer, size_t count) {
|
| size_t remaining = 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));
|
| + ssize_t bytes_written = NO_RETRY_EXPECTED(write(fd, buffer_pos, remaining));
|
| if (bytes_written == 0) {
|
| return count - remaining;
|
| } else if (bytes_written == -1) {
|
| @@ -137,7 +141,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)
|
|
|