ifndef LIBART_IMG_TARGET_BASE_ADDRESS
$(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
endif
-ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
+# The ART_TARGET_ANDROID macro is passed to target builds, which check
+# against it instead of against __ANDROID__ (which is provided by target
+# toolchains).
+ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_TARGET_ANDROID \
+ -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
+
ART_TARGET_CFLAGS += $(art_target_cflags)
ART_TARGET_ASFLAGS += $(art_asflags)
namespace dwarf {
// Run the tests only on host since we need objdump.
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
constexpr CFIFormat kCFIFormat = DW_DEBUG_FRAME_FORMAT;
CheckObjdumpOutput(is64bit, "-W");
}
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
} // namespace dwarf
} // namespace art
size_t thread_count = compiler_driver_->GetThreadCount();
if (compiler_options_->GetGenerateDebugInfo()) {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
const char* prefix = "/data/misc/trace";
#else
const char* prefix = "/tmp";
namespace art {
// Run the tests only on host.
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
class JNICFITest : public CFITest {
public:
TEST_ISA(kMips)
TEST_ISA(kMips64)
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
} // namespace art
namespace art {
// Run the tests only on host.
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
class OptimizingCFITest : public CFITest {
public:
Check(kMips64, "kMips64_adjust", expected_asm, expected_cfi);
}
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
} // namespace art
// Include results file (generated manually)
#include "assembler_thumb_test_expected.cc.inc"
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
// This controls whether the results are printed to the
// screen or compared against the expected output.
// To generate new expected output, set this to true and
}
std::string GetToolsDir() {
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
// This will only work on the host. There is no as, objcopy or objdump on the device.
static std::string toolsdir;
}
void DumpAndCheck(std::vector<uint8_t>& code, const char* testname, const char* const* results) {
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
static std::string toolsdir = GetToolsDir();
ScratchFile file;
snprintf(buf, sizeof(buf), "%s.oo", filename);
unlink(buf);
-#endif
+#endif // ART_TARGET_ANDROID
}
#define __ assembler->
ASSERT_EQ(static_cast<size_t>(5), buffer.Size());
}
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
static constexpr size_t kRandomIterations = 1000; // Devices might be puny, don't stress them...
#else
static constexpr size_t kRandomIterations = 100000; // Hosts are pretty powerful.
#include "instruction_set_features_arm.h"
-#if defined(__ANDROID__) && defined(__arm__)
+#if defined(ART_TARGET_ANDROID) && defined(__arm__)
#include <sys/auxv.h>
#include <asm/hwcap.h>
#endif
bool has_div = false;
bool has_lpae = false;
-#if defined(__ANDROID__) && defined(__arm__)
+#if defined(ART_TARGET_ANDROID) && defined(__arm__)
uint64_t hwcaps = getauxval(AT_HWCAP);
LOG(INFO) << "hwcaps=" << hwcaps;
if ((hwcaps & HWCAP_IDIVT) != 0) {
#include <gtest/gtest.h>
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "cutils/properties.h"
#endif
namespace art {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#if defined(__aarch64__)
TEST(InstructionSetFeaturesTest, DISABLED_FeaturesFromSystemPropertyVariant) {
LOG(WARNING) << "Test disabled due to no CPP define for A53 erratum 835769";
}
#endif
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
TEST(InstructionSetFeaturesTest, HostFeaturesFromCppDefines) {
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> default_features(
#include "utils.h"
// Headers for LogMessage::LogLine.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "cutils/log.h"
#else
#include <sys/types.h>
// Print INTERNAL_FATAL messages directly instead of at destruction time. This only works on the
// host right now: for the device, a stream buf collating output into lines and calling LogLine or
// lower-level logging is necessary.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
static constexpr bool kPrintInternalFatalDirectly = false;
#else
static constexpr bool kPrintInternalFatalDirectly = !kIsTargetBuild;
return data_->GetBuffer();
}
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
static const android_LogPriority kLogSeverityToAndroidLogPriority[] = {
ANDROID_LOG_VERBOSE, // NONE, use verbose as stand-in, will never be printed.
ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN,
return;
}
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
const char* tag = ProgramInvocationShortName();
int priority = kLogSeverityToAndroidLogPriority[static_cast<size_t>(log_severity)];
if (priority == ANDROID_LOG_FATAL) {
return;
}
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// Use android_writeLog() to avoid stack-based buffers used by android_printLog().
const char* tag = ProgramInvocationShortName();
int priority = kLogSeverityToAndroidLogPriority[static_cast<size_t>(log_severity)];
TEMP_FAILURE_RETRY(write(STDERR_FILENO, "] ", 2));
TEMP_FAILURE_RETRY(write(STDERR_FILENO, message, strlen(message)));
TEMP_FAILURE_RETRY(write(STDERR_FILENO, "\n", 1));
-#endif
+#endif // ART_TARGET_ANDROID
}
ScopedLogSeverity::ScopedLogSeverity(LogSeverity level) {
#include "base/stl_util.h"
#include "stack.h"
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "cutils/properties.h"
#endif
}
void AllocRecordObjectMap::SetProperties() {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// Check whether there's a system property overriding the max number of records.
const char* propertyName = "dalvik.vm.allocTrackerMax";
char allocMaxString[PROPERTY_VALUE_MAX];
max_stack_depth_ = value;
}
}
-#endif
+#endif // ART_TARGET_ANDROID
}
AllocRecordObjectMap::~AllocRecordObjectMap() {
#include "../../external/dlmalloc/malloc.h"
#pragma GCC diagnostic pop
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// Define dlmalloc routines from bionic that cannot be included directly because of redefining
// symbols from the include above.
extern "C" void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), void* arg);
// First mark slots to free in the bulk free bit map without locking the
// size bracket locks. On host, unordered_set is faster than vector + flag.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
std::vector<Run*> runs;
#else
std::unordered_set<Run*, hash_run, eq_run> runs;
DCHECK_EQ(run->magic_num_, kMagicNum);
// Set the bit in the bulk free bit map.
freed_bytes += run->AddToBulkFreeList(ptr);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
if (!run->to_be_bulk_freed_) {
run->to_be_bulk_freed_ = true;
runs.push_back(run);
// union the bulk free bit map into the thread-local free bit map
// (for thread-local runs.)
for (Run* run : runs) {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
DCHECK(run->to_be_bulk_freed_);
run->to_be_bulk_freed_ = false;
#endif
#include "base/stringprintf.h"
#include "jdwp/jdwp_priv.h"
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "cutils/sockets.h"
#endif
*/
int ret = connect(control_sock_, &control_addr_.controlAddrPlain, control_addr_len_);
if (!ret) {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
if (!socket_peer_is_trusted(control_sock_)) {
if (shutdown(control_sock_, SHUT_RDWR)) {
PLOG(ERROR) << "trouble shutting down socket";
case kJdwpTransportSocket:
InitSocketTransport(state.get(), options);
break;
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
case kJdwpTransportAndroidAdb:
InitAdbTransport(state.get(), options);
break;
#include "dalvik_system_VMRuntime.h"
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
extern "C" void android_set_application_target_sdk_version(uint32_t version);
#endif
#include <limits.h>
// Note that targetSdkVersion may be 0, meaning "current".
Runtime::Current()->SetTargetSdkVersion(target_sdk_version);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// This part is letting libc/dynamic linker know about current app's
// target sdk version to enable compatibility workarounds.
android_set_application_target_sdk_version(static_cast<uint32_t>(target_sdk_version));
#include <sstream>
// dlopen_ext support from bionic.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include "android/dlext.h"
#endif
*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
#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());
#include <sys/socket.h>
#include <sys/ioctl.h>
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// This function is provided by android linker.
extern "C" void android_update_LD_LIBRARY_PATH(const char* ld_library_path);
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
#undef LOG_TAG
#define LOG_TAG "artopenjdk"
}
static void SetLdLibraryPath(JNIEnv* env, jstring javaLdLibraryPath) {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
if (javaLdLibraryPath != nullptr) {
ScopedUtfChars ldLibraryPath(env, javaLdLibraryPath);
if (ldLibraryPath.c_str() != nullptr) {
namespace art {
// Run the tests only on host.
-#ifndef __ANDROID__
+#ifndef ART_TARGET_ANDROID
class PrebuiltToolsTest : public CommonRuntimeTest {
};
}
}
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
} // namespace art
// If a debug host build, disable ptrace restriction for debugging and test timeout thread dump.
// Only 64-bit as prctl() may fail in 32 bit userspace on a 64-bit kernel.
-#if defined(__linux__) && !defined(__ANDROID__) && defined(__x86_64__)
+#if defined(__linux__) && !defined(ART_TARGET_ANDROID) && defined(__x86_64__)
if (kIsDebugBuild) {
CHECK_EQ(prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY), 0);
}
#include "thread.h"
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include <bionic_tls.h> // Access to our own TLS slot.
#endif
if (!is_started_) {
return nullptr;
} else {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
void* thread = __get_tls()[TLS_SLOT_ART_THREAD_SELF];
#else
void* thread = pthread_getspecific(Thread::pthread_key_self_);
InitTid();
interpreter::InitInterpreterTls(this);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
__get_tls()[TLS_SLOT_ART_THREAD_SELF] = this;
#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, this), "attach self");
LOG(WARNING) << "Native thread exiting without having called DetachCurrentThread (maybe it's "
"going to use a pthread_key_create destructor?): " << *self;
CHECK(is_started_);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
__get_tls()[TLS_SLOT_ART_THREAD_SELF] = self;
#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, self), "reattach self");
std::string str(ss.str());
// log to stderr for debugging command line processes
std::cerr << str;
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// log to logcat for debugging frameworks processes
LOG(INFO) << str;
#endif
void Thread::SetUpAlternateSignalStack() {
// Create and set an alternate signal stack.
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
LOG(FATAL) << "Invalid use of alternate signal stack on Android";
#endif
stack_t ss;
// Clear the TLS data, so that the underlying native thread is recognizably detached.
// (It may wish to reattach later.)
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
__get_tls()[TLS_SLOT_ART_THREAD_SELF] = nullptr;
#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, nullptr), "detach self");
void ThreadPoolWorker::SetPthreadPriority(int priority) {
CHECK_GE(priority, PRIO_MIN);
CHECK_LE(priority, PRIO_MAX);
-#if defined(__ANDROID__)
+#if defined(ART_TARGET_ANDROID)
int result = setpriority(PRIO_PROCESS, pthread_gettid_np(pthread_), priority);
if (result != 0) {
PLOG(ERROR) << "Failed to setpriority to :" << priority;
* limitations under the License.
*/
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include <android/log.h>
#else
#include <stdarg.h>
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
__android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
#else
std::cout << buf << "\n";
#include <stdio.h>
#include <stdlib.h>
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
#include <android/log.h>
#else
#include <stdarg.h>
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
__android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
#else
std::cout << buf << "\n";
extern "C" JNIEXPORT jboolean JNICALL Java_Main_supportsThreadPriorities(
JNIEnv* env ATTRIBUTE_UNUSED,
jclass clazz ATTRIBUTE_UNUSED) {
-#if defined(__ANDROID__)
+#if defined(ART_TARGET_ANDROID)
return JNI_TRUE;
#else
return JNI_FALSE;