pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/devel/py-cffi Use libffi's closure handling based on c...
details: https://anonhg.NetBSD.org/pkgsrc/rev/db36da9c402a
branches: trunk
changeset: 364708:db36da9c402a
user: joerg <joerg%pkgsrc.org@localhost>
date: Mon Jul 03 18:17:45 2017 +0000
description:
Use libffi's closure handling based on code from the upstream branch.
Adjust test cases to not use alloca.h on NetBSD. Use a temporary
directory under WRKDIR and allow C++ when test builds are requested.
diffstat:
devel/py-cffi/Makefile | 19 +-
devel/py-cffi/distinfo | 6 +-
devel/py-cffi/patches/patch-c___cffi__backend.c | 131 +++++++++++++
devel/py-cffi/patches/patch-c_malloc__closure.h | 15 -
devel/py-cffi/patches/patch-testing_cffi0_test__verify.py | 13 +
devel/py-cffi/patches/patch-testing_cffi1_test__verify1.py | 13 +
6 files changed, 175 insertions(+), 22 deletions(-)
diffs (240 lines):
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/Makefile
--- a/devel/py-cffi/Makefile Mon Jul 03 18:14:40 2017 +0000
+++ b/devel/py-cffi/Makefile Mon Jul 03 18:17:45 2017 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.26 2017/07/03 11:08:29 wiz Exp $
+# $NetBSD: Makefile,v 1.27 2017/07/03 18:17:45 joerg Exp $
DISTNAME= cffi-1.10.0
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
+PKGREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_PYPI:=c/cffi/}
@@ -16,11 +17,19 @@
DEPENDS+= ${PYPKGPREFIX}-cparser-[0-9]*:../../devel/py-cparser
BUILD_DEPENDS+= ${PYPKGPREFIX}-test-[0-9]*:../../devel/py-test
-# needs 'make install' before running the tests
-# many segfaults and 6 other test failures
-# https://bitbucket.org/cffi/cffi/issues/321/cffi-191-segmentation-fault-during-self
+DISTUTILS_BUILDDIR_IN_TEST_ENV= yes
+
+USE_LANGUAGES= c
+
+.if !empty(PKGSRC_RUN_TEST:M[yY][eE][sS])
+USE_LANGUAGES+= c++
+.endif
+
+TEST_ENV+= TMPDIR=${WRKDIR}/tmp
+
do-test:
- cd ${WRKSRC} && py.test-${PYVERSSUFFIX} -v -k "not test_callback and not test_a_lot_of_callbacks and not test_wchar and not test_errno_callback and not test_functionptr_simple and not
test_functionptr_voidptr_return and not test_functionptr_intptr_return and not test_functionptr_void_return and not test_cast_functionptr_and_int and not test_structptr_argument and not
test_array_argument_as_list and not test_array_of_func_ptr and not test_function_pointer and not test_access_callback and not test_win32_calling_convention_0 and not test_ffi_callback and not
test_array_length_from_constant and not test_some_integer_type_for_issue73 and not test_macro_var_callback"
+ ${MKDIR} ${WRKDIR}/tmp
+ cd ${WRKSRC} && ${PKGSRC_SETENV} ${TEST_ENV} ${PREFIX}/bin/py.test-${PYVERSSUFFIX} -v
.include "../../devel/libffi/buildlink3.mk"
.include "../../lang/python/egg.mk"
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/distinfo
--- a/devel/py-cffi/distinfo Mon Jul 03 18:14:40 2017 +0000
+++ b/devel/py-cffi/distinfo Mon Jul 03 18:17:45 2017 +0000
@@ -1,7 +1,9 @@
-$NetBSD: distinfo,v 1.23 2017/04/05 15:54:26 wiz Exp $
+$NetBSD: distinfo,v 1.24 2017/07/03 18:17:45 joerg Exp $
SHA1 (cffi-1.10.0.tar.gz) = 8484aba03d1e64367d3110c0e36c1ed052b43f12
RMD160 (cffi-1.10.0.tar.gz) = 8bcdd03716d70fed5a7c25fd0371572356b36aab
SHA512 (cffi-1.10.0.tar.gz) = 02c9987c44698708dcb7e0aa17637df6b15f81732dc25b03e54563ca5664a817863b87daf7a782a62c7b6150388cdca858ef496a975ab289c86f05e5492465ef
Size (cffi-1.10.0.tar.gz) = 418131 bytes
-SHA1 (patch-c_malloc__closure.h) = d169a2ebdf899b5b67a714a068749ce25087be8a
+SHA1 (patch-c___cffi__backend.c) = e06cb7fd3eef875ba1176ba8ac9d7c1cad229ccf
+SHA1 (patch-testing_cffi0_test__verify.py) = 9097ed364176f968d8c5084e1bc3d3d368d92714
+SHA1 (patch-testing_cffi1_test__verify1.py) = 64a0c7073a446dd4ca7cd97086646959ad4fad08
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/patches/patch-c___cffi__backend.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/py-cffi/patches/patch-c___cffi__backend.c Mon Jul 03 18:17:45 2017 +0000
@@ -0,0 +1,131 @@
+$NetBSD: patch-c___cffi__backend.c,v 1.1 2017/07/03 18:17:45 joerg Exp $
+
+--- c/_cffi_backend.c.orig 2017-03-21 10:41:29.000000000 +0000
++++ c/_cffi_backend.c
+@@ -60,8 +60,6 @@
+ # endif
+ #endif
+
+-#include "malloc_closure.h"
+-
+ #if PY_MAJOR_VERSION >= 3
+ # define STR_OR_BYTES "bytes"
+ # define PyText_Type PyUnicode_Type
+@@ -256,6 +254,11 @@ typedef struct {
+ } CDataObject_gcp;
+
+ typedef struct {
++ CDataObject head;
++ ffi_closure *closure;
++} CDataObject_closure;
++
++typedef struct {
+ ffi_cif cif;
+ /* the following information is used when doing the call:
+ - a buffer of size 'exchange_size' is malloced
+@@ -1678,10 +1681,10 @@ static void cdataowninggc_dealloc(CDataO
+ Py_DECREF(x);
+ }
+ else if (cd->c_type->ct_flags & CT_FUNCTIONPTR) { /* a callback */
+- ffi_closure *closure = (ffi_closure *)cd->c_data;
+- PyObject *args = (PyObject *)(closure->user_data);
++ ffi_closure *closure = ((CDataObject_closure *)cd)->closure;
++ PyObject *args = (PyObject *)closure->user_data;
+ Py_XDECREF(args);
+- cffi_closure_free(closure);
++ ffi_closure_free(closure);
+ }
+ else if (cd->c_type->ct_flags & CT_IS_UNSIZED_CHAR_A) { /* from_buffer */
+ Py_buffer *view = ((CDataObject_owngc_frombuf *)cd)->bufferview;
+@@ -1698,8 +1701,8 @@ static int cdataowninggc_traverse(CDataO
+ Py_VISIT(x);
+ }
+ else if (cd->c_type->ct_flags & CT_FUNCTIONPTR) { /* a callback */
+- ffi_closure *closure = (ffi_closure *)cd->c_data;
+- PyObject *args = (PyObject *)(closure->user_data);
++ ffi_closure *closure = ((CDataObject_closure *)cd)->closure;
++ PyObject *args = (PyObject *)closure->user_data;
+ Py_VISIT(args);
+ }
+ else if (cd->c_type->ct_flags & CT_IS_UNSIZED_CHAR_A) { /* from_buffer */
+@@ -1719,8 +1722,8 @@ static int cdataowninggc_clear(CDataObje
+ Py_DECREF(x);
+ }
+ else if (cd->c_type->ct_flags & CT_FUNCTIONPTR) { /* a callback */
+- ffi_closure *closure = (ffi_closure *)cd->c_data;
+- PyObject *args = (PyObject *)(closure->user_data);
++ ffi_closure *closure = ((CDataObject_closure *)cd)->closure;
++ PyObject *args = (PyObject *)closure->user_data;
+ closure->user_data = NULL;
+ Py_XDECREF(args);
+ }
+@@ -1925,7 +1928,8 @@ static PyObject *cdataowninggc_repr(CDat
+ return _cdata_repr2(cd, "handle to", x);
+ }
+ else if (cd->c_type->ct_flags & CT_FUNCTIONPTR) { /* a callback */
+- PyObject *args = (PyObject *)((ffi_closure *)cd->c_data)->user_data;
++ ffi_closure *closure = ((CDataObject_closure *)cd)->closure;
++ PyObject *args = (PyObject *)closure->user_data;
+ if (args == NULL)
+ return cdata_repr(cd);
+ else
+@@ -5488,11 +5492,12 @@ static PyObject *prepare_callback_info_t
+ static PyObject *b_callback(PyObject *self, PyObject *args)
+ {
+ CTypeDescrObject *ct;
+- CDataObject *cd;
++ CDataObject_closure *cd;
+ PyObject *ob, *error_ob = Py_None, *onerror_ob = Py_None;
+ PyObject *infotuple;
+ cif_description_t *cif_descr;
+ ffi_closure *closure;
++ void *closure_exec;
+
+ if (!PyArg_ParseTuple(args, "O!O|OO:callback", &CTypeDescr_Type, &ct, &ob,
+ &error_ob, &onerror_ob))
+@@ -5502,15 +5507,20 @@ static PyObject *b_callback(PyObject *se
+ if (infotuple == NULL)
+ return NULL;
+
+- closure = cffi_closure_alloc();
++ closure = ffi_closure_alloc(sizeof(ffi_closure), &closure_exec);
++ if (closure == NULL) {
++ Py_DECREF(infotuple);
+
+- cd = PyObject_GC_New(CDataObject, &CDataOwningGC_Type);
++ return NULL;
++ }
++ cd = PyObject_GC_New(CDataObject_closure, &CDataOwningGC_Type);
+ if (cd == NULL)
+ goto error;
+ Py_INCREF(ct);
+- cd->c_type = ct;
+- cd->c_data = (char *)closure;
+- cd->c_weakreflist = NULL;
++ cd->head.c_type = ct;
++ cd->head.c_data = (char *)closure_exec;
++ cd->head.c_weakreflist = NULL;
++ cd->closure = closure;
+ PyObject_GC_Track(cd);
+
+ cif_descr = (cif_description_t *)ct->ct_extra;
+@@ -5520,8 +5530,8 @@ static PyObject *b_callback(PyObject *se
+ "return type or with '...'", ct->ct_name);
+ goto error;
+ }
+- if (ffi_prep_closure(closure, &cif_descr->cif,
+- invoke_callback, infotuple) != FFI_OK) {
++ if (ffi_prep_closure_loc(closure, &cif_descr->cif,
++ invoke_callback, infotuple, closure_exec) != FFI_OK) {
+ PyErr_SetString(PyExc_SystemError,
+ "libffi failed to build this callback");
+ goto error;
+@@ -5545,7 +5555,7 @@ static PyObject *b_callback(PyObject *se
+ error:
+ closure->user_data = NULL;
+ if (cd == NULL)
+- cffi_closure_free(closure);
++ ffi_closure_free(closure);
+ else
+ Py_DECREF(cd);
+ Py_XDECREF(infotuple);
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/patches/patch-c_malloc__closure.h
--- a/devel/py-cffi/patches/patch-c_malloc__closure.h Mon Jul 03 18:14:40 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-$NetBSD: patch-c_malloc__closure.h,v 1.2 2016/11/14 14:31:18 wiz Exp $
-
-Handle PaX/MPROTECT
-
---- c/malloc_closure.h.orig 2016-09-21 22:53:05.889258675 -0400
-+++ c/malloc_closure.h 2016-09-21 22:53:47.057812777 -0400
-@@ -57,6 +57,8 @@
-
- #define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
- : (emutramp_enabled = emutramp_enabled_check ()))
-+#elif defined(__NetBSD__)
-+#define is_emutramp_enabled() 1 /* We have PaX MPROTECT, no point in checking if it is enabled! */
- #else
- #define is_emutramp_enabled() 0
- #endif
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/patches/patch-testing_cffi0_test__verify.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/py-cffi/patches/patch-testing_cffi0_test__verify.py Mon Jul 03 18:17:45 2017 +0000
@@ -0,0 +1,13 @@
+$NetBSD: patch-testing_cffi0_test__verify.py,v 1.1 2017/07/03 18:17:45 joerg Exp $
+
+--- testing/cffi0/test_verify.py.orig 2017-07-03 17:44:02.180970759 +0000
++++ testing/cffi0/test_verify.py
+@@ -1798,7 +1798,7 @@ def test_callback_indirection():
+ #include <malloc.h>
+ #define alloca _alloca
+ #else
+- # ifdef __FreeBSD__
++ # if defined(__FreeBSD__) || defined(__NetBSD__)
+ # include <stdlib.h>
+ # else
+ # include <alloca.h>
diff -r 54b6e28bde96 -r db36da9c402a devel/py-cffi/patches/patch-testing_cffi1_test__verify1.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/py-cffi/patches/patch-testing_cffi1_test__verify1.py Mon Jul 03 18:17:45 2017 +0000
@@ -0,0 +1,13 @@
+$NetBSD: patch-testing_cffi1_test__verify1.py,v 1.1 2017/07/03 18:17:45 joerg Exp $
+
+--- testing/cffi1/test_verify1.py.orig 2017-07-03 17:44:21.313824096 +0000
++++ testing/cffi1/test_verify1.py
+@@ -1767,7 +1767,7 @@ def test_callback_indirection():
+ #include <malloc.h>
+ #define alloca _alloca
+ #else
+- # ifdef __FreeBSD__
++ # if defined(__FreeBSD__) || defined(__NetBSD__)
+ # include <stdlib.h>
+ # else
+ # include <alloca.h>
Home |
Main Index |
Thread Index |
Old Index