Commit 4cfbee70 authored by Roman Donchenko's avatar Roman Donchenko

Simplified the Windows implementation of CV_XADD.

_InterlockedExchangeAdd is a Visual Studio intrinsic that's available
for all architectures and in all VS versions that we care about. It's also
faster than the underscore-less function, since it's an intrinsic.
We also don't need to declare it ourselves.

It is, however, a Visual Studio-specific intrinsic, so I changed the
preprocessing condition accordingly.

Fixes <http://code.opencv.org/issues/3365>.
parent bb4bf7a1
......@@ -458,15 +458,8 @@ CV_INLINE int cvIsInf( double value )
# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta))
# endif
# endif
#elif (defined WIN32 || defined _WIN32 || defined WINCE) && (!defined RC_INVOKED)
# if !defined(_M_AMD64) && !defined(_M_IA64) && !defined(_M_ARM)
CV_EXTERN_C __declspec(dllimport) long __stdcall InterlockedExchangeAdd(long volatile *Addend, long Value);
# define CV_XADD(addr, delta) (int)InterlockedExchangeAdd((long volatile*)addr, delta)
# else
CV_EXTERN_C long _InterlockedExchangeAdd (long volatile *Addend, long Value);
# pragma intrinsic(_InterlockedExchangeAdd)
# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
# endif
#elif defined _MSC_VER && !defined RC_INVOKED
# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
#else
CV_INLINE CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; }
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment