diff options
author | Tom Tromey <tromey@redhat.com> | 2008-11-21 14:59:56 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2008-11-21 14:59:56 +0000 |
commit | ca30a76297419a1e0eac2ee6a709dff70d30e56a (patch) | |
tree | e13c237992ce5984085aee7f424db45b05c1dab9 /gdb/python/python-utils.c | |
parent | 3c9ab205d3020ddcb720946b4b7b1b6cc8de7bcb (diff) | |
download | gdb-ca30a76297419a1e0eac2ee6a709dff70d30e56a.zip gdb-ca30a76297419a1e0eac2ee6a709dff70d30e56a.tar.gz gdb-ca30a76297419a1e0eac2ee6a709dff70d30e56a.tar.bz2 |
* 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.
Diffstat (limited to 'gdb/python/python-utils.c')
-rw-r--r-- | gdb/python/python-utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
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. |