Skip to content

Commit b3c77ec

Browse files
authored
bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868)
Automerge-Triggered-By: GH:ronaldoussoren
1 parent fbc7723 commit b3c77ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Modules/_ctypes/malloc_closure.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ static void more_core(void)
9191
/* put the item back into the free list */
9292
void Py_ffi_closure_free(void *p)
9393
{
94-
#if USING_APPLE_OS_LIBFFI && HAVE_FFI_CLOSURE_ALLOC
94+
#if HAVE_FFI_CLOSURE_ALLOC
95+
#if USING_APPLE_OS_LIBFFI
9596
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
97+
#endif
9698
ffi_closure_free(p);
9799
return;
100+
#if USING_APPLE_OS_LIBFFI
98101
}
102+
#endif
99103
#endif
100104
ITEM *item = (ITEM *)p;
101105
item->next = free_list;
@@ -105,10 +109,14 @@ void Py_ffi_closure_free(void *p)
105109
/* return one item from the free list, allocating more if needed */
106110
void *Py_ffi_closure_alloc(size_t size, void** codeloc)
107111
{
108-
#if USING_APPLE_OS_LIBFFI && HAVE_FFI_CLOSURE_ALLOC
112+
#if HAVE_FFI_CLOSURE_ALLOC
113+
#if USING_APPLE_OS_LIBFFI
109114
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
115+
#endif
110116
return ffi_closure_alloc(size, codeloc);
117+
#if USING_APPLE_OS_LIBFFI
111118
}
119+
#endif
112120
#endif
113121
ITEM *item;
114122
if (!free_list)

0 commit comments

Comments
 (0)