History log of /seL4-refos-master/libs/libmuslc/src/fenv/i386/fenv.s
Revision Date Author Comments
# 929729d4 09-Feb-2014 Szabolcs Nagy <nsz@port70.net>

fix fesetenv(FE_DFL_ENV) on i386

the default fenv was not set up properly, in particular the
tag word that indicates the contents of the x87 registers was
set to 0 (used) instead of 0xffff (empty)

this could cause random crashes after setting the default fenv
because it corrupted the fpu stack and then any float computation
gives NaN result breaking the program logic (usually after a
float to integer conversion).


# 7e01b8f0 28-Oct-2013 Szabolcs Nagy <nsz@port70.net>

fenv: fix i386 fesetround for sse

i386 fenv code checks __hwcap for sse support, but in fesetround the sse
code was unconditionally jumped over after the test so the sse rounding
mode was never set.


# a6b0170a 18-Aug-2013 Szabolcs Nagy <nsz@port70.net>

fix fenv exception functions to mask their argument

fesetround.c is a wrapper to do the arch independent argument
check (on archs where rounding mode is not stored in 2 bits
__fesetround still has to check its arguments)

on powerpc fe*except functions do not accept the extra invalid
flags of its fpscr register

the useless FENV_ACCESS pragma was removed from feupdateenv


# d8764bf8 18-Aug-2013 Szabolcs Nagy <nsz@port70.net>

optimize x86 feclearexcept: only use save/restore x87 fenv if needed

the x87 exception summary (ES) and stack fault (SF) flags may be
spuriously cleared by feclearexcept using the fnclex instruction,
but these flags are not observable through libc hence maintaining
their state is not critical.


# ebc10fa1 16-Aug-2013 Szabolcs Nagy <nsz@port70.net>

add sse fenv support on i386 through hwcap

the sse and x87 rounding modes should be always the same,
the visible exception flags are the bitwise or of the two
fenv states (so it's enough to query the rounding mode or
raise exceptions on one fenv)


# d6841499 16-Aug-2013 Szabolcs Nagy <nsz@port70.net>

fix i386 fesetenv: FE_DFL_ENV is (fenv_t*)-1 not 0


# 316e024f 17-Mar-2012 Rich Felker <dalias@aerifal.cx>

optimize x86 feclearexcept

if all exception flags will be cleared, we can avoid the expensive
store/reload of the environment and just use the fnclex instruction.


# d5e576c7 17-Mar-2012 Rich Felker <dalias@aerifal.cx>

minor 387 fenv optimizations


# 88cfaf8a 17-Mar-2012 nsz <nsz@port70.net>

fix i386 fegetround and make fesetround faster

Note that the new fesetround has slightly different semantics:

Storing the floating-point environment with fnstenv makes the
next fldenv (or fldcw) "non-signaling", so unmasked and pending
exceptions does not invoke the exception handler.
(These are rare since exceptions are handled immediately and by
default all exceptions are masked anyway. But if one manually
unmasks an exception in the control word then either sets the
corresponding exception flag in the status word or the execution
of an exception raising floating-point operation gets interrupted
then it may happen).
So the old implementation did not trap in some rare cases
where the new implementation traps.

However POSIX does not specify anything like the x87 exception
handling traps and the fnstenv/fldenv pair is significantly slower
than the fnstcw/fldcw pair (new code is about 5x faster here and
it's dominated by the function call overhead).


# e4118279 28-Jun-2011 Rich Felker <dalias@aerifal.cx>

use type directives for fenv asm functions


# 52cf24a0 13-Jun-2011 Rich Felker <dalias@aerifal.cx>

fix fesetround - it was writing to status word instead of control word


# b09b7890 12-Jun-2011 Rich Felker <dalias@aerifal.cx>

floating point environment, untested

at present the i386 code does not support sse floating point, which is
not part of the standard i386 abi. while it may be desirable to
support it later, doing so will reduce performance and require some
tricks to probe if sse support is present.

this first commit is i386-only, but it should be trivial to port the
asm to x86_64.