Re: MSEC_TO_JIFFIES is messed up...

From: Roland Dreier
Date: Wed May 12 2004 - 17:06:55 EST


> Being curious, I tried that and got the same results. But this:
>
> int f(unsigned int x)
> {
> return x * (1000 / 1000);
> }
>
> creates this:
> f:
> pushl %ebp
> movl %esp, %ebp
> movl 8(%ebp), %eax
> leave
> ret

Of course the compiler can optimize (1000 / 1000) into 1 at compile
time. However, the original code was doing something like

x * HZ / 1000

if you change that to

x * (HZ / 1000)

then obviously that breaks if HZ is not a multiple of 1000.

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