Commit de0c04f9 by Uros Bizjak Committed by Uros Bizjak

re PR fortran/88678 (Many gfortran.dg/ieee/ieee_X.f90 test cases fail starting with r267465)

	PR fortran/88678
	* config/fpu-glibc.h (set_fpu_trap_exceptions): Clear stalled
	exception flags before changing trap mode.  Optimize to call
	feenableexcept and fedisableexcept only once.

From-SVN: r268392
parent 83a67c0c
2019-01-30 Uroš Bizjak <ubizjak@gmail.com>
PR fortran/88678
* config/fpu-glibc.h (set_fpu_trap_exceptions): Clear stalled
exception flags before changing trap mode. Optimize to call
feenableexcept and fedisableexcept only once.
2019-01-28 Sebastian Huber <sebastian.huber@embedded-brains.de> 2019-01-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
* io/async.c (init_adv_cond): Use __GTHREAD_COND_INIT_FUNCTION(). * io/async.c (init_adv_cond): Use __GTHREAD_COND_INIT_FUNCTION().
......
...@@ -39,48 +39,56 @@ _Static_assert (sizeof(fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE, ...@@ -39,48 +39,56 @@ _Static_assert (sizeof(fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
void set_fpu_trap_exceptions (int trap, int notrap) void set_fpu_trap_exceptions (int trap, int notrap)
{ {
int mode_set = 0, mode_clr = 0;
#ifdef FE_INVALID #ifdef FE_INVALID
if (trap & GFC_FPE_INVALID) if (trap & GFC_FPE_INVALID)
feenableexcept (FE_INVALID); mode_set |= FE_INVALID;
if (notrap & GFC_FPE_INVALID) if (notrap & GFC_FPE_INVALID)
fedisableexcept (FE_INVALID); mode_clr |= FE_INVALID;
#endif #endif
/* Some glibc targets (like alpha) have FE_DENORMAL, but not many. */ /* Some glibc targets (like alpha) have FE_DENORMAL, but not many. */
#ifdef FE_DENORMAL #ifdef FE_DENORMAL
if (trap & GFC_FPE_DENORMAL) if (trap & GFC_FPE_DENORMAL)
feenableexcept (FE_DENORMAL); mode_set |= FE_DENORMAL;
if (notrap & GFC_FPE_DENORMAL) if (notrap & GFC_FPE_DENORMAL)
fedisableexcept (FE_DENORMAL); mode_clr |= FE_DENORMAL;
#endif #endif
#ifdef FE_DIVBYZERO #ifdef FE_DIVBYZERO
if (trap & GFC_FPE_ZERO) if (trap & GFC_FPE_ZERO)
feenableexcept (FE_DIVBYZERO); mode_set |= FE_DIVBYZERO;
if (notrap & GFC_FPE_ZERO) if (notrap & GFC_FPE_ZERO)
fedisableexcept (FE_DIVBYZERO); mode_clr |= FE_DIVBYZERO;
#endif #endif
#ifdef FE_OVERFLOW #ifdef FE_OVERFLOW
if (trap & GFC_FPE_OVERFLOW) if (trap & GFC_FPE_OVERFLOW)
feenableexcept (FE_OVERFLOW); mode_set |= FE_OVERFLOW;
if (notrap & GFC_FPE_OVERFLOW) if (notrap & GFC_FPE_OVERFLOW)
fedisableexcept (FE_OVERFLOW); mode_clr |= FE_OVERFLOW;
#endif #endif
#ifdef FE_UNDERFLOW #ifdef FE_UNDERFLOW
if (trap & GFC_FPE_UNDERFLOW) if (trap & GFC_FPE_UNDERFLOW)
feenableexcept (FE_UNDERFLOW); mode_set |= FE_UNDERFLOW;
if (notrap & GFC_FPE_UNDERFLOW) if (notrap & GFC_FPE_UNDERFLOW)
fedisableexcept (FE_UNDERFLOW); mode_clr |= FE_UNDERFLOW;
#endif #endif
#ifdef FE_INEXACT #ifdef FE_INEXACT
if (trap & GFC_FPE_INEXACT) if (trap & GFC_FPE_INEXACT)
feenableexcept (FE_INEXACT); mode_set |= FE_INEXACT;
if (notrap & GFC_FPE_INEXACT) if (notrap & GFC_FPE_INEXACT)
fedisableexcept (FE_INEXACT); mode_clr |= FE_INEXACT;
#endif #endif
/* Clear stalled exception flags. */
feclearexcept (FE_ALL_EXCEPT);
feenableexcept (mode_set);
fedisableexcept (mode_clr);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment