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

Unified Diff: runtime/bin/fdutils_fuchsia.cc

Issue 2515643004: Fuchsia: Partial implementation of dart:io sockets (Closed)
Patch Set: Formatting Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/fdutils_android.cc ('k') | runtime/bin/fdutils_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « runtime/bin/fdutils_android.cc ('k') | runtime/bin/fdutils_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698