20 #if !defined(__MITSUBA_CORE_PLATFORM_H_)
21 #define __MITSUBA_CORE_PLATFORM_H_
24 #define BOOST_ALL_NO_LIB 1
26 #if !defined(_OPENMP) && !defined(MTS_NO_OPENMP)
35 #define _CRT_SECURE_NO_WARNINGS
36 #define _CRT_NONSTDC_NO_DEPRECATE
37 #define _CRT_SECURE_NO_DEPRECATE
39 #define _WIN32_WINNT 0x0501 // Windows XP
41 #define WIN32_LEAN_AND_MEAN
43 #pragma warning(disable : 4251) // 'field' : class 'A' needs to have dll-interface to be used by clients of class 'B'
44 #pragma warning(disable : 4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning)
45 #pragma warning(disable : 4996) // Secure SCL warnings
53 #pragma intrinsic(memset, memcmp, memcpy, strlen, strcmp, strcpy, _strset, strcat, fabs, abs)
57 #ifdef SINGLE_PRECISION
58 #pragma detect_mismatch( "MTS_FLOAT_PRECISION", "SINGLE")
59 #elif DOUBLE_PRECISION
60 #pragma detect_mismatch( "MTS_FLOAT_PRECISION", "DOUBLE")
62 #define MTS_STRINGIFY(s) #s
63 #define MTS_XSTRINGIFY(s) MTS_STRINGIFY(s)
64 #pragma detect_mismatch("MTS_SPECTRUM_SAMPLES", MTS_XSTRINGIFY(SPECTRUM_SAMPLES))
66 #elif defined(__APPLE__)
68 #elif defined(__linux)
70 #if !defined(_GNU_SOURCE)
78 #define MTS_DONT_EXPORT // not supported on MSVC
79 #define SIZE_T_FMT "%Iu"
80 #define BOOST_FILESYSTEM_NO_LIB
81 #define BOOST_SYSTEM_NO_LIB
82 #define MTS_EXPORT __declspec(dllexport)
83 #define MTS_IMPORT __declspec(dllimport)
84 #define MTS_MAY_ALIAS // not supported on Windows
86 #define MTS_EXPORT __attribute__ ((visibility("default")))
88 #define MTS_MAY_ALIAS __attribute__ ((__may_alias__))
92 #define SIZE_T_FMT "%zd"
95 #define MTS_MODULE_CORE 1
96 #define MTS_MODULE_RENDER 2
97 #define MTS_MODULE_HW 3
98 #define MTS_MODULE_BIDIR 4
99 #define MTS_MODULE_PYTHON 5
101 #if MTS_BUILD_MODULE == MTS_MODULE_CORE
102 #define MTS_EXPORT_CORE MTS_EXPORT
104 #define MTS_EXPORT_CORE MTS_IMPORT
106 #if MTS_BUILD_MODULE == MTS_MODULE_RENDER
107 #define MTS_EXPORT_RENDER MTS_EXPORT
109 #define MTS_EXPORT_RENDER MTS_IMPORT
111 #if MTS_BUILD_MODULE == MTS_MODULE_HW
112 #define MTS_EXPORT_HW MTS_EXPORT
114 #define MTS_EXPORT_HW MTS_IMPORT
116 #if MTS_BUILD_MODULE == MTS_MODULE_BIDIR
117 #define MTS_EXPORT_BIDIR MTS_EXPORT
119 #define MTS_EXPORT_BIDIR MTS_IMPORT
121 #if MTS_BUILD_MODULE == MTS_MODULE_PYTHON
122 #define MTS_EXPORT_PYTHON MTS_EXPORT
124 #define MTS_EXPORT_PYTHON MTS_IMPORT
127 #if defined(__x86_64__) || defined(_M_X64) || defined(__LP64__) || defined(_LP64) || defined(WIN64)
133 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
134 #define __LITTLE_ENDIAN__ 1 // Little endian by default
137 #define MTS_NAMESPACE_BEGIN namespace mitsuba {
138 #define MTS_NAMESPACE_END }
140 #if defined(__GNUC__)
141 #define FINLINE inline __attribute__((always_inline))
142 #define NOINLINE __attribute__((noinline))
143 #define EXPECT_TAKEN(a) __builtin_expect(!!(a), true)
144 #define EXPECT_NOT_TAKEN(a) __builtin_expect(!!(a), false)
145 #elif defined(__MSVC__)
146 #define FINLINE __forceinline
147 #define NOINLINE __declspec(noinline)
148 #define MM_ALIGN16 __declspec(align(16))
149 #define EXPECT_TAKEN(a) (a)
150 #define EXPECT_NOT_TAKEN(a) (a)
152 #error Unsupported compiler!
156 #define SSE_STR "SSE2 enabled"
158 #define SSE_STR "SSE2 disabled"
164 #if defined(__OSX__) && !defined(__INTEL_COMPILER) && !defined(MTS_NO_OPENMP)
165 #define MTS_NO_OPENMP
168 #if !defined(MTS_NO_OPENMP)
173 #define BOOST_FILESYSTEM_VERSION 3
179 #if defined(DOUBLE_PRECISION)
180 typedef double Float;
181 #elif defined(SINGLE_PRECISION)
184 #error No precision flag was defined!
196 #define MTS_AUTORELEASE_BEGIN() __mts_autorelease_begin();
197 #define MTS_AUTORELEASE_END() __mts_autorelease_end();
198 #define MTS_AMBIGUOUS_SIZE_T 1
200 #define MTS_AUTORELEASE_BEGIN()
201 #define MTS_AUTORELEASE_END()
211 #if defined(_MSC_VER)
215 #define snprintf _snprintf
216 #define vsnprintf _vsnprintf
219 #if defined(__64BIT__)
220 typedef long long ssize_t;
222 typedef long ssize_t;
227 inline char tolower(
char c) {
231 inline char toupper(
char c) {
235 inline bool isnan(
float f) {
239 inline bool isnan(
double f) {
243 inline bool isfinite(
float f) {
247 inline bool isfinite(
double f) {
251 inline bool isinf(
float f) {
255 inline bool isinf(
double f) {