From owner-svn-src-head@FreeBSD.ORG Tue Oct 21 21:32:44 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7EF14B6B; Tue, 21 Oct 2014 21:32:44 +0000 (UTC) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 3F764C4; Tue, 21 Oct 2014 21:32:42 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 4D9057300B; Tue, 21 Oct 2014 23:36:21 +0200 (CEST) Date: Tue, 21 Oct 2014 23:36:21 +0200 From: Luigi Rizzo To: Andriy Gapon Subject: Re: svn commit: r273274 - head/sys/netpfil/ipfw Message-ID: <20141021213621.GA70907@onelab2.iet.unipi.it> References: <201410191115.s9JBFJxA058370@svn.freebsd.org> <5443A83F.5090807@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5443A83F.5090807@FreeBSD.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, "Alexander V. Chernikov" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Oct 2014 21:32:44 -0000 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 >