2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

fix: nil: Fix ISC_LEADING_ZEROS and ISC_TRAILING_ZEROS macros

Closes #5488

Merge branch '5488-fix-isc-leading-trailing-zeros-macros' into 'main'

See merge request isc-projects/bind9!10875
This commit is contained in:
Mark Andrews 2025-08-21 09:54:29 +10:00
commit b7eb292121

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))