VTK
vtkMathConfigure.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /*=========================================================================
3 
4  Program: Visualization Toolkit
5  Module: vtkMathConfigure.h.in
6 
7  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
16 /*----------------------------------------------------------------------------
17  Copyright (c) Sandia Corporation
18  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
19 ----------------------------------------------------------------------------*/
20 
21 #ifndef vtkMathConfigure_h
22 #define vtkMathConfigure_h
23 
24 #include <cmath>
25 #include <float.h> // for _isnan, _finite on Win32
26 
27 #define VTK_HAS_ISNAN
28 #define VTK_HAS_STD_ISNAN
29 /* #undef VTK_HAS__ISNAN */
30 #define VTK_HAS_ISINF
31 #define VTK_HAS_STD_ISINF
32 #define VTK_HAS_ISFINITE
33 #define VTK_HAS_STD_ISFINITE
34 #define VTK_HAS_FINITE
35 /* #undef VTK_HAS__FINITE */
36 
37 // Check for undetected macro versions of isnan(), isinf(), isfinite()
38 #if !defined(VTK_HAS_ISNAN) && defined(isnan)
39 # define VTK_HAS_ISNAN 1
40 #endif
41 #if !defined(VTK_HAS_ISINF) && defined(isinf)
42 # define VTK_HAS_ISINF 1
43 #endif
44 #if !defined(VTK_HAS_ISFINITE) && defined(isfinite)
45 # define VTK_HAS_ISFINITE 1
46 #endif
47 #if !defined(VTK_HAS_FINITE) && defined(finite)
48 # define VTK_HAS_FINITE 1
49 #endif
50 
51 // Make macros from _isnan(), _finite() if they exist (there is no _isinf)
52 #if !defined(VTK_HAS_ISNAN) && (defined(VTK_HAS__ISNAN) || defined(_isnan))
53 # define isnan(x) _isnan(x)
54 # define VTK_HAS_ISNAN 1
55 #endif
56 #if !defined(VTK_HAS_FINITE) && (defined(VTK_HAS__FINITE) || defined(_finite))
57 # define finite(x) _finite(x)
58 # define VTK_HAS_FINITE 1
59 #endif
60 
61 // The CUDA compiler(nvcc) is a secondary compiler that is used beside
62 // your host compiler. While your host compiler can support std::isnan and
63 // other functions, the CUDA compiler doesn't. Because the CUDA compiler is
64 // given both host and device code to parse it will then fail when it sees
65 // std::isnan because it is in the vtkMath header and not the
66 // implementation file. To get around this issue we check __CUDACC__ which
67 // is only set when we are compiling with the CUDA compiler
68 #ifdef __CUDACC__
69 
70 #if defined(VTK_HAS_STD_ISINF)
71 #undef VTK_HAS_STD_ISINF
72 #endif
73 
74 #if defined(VTK_HAS_STD_ISNAN)
75 #undef VTK_HAS_STD_ISNAN
76 #endif
77 
78 #if defined(VTK_HAS_STD_ISFINITE)
79 #undef VTK_HAS_STD_ISFINITE
80 #endif
81 
82 #endif
83 
84 // We pretty much assume that all compilers are going to provide
85 // std::numeric_limits methods in the limits header. On of the Borland
86 // dashboard compilers failed to link in the methods, so we have a special
87 // case here. If we find more platforms that do not support it correctly,
88 // then we should probably implement a TRY_COMPILE in the CMakeLists.txt.
89 #ifndef __BORLANDC__
90 # define VTK_HAS_STD_NUMERIC_LIMITS
91 #endif
92 
93 // If the isnan or isinf function does not exist, then our next attempt is to
94 // use comparisons to determine if the number is not finite. Although these
95 // comparisons should be valid, some systems raise execeptions anyway (possibly
96 // because exceptions for really bad operations like division by 0 are on).
97 // This flag will instruct vtkMath not to make these comparisons. (The next
98 // fallback is to do IEEE-754 bit comparisons.)
99 #ifdef __BORLANDC__
100 # define VTK_NON_FINITE_CAUSES_EXCEPTIONS
101 #endif
102 
103 #endif //vtkMathConfigure_h