Bug#714923: opencv FTBFS on sparc64

David Matthew Mattli dmm at mattli.us
Mon Feb 1 22:14:26 UTC 2016


Source: opencv
Followup-For: Bug #714923
User: debian-sparc at lists.debian.org
Usertags: sparc64

The _Atomic_word problem was reintroduced in two places and it's
breaking the sparc64 build again. You can see the problem in this
build log:

https://buildd.debian.org/status/fetch.php?pkg=opencv&arch=sparc64&ver=2.4.9.1%2Bdfsg-1.2&stamp=\
\
1452934608

I've updated the "change_type_from_int_to_Atomic_word" patch already
in the opencv package to add corrections for the problematic
lines. Please replace the current patch with the one attached to fix
the build.

Thanks,
David Mattli



-- System Information:
Debian Release: stretch/sid
  APT prefers unreleased
    APT policy: (500, 'unreleased'), (500, 'unstable')
    Architecture: sparc64

Kernel: Linux 4.3.0-1-sparc64-smp (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


Description: Fix FTBFS on sparc64
Author: Aurelien Jarno <aurel32 at debian.org>, David Mattli <dmm at mattli.us>
Forwarded: not yet
Debian-Bug: 714923
Last-Update: <2015-01-25>

Index: opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/core.hpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/include/opencv2/core/core.hpp
+++ opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/core.hpp
@@ -1300,7 +1300,7 @@ public:
     operator const _Tp*() const;
 
     _Tp* obj; //< the object pointer.
-    int* refcount; //< the associated reference counter
+    _Atomic_word* refcount; //< the associated reference counter
 };
 
 
@@ -1468,9 +1468,9 @@ class CV_EXPORTS MatAllocator
 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;
 };
 
 /*!
@@ -1965,7 +1965,7 @@ public:
 
     //! 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;
@@ -3384,7 +3384,7 @@ public:
     {
         Hdr(int _dims, const int* _sizes, int _type);
         void clear();
-        int refcount;
+        _Atomic_word refcount;
         int dims;
         int valueOffset;
         size_t nodeSize;
Index: opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/gpumat.hpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/include/opencv2/core/gpumat.hpp
+++ opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/gpumat.hpp
@@ -301,7 +301,7 @@ namespace cv { namespace gpu
 
         //! 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;
Index: opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/operations.hpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/include/opencv2/core/operations.hpp
+++ opencv-2.4.9.1+dfsg/modules/core/include/opencv2/core/operations.hpp
@@ -2281,7 +2281,7 @@ public:
         Hdr() : data(0), datastart(0), refcount(0), size(0), capacity(0) {};
         _Tp* data;
         _Tp* datastart;
-        int* refcount;
+        _Atomic_word* refcount;
         size_t size;
         size_t capacity;
     };
@@ -2588,7 +2588,7 @@ template<typename _Tp> inline Ptr<_Tp>::
 {
     if(obj)
     {
-        refcount = (int*)fastMalloc(sizeof(*refcount));
+        refcount = (_Atomic_word*)fastMalloc(sizeof(*refcount));
         *refcount = 1;
     }
     else
@@ -2625,7 +2625,7 @@ template<typename _Tp> inline Ptr<_Tp>::
 
 template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& _ptr)
 {
-    int* _refcount = _ptr.refcount;
+    _Atomic_word* _refcount = _ptr.refcount;
     if( _refcount )
         CV_XADD(_refcount, 1);
     release();
Index: opencv-2.4.9.1+dfsg/modules/core/src/gpumat.cpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/src/gpumat.cpp
+++ opencv-2.4.9.1+dfsg/modules/core/src/gpumat.cpp
@@ -716,7 +716,7 @@ void cv::gpu::GpuMat::create(int _rows,
         datastart = data = static_cast<uchar*>(devPtr);
         dataend = data + nettosize;
 
-        refcount = static_cast<int*>(fastMalloc(sizeof(*refcount)));
+        refcount = static_cast<_Atomic_word*>(fastMalloc(sizeof(*refcount)));
         *refcount = 1;
     }
 }
Index: opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/src/matrix.cpp
+++ opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp
@@ -213,7 +213,7 @@ void Mat::create(int d, const int* _size
         {
             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
Index: opencv-2.4.9.1+dfsg/modules/core/src/system.cpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/core/src/system.cpp
+++ opencv-2.4.9.1+dfsg/modules/core/src/system.cpp
@@ -903,7 +903,7 @@ struct Mutex::Impl
     void unlock() { pthread_spin_unlock(&sl); }
 
     pthread_spinlock_t sl;
-    int refcount;
+    _Atomic_word refcount;
 };
 
 #else
Index: opencv-2.4.9.1+dfsg/modules/gpu/include/opencv2/gpu/gpu.hpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/gpu/include/opencv2/gpu/gpu.hpp
+++ opencv-2.4.9.1+dfsg/modules/gpu/include/opencv2/gpu/gpu.hpp
@@ -125,7 +125,7 @@ public:
     size_t step;
 
     uchar* data;
-    int* refcount;
+    _Atomic_word* refcount;
 
     uchar* datastart;
     uchar* dataend;
Index: opencv-2.4.9.1+dfsg/modules/python/src2/cv2.cpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/python/src2/cv2.cpp
+++ opencv-2.4.9.1+dfsg/modules/python/src2/cv2.cpp
@@ -157,14 +157,14 @@ static PyObject* failmsgp(const char *fm
 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);
+    return (_Atomic_word*)((size_t)obj + REFCOUNT_OFFSET);
 }
 
 class NumpyAllocator : public MatAllocator
@@ -173,7 +173,7 @@ public:
     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 @@ public:
         datastart = data = (uchar*)PyArray_DATA((PyArrayObject*) o);
     }
 
-    void deallocate(int* refcount, uchar*, uchar*)
+    void deallocate(_Atomic_word* refcount, uchar*, uchar*)
     {
         PyEnsureGIL gil;
         if( !refcount )
Index: opencv-2.4.9.1+dfsg/modules/ocl/include/opencv2/ocl/ocl.hpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/ocl/include/opencv2/ocl/ocl.hpp
+++ opencv-2.4.9.1+dfsg/modules/ocl/include/opencv2/ocl/ocl.hpp
@@ -404,7 +404,7 @@ namespace cv
 
             //! 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
Index: opencv-2.4.9.1+dfsg/modules/ocl/src/matrix_operations.cpp
===================================================================
--- opencv-2.4.9.1+dfsg.orig/modules/ocl/src/matrix_operations.cpp
+++ opencv-2.4.9.1+dfsg/modules/ocl/src/matrix_operations.cpp
@@ -591,7 +591,7 @@ void cv::ocl::oclMat::createEx(int _rows
         datastart = data = (uchar *)dev_ptr;
         dataend = data + nettosize;
 
-        refcount = (int *)fastMalloc(sizeof(*refcount));
+        refcount = (_Atomic_word *)fastMalloc(sizeof(*refcount));
         *refcount = 1;
     }
 }



More information about the debian-science-maintainers mailing list