diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-09-05 18:25:59 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-09-05 18:25:59 (GMT) |
commit | 2decf22b9549a4034dc17006bd158870d22c3851 (patch) | |
tree | 5a1600b523be17a2241a0ef4ffb947843ffcd52e | |
parent | 713f2aa569c39aa72c18bd915ef21d16c1a9927c (diff) | |
download | cpython-2decf22b9549a4034dc17006bd158870d22c3851.zip cpython-2decf22b9549a4034dc17006bd158870d22c3851.tar.gz cpython-2decf22b9549a4034dc17006bd158870d22c3851.tar.bz2 |
Fix for issue9662, patch by Ćukasz Langa in issue5504.
-rw-r--r-- | Modules/_ctypes/callbacks.c | 4 | ||||
-rw-r--r-- | Modules/_ctypes/libffi_osx/include/ffi.h | 5 | ||||
-rw-r--r-- | Modules/_ctypes/malloc_closure.c | 3 | ||||
-rw-r--r-- | setup.py | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 8e137a0..88dad95 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -416,9 +416,13 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable, "ffi_prep_cif failed with %d", result); goto error; } +#if defined(X86_DARWIN) || defined(POWERPC_DARWIN) + result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p); +#else result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn, p, p->pcl_exec); +#endif if (result != FFI_OK) { PyErr_Format(PyExc_RuntimeError, "ffi_prep_closure failed with %d", result); diff --git a/Modules/_ctypes/libffi_osx/include/ffi.h b/Modules/_ctypes/libffi_osx/include/ffi.h index 3d39064..c104a5c 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi.h +++ b/Modules/_ctypes/libffi_osx/include/ffi.h @@ -264,6 +264,9 @@ ffi_prep_closure( void (*fun)(ffi_cif*,void*,void**,void*), void* user_data); +void ffi_closure_free(void *); +void *ffi_closure_alloc (size_t size, void **code); + typedef struct ffi_raw_closure { char tramp[FFI_TRAMPOLINE_SIZE]; ffi_cif* cif; @@ -349,4 +352,4 @@ ffi_call( } #endif -#endif // #ifndef LIBFFI_H
\ No newline at end of file +#endif // #ifndef LIBFFI_H diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index 519941b..248c6a6 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -106,7 +106,6 @@ void *ffi_closure_alloc(size_t ignored, void** codeloc) return NULL; item = free_list; free_list = item->next; - *codeloc = (void *)item; + *codeloc = (void *)item; return (void *)item; } - @@ -1657,6 +1657,7 @@ class PyBuildExt(build_ext): depends = ['_ctypes/ctypes.h'] if sys.platform == 'darwin': + sources.append('_ctypes/malloc_closure.c') sources.append('_ctypes/darwin/dlfcn_simple.c') extra_compile_args.append('-DMACOSX') include_dirs.append('_ctypes/darwin') |