Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Oct 2014 15:02:07 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        "Alexander V. Chernikov" <melifaro@FreeBSD.org>, src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org
Subject:   Re: svn commit: r273274 - head/sys/netpfil/ipfw
Message-ID:  <5443A83F.5090807@FreeBSD.org>
In-Reply-To: <201410191115.s9JBFJxA058370@svn.freebsd.org>
References:  <201410191115.s9JBFJxA058370@svn.freebsd.org>

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

-- 
Andriy Gapon



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