mirror of
https://github.com/neovim/neovim
synced 2025-07-27 17:02:14 +00:00
build: "popcount" name conflict on NetBSD #28983
Problem: NetBSD's libc already has a function by the same name. Solution: Rename popcount to xpopcount and add #if defined(__NetBSD__) to prefer NetBSD's own implementation. This fixes #28983.
This commit is contained in:
@ -2354,8 +2354,8 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = (win != NULL) + (buf != NULL);
|
unsigned count = (win != NULL) + (buf != NULL);
|
||||||
VALIDATE(popcount(opts->is_set__redraw_) > count, "%s", "at least one action required", {
|
VALIDATE(xpopcount(opts->is_set__redraw_) > count, "%s", "at least one action required", {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,13 +78,15 @@ int xctz(uint64_t x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Count number of set bits in bit field.
|
/// Count number of set bits in bit field.
|
||||||
int popcount(uint64_t x)
|
unsigned xpopcount(uint64_t x)
|
||||||
{
|
{
|
||||||
// Use compiler builtin if possible.
|
// Use compiler builtin if possible.
|
||||||
#if defined(__clang__) || defined(__GNUC__)
|
#if defined(__NetBSD__)
|
||||||
return __builtin_popcountll(x);
|
return popcount64(x);
|
||||||
|
#elif defined(__clang__) || defined(__GNUC__)
|
||||||
|
return (unsigned)__builtin_popcountll(x);
|
||||||
#else
|
#else
|
||||||
int count = 0;
|
unsigned count = 0;
|
||||||
for (; x != 0; x >>= 1) {
|
for (; x != 0; x >>= 1) {
|
||||||
if (x & 1) {
|
if (x & 1) {
|
||||||
count++;
|
count++;
|
||||||
|
Reference in New Issue
Block a user