[PATCH] Avoid divides in BITS_TO_LONGS

Previous thread: [PATCH] KGDB-8250: fix initial interrupt by Jan Kiszka on Thursday, February 7, 2008 - 12:38 am. (1 message)

Next thread: [PATCH] m68k: kill page walker compile warning by Geert Uytterhoeven on Thursday, February 7, 2008 - 1:10 am. (1 message)
From: Eric Dumazet
Date: Thursday, February 7, 2008 - 12:54 am

BITS_PER_LONG is a signed value (32 or 64)

DIV_ROUND_UP(nr, BITS_PER_LONG) performs signed arithmetic if "nr" is signed too.

Converting BITS_TO_LONGS(nr) to DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
makes sure compiler can perform a right shift, even if "nr" is a signed value, 
instead of an expensive integer divide.

Applying this patch saves 141 bytes on x86 when CONFIG_CC_OPTIMIZE_FOR_SIZE=y
and speedup bitmap operations.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

Previous thread: [PATCH] KGDB-8250: fix initial interrupt by Jan Kiszka on Thursday, February 7, 2008 - 12:38 am. (1 message)

Next thread: [PATCH] m68k: kill page walker compile warning by Geert Uytterhoeven on Thursday, February 7, 2008 - 1:10 am. (1 message)