lkml.org 
[lkml]   [2022]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/3] lib/find_bit: create find_first_zero_bit_le()
> Just make the macro take that "last word op" as another argument, and
> then you don't need these tricks, and you can do the _le() version in
> lib/find.c file *exactly* like the regular version, using just
>
> #ifdef __BIG_ENDIAN
> unsigned long find_first_zero_bit_le(const unsigned long *addr,
> unsigned long size)
> { return FIND_FIRST_BIT(~addr[idx], swab(val), size); }
> #else
> unsigned long find_first_zero_bit_le(const unsigned long *addr,
> unsigned long size) __alias(find_first_zero_bit);
> #endif
>
> or something like that.
>
> And yes, it means that the "regular" versions need to pass in just
> "val" as a last-word expression, but who cares? It's still cleaner,
> and easier to explain: "The first expression finds the word that
> matches our requirement, the second expression munges the word we
> found into the bit order we use".

OK. I'll do like this:

#define FIND_FIRST_BIT(FETCH, MUNG, size) ...

unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
{
return FIND_FIRST_BIT(~addr[idx], /* NOP */, size);
}

unsigned long find_first_zero_bit_le(const unsigned long *addr, unsigned long size)
{
return FIND_FIRST_BIT(~addr[idx], swab, size);
}

It doesn't actually look that worse.

Thanks,
Yury

\
 
 \ /
  Last update: 2022-08-25 00:12    [W:0.143 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site