diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index 413e50a738..f19b798e11 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -67,6 +67,7 @@ # undef small # undef min # undef max +# undef abs #else # include #endif diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index af89bbf3a2..cb01f91390 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -75,16 +75,9 @@ #endif #endif -#elif defined WIN32 || defined _WIN32 - #define WIN32_MEAN_AND_LEAN - #ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) - #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx - #endif - #include - #undef min - #undef max - #undef abs - #define CV_XADD(addr,delta) InterlockedExchangeAdd((long volatile*)(addr), (delta)) +#elif defined WIN32 || defined _WIN32 || defined WINCE + namespace cv { CV_EXPORTS int _interlockedExchangeAdd(int* addr, int delta); } + #define CV_XADD cv::_interlockedExchangeAdd #else static inline int CV_XADD(int* addr, int delta) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index f85f78a191..7bb630bd18 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -947,6 +947,15 @@ struct Mutex::Impl CRITICAL_SECTION cs; int refcount; }; + +int _interlockedExchangeAdd(int* addr, int delta) +{ +#if defined _MSC_VER && _MSC_VER >= 1500 + return (int)_InterlockedExchangeAdd((long volatile*)addr, delta); +#else + return (int)InterlockedExchangeAdd((long volatile*)addr, delta); +#endif +} #elif defined __APPLE__