fpe: prevent spurious floating point exceptions in WITH_LISP_FPE
feenableexcept may generate a SIGFPE signal if exception status flags are not cleared beforehand. Happens for example on powerpc platforms. Fixes #612.
This commit is contained in:
parent
7f1813cd93
commit
cdb602e40d
2 changed files with 3 additions and 4 deletions
|
|
@ -258,8 +258,7 @@ booting. This macro allows for execution of Lisp code while saving and
|
||||||
later restoring the floating point environment of surrounding C code
|
later restoring the floating point environment of surrounding C code
|
||||||
so that changes in the floating point environment don't leak outside.
|
so that changes in the floating point environment don't leak outside.
|
||||||
|
|
||||||
@coderef{ECL_WITH_LISP_FPE} can be also used before ECL has booted or
|
@coderef{ECL_WITH_LISP_FPE} can be also used before ECL has booted.
|
||||||
before an external thread has been imported.
|
|
||||||
|
|
||||||
@exindex Safely executing Lisp code with floating point exceptions in embedding program
|
@exindex Safely executing Lisp code with floating point exceptions in embedding program
|
||||||
@paragraph Example
|
@paragraph Example
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@
|
||||||
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
||||||
fenv_t __fenv; \
|
fenv_t __fenv; \
|
||||||
fegetenv(&__fenv); \
|
fegetenv(&__fenv); \
|
||||||
|
feclearexcept(FE_ALL_EXCEPT); \
|
||||||
if (ecl_get_option(ECL_OPT_BOOTED) > 0) { \
|
if (ecl_get_option(ECL_OPT_BOOTED) > 0) { \
|
||||||
int bits = ecl_process_env()->trap_fpe_bits; \
|
int bits = ecl_process_env()->trap_fpe_bits; \
|
||||||
fedisableexcept(FE_ALL_EXCEPT & ~bits); \
|
fedisableexcept(FE_ALL_EXCEPT & ~bits); \
|
||||||
feenableexcept(FE_ALL_EXCEPT & bits); \
|
feenableexcept(FE_ALL_EXCEPT & bits); \
|
||||||
} \
|
}
|
||||||
feclearexcept(FE_ALL_EXCEPT);
|
|
||||||
# else
|
# else
|
||||||
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
# define ECL_WITH_LISP_FPE_BEGIN do { \
|
||||||
fenv_t __fenv; \
|
fenv_t __fenv; \
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue