lkml.org 
[lkml]   [2007]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: division and cpu usage
Date

> Hello.
>
> I'm new to kernel development and have some questions.
>
> 1. Why can't I divide with regular casting to double ((double)a /
> (double)b)? It gives me strange errors when compiling:
>
> WARNING: "__divdf3" [/root....] undefined!
> WARNING: "__addf3" [/root/...] undefined!
> WARNING: "__floatsidf" [/root/...] undefined!
>
> And if I compile with normal integers, I get zero as the result.

As the HOWTO says:

"The kernel is written using GNU C and the GNU toolchain. While it
adheres to the ISO C89 standard, it uses a number of extensions that are
not featured in the standard. The kernel is a freestanding C
environment, with no reliance on the standard C library, so some
portions of the C standard are not supported. Arbitrary long long
divisions and floating point are not allowed. It can sometimes be
difficult to understand the assumptions the kernel has on the toolchain
and the extensions that it uses, and unfortunately there is no
definitive reference for them. Please check the gcc info pages (`info
gcc`) for some information on them."

The short version is simply that it's very expensive to allow this, adding
overhead even in cases where it isn't used, and there is very little
benefit. For almost every imaginable case where you would want floating
point in the kernel, fixed point works as well or better.

Just scale your numbers by shifting them.

DS


-
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/

\
 
 \ /
  Last update: 2007-08-24 03:07    [W:2.285 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site