src/cpuinfo/SDL_cpuinfo.c
changeset 10625 d40f7ebf34eb
parent 10624 294ee69a9f11
child 10626 04035f36048e
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Nov 17 15:57:58 2016 -0500
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Nov 17 16:01:59 2016 -0500
     1.3 @@ -50,9 +50,12 @@
     1.4  #include <setjmp.h>
     1.5  #endif
     1.6  
     1.7 -#if defined(__LINUX__) && defined(__ARM_ARCH)
     1.8 +#if defined(__LINUX__) || defined(__ANDROID__) && defined(__ARM_ARCH)
     1.9  #include <sys/auxv.h>
    1.10  #include <asm/hwcap.h>
    1.11 +#if !defined HAVE_GETAUXVAL
    1.12 +#include <fcntl.h>
    1.13 +#endif
    1.14  #endif
    1.15  
    1.16  #define CPU_HAS_RDTSC   0x00000001
    1.17 @@ -294,7 +297,7 @@
    1.18      return altivec;
    1.19  }
    1.20  
    1.21 -#if (defined(__LINUX__) || defined(__ANDROID__)) && !HAVE_GETAUXVAL
    1.22 +#if (defined(__LINUX__) || defined(__ANDROID__)) && !defined(HAVE_GETAUXVAL)
    1.23  static int
    1.24  readProcAuxvForNeon(void)
    1.25  {
    1.26 @@ -326,7 +329,7 @@
    1.27  /* The way you detect NEON is a privileged instruction on ARM, so you have
    1.28     query the OS kernel in a platform-specific way. :/ */
    1.29  #if defined(SDL_CPUINFO_DISABLED) || !defined(__ARM_ARCH)
    1.30 -    return 0;
    1.31 +    return 0;  /* disabled or not an ARM CPU at all. */
    1.32  #elif __ARM_ARCH >= 8
    1.33      return 1;  // ARMv8 always has non-optional NEON support.
    1.34  #elif defined(__APPLE__)
    1.35 @@ -336,18 +339,16 @@
    1.36      const int error = sysctlbyname("hw.optional.neon", &neon, &length, NULL, 0);
    1.37      return (!error) && (neon != 0);
    1.38  /* Android offers a static library for this but all it does is parse /proc/cpuinfo */
    1.39 -#elif (defined(__LINUX__) || defined(__ANDROID__)) && HAVE_GETAUXVAL
    1.40 +#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
    1.41      return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON)
    1.42  #elif (defined(__LINUX__) || defined(__ANDROID__))
    1.43      return readProcAuxvForNeon();
    1.44  #elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM)
    1.45      /* All WinRT ARM devices are required to support NEON, but just in case. */
    1.46 -    if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)) {
    1.47 -        neon = 1;
    1.48 -    }
    1.49 +    return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
    1.50  #else
    1.51  #warning SDL_HasNEON is not implemented for this ARM platform. Write me.
    1.52 -#endif
    1.53 +    return 0;
    1.54  #endif
    1.55  }
    1.56