]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Detect whether we can use floating point exceptions.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 28 Jul 2015 21:32:20 +0000 (16:32 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 29 Jul 2015 21:46:16 +0000 (16:46 -0500)
cmake/checks/check_02_system_features.cmake
include/deal.II/base/config.h.in

index cd58f4141609ebeccfbfc73c611008b3d5832208..33aaccc9f026c8dc7fbced3a3a8a4d2dea793827 100644 (file)
@@ -19,6 +19,7 @@
 #   DEAL_II_HAVE_GETHOSTNAME
 #   DEAL_II_HAVE_GETPID
 #   DEAL_II_HAVE_JN
+#   DEAL_II_HAVE_FP_EXCEPTIONS
 #   DEAL_II_HAVE_SYS_RESOURCE_H
 #   DEAL_II_HAVE_SYS_TIME_H
 #   DEAL_II_HAVE_SYS_TIMES_H
@@ -67,6 +68,41 @@ IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
 ENDIF()
 
 
+#
+# Check that we can use feenableexcept. Sets DEAL_II_HAVE_FP_EXCEPTIONS
+#
+# The test is a bit more complicated because we also check that no garbage
+# exception is thrown if we convert -std::numeric_limits<double>::max to a
+# string. This sadly happens with some compiler support libraries :-(
+
+INCLUDE (CheckCXXSourceRuns)
+
+CHECK_CXX_SOURCE_RUNS("
+  #include <fenv.h>
+  #include <limits>
+  #include <sstream>
+
+  int main()
+  {
+    feenableexcept(FE_DIVBYZERO|FE_INVALID);
+    std::ostringstream description;
+    const double lower_bound = -std::numeric_limits<double>::max();  
+
+    description << lower_bound;
+
+    return 0;
+  }
+  " 
+  _HAVE_FP_EXCEPTIONS)
+
+IF(_HAVE_FP_EXCEPTIONS)
+  MESSAGE(STATUS "Checking for Floating Point Exception macros -- Success")
+  SET(DEAL_II_HAVE_FP_EXCEPTIONS 1)
+ELSE()
+  MESSAGE(STATUS "Checking for Floating Point Exception macros -- Failed")
+ENDIF()
+
+
 ########################################################################
 #                                                                      #
 #                        Mac OSX specific setup:                       #
index 09fbfb319ceb746d7e006ebf116f3441a12f6cf3..05a6ae90cdbf2d6942a4bec4c30226397ae00939 100644 (file)
 #cmakedefine DEAL_II_HAVE_GETPID
 #cmakedefine DEAL_II_HAVE_TIMES
 #cmakedefine DEAL_II_HAVE_JN
+#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
 
 #cmakedefine DEAL_II_MSVC
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.