Commit 8d324dfd authored by John Kirkham's avatar John Kirkham

Define Python Raw Mem helpers in ModuleSetupCode

To handle the Python version differences, handle the definitions of
`PyMem_Raw*` functions in `ModuleSetupCode`. Then extern them in
`cpython.mem` without using a version check or a specific header.
parent 9fbbf216
from cpython.version cimport PY_VERSION_HEX
cdef extern from *:
void* PyMem_RawMalloc(size_t n) nogil
void* PyMem_RawRealloc(void *p, size_t n) nogil
void PyMem_RawFree(void *p) nogil
cdef extern from "Python.h":
#####################################################################
......@@ -24,15 +29,6 @@ cdef extern from "Python.h":
# for the I/O buffer escapes completely the Python memory
# manager."
IF PY_VERSION_HEX >= 0x03040000:
void* PyMem_RawMalloc(size_t n) nogil
void* PyMem_RawRealloc(void *p, size_t n) nogil
void PyMem_RawFree(void *p) nogil
ELSE:
void* PyMem_RawMalloc "PyMem_Malloc" (size_t n) nogil
void* PyMem_RawRealloc "PyMem_Realloc" (void *p, size_t n) nogil
void PyMem_RawFree "PyMem_Free" (void *p) nogil
# The following function sets, modeled after the ANSI C standard,
# but specifying behavior when requesting zero bytes, are
# available for allocating and releasing memory from the Python
......
......@@ -441,6 +441,12 @@ class __Pyx_FakeReference {
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
#define PyMem_RawMalloc(n) PyMem_Malloc(n)
#define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
#define PyMem_RawFree(p) PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
// special C-API functions only in Pyston
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
......
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