]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix stdc_count_zeros/stdc_count_ones polyfill mismatch 12165/head
authorAlessio Podda <alessio@isc.org>
Fri, 17 Apr 2026 09:42:53 +0000 (11:42 +0200)
committerAlessio Podda <alessio@isc.org>
Tue, 2 Jun 2026 08:18:13 +0000 (10:18 +0200)
A previous commit introduced a latent bug where the wrong popcount
definition was used when overriding the compilation mode to C23.
This commit fixes it.

lib/dns/qp_p.h
lib/isc/include/isc/bit.h

index 21d7586ab0ea2db3aafa25f67630688dc1c5f04f..0378ce2ef8aeb5b9ea9d8588cd090232c0b9b9aa 100644 (file)
@@ -753,7 +753,7 @@ static inline dns_qpweight_t
 branch_count_bitmap_before(dns_qpnode_t *n, dns_qpshift_t bit) {
        uint64_t mask = (1ULL << bit) - 1 - TAG_MASK;
        uint64_t bitmap = branch_index(n) & mask;
-       return (dns_qpweight_t)stdc_count_zeros(bitmap);
+       return (dns_qpweight_t)stdc_count_ones(bitmap);
 }
 
 /*
index a8b47e16bcee9d8cd016c2326eed3fdc43daadaf..68f01bd5c94a5e7d1c77e9ff2ed5311528517742 100644 (file)
@@ -26,9 +26,9 @@
 #else /* __has_header(<stdbit.h>) */
 
 #ifdef HAVE_BUILTIN_POPCOUNTG
-#define stdc_count_zeros(x) __builtin_popcountg(x)
+#define stdc_count_ones(x) __builtin_popcountg(x)
 #else /* HAVE_BUILTIN_POPCOUNTG */
-#define stdc_count_zeros(x)                         \
+#define stdc_count_ones(x)                          \
        _Generic((x),                               \
                unsigned int: __builtin_popcount,   \
                unsigned long: __builtin_popcountl, \