lists.zerezo.com



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [v4l-dvb-maintainer] [PATCH] [PATCH] v4l: Introduce "index" attribute for persistent video4linux device nodes



On Mon, 23 Jun 2008, Brandon Philips wrote:
> On 13:34 Sun 22 Jun 2008, Hans Verkuil wrote:
> > Or if that's not possible for some reason, at least avoid the
> > expensive struct allocation and simply use a bitarray allocated on the
> > stack (max 256 devices = 32 bytes)?
>
> Using ffz and set_bit would be an option (since bitfields can't be used
> on arrays) but I don't think the savings would be worth the effort since
> we would need to use division and an array if VIDEO_NUM_DEVICES grows
> past 256.

unsigned long used[VIDEO_NUM_DEVICES / (sizeof(used[0])*8)];

for_each_device {
    set_bit(index, used);
}

empty = find_first_zero_bit(used, VIDEO_NUM_DEVICES);

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list