diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-01-31 21:15:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 00:15:23 -0500 |
commit | 7e729978fa08a360cbf936dc215ba7dd25a06a08 (patch) | |
tree | 9631fb378a61aeb18602da99bf7773bb0adaad79 | |
parent | bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string... (diff) | |
download | cpython-7e729978fa08a360cbf936dc215ba7dd25a06a08.tar.gz cpython-7e729978fa08a360cbf936dc215ba7dd25a06a08.tar.bz2 cpython-7e729978fa08a360cbf936dc215ba7dd25a06a08.zip |
bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868) (GH-23888)
Automerge-Triggered-By: GH:ronaldoussoren
(cherry picked from commit b3c77ecbbe0ad3e3cc6dbd885792203e9e6ec858)
Co-authored-by: erykoff <erykoff@stanford.edu>
-rw-r--r-- | Modules/_ctypes/malloc_closure.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index 4f220e42ff3..788bae6a96c 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -91,12 +91,16 @@ 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; free_list = item; @@ -105,11 +109,15 @@ 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) more_core(); |