• Yury Norov's avatar
    lib/find_bit: introduce FIND_FIRST_BIT() macro · 58414bbb
    Yury Norov authored
    Now that we have many flavors of find_first_bit(), and expect even more,
    it's better to have one macro that generates optimal code for all and makes
    maintaining of slightly different functions simpler.
    
    The logic common to all versions is moved to the new macro, and all the
    flavors are generated by providing an FETCH macro-parameter, like
    in this example:
    
      #define FIND_FIRST_BIT(FETCH, MUNGE, size) ...
    
      find_first_ornot_and_bit(addr1, addr2, addr3, size)
      {
            return FIND_FIRST_BIT(addr1[idx] | ~addr2[idx] & addr3[idx], /* nop */, size);
      }
    
    The FETCH may be of any complexity, as soon as it only refers
    the bitmap(s) and an iterator idx.
    
    MUNGE is here to support _le code generation for BE builds. May be
    empty.
    Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Reviewed-by: default avatarValentin Schneider <vschneid@redhat.com>
    Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
    58414bbb
find_bit.c 3.99 KB