lkml.org 
[lkml]   [2006]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [parisc-linux] [patch 12/44] generic sched_find_first_bit()
    On Wed, Feb 01, 2006 at 06:02:36PM +0900, Akinobu Mita wrote:
    > This patch introduces the C-language equivalent of the function:
    > int sched_find_first_bit(const unsigned long *b);

    Akinobu, would you prefer this is a slightly cleaner way?
    (Not compile tested)

    static inline int sched_find_first_bit(const unsigned long *b)
    {
    if (unlikely(b[0]))
    return __ffs(b[0]);
    if (unlikely(b[1]))
    return __ffs(b[1]) + BITS_PER_LONG;
    #if BITS_PER_LONG == 32
    if (unlikely(b[2]))
    return __ffs(b[2]) + 64;
    if (b[3])
    return __ffs(b[3]) + 96;
    #endif
    return __ffs(b[128/BITS_PER_LONG]) + 128;
    }

    If BITS_PER_LONG isn't defined, the link step will fail and point
    at a some unknown .o as the offender. But it's the responsibility
    of the header file to make sure it's including the BITS_PER_LONG
    definition, not the code that calls sched_find_first_bit().

    hth,
    grant
    -
    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 04:51    [W:0.022 / U:121.048 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site