Skip to content

Commit

Permalink
Improved CPU detection on ARM platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Feb 4, 2020
1 parent 8f1a916 commit 582f570
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -338,7 +338,14 @@ CPU_haveAltiVec(void)
return altivec;
}

#if !defined(__ARM_ARCH)
#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6)
static int
CPU_haveARMSIMD(void)
{
return 1;
}

#elif !defined(__arm__)
static int
CPU_haveARMSIMD(void)
{
Expand Down Expand Up @@ -403,10 +410,8 @@ CPU_haveARMSIMD(void)
static int
CPU_haveARMSIMD(void)
{
#if !defined(__ANDROID__) && !defined(__IPHONEOS__) && !defined(__TVOS__)
#warning SDL_HasARMSIMD is not implemented for this ARM platform, defaulting to TRUE
#endif
return 1;
#warning SDL_HasARMSIMD is not implemented for this ARM platform. Write me.
return 0;
}
#endif

Expand Down Expand Up @@ -445,15 +450,15 @@ CPU_haveNEON(void)
# endif
/* All WinRT ARM devices are required to support NEON, but just in case. */
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
#elif !defined(__ARM_ARCH)
return 0; /* not an ARM CPU at all. */
#elif __ARM_ARCH >= 8
#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
return 1; /* ARMv8 always has non-optional NEON support. */
#elif defined(__APPLE__) && (__ARM_ARCH >= 7)
#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)
/* (note that sysctlbyname("hw.optional.neon") doesn't work!) */
return 1; /* all Apple ARMv7 chips and later have NEON. */
#elif defined(__APPLE__)
return 0; /* assume anything else from Apple doesn't have NEON. */
#elif !defined(__arm__)
return 0; /* not an ARM CPU at all. */
#elif defined(__QNXNTO__)
return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON;
#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
Expand Down

0 comments on commit 582f570

Please sign in to comment.