Re: unresolved symbols __udivdi3 and __umoddi3

From: Daniel Phillips (phillips@bonn-fries.net)
Date: Mon Jan 28 2002 - 06:08:49 EST


On January 25, 2002 05:56 pm, Richard B. Johnson wrote:
> On Fri, 25 Jan 2002, wrote:
>
> > I am writing a module and would like to perform arithmetic on long
> > long variables. When I try to do this the module does not load due
> > to the unresolved symbols __udivdi3 and __umoddi3. I notice these
> > are normally defined in libc. Is there any way I can do this in a
> > kernel module.
> >
> > Many Thanks
> >
> > Simon.
>
> Normally, in modules, the granularity is such that divisions can
> be made by powers-of-two. In a 32-bit world, the modulus that you
> obtain with umoddi3 (the remainder from a long-long, division) should
> normally fit within a 32-bit variable. If you insist upon doing 64-bit
> math in a 32-bit world, then you can either make your own procedures
> and link them, of you can "appropriate" them from the 'C' runtime
> library code, include them with your source, assemble, and link them
> in.

Let's be clear on one thing. There is nothing unnatural about
32bits * 32bits = 64bits or 64bits / 32bits = 32bits in a 32 bit world.
In fact, it is a rare architecture that does not support this directly
in hardware. It may be awkward to express it in C, but since when has
that ever stopped us from using the best machine instructions for the
job?

Personally, I find the omission of these mixed size muldiv operations
from the kernel a great inconvenience. Think 'multiply by a ratio'.
Yes, I know that by various posturings you can force most problems
that would be most naturally be expressed this way into some other
form, but several things suffer:

  - Readability
  - Efficiency
  - Code complexity
  - Code size

I think the argument I've seen most often presented against mixed
size muldiv operations goes something like 'I've never used them, so
why would anybody need them?'. This just means that somebody hasn't
written very many kinds of programs, particularly the kind of code
we need to write if we are ever going to get the VM and IO
balancing code working properly.

-- 
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jan 31 2002 - 21:00:49 EST