HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Platform.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 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 //
29 ///////////////////////////////////////////////////////////////////////////
30 ///
31 /// @file Platform.h
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 
40 /// @name Utilities
41 /// @{
42 /// @cond OPENVDB_VERSION_INTERNAL
43 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
44 /// @endcond
45 /// @brief Return @a x as a string literal. If @a x is a macro,
46 /// return its value as a string literal.
47 /// @hideinitializer
48 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
49 
50 /// @cond OPENVDB_VERSION_INTERNAL
51 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
52 /// @endcond
53 /// @brief Form a new token by concatenating two existing tokens.
54 /// If either token is a macro, concatenate its value.
55 /// @hideinitializer
56 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
57 /// @}
58 
59 
60 /// Use OPENVDB_DEPRECATED to mark functions as deprecated.
61 /// It should be placed right before the signature of the function,
62 /// e.g., "OPENVDB_DEPRECATED void functionName();".
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 
72 /// Macro for determining if GCC version is >= than X.Y
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 
80 /// Macro for determining if there are sufficient C++0x/C++11 features
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 
105 /// For compilers that need templated function specializations to have
106 /// storage qualifiers, we need to declare the specializations as static inline.
107 /// Otherwise, we'll get linker errors about multiply defined symbols.
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 
115 /// Bracket code with OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN/_END,
116 /// as in the following example, to inhibit ICC remarks about unreachable code:
117 /// @code
118 /// template<typename NodeType>
119 /// void processNode(NodeType& node)
120 /// {
121 /// OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
122 /// if (NodeType::LEVEL == 0) return; // ignore leaf nodes
123 /// int i = 0;
124 /// ...
125 /// OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
126 /// }
127 /// @endcode
128 /// In the above, <tt>NodeType::LEVEL == 0</tt> is a compile-time constant expression,
129 /// so for some template instantiations, the line below it is unreachable.
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 
154 /// @brief Bracket code with OPENVDB_NO_DEPRECATION_WARNING_BEGIN/_END,
155 /// to inhibit warnings about deprecated code.
156 /// @note Use this sparingly. Remove references to deprecated code if at all possible.
157 /// @details Example:
158 /// @code
159 /// OPENVDB_DEPRECATED void myDeprecatedFunction() {}
160 ///
161 /// {
162 /// OPENVDB_NO_DEPRECATION_WARNING_BEGIN
163 /// myDeprecatedFunction();
164 /// OPENVDB_NO_DEPRECATION_WARNING_END
165 /// }
166 /// @endcode
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 
195 /// @brief Bracket code with OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN/_END,
196 /// to inhibit warnings about type conversion.
197 /// @note Use this sparingly. Use static casts and explicit type conversion if at all possible.
198 /// @details Example:
199 /// @code
200 /// float value = 0.1f;
201 /// OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
202 /// int valueAsInt = value;
203 /// OPENVDB_NO_TYPE_CONVERSION_WARNING_END
204 /// @endcode
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  /// Visual C++ does not have constants like M_PI unless this is defined.
230  /// @note This is needed even though the core library is built with this but
231  /// hcustom 12.1 doesn't define it. So this is needed for HDK operators.
232  #ifndef _USE_MATH_DEFINES
233  #define _USE_MATH_DEFINES
234  #endif
235  /// Visual C++ does not have round
236  #include <hboost/math/special_functions/round.hpp>
237  using hboost::math::round;
238 #endif
239 
240 /// Visual C++ uses _copysign() instead of copysign()
241 #ifdef _MSC_VER
242  #include <float.h>
243  static inline double copysign(double x, double y) { return _copysign(x, y); }
244 #endif
245 
246 /// Visual C++ does not have stdint.h which defines types like uint64_t.
247 /// So for portability we instead include hboost/cstdint.hpp.
248 #include <hboost/cstdint.hpp>
249 using hboost::int8_t;
250 using hboost::int16_t;
251 using hboost::int32_t;
252 using hboost::int64_t;
253 using hboost::uint8_t;
254 using hboost::uint16_t;
255 using hboost::uint32_t;
256 using hboost::uint64_t;
257 
258 /// Helper macros for defining library symbol visibility
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 
279 /// All classes and public free standing functions must be explicitly marked
280 /// as <lib>_API to be exported. The <lib>_PRIVATE macros are defined when
281 /// building that particular library.
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) 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/ )
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
SYS_API double copysign(double x, double y)
vfloat4 round(const vfloat4 &a)
Definition: simd.h:7186