From 6aa63b08263172a979012747497f4207cc341bb0 Mon Sep 17 00:00:00 2001 From: Lucia Li Date: Mon, 8 Nov 2021 21:45:14 +0800 Subject: Upgrade cffi from 1.12.2 to 1.15.0 Source is fetched from https://foss.heptapod.net/pypy/cffi/-/archive/branch/release-1.15/cffi-branch-release-1.15.zip Build cffi manually and update Android.bp Bug: 205265538 Test: None Change-Id: I91a5ed3b96029b3988602aba6a00c0e0748d0600 --- c/lib_obj.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'c/lib_obj.c') diff --git a/c/lib_obj.c b/c/lib_obj.c index 7cd40ec..38bf3d5 100644 --- a/c/lib_obj.c +++ b/c/lib_obj.c @@ -29,6 +29,7 @@ struct LibObject_s { PyObject *l_libname; /* some string that gives the name of the lib */ FFIObject *l_ffi; /* reference back to the ffi object */ void *l_libhandle; /* the dlopen()ed handle, if any */ + int l_auto_close; /* if we must dlclose() this handle */ }; static struct CPyExtFunc_s *_cpyextfunc_get(PyObject *x) @@ -91,7 +92,8 @@ static void *cdlopen_fetch(PyObject *libname, void *libhandle, static void lib_dealloc(LibObject *lib) { PyObject_GC_UnTrack(lib); - cdlopen_close_ignore_errors(lib->l_libhandle); + if (lib->l_auto_close) + cdlopen_close_ignore_errors(lib->l_libhandle); Py_DECREF(lib->l_dict); Py_DECREF(lib->l_libname); Py_DECREF(lib->l_ffi); @@ -587,7 +589,7 @@ static PyMethodDef lib_methods[] = { static PyTypeObject Lib_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "CompiledLib", + "_cffi_backend.Lib", sizeof(LibObject), 0, (destructor)lib_dealloc, /* tp_dealloc */ @@ -624,7 +626,7 @@ static PyTypeObject Lib_Type = { }; static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, - void *dlopen_libhandle) + void *dlopen_libhandle, int auto_close) { LibObject *lib; PyObject *libname, *dict; @@ -647,6 +649,7 @@ static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, Py_INCREF(ffi); lib->l_ffi = ffi; lib->l_libhandle = dlopen_libhandle; + lib->l_auto_close = auto_close; return lib; err3: @@ -654,7 +657,8 @@ static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, err2: Py_DECREF(libname); err1: - cdlopen_close_ignore_errors(dlopen_libhandle); + if (auto_close) + cdlopen_close_ignore_errors(dlopen_libhandle); return NULL; } -- cgit v1.2.3