OpenVDB: Platform.h Source File

OpenVDB 3.2.0

Platform.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2016 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
32
33 #ifndef OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
34 #define OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
35
36 #include "PlatformConfig.h"
37
38 #define PRAGMA(x) _Pragma(#x)
39
43 #ifdef OPENVDB_DEPRECATED
44 #undef OPENVDB_DEPRECATED
45 #endif
46 #ifdef _MSC_VER
47 #define OPENVDB_DEPRECATED __declspec(deprecated)
48 #else
49 #define OPENVDB_DEPRECATED __attribute__ ((deprecated))
50 #endif
51
53 #if defined(__GNUC__)
54 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) \
55 (__GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR))
56 #else
57 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) 0
58 #endif
59
61 #ifdef __INTEL_COMPILER
62 #ifdef __INTEL_CXX11_MODE__
63 #define OPENVDB_HAS_CXX11 1
64 #endif
65 #elif defined(__clang__)
66 #ifndef _LIBCPP_VERSION
67 #include <ciso646>
68 #endif
69 #ifdef _LIBCPP_VERSION
70 #define OPENVDB_HAS_CXX11 1
71 #endif
72 #elif defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus > 199711L)
73 #define OPENVDB_HAS_CXX11 1
74 #elif defined(_MSC_VER)
75 #if (_MSC_VER >= 1700)
76 #define OPENVDB_HAS_CXX11 1
77 #endif
78 #endif
79 #if defined(__GNUC__) && !OPENVDB_CHECK_GCC(4, 4)
80 // ICC uses GCC's standard library headers, so even if the ICC version
81 // is recent enough for C++11, the GCC version might not be.
82 #undef OPENVDB_HAS_CXX11
83 #endif
84
88 #if defined(__GNUC__) && OPENVDB_CHECK_GCC(4, 4)
89 #define OPENVDB_STATIC_SPECIALIZATION
90 #else
91 #define OPENVDB_STATIC_SPECIALIZATION static
92 #endif
93
94
110 #if defined(__INTEL_COMPILER)
111 // Disable ICC remarks 111 ("statement is unreachable"), 128 ("loop is not reachable"),
112 // 185 ("dynamic initialization in unreachable code"), and 280 ("selector expression
113 // is constant").
114 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
115 _Pragma("warning (push)") \
116 _Pragma("warning (disable:111)") \
117 _Pragma("warning (disable:128)") \
118 _Pragma("warning (disable:185)") \
119 _Pragma("warning (disable:280)")
120 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
121 _Pragma("warning (pop)")
122 #elif defined(__clang__)
123 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
124 PRAGMA(clang diagnostic push) \
125 PRAGMA(clang diagnostic ignored "-Wunreachable-code")
126 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
127 PRAGMA(clang diagnostic pop)
128 #else
129 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
130 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
131 #endif
132
133
137 #ifndef _USE_MATH_DEFINES
138 #define _USE_MATH_DEFINES
139 #endif
140
142 #ifdef _MSC_VER
143 #include <boost/math/special_functions/round.hpp>
144 using boost::math::round;
145 #endif
146
148 #ifdef _MSC_VER
149 #include <float.h>
150 static inline double copysign(double x, double y) { return _copysign(x, y); }
151 #endif
152
155 #include <boost/cstdint.hpp>
156 using boost::int8_t;
157 using boost::int16_t;
158 using boost::int32_t;
159 using boost::int64_t;
160 using boost::uint8_t;
161 using boost::uint16_t;
162 using boost::uint32_t;
163 using boost::uint64_t;
164
166 #ifdef OPENVDB_EXPORT
167 #undef OPENVDB_EXPORT
168 #endif
169 #ifdef OPENVDB_IMPORT
170 #undef OPENVDB_IMPORT
171 #endif
172 #ifdef __GNUC__
173 #define OPENVDB_EXPORT __attribute__((visibility("default")))
174 #define OPENVDB_IMPORT __attribute__((visibility("default")))
175 #endif
176 #ifdef _WIN32
177 #ifdef OPENVDB_DLL
178 #define OPENVDB_EXPORT __declspec(dllexport)
179 #define OPENVDB_IMPORT __declspec(dllimport)
180 #else
181 #define OPENVDB_EXPORT
182 #define OPENVDB_IMPORT
183 #endif
184 #endif
185
189 #ifdef OPENVDB_API
190 #undef OPENVDB_API
191 #endif
192 #ifdef OPENVDB_PRIVATE
193 #define OPENVDB_API OPENVDB_EXPORT
194 #else
195 #define OPENVDB_API OPENVDB_IMPORT
196 #endif
197 #ifdef OPENVDB_HOUDINI_API
198 #undef OPENVDB_HOUDINI_API
199 #endif
200 #ifdef OPENVDB_HOUDINI_PRIVATE
201 #define OPENVDB_HOUDINI_API OPENVDB_EXPORT
202 #else
203 #define OPENVDB_HOUDINI_API OPENVDB_IMPORT
204 #endif
205
206 #endif // OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
207
208 // Copyright (c) 2012-2016 DreamWorks Animation LLC
209 // All rights reserved. This software is distributed under the
210 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
PlatformConfig.h