diff options
author | Malte Dehling <mdehling@gmail.com> | 2024-05-27 04:14:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-27 04:14:57 -0700 |
commit | 104800ce2eadd21475b5a4897265a8a177e58d77 (patch) | |
tree | 08650929d2c0815cfc1d88211fab799b83b427d1 /src | |
parent | 9a0239fdc8b380a8a32739a7c722fe90e3c2e910 (diff) | |
download | rneovim-104800ce2eadd21475b5a4897265a8a177e58d77.tar.gz rneovim-104800ce2eadd21475b5a4897265a8a177e58d77.tar.bz2 rneovim-104800ce2eadd21475b5a4897265a8a177e58d77.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/vim.c | 4 | ||||
-rw-r--r-- | src/nvim/math.c | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index fc780e1248..52ab18cbff 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2354,8 +2354,8 @@ void nvim__redraw(Dict(redraw) *opts, Error *err) } } - int count = (win != NULL) + (buf != NULL); - VALIDATE(popcount(opts->is_set__redraw_) > count, "%s", "at least one action required", { + unsigned count = (win != NULL) + (buf != NULL); + VALIDATE(xpopcount(opts->is_set__redraw_) > count, "%s", "at least one action required", { return; }); diff --git a/src/nvim/math.c b/src/nvim/math.c index 1ccf4d7806..4ca212413b 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -78,13 +78,15 @@ int xctz(uint64_t x) } /// Count number of set bits in bit field. -int popcount(uint64_t x) +unsigned xpopcount(uint64_t x) { // Use compiler builtin if possible. -#if defined(__clang__) || defined(__GNUC__) - return __builtin_popcountll(x); +#if defined(__NetBSD__) + return popcount64(x); +#elif defined(__clang__) || defined(__GNUC__) + return (unsigned)__builtin_popcountll(x); #else - int count = 0; + unsigned count = 0; for (; x != 0; x >>= 1) { if (x & 1) { count++; |