Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Sebastian Ude <ude@ha...> - 2002-05-28 17:00:14
I downloaded the acpi-20020517 patch for Kernel 2.2.18.
While trying to debug some strange ACPI behaviour, I found out that the
following macro defined in processor.c causes integer overflows on my
#define US_TO_PM_TIMER_TICKS(t) ((t * PM_TIMER_FREQUENCY) / 1000000)
Note that PM_TIMER_FREQUENCY is defined to be 3579545 in
acpi/include/achware.h. So, invoking the macro for, say, 1000 uS would
((1000 * 3579545) / 1000000)
That seems to be more than the temporary integer variables can handle (this
is an ix386 machine) - thus, my gcc version throws a warning and even more
important, the expression does not produce the expected result.
Possible ways to avoid an integer overflow at that point which I can think
- Perform the operations which each number cast into a "long long" integer
and cast the result back to int.
- Instead of multiplying by PM_TIMER_FREQUENCY and dividing by 1.000.000,
do a floating-point division of PM_TIMER_FREQUENCY and 1.000.000,
multiply the result of the division with "t" and cast the final result
back to "int".
I am afraid this might not be the way that returns the most excact