svn commit: r273274 - head/sys/netpfil/ipfw
Luigi Rizzo
rizzo at iet.unipi.it
Tue Oct 21 21:32:44 UTC 2014
On Sun, Oct 19, 2014 at 03:02:07PM +0300, Andriy Gapon wrote:
> On 19/10/2014 14:15, Alexander V. Chernikov wrote:
> > +static uint32_t
> > +roundup2p(uint32_t v)
> > +{
> > +
> > + v--;
> > + v |= v >> 1;
> > + v |= v >> 2;
> > + v |= v >> 4;
> > + v |= v >> 8;
> > + v |= v >> 16;
> > + v++;
> > +
> > + return (v);
> > +}
>
> I think that on platforms where an optimized version of fls() is available that
> would work faster than this cool piece of bit magic.
This code is not performance critical. I wouldn't bother optimizing it.
Rather, since this code must be platform independent, I'd like
to give it a name that does not conflict with any builtin.
cheers
luigi
>
More information about the svn-src-all
mailing list