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

From: Erik Andersen
Date: Sun Aug 31 2003 - 17:25:59 EST


On Sun Aug 31, 2003 at 02:05:25PM -0700, Linus Torvalds wrote:
>
> On Fri, 29 Aug 2003, Erik Andersen wrote:
> >
> > gcc then generates code calling __udivdi3 and __umoddi3. Since
> > the kernel does not provide these, people keep reinventing them.
> > Perhaps it is time to kill off do_div and all its little friends
> > and simply copy __udivdi3 and __umoddi3 from libgcc.....
>
> No. do_div() does _nothing_ like __udivdi3/__umoddi3.
>
> Read the documentation.

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.
Except it does unexpected things like modify its arguments...

Most places in the kernel using do_div() not because it is the
right thing to do, but because they tried to do something
seemingly simple such as:

u64 foo, bar, baz;
...
baz = foo / bar;

and then got an error that __udivdi3 was undefined. So the
authors then go hunting for a way to do a 64 bit division and
find do_div()...

See mm/vmscan.c, mm/shmem.c, fs/proc/proc_misc.c,
drivers/ide/ide-disk.c, etc, etc, etc, for plenty of examples of
_exactly_ this sort of thing. Every one of them is using
do_div() to perform 64 bit division. Not becase that is the
right thing to do, but because __udivdi3 is missing.

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
-
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/