diff options
-rw-r--r-- | dex2oat/dex2oat.cc | 18 | ||||
-rw-r--r-- | runtime/arch/arm/instruction_set_features_arm.cc | 2 | ||||
-rw-r--r-- | runtime/base/time_utils.h | 4 |
3 files changed, 20 insertions, 4 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 729d712a54..d7a0266bf6 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -80,6 +80,13 @@ #include "well_known_classes.h" #include "zip_archive.h" +#if !defined(__APPLE__) +// Apple doesn't have CLOCK_MONOTONIC +#define WATCHDOG_CLOCK CLOCK_MONOTONIC +#else +#define WATCHDOG_CLOCK CLOCK_REALTIME +#endif + namespace art { static constexpr size_t kDefaultMinDexFilesForSwap = 2; @@ -413,7 +420,13 @@ class WatchDog { shutting_down_ = false; const char* reason = "dex2oat watch dog thread startup"; CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_init, (&mutex_, nullptr), reason); - CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, nullptr), reason); + CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_init, (&condattr_), reason); +#if !defined(__APPLE__) + // Apple doesn't have CLOCK_MONOTONIC or pthread_condattr_setclock. + CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_setclock, (&condattr_, WATCHDOG_CLOCK), reason); +#endif + CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, &condattr_), reason); + CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_destroy, (&condattr_), reason); CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_init, (&attr_), reason); CHECK_WATCH_DOG_PTHREAD_CALL(pthread_create, (&pthread_, &attr_, &CallBack, this), reason); CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_destroy, (&attr_), reason); @@ -456,7 +469,7 @@ class WatchDog { // large. constexpr int64_t multiplier = kVerifyObjectSupport > kVerifyObjectModeFast ? 100 : 1; timespec timeout_ts; - InitTimeSpec(true, CLOCK_REALTIME, multiplier * kWatchDogTimeoutSeconds * 1000, 0, &timeout_ts); + InitTimeSpec(true, WATCHDOG_CLOCK, multiplier * kWatchDogTimeoutSeconds * 1000, 0, &timeout_ts); const char* reason = "dex2oat watch dog thread waiting"; CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason); while (!shutting_down_) { @@ -486,6 +499,7 @@ class WatchDog { bool shutting_down_; // TODO: Switch to Mutex when we can guarantee it won't prevent shutdown in error cases. pthread_mutex_t mutex_; + pthread_condattr_t condattr_; pthread_cond_t cond_; pthread_attr_t attr_; pthread_t pthread_; diff --git a/runtime/arch/arm/instruction_set_features_arm.cc b/runtime/arch/arm/instruction_set_features_arm.cc index 51f992b056..293557584e 100644 --- a/runtime/arch/arm/instruction_set_features_arm.cc +++ b/runtime/arch/arm/instruction_set_features_arm.cc @@ -88,7 +88,7 @@ const ArmInstructionSetFeatures* ArmInstructionSetFeatures::FromVariant( "arm1136j-s", "arm1136jf-s", "arm1156t2-s", "arm1156t2f-s", "arm1176jz-s", "arm1176jzf-s", "cortex-a5", "cortex-a8", "cortex-a9", "cortex-a9-mp", "cortex-r4f", - "marvell-pj4", "mpcore", "mpcorenovfp" + "marvell-pj4", "mpcore", "mpcorenovfp", "scorpion" }; if (!FindVariantInArray(arm_variants_without_known_features, arraysize(arm_variants_without_known_features), diff --git a/runtime/base/time_utils.h b/runtime/base/time_utils.h index 55d2764576..383b52fb33 100644 --- a/runtime/base/time_utils.h +++ b/runtime/base/time_utils.h @@ -73,9 +73,11 @@ static constexpr inline uint64_t MsToNs(uint64_t ms) { } #if defined(__APPLE__) -// No clocks to specify on OS/X, fake value to pass to routines that require a clock. +#ifndef CLOCK_REALTIME +// No clocks to specify on OS/X < 10.12, fake value to pass to routines that require a clock. #define CLOCK_REALTIME 0xebadf00d #endif +#endif // Sleep for the given number of nanoseconds, a bad way to handle contention. void NanoSleep(uint64_t ns); |