lkml.org 
[lkml]   [2022]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 08/22] bitops: introduce MANY_BITS() macro
Hi Yury,

On Tue, May 10, 2022 at 8:48 AM Yury Norov <yury.norov@gmail.com> wrote:
> arch/xtensa/kernel/traps.c and include/linux/log2.h define very similar
> functions with different behaviour. XTENSA defines IS_POW2(), and
> log2.h defines is_power_of_2(). The difference is that IS_POW2()
> considers 0 as power of 2, while is_power_of_2() - does not.

IS_POW2 is constructed this way because we know that there is at least
one non-zero bit in the value that it tests.

> This discrepancy may confuse reader. From mathematical point of view,
> 0 is not a power of 2.

If it would reduce the confusion we can add a check that the value is
non-zero in the IS_POW2 macro.

I'd really like to not introduce the local macro and just use something
standard, but I can't use is_power_of_2 in a preprocessor condition,
can I?

--
Thanks.
-- Max

\
 
 \ /
  Last update: 2022-05-10 19:58    [W:0.682 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site