Browse Source

Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge

Adam Ierymenko 6 years ago
parent
commit
af137fd5d3
2 changed files with 20 additions and 3 deletions
  1. 5 0
      CMakeLists.txt
  2. 15 3
      node/AES.cpp

+ 5 - 0
CMakeLists.txt

@@ -2,6 +2,11 @@
 
 cmake_minimum_required (VERSION 3.8)
 
+if(WIN32)
+	# If building on Windows, set minimum target to Windows 7
+	set(CMAKE_SYSTEM_VERSION "7" CACHE STRING INTERNAL FORCE)
+endif(WIN32)
+
 # ZeroTier One Version Config
 
 set(ZEROTIER_ONE_VERSION_MAJOR 1)

+ 15 - 3
node/AES.cpp

@@ -26,15 +26,26 @@
 
 #include "AES.hpp"
 
-namespace ZeroTier {
-
 #if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64))
-
 #include <wmmintrin.h>
 #include <emmintrin.h>
 #include <smmintrin.h>
+#endif
+#ifdef _WIN32
+#include <intrin.h>
+#endif
+
+namespace ZeroTier {
+
+#if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64))
+
 static inline bool _zt_aesni_supported()
 {
+#ifdef WIN32
+	int regs[4];
+	__cpuid(regs, 1);
+	return (regs[2] >> 25) & 1;
+#else
 	uint32_t eax,ebx,ecx,edx;
 	__asm__ __volatile__ (
 		"cpuid"
@@ -42,6 +53,7 @@ static inline bool _zt_aesni_supported()
 		: "a"(1), "c"(0)
 	);
 	return ((ecx & (1 << 25)) != 0);
+#endif
 }
 const bool AES::HW_ACCEL = _zt_aesni_supported();