Why all glibc2 programs are FPU programs

Adam J. Richter (adam@yggdrasil.com)
Tue, 26 May 1998 00:32:05 -0700


I am cc'ing this to linux-kernel because I would like
some input on the Linux FPU compatability question below.

At the end of this email, I have attached a patch to
glibc-2.0.6 that eliminates an initial floating point instruction
that all glibc2 and Linux libc5 programs heretofore executed at
initialization. This turned every glibc2 or libc5 program into
an FPU program, slighly undermining Linux's lazy FPU context
scheduling optimizations and preventing math emulation from working
as a loadable module, because the modprobe program that was used
to load the module would itself try to execute a floating point
instruction.

In Linux, this FPU initialization can be skipped because
the kernel will initialize the FPU to a known state when and if
the program executes its first floating point instruction.

The only compatability issue is that the inital state
the Linux loads, which is also the default hardware state,
apparently differs from the state that the C library loads when
run with on 80287 floating point processor, that in "infinite
control" is deactivated by default on a 287, but set by the
Linux C library. For 387 and above FPU hardware, there should
be no problem. So, my question for linux-kernel is this:

Does anybody know if Linux even uses the 80287 coprocessor
on systems with an 80386 CPU + 80287 FPU? If so, should I change
the kernel to initialize the FPU control word to 0137f instead
of 0x37f upon first use of the FPU, or I am within all applicable
standards and specifications to leave it deactivated?

Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 205
adam@yggdrasil.com \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."

--- glibc/sysdeps/unix/sysv/linux/init-first.c.orig Tue May 26 00:16:25 1998
+++ glibc/sysdeps/unix/sysv/linux/init-first.c Tue May 26 00:17:53 1998
@@ -62,8 +62,13 @@
the executable format. */
__personality (PER_LINUX);

+#ifndef linux
/* Set the FPU control word to the proper default value. */
__setfpucw (__fpu_control);
+ /* The Linux kernel sets the default FPU control word when
+ the first FPU instruction is executed, so there is no need
+ for us to explicitly do this. */
+#endif
}

/* Save the command-line arguments. */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu