Linus Torvalds writes: (Summary) wrote:
If sparse warns about it, then presumably gcc with -Wvla warns about it too? So I suspect that what you'd want is
So I suspect that what you'd want is
#define ilog2(n) \
__builtin_choose_expr(__is_constexpr(n), \
const_ilog2(n), \
__builtin_choose_expr(sizeof(n) <= 4, \
__ilog2_u32(n), \
__ilog2_u64(n)))
__ilog2_u64(n)))
or something.
[...]
__ilog2_32() and __ilog2_64(),If sparse warns about it, then presumably gcc with -Wvla warns about it too? So I suspect that what you'd want is
So I suspect that what you'd want is
#define ilog2(n) \
__builtin_choose_expr(__is_constexpr(n), \
const_ilog2(n), \
__builtin_choose_expr(sizeof(n) <= 4, \
__ilog2_u32(n), \
__ilog2_u64(n)))
__ilog2_u64(n)))
or something.