Re: Why all glibc2 programs are FPU programs

Ulrich Drepper (drepper@cygnus.com)
27 May 1998 13:06:01 -0700


"Adam J. Richter" <adam@yggdrasil.com> writes:

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

By overwriting the variable value, normally done by using that the
variable is weak. See the -lieee "library".

> No. The glibc code would look like this:
>
> personality(<current_libc6_personality_including_mask>);

See above why this isn't possible. It must be possible for the user
to decide about the mode. It must not be manifested in the libc.
There are lots of programs which require, e.g., 53bit mantissa on
Intel. Without selecting the correct mode you'll end up with lots of
wrong results (see SPECS). As I wrote in the other mail, the value
used in the setfpucw() call by the libc is a variable, no constant.

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

Yes, but that shouldn't be that much of a problem since in these
situations it can be expected for those who want to benefit from the
last improvements to update their systems.

> 2. Your approach only works for ELF format executables.

Yes, and? You don't have a.out binaries on your root disk. And you
cannot change the startup code for existing a.out binaries anyway.
Plus: if you really care you can modify the a.out environment to do
something equivalent. Using the auxiliary vector is only comfortable,
not the only possibility.

> 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);

This was my initial proposal. Get a way to signal the kernel which
value to use. This specific situation can be made a bit easier.
Simply let the new sys_setfpucw() syscall do the job of the if:

int
sys_setfpucw (int value)
{
if (value == WHAT_I_WOULD_USE_ANYWAY)
/* Nothing. */ ;
else
STORE_IN_TASK_STRUCT (value);

return 0;
}

Then the code which creates the FPU data structures once the first FPU
instruction is used will use instead of the default value always the
value from the task struct to initialize the FPU CW.

This approach only has the advantage that it is usable from a.out as
well. But it adds more code, it requires more system calls (= is
slower) than the use of the auxiliary vector.

-- Uli
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------

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