mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-16 22:32:05 -08:00
Fix detection of NaN/inf for platforms without fenv.h
This commit is contained in:
parent
f042896b53
commit
a995a89c1d
2 changed files with 8 additions and 19 deletions
|
|
@ -37,19 +37,10 @@
|
|||
* X, where the status of the FPE control word is changed by
|
||||
* printf. We have two alternatives.
|
||||
*/
|
||||
# ifdef HAVE_FENV_H
|
||||
# define DO_DETECT_FPE(f) do { \
|
||||
unlikely_if (isnan(f)) ecl_deliver_fpe(FE_INVALID); \
|
||||
unlikely_if (!isfinite(f)) ecl_deliver_fpe(FE_OVERFLOW); \
|
||||
# define DO_DETECT_FPE(f) do { \
|
||||
unlikely_if (isnan(f)) ecl_deliver_fpe(FE_INVALID); \
|
||||
unlikely_if (!isfinite(f)) ecl_deliver_fpe(FE_OVERFLOW); \
|
||||
} while (0)
|
||||
# else
|
||||
# define DO_DETECT_FPE(f) do { \
|
||||
if (isnan(f)) { \
|
||||
cl_error(1, @'floating-point-invalid-operation'); \
|
||||
} else if (!isfinite(f)) { \
|
||||
cl_error(1, @'division-by-zero'); \
|
||||
} } while (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
cl_fixnum
|
||||
|
|
@ -451,12 +442,12 @@ ecl_make_ratio(cl_object num, cl_object den)
|
|||
return(r);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FENV_H
|
||||
void
|
||||
ecl_deliver_fpe(int status)
|
||||
{
|
||||
cl_env_ptr env = ecl_process_env();
|
||||
int bits = status & env->trap_fpe_bits;
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
if (bits) {
|
||||
cl_object condition;
|
||||
if (bits & FE_DIVBYZERO)
|
||||
|
|
@ -471,12 +462,9 @@ ecl_deliver_fpe(int status)
|
|||
condition = @'floating-point-inexact';
|
||||
else
|
||||
condition = @'arithmetic-error';
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
cl_error(1, condition);
|
||||
}
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
}
|
||||
#endif
|
||||
|
||||
cl_object
|
||||
ecl_make_singlefloat(float f)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
See file '../../Copyright' for full details.
|
||||
*/
|
||||
|
||||
#if !defined(ECL_MATH_FENV_H) && defined(HAVE_FENV_H)
|
||||
#ifndef ECL_MATH_FENV_H
|
||||
#define ECL_MATH_FENV_H
|
||||
|
||||
/*
|
||||
|
|
@ -61,6 +61,7 @@
|
|||
# define FE_UNDERFLOW 0
|
||||
# define ECL_WITHOUT_FPE_BEGIN
|
||||
# define ECL_WITHOUT_FPE_END
|
||||
# define feclearexcept(x)
|
||||
#endif /* !HAVE_FENV_H */
|
||||
|
||||
#if defined(HAVE_FENV_H) && !defined(HAVE_FEENABLEEXCEPT) && !defined(ECL_AVOID_FPE_H)
|
||||
|
|
@ -104,6 +105,6 @@ static inline int myfetestexcept(cl_fixnum flags)
|
|||
}
|
||||
#endif /* __APPLE__ && __amd64__ */
|
||||
|
||||
void ecl_deliver_fpe(int flags);
|
||||
extern void ecl_deliver_fpe(int flags);
|
||||
|
||||
#endif /* !ECL_MATH_FENV_H && HAVE_FENV_H */
|
||||
#endif /* !ECL_MATH_FENV_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue