lists.openwall.net   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  linux-hardening  linux-cve-announce  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]
Message-ID: <CAMo8BfKW15_vLWLHmxPDzB4qWNkH6R8yYJ4fMtVXRge6eMj3yA@mail.gmail.com>
Date:   Tue, 10 May 2022 21:55:23 -0700
From:   Max Filippov <jcmvbkbc@...il.com>
To:     Yury Norov <yury.norov@...il.com>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        David Laight <David.Laight@...lab.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Joe Perches <joe@...ches.com>,
        Julia Lawall <Julia.Lawall@...ia.fr>,
        Michał Mirosław <mirq-linux@...e.qmqm.pl>,
        Nicholas Piggin <npiggin@...il.com>,
        Nicolas Palix <nicolas.palix@...g.fr>,
        Peter Zijlstra <peterz@...radead.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Matti Vaittinen <Matti.Vaittinen@...rohmeurope.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Chris Zankel <chris@...kel.net>,
        Christophe Leroy <christophe.leroy@...roup.eu>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Kumar Kartikeya Dwivedi <memxor@...il.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        "open list:TENSILICA XTENSA PORT (xtensa)" 
        <linux-xtensa@...ux-xtensa.org>
Subject: Re: [PATCH 08/22] bitops: introduce MANY_BITS() macro

On Tue, May 10, 2022 at 12:16 PM Yury Norov <yury.norov@...il.com> wrote:
>
> Hi Max,
>
> On Tue, May 10, 2022 at 10:57:25AM -0700, Max Filippov wrote:
> > Hi Yury,
> >
> > On Tue, May 10, 2022 at 8:48 AM Yury Norov <yury.norov@...il.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,
>
> This patch introduces a macro MANY_BITS() in include/linux/bitops.h, which
> is a full analogue of IS_POW2(). Would it work for you to switch to
> MANY_BITS()?

It would, I guess. It would also work if is_power_of_2 was a macro.

-- 
Thanks.
-- Max

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ