mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
cpuinfo: Patched to compile on Android, Linux.
This commit is contained in:
parent
e8f4b7c4f5
commit
a298e56349
@ -50,10 +50,11 @@
|
|||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__LINUX__) || defined(__ANDROID__) && defined(__ARM_ARCH)
|
#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH)
|
||||||
#include <sys/auxv.h>
|
|
||||||
#include <asm/hwcap.h>
|
#include <asm/hwcap.h>
|
||||||
#if !defined HAVE_GETAUXVAL
|
#if defined HAVE_GETAUXVAL
|
||||||
|
#include <sys/auxv.h>
|
||||||
|
#else
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -297,27 +298,22 @@ CPU_haveAltiVec(void)
|
|||||||
return altivec;
|
return altivec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(__LINUX__) || defined(__ANDROID__)) && !defined(HAVE_GETAUXVAL)
|
#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL)
|
||||||
static int
|
static int
|
||||||
readProcAuxvForNeon(void)
|
readProcAuxvForNeon(void)
|
||||||
{
|
{
|
||||||
int neon = 0;
|
int neon = 0;
|
||||||
int kv[2];
|
int kv[2];
|
||||||
const int fd = open("/proc/self/auxv", O_RDONLY);
|
const int fd = open("/proc/self/auxv", O_RDONLY);
|
||||||
|
if (fd != -1) {
|
||||||
if (fd == -1) {
|
while (read(fd, kv, sizeof (kv)) == sizeof (kv)) {
|
||||||
return 0;
|
if (kv[0] == AT_HWCAP) {
|
||||||
}
|
neon = ((kv[1] & HWCAP_NEON) == HWCAP_NEON);
|
||||||
|
break;
|
||||||
while (read(fd, kv, sizeof (kv)) == sizeof (kv)) {
|
}
|
||||||
if (kv[0] == AT_HWCAP) {
|
|
||||||
neon = ((kv[1] & HWCAP_NEON) == HWCAP_NEON);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return neon;
|
return neon;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -338,11 +334,10 @@ CPU_haveNEON(void)
|
|||||||
size_t length = sizeof (neon);
|
size_t length = sizeof (neon);
|
||||||
const int error = sysctlbyname("hw.optional.neon", &neon, &length, NULL, 0);
|
const int error = sysctlbyname("hw.optional.neon", &neon, &length, NULL, 0);
|
||||||
return (!error) && (neon != 0);
|
return (!error) && (neon != 0);
|
||||||
/* Android offers a static library for this but all it does is parse /proc/cpuinfo */
|
|
||||||
#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
|
#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
|
||||||
return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON)
|
return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON)
|
||||||
#elif (defined(__LINUX__) || defined(__ANDROID__))
|
#elif (defined(__LINUX__) || defined(__ANDROID__))
|
||||||
return readProcAuxvForNeon();
|
return readProcAuxvForNeon(); /* Android offers a static library for this, but it just parses /proc/self/auxv */
|
||||||
#elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM)
|
#elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM)
|
||||||
/* All WinRT ARM devices are required to support NEON, but just in case. */
|
/* All WinRT ARM devices are required to support NEON, but just in case. */
|
||||||
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
|
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user