Re: Why all glibc2 programs are FPU programs

Adam J. Richter (adam@yggdrasil.com)
Wed, 27 May 1998 12:44:30 -0700


>> So, can we settle on this solution? To implement this change, no
>> work is necessary beyond deleteing that line that line in
>> glibc/sysdeps/unix/sysv/linux/init-first.c that says
>> "setfpucw(__fpu_control);". Okay?

>No, you miss the point. There are cases when the initialization is
>necessary (try running the SPECS suite with the default setup).

Under Linux, the default personality is the personality initialized
by glibc, so how can any program possibly produce different output?

>Even
>when using the personality is used this would require the if and
>*hardcoding* the default value for each architecture and each kernel
>version (i.e., when the kernel changed this).

>The code must look in general like this:

> kvalue = <somehow get the default value the kernel uses>;

> lvalue = <the value libc would use to initialize>;

> if (kvalue != lvalue)
> setfpucw (lvalue);

No. The glibc code would look like this:

personality(<current_libc6_personality_including_mask>);

This is already present in init-first.c. The kernel would do
the rest. Inside the kernel, if it were ever desired to support
a different initial fpu control word, the code would look like
this:

sys_personality(per) {
unsigned long fpucw = _DEFAULT_FPU_CONTROL;
...
if (per & PER_TWIDDLE_DEFAULT_FPU_FOO_BIT)
fpucw |= FPU_FOO_BIT;
if (per & PER_TWIDDLE_DEFAULT_FPU_BAR_BIT)
fpucw |= FPU_BAR_BIT;
...
current->default_fpucw = fpucw;
...
}

Advantanges of my personality() approach over your initial
elf data approach:

1. Under your approach, there is only one default FPU control
word for all ELF executables. If the value of that
ever changes, all of the old programs become floating
point programs.

2. Your approach only works for ELF format executables.

3. Your approach adds code, mine deletes code, albiet in
tiny amounts in each direction. Admittedly, my
approach adds a tiny amount of code to the kernel
if a future personality with a different default FPU
control word is created, but this this buys you
the ability to continue to run the old non-floating-point
programs without an FPU (i.e., item 1).

You could get advtanges 1 and 2 if you had a setdefaultfpucw
system call. The downardly compatibile initialization code in glibc
could look like this:

if (setdefaultpfpucw(__fpu_control) == -1 && errno == ENOSYS)
setfpucw(__fpu_control);

What do you think of this additional alternative?

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."

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