0001-atomic.patch
8.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
Bug#714923: opencv FTBFS on sparc64
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714923
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.
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
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<typename T>
@@ -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<uchar*>(devPtr);
dataend = data + nettosize;
- refcount = static_cast<int*>(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 )