]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix ISC_LEADING_ZEROS and ISC_TRAILING_ZEROS macros
authorMark Andrews <marka@isc.org>
Wed, 20 Aug 2025 09:38:00 +0000 (19:38 +1000)
committerMark Andrews <marka@isc.org>
Wed, 20 Aug 2025 23:12:14 +0000 (09:12 +1000)
lib/isc/include/isc/bit.h

index 78a72df3e9de32d64e7eba6069eec5c03982ac50..59c11e47ec839602149379fef631e4ee5206e603 100644 (file)
 #ifdef HAVE_BUILTIN_CLZG
 #define ISC_LEADING_ZEROS(x) __builtin_clzg(x, (int)(sizeof(x) * 8))
 #else /* HAVE_BUILTIN_CLZG */
-#define ISC_LEADING_ZEROS(x)                           \
-       ((x) == 0) ? (sizeof(x) * 8)                   \
-                  : _Generic((x),                     \
-                       unsigned int: __builtin_clz,   \
-                       unsigned long: __builtin_clzl, \
-                       unsigned long long: __builtin_clzll)(x)
+#define ISC_LEADING_ZEROS(x)                            \
+       (((x) == 0) ? (sizeof(x) * 8)                   \
+                   : _Generic((x),                     \
+                        unsigned int: __builtin_clz,   \
+                        unsigned long: __builtin_clzl, \
+                        unsigned long long: __builtin_clzll)(x))
 #endif /* HAVE_BUILTIN_CLZG */
 
 #ifdef HAVE_BUILTIN_CTZG
 #define ISC_TRAILING_ZEROS(x) __builtin_ctzg(x, (int)sizeof(x) * 8)
 #else /* HAVE_BUILTIN_CTZG */
-#define ISC_TRAILING_ZEROS(x)                          \
-       ((x) == 0) ? (sizeof(x) * 8)                   \
-                  : _Generic((x),                     \
-                       unsigned int: __builtin_ctz,   \
-                       unsigned long: __builtin_ctzl, \
-                       unsigned long long: __builtin_ctzll)(x)
+#define ISC_TRAILING_ZEROS(x)                           \
+       (((x) == 0) ? (sizeof(x) * 8)                   \
+                   : _Generic((x),                     \
+                        unsigned int: __builtin_ctz,   \
+                        unsigned long: __builtin_ctzl, \
+                        unsigned long long: __builtin_ctzll)(x))
 #endif /* HAVE_BUILTIN_CTZG */
 
 #define ISC_LEADING_ONES(x)  ISC_LEADING_ZEROS(~(x))