Skip to content

Commit 2ac4e72

Browse files
committed
Fix for Windows compilation issue
1 parent 656236c commit 2ac4e72

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/simd/x86/sse_ops.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121

2222
#ifdef _MSC_VER
2323
#include <intrin.h>
24+
25+
/* MSVC doesn't have __builtin_prefetch, use _mm_prefetch instead */
26+
#define __builtin_prefetch(addr, rw, locality) \
27+
_mm_prefetch((const char*)(addr), _MM_HINT_T0)
28+
29+
/* MSVC doesn't have __builtin_ctz (count trailing zeros) */
30+
static inline int msvc_ctz(unsigned int x) {
31+
unsigned long index;
32+
_BitScanForward(&index, x);
33+
return (int)index;
34+
}
35+
#define __builtin_ctz(x) msvc_ctz(x)
36+
37+
/* MSVC doesn't have __builtin_popcount */
38+
#define __builtin_popcount(x) __popcnt(x)
39+
2440
#endif
2541
#include <smmintrin.h>
2642
#include <nmmintrin.h>

0 commit comments

Comments
 (0)