Bug#714923: opencv FTBFS on sparc64 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714923 opencv uses functions from , but it wrongly assumes this functions apply to an int type. While it is true for some architectures, some architectures are using a long type there. The correct type to use is _Atomic_word. Signed-off-by: Waldemar Brodkorb diff -Nur opencv-2.4.12.3.orig/modules/core/include/opencv2/core/core.hpp opencv-2.4.12.3/modules/core/include/opencv2/core/core.hpp --- opencv-2.4.12.3.orig/modules/core/include/opencv2/core/core.hpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/include/opencv2/core/core.hpp 2016-04-03 00:10:50.455774144 +0200 @@ -1290,7 +1290,7 @@ operator const _Tp*() const; _Tp* obj; //< the object pointer. - int* refcount; //< the associated reference counter + _Atomic_word* refcount; //< the associated reference counter }; template @@ -1490,9 +1490,9 @@ public: MatAllocator() {} virtual ~MatAllocator() {} - virtual void allocate(int dims, const int* sizes, int type, int*& refcount, + virtual void allocate(int dims, const int* sizes, int type, _Atomic_word*& refcount, uchar*& datastart, uchar*& data, size_t* step) = 0; - virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; + virtual void deallocate(_Atomic_word* refcount, uchar* datastart, uchar* data) = 0; }; /*! @@ -1985,7 +1985,7 @@ //! pointer to the reference counter; // when matrix points to user-allocated data, the pointer is NULL - int* refcount; + _Atomic_word* refcount; //! helper fields used in locateROI and adjustROI uchar* datastart; @@ -3408,7 +3408,7 @@ { Hdr(int _dims, const int* _sizes, int _type); void clear(); - int refcount; + _Atomic_word refcount; int dims; int valueOffset; size_t nodeSize; diff -Nur opencv-2.4.12.3.orig/modules/core/include/opencv2/core/gpumat.hpp opencv-2.4.12.3/modules/core/include/opencv2/core/gpumat.hpp --- opencv-2.4.12.3.orig/modules/core/include/opencv2/core/gpumat.hpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/include/opencv2/core/gpumat.hpp 2016-04-02 23:08:58.116874218 +0200 @@ -301,7 +301,7 @@ //! pointer to the reference counter; // when GpuMatrix points to user-allocated data, the pointer is NULL - int* refcount; + _Atomic_word* refcount; //! helper fields used in locateROI and adjustROI uchar* datastart; diff -Nur opencv-2.4.12.3.orig/modules/core/include/opencv2/core/operations.hpp opencv-2.4.12.3/modules/core/include/opencv2/core/operations.hpp --- opencv-2.4.12.3.orig/modules/core/include/opencv2/core/operations.hpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/include/opencv2/core/operations.hpp 2016-04-02 23:12:59.148385306 +0200 @@ -2589,7 +2589,7 @@ { if(obj) { - refcount = (int*)fastMalloc(sizeof(*refcount)); + refcount = (_Atomic_word*)fastMalloc(sizeof(*refcount)); *refcount = 1; } else @@ -2628,7 +2628,7 @@ { if (this != &_ptr) { - int* _refcount = _ptr.refcount; + _Atomic_word* _refcount = _ptr.refcount; if( _refcount ) CV_XADD(_refcount, 1); release(); diff -Nur opencv-2.4.12.3.orig/modules/core/src/gpumat.cpp opencv-2.4.12.3/modules/core/src/gpumat.cpp --- opencv-2.4.12.3.orig/modules/core/src/gpumat.cpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/src/gpumat.cpp 2016-04-02 23:14:38.894804300 +0200 @@ -716,7 +716,7 @@ datastart = data = static_cast(devPtr); dataend = data + nettosize; - refcount = static_cast(fastMalloc(sizeof(*refcount))); + refcount = static_cast<_Atomic_word*>(fastMalloc(sizeof(*refcount))); *refcount = 1; } } diff -Nur opencv-2.4.12.3.orig/modules/core/src/matrix.cpp opencv-2.4.12.3/modules/core/src/matrix.cpp --- opencv-2.4.12.3.orig/modules/core/src/matrix.cpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/src/matrix.cpp 2016-04-02 23:59:53.405491031 +0200 @@ -213,7 +213,7 @@ { size_t totalsize = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount)); data = datastart = (uchar*)fastMalloc(totalsize + (int)sizeof(*refcount)); - refcount = (int*)(data + totalsize); + refcount = (_Atomic_word*)(data + totalsize); *refcount = 1; } else @@ -228,7 +228,7 @@ allocator = 0; size_t totalSize = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount)); data = datastart = (uchar*)fastMalloc(totalSize + (int)sizeof(*refcount)); - refcount = (int*)(data + totalSize); + refcount = (_Atomic_word*)(data + totalSize); *refcount = 1; } #else diff -Nur opencv-2.4.12.3.orig/modules/core/src/system.cpp opencv-2.4.12.3/modules/core/src/system.cpp --- opencv-2.4.12.3.orig/modules/core/src/system.cpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/core/src/system.cpp 2016-04-02 23:33:19.298905578 +0200 @@ -892,7 +892,7 @@ void unlock() { LeaveCriticalSection(&cs); } CRITICAL_SECTION cs; - int refcount; + _Atomic_word refcount; }; #ifndef __GNUC__ @@ -920,7 +920,7 @@ void unlock() { OSSpinLockUnlock(&sl); } OSSpinLock sl; - int refcount; + _Atomic_word refcount; }; #elif defined __linux__ && !defined ANDROID && !defined __LINUXTHREADS_OLD__ @@ -935,7 +935,7 @@ void unlock() { pthread_spin_unlock(&sl); } pthread_spinlock_t sl; - int refcount; + _Atomic_word refcount; }; #else @@ -950,7 +950,7 @@ void unlock() { pthread_mutex_unlock(&sl); } pthread_mutex_t sl; - int refcount; + _Atomic_word refcount; }; #endif diff -Nur opencv-2.4.12.3.orig/modules/gpu/include/opencv2/gpu/gpu.hpp opencv-2.4.12.3/modules/gpu/include/opencv2/gpu/gpu.hpp --- opencv-2.4.12.3.orig/modules/gpu/include/opencv2/gpu/gpu.hpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/gpu/include/opencv2/gpu/gpu.hpp 2016-04-02 23:16:19.737293785 +0200 @@ -125,7 +125,7 @@ size_t step; uchar* data; - int* refcount; + _Atomic_word* refcount; uchar* datastart; uchar* dataend; diff -Nur opencv-2.4.12.3.orig/modules/ocl/include/opencv2/ocl/ocl.hpp opencv-2.4.12.3/modules/ocl/include/opencv2/ocl/ocl.hpp --- opencv-2.4.12.3.orig/modules/ocl/include/opencv2/ocl/ocl.hpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/ocl/include/opencv2/ocl/ocl.hpp 2016-04-02 23:18:55.715331443 +0200 @@ -404,7 +404,7 @@ //! pointer to the reference counter; // when oclMatrix points to user-allocated data, the pointer is NULL - int *refcount; + _Atomic_word *refcount; //! helper fields used in locateROI and adjustROI //datastart and dataend are not used in current version diff -Nur opencv-2.4.12.3.orig/modules/ocl/src/matrix_operations.cpp opencv-2.4.12.3/modules/ocl/src/matrix_operations.cpp --- opencv-2.4.12.3.orig/modules/ocl/src/matrix_operations.cpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/ocl/src/matrix_operations.cpp 2016-04-02 23:19:23.633128033 +0200 @@ -591,7 +591,7 @@ datastart = data = (uchar *)dev_ptr; dataend = data + nettosize; - refcount = (int *)fastMalloc(sizeof(*refcount)); + refcount = (_Atomic_word *)fastMalloc(sizeof(*refcount)); *refcount = 1; } } diff -Nur opencv-2.4.12.3.orig/modules/python/src2/cv2.cpp opencv-2.4.12.3/modules/python/src2/cv2.cpp --- opencv-2.4.12.3.orig/modules/python/src2/cv2.cpp 2015-10-26 08:56:34.000000000 +0100 +++ opencv-2.4.12.3/modules/python/src2/cv2.cpp 2016-04-02 23:18:34.897991791 +0200 @@ -157,12 +157,12 @@ static size_t REFCOUNT_OFFSET = (size_t)&(((PyObject*)0)->ob_refcnt) + (0x12345678 != *(const size_t*)"\x78\x56\x34\x12\0\0\0\0\0")*sizeof(int); -static inline PyObject* pyObjectFromRefcount(const int* refcount) +static inline PyObject* pyObjectFromRefcount(const _Atomic_word* refcount) { return (PyObject*)((size_t)refcount - REFCOUNT_OFFSET); } -static inline int* refcountFromPyObject(const PyObject* obj) +static inline _Atomic_word* refcountFromPyObject(const PyObject* obj) { return (int*)((size_t)obj + REFCOUNT_OFFSET); } @@ -173,7 +173,7 @@ NumpyAllocator() {} ~NumpyAllocator() {} - void allocate(int dims, const int* sizes, int type, int*& refcount, + void allocate(int dims, const int* sizes, int type, _Atomic_word*& refcount, uchar*& datastart, uchar*& data, size_t* step) { PyEnsureGIL gil; @@ -206,7 +206,7 @@ datastart = data = (uchar*)PyArray_DATA((PyArrayObject*) o); } - void deallocate(int* refcount, uchar*, uchar*) + void deallocate(_Atomic_word* refcount, uchar*, uchar*) { PyEnsureGIL gil; if( !refcount )