On Mon, Apr 24, 2017 at 11:59 PM, Eric Anholt <e...@anholt.net> wrote: > I wrote this code with reference to pixman, though I've only decided to > cover Linux (what I'm testing) and Android (seems obvious enough). Linux > has getauxval() as a cleaner interface to the /proc entry, but it's more > glibc-specific and I didn't want to add detection for that. > > This will be used to enable NEON at runtime on ARMv6 builds of vc4. > > v2: Actually initialize the temp vars in the Android path (noticed by > daniels) > v3: Actually pull in the cpufeatures library (change by robher). > Use O_CLOEXEC. Break out of the loop when we find our feature. > v4: Drop VFP code, which was confused about what it was detecting and not > actually used yet. > --- > src/gallium/auxiliary/Android.mk | 2 ++ > src/gallium/auxiliary/util/u_cpu_detect.c | 43 > +++++++++++++++++++++++++++++++ > src/gallium/auxiliary/util/u_cpu_detect.h | 1 + > 3 files changed, 46 insertions(+) > > diff --git a/src/gallium/auxiliary/Android.mk > b/src/gallium/auxiliary/Android.mk > index e8628e43744a..4f6f71bbf6a9 100644 > --- a/src/gallium/auxiliary/Android.mk > +++ b/src/gallium/auxiliary/Android.mk > @@ -48,6 +48,8 @@ endif > LOCAL_MODULE := libmesa_gallium > LOCAL_STATIC_LIBRARIES += libmesa_nir > > +LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures > + > # generate sources > LOCAL_MODULE_CLASS := STATIC_LIBRARIES > intermediates := $(call local-generated-sources-dir) > diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c > b/src/gallium/auxiliary/util/u_cpu_detect.c > index 845fc6b34d5c..76115bf8d55d 100644 > --- a/src/gallium/auxiliary/util/u_cpu_detect.c > +++ b/src/gallium/auxiliary/util/u_cpu_detect.c > @@ -59,12 +59,18 @@ > > #if defined(PIPE_OS_LINUX) > #include <signal.h> > +#include <fcntl.h> > +#include <elf.h> > #endif > > #ifdef PIPE_OS_UNIX > #include <unistd.h> > #endif > > +#if defined(PIPE_OS_ANDROID) > +#include <cpu-features.h> > +#endif > + > #if defined(PIPE_OS_WINDOWS) > #include <windows.h> > #if defined(PIPE_CC_MSVC) > @@ -294,6 +300,38 @@ PIPE_ALIGN_STACK static inline boolean sse2_has_daz(void) > > #endif /* X86 or X86_64 */ > > +#if defined(PIPE_ARCH_ARM) > +static void > +check_os_arm_support(void) > +{ > +#if defined(PIPE_OS_ANDROID) > + AndroidCpuFamily cpu_family = android_getCpuFamily(); > + uint64_t cpu_features = android_getCpuFeatures(); > + > + if (cpu_family == ANDROID_CPU_FAMILY_ARM) {
I don't think this is strictly speaking necessary... this function is already guarded by PIPE_ARCH_ARM, which shouldn't be set on AArch64 (or other architectures for that matter)... _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev