Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float

From: Tonnerre
Date: Wed Sep 15 2004 - 10:39:18 EST


Salut,

On Wed, Sep 15, 2004 at 02:14:18AM +0600, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?

The problem is that the kernel can't use the FPU. I think this is
because its context is not saved on context switch (userland ->
kernel), so we'd end up messing up the FPU state, and userland
applications would get silly results for calculations with context
switches in between.

Thus we force gcc to use the library functions for floating point
arith, and since we don't link against gcc's lib, FPU users get a
fancy linker error.

If you want to use floating point arith inside the kernel, you're
probably wrong wanting it. If you really need it, you can

a) emulate it using fixed-point math on unsigned long or
b) manually save the FPU state, load your operations into it, operate,
get the results and restore the FPU state.

I have yet to see someone who really needs to do floating point maths
inside the kernel.

Tonnerre

Attachment: signature.asc
Description: Digital signature