Skip to content

Commit 1261e9e

Browse files
committed
CPUID support on MSVC
1 parent ec49c07 commit 1261e9e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/minisketch.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
#include "sketch.h"
1313

1414
#ifdef HAVE_CLMUL
15-
#include <cpuid.h>
15+
# ifdef _MSC_VER
16+
# include <intrin.h>
17+
# else
18+
# include <cpuid.h>
19+
# endif
1620
#endif
1721

1822
Sketch* ConstructGeneric1Byte(int bits, int implementation);
@@ -80,8 +84,14 @@ Sketch* Construct(int bits, int impl)
8084
#ifdef HAVE_CLMUL
8185
case FieldImpl::CLMUL:
8286
case FieldImpl::CLMUL_TRI: {
87+
#ifdef _MSC_VER
88+
int regs[4];
89+
__cpuid(regs, 1);
90+
if (regs[2] & 0x2) {
91+
#else
8392
uint32_t eax, ebx, ecx, edx;
8493
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & 0x2)) {
94+
#endif
8595
switch ((bits + 7) / 8) {
8696
case 1:
8797
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul1Byte(bits, impl);

0 commit comments

Comments
 (0)