Refactor use of __ANDROID__ macro
We use the __ANDROID__ macro, which is provided by the toolchain, in
numerous places. This patch refactors the usage of this by defining a
new macro, ART_TARGET_ANDROID, that is being passed during build to
ART_TARGET_CFLAGS in Android.common_build.mk on the same line as
ART_TARGET. The codebase currently assumes that the existence of the
__ANDROID__ macro implies that we are compiling art for an android
target device. This is because, currently, target builds are compiled
with target toolchains that provide the macro, while host toolchains
do not. With this change this assumption is still preserved. However,
in a future patch we will add the ability to compile art for a linux
target, and in that case the ART_TARGET_ANDROID macro won't be passed
anymore.
Change-Id: I1f3a811aa735c87087d812da27fc6b08f01bad51
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index ccb8b29..ae84019 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -28,7 +28,7 @@
#include <sstream>
// dlopen_ext support from bionic.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "android/dlext.h"
#endif
@@ -623,7 +623,7 @@
*error_msg = StringPrintf("Failed to find absolute path for '%s'", elf_filename.c_str());
return false;
}
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
android_dlextinfo extinfo;
extinfo.flags = ANDROID_DLEXT_FORCE_LOAD | // Force-load, don't reuse handle
// (open oat files multiple
@@ -638,7 +638,7 @@
#else
dlopen_handle_ = dlopen(absolute_path.get(), RTLD_NOW);
UNUSED(oat_file_begin);
-#endif
+#endif // ART_TARGET_ANDROID
}
if (dlopen_handle_ == nullptr) {
*error_msg = StringPrintf("Failed to dlopen '%s': %s", elf_filename.c_str(), dlerror());