Commit e66e05e2 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

configure: check function feenableexcept

parent 8c30053b
......@@ -17560,6 +17560,17 @@ _ACEOF
fi
done
 
for ac_func in feenableexcept
do :
ac_fn_c_check_func "$LINENO" "feenableexcept" "ac_cv_func_feenableexcept"
if test "x$ac_cv_func_feenableexcept" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_FEENABLEEXCEPT 1
_ACEOF
fi
done
# ----------------------------------------------------------------------
# Checks for the availability of ANSI-C99 functions
for ac_func in getrlimit
......
......@@ -72,6 +72,7 @@ AC_CHECK_HEADERS(execinfo.h)
# Checks for the availability of functions
AC_CHECK_FUNCS(mallinfo)
AC_CHECK_FUNCS(backtrace)
AC_CHECK_FUNCS(feenableexcept)
# ----------------------------------------------------------------------
# Checks for the availability of ANSI-C99 functions
AC_CHECK_FUNCS(getrlimit)
......
......@@ -123,22 +123,30 @@ void cdo_stackframe(void)
}
static
int cdo_feenableexcept(unsigned excepts)
int cdo_feenableexcept(int excepts)
{
#if defined HAVE_FEENABLEEXCEPT
int old_excepts = feenableexcept(int);
return old_excepts;
#else
static fenv_t fenv;
unsigned new_excepts = excepts & FE_ALL_EXCEPT,
old_excepts = 0; // previous masks
unsigned new_excepts = ((unsigned)excepts) & FE_ALL_EXCEPT;
int old_excepts = -1; // previous masks
if ( fegetenv(&fenv) ) return -1;
#if defined(__i386__) || defined(__x86_64__)
old_excepts = fenv.__control & FE_ALL_EXCEPT;
if ( ISME )
{
old_excepts = (int) (fenv.__control & FE_ALL_EXCEPT);
// unmask
fenv.__control &= ~new_excepts;
fenv.__mxcsr &= ~(new_excepts << 7);
// unmask
fenv.__control &= ~new_excepts;
fenv.__mxcsr &= ~(new_excepts << 7);
}
#endif
return ( fesetenv(&fenv) ? -1 : (int)old_excepts );
#endif
}
static
......
......@@ -31,6 +31,9 @@
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `feenableexcept' function. */
#undef HAVE_FEENABLEEXCEPT
/* Define to 1 if you have the <fftw3.h> header file. */
#undef HAVE_FFTW3_H
......
Supports Markdown
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