From 7b3e6ed082074e1fc4be22f3857813a5988ecef3 Mon Sep 17 00:00:00 2001 From: dktue <2878623+dktue@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:19:05 +0100 Subject: [PATCH] build: rename libpopcnt's popcount64 to avoid NetBSD libc clash (#821) --- Makefile | 2 +- include/external/libpopcnt.h | 10 +++++----- src/sorted_node_store.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b651ec64..15e43d99 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ PLATFORM_PATH := /usr/local # First, find what the Lua executable is called # - when a new Lua is released, then add it before 5.4 here LUA_CMD := $(shell luajit -e 'print("luajit")' 2> /dev/null || lua -e 'print("lua")' 2> /dev/null || lua5.4 -e 'print("lua5.4")' 2> /dev/null || lua5.3 -e 'print("lua5.3")' 2> /dev/null || lua5.2 -e 'print("lua5.2")' 2> /dev/null || lua5.1 -e 'print("lua5.1")' 2> /dev/null) -ifeq ($(LUA_CMD),"") +ifeq ($(LUA_CMD),) $(error Couldn't find Lua interpreter) endif $(info Using ${LUA_CMD}) diff --git a/include/external/libpopcnt.h b/include/external/libpopcnt.h index ffcd976b..b3aad574 100644 --- a/include/external/libpopcnt.h +++ b/include/external/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 popcnt64_bitwise(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 popcnt64_bitwise(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 += popcnt64_bitwise(*(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 += popcnt64_bitwise(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 += popcnt64_bitwise(val); } return cnt; diff --git a/src/sorted_node_store.cpp b/src/sorted_node_store.cpp index c6d282e8..20eb0c9f 100644 --- a/src/sorted_node_store.cpp +++ b/src/sorted_node_store.cpp @@ -74,7 +74,7 @@ namespace SortedNodeStoreTypes { #if defined(SORTED_NODE_STORE_RUNTIME_POPCNT) if (cpuHasPopcnt) return popcnt64(x); - return ::popcount64(x); + return ::popcnt64_bitwise(x); #elif defined(__GNUC__) || defined(__clang__) return __builtin_popcountll(x); #elif defined(_MSC_VER) && defined(_M_X64)