[Click] ]use of log() funtcion in click?

Michele Mordenti michele.mordenti2 at studio.unibo.it
Thu Dec 16 12:15:29 EST 2004


Alle 20:28, mercoledì 24 novembre 2004, Eddie Kohler ha scritto:
> Floating point arithmetic is *not allowed* in the kernel.
>
> The kernel does not necessarily save floating-point registers on
> entry, only integer registers.  That means that if you do
> floating-point arithmetic in the kernel, any user programs using
> floating point might go subtly wrong.  Also, the Linux kernel
> emulates a floating-point unit for machines that don't have one of
> their own; that emulation doesn't work in kernel context.  (That's
> probably not relevant for any machine you deal with.)
>
> That's why sqrt() and log() are not implemented in the kernel.
>
> Giorgio: Your workaround is unacceptable for the same reason.
>
> Now, if floating point is *absolutely required*, there is a
> workaround:
>
> http://lkml.org/lkml/2004/5/31/5
>
> Then something like Giorgio's code, or a math module, might work.


Dear all,
I'm working on the Log() function by Giorgio;
The results of the function _seem_ to be incorrect when a process in 
userspace does a lot of floating point operations.
I tried with the workaround proposed by Eddie/Linus:
[CODE]
...
#include <click/cxxprotect.h>
CLICK_CXX_PROTECT
#if __i386__
#include <asm/i387.h>
#endif
CLICK_CXX_UNPROTECT
#include <click/cxxunprotect.h>
...
kernel_fpu_begin();
 ... Log() ...
kernel_fpu_end();
...
[/CODE]

But something goes wrong, when I try to launch click:

/usr/local/lib/click.o: unresolved symbol kernel_fpu_begin
click-install: '/sbin/insmod /usr/local/lib/click.o' failed

The function is present in my /boot/System.map, so what's wrong?



More in general, I found this on the net:
Rusty Russell about the FPU from his kernel guide:
[QUOTE]
"The FPU context is not saved; even in user context the FPU state 
probably
won't correspond with the current process: you would mess with some user
process' FPU state. If you really want to do this, you would have to
explicitly save/restore the full FPU state (and avoid context 
switches)."
[/QUOTE]

I'm looking for documents or examples that can explain to me [kernel 
newbie ;-)] how to protect the fpu registers, any suggestions?

Thanks in advance,
Michele

p.s.: sorry for my incorrect english.

-- 
Michele Mordenti
http://xoomer.virgilio.it/michele.mordenti



More information about the click mailing list