64-bit math in the kernel

Albert Cahalan (albert@ccs.neu.edu)
Thu, 14 Nov 1996 19:27:10 -0500 (EST)

What is the best way to divide a __u64 by a __u32 in the kernel?
The result will fit in a __u32.

It seems gcc requires libgcc to do that, but libgcc is not available.
Right now the code casts to a double, but it is not good to use the
FPU in the kernel. I do have a disgusting hack that does the job in
4 divisions and 3 multiplications (hmmm, is div() available?), but
the hack takes almost 4 times as long on a Pentium.

Just how bad are FPU operations in the kernel? I seem to remember
that the FPU memcpy patch had to take special precautions to avoid
corrupting data.