Improved CPU detection on ARM platforms
authorCameron Cawley <ccawley2011@gmail.com>
Tue, 04 Feb 2020 16:46:22 +0000
changeset 13527604325956b9a
parent 13526 2b708d63875d
child 13528 cf2ef2000634
Improved CPU detection on ARM platforms
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Feb 13 20:50:47 2020 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Tue Feb 04 16:46:22 2020 +0000
     1.3 @@ -338,7 +338,14 @@
     1.4      return altivec;
     1.5  }
     1.6  
     1.7 -#if !defined(__ARM_ARCH)
     1.8 +#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6)
     1.9 +static int
    1.10 +CPU_haveARMSIMD(void)
    1.11 +{
    1.12 +	return 1;
    1.13 +}
    1.14 +
    1.15 +#elif !defined(__arm__)
    1.16  static int
    1.17  CPU_haveARMSIMD(void)
    1.18  {
    1.19 @@ -403,10 +410,8 @@
    1.20  static int
    1.21  CPU_haveARMSIMD(void)
    1.22  {
    1.23 -#if !defined(__ANDROID__) && !defined(__IPHONEOS__) && !defined(__TVOS__)
    1.24 -#warning SDL_HasARMSIMD is not implemented for this ARM platform, defaulting to TRUE
    1.25 -#endif
    1.26 -    return 1;
    1.27 +#warning SDL_HasARMSIMD is not implemented for this ARM platform. Write me.
    1.28 +    return 0;
    1.29  }
    1.30  #endif
    1.31  
    1.32 @@ -445,15 +450,15 @@
    1.33  #  endif
    1.34  /* All WinRT ARM devices are required to support NEON, but just in case. */
    1.35      return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
    1.36 -#elif !defined(__ARM_ARCH)
    1.37 -    return 0;  /* not an ARM CPU at all. */
    1.38 -#elif __ARM_ARCH >= 8
    1.39 +#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
    1.40      return 1;  /* ARMv8 always has non-optional NEON support. */
    1.41 -#elif defined(__APPLE__) && (__ARM_ARCH >= 7)
    1.42 +#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)
    1.43      /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */
    1.44      return 1;  /* all Apple ARMv7 chips and later have NEON. */
    1.45  #elif defined(__APPLE__)
    1.46      return 0;  /* assume anything else from Apple doesn't have NEON. */
    1.47 +#elif !defined(__arm__)
    1.48 +    return 0;  /* not an ARM CPU at all. */
    1.49  #elif defined(__QNXNTO__)
    1.50      return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON;
    1.51  #elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)