lkml.org 
[lkml]   [2010]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC][PATCH] introduce ptr_diff()
Date
David Howells <dhowells@redhat.com> writes:

> Namhyung Kim <namhyung@gmail.com> 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.

Only when the numerator is provably non-negative, which is certainly
not the case here.

--
Måns Rullgård
mans@mansr.com

--
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/

\
 
 \ /
  Last update: 2010-08-19 18:21    [W:0.097 / U:0.068 seconds]
©2003-2014 Jasper Spaans. Advertise on this site