2005-05-24 12:27:27

by Mateusz Berezecki

[permalink] [raw]
Subject: __udivdi3 and linux kernel u64 division question [x86]

Hi list members,

After a failure of compilation of the similar code snippet


u64 mconst = somebig64bitvalue;
u64 tmp = some32bitvalue;
u64 r = mconst / tmp;

I encounter compilation error and gcc reporting __udivdi3 has not been
found!
After firing up cscope I found that this function has never(?) been
implemented for
x86 architecture. How is it possible that during compilation process of
some module
make system tries to link with nonexisting function?

I've also found a do_div() and it was sufficent for my purposes but Im
still curious about
__udivdi3. Can someone explain this issue to me?


2005-05-24 12:37:47

by Arjan van de Ven

[permalink] [raw]
Subject: Re: __udivdi3 and linux kernel u64 division question [x86]

On Tue, 2005-05-24 at 14:29 +0200, Mateusz Berezecki wrote:
> Hi list members,
>
> After a failure of compilation of the similar code snippet
>
>
> u64 mconst = somebig64bitvalue;
> u64 tmp = some32bitvalue;
> u64 r = mconst / tmp;

you shouldn't do this in linux

> I've also found a do_div() and it was sufficent for my purposes but Im
> still curious about
> __udivdi3. Can someone explain this issue to me?

do_div is a very small subset of divides.

Also.. you forgot to put the URL of your module into your email..



2005-05-24 13:08:48

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: __udivdi3 and linux kernel u64 division question [x86]

On Tue, 2005-05-24 14:29:44 +0200, Mateusz Berezecki <[email protected]> wrote:
> u64 mconst = somebig64bitvalue;
> u64 tmp = some32bitvalue;
> u64 r = mconst / tmp;
>
> I encounter compilation error and gcc reporting __udivdi3 has not been
> found!
> After firing up cscope I found that this function has never(?) been
> implemented for
> x86 architecture. How is it possible that during compilation process of
> some module
> make system tries to link with nonexisting function?
>
> I've also found a do_div() and it was sufficent for my purposes but Im
> still curious about
> __udivdi3. Can someone explain this issue to me?

In some cases, gcc decides that a given division is too complicated to
do it in one assembler instruction. That's especially true for things
that newer CPUs support but older lack. In these cases, gcc emits a
function call instead of the actual division and normally, libgcc would
provide these functions.

However, it's each architecture's decision to link-in libgcc or not,
because it can open another can of worms. Alternatively, you can
implement these little functions on your own and put them somewhere in
some library file.

MfG, JBG

--
Jan-Benedict Glaw [email protected] . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));


Attachments:
(No filename) (1.46 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments