From ebb6e97d0dbc226e93196bf3d0085443734f08dc Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 14 Aug 2024 19:24:10 +0800 Subject: [PATCH] Avoid `__popcnt64` on MSVC Windows 32-bit platform The `__popcnt64` intrinsic isn't supported on 32-bit Windows, so `__popcnt` should be used instead. --- sqlite-vec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqlite-vec.c b/sqlite-vec.c index cb4901d..78aad2d 100644 --- a/sqlite-vec.c +++ b/sqlite-vec.c @@ -529,7 +529,11 @@ static unsigned int __builtin_popcountl(unsigned int x) { } #else #include +#ifdef _WIN64 #define __builtin_popcountl __popcnt64 +#else +static unsigned int __builtin_popcountl(u64 n) { return __popcnt((u32)n) + __popcnt((u32)(n >> 32)); } +#endif #endif #endif