lkml.org 
[lkml]   [2009]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] Introduce a boolean "single_bit_set" function.
    From
    Date
    Robert P. J. Day píše v Čt 28. 05. 2009 v 08:32 -0400:
    > On Thu, 28 May 2009, Petr Tesarik wrote:
    >
    > > Robert P. J. Day píše v Čt 23. 04. 2009 v 13:43 -0400:
    > > > A boolean single_bit_set() routine would simplify the numerous
    > > > constructs of the form (((n & (n - 1)) == 0)) when testing for
    > > > single-bitness.
    > > >
    > > > Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
    > > >
    > > > ---
    > > >
    > > > This is similar to the current is_power_of_2() routine defined in
    > > > include/linux/log2.h, which is mathematically identical but,
    > > > semantically, should be defined independently just so the code is more
    > > > readable.
    > > >
    > > > I'm open to an alternative function name.
    > >
    > > ispow2() ?
    > >
    > > Because what it really does is to check that a value is a power of two,
    > > doesn'it.
    >
    > by the way, a search for places in the code that are candidates for
    > this kind of rewriting can be seen at one of my wiki kernel cleanup
    > pages:
    >
    > http://www.crashcourse.ca/wiki/index.php/The_style_script

    Ah, yes, sorry, I missed the top of your email.

    Ok, then my only concern is that the hweight* functions return the exact
    weight, which might be much less efficient if all we need is to know
    whether it's 1.

    Theoretically, gcc should be able to optimize things out, but I'm not
    all that optimistic about how well it does it.

    Petr Tesarik


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2009-05-28 15:15    [W:0.035 / U:1.060 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site