lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 01 Mar 2019 13:07:58 +0000
From:   Chris Wilson <>
To:     Jani Nikula <>,
Cc:     Andrew Morton <>,
Subject: Re: [PATCH] log2: make is_power_of_2() integer constant expression when

Quoting Jani Nikula (2019-03-01 12:52:07)
> While is_power_of_2() is an inline function and likely gets optimized
> for compile time constant arguments, it still doesn't produce an integer
> constant expression that could be used in, say, static data
> initialization or case labels.
> Make is_power_of_2() an integer constant expression when possible,
> otherwise using the inline function to avoid multiple evaluation of the
> parameter.
> Cc: Chris Wilson <>
> Signed-off-by: Jani Nikula <>

It does what it says on the tin and allows for

static const is_pot = is_power_of_two(32);

or in the actual case of interest,

BUILD_BUG_ON(is_power_of_two(x) ? test1(x) : test2(x)).

The only question remains can build_bug.h include ilog2.h and use this
macro instead of having its own copy? Or that may be overkill for a
single commonplace macro.

Reviewed-by: Chris Wilson <>

Powered by blists - more mailing lists