Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753688Ab0AVUJq (ORCPT ); Fri, 22 Jan 2010 15:09:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753578Ab0AVUJp (ORCPT ); Fri, 22 Jan 2010 15:09:45 -0500 Received: from terminus.zytor.com ([198.137.202.10]:41367 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752309Ab0AVUJp (ORCPT ); Fri, 22 Jan 2010 15:09:45 -0500 Message-ID: <4B5A05A1.3040901@zytor.com> Date: Fri, 22 Jan 2010 12:08:01 -0800 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Thunderbird/3.0 MIME-Version: 1.0 To: Joe Perches CC: Christoph Lameter , Yinghai Lu , Ingo Molnar , Thomas Gleixner , Andrew Morton , Linus Torvalds , Jesse Barnes , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH 24/38] move round_up/down to kernel.h References: <1264152287-13866-1-git-send-email-yinghai@kernel.org> <1264152287-13866-25-git-send-email-yinghai@kernel.org> <1264188512.32383.118.camel@Joe-Laptop.home> In-Reply-To: <1264188512.32383.118.camel@Joe-Laptop.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 897 Lines: 23 On 01/22/2010 11:28 AM, Joe Perches wrote: > On Fri, 2010-01-22 at 08:52 -0600, Christoph Lameter wrote: >> On Fri, 22 Jan 2010, Yinghai Lu wrote: >>> +#define __round_mask(x,y) ((__typeof__(x))((y)-1)) >>> +#define round_up(x,y) ((((x)-1) | __round_mask(x,y))+1) >>> +#define round_down(x,y) ((x) & ~__round_mask(x,y)) >> s/round/round_power2/ > > s/round/round_power_of_2/ > BUILD_BUG_ON_NOT_POWER_OF_2 > Uh... the whole reason why the classical rounding functions don't work is that we're using it with non-constants, and therefore the compiler doesn't know that we're restricted to powers of two (and therefore it will generate divides.) -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/