fpe: fix ECL_WITH_LISP_FPE macro after changes to floating point exception handling
Make sure that apart from turning on/off signaling for exceptions, we also clear all exception bits. After the recent changes to how ECL handles floating point exceptions, not doing that could lead to spurious exceptions being signaled even when using the ECL_WITH_LISP_FPE macro because an earlier calculation yielded infinity/NaN.
This commit is contained in:
parent
9cf6e774a4
commit
865b9e7636
1 changed files with 17 additions and 9 deletions
|
|
@ -70,16 +70,24 @@
|
|||
# define FE_ALL_EXCEPT FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FENV_H) && !defined(ECL_AVOID_FPE_H) && defined(HAVE_FEENABLEEXCEPT)
|
||||
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
||||
fenv_t __fenv; \
|
||||
fegetenv(&__fenv); \
|
||||
#if defined(HAVE_FENV_H) && !defined(ECL_AVOID_FPE_H)
|
||||
# if defined(HAVE_FEENABLEEXCEPT)
|
||||
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
||||
fenv_t __fenv; \
|
||||
fegetenv(&__fenv); \
|
||||
cl_env_ptr __the_env = ecl_process_env_unsafe(); \
|
||||
if (__the_env) { \
|
||||
int bits = __the_env->trap_fpe_bits; \
|
||||
fedisableexcept(FE_ALL_EXCEPT & ~bits); \
|
||||
feenableexcept(FE_ALL_EXCEPT & bits); \
|
||||
}
|
||||
if (__the_env) { \
|
||||
int bits = __the_env->trap_fpe_bits; \
|
||||
fedisableexcept(FE_ALL_EXCEPT & ~bits); \
|
||||
feenableexcept(FE_ALL_EXCEPT & bits); \
|
||||
} \
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
# else
|
||||
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
||||
fenv_t __fenv; \
|
||||
fegetenv(&__fenv); \
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
# endif
|
||||
# define ECL_WITH_LISP_FPE_END \
|
||||
fesetenv(&__fenv); } while (0)
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue