Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Oct 2014 23:36:21 +0200
From:      Luigi Rizzo <rizzo@iet.unipi.it>
To:        Andriy Gapon <avg@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, "Alexander V. Chernikov" <melifaro@freebsd.org>
Subject:   Re: svn commit: r273274 - head/sys/netpfil/ipfw
Message-ID:  <20141021213621.GA70907@onelab2.iet.unipi.it>
In-Reply-To: <5443A83F.5090807@FreeBSD.org>
References:  <201410191115.s9JBFJxA058370@svn.freebsd.org> <5443A83F.5090807@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141021213621.GA70907>