From: Wolfgang Bangerth Date: Wed, 15 Mar 2006 20:41:24 +0000 (+0000) Subject: Detect whether std::isfinite is available. X-Git-Tag: v8.0.0~12096 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12dcfee4b403a232c33b8ee35adf581d75d1e3c3;p=dealii.git Detect whether std::isfinite is available. git-svn-id: https://svn.dealii.org/trunk@12599 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 34360303aa..9349cdda25 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -2174,6 +2174,41 @@ AC_DEFUN(DEAL_II_CHECK_ISNAN_FLAG, dnl +dnl ------------------------------------------------------------- +dnl See if the isfinite function is available in namespace std +dnl (this function is C99 and therefore not part of C++98, but +dnl some implementations provide it nevertheless). +dnl +dnl Usage: DEAL_II_CHECK_ISFINITE +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_ISFINITE, dnl +[ + AC_MSG_CHECKING(for std::isfinite) + AC_LANG(C++) + CXXFLAGS=$CXXFLAGSG + AC_TRY_COMPILE( + [ +#include + ], + [ + double d=0; + std::isfinite (d); + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(DEAL_II_HAVE_ISFINITE, 1, + [Defined if std::isfinite is available]) + ], + [ + AC_MSG_RESULT(no) + ]) +]) + + + + + dnl ------------------------------------------------------------- dnl rand_r is defined for some compiler flag combinations, but not for dnl others. check that. note that since these are C++ flags, we can't diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index edb929fef6..485ac968ab 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -74,6 +74,9 @@ aclocal.m4 in the top-level directory. */ #undef DEAL_II_FUNPTR_TEMPLATE_TEMPLATE_BUG +/* Defined if std::isfinite is available */ +#undef DEAL_II_HAVE_ISFINITE + /* Flag indicating whether the library shall be compiled to use the NetCDF interface */ #undef DEAL_II_HAVE_NETCDF @@ -400,6 +403,14 @@ namespace deal_II_numbers { * 1/sqrt(2) */ static const double SQRT1_2 = 0.70710678118654752440; + + /** + * Return @p true if the given + * value is a finite floating point + * number, i.e. is neither plus or + * minus infinity nor NaN (not a + * number). + */ + bool is_finite (const double x); } -#endif diff --git a/deal.II/configure b/deal.II/configure index c470db4595..1755bb1c45 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.219 . +# From configure.in Revision: 1.220 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for deal.II 5.3.pre. # @@ -8401,6 +8401,78 @@ echo "${ECHO_T}using $testflag" >&6 + echo "$as_me:$LINENO: checking for std::isfinite" >&5 +echo $ECHO_N "checking for std::isfinite... $ECHO_C" >&6 + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS=$CXXFLAGSG + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include + +int +main () +{ + + double d=0; + std::isfinite (d); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define DEAL_II_HAVE_ISFINITE 1 +_ACEOF + + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + echo "$as_me:$LINENO: checking for rand_r" >&5 echo $ECHO_N "checking for rand_r... $ECHO_C" >&6 ac_ext=cc diff --git a/deal.II/configure.in b/deal.II/configure.in index e7d96cd283..5e46b3a5e1 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -204,6 +204,7 @@ DEAL_II_CHECK_MIN_VECTOR_CAPACITY DEAL_II_CHECK_ABORT DEAL_II_CHECK_GETRUSAGE DEAL_II_CHECK_ISNAN +DEAL_II_CHECK_ISFINITE DEAL_II_CHECK_RAND_R DEAL_II_CHECK_QUAD_DEFINE DEAL_II_CHECK_ERROR_CODES_DEFINITION @@ -689,8 +690,16 @@ namespace deal_II_numbers { * 1/sqrt(2) */ static const double SQRT1_2 = 0.70710678118654752440; + + /** + * Return @p true if the given + * value is a finite floating point + * number, i.e. is neither plus or + * minus infinity nor NaN (not a + * number). + */ + bool is_finite (const double x); } -#endif ]) diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 8eb0ad7a3f..5d6ed58050 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -259,6 +259,14 @@ inconvenience this causes.
    +
  1. New: The new deal_II_numbers::is_finite function can + be used to check whether a floating point number is finite, + i.e. neither plus or minus infinite nor NaN (not a number). +
    + (WB 2006/03/15) +

    +
  2. Improved: If the C++ runtime environment allows it, we now demangle stacktraces generated whenever an exception is thrown.