summaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2020-11-24 10:38:11 +0100
committerArmin Rigo <arigo@tunes.org>2020-11-24 10:38:11 +0100
commit097bc56353a9084b10e30de94b8f0f12487b2784 (patch)
tree85c0edbbfbe51a852bd72196dd35919d17c24828 /c
parentc607b3813de87f6b0d67d39a3e6f36095b792e8b (diff)
downloadcffi-097bc56353a9084b10e30de94b8f0f12487b2784.tar.gz
fix for yet another way in which old libffi's are not compatible with new libffi's
Diffstat (limited to 'c')
-rw-r--r--c/_cffi_backend.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 578e59f..81d2651 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -90,6 +90,7 @@
#ifdef __NetBSD__
# define CFFI_CHECK_FFI_CLOSURE_ALLOC 1
+# define CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE 1
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC 1
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC_MAYBE 1
# define CFFI_CHECK_FFI_PREP_CIF_VAR 0
@@ -98,6 +99,7 @@
#elif defined(__APPLE__) && defined(FFI_AVAILABLE_APPLE)
# define CFFI_CHECK_FFI_CLOSURE_ALLOC __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
+# define CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE 1
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC_MAYBE 1
# define CFFI_CHECK_FFI_PREP_CIF_VAR __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
@@ -106,6 +108,7 @@
#else
# define CFFI_CHECK_FFI_CLOSURE_ALLOC 0
+# define CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE 0
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC 0
# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC_MAYBE 0
# define CFFI_CHECK_FFI_PREP_CIF_VAR 0
@@ -1915,11 +1918,12 @@ static void cdataowninggc_dealloc(CDataObject *cd)
ffi_closure *closure = ((CDataObject_closure *)cd)->closure;
PyObject *args = (PyObject *)(closure->user_data);
Py_XDECREF(args);
+#if CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE
if (CFFI_CHECK_FFI_CLOSURE_ALLOC) {
ffi_closure_free(closure);
- } else {
+ } else
+#endif
cffi_closure_free(closure);
- }
}
else {
Py_FatalError("cdata CDataOwningGC_Type with unexpected type flags");
@@ -6283,9 +6287,12 @@ static PyObject *b_callback(PyObject *self, PyObject *args)
if (infotuple == NULL)
return NULL;
+#if CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE
if (CFFI_CHECK_FFI_CLOSURE_ALLOC) {
closure = ffi_closure_alloc(sizeof(ffi_closure), &closure_exec);
- } else {
+ } else
+#endif
+ {
closure = cffi_closure_alloc();
closure_exec = closure;
}
@@ -6373,12 +6380,13 @@ static PyObject *b_callback(PyObject *self, PyObject *args)
error:
closure->user_data = NULL;
if (cd == NULL) {
+#if CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE
if (CFFI_CHECK_FFI_CLOSURE_ALLOC) {
ffi_closure_free(closure);
}
- else {
+ else
+#endif
cffi_closure_free(closure);
- }
}
else
Py_DECREF(cd);