From ca30a76297419a1e0eac2ee6a709dff70d30e56a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 21 Nov 2008 14:59:56 +0000 Subject: * python/python-internal.h (PyGILState_Ensure): New define. (PyGILState_Release): Likewise. (PyEval_InitThreads): Likewise. (PyThreadState_Swap): Likewise. (PyEval_InitThreads): Likewise. * python/python.c (_initialize_python): Initialize threads. Release GIL. (eval_python_from_control_command): Acquire GIL. (python_command): Likewise. * python/python-internal.h (make_cleanup_py_restore_gil): Declare. * python/python-utils.c (py_gil_restore): New function. (make_cleanup_py_restore_gil): Likewise. --- gdb/python/python-utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gdb/python/python-utils.c') diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c index 912845f..8db81ec 100644 --- a/gdb/python/python-utils.c +++ b/gdb/python/python-utils.c @@ -46,6 +46,23 @@ make_cleanup_py_decref (PyObject *py) return make_cleanup (py_decref, (void *) py); } +/* A cleanup function to restore the thread state. */ + +static void +py_gil_restore (void *p) +{ + PyGILState_STATE *state = p; + PyGILState_Release (*state); +} + +/* Return a new cleanup which will restore the Python GIL state. */ + +struct cleanup * +make_cleanup_py_restore_gil (PyGILState_STATE *state) +{ + return make_cleanup (py_gil_restore, state); +} + /* Converts a Python 8-bit string to a unicode string object. Assumes the 8-bit string is in the host charset. If an error occurs during conversion, returns NULL with a python exception set. -- cgit v1.1