Requires 64-bit CPU
@@ -18,6 +18,10 @@
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
+#ifdef __APPLE__
+#include <arm_neon.h>
+#endif
+
#define Te1_r(x) ZT_ROR32(Te0[x], 8U)
#define Te2_r(x) ZT_ROR32(Te0[x], 16U)
#define Te3_r(x) ZT_ROR32(Te0[x], 24U)
@@ -112,12 +112,18 @@
#if (defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(ZT_ARCH_ARM_HAS_NEON))
+#if defined(__APPLE__) && !defined(__LP64__)
+#ifdef ZT_ARCH_ARM_HAS_NEON
+#undef ZT_ARCH_ARM_HAS_NEON
+#else
#ifndef ZT_ARCH_ARM_HAS_NEON
#define ZT_ARCH_ARM_HAS_NEON 1
#include <arm_neon.h>
/*#include <arm_acle.h>*/
// Define ZT_NO_TYPE_PUNNING to disable reckless casts on anything other than x86/x64.
#if (!(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__386)))
@@ -42,6 +42,10 @@
#include "Mutex.hpp"
#include "Salsa20.hpp"
+#include <TargetConditionals.h>
namespace ZeroTier {
const uint64_t Utils::ZERO256[4] = {0ULL,0ULL,0ULL,0ULL};
@@ -51,6 +55,13 @@ const char Utils::HEXCHARS[16] = { '0','1','2','3','4','5','6','7','8','9','a','
#ifdef ZT_ARCH_ARM_HAS_NEON
Utils::ARMCapabilities::ARMCapabilities() noexcept
{
+#if TARGET_OS_IPHONE
+ this->aes = true;
+ this->crc32 = true;
+ this->pmull = true;
+ this->sha1 = true;
+ this->sha2 = true;
#ifdef HWCAP2_AES
if (sizeof(void *) == 4) {
const long hwcaps2 = getauxval(AT_HWCAP2);
@@ -70,6 +81,7 @@ Utils::ARMCapabilities::ARMCapabilities() noexcept
}
+#endif // TARGET_OS_IPHONE
const Utils::ARMCapabilities Utils::ARMCAP;