]> git.baikalelectronics.ru Git - kernel.git/commit
lib/find_bit: introduce FIND_FIRST_BIT() macro
authorYury Norov <yury.norov@gmail.com>
Thu, 15 Sep 2022 02:07:27 +0000 (19:07 -0700)
committerYury Norov <yury.norov@gmail.com>
Wed, 21 Sep 2022 19:15:53 +0000 (12:15 -0700)
commitb59be57cc3a056e05499d5b72c6de300edf30c5e
treee18acc7bcec118a162e967d177887ae4e4d80211
parenta959c3fdbcbe9ef72303134de2225d38a7ba3ec9
lib/find_bit: introduce FIND_FIRST_BIT() macro

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: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
lib/find_bit.c