bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868)

Automerge-Triggered-By: GH:ronaldoussoren
This commit is contained in:
erykoff 2020-12-22 03:12:07 -08:00 committed by GitHub
parent fbc7723778
commit b3c77ecbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -91,11 +91,15 @@ static void more_core(void)
/* put the item back into the free list */ /* put the item back into the free list */
void Py_ffi_closure_free(void *p) 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, *)) { if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
#endif
ffi_closure_free(p); ffi_closure_free(p);
return; return;
#if USING_APPLE_OS_LIBFFI
} }
#endif
#endif #endif
ITEM *item = (ITEM *)p; ITEM *item = (ITEM *)p;
item->next = free_list; 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 */ /* return one item from the free list, allocating more if needed */
void *Py_ffi_closure_alloc(size_t size, void** codeloc) 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, *)) { if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
#endif
return ffi_closure_alloc(size, codeloc); return ffi_closure_alloc(size, codeloc);
#if USING_APPLE_OS_LIBFFI
} }
#endif
#endif #endif
ITEM *item; ITEM *item;
if (!free_list) if (!free_list)