diff -Nuarp opencv-2.4.13.7/modules/core/include/opencv2/core/operations.hpp opencv-2.4.13.7.unsafe_xadd/modules/core/include/opencv2/core/operations.hpp --- opencv-2.4.13.7/modules/core/include/opencv2/core/operations.hpp 2018-07-02 05:41:56.000000000 +0800 +++ opencv-2.4.13.7.unsafe_xadd/modules/core/include/opencv2/core/operations.hpp 2021-05-11 15:43:01.953963662 +0800 @@ -52,46 +52,8 @@ #ifdef __cplusplus /////// exchange-add operation for atomic operations on reference counters /////// -#ifdef CV_XADD - // allow to use user-defined macro -#elif defined __GNUC__ - - #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) - #ifdef __ATOMIC_SEQ_CST - #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST) - #else - #define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), (delta), 5) - #endif - #elif __GNUC__*10 + __GNUC_MINOR__ >= 42 - - #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \ - defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) || \ - defined _STLPORT_MAJOR || defined _LIBCPP_VERSION || \ - defined __EMSCRIPTEN__ - - #define CV_XADD __sync_fetch_and_add - #else - #include - #define CV_XADD __gnu_cxx::__exchange_and_add - #endif - - #else - #include - #if __GNUC__*10 + __GNUC_MINOR__ >= 34 - #define CV_XADD __gnu_cxx::__exchange_and_add - #else - #define CV_XADD __exchange_and_add - #endif - #endif - -#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) - { int tmp = *addr; *addr += delta; return tmp; } -#endif +static inline int CV_XADD(int* addr, int delta) +{ int tmp = *addr; *addr += delta; return tmp; } #include