]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 1 Feb 2021 05:15:23 +0000 (21:15 -0800)
committerGitHub <noreply@github.com>
Mon, 1 Feb 2021 05:15:23 +0000 (00:15 -0500)
Automerge-Triggered-By: GH:ronaldoussoren
(cherry picked from commit b3c77ecbbe0ad3e3cc6dbd885792203e9e6ec858)

Co-authored-by: erykoff <erykoff@stanford.edu>
Modules/_ctypes/malloc_closure.c

index 4f220e42ff3fccb45f4c5c95acfcd2b0072312b2..788bae6a96c7f4a8558f8ef3f34c01c747e659fd 100644 (file)
@@ -91,11 +91,15 @@ static void more_core(void)
 /* put the item back into the free list */
 void Py_ffi_closure_free(void *p)
 {
-#if USING_APPLE_OS_LIBFFI && HAVE_FFI_CLOSURE_ALLOC
+#if HAVE_FFI_CLOSURE_ALLOC
+#if USING_APPLE_OS_LIBFFI
     if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
+#endif
         ffi_closure_free(p);
         return;
+#if USING_APPLE_OS_LIBFFI
     }
+#endif
 #endif
     ITEM *item = (ITEM *)p;
     item->next = free_list;
@@ -105,10 +109,14 @@ void Py_ffi_closure_free(void *p)
 /* return one item from the free list, allocating more if needed */
 void *Py_ffi_closure_alloc(size_t size, void** codeloc)
 {
-#if USING_APPLE_OS_LIBFFI && HAVE_FFI_CLOSURE_ALLOC
+#if HAVE_FFI_CLOSURE_ALLOC
+#if USING_APPLE_OS_LIBFFI
     if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
+#endif
         return ffi_closure_alloc(size, codeloc);
+#if USING_APPLE_OS_LIBFFI
     }
+#endif
 #endif
     ITEM *item;
     if (!free_list)