mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-25 03:06:11 +08:00
* 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.
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user