Commit c541223a authored by Stefan Behnel's avatar Stefan Behnel

manually mangle new names used in memoryview code to prevent them from interfering with user C code

parent b8eb6545
...@@ -305,8 +305,8 @@ cdef void *align_pointer(void *memory, size_t alignment) nogil: ...@@ -305,8 +305,8 @@ cdef void *align_pointer(void *memory, size_t alignment) nogil:
## note that this could be implemented in a more beautiful way in "normal" Cython, ## note that this could be implemented in a more beautiful way in "normal" Cython,
## but this code gets merged into the user module and not everything works there. ## but this code gets merged into the user module and not everything works there.
DEF THREAD_LOCKS_PREALLOCATED = 8 DEF THREAD_LOCKS_PREALLOCATED = 8
cdef int _thread_locks_used = 0 cdef int __pyx_memoryview_thread_locks_used = 0
cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] _thread_locks = [ cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
PyThread_allocate_lock(), PyThread_allocate_lock(),
PyThread_allocate_lock(), PyThread_allocate_lock(),
PyThread_allocate_lock(), PyThread_allocate_lock(),
...@@ -343,10 +343,10 @@ cdef class memoryview(object): ...@@ -343,10 +343,10 @@ cdef class memoryview(object):
(<__pyx_buffer *> &self.view).obj = Py_None (<__pyx_buffer *> &self.view).obj = Py_None
Py_INCREF(Py_None) Py_INCREF(Py_None)
global _thread_locks_used global __pyx_memoryview_thread_locks_used
if _thread_locks_used < THREAD_LOCKS_PREALLOCATED: if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
self.lock = _thread_locks[_thread_locks_used] self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
_thread_locks_used += 1 __pyx_memoryview_thread_locks_used += 1
if self.lock is NULL: if self.lock is NULL:
self.lock = PyThread_allocate_lock() self.lock = PyThread_allocate_lock()
if self.lock is NULL: if self.lock is NULL:
...@@ -366,14 +366,14 @@ cdef class memoryview(object): ...@@ -366,14 +366,14 @@ cdef class memoryview(object):
__Pyx_ReleaseBuffer(&self.view) __Pyx_ReleaseBuffer(&self.view)
cdef int i cdef int i
global _thread_locks_used global __pyx_memoryview_thread_locks_used
if self.lock != NULL: if self.lock != NULL:
for i in range(_thread_locks_used): for i in range(__pyx_memoryview_thread_locks_used):
if _thread_locks[i] is self.lock: if __pyx_memoryview_thread_locks[i] is self.lock:
_thread_locks_used -= 1 __pyx_memoryview_thread_locks_used -= 1
if i != _thread_locks_used: if i != __pyx_memoryview_thread_locks_used:
_thread_locks[i], _thread_locks[_thread_locks_used] = ( __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
_thread_locks[_thread_locks_used], _thread_locks[i]) __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
break break
else: else:
PyThread_free_lock(self.lock) PyThread_free_lock(self.lock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment