diff options
author | Elliott Hughes <enh@google.com> | 2015-01-09 23:23:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-09 23:23:36 +0000 |
commit | 1de532495b2669ce4fae9b9d20848d78d83813d8 (patch) | |
tree | 362fff8964f1f2cd52beaf5b7445cb117f9c2dc4 | |
parent | 25d034cedea702c1f9ecb7a3a3ca977b07b9c3ba (diff) | |
parent | 0a18df82f4dea95b7398f8c934341fccbf04eeee (diff) | |
download | art-1de532495b2669ce4fae9b9d20848d78d83813d8.zip art-1de532495b2669ce4fae9b9d20848d78d83813d8.tar.gz art-1de532495b2669ce4fae9b9d20848d78d83813d8.tar.bz2 |
Merge "Clean up some #ifdefs."
-rw-r--r-- | runtime/globals.h | 2 | ||||
-rw-r--r-- | runtime/native/dalvik_system_ZygoteHooks.cc | 4 | ||||
-rw-r--r-- | runtime/thread.cc | 4 | ||||
-rw-r--r-- | runtime/trace.cc | 2 | ||||
-rw-r--r-- | runtime/utils.cc | 35 |
5 files changed, 18 insertions, 29 deletions
diff --git a/runtime/globals.h b/runtime/globals.h index e531c3a..93026da 100644 --- a/runtime/globals.h +++ b/runtime/globals.h @@ -108,7 +108,7 @@ enum TraceClockSource { kTraceClockSourceDual, // Both wall and thread CPU clocks. }; -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceDual; #else static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceWall; diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index 5f68d60..c056adc 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -26,7 +26,7 @@ #include "ScopedUtfChars.h" #include "thread-inl.h" -#if defined(HAVE_PRCTL) +#if defined(__linux__) #include <sys/prctl.h> #endif @@ -35,9 +35,9 @@ namespace art { static void EnableDebugger() { +#if defined(__linux__) // To let a non-privileged gdbserver attach to this // process, we must set our dumpable flag. -#if defined(HAVE_PRCTL) if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) { PLOG(ERROR) << "prctl(PR_SET_DUMPABLE) failed for pid " << getpid(); } diff --git a/runtime/thread.cc b/runtime/thread.cc index 527d758..6a1aeb5 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -592,13 +592,13 @@ void Thread::GetThreadName(std::string& name) const { } uint64_t Thread::GetCpuMicroTime() const { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) clockid_t cpu_clock_id; pthread_getcpuclockid(tlsPtr_.pthread_self, &cpu_clock_id); timespec now; clock_gettime(cpu_clock_id, &now); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000) + now.tv_nsec / UINT64_C(1000); -#else +#else // __APPLE__ UNIMPLEMENTED(WARNING); return -1; #endif diff --git a/runtime/trace.cc b/runtime/trace.cc index 29a3b09..5066e03 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -150,7 +150,7 @@ void Trace::FreeStackTrace(std::vector<mirror::ArtMethod*>* stack_trace) { } void Trace::SetDefaultClockSource(TraceClockSource clock_source) { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) default_clock_source_ = clock_source; #else if (clock_source != kTraceClockSourceWall) { diff --git a/runtime/utils.cc b/runtime/utils.cc index a71f1e9..d7d4ec2 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -39,17 +39,10 @@ #include "scoped_thread_state_change.h" #include "utf-inl.h" -#if !defined(HAVE_POSIX_CLOCKS) -#include <sys/time.h> -#endif - -#if defined(HAVE_PRCTL) -#include <sys/prctl.h> -#endif - #if defined(__APPLE__) #include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED #include <sys/syscall.h> +#include <sys/time.h> #endif #include <backtrace/Backtrace.h> // For DumpNativeStack. @@ -168,11 +161,11 @@ std::string GetIsoDate() { } uint64_t MilliTime() { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000) + now.tv_nsec / UINT64_C(1000000); -#else +#else // __APPLE__ timeval now; gettimeofday(&now, NULL); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000) + now.tv_usec / UINT64_C(1000); @@ -180,11 +173,11 @@ uint64_t MilliTime() { } uint64_t MicroTime() { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000) + now.tv_nsec / UINT64_C(1000); -#else +#else // __APPLE__ timeval now; gettimeofday(&now, NULL); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000) + now.tv_usec; @@ -192,11 +185,11 @@ uint64_t MicroTime() { } uint64_t NanoTime() { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000000) + now.tv_nsec; -#else +#else // __APPLE__ timeval now; gettimeofday(&now, NULL); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000000) + now.tv_usec * UINT64_C(1000); @@ -204,11 +197,11 @@ uint64_t NanoTime() { } uint64_t ThreadCpuNanoTime() { -#if defined(HAVE_POSIX_CLOCKS) +#if defined(__linux__) timespec now; clock_gettime(CLOCK_THREAD_CPUTIME_ID, &now); return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000000) + now.tv_nsec; -#else +#else // __APPLE__ UNIMPLEMENTED(WARNING); return -1; #endif @@ -1061,21 +1054,17 @@ void SetThreadName(const char* thread_name) { } else { s = thread_name + len - 15; } -#if defined(__BIONIC__) +#if defined(__linux__) // pthread_setname_np fails rather than truncating long strings. - char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded into bionic + char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. strncpy(buf, s, sizeof(buf)-1); buf[sizeof(buf)-1] = '\0'; errno = pthread_setname_np(pthread_self(), buf); if (errno != 0) { PLOG(WARNING) << "Unable to set the name of current thread to '" << buf << "'"; } -#elif defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 +#else // __APPLE__ pthread_setname_np(thread_name); -#elif defined(HAVE_PRCTL) - prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0); // NOLINT (unsigned long) -#else - UNIMPLEMENTED(WARNING) << thread_name; #endif } |