From owner-svn-src-head@FreeBSD.ORG Mon Oct 20 20:10:45 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 E799B91A for ; Mon, 20 Oct 2014 20:10:45 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B214A277 for ; Mon, 20 Oct 2014 20:10:45 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by gateway2.nyi.internal (Postfix) with ESMTP id 03EB320945 for ; Mon, 20 Oct 2014 16:10:43 -0400 (EDT) Received: from web6 ([10.202.2.216]) by compute6.internal (MEProxy); Mon, 20 Oct 2014 16:10:44 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.net; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=pgkbJF81e+6GKJ4yW9TwHi+XOfs=; b=jWJG SOl4I+hQ3kzWA6fnwHB0/VgRyDZwS5EpQvOGuV+PSuR7G24KLvckwg6ufccwSZI+ W7GzbfMkYlG4IFgf7v5pJ0Bnzd7N5ORkBzf/DGR9HZcSFffrnsyQE7r2yhC5NwP6 EH2XPhgSRycnKkTeQBdlwqv5Ic17YqfI5s0YcEM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=pgkbJF81e+6GKJ4yW9TwHi+X Ofs=; b=g52J5mVm7senD11MQCeCiWHKmRUvC61sVpMEwKTx27IENejNxKB/P3hk E5Kalls2s9XeESR3MgUEt5YO9UhSpfl+4MuA6Oy69xn+3liOrksy3pYzqUX9OS+y JnP/x87YPJD/88hWaEHu9ua/jTTN7TPJegDiHFguF49iLx5ZH3o= Received: by web6.nyi.internal (Postfix, from userid 99) id BCE3648D60; Mon, 20 Oct 2014 16:10:43 -0400 (EDT) Message-Id: <1413835843.3284180.181238849.236EFDEE@webmail.messagingengine.com> X-Sasl-Enc: J98mwy4wHPZgD8b9QvPHFWRa5OaTyvZ+IFaJO1eM754W 1413835843 From: Bruce Simpson To: Andriy Gapon , "Alexander V. Chernikov" , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-e69fc525 In-Reply-To: <5443A83F.5090807@FreeBSD.org> References: <201410191115.s9JBFJxA058370@svn.freebsd.org> <5443A83F.5090807@FreeBSD.org> Subject: Re: svn commit: r273274 - head/sys/netpfil/ipfw Date: Mon, 20 Oct 2014 21:10:43 +0100 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: Mon, 20 Oct 2014 20:10:46 -0000 On Sun, 19 Oct 2014, at 13:02, Andriy Gapon wrote: > 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 is a common enough idiom that perhaps a macro should be added: sys/param.h: #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ #define powerof2(x) ((((x)-1)&(x))==0) sys/amd64/amd64/mp_machdep.c: /* * Round up to the next power of two, if necessary, and then * take log2. * Returns -1 if argument is zero. */ static __inline int mask_width(u_int x) { return (fls(x << (1 - powerof2(x))) - 1); } -- BMS (sent via webmail)