call for API review: new bitstring functions

Max Laier max at love2party.net
Fri Jan 2 09:11:18 PST 2004


On Friday 02 January 2004 08:28, Jeffrey Hsu wrote:
> I need to find the first and last bit set within a subrange of an array
> of bits.  Rather than make up an adhoc API for these two functions, I
> propose adding the following general functions to the bitstring(3) API:
>
> /* Return the first bit set in the range [n, m] or -1 if none found. */
> int bit_ffsrange(bitstr_t *name, int n, int m)
>
> /* Return the highest (last) bit set in the range [n, m] or -1 if none
> found. */
> int bit_lfsrange(bitstr_t *name, int n, int m)
>
> 							Jeffrey

AFAIR, bitstring is "macro centric" and uses an additional reference to return 
values, you'd like to keep that?! Apart from that I dislike the naming a bit 
and would rather go for: bit_rffs(), bit_rfls() ... as it is already used for 
the bit_n*-class functions.
btw, bit_lfsrange() should be bit_flsrange() IMO as it spells FindLastSet and 
FindFirstSet not LastFindSet.

-- 
Best regards,				| max at xxxxxxxxxxxxxx
Max Laier				| ICQ #67774661
http://pf4freebsd.love2party.net/	| mlaier at EFnet #DragonFlyBSD






More information about the Kernel mailing list