diff options
author | J.H. van de Water <houder@xs4all.nl> | 2018-08-03 01:45:12 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-08-03 09:33:49 +0200 |
commit | d79069d2ff163397ed83fd90c97ae778977274fb (patch) | |
tree | 6dca71a3fb9c48caf2818e873edf745af455da5d | |
parent | 2ec54fb1d152f7b9bed5224756e552cb7f9609c2 (diff) | |
download | cygnal-d79069d2ff163397ed83fd90c97ae778977274fb.tar.gz cygnal-d79069d2ff163397ed83fd90c97ae778977274fb.tar.bz2 cygnal-d79069d2ff163397ed83fd90c97ae778977274fb.zip |
Cygwin: fegetenv() should not disable exceptions
fnstenv MUST be followed by fldenv in fegetenv(), as the former disables all
exceptions in the x87 FPU, which is not appropriate here (fegetenv() ).
fldenv after fnstenv should reload the x87 FPU w/ the configuration that was
saved by fnstenv, i.e. a configuration that might have exceptions enabled.
Note: x86_64 uses SSE for floating-point, not the x87 FPU. However, because
feraiseexcept() attempts to provoke an exception using the x87 FPU, the bug
in fegetenv() will make this attempt futile here (x86_64).
Note: WoW uses the x87 FPU for floating-point, not SSE. Here anything that
would normally result in triggering an exception, not only feraiseexcept(),
will not be able to, as result of the bug in fegetenv().
-rw-r--r-- | winsup/cygwin/fenv.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/winsup/cygwin/fenv.cc b/winsup/cygwin/fenv.cc index bd3f90495..066704b40 100644 --- a/winsup/cygwin/fenv.cc +++ b/winsup/cygwin/fenv.cc @@ -141,7 +141,11 @@ fegetexcept (void) int fegetenv (fenv_t *envp) { - __asm__ volatile ("fnstenv %0" : "=m" (envp->_fpu) : ); + /* fnstenv disables all exceptions in the x87 FPU; as this is not what is + desired here, reload the cfg saved from the x87 FPU, back to the FPU */ + __asm__ volatile ("fnstenv %0\n\ + fldenv %0" + : "=m" (envp->_fpu) : ); if (use_sse) __asm__ volatile ("stmxcsr %0" : "=m" (envp->_sse_mxcsr) : ); return 0; |