Re: Floating point in kernel

From: Khimenko Victor (khim@sch57.msk.ru)
Date: Wed May 03 2000 - 12:49:34 EST


In <Pine.LNX.4.10.10005030937120.25470-100000@neptune.terran> B. James Phillippe (bryan@terran.org) wrote:
> Hello,

> I know this is not legal. However, I'm reviewing some kernel module code
> which basically does:

> unsigned long foo = some_other_ulong * 1.234;

> This code has apparently been working for some time. According to C rules
> of type promotion, "some_other_ulong" should be promoted to a double to
> store the result of the expression, before discarding the fraction and
> assigning to foo.

> My question is, what are the likely problems to expect from this when
> running in kernel-space (on x86 w/FPU)?

RARE random errors in programs with FPU usage. Since kernel doing lazy
store/restore FPU state and will just store garbage from your instruction
instead of correct data. Of course in most cases it'll not change anything
(only few flags and bottom of FPU stack should be changed and it's not very
oftent important info). Code itself should work fine :-)

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



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:12 EST