Loading src/shared_array.c +2 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define PY_ARRAY_UNIQUE_SYMBOL SHARED_ARRAY_ARRAY_API #include <Python.h> #include <structseq.h> #include <numpy/arrayobject.h> #include "shared_array.h" Loading Loading @@ -47,11 +48,9 @@ static PyMethodDef module_functions[] = { METH_VARARGS, "Delete an existing numpy array from shared memory" }, #if PY_MAJOR_VERSION >= 3 { "list", (PyCFunction) shared_array_list, METH_VARARGS, "List all existing numpy arrays from shared memory" }, #endif { NULL, NULL, 0, NULL } }; Loading Loading @@ -101,13 +100,12 @@ static PyObject *module_init(void) Py_INCREF(&PyLeonObject_Type); PyModule_AddObject(m, module_name, (PyObject *) &PyLeonObject_Type); #if PY_MAJOR_VERSION >= 3 /* Register the Descr type */ PyStructSequence_InitType(&PyArrayDescObject_Type, &PyArrayDescObject_Desc); PyType_Ready(&PyArrayDescObject_Type); Py_INCREF(&PyArrayDescObject_Type); PyModule_AddObject(m, module_name, (PyObject *) &PyArrayDescObject_Type); #endif return m; } Loading src/shared_array.h +1 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define __SHARED_ARRAY_H__ #include <Python.h> #include <structseq.h> #include <numpy/arrayobject.h> /* Magic header */ Loading @@ -38,10 +39,8 @@ struct array_meta { } __attribute__ ((packed)); /* ArrayDesc object */ #if PY_MAJOR_VERSION >= 3 extern PyStructSequence_Desc PyArrayDescObject_Desc; extern PyTypeObject PyArrayDescObject_Type; #endif /* Leon object */ typedef struct { Loading @@ -56,8 +55,6 @@ extern PyTypeObject PyLeonObject_Type; extern PyObject *shared_array_create(PyObject *self, PyObject *args, PyObject *kw); extern PyObject *shared_array_attach(PyObject *self, PyObject *args); extern PyObject *shared_array_delete(PyObject *self, PyObject *args); #if PY_MAJOR_VERSION >= 3 extern PyObject *shared_array_list(PyObject *self, PyObject *args); #endif #endif /* !__SHARED_ARRAY_H__ */ src/shared_array_desc.c +1 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ #define NPY_NO_DEPRECATED_API NPY_1_8_API_VERSION #include <Python.h> #if PY_MAJOR_VERSION >= 3 #include <structseq.h> /* * List of fields Loading @@ -45,5 +44,3 @@ PyStructSequence_Desc PyArrayDescObject_Desc = { * Type definition */ PyTypeObject PyArrayDescObject_Type; #endif src/shared_array_list.c +5 −9 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ #define NO_IMPORT_ARRAY #include <Python.h> #if PY_MAJOR_VERSION >= 3 #include <structseq.h> #include <numpy/arrayobject.h> #include <sys/types.h> #include <sys/stat.h> Loading Loading @@ -89,7 +87,7 @@ static PyObject *convert_dims(int ndims, npy_intp *dims) int i; for (i = 0; i < ndims; i++) PyTuple_SetItem(tuple, i, PyLong_FromLong(dims[i])); PyTuple_SET_ITEM(tuple, i, PyLong_FromLong(dims[i])); return tuple; } Loading @@ -110,9 +108,9 @@ static struct list *list_extend(struct list *next, struct array_meta *meta, cons list->next = next; list->desc = PyStructSequence_New(&PyArrayDescObject_Type); PyStructSequence_SetItem(list->desc, 0, PyBytes_FromString(name)); PyStructSequence_SetItem(list->desc, 1, PyArray_TypeObjectFromType(meta->typenum)); PyStructSequence_SetItem(list->desc, 2, convert_dims(meta->ndims, meta->dims)); PyStructSequence_SET_ITEM(list->desc, 0, PyBytes_FromString(name)); PyStructSequence_SET_ITEM(list->desc, 1, PyArray_TypeObjectFromType(meta->typenum)); PyStructSequence_SET_ITEM(list->desc, 2, convert_dims(meta->ndims, meta->dims)); /* Return the new element */ return list; Loading Loading @@ -208,5 +206,3 @@ PyObject *shared_array_list(PyObject *self, PyObject *args) /* Return the tuple */ return tuple; } #endif Loading
src/shared_array.c +2 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define PY_ARRAY_UNIQUE_SYMBOL SHARED_ARRAY_ARRAY_API #include <Python.h> #include <structseq.h> #include <numpy/arrayobject.h> #include "shared_array.h" Loading Loading @@ -47,11 +48,9 @@ static PyMethodDef module_functions[] = { METH_VARARGS, "Delete an existing numpy array from shared memory" }, #if PY_MAJOR_VERSION >= 3 { "list", (PyCFunction) shared_array_list, METH_VARARGS, "List all existing numpy arrays from shared memory" }, #endif { NULL, NULL, 0, NULL } }; Loading Loading @@ -101,13 +100,12 @@ static PyObject *module_init(void) Py_INCREF(&PyLeonObject_Type); PyModule_AddObject(m, module_name, (PyObject *) &PyLeonObject_Type); #if PY_MAJOR_VERSION >= 3 /* Register the Descr type */ PyStructSequence_InitType(&PyArrayDescObject_Type, &PyArrayDescObject_Desc); PyType_Ready(&PyArrayDescObject_Type); Py_INCREF(&PyArrayDescObject_Type); PyModule_AddObject(m, module_name, (PyObject *) &PyArrayDescObject_Type); #endif return m; } Loading
src/shared_array.h +1 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define __SHARED_ARRAY_H__ #include <Python.h> #include <structseq.h> #include <numpy/arrayobject.h> /* Magic header */ Loading @@ -38,10 +39,8 @@ struct array_meta { } __attribute__ ((packed)); /* ArrayDesc object */ #if PY_MAJOR_VERSION >= 3 extern PyStructSequence_Desc PyArrayDescObject_Desc; extern PyTypeObject PyArrayDescObject_Type; #endif /* Leon object */ typedef struct { Loading @@ -56,8 +55,6 @@ extern PyTypeObject PyLeonObject_Type; extern PyObject *shared_array_create(PyObject *self, PyObject *args, PyObject *kw); extern PyObject *shared_array_attach(PyObject *self, PyObject *args); extern PyObject *shared_array_delete(PyObject *self, PyObject *args); #if PY_MAJOR_VERSION >= 3 extern PyObject *shared_array_list(PyObject *self, PyObject *args); #endif #endif /* !__SHARED_ARRAY_H__ */
src/shared_array_desc.c +1 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ #define NPY_NO_DEPRECATED_API NPY_1_8_API_VERSION #include <Python.h> #if PY_MAJOR_VERSION >= 3 #include <structseq.h> /* * List of fields Loading @@ -45,5 +44,3 @@ PyStructSequence_Desc PyArrayDescObject_Desc = { * Type definition */ PyTypeObject PyArrayDescObject_Type; #endif
src/shared_array_list.c +5 −9 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ #define NO_IMPORT_ARRAY #include <Python.h> #if PY_MAJOR_VERSION >= 3 #include <structseq.h> #include <numpy/arrayobject.h> #include <sys/types.h> #include <sys/stat.h> Loading Loading @@ -89,7 +87,7 @@ static PyObject *convert_dims(int ndims, npy_intp *dims) int i; for (i = 0; i < ndims; i++) PyTuple_SetItem(tuple, i, PyLong_FromLong(dims[i])); PyTuple_SET_ITEM(tuple, i, PyLong_FromLong(dims[i])); return tuple; } Loading @@ -110,9 +108,9 @@ static struct list *list_extend(struct list *next, struct array_meta *meta, cons list->next = next; list->desc = PyStructSequence_New(&PyArrayDescObject_Type); PyStructSequence_SetItem(list->desc, 0, PyBytes_FromString(name)); PyStructSequence_SetItem(list->desc, 1, PyArray_TypeObjectFromType(meta->typenum)); PyStructSequence_SetItem(list->desc, 2, convert_dims(meta->ndims, meta->dims)); PyStructSequence_SET_ITEM(list->desc, 0, PyBytes_FromString(name)); PyStructSequence_SET_ITEM(list->desc, 1, PyArray_TypeObjectFromType(meta->typenum)); PyStructSequence_SET_ITEM(list->desc, 2, convert_dims(meta->ndims, meta->dims)); /* Return the new element */ return list; Loading Loading @@ -208,5 +206,3 @@ PyObject *shared_array_list(PyObject *self, PyObject *args) /* Return the tuple */ return tuple; } #endif