diff --git a/src/Cpu_stub.cpp b/src/Cpu_stub.cpp index 4bf0ba08..0b9196ee 100644 --- a/src/Cpu_stub.cpp +++ b/src/Cpu_stub.cpp @@ -22,11 +22,14 @@ */ -#ifdef _MSC_VER -# include -#else -# include -#endif +#ifdef _MSC_VER +# include + +# define bit_AES (1 << 25) +# define bit_BMI2 (1 << 8) +#else +# include +#endif #include @@ -48,15 +51,21 @@ #define EDX_Reg (3) +#ifdef _MSC_VER +static inline void cpuid(int level, int output[4]) { + __cpuid(output, level); +} +#else static inline void cpuid(int level, int output[4]) { int a, b, c, d; - //__cpuid_count(level, 0, a, b, c, d); + __cpuid_count(level, 0, a, b, c, d); output[0] = a; output[1] = b; output[2] = c; output[3] = d; } +#endif static inline void cpu_brand_string(char* s) { @@ -78,8 +87,7 @@ static inline bool has_aes_ni() int cpu_info[4] = { 0 }; cpuid(PROCESSOR_INFO, cpu_info); - return false; - //return cpu_info[ECX_Reg] & bit_AES; + return cpu_info[ECX_Reg] & bit_AES; } @@ -87,8 +95,7 @@ static inline bool has_bmi2() { int cpu_info[4] = { 0 }; cpuid(EXTENDED_FEATURES, cpu_info); - return false; - //return cpu_info[EBX_Reg] & bit_BMI2; + return cpu_info[EBX_Reg] & bit_BMI2; } @@ -112,7 +119,7 @@ void Cpu::initCommon() { cpu_brand_string(m_brand); -# ifdef __x86_64__ +# if defined(__x86_64__) || defined(_M_AMD64) m_flags |= X86_64; # endif diff --git a/src/crypto/CryptoNight_p.h b/src/crypto/CryptoNight_p.h index b44b6616..8a5268f4 100644 --- a/src/crypto/CryptoNight_p.h +++ b/src/crypto/CryptoNight_p.h @@ -73,7 +73,7 @@ void (* const extra_hashes[4])(const void *, size_t, char *) = {do_blake_hash, d -#if defined(__x86_64__) || defined(_WIN64) +#if defined(__x86_64__) || defined(_M_AMD64) # define EXTRACT64(X) _mm_cvtsi128_si64(X) # ifdef __GNUC__ @@ -86,7 +86,7 @@ static inline uint64_t __umul128(uint64_t a, uint64_t b, uint64_t* hi) # else #define __umul128 _umul128 # endif -#elif defined(__i386__) +#elif defined(__i386__) || defined(_M_IX86) # define HI32(X) \ _mm_srli_si128((X), 4)