diff --git a/SConstruct b/SConstruct index a509cefc..af48e599 100644 --- a/SConstruct +++ b/SConstruct @@ -285,8 +285,8 @@ if sys.platform == 'darwin': coreEnv_osx['CXXFLAGS'].append('-fno-strict-aliasing'); libcore_objects += coreEnv_osx.SharedObject('src/libcore/platform_darwin.mm') elif sys.platform == 'win32': - libcore_objects += coreEnv_osx.SharedObject('src/libcore/getopt.c') - libcore_objects += coreEnv_osx.SharedObject('src/libcore/platform_win32.cpp') + libcore_objects += coreEnv.SharedObject('src/libcore/getopt.c') + libcore_objects += coreEnv.SharedObject('src/libcore/platform_win32.cpp') libcore = coreEnv.SharedLibrary('src/libcore/mitsuba-core', libcore_objects); diff --git a/include/mitsuba/core/atomic.h b/include/mitsuba/core/atomic.h index 8d646b8c..4af4d365 100644 --- a/include/mitsuba/core/atomic.h +++ b/include/mitsuba/core/atomic.h @@ -29,7 +29,8 @@ MTS_NAMESPACE_BEGIN template inline bool atomicCompareAndExchangePtr(T **v, T *newValue, T *oldValue) { #if defined(WIN32) - return InterlockedCompareExchange(v, newValue, oldValue) == oldValue; + return InterlockedCompareExchangePointer( + reinterpret_cast(v), newValue, oldValue) == oldValue; #else return __sync_bool_compare_and_swap(v, oldValue, newValue); #endif diff --git a/include/mitsuba/core/getopt.h b/include/mitsuba/core/getopt.h index ced5d056..8c5a6598 100644 --- a/include/mitsuba/core/getopt.h +++ b/include/mitsuba/core/getopt.h @@ -23,6 +23,14 @@ # define _GETOPT_H 1 #endif +#if !defined(MTS_EXPORT_CORE) + #if MTS_BUILD_MODULE == MTS_MODULE_CORE + #define MTS_EXPORT_CORE __declspec(dllexport) + #else + #define MTS_EXPORT_CORE __declspec(dllimport) + #endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -33,7 +41,7 @@ extern "C" { Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -extern char *optarg; +extern MTS_EXPORT_CORE char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -47,16 +55,16 @@ extern char *optarg; Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ -extern int optind; +extern MTS_EXPORT_CORE int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ -extern int opterr; +extern MTS_EXPORT_CORE int opterr; /* Set to an option character which was unrecognized. */ -extern int optopt; +extern MTS_EXPORT_CORE int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. @@ -125,17 +133,17 @@ struct option /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ -extern int getopt (int __argc, char *const *__argv, const char *__shortopts); +extern MTS_EXPORT_CORE int getopt (int __argc, char *const *__argv, const char *__shortopts); # ifndef __need_getopt -extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, +extern MTS_EXPORT_CORE int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); -extern int getopt_long_only (int __argc, char *const *__argv, +extern MTS_EXPORT_CORE int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int __argc, char *const *__argv, +extern MTS_EXPORT_CORE int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); diff --git a/include/mitsuba/core/stl.h b/include/mitsuba/core/stl.h index 39e2a574..c0335feb 100644 --- a/include/mitsuba/core/stl.h +++ b/include/mitsuba/core/stl.h @@ -168,8 +168,10 @@ inline bool ubi_isnan(double f) { int classification = ::_fpclass(f); return classification == _FPCLASS_QNAN || classification == _FPCLASS_SNAN; } +extern "C" { + extern MTS_EXPORT_CORE float nextafterf(float x, float y); +}; -extern float nextafterf(float x, float y); #else inline bool ubi_isnan(float f) { return std::fpclassify(f) == FP_NAN; diff --git a/include/mitsuba/render/gkdtree.h b/include/mitsuba/render/gkdtree.h index 01fe8e94..59a00cd2 100644 --- a/include/mitsuba/render/gkdtree.h +++ b/include/mitsuba/render/gkdtree.h @@ -119,7 +119,7 @@ public: * Walks through the list of chunks to find one with enough * free memory. If no chunk could be found, a new one is created. */ - template T * __restrict__ allocate(size_t size) { + template T * __restrict allocate(size_t size) { size *= sizeof(T); for (std::vector::iterator it = m_chunks.begin(); it != m_chunks.end(); ++it) { @@ -295,7 +295,7 @@ public: * create unused elements in the previous block if a new * one has to be allocated. */ - inline T * __restrict__ allocate(size_t size) { + inline T * __restrict allocate(size_t size) { #if defined(MTS_KD_DEBUG) SAssert(size <= BlockSize); #endif @@ -2174,10 +2174,10 @@ protected: } } - KDAssert(leftEventsTempEnd - leftEventsTempStart <= primsLeft * 6); - KDAssert(rightEventsTempEnd - rightEventsTempStart <= primsRight * 6); - KDAssert(newEventsLeftEnd - newEventsLeftStart <= primsBoth * 6); - KDAssert(newEventsRightEnd - newEventsRightStart <= primsBoth * 6); + KDAssert((size_type) (leftEventsTempEnd - leftEventsTempStart) <= primsLeft * 6); + KDAssert((size_type) (rightEventsTempEnd - rightEventsTempStart) <= primsRight * 6); + KDAssert((size_type) (newEventsLeftEnd - newEventsLeftStart) <= primsBoth * 6); + KDAssert((size_type) (newEventsRightEnd - newEventsRightStart) <= primsBoth * 6); ctx.pruned += prunedLeft + prunedRight; /* Sort the events from overlapping prims */ @@ -2216,8 +2216,8 @@ protected: *rightEventsEnd++ = *event; } } - KDAssert(leftEventsEnd - leftEventsStart <= bestSplit.numLeft * 6); - KDAssert(rightEventsEnd - rightEventsStart <= bestSplit.numRight * 6); + KDAssert((size_type) (leftEventsEnd - leftEventsStart) <= bestSplit.numLeft * 6); + KDAssert((size_type) (rightEventsEnd - rightEventsStart) <= bestSplit.numRight * 6); } /* Shrink the edge event storage now that we know exactly how @@ -2317,7 +2317,7 @@ protected: */ void setAABB(const AABB &aabb) { m_aabb = aabb; - m_binSize = m_aabb.getExtents() / m_binCount; + m_binSize = m_aabb.getExtents() / (Float) m_binCount; for (int axis=0; axis<3; ++axis) m_invBinSize[axis] = 1/m_binSize[axis]; } @@ -3092,9 +3092,9 @@ template void GenericKDTree::findCosts( nIntersections++; if (i > warmup) { A[idx].x = 1; - A[idx].y = boost::get<1>(statistics); - A[idx].z = boost::get<2>(statistics); - b[idx] = boost::get<3>(statistics); + A[idx].y = (Float) boost::get<1>(statistics); + A[idx].z = (Float) boost::get<2>(statistics); + b[idx] = (Float) boost::get<3>(statistics); idx++; } } diff --git a/include/mitsuba/render/irrcache.h b/include/mitsuba/render/irrcache.h index e27bf917..c9b2feee 100644 --- a/include/mitsuba/render/irrcache.h +++ b/include/mitsuba/render/irrcache.h @@ -39,7 +39,7 @@ typedef Spectrum TranslationalGradient[3]; * * @author Wenzel Jakob */ -struct MTS_EXPORT_RENDER HemisphereSampler : public Object { +class MTS_EXPORT_RENDER HemisphereSampler : public Object { public: struct SampleEntry { Vector d; diff --git a/include/mitsuba/render/kdtree.h b/include/mitsuba/render/kdtree.h index 79dab483..065183a5 100644 --- a/include/mitsuba/render/kdtree.h +++ b/include/mitsuba/render/kdtree.h @@ -54,7 +54,7 @@ MTS_NAMESPACE_BEGIN * * \sa GenericKDTree */ -class KDTree : public GenericKDTree { +class MTS_EXPORT_RENDER KDTree : public GenericKDTree { friend class GenericKDTree; public: /// Create an empty kd-tree diff --git a/src/converter/mtsimport.cpp b/src/converter/mtsimport.cpp index 8d3838e4..f23d9b8f 100644 --- a/src/converter/mtsimport.cpp +++ b/src/converter/mtsimport.cpp @@ -32,7 +32,7 @@ #include #include #if defined(WIN32) -#include "../mitsuba/getopt.h" +#include #endif XERCES_CPP_NAMESPACE_USE diff --git a/src/libcore/getopt.c b/src/libcore/getopt.c index 79ccd96c..cc64bdad 100644 --- a/src/libcore/getopt.c +++ b/src/libcore/getopt.c @@ -100,7 +100,7 @@ GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ -#include "getopt.h" +#include /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, diff --git a/src/librender/integrator.cpp b/src/librender/integrator.cpp index 97ee849a..51776a42 100644 --- a/src/librender/integrator.cpp +++ b/src/librender/integrator.cpp @@ -163,7 +163,7 @@ void SampleIntegrator::renderBlock(const Scene *scene, RadianceQueryRecord rRec(scene, sampler); bool needsLensSample = camera->needsLensSample(); const TabulatedFilter *filter = camera->getFilm()->getTabulatedFilter(); - Float scaleFactor = 1.0f/std::sqrt(sampler->getSampleCount()); + Float scaleFactor = 1.0f/std::sqrt((Float) sampler->getSampleCount()); if (!block->collectStatistics()) { for (y = sy; y < ey; y++) {