Test Apple ARM64 runtime detection

This is a compile test
pull/461/head
Jeffrey Walton 2017-08-11 11:57:30 -04:00
parent a46377caf7
commit 22b7d74e1f
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 30 additions and 1 deletions

View File

@ -333,7 +333,7 @@ unsigned int GCM_Base::OptimalDataAlignment() const
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
HasSSE2() ? 16 :
#elif CRYPTOPP_ARM_NEON_AVAILABLE
HasNEON() ? 16 :
HasNEON() ? 4 :
#endif
GetBlockCipher().OptimalDataAlignment();
}

View File

@ -52,6 +52,10 @@
# include <setjmp.h>
#endif
#if defined(__APPLE__) && defined(__aarch64__)
# include <sys/utsname.h>
#endif
#ifndef EXCEPTION_EXECUTE_HANDLER
# define EXCEPTION_EXECUTE_HANDLER 1
#endif
@ -110,6 +114,27 @@ bool CPU_TryAES_ARMV8()
# elif defined(__linux__) && defined(__aarch32__)
if (getauxval(AT_HWCAP2) & HWCAP2_AES)
return true;
# elif defined(__APPLE__)
{
// https://stackoverflow.com/a/11197770/608639
// https://gist.github.com/erkanyildiz/390a480f27e86f8cd6ba
struct utsname systemInfo;
systemInfo.machine[0] = '\0';
uname(&systemInfo);
const char* machine = systemInfo.machine;
if (0==strcmp(machine, "iPhone6,1") || 0==strcmp(machine, "iPhone6,2") ||
0==strcmp(machine, "iPhone7,1") || 0==strcmp(machine, "iPhone7,2") ||
0==strcmp(machine, "iPad4,1") || 0==strcmp(machine, "iPad4,2") ||
0==strcmp(machine, "iPad4,3") || 0==strcmp(machine, "iPad4,4") ||
0==strcmp(machine, "iPad4,5") || 0==strcmp(machine, "iPad4,6") ||
0==strcmp(machine, "iPad4,7") || 0==strcmp(machine, "iPad4,8") ||
0==strcmp(machine, "iPad4,9") ||
0==strcmp(machine, "iPad5,3") || 0==strcmp(machine, "iPad5,4") )
{
return true;
}
}
# endif
// longjmp and clobber warnings. Volatile is required.

View File

@ -4,6 +4,10 @@
// use "cl /EP /P /DCRYPTOPP_GENERATE_X64_MASM rijndael.cpp" to generate MASM code
/*
July 2017: Added support for ARM AES instructions via compiler intrinsics.
*/
/*
July 2010: Added support for AES-NI instructions via compiler intrinsics.
*/