Bug#714923: opencv: FTBFS on sparc64

Aurelien Jarno aurel32 at debian.org
Thu Jul 4 11:24:07 UTC 2013


Source: opencv
Version: 2.3.1-11
Severity: important
Tags: patch

opencv uses functions from <ext/atomicity.h>, 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. This is what the patch below is
doing. Would it be possible to upload it in the next upload? Thanks in
advance.

--- opencv-2.3.1.orig/modules/core/include/opencv2/core/core.hpp
+++ opencv-2.3.1/modules/core/include/opencv2/core/core.hpp
@@ -1252,7 +1252,7 @@ public:
     
 protected:
     _Tp* obj; //< the object pointer.
-    int* refcount; //< the associated reference counter
+    _Atomic_word* refcount; //< the associated reference counter
 };
 
     
@@ -1355,9 +1355,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;
 };
     
 /*!
@@ -1850,7 +1850,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;
@@ -3195,7 +3195,7 @@ public:
     {
         Hdr(int _dims, const int* _sizes, int _type);
         void clear();
-        int refcount;
+        _Atomic_word refcount;
         int dims;
         int valueOffset;
         size_t nodeSize;
--- opencv-2.3.1.orig/modules/core/include/opencv2/core/operations.hpp
+++ opencv-2.3.1/modules/core/include/opencv2/core/operations.hpp
@@ -2354,7 +2354,7 @@ template<typename _Tp> inline Ptr<_Tp>::
 {
     if(obj)
     {
-        refcount = (int*)fastMalloc(sizeof(*refcount));
+        refcount = (_Atomic_word*)fastMalloc(sizeof(*refcount));
         *refcount = 1;
     }
     else
@@ -2391,7 +2391,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();
--- opencv-2.3.1.orig/modules/core/src/matrix.cpp
+++ opencv-2.3.1/modules/core/src/matrix.cpp
@@ -207,7 +207,7 @@ void Mat::create(int d, const int* _size
         {
             size_t total = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
             data = datastart = (uchar*)fastMalloc(total + (int)sizeof(*refcount));
-            refcount = (int*)(data + total);
+            refcount = (_Atomic_word*)(data + total);
             *refcount = 1;
         }
         else
--- opencv-2.3.1.orig/modules/gpu/include/opencv2/gpu/gpumat.hpp
+++ opencv-2.3.1/modules/gpu/include/opencv2/gpu/gpumat.hpp
@@ -204,7 +204,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;
--- opencv-2.3.1.orig/modules/gpu/include/opencv2/gpu/gpu.hpp
+++ opencv-2.3.1/modules/gpu/include/opencv2/gpu/gpu.hpp
@@ -212,7 +212,7 @@ namespace cv
             size_t step;
 
             uchar* data;
-            int* refcount;
+            _Atomic_word* refcount;
 
             uchar* datastart;
             uchar* dataend;
--- opencv-2.3.1.orig/modules/python/src2/cv2.cpp
+++ opencv-2.3.1/modules/python/src2/cv2.cpp
@@ -84,14 +84,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
@@ -100,7 +100,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)
     {
         int depth = CV_MAT_DEPTH(type);
@@ -131,7 +131,7 @@ public:
         datastart = data = (uchar*)PyArray_DATA(o);
     }
     
-    void deallocate(int* refcount, uchar* datastart, uchar* data)
+    void deallocate(_Atomic_word* refcount, uchar* datastart, uchar* data)
     {
         if( !refcount )
             return;

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

Kernel: Linux 3.2.0-4-sparc64
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash



More information about the debian-science-maintainers mailing list