ART: Replace ScopedFd with FdFile
FdFile can now be used like ScopedFd. Remove ScopedFd.
Bug: 21192156
Test: m test-art-host
Test: m test-art-target (shamu)
Change-Id: I32115fa8b2b8bb5aa5d1886eae63522f80ce836b
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index c047ba2..bb07fcb 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -25,12 +25,8 @@
#include <sstream>
#include "base/stringprintf.h"
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wshadow"
-#include "ScopedFd.h"
-#pragma GCC diagnostic pop
-
+#include "base/unix_file/fd_file.h"
+#include "os.h"
#include "thread-inl.h"
#include "utils.h"
@@ -301,7 +297,7 @@
flags |= MAP_FIXED;
}
- ScopedFd fd(-1);
+ File fd;
if (use_ashmem) {
if (!kIsTargetBuild) {
@@ -320,8 +316,9 @@
// prefixed "dalvik-".
std::string debug_friendly_name("dalvik-");
debug_friendly_name += name;
- fd.reset(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count));
- if (fd.get() == -1) {
+ fd.Reset(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count),
+ /* check_usage */ false);
+ if (fd.Fd() == -1) {
*error_msg = StringPrintf("ashmem_create_region failed for '%s': %s", name, strerror(errno));
return nullptr;
}
@@ -335,7 +332,7 @@
page_aligned_byte_count,
prot,
flags,
- fd.get(),
+ fd.Fd(),
0,
low_4gb);
saved_errno = errno;
@@ -352,7 +349,7 @@
page_aligned_byte_count,
prot,
flags,
- fd.get(),
+ fd.Fd(),
strerror(saved_errno));
}
return nullptr;
@@ -558,7 +555,7 @@
return nullptr;
}
}
- ScopedFd fd(int_fd);
+ File fd(int_fd, /* check_usage */ false);
MEMORY_TOOL_MAKE_UNDEFINED(tail_base_begin, tail_base_size);
// Unmap/map the tail region.
@@ -574,12 +571,12 @@
// region. Note this isn't perfect as there's no way to prevent
// other threads to try to take this memory region here.
uint8_t* actual = reinterpret_cast<uint8_t*>(mmap(tail_base_begin, tail_base_size, tail_prot,
- flags, fd.get(), 0));
+ flags, fd.Fd(), 0));
if (actual == MAP_FAILED) {
PrintFileToLog("/proc/self/maps", LogSeverity::WARNING);
*error_msg = StringPrintf("anonymous mmap(%p, %zd, 0x%x, 0x%x, %d, 0) failed. See process "
"maps in the log.", tail_base_begin, tail_base_size, tail_prot, flags,
- fd.get());
+ fd.Fd());
return nullptr;
}
return new MemMap(tail_name, actual, tail_size, actual, tail_base_size, tail_prot, false);