OpenVDB: Platform.h Source File

OpenVDB 6.1.0

Platform.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2019 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 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
44 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
49
51 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
52 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
57
59
63 #ifdef OPENVDB_DEPRECATED
64 #undef OPENVDB_DEPRECATED
65 #endif
66 #ifdef _MSC_VER
67 #define OPENVDB_DEPRECATED __declspec(deprecated)
68 #else
69 #define OPENVDB_DEPRECATED __attribute__ ((deprecated))
70 #endif
71
73 #if defined(__GNUC__)
74 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) \
75 (__GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR))
76 #else
77 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) 0
78 #endif
79
81 #ifdef __INTEL_COMPILER
82 #ifdef __INTEL_CXX11_MODE__
83 #define OPENVDB_HAS_CXX11 1
84 #endif
85 #elif defined(__clang__)
86 #ifndef _LIBCPP_VERSION
87 #include <ciso646>
88 #endif
89 #ifdef _LIBCPP_VERSION
90 #define OPENVDB_HAS_CXX11 1
91 #endif
92 #elif defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus > 199711L)
93 #define OPENVDB_HAS_CXX11 1
94 #elif defined(_MSC_VER)
95 #if (_MSC_VER >= 1700)
96 #define OPENVDB_HAS_CXX11 1
97 #endif
98 #endif
99 #if defined(__GNUC__) && !OPENVDB_CHECK_GCC(4, 4)
100 // ICC uses GCC's standard library headers, so even if the ICC version
101 // is recent enough for C++11, the GCC version might not be.
102 #undef OPENVDB_HAS_CXX11
103 #endif
104
108 #if defined(__GNUC__) && OPENVDB_CHECK_GCC(4, 4)
109 #define OPENVDB_STATIC_SPECIALIZATION
110 #else
111 #define OPENVDB_STATIC_SPECIALIZATION static
112 #endif
113
114
130 #if defined(__INTEL_COMPILER)
131 // Disable ICC remarks 111 ("statement is unreachable"), 128 ("loop is not reachable"),
132 // 185 ("dynamic initialization in unreachable code"), and 280 ("selector expression
133 // is constant").
134 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
135 _Pragma("warning (push)") \
136 _Pragma("warning (disable:111)") \
137 _Pragma("warning (disable:128)") \
138 _Pragma("warning (disable:185)") \
139 _Pragma("warning (disable:280)")
140 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
141 _Pragma("warning (pop)")
142 #elif defined(__clang__)
143 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
144 PRAGMA(clang diagnostic push) \
145 PRAGMA(clang diagnostic ignored "-Wunreachable-code")
146 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
147 PRAGMA(clang diagnostic pop)
148 #else
149 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
150 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
151 #endif
152
153
167 #if defined __INTEL_COMPILER
168 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
169 _Pragma("warning (push)") \
170 _Pragma("warning (disable:1478)") \
171 PRAGMA(message("NOTE: ignoring deprecation warning at " __FILE__ \
172 ":" OPENVDB_PREPROC_STRINGIFY(__LINE__)))
173 #define OPENVDB_NO_DEPRECATION_WARNING_END \
174 _Pragma("warning (pop)")
175 #elif defined __clang__
176 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
177 _Pragma("clang diagnostic push") \
178 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
179 // note: no #pragma message, since Clang treats them as warnings
180 #define OPENVDB_NO_DEPRECATION_WARNING_END \
181 _Pragma("clang diagnostic pop")
182 #elif defined __GNUC__
183 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
184 _Pragma("GCC diagnostic push") \
185 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
186 _Pragma("message(\"NOTE: ignoring deprecation warning\")")
187 #define OPENVDB_NO_DEPRECATION_WARNING_END \
188 _Pragma("GCC diagnostic pop")
189 #else
190 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN
191 #define OPENVDB_NO_DEPRECATION_WARNING_END
192 #endif
193
194
205 #if defined __INTEL_COMPILER
206 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
207 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
208 #elif defined __GNUC__
209 // -Wfloat-conversion was only introduced in GCC 4.9
210 #if OPENVDB_CHECK_GCC(4, 9)
211 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
212 _Pragma("GCC diagnostic push") \
213 _Pragma("GCC diagnostic ignored \"-Wconversion\"") \
214 _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"")
215 #else
216 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
217 _Pragma("GCC diagnostic push") \
218 _Pragma("GCC diagnostic ignored \"-Wconversion\"")
219 #endif
220 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END \
221 _Pragma("GCC diagnostic pop")
222 #else
223 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
224 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
225 #endif
226
227
228 #ifdef _MSC_VER
229 #ifndef _USE_MATH_DEFINES
233 #define _USE_MATH_DEFINES
234 #endif
235 #include <boost/math/special_functions/round.hpp>
237 using boost::math::round;
238 #endif
239
241 #ifdef _MSC_VER
242 #include <float.h>
243 static inline double copysign(double x, double y) { return _copysign(x, y); }
244 #endif
245
248 #include <boost/cstdint.hpp>
249 using boost::int8_t;
250 using boost::int16_t;
251 using boost::int32_t;
252 using boost::int64_t;
253 using boost::uint8_t;
254 using boost::uint16_t;
255 using boost::uint32_t;
256 using boost::uint64_t;
257
259 #ifdef OPENVDB_EXPORT
260 #undef OPENVDB_EXPORT
261 #endif
262 #ifdef OPENVDB_IMPORT
263 #undef OPENVDB_IMPORT
264 #endif
265 #ifdef __GNUC__
266 #define OPENVDB_EXPORT __attribute__((visibility("default")))
267 #define OPENVDB_IMPORT __attribute__((visibility("default")))
268 #endif
269 #ifdef _WIN32
270 #ifdef OPENVDB_DLL
271 #define OPENVDB_EXPORT __declspec(dllexport)
272 #define OPENVDB_IMPORT __declspec(dllimport)
273 #else
274 #define OPENVDB_EXPORT
275 #define OPENVDB_IMPORT
276 #endif
277 #endif
278
282 #ifdef OPENVDB_API
283 #undef OPENVDB_API
284 #endif
285 #ifdef OPENVDB_PRIVATE
286 #define OPENVDB_API OPENVDB_EXPORT
287 #else
288 #define OPENVDB_API OPENVDB_IMPORT
289 #endif
290 #ifdef OPENVDB_HOUDINI_API
291 #undef OPENVDB_HOUDINI_API
292 #endif
293 #ifdef OPENVDB_HOUDINI_PRIVATE
294 #define OPENVDB_HOUDINI_API OPENVDB_EXPORT
295 #else
296 #define OPENVDB_HOUDINI_API OPENVDB_IMPORT
297 #endif
298
299 #endif // OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
300
301 // Copyright (c) 2012-2019 DreamWorks Animation LLC
302 // All rights reserved. This software is distributed under the
303 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
PlatformConfig.h