Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/arch/arm/ep93xx



simonb%NetBSD.org@localhost wrote:

> -       remaining = n * TIMER_FREQ / 1000000;
> +       remaining = (uint64_t)n * TIMER_FREQ / 1000000;
> 
> do instead, forcing 64-bit arithmetic?

Some ports have another example:
---
        if (n <= UINT_MAX / TIMB_FREQ) {
                /*
                 * For unsigned arithmetic, division can be replaced with
                 * multiplication with the inverse and a shift.
                 */
                remaining = n * TIMB_FREQ / 1000000;
        } else {
                /* This is a very long delay.
                 * Being slow here doesn't matter.
                 */
                remaining = (unsigned long long) n * TIMB_FREQ / 1000000;
        }
---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index