aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-02-07 18:03:15 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-08 20:25:45 +0000
commit30ec0b3735d5f728c2aea4184736a3e286a5ccda (patch)
treea4d1812acc503f21ef12ed704287317c0b5af515
parent3c5cfb0d156d09d0da76d9d0a036b08f4ba8a537 (diff)
Simplify SkCpu.cpp preprocessor guards.
We have a couple ways to detect CPU features on ARM: - on ARMv8, getauxval(AT_HWCAP) - on ARMv7, getauxval(AT_HWCAP) and cpu-features.h This guards each of these methods with preprocessor guards to match exactly when we can use them. Today they're sort of a mix of that and higher level expectations about particular build and operating systems. I'm looking into doing this directly by reading CPU registers, much like we do for x86 further up the file. None of this is super important right now, so as long as we don't decide that we have these features when we don't, things will be fine. It's no big deal for now if we fail to detect them. Change-Id: I3b7768483086d0f3f4f6516b754c3ea5ec2d03e5 Reviewed-on: https://skia-review.googlesource.com/8182 Reviewed-by: Chinmay Garde <chinmaygarde@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r--src/core/SkCpu.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/SkCpu.cpp b/src/core/SkCpu.cpp
index 1ae6723983..5e5b3169c7 100644
--- a/src/core/SkCpu.cpp
+++ b/src/core/SkCpu.cpp
@@ -62,7 +62,7 @@
return features;
}
-#elif defined(SK_CPU_ARM64) && defined(SK_BUILD_FOR_ANDROID)
+#elif defined(SK_CPU_ARM64) && __has_include(<asm/hwcap.h>) && __has_include(<sys/auxv.h>)
#include <asm/hwcap.h>
#include <sys/auxv.h>
@@ -73,9 +73,8 @@
return features;
}
-#elif defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR_ANDROID) && \
- __has_include(<asm/hwcap.h>) && __has_include(<sys/auxv.h>)
- // asm/hwcap.h and sys/auxv.h won't be present on builds targeting NDK APIs before 21.
+#elif defined(SK_CPU_ARM32) && __has_include(<asm/hwcap.h>) && __has_include(<sys/auxv.h>)
+ // asm/hwcap.h and sys/auxv.h won't be present on NDK builds before API v21.
#include <asm/hwcap.h>
#include <sys/auxv.h>
@@ -86,8 +85,7 @@
return features;
}
-#elif defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR_ANDROID) && \
- !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
+#elif defined(SK_CPU_ARM32) && __has_include(<cpu-features.h>)
#include <cpu-features.h>
static uint32_t read_cpu_features() {