Re: [RFC][PATCH] introduce ptr_diff()
From: David Howells
Date:  Thu Aug 19 2010 - 08:03:24 EST
Namhyung Kim <namhyung@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/