Go to the documentation of this file.
6 #ifndef OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
7 #define OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
9 #define PRAGMA(x) _Pragma(#x)
14 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
19 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
22 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
27 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
32 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) \
33 (__GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR))
35 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) 0
39 #define OPENVDB_HAS_CXX11 1 // kept for backward compatibility
41 #if __cplusplus >= 202002L
42 #define OPENVDB_HAS_CXX20
46 #if defined(OPENVDB_USE_SSE42) || defined(OPENVDB_USE_AVX)
49 #elif defined(__GNUC__)
50 #if defined(__x86_64__) || defined(__i386__)
51 #include <x86intrin.h>
52 #elif defined(__ARM_NEON__)
67 #if defined(_DLL) && !defined(OPENVDB_STATICLIB) && !defined(OPENVDB_DLL)
74 #if defined(__clang__)
75 #define OPENVDB_UBSAN_SUPPRESS(X) __attribute__((no_sanitize(X)))
77 #define OPENVDB_UBSAN_SUPPRESS(X)
82 #if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
84 #define OPENVDB_LIKELY(x) (__builtin_expect(static_cast<bool>(x), true))
85 #define OPENVDB_UNLIKELY(x) (__builtin_expect(static_cast<bool>(x), false))
87 #define OPENVDB_LIKELY(x) (__builtin_expect((x), 1))
88 #define OPENVDB_UNLIKELY(x) (__builtin_expect((x), 0))
91 #define OPENVDB_LIKELY(x) (x)
92 #define OPENVDB_UNLIKELY(x) (x)
99 #define OPENVDB_FORCE_INLINE __attribute__((always_inline)) inline
100 #elif defined(_MSC_VER)
101 #define OPENVDB_FORCE_INLINE __forceinline
103 #define OPENVDB_FORCE_INLINE inline
121 #if defined(__INTEL_COMPILER)
125 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
126 _Pragma("warning (push)") \
127 _Pragma("warning (disable:111)") \
128 _Pragma("warning (disable:128)") \
129 _Pragma("warning (disable:185)") \
130 _Pragma("warning (disable:280)")
131 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
132 _Pragma("warning (pop)")
133 #elif defined(__clang__)
134 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
135 PRAGMA(clang diagnostic push) \
136 PRAGMA(clang diagnostic ignored "-Wunreachable-code")
137 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
138 PRAGMA(clang diagnostic pop)
140 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
141 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
146 #ifndef OPENVDB_NO_DEPRECATION_WARNINGS
147 #define OPENVDB_DEPRECATED [[deprecated]]
148 #define OPENVDB_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]]
150 #define OPENVDB_DEPRECATED
151 #define OPENVDB_DEPRECATED_MESSAGE(msg)
168 #if defined __INTEL_COMPILER
169 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
170 _Pragma("warning (push)") \
171 _Pragma("warning (disable:1478)")
172 #define OPENVDB_NO_DEPRECATION_WARNING_END \
173 _Pragma("warning (pop)")
174 #elif defined __clang__
175 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
176 _Pragma("clang diagnostic push") \
177 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
179 #define OPENVDB_NO_DEPRECATION_WARNING_END \
180 _Pragma("clang diagnostic pop")
181 #elif defined __GNUC__
182 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
183 _Pragma("GCC diagnostic push") \
184 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
185 #define OPENVDB_NO_DEPRECATION_WARNING_END \
186 _Pragma("GCC diagnostic pop")
187 #elif defined _MSC_VER
188 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
189 __pragma(warning(push)) \
190 __pragma(warning(disable : 4996))
191 #define OPENVDB_NO_DEPRECATION_WARNING_END \
192 __pragma(warning(pop))
194 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN
195 #define OPENVDB_NO_DEPRECATION_WARNING_END
209 #if defined __INTEL_COMPILER
210 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
211 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
212 #elif defined __GNUC__
214 #if OPENVDB_CHECK_GCC(4, 9)
215 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
216 _Pragma("GCC diagnostic push") \
217 _Pragma("GCC diagnostic ignored \"-Wconversion\"") \
218 _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"")
220 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
221 _Pragma("GCC diagnostic push") \
222 _Pragma("GCC diagnostic ignored \"-Wconversion\"")
224 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END \
225 _Pragma("GCC diagnostic pop")
227 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
228 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
232 #ifdef OPENVDB_EXPORT
233 #undef OPENVDB_EXPORT
235 #ifdef OPENVDB_IMPORT
236 #undef OPENVDB_IMPORT
240 #define OPENVDB_EXPORT __declspec(dllexport)
241 #define OPENVDB_IMPORT __declspec(dllimport)
243 #define OPENVDB_EXPORT
244 #define OPENVDB_IMPORT
246 #elif defined(__GNUC__)
247 #define OPENVDB_EXPORT __attribute__((visibility("default")))
248 #define OPENVDB_IMPORT __attribute__((visibility("default")))
252 #if defined(_WIN32) && defined(OPENVDB_DLL)
253 #ifdef OPENVDB_PRIVATE
254 #define OPENVDB_TEMPLATE_EXPORT OPENVDB_EXPORT
255 #define OPENVDB_TEMPLATE_IMPORT
257 #define OPENVDB_TEMPLATE_EXPORT
258 #define OPENVDB_TEMPLATE_IMPORT OPENVDB_IMPORT
261 #define OPENVDB_TEMPLATE_IMPORT
262 #define OPENVDB_TEMPLATE_EXPORT
271 #ifdef OPENVDB_PRIVATE
272 #define OPENVDB_API OPENVDB_EXPORT
274 #define OPENVDB_API OPENVDB_IMPORT
276 #ifdef OPENVDB_HOUDINI_API
277 #undef OPENVDB_HOUDINI_API
279 #ifdef OPENVDB_HOUDINI_PRIVATE
280 #define OPENVDB_HOUDINI_API OPENVDB_EXPORT
282 #define OPENVDB_HOUDINI_API OPENVDB_IMPORT
285 #ifdef OPENVDB_AX_DLL
286 #ifdef OPENVDB_AX_API
287 #undef OPENVDB_AX_API
289 #ifdef OPENVDB_AX_PRIVATE
290 #define OPENVDB_AX_API OPENVDB_EXPORT
292 #define OPENVDB_AX_API OPENVDB_IMPORT
295 #define OPENVDB_AX_API
296 #endif // OPENVDB_AX_DLL
302 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
303 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
304 #define OPENVDB_START_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
305 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
306 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
307 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
311 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
312 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
313 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
314 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
315 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
316 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
319 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) \
320 __pragma(warning(disable:1710)); CODE; __pragma(warning(default:1710))
321 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) \
322 __pragma(warning(disable:1711)); CODE; __pragma(warning(default:1711))
323 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) \
324 __pragma(warning(disable:1712)); CODE; __pragma(warning(default:1712))
326 #else // GCC does not support these compiler warnings
328 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE
329 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE
330 #define OPENVDB_START_THREADSAFE_STATIC_WRITE
331 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE
332 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS
333 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS
335 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE
336 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE
337 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE
338 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE
339 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS
340 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS
342 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) CODE
343 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) CODE
344 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) CODE
346 #endif // defined(__ICC)
348 #endif // OPENVDB_PLATFORM_HAS_BEEN_INCLUDED