From ff897112a0d2510c4c94453c0375ebc63568eff8 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Sat, 16 Mar 2024 21:23:17 -0400 Subject: [PATCH] Fix building on NetBSD The static inline function popcount64() conflicts with a function with NetBSD's libc. https://man.netbsd.org/popcount.3 --- libpopcnt.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libpopcnt.h b/libpopcnt.h index ffcd976..1291d2d 100644 --- a/libpopcnt.h +++ b/libpopcnt.h @@ -149,7 +149,7 @@ extern "C" { * It uses 12 arithmetic operations, one of which is a multiply. * http://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation */ -static inline uint64_t popcount64(uint64_t x) +static inline uint64_t libpopcount64(uint64_t x) { uint64_t m1 = 0x5555555555555555ll; uint64_t m2 = 0x3333333333333333ll; @@ -222,7 +222,7 @@ static inline uint64_t popcnt64(uint64_t x) static inline uint64_t popcnt64(uint64_t x) { - return popcount64(x); + return libpopcount64(x); } #endif @@ -645,14 +645,14 @@ static inline uint64_t popcnt(const void* data, uint64_t size) * We use unaligned memory accesses here to improve performance. */ for (; i < size - size % 8; i += 8) - cnt += popcount64(*(const uint64_t*)(ptr + i)); + cnt += libpopcount64(*(const uint64_t*)(ptr + i)); if (i < size) { uint64_t val = 0; size_t bytes = (size_t)(size - i); memcpy(&val, &ptr[i], bytes); - cnt += popcount64(val); + cnt += libpopcount64(val); } return cnt; @@ -750,7 +750,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size) uint64_t val = 0; size_t bytes = (size_t)(size - i); memcpy(&val, &ptr[i], bytes); - cnt += popcount64(val); + cnt += libpopcount64(val); } return cnt;