lkml.org 
[lkml]   [2006]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [patch 14/44] generic hweight{64,32,16,8}()
    Date
    On Wednesday 01 February 2006 10:02, Akinobu Mita wrote:
    > unsigned int hweight32(unsigned int w);
    > unsigned int hweight16(unsigned int w);
    > unsigned int hweight8(unsigned int w);
    > unsigned long hweight64(__u64 w);

    IMHO, this should use explicitly sized integers like __u8, __u16 etc, unless
    there are stringent reasons like better register use - which is hard to tell
    for generic C code. Also, why on earth is the returntype for hweight64 a
    long?

    > +static inline unsigned int hweight32(unsigned int w)
    > +{
    > + unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
    > + res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
    [...]

    Why not use unsigned constants here?

    > +static inline unsigned long hweight64(__u64 w)
    > +{
    [..]
    > + u64 res;
    > + res = (w & 0x5555555555555555ul) + ((w >> 1) & 0x5555555555555555ul);

    Why not use initialisation here, too?

    just my 2c

    Uli
    -
    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: 2006-02-03 09:36    [W:0.026 / U:0.152 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site