From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Subject: Re: [RFC][PATCH] introduce ptr_diff() Date: Thu, 19 Aug 2010 13:03:12 +0100 Message-ID: <5790.1282219392@redhat.com> References: <1282217856-8625-1-git-send-email-namhyung@gmail.com> Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42317 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583Ab0HSMDU (ORCPT ); Thu, 19 Aug 2010 08:03:20 -0400 In-Reply-To: <1282217856-8625-1-git-send-email-namhyung@gmail.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Namhyung Kim Cc: dhowells@redhat.com, Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Namhyung Kim wrote: > + if (is_power_of_2(__size)) \ > + __diff = (__addr1 - __addr2) >> ilog2(__size); \ > + else \ > + __diff = (__addr1 - __addr2) / __size; \ You shouldn't need to do this. The compiler's optimiser should switch a divide to a shift for a power-of-2 divisor. David