From bb661c0f0cb72d4bbfc2e251f6ded6949a713292 Mon Sep 17 00:00:00 2001 From: Bilyan Borisov Date: Mon, 4 Apr 2016 16:27:32 +0100 Subject: [PATCH] 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 --- build/Android.common_build.mk | 7 ++++++- compiler/debug/dwarf/dwarf_test.cc | 4 ++-- compiler/jit/jit_compiler.cc | 2 +- compiler/jni/jni_cfi_test.cc | 4 ++-- compiler/optimizing/optimizing_cfi_test.cc | 4 ++-- compiler/utils/assembler_thumb_test.cc | 8 ++++---- compiler/utils/x86_64/assembler_x86_64_test.cc | 2 +- runtime/arch/arm/instruction_set_features_arm.cc | 4 ++-- runtime/arch/instruction_set_features_test.cc | 6 +++--- runtime/base/logging.cc | 12 ++++++------ runtime/gc/allocation_record.cc | 6 +++--- runtime/gc/allocator/dlmalloc.h | 2 +- runtime/gc/allocator/rosalloc.cc | 6 +++--- runtime/jdwp/jdwp_adb.cc | 4 ++-- runtime/jdwp/jdwp_main.cc | 2 +- runtime/native/dalvik_system_VMRuntime.cc | 4 ++-- runtime/oat_file.cc | 6 +++--- runtime/openjdkjvm/OpenjdkJvm.cc | 6 +++--- runtime/prebuilt_tools_test.cc | 4 ++-- runtime/runtime.cc | 2 +- runtime/thread-inl.h | 4 ++-- runtime/thread.cc | 6 +++--- runtime/thread_linux.cc | 2 +- runtime/thread_list.cc | 2 +- runtime/thread_pool.cc | 2 +- sigchainlib/sigchain.cc | 4 ++-- sigchainlib/sigchain_dummy.cc | 4 ++-- test/051-thread/thread_test.cc | 2 +- 28 files changed, 63 insertions(+), 58 deletions(-) diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk index 2294ddbd5..dde3cdb1d 100644 --- a/build/Android.common_build.mk +++ b/build/Android.common_build.mk @@ -363,7 +363,12 @@ ART_HOST_ASFLAGS += $(art_asflags) 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) diff --git a/compiler/debug/dwarf/dwarf_test.cc b/compiler/debug/dwarf/dwarf_test.cc index 2ba3af5e1..866bf4394 100644 --- a/compiler/debug/dwarf/dwarf_test.cc +++ b/compiler/debug/dwarf/dwarf_test.cc @@ -27,7 +27,7 @@ namespace art { 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; @@ -341,7 +341,7 @@ TEST_F(DwarfTest, DebugInfo) { CheckObjdumpOutput(is64bit, "-W"); } -#endif // __ANDROID__ +#endif // ART_TARGET_ANDROID } // namespace dwarf } // namespace art diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index c8dfc93a0..5de9842d9 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -171,7 +171,7 @@ JitCompiler::JitCompiler() { 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"; diff --git a/compiler/jni/jni_cfi_test.cc b/compiler/jni/jni_cfi_test.cc index 05c85e027..371019a22 100644 --- a/compiler/jni/jni_cfi_test.cc +++ b/compiler/jni/jni_cfi_test.cc @@ -29,7 +29,7 @@ namespace art { // Run the tests only on host. -#ifndef __ANDROID__ +#ifndef ART_TARGET_ANDROID class JNICFITest : public CFITest { public: @@ -94,6 +94,6 @@ TEST_ISA(kX86_64) TEST_ISA(kMips) TEST_ISA(kMips64) -#endif // __ANDROID__ +#endif // ART_TARGET_ANDROID } // namespace art diff --git a/compiler/optimizing/optimizing_cfi_test.cc b/compiler/optimizing/optimizing_cfi_test.cc index 400686d23..a6d234d73 100644 --- a/compiler/optimizing/optimizing_cfi_test.cc +++ b/compiler/optimizing/optimizing_cfi_test.cc @@ -32,7 +32,7 @@ namespace art { // Run the tests only on host. -#ifndef __ANDROID__ +#ifndef ART_TARGET_ANDROID class OptimizingCFITest : public CFITest { public: @@ -241,6 +241,6 @@ TEST_F(OptimizingCFITest, kMips64Adjust) { Check(kMips64, "kMips64_adjust", expected_asm, expected_cfi); } -#endif // __ANDROID__ +#endif // ART_TARGET_ANDROID } // namespace art diff --git a/compiler/utils/assembler_thumb_test.cc b/compiler/utils/assembler_thumb_test.cc index c67cb5a56..9c9271db3 100644 --- a/compiler/utils/assembler_thumb_test.cc +++ b/compiler/utils/assembler_thumb_test.cc @@ -32,7 +32,7 @@ namespace arm { // 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 @@ -72,7 +72,7 @@ void InitResults() { } 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; @@ -89,7 +89,7 @@ std::string GetToolsDir() { } void DumpAndCheck(std::vector& code, const char* testname, const char* const* results) { -#ifndef __ANDROID__ +#ifndef ART_TARGET_ANDROID static std::string toolsdir = GetToolsDir(); ScratchFile file; @@ -169,7 +169,7 @@ void DumpAndCheck(std::vector& code, const char* testname, const char* snprintf(buf, sizeof(buf), "%s.oo", filename); unlink(buf); -#endif +#endif // ART_TARGET_ANDROID } #define __ assembler-> diff --git a/compiler/utils/x86_64/assembler_x86_64_test.cc b/compiler/utils/x86_64/assembler_x86_64_test.cc index b19e616dd..afe9207eb 100644 --- a/compiler/utils/x86_64/assembler_x86_64_test.cc +++ b/compiler/utils/x86_64/assembler_x86_64_test.cc @@ -37,7 +37,7 @@ TEST(AssemblerX86_64, CreateBuffer) { ASSERT_EQ(static_cast(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. diff --git a/runtime/arch/arm/instruction_set_features_arm.cc b/runtime/arch/arm/instruction_set_features_arm.cc index 51f992b05..ffac0307b 100644 --- a/runtime/arch/arm/instruction_set_features_arm.cc +++ b/runtime/arch/arm/instruction_set_features_arm.cc @@ -16,7 +16,7 @@ #include "instruction_set_features_arm.h" -#if defined(__ANDROID__) && defined(__arm__) +#if defined(ART_TARGET_ANDROID) && defined(__arm__) #include #include #endif @@ -166,7 +166,7 @@ const ArmInstructionSetFeatures* ArmInstructionSetFeatures::FromHwcap() { 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) { diff --git a/runtime/arch/instruction_set_features_test.cc b/runtime/arch/instruction_set_features_test.cc index 99c2d4dc7..fb38b47ea 100644 --- a/runtime/arch/instruction_set_features_test.cc +++ b/runtime/arch/instruction_set_features_test.cc @@ -18,7 +18,7 @@ #include -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include "cutils/properties.h" #endif @@ -26,7 +26,7 @@ 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"; @@ -111,7 +111,7 @@ TEST(InstructionSetFeaturesTest, FeaturesFromCpuInfo) { } #endif -#ifndef __ANDROID__ +#ifndef ART_TARGET_ANDROID TEST(InstructionSetFeaturesTest, HostFeaturesFromCppDefines) { std::string error_msg; std::unique_ptr default_features( diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc index 212e5bd92..3ee15a246 100644 --- a/runtime/base/logging.cc +++ b/runtime/base/logging.cc @@ -26,7 +26,7 @@ #include "utils.h" // Headers for LogMessage::LogLine. -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include "cutils/log.h" #else #include @@ -47,7 +47,7 @@ static std::unique_ptr gProgramInvocationShortName; // 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; @@ -235,7 +235,7 @@ std::ostream& LogMessage::stream() { 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, @@ -251,7 +251,7 @@ void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity log_se return; } -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID const char* tag = ProgramInvocationShortName(); int priority = kLogSeverityToAndroidLogPriority[static_cast(log_severity)]; if (priority == ANDROID_LOG_FATAL) { @@ -274,7 +274,7 @@ void LogMessage::LogLineLowStack(const char* file, unsigned int line, LogSeverit 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(log_severity)]; @@ -311,7 +311,7 @@ void LogMessage::LogLineLowStack(const char* file, unsigned int line, LogSeverit 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) { diff --git a/runtime/gc/allocation_record.cc b/runtime/gc/allocation_record.cc index bd023b34f..d9f1507af 100644 --- a/runtime/gc/allocation_record.cc +++ b/runtime/gc/allocation_record.cc @@ -20,7 +20,7 @@ #include "base/stl_util.h" #include "stack.h" -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include "cutils/properties.h" #endif @@ -38,7 +38,7 @@ const char* AllocRecord::GetClassDescriptor(std::string* storage) const { } 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]; @@ -88,7 +88,7 @@ void AllocRecordObjectMap::SetProperties() { max_stack_depth_ = value; } } -#endif +#endif // ART_TARGET_ANDROID } AllocRecordObjectMap::~AllocRecordObjectMap() { diff --git a/runtime/gc/allocator/dlmalloc.h b/runtime/gc/allocator/dlmalloc.h index 50e2622e8..c07da5da4 100644 --- a/runtime/gc/allocator/dlmalloc.h +++ b/runtime/gc/allocator/dlmalloc.h @@ -35,7 +35,7 @@ #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); diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index bd84d0d8e..375d8699c 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -1021,7 +1021,7 @@ size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { // 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 runs; #else std::unordered_set runs; @@ -1088,7 +1088,7 @@ size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { 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); @@ -1103,7 +1103,7 @@ size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { // 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 diff --git a/runtime/jdwp/jdwp_adb.cc b/runtime/jdwp/jdwp_adb.cc index 51952c492..e9d6d079c 100644 --- a/runtime/jdwp/jdwp_adb.cc +++ b/runtime/jdwp/jdwp_adb.cc @@ -24,7 +24,7 @@ #include "base/stringprintf.h" #include "jdwp/jdwp_priv.h" -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include "cutils/sockets.h" #endif @@ -224,7 +224,7 @@ bool JdwpAdbState::Accept() { */ 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"; diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc index 668d5dc49..dbf04fe7a 100644 --- a/runtime/jdwp/jdwp_main.cc +++ b/runtime/jdwp/jdwp_main.cc @@ -251,7 +251,7 @@ JdwpState* JdwpState::Create(const JdwpOptions* options) { case kJdwpTransportSocket: InitSocketTransport(state.get(), options); break; -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID case kJdwpTransportAndroidAdb: InitAdbTransport(state.get(), options); break; diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index d22c0c715..f355c2a94 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -16,7 +16,7 @@ #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 @@ -196,7 +196,7 @@ static void VMRuntime_setTargetSdkVersionNative(JNIEnv*, jobject, jint target_sd // 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(target_sdk_version)); diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index ccb8b2970..ae84019a5 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -28,7 +28,7 @@ #include // dlopen_ext support from bionic. -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include "android/dlext.h" #endif @@ -623,7 +623,7 @@ bool DlOpenOatFile::Dlopen(const std::string& elf_filename, *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 @@ bool DlOpenOatFile::Dlopen(const std::string& elf_filename, #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()); diff --git a/runtime/openjdkjvm/OpenjdkJvm.cc b/runtime/openjdkjvm/OpenjdkJvm.cc index 1f3365124..ca5efe554 100644 --- a/runtime/openjdkjvm/OpenjdkJvm.cc +++ b/runtime/openjdkjvm/OpenjdkJvm.cc @@ -58,10 +58,10 @@ #include #include -#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" @@ -325,7 +325,7 @@ JNIEXPORT __attribute__((noreturn)) void JVM_Exit(jint status) { } 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) { diff --git a/runtime/prebuilt_tools_test.cc b/runtime/prebuilt_tools_test.cc index eb226d496..c2b34c859 100644 --- a/runtime/prebuilt_tools_test.cc +++ b/runtime/prebuilt_tools_test.cc @@ -23,7 +23,7 @@ namespace art { // Run the tests only on host. -#ifndef __ANDROID__ +#ifndef ART_TARGET_ANDROID class PrebuiltToolsTest : public CommonRuntimeTest { }; @@ -61,6 +61,6 @@ TEST_F(PrebuiltToolsTest, CheckTargetTools) { } } -#endif // __ANDROID__ +#endif // ART_TARGET_ANDROID } // namespace art diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 2489e45e4..a4d31ef12 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -545,7 +545,7 @@ bool Runtime::Start() { // 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); } diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h index f5d20bd60..d98f82a54 100644 --- a/runtime/thread-inl.h +++ b/runtime/thread-inl.h @@ -19,7 +19,7 @@ #include "thread.h" -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include // Access to our own TLS slot. #endif @@ -45,7 +45,7 @@ inline Thread* Thread::Current() { 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_); diff --git a/runtime/thread.cc b/runtime/thread.cc index e015833c9..7922b6096 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -704,7 +704,7 @@ bool Thread::Init(ThreadList* thread_list, JavaVMExt* java_vm, JNIEnvExt* jni_en 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"); @@ -1542,7 +1542,7 @@ void Thread::ThreadExitCallback(void* arg) { 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"); @@ -2392,7 +2392,7 @@ void Thread::DumpFromGdb() const { 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 diff --git a/runtime/thread_linux.cc b/runtime/thread_linux.cc index 9563b994f..b922d9461 100644 --- a/runtime/thread_linux.cc +++ b/runtime/thread_linux.cc @@ -44,7 +44,7 @@ static constexpr int kHostAltSigStackSize = 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; diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 1e5264c9c..da214796b 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -1277,7 +1277,7 @@ void ThreadList::Unregister(Thread* self) { // 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"); diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc index 2fba805fa..b14f340c4 100644 --- a/runtime/thread_pool.cc +++ b/runtime/thread_pool.cc @@ -61,7 +61,7 @@ ThreadPoolWorker::~ThreadPoolWorker() { 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; diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc index b76555b00..f29301d22 100644 --- a/sigchainlib/sigchain.cc +++ b/sigchainlib/sigchain.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include #else #include @@ -103,7 +103,7 @@ static void log(const char* format, ...) { 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"; diff --git a/sigchainlib/sigchain_dummy.cc b/sigchainlib/sigchain_dummy.cc index dfe0c6f98..aa3c360b3 100644 --- a/sigchainlib/sigchain_dummy.cc +++ b/sigchainlib/sigchain_dummy.cc @@ -17,7 +17,7 @@ #include #include -#ifdef __ANDROID__ +#ifdef ART_TARGET_ANDROID #include #else #include @@ -38,7 +38,7 @@ static void log(const char* format, ...) { 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"; diff --git a/test/051-thread/thread_test.cc b/test/051-thread/thread_test.cc index 4215207c9..079ad4023 100644 --- a/test/051-thread/thread_test.cc +++ b/test/051-thread/thread_test.cc @@ -28,7 +28,7 @@ extern "C" JNIEXPORT jint JNICALL Java_Main_getNativePriority(JNIEnv* env, 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; -- 2.11.0