diff options
author | Armin Rigo <arigo@tunes.org> | 2022-12-24 14:13:11 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2022-12-24 14:13:11 +0100 |
commit | ce7d85d713215f2c97c32c81f50753f290fbe977 (patch) | |
tree | 77c3ddfe9205b03ae68716116be10b2cf48c37d0 | |
parent | a8439665e6bc075f85f58d4edb40ca34f4eaa8e6 (diff) | |
parent | 7aecd67547c025a8c146569d5f0c3bd22ec72718 (diff) | |
download | cffi-ce7d85d713215f2c97c32c81f50753f290fbe977.tar.gz |
merge branch "hppa" !118
Fix the test failures on hppa. Thanks Stefano Rivera
-rw-r--r-- | c/_cffi_backend.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c index d2dc76c..fd71ede 100644 --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -60,6 +60,13 @@ # endif #endif +/* Convert from closure pointer to function pointer. */ +#if defined(__hppa__) && !defined(__LP64__) +#define CFFI_CLOSURE_TO_FNPTR(type, f) ((type)((unsigned int)(f) | 2)) +#else +#define CFFI_CLOSURE_TO_FNPTR(type, f) ((type)(f)) +#endif + /* Define the following macro ONLY if you trust libffi's version of * ffi_closure_alloc() more than the code in malloc_closure.h. @@ -3191,7 +3198,7 @@ cdata_call(CDataObject *cd, PyObject *args, PyObject *kwds) Py_BEGIN_ALLOW_THREADS restore_errno(); - ffi_call(&cif_descr->cif, (void (*)(void))(cd->c_data), + ffi_call(&cif_descr->cif, CFFI_CLOSURE_TO_FNPTR(void (*)(void), cd->c_data), resultdata, buffer_array); save_errno(); Py_END_ALLOW_THREADS @@ -6394,7 +6401,7 @@ static PyObject *b_callback(PyObject *self, PyObject *args) goto error; Py_INCREF(ct); cd->head.c_type = ct; - cd->head.c_data = (char *)closure_exec; + cd->head.c_data = CFFI_CLOSURE_TO_FNPTR(char *, closure_exec); cd->head.c_weakreflist = NULL; closure->user_data = NULL; cd->closure = closure; |