Re: [PATCHSET][2.6-test4][0/6]Support for HPET based timer - Take 2

Linus Torvalds
2003-08-31T22:48:32Z

On Sun, 31 Aug 2003, Erik Andersen wrote:
>
> Been there done that, got the scars to prove it. do_div() is a
> macro that acts sortof like the ISO C99 lldiv(3) function.

No.

You missed a very important part of do_div() - it has _totally_ different
numerical range than a regular /, % or lldiv() call.

All of /, % and lldiv() work on 64-bit numbers. do_div() DOES NOT!

do_div() very much is all about:

*** 32-bit divisor ***

which also implies that the remainder is 32-bit.

And the fact is, such a division is a lot faster than a full 64-bit
division. On a _lot_ of architectures, but notably so on x86.

It is _not_ a 64-bit divide, and that's not only important, it's the
whole _reason_d'etre_ for the whole function. See?

So by continually confusing it with a 64-bit divide (either by confusing
it with lldiv() or those horrible gcc internal __{div|mod}di3u things),
you miss the whole point of the function.

Linus