2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Fix ISC_LEADING_ZEROS and ISC_TRAILING_ZEROS macros

This commit is contained in:
Mark Andrews 2025-08-20 19:38:00 +10:00
parent 5d219d2612
commit 1c3b9698bc

View File

@ -48,23 +48,23 @@
#ifdef HAVE_BUILTIN_CLZG #ifdef HAVE_BUILTIN_CLZG
#define ISC_LEADING_ZEROS(x) __builtin_clzg(x, (int)(sizeof(x) * 8)) #define ISC_LEADING_ZEROS(x) __builtin_clzg(x, (int)(sizeof(x) * 8))
#else /* HAVE_BUILTIN_CLZG */ #else /* HAVE_BUILTIN_CLZG */
#define ISC_LEADING_ZEROS(x) \ #define ISC_LEADING_ZEROS(x) \
((x) == 0) ? (sizeof(x) * 8) \ (((x) == 0) ? (sizeof(x) * 8) \
: _Generic((x), \ : _Generic((x), \
unsigned int: __builtin_clz, \ unsigned int: __builtin_clz, \
unsigned long: __builtin_clzl, \ unsigned long: __builtin_clzl, \
unsigned long long: __builtin_clzll)(x) unsigned long long: __builtin_clzll)(x))
#endif /* HAVE_BUILTIN_CLZG */ #endif /* HAVE_BUILTIN_CLZG */
#ifdef HAVE_BUILTIN_CTZG #ifdef HAVE_BUILTIN_CTZG
#define ISC_TRAILING_ZEROS(x) __builtin_ctzg(x, (int)sizeof(x) * 8) #define ISC_TRAILING_ZEROS(x) __builtin_ctzg(x, (int)sizeof(x) * 8)
#else /* HAVE_BUILTIN_CTZG */ #else /* HAVE_BUILTIN_CTZG */
#define ISC_TRAILING_ZEROS(x) \ #define ISC_TRAILING_ZEROS(x) \
((x) == 0) ? (sizeof(x) * 8) \ (((x) == 0) ? (sizeof(x) * 8) \
: _Generic((x), \ : _Generic((x), \
unsigned int: __builtin_ctz, \ unsigned int: __builtin_ctz, \
unsigned long: __builtin_ctzl, \ unsigned long: __builtin_ctzl, \
unsigned long long: __builtin_ctzll)(x) unsigned long long: __builtin_ctzll)(x))
#endif /* HAVE_BUILTIN_CTZG */ #endif /* HAVE_BUILTIN_CTZG */
#define ISC_LEADING_ONES(x) ISC_LEADING_ZEROS(~(x)) #define ISC_LEADING_ONES(x) ISC_LEADING_ZEROS(~(x))