From: erykoff Date: Tue, 22 Dec 2020 11:12:07 +0000 (-0800) Subject: bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868) X-Git-Tag: v3.10.0a4~109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3c77ecbbe0ad3e3cc6dbd885792203e9e6ec858;p=thirdparty%2FPython%2Fcpython.git bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868) Automerge-Triggered-By: GH:ronaldoussoren --- diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index 4f220e42ff3f..788bae6a96c7 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -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)